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


These sections will guide you on how to develop and test YenePay’s payment method integration with your PHP application.


Download the SDK

Go to our github page and download the latest version of our PHP SDK. Then copy the sdk folder from the downloaded directory and place it inside your PHP project folder.

Add to your project

Open your payment processor PHP class and import the SDK’s helper class and namespaces.

use YenePay\Models\CheckoutOptions;
use YenePay\Models\CheckoutItem;
use YenePay\CheckoutHelper;

require(__DIR__ .'/lib/sdk/CheckoutHelper.php');

Note: depending on your directory structure, the path to the CheckoutHelper.php file may be slightly different.

Generate checkout URL

Generate a Checkout Url using the help methods provided by the SDK library as shown below

$useSandbox = true;
$checkoutOptions = new CheckoutOptions($sellerCode, $useSandbox);

This will create a new instance of type CheckoutOptions and sets the UseSandbox property to true. Set this to false when on production environment.

Once you have that, set the other optional checkout options and provide the details of the order to be paid for.

$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";

CheckoutItem checkoutitem = new CheckoutItem("NAME_OF_ITEM_PAID_FOR", UNIT_PRICE_OF_ITEM, QUANTITY);
string yenepayCheckoutUrl = CheckoutHelper.GetCheckoutUrl(checkoutoptions, checkoutitem);

$checkoutOrderItem = new CheckoutItem("NAME_OF_ITEM_PAID_FOR", UNIT_PRICE_OF_ITEM, QUANTITY);
$checkoutOrderItem  -> ItemId = "UNIQUE_ID_FOR_THE_ITEM";
$checkoutOrderItem  -> DeliveryFee = DELIVERY_FEE_IF_AVAILABLE;
$checkoutOrderItem  -> Tax1 = VAT_FEE_IF_AVAILABLE;
$checkoutOrderItem  -> Tax2 = TOT_FEE_IF_AVAILABLE;
$checkoutOrderItem  -> Discount = DISCOUNT_AMOUNT_IF_AVAILABLE;
$checkoutOrderItem  -> HandlingFee = HANDLING_FEE_IF_AVAILABLE;

$checkoutHelper = new CheckoutHelper();
$checkoutUrl = $checkoutHelper -> getSingleCheckoutUrl($checkoutOptions, $checkoutOrderItem);

If you are processing cart payment, use the getCartCheckoutUrl method instead as follows:

$checkoutUrl = $checkoutHelper -> getCartCheckoutUrl($checkoutOptions, $checkoutOrderItems);

Redirect your customer

Redirect your customer to the checkout URL generated in the step above. Your customer will then be taken to our checkout page, login with his/her YenePay account and complete the payment there. Once a payment has been successfully completed, we will send you an Instant Payment Notification (IPN) to the URL you provided on the CheckoutOptions object in the step above. 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 is shown below

use YenePay\Models\IPN;
use YenePay\CheckoutHelper;

require_once(__DIR__ .'/lib/sdk/CheckoutHelper.php');
require_once(__DIR__ .'/lib/sdk/Models/IPN.php');

$ipnModel = new IPN();

$helper = new CheckoutHelper();
if ($helper->isIPNAuthentic($ipnModel))
	echo 'Success!';
	echo 'Fail';

For a more concrete example, please have a look at our sampleshopapplication on our github page that shows how you can do the integration on your PHP based application.

Was this article helpful to you? Yes 8 No 1

How can we help?