FibPaymentSDK 1.0.3

dotnet add package FibPaymentSDK --version 1.0.3                
NuGet\Install-Package FibPaymentSDK -Version 1.0.3                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FibPaymentSDK" Version="1.0.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FibPaymentSDK --version 1.0.3                
#r "nuget: FibPaymentSDK, 1.0.3"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.