Luftborn.DibsPaymentSDK 2.0.1

.NET Standard 2.0
dotnet add package Luftborn.DibsPaymentSDK --version 2.0.1
NuGet\Install-Package Luftborn.DibsPaymentSDK -Version 2.0.1
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="Luftborn.DibsPaymentSDK" Version="2.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Luftborn.DibsPaymentSDK --version 2.0.1
#r "nuget: Luftborn.DibsPaymentSDK, 2.0.1"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Luftborn.DibsPaymentSDK as a Cake Addin
#addin nuget:?package=Luftborn.DibsPaymentSDK&version=2.0.1

// Install Luftborn.DibsPaymentSDK as a Cake Tool
#tool nuget:?package=Luftborn.DibsPaymentSDK&version=2.0.1

Dibs Payment API SDK

Description

.Net Core SDK for Dibs Payment easy API, it's a .Net core wrapper for Dibs Payment APIs including APIs for create payments, charge payment, update orders... etc.

For more details about Dibs Payment Please visit https://www.nets.eu/en/payments/online/

For more specific information about Dibs Payment APIs, Please visit Dibs Payment API site which also include full API documentation and code samples.

https://tech.dibspayment.com/easy/api/paymentapi

Installation

Use the nuget package manager to install library.

Install-Package DibsPaymentSDK -Version 1.0.0

Requirements

.Net Core v3
VSCode or VS
Nuget Package Manager

DibsPaymentSDK Configuration

Add below section to your application appsettings.json file.

"DibsPaymentAPI": {
	"BaseURL": "https://test.api.dibspayment.eu",
	"SecretKey": "100101010101010101010"
}

DibsPaymentSDK Usage

Table of Contents

  1. Create Payment

  2. Charge Payment

  3. Get Payment

  4. Cancel Payment

  5. Refund Payment

    <a name="create-payment"></a>

    1. Create Payment

Create payment instance

var createPaymentPost = new CreatePaymentPost();

Add your "bought" items to the payment order

            var items = new List<Item>();
            items.Add(new Item() {
                Name = "Product1",
                Reference = "22020206",
                GrossTotalAmount = 10,
                NetTotalAmount = 10,
                Quantity = 5,
                TaxAmount = 0,
                TaxRate = 0,
                Unit = "Item",
                UnitPrice = 2
            });
			
            createPaymentPost.Order = new Order() { 
                Amount = 10,
                Currency = "DKK",
                Reference = "123456",
                Items = items
            };

            createPaymentPost.PaymentMethods = new List<PaymentMethod>();
            createPaymentPost.PaymentMethods.Add(new PaymentMethod()
            {
                Fee = items.First(),
                Name = "easy-invoice"
            });
			
            var countries = new List<Country>();
            countries.Add(new Country() {
                CountryCode = "DNK"
            });

Setup checkout

            createPaymentPost.Checkout = new Checkout()
            {
                Charge = true,
                Consumer = new Consumer()
                { Company = null
                  ,Email = "123@live.com",
                    PhoneNumber = new PhoneNumber { Number = "01281339011", Prefix = "+45" },
                    PrivatePerson = null,
                    Reference = "3303030",
                    ShippingAddress = new ShippingAddress()
                    {
                        Country = "DNK",
                        AddressLine1 = "123 anywhere",
                        AddressLine2 = "here",
                        City = "Copenhagen",
                        PostalCode = "2000"
                    }

                },
                ConsumerType = new ConsumerType()
                { Default = "B2C" },
                IntegrationType = "EmbeddedCheckout",
                MerchantHandlesConsumerData = true,
                MerchantHandlesShippingCost = true,
                PublicDevice = true,
                ReturnUrl = "https://luftborn.com/callback",
                Shipping = new Shipping() { Countries = countries },
                TermsUrl = "https://luftborn.com/terms",
                Url = "https://luftborn.com/checkout"
            };

Setup webhook and callback settings

            createPaymentPost.Notifications = new Notifications()
            {
                WebHooks = new List<WebHook>()
            };
			
            createPaymentPost.Notifications.WebHooks.Add(new WebHook()
            {
                Authorization = "111111111",
                Url = "https://c95aed08.ngrok.io/home/Callback",
                EventName = "payment.created"
            });
			
			//create payment
            var paymnetAPI = new PaymentAPI();
            var response = await paymnetAPI.CreatePayment(createPaymentPost);

<a name="charge-payment"></a>

2. Charge Payment

	    //charge payment		
            var chargePayment = new ChargePayment();

            chargePayment.Amount = 10;
            chargePayment.OrderItems = new List<DibsPaymentSDK.Entities.ChargePayment.OrderItem>();
            chargePayment.OrderItems.Add(new DibsPaymentSDK.Entities.ChargePayment.OrderItem() {
                Name = "Product1",
                Reference = "22020206",
                GrossTotalAmount = 10,
                NetTotalAmount = 10,
                Quantity = 5,
                TaxAmount = 0,
                TaxRate = 0,
                Unit = "Item",
                UnitPrice = 2
            });

            var response = await paymentAPI.ChargePayment("00c600005e43dd5a046e301eacf52f0e", chargePayment);

<a name="get-payment"></a>

3. Get Payment

	    //get payment
            var response = await paymentAPI.GetPayment("023900005e43e0a4046e301eacf52f20");

<a name="cancel-payment"></a>

4. Cancel Payment

	    //create CancelPayment object
	    var cancelPayment = new CancelPayment();
	    cancelPayment.Amount = 10;
			
	    // add order items you want to cancel
            cancelPayment.OrderItems.Add();
	    cancelPayment.OrderItems.Add();
            ....

	    //cancel payment
            var response = await paymentAPI.CancelPayment("023900005e43e0a4046e301eacf52f20", cancelPayment);

<a name="refund-payment"></a>

5. Refund Payment

	   //create Refund object
	   var refundPayment = new Refund();
	   refundPayment.Amount = 10;
			
	   // add order items you want to refund
	   refundPayment.OrderItems.Add();
	   refundPayment.OrderItems.Add();
	   ....

	   // refund, submit chargeId and refund object
           var response = await paymentAPI.RefundPayment("023900005e43e0a4046e301eacf52f20", refundPayment);

Contributing

Pull requests are welcome, Please open an issue first to discuss what you would like to change.

License

MIT

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
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
2.0.1 460 8/17/2022
2.0.0 242 6/10/2022
1.0.5 594 9/14/2020
1.0.4 334 9/14/2020
1.0.3 332 9/14/2020
1.0.2 314 9/14/2020
1.0.1 326 9/14/2020
1.0.0 334 7/1/2020