pay-now / paynow-php-sdk
PHP client library for accessing Paynow API
Installs: 126 267
Dependents: 1
Suggesters: 0
Security: 0
Stars: 16
Watchers: 3
Forks: 10
Open Issues: 8
Requires
- php: >=7.2
- php-http/client-implementation: ^1.0 || ^2.0
- php-http/discovery: ^1.12
- php-http/httplug: ^2.2
- php-http/message-factory: ^1.0 || ^2.0
- psr/http-message: ^1.0 || ^2.0
Requires (Dev)
- dealerdirect/phpcodesniffer-composer-installer: ^0.7.0
- friendsofphp/php-cs-fixer: ^2.15
- guzzlehttp/psr7: ^1.6
- nyholm/psr7: ^1.2
- php-http/guzzle6-adapter: ^2.0
- php-http/mock-client: ^1.3
- phpcompatibility/php-compatibility: ^9.3
- phpunit/phpunit: ^8.5.36
- squizlabs/php_codesniffer: ^3.4
Suggests
- nyholm/psr7: A super lightweight PSR-7 implementation
- php-http/curl-client: PSR-18 and HTTPlug Async client with cURL
- dev-master
- 2.4.3
- 2.4.2
- 2.4.1
- 2.4.0
- 2.3.1
- 2.3.0
- 2.2.2
- 2.2.1
- 2.2.0
- 2.1.4
- 2.1.3
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.2
- 2.0.1
- 2.0.0
- 1.1.0
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- v1.0.1
- v1.0.0
- dev-release/v2.4.3
- dev-feature/PPM-311
- dev-release/v2.4.2
- dev-feature/PPM-294-and-PPM-295
- dev-release/v2.4.0
- dev-release/v2.3.1
- dev-tech/build-on-php8
- dev-develop
This package is auto-updated.
Last update: 2024-11-28 14:26:47 UTC
README
Paynow PHP Library provides access to Paynow API from Applications written in PHP language.
Requirements
- PHP 7.1 or higher
- HTTP client implements
php-http/client-implementation
. For more information see the packages list.
Installation
Composer
Install the library using Composer
$ composer require pay-now/paynow-php-sdk
If you don't have HTTP client that implements PSR-18 you can use:
$ composer require pay-now/paynow-php-sdk nyholm/psr7 php-http/curl-client
Use autoloader
require_once('vendor/autoload.php');
Usage
Making a payment
use Paynow\Client; use Paynow\Environment; use Paynow\Exception\PaynowException; use Paynow\Service\Payment; $client = new Client('TestApiKey', 'TestSignatureKey', Environment::SANDBOX); $orderReference = "success_1234567"; $idempotencyKey = uniqid($orderReference . '_'); $paymentData = [ 'amount' => '100', 'currency' => 'PLN', 'externalId' => $orderReference, 'description' => 'Payment description', 'buyer' => [ 'email' => 'customer@domain.com' ] ]; try { $payment = new Payment($client); $result = $payment->authorize($paymentData, $idempotencyKey); } catch (PaynowException $exception) { // catch errors }
Handling notification with current payment status
use Paynow\Notification; $payload = trim(file_get_contents('php://input')); $headers = getallheaders(); $notificationData = json_decode($payload, true); try { new Notification('TestSignatureKey', $payload, $headers); // process notification with $notificationData } catch (Exception $exception) { header('HTTP/1.1 400 Bad Request', true, 400); } header('HTTP/1.1 202 Accepted', true, 202);
Making a payment's refund
use Paynow\Client; use Paynow\Environment; use Paynow\Exception\PaynowException; use Paynow\Service\Refund; $client = new Client('TestApiKey', 'TestSignatureKey', Environment::SANDBOX); try { $refund = new Refund($client); $result = $refund->create('YXZA-123-ABC-A01', uniqid(), 100); } catch (PaynowException $exception) { // catch errors }
Retrieving available payment methods
use Paynow\Client; use Paynow\Environment; use Paynow\Exception\PaynowException; use Paynow\Service\Payment; $client = new Client('TestApiKey', 'TestSignatureKey', Environment::SANDBOX); try { $payment = new Payment($client); $paymentMethods = $payment->getPaymentMethods('PLN', 100); $availablePaymentMethods = $paymentMethods->getAll(); } catch (PaynowException $exception) { // catch errors }
Documentation
See the Paynow API documentation
Support
If you have any questions or issues, please contact our support at support@paynow.pl.
License
MIT license. For more information see the LICENSE file