SENESO.Paymob.Net
1.0.2
dotnet add package SENESO.Paymob.Net --version 1.0.2
NuGet\Install-Package SENESO.Paymob.Net -Version 1.0.2
<PackageReference Include="SENESO.Paymob.Net" Version="1.0.2" />
<PackageVersion Include="SENESO.Paymob.Net" Version="1.0.2" />
<PackageReference Include="SENESO.Paymob.Net" />
paket add SENESO.Paymob.Net --version 1.0.2
#r "nuget: SENESO.Paymob.Net, 1.0.2"
#:package SENESO.Paymob.Net@1.0.2
#addin nuget:?package=SENESO.Paymob.Net&version=1.0.2
#tool nuget:?package=SENESO.Paymob.Net&version=1.0.2
Paymob.Net
The missing .NET SDK for Paymob — Egypt's leading payment gateway.
using Paymob;
using Paymob.Models;
var client = new PaymobClient(new PaymobClientOptions
{
ApiKey = "<your-api-key>",
HmacSecret = "<your-hmac-secret>" // for webhook validation
});
// One call: auth → order → payment key → iframe URL
var checkout = await client.CreateCheckoutAsync(new CheckoutRequest
{
AmountCents = 50000, // 500.00 EGP
Currency = "EGP",
MerchantOrderId = "order-123",
IntegrationId = 123456, // card / wallet integration from the dashboard
IframeId = 789012,
BillingData = new BillingData
{
FirstName = "Ahmed",
LastName = "Hassan",
Email = "ahmed@example.com",
PhoneNumber = "+201012345678",
City = "Cairo",
Country = "EG"
}
});
return Redirect(checkout.IframeUrl); // customer pays on Paymob's page
After the payment
// Refund (full or partial)
await client.RefundAsync(transactionId: 12345, amountCents: 50000);
// Void before settlement (cards)
await client.VoidAsync(transactionId: 12345);
// Capture a previously authorized transaction
await client.CaptureAsync(transactionId: 12345, amountCents: 50000);
// Look up a transaction — the reconciliation fallback when callbacks lag
var txn = await client.GetTransactionAsync(12345);
These use Authorization: Token {secret_key} — set PaymobClientOptions.SecretKey.
Intention API (unified checkout)
The newer flow — one call, then redirect:
var intention = await client.CreateIntentionAsync(new IntentionRequest
{
Amount = 50000,
Currency = "EGP",
PaymentMethods = new List<int> { 123456 }, // integration ids
BillingData = billingData,
Customer = new IntentionCustomer { FirstName = "Ahmed", LastName = "Hassan", Email = "ahmed@example.com" },
NotificationUrl = "https://yoursite.com/api/paymob/webhook",
RedirectionUrl = "https://yoursite.com/payment/done"
});
return Redirect(client.BuildUnifiedCheckoutUrl(intention.ClientSecret));
ASP.NET Core DI
services.AddPaymob(options =>
{
options.ApiKey = builder.Configuration["Paymob:ApiKey"];
options.SecretKey = builder.Configuration["Paymob:SecretKey"];
options.PublicKey = builder.Configuration["Paymob:PublicKey"];
options.HmacSecret = builder.Configuration["Paymob:HmacSecret"];
});
// then inject PaymobClient anywhere
Webhook validation
Paymob POSTs transaction callbacks to your notification URL. Always verify the HMAC — otherwise anyone can forge a "payment succeeded" callback:
using Paymob.Webhooks;
var json = await new StreamReader(Request.Body).ReadToEndAsync();
if (!PaymobWebhookValidator.IsValidCallback(hmacSecret, json))
return Unauthorized();
// safe to trust: update the order
Step-by-step (if you prefer)
var authToken = await client.GetAuthTokenAsync();
var orderId = await client.CreateOrderAsync(authToken, request);
var paymentToken = await client.CreatePaymentKeyAsync(authToken, orderId, request);
var url = client.BuildIframeUrl(iframeId, paymentToken);
Bring your own HttpClient (e.g. from IHttpClientFactory):
var client = new PaymobClient(options, httpClient);
API errors throw PaymobApiException with the HTTP status code and Paymob's response body.
Targets
netstandard2.0 and net8.0. Only dependency is System.Text.Json.
License
MIT
| 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.