PHP code example of aba_payway_gateway / php_payway
1. Go to this page and download the library: Download aba_payway_gateway/php_payway 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/ */
aba_payway_gateway / php_payway example snippets
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
$dotenv->load();
$merchant = new PaywayMerchant(
merchantID: $_ENV['ABA_PAYWAY_MERCHANT_ID'] ?? '',
merchantApiName: $_ENV['ABA_PAYWAY_MERCHANT_NAME'] ?? '',
merchantApiKey: $_ENV['ABA_PAYWAY_API_KEY'] ?? '',
baseApiUrl: $_ENV['ABA_PAYWAY_API_URL'] ?? '',
refererDomain: "http://mylekha.app",
);
$service = new PaywayTransactionService(merchant: $merchant);
$tran_id = $service->uniqueTranID();
$items = [
new PaywayTransactionItem(name: "ទំនិញ 1", quantity: 1, price: 1,),
new PaywayTransactionItem(name: "ទំនិញ 2", quantity: 1, price: 2,),
new PaywayTransactionItem(name: "ទំនិញ 3", quantity: 1, price: 3,),
];
$transaction = new PaywayCreateTransaction(
tran_id: $tran_id,
req_time: $service->uniqueReqTime(),
amount: 6.00,
items: $items,
firstname: 'Miss',
lastname: 'My Lekha',
phone: '010464144',
email: '[email protected] ',
option: PaywayPaymentOption::abapay_deeplink,
type: PaywayTransactionType::purchase,
currency: PaywayTransactionCurrency::USD,
return_url: "https://stage.mylekha.app",
shipping: 0.0,
);
$form_service = new PaywayClientFormRequestService(merchant: $merchant);
$request_options = $form_service->generateCreateTransactionFormData(transaction: $transaction);
$createResponse = $service->createTransaction(transaction: $transaction);
$checkTransaction = $transaction = new PaywayCheckTransaction(tran_id: $tran_id, req_time: $service->uniqueReqTime());
$checkResponse = $service->checkTransaction(transaction: $checkTransaction);
dd($checkResponse);