2017 © Pedro Peláez
 

library sdk

image

paynl/sdk

  • Monday, July 30, 2018
  • by andypieters
  • Repository
  • 6 Watchers
  • 18 Stars
  • 38,678 Installations
  • PHP
  • 4 Dependents
  • 0 Suggesters
  • 24 Forks
  • 2 Open issues
  • 45 Versions
  • 16 % Grown

The README.md

Latest Stable Version Total Downloads Latest Unstable Version Build Status Coverage Status, (*1)

Pay.nl PHP SDK



Installation

This SDK uses composer., (*2)

Composer is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you., (*3)

For more information on how to use/install composer, please visit: https://github.com/composer/composer, (*4)

To install the Pay.nl PHP sdk into your project, simply, (*5)

$ composer require paynl/sdk

Installation without composer

If you don't have experience with composer, it is possible to use the SDK without using composer., (*6)

You can download the zip on the projects releases page., (*7)

  1. Download the package zip (SDKvx.x.x.zip).
  2. Unzip the contents of the zip, and upload the vendor directory to your server.
  3. In your project, require the file vendor/autoload.php
  4. You can now use the SDK in your project

Requirements

The PAY. PHP SDK is tested up to PHP version 8.2 and requires the PHP cURL extension., (*8)

Quick start and examples

Set the configuration, (*9)

require __DIR__ . '/vendor/autoload.php';

# Replace tokenCode apitoken and serviceId with your own.
\Paynl\Config::setTokenCode('AT-####-####');
\Paynl\Config::setApiToken('****************************************');
\Paynl\Config::setServiceId('SL-####-####');

Get available payment methods, (*10)

require __DIR__ . '/vendor/autoload.php';

\Paynl\Config::setTokenCode('AT-####-####');
\Paynl\Config::setApiToken('****************************************');
\Paynl\Config::setServiceId('SL-####-####');

$paymentMethods = \Paynl\Paymentmethods::getList();
var_dump($paymentMethods);

Start a transaction, (*11)

require __DIR__ . '/vendor/autoload.php';

\Paynl\Config::setTokenCode('AT-####-####');
\Paynl\Config::setApiToken('****************************************');
\Paynl\Config::setServiceId('SL-####-####');

$result = \Paynl\Transaction::start(array(
    # Required
        'amount' => 10.00,
        'returnUrl' => Paynl\Helper::getBaseUrl().'/return.php',

    # Optional
        'currency' => 'EUR',
        'exchangeUrl' => Paynl\Helper::getBaseUrl().'/exchange.php',
        'paymentMethod' => 10,
        'bank' => 1,
        'description' => 'demo betaling',
        'testmode' => 1,
        'extra1' => 'ext1',
        'extra2' => 'ext2',
        'extra3' => 'ext3',
        'products' => array(
            array(
                'id' => 1,
                'name' => 'een product',
                'price' => 5.00,
                'tax' => 0.87,
                'qty' => 1,
            ),
            array(
                'id' => 2,
                'name' => 'ander product',
                'price' => 5.00,
                'tax' => 0.87,
                'qty' => 1,
            )
        ),
        'language' => 'EN',
        'ipaddress' => '127.0.0.1',
        'invoiceDate' => new DateTime('2016-02-16'),
        'deliveryDate' => new DateTime('2016-06-06'), // in case of tickets for an event, use the event date here
        'enduser' => array(
            'initials' => 'T',
            'lastName' => 'Test',
            'gender' => 'M',
            'birthDate' => new DateTime('1990-01-10'),
            'phoneNumber' => '0612345678',
            'emailAddress' => 'test@test.nl',
        ),
        'address' => array(
            'streetName' => 'Test',
            'houseNumber' => '10',
            'zipCode' => '1234AB',
            'city' => 'Test',
            'country' => 'NL',
        ),
        'invoiceAddress' => array(
            'initials' => 'IT',
            'lastName' => 'ITEST',
            'streetName' => 'Istreet',
            'houseNumber' => '70',
            'zipCode' => '5678CD',
            'city' => 'ITest',
            'country' => 'NL',
        ),
    ));

