MiroPaySDK 1.0.0
See the version list below for details.
dotnet add package MiroPaySDK --version 1.0.0
NuGet\Install-Package MiroPaySDK -Version 1.0.0
<PackageReference Include="MiroPaySDK" Version="1.0.0" />
<PackageVersion Include="MiroPaySDK" Version="1.0.0" />
<PackageReference Include="MiroPaySDK" />
paket add MiroPaySDK --version 1.0.0
#r "nuget: MiroPaySDK, 1.0.0"
#:package MiroPaySDK@1.0.0
#addin nuget:?package=MiroPaySDK&version=1.0.0
#tool nuget:?package=MiroPaySDK&version=1.0.0
C#.NET SDK
A lightweight SDK for interacting with the Miropay Payment API, built on top of [HttpClient in System.Net.Http and System.Net.Http.Headers] for fast, native HTTP calls and private key-based request signing.
๐ฆ Installation
dotnet add package MiroPaySDK --version x.x.x
๐ Usage
using MiroPaySDK.Rest;
using MiroPaySDK.Rest.Enums;
using MiroPaySDK.Rest.Interfaces;
var client = new PaymentRestClient(privateKey, secretKey, isTest);
Note:
The switch between sandbox and production mode will be manually throw theisTest
boolean value(true = sandbox, false = production mode)
.
๐ Authentication
The SDK uses a private key and a secret to sign every request with HMAC. Signature logic is handled internally.
๐งช Example
string privateKey = `-----BEGIN ENCRYPTED PRIVATE KEY-----
...
-----END ENCRYPTED PRIVATE KEY-----`;
string secretKey = "live_xxx..."; // or "test_xxx..."
bool isTest = false // or true.
var client = new PaymentRestClient(privateKey, secretKey, isTest);
๐ API Reference
new PaymentRestClient(string privateKey, string secretKey)
Creates a new client instance.
async Task<ICreatePaymentResponse> CreatePaymentAsync(ICreatePayment payload)
Creates a new payment session.
Hint: The amount
parameter cannot be a decimal value.
Parameters:
{
string amount; // e.g. "1000"
GATEWAY[] gateways; // e.g. [GATEWAY.ZAIN, GATEWAY.FIB]
string title;
string description;
string callbackUrl;
bool collectFeeFromCustomer;
bool collectCustomerEmail;
bool collectCustomerPhoneNumber;
}
Returns:
<CreatePaymentResponseBody>(Body:
{
string ReferenceCode,
string Amount,
string? PaidVia,
string? PaidAt,
string? CallbackUrl,
PAYMENT_STATUS Status,
string? PayoutAmount
});
return new CreatePaymentResponse
{
StatusCode = response.StatusCode,
Body = response.Body,
Headers = response.Headers
};
Example:
await client.CreatePaymentAsync({
amount: "1000",
gateways: [GATEWAY.FIB],
title: "Test",
description: "Desc",
callbackUrl: "https://google.com",
collectFeeFromCustomer: false,
collectCustomerEmail: false,
collectCustomerPhoneNumber: false,
});
async Task<IPaymentDetailsResponse> GetPaymentByIdAsync(string referenceCode)
Checks the status of a payment.
Returns:
<CreatePaymentResponseBody>(Body:
{
string ReferenceCode,
string Amount,
string? PaidVia,
string? PaidAt,
string? CallbackUrl,
PAYMENT_STATUS Status,
string? PayoutAmount
});
return new CreatePaymentResponse
{
StatusCode = response.StatusCode,
Body = response.Body,
Headers = response.Headers
};
Example:
var status = await client.GetPaymentByIdAsync("your-reference-code");
Console.WriteLine(status.body.status);
async Task<ICancelPaymentResponse> CancelPaymentAsync(string referenceCode)
Cancels an existing payment.
Example:
await client.CancelPaymentAsync("your-reference-code");
Returns:
<CancelPaymentResponseBody>(Body:
{
string ReferenceCode,
string Amount,
string? PaidVia,
string? PaidAt,
string? CallbackUrl,
PAYMENT_STATUS Status,
string? PayoutAmount
});
return new CreatePaymentResponse
{
StatusCode = response.StatusCode,
Body = response.Body,
Headers = response.Headers
};
๐ท๏ธ Types
public enum GATEWAY
{
[EnumMember(Value = "ZAIN")]
ZAIN,
[EnumMember(Value = "FIB")]
FIB
}
public enum PAYMENT_STATUS
{
[EnumMember(Value = "TIMED_OUT")]
TIMED_OUT,
[EnumMember(Value = "PENDING")]
PENDING,
[EnumMember(Value = "PAID")]
PAID,
[EnumMember(Value = "CANCELED")]
CANCELED,
[EnumMember(Value = "FAILED")]
FAILED,
[EnumMember(Value = "SETTLED")]
SETTLED
}
๐ฌ Need Help?
Contact the payment provider or open an issue on the internal GitHub repo.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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. |
-
net8.0
- BouncyCastle.Cryptography (>= 2.6.1)
- Microsoft.IdentityModel.Tokens (>= 8.13.0)
- NSec.Cryptography (>= 25.4.0)
- System.IdentityModel.Tokens.Jwt (>= 8.13.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.