trustwebmaster / paynow-php-sdk

PHP Library for Paynow API

Home Page:https://docs.paynow.pl

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Paynow PHP SDK

Latest Version Build Status Software License

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);

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

About

PHP Library for Paynow API

https://docs.paynow.pl

License:MIT License


Languages

Language:PHP 100.0%