# Save this transactionid and link it to your order
$transactionId = $result->getTransactionId();

# Redirect the customer to this url to complete the payment
$redirect = $result->getRedirectUrl();

On the return page, redirect the user to the thank you page or back to checkout, (*12)

require __DIR__ . '/vendor/autoload.php';

\Paynl\Config::setTokenCode('AT-####-####');
\Paynl\Config::setApiToken('****************************************');

$transactionId = $_REQUEST['orderId'];

$transaction = \Paynl\Transaction::status($transactionId);

# Manual transfer transactions are always pending when the user is returned
if( $transaction->isPaid() || $transaction->isPending()) {
   # Redirect to thank you page
} elseif($transaction->isCanceled()) {
   # Redirect back to checkout
}

On the exchange script, process the order, (*13)

require __DIR__ . '/vendor/autoload.php';

\Paynl\Config::setTokenCode('AT-####-####');
\Paynl\Config::setApiToken('****************************************');

$transactionId = $_REQUEST['order_id'];

$transaction = \Paynl\Transaction::status($transactionId);

if($transaction->isPaid() || $transaction->isAuthorized()) {
    # Process the payment
} elseif($transaction->isCanceled()) {
    # Payment canceled, restock items
}

# Always respond with TRUE|
echo "TRUE| ";

# Optionally you can send a message after TRUE|, you can view these messages in the logs.
# https://admin.pay.nl/logs/payment_state
echo ($transaction->isPaid() || $transaction->isAuthorized())?'Paid':'Not paid';


Failover gateway

In the event of an outage, set the failover gateway like this:, (*14)

use Paynl\Config;
use Paynl\Transaction;

require __DIR__ . '/vendor/autoload.php';

Config::setTokenCode('AT-####-####');
Config::setApiToken('****************************************');
Config::setServiceId('SL-####-####');

# Setting Failover gateway (for available cores, call Config::getCores())
Config::setCore( Config::CORE2 );

# Or for SDK versions lower then 1.6.7, use:
Config::setApiBase('https://rest.achterelkebetaling.nl');

$requiredArguments = []; // See: Start a transaction example
$result = Transaction::start($requiredArguments);

Testing

Please run vendor/bin/phpunit --bootstrap vendor/autoload.php tests/ to test the application, (*15)

The Versions

30/07 2018

dev-master

9999999-dev

  Sources   Download

The Requires

 

The Development Requires

by Andy Pieters

16/05 2018

v1.5.2

1.5.2.0

  Sources   Download

The Requires

 

The Development Requires

by Andy Pieters

10/04 2018

v1.5.1

1.5.1.0

  Sources   Download

The Requires

 

The Development Requires

by Andy Pieters

06/03 2018

dev-DynamicUUID

dev-DynamicUUID

  Sources   Download

The Requires

 

The Development Requires

by Andy Pieters

22/02 2018

v1.5.0

1.5.0.0

  Sources   Download

The Requires

 

The Development Requires

by Andy Pieters

14/02 2018

v1.4.1

1.4.1.0

  Sources   Download

The Requires

 

The Development Requires

by Andy Pieters

29/11 2017

v1.4.0

1.4.0.0

  Sources   Download

The Requires

 

The Development Requires

by Andy Pieters

23/10 2017

dev-kingsquare-fixing-inconsistencies

dev-kingsquare-fixing-inconsistencies

  Sources   Download

The Requires

 

The Development Requires

by Andy Pieters

06/06 2017

v1.3.2

1.3.2.0

  Sources   Download

The Requires

 

The Development Requires

by Andy Pieters

29/05 2017

v1.3.1

1.3.1.0

  Sources   Download

The Requires

 

The Development Requires

by Andy Pieters

25/04 2017

v1.3.0

1.3.0.0

  Sources   Download

The Requires

 

The Development Requires

by Andy Pieters

24/04 2017

v1.2.10

1.2.10.0

  Sources   Download

The Requires

 

The Development Requires

by Andy Pieters

14/03 2017

v1.2.9

1.2.9.0

  Sources   Download

