Xdot.Paymob.CashIn
0.0.0-preview.0.26
See the version list below for details.
dotnet add package Xdot.Paymob.CashIn --version 0.0.0-preview.0.26
NuGet\Install-Package Xdot.Paymob.CashIn -Version 0.0.0-preview.0.26
<PackageReference Include="Xdot.Paymob.CashIn" Version="0.0.0-preview.0.26" />
paket add Xdot.Paymob.CashIn --version 0.0.0-preview.0.26
#r "nuget: Xdot.Paymob.CashIn, 0.0.0-preview.0.26"
// Install Xdot.Paymob.CashIn as a Cake Addin #addin nuget:?package=Xdot.Paymob.CashIn&version=0.0.0-preview.0.26&prerelease // Install Xdot.Paymob.CashIn as a Cake Tool #tool nuget:?package=Xdot.Paymob.CashIn&version=0.0.0-preview.0.26&prerelease
Xdot.Paymob
An SDK for .NET to help you integrate with the Paymob’s payment gateway.
if you like this work, please consider give the project star 🌟
Features
- Supporting .NET Standard 2.0+, .NET 5+, .NET Core 2.0+, and .NET Framework 4.6.1+.
- Automatic retries - The library automatically retries requests on intermittent failures.
- Manage authentication tokens - The library manage authenticate (using the configured ApiKey), token caching and invalidation. so you don't need to provide it for each request and the library provide it in each request need it for you.
- You can access the full response property.
- Handle API DateTime responses correctly - all responses use
DateTimeOffset
. - Ability to swap the configuration (API key, hmac, ...) during runtime.
Installation
Using the .NET CLI tools:
dotnet add package Xdot.Paymob.CashIn.DependencyInjection
Using the NuGet CLI:
nuget install Xdot.Paymob.CashIn.DependencyInjection
Using the Package Manager Console:
Install-Package Xdot.Paymob.CashIn.DependencyInjection
Usage
Configuration Dependency Injection
Configure the library in Startup.cs
with these helper methods. This will inject IPaymobCashInBroker
(used to call
the Paymob API),
IPaymobCashInAuthenticator
(used to authenticate and manage authentication token), and configure options.
services.AddPaymobCashIn(config => {
config.ApiKey = "Api Key";
config.Hmac = "Hmac secret",
});
// Alert: ApiKey and Hmac is a sensitive settings make sure to store them into
// a secret manager (Azure key vault for example).
// DON'T STORE SECRETS IN CODE
- If you don't use Microsoft DI, Use the base package Xdot.Paymob.CashIn and configure your DI to the equivalent to this configuration.
- Then you can inject
IPaymobCashInBroker
to your service and use to to call the Paymob API.
Here's the details of what the IPaymobCashInBroker
has to offer:
Method | Description |
---|---|
CreateOrderAsync | See: https://docs.paymob.com/docs/accept-standard-redirect#2-order-registration-api |
RequestPaymentKeyAsync | See: https://docs.paymob.com/docs/accept-standard-redirect#3-payment-key-request |
CreateWalletPayAsync | See: https://docs.paymob.com/docs/mobile-wallets#pay-request |
CreateKioskPayAsync | See: https://docs.paymob.com/docs/kiosk-payments |
CreateCashCollectionPayAsync | See: https://docs.paymob.com/docs/cash-collection |
CreateSavedTokenPayAsync | See: https://docs.paymob.com/docs/pay-with-saved-token |
GetTransactionAsync | Get transaction by id. |
GetTransactionsPageAsync | Get transactions page. |
GetOrderAsync | Get an order by id. |
GetOrdersPageAsync | Get orders page. |
CreateIframeSrc | Helper method to create iframe src url |
Validate | Helper method to verify callback content with your hmac secret see: https://docs.paymob.com/docs/transaction-webhooks#hmac-authentication |
Simple Example
public class CashInService
{
private readonly IPaymobCashInBroker _broker;
public CashInService(IPaymobCashInBroker broker)
{
_broker = broker;
}
public async Task<string> RequestCardPaymentKey()
{
// Create order.
var amountCents = 1000; // 10 LE
var orderRequest = CashInCreateOrderRequest.CreateOrder(amountCents);
var orderResponse = await _broker.CreateOrderAsync(orderRequest);
// Request card payment key.
var billingData = new CashInBillingData(
firstName: "Mahmoud",
lastName: "Shaheen",
phoneNumber: "010000000",
email: "mxshaheen@gmail.com");
var paymentKeyRequest = new CashInPaymentKeyRequest(
integrationId: 123,
orderId: orderResponse.Id,
billingData: billingData,
amountCents: amountCents);
var paymentKeyResponse = await _broker.RequestPaymentKeyAsync(paymentKeyRequest);
// Create iframe src.
return _broker.CreateIframeSrc(iframeId: "1234", token: paymentKeyResponse.PaymentKey);
}
}
License
This project is licensed under the Apache 2.0 license.
Contact
If you have any suggestions, comments or questions, please feel free to contact me on:
Email: mxshaheen@gmail.com
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. 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 was computed. 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. |
.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 is compatible. 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. |
-
.NETFramework 4.6.1
- Ardalis.GuardClauses (>= 3.2.0)
- Flurl (>= 3.0.2)
- Microsoft.Extensions.Options (>= 5.0.0)
- System.ComponentModel.Annotations (>= 4.3.0)
- System.Net.Http.Json (>= 5.0.0)
-
.NETStandard 2.0
- Ardalis.GuardClauses (>= 3.2.0)
- Flurl (>= 3.0.2)
- Microsoft.Extensions.Options (>= 5.0.0)
- System.ComponentModel.Annotations (>= 4.3.0)
- System.Net.Http.Json (>= 5.0.0)
-
net5.0
- Ardalis.GuardClauses (>= 3.2.0)
- Flurl (>= 3.0.2)
- Microsoft.Extensions.Options (>= 5.0.0)
- System.ComponentModel.Annotations (>= 4.3.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Xdot.Paymob.CashIn:
Package | Downloads |
---|---|
Xdot.Paymob.CashIn.DependencyInjection
Xdot.Paymob.CashIn extensions for Dependency Injection. Xdot.Paymob.CashIn is SDK to help you integrate with the Paymob’s payment gateway. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.7 | 1,170 | 10/25/2023 |
1.0.6 | 1,041 | 10/15/2022 |
1.0.5 | 653 | 6/28/2022 |
1.0.0 | 933 | 1/2/2022 |
0.0.0-preview.0.30 | 152 | 12/6/2021 |
0.0.0-preview.0.27 | 149 | 12/6/2021 |
0.0.0-preview.0.26 | 155 | 10/2/2021 |
0.0.0-preview.0.23 | 157 | 9/5/2021 |
0.0.0-preview.0.21 | 150 | 9/1/2021 |
0.0.0-preview.0.10 | 157 | 8/25/2021 |
0.0.0-preview.0.9 | 173 | 8/20/2021 |
0.0.0-preview.0.7 | 140 | 8/18/2021 |
0.0.0-preview.0.4 | 167 | 8/12/2021 |
0.0.0-preview.0 | 152 | 8/11/2021 |