FibPaymentSDK 1.0.3
dotnet add package FibPaymentSDK --version 1.0.3
NuGet\Install-Package FibPaymentSDK -Version 1.0.3
<PackageReference Include="FibPaymentSDK" Version="1.0.3" />
paket add FibPaymentSDK --version 1.0.3
#r "nuget: FibPaymentSDK, 1.0.3"
// Install FibPaymentSDK as a Cake Addin #addin nuget:?package=FibPaymentSDK&version=1.0.3 // Install FibPaymentSDK as a Cake Tool #tool nuget:?package=FibPaymentSDK&version=1.0.3
FibPaymentSDK 🚀
FibPaymentSDK is a .NET 9 SDK that simplifies integrating with Fib Payment API.
It handles authentication, payment creation, status checks, cancellations, and refunds.
📌 Features
✅ Secure & Fast Payment Processing
✅ OAuth2 Token Management
✅ Retry Mechanism for Token Expiration
✅ Easy Integration with .NET 9
✅ Async API Calls
📥 Installation
Install the package via NuGet:
dotnet add package FibPaymentSDK
Or via Package Manager Console:
Install-Package FibPaymentSDK
🚀 Usage
1️⃣ Initialize the Payment Service
using FibPaymentSdk.FIB;
using System.Net.Http;
var httpClient = new HttpClient();
var paymentService = new FibPaymentService(httpClient,
"https://api.fibpayment.com",
"your-client-id",
"your-client-secret");
2️⃣ Authenticate & Get Access Token
var tokenResponse = await paymentService.GetAccessTokenAsync();
Console.WriteLine($"Access Token: {tokenResponse.AccessToken}");
3️⃣ Create a Payment
var request = new FibCreatePaymentRequest
{
MonetaryValue = new FibMonetaryValue
{
Amount = "1000",
Currency = "IQD"
},
StatusCallbackUrl = "https://webhook-test.com",
Description = "Tested By Pshitiwan",
ExpiresIn = "PT5M",
Category = "POS",
RefundableFor = "PT48H"
};
var response = await paymentService.CreatePaymentAsync(request);
if (response != null)
{
Console.WriteLine($"Payment successful! Transaction ID: {response.TransactionId}");
}
else
{
Console.WriteLine("Payment failed.");
}
4️⃣ Check Payment Status
var statusResponse = await paymentService.CheckPaymentStatusAsync("txn_123456");
Console.WriteLine($"Payment Status: {statusResponse?.Status}");
5️⃣ Cancel a Payment
await paymentService.CancelPaymentAsync("txn_123456");
Console.WriteLine("Payment cancelled successfully.");
6️⃣ Refund a Payment
await paymentService.RefundPaymentAsync("txn_123456");
Console.WriteLine("Payment refunded successfully.");
🛠 Configuration
You can configure API Credentials in appsettings.json
:
{
"FibPaymentSDK": {
"ApiBaseUrl": "https://api.fibpayment.com",
"ClientId": "your-client-id",
"ClientSecret": "your-client-secret"
}
}
Or set it dynamically:
var paymentService = new FibPaymentService(httpClient, "https://api.fibpayment.com", "your-client-id", "your-client-secret");
🔄 Poll Payment Status
If you need to continuously check payment status, use the PollPaymentStatusAsync
method:
await paymentService.PollPaymentStatusAsync("txn_123456", 5, 60, async status =>
{
Console.WriteLine($"Payment Status Updated: {status.Status}");
});
This will check the payment every 5 seconds for up to 60 seconds.
📜 License
This project is licensed under the MIT License.
🤝 Contributing
Pull requests are welcome!
For major changes, please open an issue first to discuss the proposed changes.
🌎 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 is compatible. 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. |
-
net8.0
- System.Net.Http (>= 4.3.4)
- System.Text.Json (>= 9.0.2)
-
net9.0
- System.Net.Http (>= 4.3.4)
- System.Text.Json (>= 9.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.