Fawry.Net
1.0.1
dotnet add package Fawry.Net --version 1.0.1
NuGet\Install-Package Fawry.Net -Version 1.0.1
<PackageReference Include="Fawry.Net" Version="1.0.1" />
<PackageVersion Include="Fawry.Net" Version="1.0.1" />
<PackageReference Include="Fawry.Net" />
paket add Fawry.Net --version 1.0.1
#r "nuget: Fawry.Net, 1.0.1"
#:package Fawry.Net@1.0.1
#addin nuget:?package=Fawry.Net&version=1.0.1
#tool nuget:?package=Fawry.Net&version=1.0.1
Fawry.Net
The missing .NET SDK for Fawry — Egypt's largest payment network.
Create Pay-at-Fawry reference numbers (cash at 300k+ outlets), charge cards (immediate or authorize-then-capture), take mobile-wallet payments, capture and cancel authorizations, and verify payment callbacks. Request signing follows Fawry's official documentation exactly — you never hand-roll a signature again.
Targets netstandard2.0 and net8.0. Only System.Text.Json (+ DI abstractions).
Bring your own HttpClient.
Install
dotnet add package Fawry.Net
Or clone and reference the project:
git clone https://github.com/SENESO/Fawry.Net.git
Quickstart
using Fawry;
using Fawry.Models;
var client = new FawryClient(new FawryClientOptions
{
MerchantCode = "<your-merchant-code>",
SecureKey = "<your-secure-key>",
// BaseUrl defaults to staging. Go live with:
// BaseUrl = FawryClientOptions.ProductionBaseUrl
});
// Pay-at-Fawry: customer pays cash at any outlet with the reference number
var charge = await client.ChargePayAtFawryAsync(new ChargeRequest
{
MerchantRefNum = Guid.NewGuid().ToString("N"), // unique per charge
CustomerName = "Ahmed Ali",
CustomerMobile = "01234567891",
CustomerEmail = "ahmed@example.com",
Amount = 580.55m,
ChargeItems =
{
new ChargeItem { ItemId = "sku-1", Description = "Blue T-shirt", Price = 580.55m, Quantity = 1 }
}
});
Console.WriteLine(charge.ReferenceNumber); // <-- customer pays with this
API reference
Charges
// Pay-at-Fawry (cash at outlets)
Task<ChargeResponse> ChargePayAtFawryAsync(ChargeRequest request, CancellationToken ct = default)
// Mobile wallet (e.g. Vodafone Cash) — customer approves on their phone
Task<ChargeResponse> ChargeMobileWalletAsync(ChargeRequest request, CancellationToken ct = default)
// Card payment. Set AuthCaptureMode = true to authorize now and capture later.
Task<ChargeResponse> ChargeCardAsync(CardChargeRequest request, CancellationToken ct = default)
Card example (authorize now, capture on shipment):
var auth = await client.ChargeCardAsync(new CardChargeRequest
{
MerchantRefNum = Guid.NewGuid().ToString("N"),
CustomerName = "Ahmed Ali",
CustomerMobile = "01234567891",
CustomerEmail = "ahmed@example.com",
Amount = 1200.00m,
CardNumber = "4242424242424242",
CardExpiryYear = "27",
CardExpiryMonth = "05",
Cvv = "123",
AuthCaptureMode = true, // hold the funds, capture later
ChargeItems = { new ChargeItem { ItemId = "sku-2", Description = "Laptop", Price = 1200.00m, Quantity = 1 } }
});
// ... when you ship:
var capture = await client.CaptureAsync(auth.MerchantRefNumber); // full amount
var partial = await client.CaptureAsync(auth.MerchantRefNumber, 800.00m); // partial
// or release the hold:
var cancel = await client.CancelAuthorizationAsync(auth.MerchantRefNumber);
Callbacks — always verify
[HttpPost("api/fawry/callback")]
public IActionResult Callback([FromBody] ChargeResponse callback)
{
if (!client.VerifyCallbackSignature(callback))
return Unauthorized(); // constant-time SHA-256 comparison
if (callback.IsPaid)
{
// fulfill order callback.MerchantRefNumber ...
}
return Ok();
}
Never trust callback query params alone — verify the signature first.
ASP.NET Core DI
services.AddFawry(options =>
{
options.MerchantCode = builder.Configuration["Fawry:MerchantCode"];
options.SecureKey = builder.Configuration["Fawry:SecureKey"];
options.BaseUrl = FawryClientOptions.ProductionBaseUrl;
});
// then inject FawryClient anywhere
Errors
Non-200 responses throw FawryApiException with StatusCode
(e.g. "9946" = blank or invalid signature), StatusDescription,
and the raw ResponseBody.
Staging vs production
| Environment | Base URL |
|---|---|
| Staging (default) | https://atfawry.fawrystaging.com |
| Production | https://www.atfawry.com |
Set FawryClientOptions.BaseUrl accordingly. Test credentials come from the
FawryPay team during account setup.
Notes & honesty
- Signature recipes were taken from Fawry's official docs (developer.fawrystaging.com, "Authorize and Capture Payments" + charge API pages, verified Oct 2026). Card charges use the card-inclusive recipe from those docs.
- Amounts are sent as two-decimal strings (
"580.55"), matching Fawry's own examples, so the signed value is always exactly what is sent. ChargeResponse.ShippingFeesis included for callback verification but is rarely populated by Fawry.FawryPaymentMethods.Valuis defined for completeness; dedicated ValU flows are not wrapped yet (the charge recipe is identical — open an issue if you need it).
License
MIT — see LICENSE.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- System.Text.Json (>= 8.0.5)
-
net8.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- System.Text.Json (>= 8.0.5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
NuGet polish release: branded package icon, embedded README, and full repository metadata.