PHP code example of codevirtus / pesepay
1. Go to this page and download the library: Download codevirtus/pesepay library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
codevirtus / pesepay example snippets
use Codevirtus\Payments\Pesepay;
$pesepay = new Pesepay(
"INTEGRATION_KEY",
"ENCRYPTION_KEY"
);
$pesepay = new Pesepay(
"INTEGRATION_KEY",
"ENCRYPTION_KEY",
true
);
$pesepay->returnUrl = "https://example.com/gateway/return";
$pesepay->resultUrl = "https://example.com/gateway/result";
$payment = $pesepay->createPayment(
'CURRENCY_CODE',
'PAYMENT_METHOD_CODE',
'CUSTOMER_EMAIL', // Optional
'CUSTOMER_PHONE_NUMBER', // Optional
'CUSTOMER_NAME' // Optional
);
$ "creditCardExpiryDate" => "09/23",
"creditCardNumber" => "4867960000005461",
"creditCardSecurityNumber" => "608"
];
$ "customerPhoneNumber" => "0712345678"
];
$response = $pesepay->makeSeamlessPayment(
$payment,
'Online Transaction',
$AMOUNT,
$heck payment status later
$referenceNumber = $response->referenceNumber();
$pollUrl = $response->pollUrl();
// Transaction details
$amount = $response->amount();
$currencyCode = $response->currencyCode();
$transactionFee = $response->transactionServiceFee();
$metaData = $response->transactionMetadata();
// Full API response
$data = $response->rawData();
// InnBucks-specific data
$code = $response->metadataCode();
$qrcode = $response->metadataQrCode();
} else {
$errorMessage = $response->message();
}
$transaction = $pesepay->createTransaction(
$amount,
'CURRENCY_CODE',
'PAYMENT_REASON',
'MERCHANT_REFERENCE' // Optional
);
$response = $pesepay->initiateTransaction($transaction);
if ($response->success()) {
// Save these values for future payment status checks
$referenceNumber = $response->referenceNumber();
$pollUrl = $response->pollUrl();
// Redirect the customer
$redirectUrl = $response->redirectUrl();
} else {
$errorMessage = $response->message();
}
$transaction = $pesepay->createTransaction(
$amount,
'CURRENCY_CODE',
'PAYMENT_REASON',
'MERCHANT_REFERENCE' // Optional
);
// Identify the beneficiary merchant receiving the main payment.
$transaction->setSplitPayment(
'[email protected] ',
'PRINCIPAL' // or 'ADD_ON'
);
$response = $pesepay->initiateTransaction($transaction);
$payment = $pesepay->createPayment(
'CURRENCY_CODE',
'PAYMENT_METHOD_CODE',
'CUSTOMER_EMAIL',
'CUSTOMER_PHONE_NUMBER',
'CUSTOMER_NAME'
);
$payment->setSplitPayment(
'[email protected] ',
'PRINCIPAL' // or 'ADD_ON'
);
$response = $pesepay->makeSeamlessPayment(
$payment,
'Online Transaction',
$AMOUNT,
$
$response = $pesepay->checkPayment($referenceNumber);
if ($response->success()) {
if ($response->paid()) {
// Payment successful
}
} else {
$errorMessage = $response->message();
}
$response = $pesepay->pollTransaction($pollUrl);
if ($response->success()) {
if ($response->paid()) {
// Payment successful
}
} else {
$errorMessage = $response->message();
}