ThawaniPaySDK 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package ThawaniPaySDK --version 1.0.0                
NuGet\Install-Package ThawaniPaySDK -Version 1.0.0                
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="ThawaniPaySDK" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ThawaniPaySDK --version 1.0.0                
#r "nuget: ThawaniPaySDK, 1.0.0"                
#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 ThawaniPaySDK as a Cake Addin
#addin nuget:?package=ThawaniPaySDK&version=1.0.0

// Install ThawaniPaySDK as a Cake Tool
#tool nuget:?package=ThawaniPaySDK&version=1.0.0                

(Unofficial) This package was created to ease the integration of Thawani Payment (Oman Based Payment Gateway) in .NET Applications.

ThawaniSDK (.NET)

You can find the package on GitHub.

The error codes can be found on Thawani Docs.

For creating a Payment Session:

var checkout = new ThawaniPaySDK.Checkout();
//If you have your API Keys and want to use the Production instead of UAT
var checkout = new ThawaniPaySDK.Checkout("apiKey", "publicKey");
var products = new List<ThawaniPaySDK.Models.CommonModels.ProductModel>()
{
    new ThawaniPaySDK.Models.CommonModels.ProductModel()
    {
        name = "Product 1",
        quantity = 1,
        unit_amount = 100
    }
};

var sessionModel = new ThawaniPaySDK.Models.CheckoutModels.CheckoutSessionCreateRequestModel()
{
    success_url = "https://domain.com/success/",
    cancel_url = "https://domain.com/cancel/",
    mode = "payment",
    client_reference_id = "",
    customer_id = "", //If you have a customer id, the customer can save their cards. We will see how you can initiate a payment intent using a saved card
    products = products,
    metadata = new ThawaniPaySDK.Models.CommonModels.MetadataModel()
    {
        customer_email = "example@domain.com", //Mandatory
        customer_name = "Customer Name", //Mandatory
        customer_phone = "968 12345678", //Mandatory
        customer_id = "", //Optional
        order_id = "" //Optional
    }
};

var sessionInfo = checkout.CreateSession(sessionModel);
var url = checkout.GeneratePaymentURL(sessionInfo.data.session_id);

The payment status of the Checkout Session, one of paid, unpaid, or cancelled. You can use this value to decide when to fulfill your customer’s order.

For creating a Customer (This is required before you can make Payment Intents):

var customer = new ThawaniPaySDK.Customer();
var customerCreateModel = customer.CreateCustomer(new ThawaniPaySDK.Models.CustomerModels.CustomerCreateRequestModel()
{
    client_customer_id = "",
    //A unique Identification from you, it could be an Email or a UserId.
    //It would later be used for retrieval of the Customer Info
});

var customerDeleteModel = customer.DeleteCustomer("customer_id");
//The above will delete customer

var paymentMethods = new ThawaniPaySDK.PaymentMethods();
var customerPaymentMethods = paymentMethods.ListCustomerPaymentMethods("customer_id");
//This above will list out all of the cards with their Masked Numbers, NickName, Brand and an Id (Payment Method Id)

var paymentMethodDeletedModel = paymentMethods.DeleteCustomerPaymentMethod("payment_method_id");
//The above will delete Payment Method

For creating a Payment Intent:

var paymentIntent = new ThawaniPaySDK.PaymentIntent();
//If you have your API Keys and want to use the Production instead of UAT
var paymentIntent = new ThawaniPaySDK.PaymentIntent("apiKey", "publicKey");
var paymentIntentModel = paymentIntent.CreatePaymentIntent(new ThawaniPaySDK.Models.PaymentIntentModels.CreatePaymentIntentRequestModel()
{
    amount = 100,
    client_reference_id = "", //The Customer Id
    payment_method_id = "", //The Card Id saved at Thawani
    return_url = "https://domain.com/returnURL",
    metadata = new ThawaniPaySDK.Models.CommonModels.MetadataModel()
    {
        customer_email = "example@domain.com", //Mandatory
        customer_name = "Customer Name", //Mandatory
        customer_phone = "968 12345678", //Mandatory
        customer_id = "", //Optional
        order_id = "" //Optional
    }
});

var paymentIntentConfirmModel = paymentIntent.ConfirmPaymentIntent(new ThawaniPaySDK.Models.PaymentIntentModels.ConfirmPaymentIntentRequestModel()
{
    amount = 100,
    payment_method_id = "", //The Card Id saved at Thawani
},
paymentIntentModel.data.id);

var paymentIntentURL = paymentIntentConfirmModel.data.next_action.url;

var paymentIntentRetrieveModel = paymentIntent.RetrievePaymentIntent(paymentIntentModel.data.id);

Status of this PaymentIntent, one of requires_payment_method, requires_confirmation, requires_action, cancelled, or succeeded

For further details, you can check Thawani's official docs page.

Product 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. 
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.

Version Downloads Last updated
1.1.7 576 10/31/2022
1.1.6 505 4/9/2022
1.1.1 425 7/27/2021
1.1.0 400 7/27/2021
1.0.0 347 7/15/2021