SDKs
Official SDKs wrap the encryption and HTTP calls for you — use one if your language is covered.
-
Node.js
npm install pesepay -
Python
pip install pesepay -
PHP
composer require codevirtus/pesepay -
Java
Maven Central — com.pesepay:pesepay -
Ruby
gem install pesepay
Install and initialize
Section titled “Install and initialize”npm install pesepayconst { Pesepay } = require('pesepay');
const pesepay = new Pesepay('INTEGRATION_KEY', 'ENCRYPTION_KEY');pesepay.resultUrl = 'https://example.com/result';pesepay.returnUrl = 'https://example.com/return';pip install pesepayfrom pesepay import Pesepay
pesepay = Pesepay("INTEGRATION_KEY", "ENCRYPTION_KEY")pesepay.result_url = "https://example.com/result"pesepay.return_url = "https://example.com/return"composer require codevirtus/pesepay<?phprequire_once 'vendor/autoload.php';use Codevirtus\Payments\Pesepay;
$pesepay = new Pesepay("INTEGRATION_KEY", "ENCRYPTION_KEY");$pesepay->returnUrl = "https://example.com/return";$pesepay->resultUrl = "https://example.com/result";<dependency> <groupId>com.pesepay</groupId> <artifactId>pesepay</artifactId> <version>1.0.0</version></dependency>Pesepay pesepay = new Pesepay(integrationKey, encryptionKey);pesepay.setResultUrl("https://example.com/result");pesepay.setReturnUrl("https://example.com/return");Redirect flow
Section titled “Redirect flow”const transaction = pesepay.createTransaction(amount, 'CURRENCY_CODE', 'PAYMENT_REASON');
pesepay .initiateTransaction(transaction) .then((response) => { const redirectUrl = response.redirectUrl; // send the customer here const referenceNumber = response.referenceNumber; // store for tracking }) .catch((error) => { /* handle error */ });transaction = pesepay.create_transaction(amount, "CURRENCY_CODE", "PAYMENT_REASON")
try: response = pesepay.initiate_transaction(transaction) redirect_url = response.redirect_url # send the customer here reference_number = response.reference_number # store for trackingexcept Exception as err: pass # handle error$transaction = $pesepay->createTransaction($amount, 'CURRENCY_CODE', 'PAYMENT_REASON', 'MERCHANT_REFERENCE');
$response = $pesepay->initiateTransaction($transaction);
if ($response->success()) { $redirectUrl = $response->redirectUrl(); $referenceNumber = $response->referenceNumber();} else { $errorMessage = $response->message();}Transaction transaction = pesepay.createTransaction(amount, "CURRENCY_CODE", "PAYMENT_REASON");
Response response = pesepay.initiateTransaction(transaction);
if (response.isSuccess()) { String redirectUrl = response.getRedirectUrl(); String referenceNumber = response.getReferenceNumber();} else { String errorMessage = response.getMessage();}Seamless flow
Section titled “Seamless flow”const payment = pesepay.createPayment( 'CURRENCY_CODE', 'PAYMENT_METHOD_CODE', 'CUSTOMER_EMAIL', 'CUSTOMER_PHONE_NUMBER', 'CUSTOMER_NAME');const requiredFields = { customerPhoneNumber: '0777777777' };
pesepay .makeSeamlessPayment(payment, 'PAYMENT_REASON', amount, requiredFields) .then((response) => { const pollUrl = response.pollUrl; const referenceNumber = response.referenceNumber; }) .catch((error) => { /* handle error */ });payment = pesepay.create_payment( "CURRENCY_CODE", "PAYMENT_METHOD_CODE", "CUSTOMER_EMAIL", "CUSTOMER_PHONE_NUMBER", "CUSTOMER_NAME")required_fields = {"customerPhoneNumber": "0777777777"}
try: response = pesepay.make_seamless_payment(payment, "PAYMENT_REASON", amount, required_fields) poll_url = response.poll_url reference_number = response.reference_numberexcept Exception as err: pass # handle error$payment = $pesepay->createPayment('CURRENCY_CODE', 'PAYMENT_METHOD_CODE', 'CUSTOMER_EMAIL', 'CUSTOMER_PHONE_NUMBER', 'CUSTOMER_NAME');$requiredFields = ['customerPhoneNumber' => '0777777777'];
$response = $pesepay->makeSeamlessPayment($payment, 'PAYMENT_REASON', $amount, $requiredFields, 'MERCHANT_REFERENCE');
if ($response->success()) { $referenceNumber = $response->referenceNumber(); $pollUrl = $response->pollUrl();} else { $errorMessage = $response->message();}Payment payment = pesepay.createPayment("CURRENCY_CODE", "PAYMENT_METHOD_CODE", "CUSTOMER_EMAIL");Map<String, String> requiredFields = new HashMap<>();requiredFields.put("customerPhoneNumber", "0777777777");
Response response = pesepay.makeSeamlessPayment(payment, "PAYMENT_REASON", amount, requiredFields);
if (response.isSuccess()) { String pollUrl = response.getPollUrl(); String referenceNumber = response.getReferenceNumber();} else { String errorMessage = response.getMessage();}Plugins
Section titled “Plugins”Running WooCommerce, PrestaShop, Moodle or WHMCS? Install the plugin instead — no integration code at all.