1. Go to this page and download the library: Download pils36/wayapay-php 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/ */
pils36 / wayapay-php example snippets
$wayapay = new \Pils36\Wayapay;
try
{
$tranx = $wayapay->transaction->initialize([
'amount'=>"128.00", // string
'description'=>"Order for something", // string
'currency'=>566, // int
'fee'=>1, // int
'customer'=> ['name' => "Like Vincent", 'email' => "[email protected]", 'phoneNumber' => "+11948667447"], // array
'merchantId'=>"MER_qZaVZ1645265780823HOaZW", // string
'wayaPublicKey'=>"WAYAPUBK_TEST_0x3442f06c8fa6454e90c5b1a518758c70", // string
'mode'=>"test" // string: \\test or live
]);
} catch(\Pils36\Wayapay\Exception\ApiException $e){
print_r($e->getResponseObject());
die($e->getMessage());
}
// store transaction reference so we can query in case user never comes back
// perhaps due to network issue
saveLastTransactionId($tranx->data->tranId);
// Get Authorization URL to make payment to the Wayapay payment gateway environment
$uri = $wayapay->authorizationUrl('test'); // change to live for production
// Use the authorization url to
$authorization_url = $uri.$tranx->data->tranId;
$transactionId = isset($_GET['_tranId']) ? $_GET['_tranId'] : '';
if(!$transactionId){
die('No transaction id provided');
}
// initiate the Library's Wayapay Object
$wayapay = new Pils36\Wayapay;
try
{
// verify using the library
$tranx = $wayapay->transaction->verify([
'_tranId'=>$transactionId, // unique to transactions
'mode'=>'test', // test or live
]);
} catch(\Pils36\Wayapay\Exception\ApiException $e){
print_r($e->getResponseObject());
die($e->getMessage());
}
if ($tranx->status === true) {
// transaction was successful...
// please check other things like whether you already gave value for this transactions
// if the email matches the customer who owns the product etc
// Save your transaction information
}
bash
$ composer
php
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.