PHP code example of pay-now / omnipay-paynow
1. Go to this page and download the library: Download pay-now/omnipay-paynow 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/ */
pay-now / omnipay-paynow example snippets
use Omnipay\Omnipay;
$gateway = Omnipay::create('Paynow');
$gateway->setApiKey('api-key');
$gateway->setSignatureKey('signature-key');
$buyer = [
'email' => '[email protected] ',
'firstName' => 'Jan',
'lastName' => 'Nowak',
'phone' => [
'number' => '123123123',
'prefix' => '+48'
],
'locale'=> 'en-EN'
];
$items[] = [
'name' => 'itemName',
'quantity' => '12',
'category' => 'toys',
'price' => '123'
];
$paymentData = [
'amount' => '10000',
'description' => 'PLN',
'returnUrl' => 'https://paynow.pl',
'transactionId' => '123',
'buyer' => $buyer,
'items' => $items
];
try {
$response = $gateway->purchase($paymentData)->send();
} catch (\Exception $e) {
// catch errors
}
use Omnipay\Omnipay;
$gateway = Omnipay::create('Paynow');
$gateway->setApiKey('api-key');
$gateway->setSignatureKey('signature-key');
try {
$response = $gateway->acceptNotification();
} catch (\Exception $e) {
header('HTTP/1.1 400 Bad Request', true, 400);
}
header('HTTP/1.1 202 Accepted', true, 202);
use Omnipay\Omnipay;
$gateway = Omnipay::create('Paynow');
$gateway->setApiKey('api-key');
$gateway->setSignatureKey('signature-key');
$refundData = [
'amount' => '1000000',
'transactionReference' => 'NOW8-CK5-C3E-ZDM',
'reason' => 'RMA'
];
try {
$response = $gateway->refund($refundData)->send();
} catch (\Exception $e) {
// catch errors
}
use Omnipay\Omnipay;
$gateway = Omnipay::create('Paynow');
$gateway->setApiKey('api-key');
$gateway->setSignatureKey('signature-key');
$requestData = [
'amount'=>'1000',
'currency'=> 'PLN'
];
try {
$response = $gateway->fetchPaymentMethods($requestData)->send();
} catch (\Exception $e) {
// catch errors
}