Awesome
Omnipay: Paynow
Paynow driver for the Omnipay PHP payment processing library
Omnipay is a framework agnostic, multi-gateway payment processing library for PHP. This package implements paynow support for Omnipay.
Installation
Omnipay is installed via Composer. To install, simply require league/omnipay
and pay-now/omnipay-paynow
with Composer:
composer require league/omnipay pay-now/omnipay-paynow
Basic Usage
Making a payment:
use Omnipay\Omnipay;
$gateway = Omnipay::create('Paynow');
$gateway->setApiKey('api-key');
$gateway->setSignatureKey('signature-key');
$buyer = [
'email' => 'jan.nowak@melements.pl',
'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
}
Handling notification with current payment status:
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);
Making a payment's refund
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
}
Retrieving available payment methods
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
}
For general usage instructions, please see the main Omnipay repository.
Support
If you have any questions or issues regarding paynow, please contact our support at support@paynow.pl.
If you are having general issues with Omnipay, we suggest posting on Stack Overflow. Be sure to add the omnipay tag so it can be easily found.
If you want to keep up to date with release anouncements, discuss ideas for the project, or ask more detailed questions, there is also a mailing list which you can subscribe to.
If you believe you have found a bug, please report it using the GitHub issue tracker, or better yet, fork the library and submit a pull request.