PHP code example of alvarezallen99 / ipay88
1. Go to this page and download the library: Download alvarezallen99/ipay88 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/ */
alvarezallen99 / ipay88 example snippets
class Payment {
protected $merchantCode;
protected $merchantKey;
protected $payment_response;
protected $backend_response;
public function __construct()
{
parent::__construct();
$this->merchantCode = env('IPAY88_MERCHANT_CODE'); //MerchantCode confidential
$this->merchantKey = env('IPAY88_MERCHANT_KEY'); //MerchantKey confidential
$this->payment_response = 'http://example.com/response';
$this->backend_response = 'http://example.com/backend';
}
public function index()
{
$request = new IPay88\Payment\Request($this->merchantKey);
$this->_data = array(
'merchantCode' => $request->setMerchantCode($this->merchantCode),
'paymentId' => $request->setPaymentId(1),
'refNo' => $request->setRefNo('EXAMPLE0001'),
'amount' => $request->setAmount('0.50'),
'currency' => $request->setCurrency('MYR'),
'prodDesc' => $request->setProdDesc('Testing'),
'userName' => $request->setUserName('Your name'),
'userEmail' => $request->setUserEmail('[email protected] '),
'userContact' => $request->setUserContact('0123456789'),
'remark' => $request->setRemark('Some remarks here..'),
'lang' => $request->setLang('UTF-8'),
'signature' => $request->getSignature(),
'responseUrl' => $request->setResponseUrl($this->payment_response),
'backendUrl' => $request->setBackendUrl($this->backend_response)
);
IPay88\Payment\Request::make($this->merchantKey, $this->_data);
}
public function response()
{
$response = (new IPay88\Payment\Response)->init($this->merchantCode);
echo "<pre>";
print_r($response);
}
}