The Requires

 

The Development Requires

by Andy Pieters

22/02 2017

v1.2.8

1.2.8.0

  Sources   Download

The Requires

 

The Development Requires

by Andy Pieters

21/02 2017

v1.2.7

1.2.7.0

  Sources   Download

The Requires

 

The Development Requires

by Andy Pieters

26/01 2017

v1.2.6

1.2.6.0

  Sources   Download

The Requires

 

The Development Requires

by Andy Pieters

17/01 2017

v1.2.5

1.2.5.0

  Sources   Download

The Requires

 

The Development Requires

by Andy Pieters

02/01 2017

v1.2.4

1.2.4.0

  Sources   Download

The Requires

 

The Development Requires

by Andy Pieters

23/11 2016

v1.2.3

1.2.3.0

  Sources   Download

The Requires

 

The Development Requires

by Andy Pieters

11/11 2016

v1.2.2

1.2.2.0

  Sources   Download

The Requires

 

The Development Requires

by Andy Pieters

04/11 2016

v1.2.1

1.2.1.0

  Sources   Download

The Requires

 

The Development Requires

by Andy Pieters

12/10 2016

v1.2.0

1.2.0.0

  Sources   Download

The Requires

 

The Development Requires

by Andy Pieters

13/09 2016

v1.1.15

1.1.15.0

  Sources   Download

The Requires

 

The Development Requires

by Andy Pieters

27/06 2016

v1.1.14

1.1.14.0

  Sources   Download

The Requires

 

The Development Requires

by Andy Pieters

31/05 2016

v1.1.13

1.1.13.0

  Sources   Download

The Requires

 

The Development Requires

by Andy Pieters

29/04 2016

v1.1.12

1.1.12.0

  Sources   Download

The Requires

 

The Development Requires

by Andy Pieters

26/04 2016

dev-UnitTests

dev-UnitTests

  Sources   Download

The Requires

 

The Development Requires

by Andy Pieters

12/04 2016

v1.1.11

1.1.11.0

  Sources   Download

The Requires

 

The Development Requires

by Andy Pieters

11/03 2016

v1.1.10

1.1.10.0

  Sources   Download

The Requires

 

The Development Requires

by Andy Pieters

03/03 2016

v1.1.9

1.1.9.0

  Sources   Download

The Requires

 

The Development Requires

by Andy Pieters

19/02 2016

v1.1.8

1.1.8.0

  Sources   Download

The Requires

 

by Andy Pieters

18/02 2016

v1.0.7

1.0.7.0

  Sources   Download

The Requires

 

by Andy Pieters

18/02 2016

v1.1.7

1.1.7.0

  Sources   Download

The Requires

 

by Andy Pieters

15/02 2016

v1.1.6

1.1.6.0

  Sources   Download

The Requires

 

by Andy Pieters

15/01 2016

v1.1.5

1.1.5.0

  Sources   Download

The Requires

 

by Andy Pieters

06/01 2016

v1.1.4

1.1.4.0

  Sources   Download

The Requires

 

by Andy Pieters

23/12 2015

v1.1.3

1.1.3.0

  Sources   Download

The Requires

 

by Andy Pieters

21/12 2015

v1.1.2

1.1.2.0

  Sources   Download

The Requires

 

by Andy Pieters

17/12 2015

v1.1.1

1.1.1.0

  Sources   Download

The Requires

 

by Andy Pieters

15/12 2015

v1.1.0

1.1.0.0

  Sources   Download

The Requires

 

by Andy Pieters

14/12 2015

v1.0.4

1.0.4.0

  Sources   Download

The Requires

 

by Andy Pieters

03/12 2015

v1.0.3

1.0.3.0

  Sources   Download

The Requires

 

by Andy Pieters

01/12 2015

v1.0.2

1.0.2.0

  Sources   Download

The Requires

 

by Andy Pieters

11/11 2015

v1.0.1

1.0.1.0

  Sources   Download

The Requires

 

by Andy Pieters

04/11 2015

v1.0.0

1.0.0.0

  Sources   Download

The Requires

 

by Andy Pieters