1. Home
  2. Docs
  3. Integration Guide
  4. .NET SDK


To make integration easier, we’ve developed SDK that allows you to quickly and easily add YenePay as a payment method to your .NET based platform. The sections below describe how you can use this library to integrate with our platform.


Download and reference the SDK on your project

The recommended way to add our .net sdk to your project is from the NuGet packages store. To use this, open the Package Manager Console in Visual Studio from the View > Other Windows > Package Manager Console menu.

On the console window, make sure that the selected Default Project dropdown is the project you want to add our SDK reference to. Then type the following command to pull the latest sdk from the NuGet store and add a reference to your project:

PM> Install-Package yenepay.yenepaysdk

Alternatively, you can download the .dll library, available on our git page, and add a reference to this dll to your project. 
To do this, open your project in Visual Studio, right click on References node under your project name, select Add References and locate the YenePaySDK.dll file you downloaded.

Then, add a using reference to your class

 using YenePaySDK;

Generate a Checkout Url

Using the help methods provided by the SDK library, create a new instance of the CheckoutOptions object

CheckoutOptions checkoutoptions = new CheckoutOptions("YOUR_SELLER_CODE", true);

This will create a new instance and sets the UseSandbox property to true, which will point all transactions to our sandbox application and lets you test freely. Set this to false when on production environment

Alternatively, you can call the overridden constructor with more setup options:

CheckoutOptions checkoutoptions = new CheckoutOptions("YOUR_SELLER_CODE", "MERCHANT_ORDER_ID", CheckoutType.Express, true, 30, "SUCCESS_URL", "CANCEL_URL", "IPN_URL", "FAILURE_URL"));

The above sample call will create a new instance and sets the checkout process type to Express, use sandbox and order expiration to 30 days.

You can also set these optional checkout options and provide the details of the order to be paid for as follows:

checkoutoptions.Process = CheckoutType.Express; //alternatively you can set this to CheckoutType.Cart if you are including multiple items in a single order

// These properties are optional
checkoutoptions.SuccessReturn = "PAYMENT_SUCCESS_RETURN_URL";
checkoutoptions.CancelReturn = "PAYMENT_CANCEL_RETURN_URL";
checkoutoptions.FailureReturn = "PAYMENT_FAILURE_RETURN_URL";
checkoutoptions.ExpiresInDays = "NUMBER_OF_DAYS_BEFORE_THE_ORDER_EXPIRES";

Once you have completed setting up the checkout options, you then need to provide details of the item being paid for by creating an instance of the CheckoutItem object:

CheckoutItem checkoutitem = new CheckoutItem("NAME_OF_ITEM", UNIT_PRICE_OF_ITEM, QUANTITY);

Alternatively you can instantiate this object by calling the overloaded constructor with more parameters for details:

CheckoutItem checkoutitem = new CheckoutItem("001", "Sample Item", 100.00, 1, 15.00, NULL, 0.00, 0.00, 5.00);

The above call creates a new instance with these details:

  • Item id: 001
  • Item name: Sample Item
  • Price: 100.00 ETB
  • Quantity: 1
  • VAT: 15.00 ETB
  • Discount: 0.00 ETB
  • Handling Fee: 0.00 ETB
  • Delivery Fee: 0.00 ETB

Once you have the checkout options and the checkout item in place, you are ready to generate the checkout link as follows:

string yenepayCheckoutUrl = CheckoutHelper.GetCheckoutUrl(checkoutoptions, checkoutitem);

Redirect your customer

After you have generated the checkout URL, you need to redirect your customers to our checkout page. Your customer will then be requested to login with his/her YenePay account and complete the payment there.

Receive and verify IPN

Once a payment has been successfully completed, we will send you an Instant Payment Notification (IPN) to the URL you provided. When you receive this notification, you should query our IPN verification url to make sure it is an authentic notification initiated by our servers.

A sample implementation of a method to receive and verify IPN is shown below

public void IPNDestination(IPNModel ipnModel)
     ipnModel.UseSandbox = true; // set to false on production environment
     if (ipnModel != null)
          bool isIPNValid = CheckIPN(ipnModel).Result;

          if (isIPNValid)
               //mark your order as "Paid" or "Completed" here

// verify ipn method
private async Task<bool> CheckIPN(IPNModel model)
     return await CheckoutHelper.IsIPNAuthentic(model);

Verify notification on your Success URL

Another important endpoint on your system is the success endpoint. This is where the customer is redirected to after making a successful payment on our checkout page. When this happens, our system will post all the necessary information about the payment made to your success URL and you need to call our PDT endpoint to verify that the posted data is authentic. Here is a sample implementation of a success endpoint:

public async Task<ActionResult> PaymentSuccessReturnUrl(IPNModel ipnModel)
PDTRequestModel model = new PDTRequestModel(pdtToken, ipnModel.TransactionId, ipnModel.MerchantOrderId);
model.UseSandbox = checkoutoptions.UseSandbox;
var pdtResponse = await CheckoutHelper.RequestPDT(model);

if (pdtResponse.Count() > 0)
if (pdtResponse["Status"] == "Paid")
//This means the payment is completed.
//You can extract more information of the transaction from the pdtResponse dictionary
//You can now mark the order as "Paid" or "Completed" here and start the delivery process
//This means the pdt request has failed.
//possible reasons are
//1. the TransactionId is not valid
//2. the PDT_Key is incorrect
return Redirect("/"); ;

For a more concrete example, please have a look at our SampleShopApplication on github that shows you how you can do the integration on your .NET based system.

Was this article helpful to you? Yes 5 No

How can we help?