AsiaPayPaymentSDK 1.0.1
dotnet add package AsiaPayPaymentSDK --version 1.0.1
NuGet\Install-Package AsiaPayPaymentSDK -Version 1.0.1
<PackageReference Include="AsiaPayPaymentSDK" Version="1.0.1" />
<PackageVersion Include="AsiaPayPaymentSDK" Version="1.0.1" />
<PackageReference Include="AsiaPayPaymentSDK" />
paket add AsiaPayPaymentSDK --version 1.0.1
#r "nuget: AsiaPayPaymentSDK, 1.0.1"
#:package AsiaPayPaymentSDK@1.0.1
#addin nuget:?package=AsiaPayPaymentSDK&version=1.0.1
#tool nuget:?package=AsiaPayPaymentSDK&version=1.0.1
AsiaPayPaymentSDK
AsiaPayPaymentSDK is a .NET 8 SDK designed to simplify payment processing using the AsiaPay API.
It provides seamless integration for merchants to handle transactions, refunds, and order queries.
📌 Features
✅ Token-Based Authentication
✅ Pre-Order Processing
✅ Payment Token Handling
✅ Order Queries & Refunds
✅ QR Code Generation for Payments
🚀 Installation
Using NuGet
Run the following command in the .NET CLI:
dotnet add package AsiaPayPaymentSDK --version 1.0.0
Or using Package Manager Console (PMC):
Install-Package AsiaPayPaymentSDK -Version 1.0.0
🔥 Quick Start
1️⃣ Initialize AsiaPayService
using AsiaPayPaymentSDK.AsiaPay;
var httpClient = new HttpClient();
var paymentService = new AsiaPayService(
httpClient,
PaymentConstants.ServerUrl,
PaymentConstants.CheckH5MidPageUrl,
PaymentConstants.AppSecret,
PaymentConstants.XAppKey,
PaymentConstants.AppId,
PaymentConstants.MerchCode,
PaymentConstants.PrivateKey
);
2️⃣ Create an Order in AsiaPay
var timestamp = DateTimeOffset.Now.ToUnixTimeSeconds().ToString();
var nonceStr = Guid.NewGuid().ToString("N").ToLower();
var request = new AsiaPayPreOrderRequest
{
Timestamp = timestamp,
NonceStr = nonceStr,
BizContent = new BizContentPreOrderRequest
{
NotifyUrl = "https://pshtiwan.free.beeceptor.com",
RedirectUrl = "https://pshtiwan.free.beeceptor.com",
AppId = PaymentConstants.AppId,
MerchCode = PaymentConstants.MerchCode,
MerchOrderId = Guid.NewGuid().ToString("N"),
Title = "Tested By pshtiwan",
TotalAmount = "500",
TransCurrency = "IQD",
TimeoutExpress = "5m"
}
};
var createResponse = await paymentService.PreOrderAsync(request);
if (createResponse?.BizContent?.PrepayId == null)
{
Console.WriteLine("Failed to create order.");
return;
}
Console.WriteLine($"Order Created: {createResponse.BizContent.PrepayId}");
3️⃣ Generate Payment URL & QR Code
var generateQr = await paymentService.GetApplyPayTokenAsync(
createResponse.BizContent.PrepayId, timestamp, nonceStr
);
string paymentUrl = $"https://pay.com?tradeType=PWA&appId={PaymentConstants.AppId}&merchCode={PaymentConstants.MerchCode}&prepayId={createResponse.BizContent.PrepayId}&payToken={generateQr.BizContent?.PayToken}";
Console.WriteLine($"Payment URL: {paymentUrl}");
Console.WriteLine("_________________________");
// Generate QR Code
Console.WriteLine("QrCode:data:image/png;base64," + paymentService.GenerateQrCodeBase64(paymentUrl));
Console.WriteLine("_________________________");
// Generate H5 Checkout URL
Console.WriteLine("OpenApp:" + paymentService.GenerateH5CheckoutUrl(createResponse.BizContent.PrepayId));
4️⃣ Query an Order
var queryOrder = await paymentService.QueryOrderAsync("52da1851e46c4017a7637f0249b007fe");
Console.WriteLine($"Order Details: {queryOrder}");
5️⃣ Process Refund
var refund = await paymentService.RefundOrderAsync("f8bfc6d157c74b32b99c1c434be51b3a");
Console.WriteLine($"Refund Response: {refund}");
🌎 Connect With Me
📧 Email: pshitiwan.eng@gmail.com
💼 LinkedIn: Pshitiwan Hassan
🐙 GitHub: pshtiwan-hassan
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
- QRCoder (>= 1.6.0)
- System.Drawing.Common (>= 9.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.