Skip to content

Commit

Permalink
Merge pull request #1 from paynl/master
Browse files Browse the repository at this point in the history
update
  • Loading branch information
Grisgruis authored Nov 6, 2019
2 parents 8d40259 + 02e4164 commit 68b200f
Show file tree
Hide file tree
Showing 175 changed files with 8,384 additions and 1,087 deletions.
9 changes: 4 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
nbproject/*
index.php
vendor/*
composer.lock
.idea/*
samples/config.php
.idea/*
vendor/
composer.lock
22 changes: 22 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
language: php

matrix:
include:
- php: 5.6
- php: 7
- php: 7.1
- php: 7.2
- php: 7.3
fast_finish: true

before_install:
- composer self-update

before_script:
- composer install

script:
- vendor/bin/phpunit --bootstrap vendor/autoload.php --coverage-clover build/logs/clover.xml tests/

after_success:
- travis_retry php vendor/bin/coveralls
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Pay.nl

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
24 changes: 18 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
[![Latest Stable Version](https://poser.pugx.org/paynl/sdk/v/stable)](https://packagist.org/packages/paynl/sdk) [![Total Downloads](https://poser.pugx.org/paynl/sdk/downloads)](https://packagist.org/packages/paynl/sdk) [![Latest Unstable Version](https://poser.pugx.org/paynl/sdk/v/unstable)](https://packagist.org/packages/paynl/sdk)
[![Latest Stable Version](https://poser.pugx.org/paynl/sdk/v/stable)](https://packagist.org/packages/paynl/sdk)
[![Total Downloads](https://poser.pugx.org/paynl/sdk/downloads)](https://packagist.org/packages/paynl/sdk)
[![Latest Unstable Version](https://poser.pugx.org/paynl/sdk/v/unstable)](https://packagist.org/packages/paynl/sdk)
[![Build Status](https://travis-ci.org/paynl/sdk.svg?branch=master)](https://travis-ci.org/paynl/sdk)
[![Coverage Status](https://coveralls.io/repos/github/paynl/sdk/badge.svg?branch=master)](https://coveralls.io/github/paynl/sdk?branch=master)
# Pay.nl PHP SDK

---
Expand Down Expand Up @@ -35,7 +39,7 @@ You can download the zip on the projects [releases](https://github.com/paynl/sdk

### Requirements

The Pay.nl PHP SDK works on php versions 5.3, 5.4, 5.5 and 5.6.
The Pay.nl PHP SDK works on php versions 5.3, 5.4, 5.5, 5.6, 7.0 and 7.1
Also the php curl extension needs to be installed.

### Quick start and examples
Expand All @@ -44,7 +48,8 @@ Set the configuration
```php
require __DIR__ . '/vendor/autoload.php';

// Replace apitoken and serviceId with your own.
// Replace tokenCode apitoken and serviceId with your own.
\Paynl\Config::setTokenCode('AT-1234-5678');
\Paynl\Config::setApiToken('e41f83b246b706291ea9ad798ccfd9f0fee5e0ab');
\Paynl\Config::setServiceId('SL-3490-4320');
```
Expand All @@ -53,6 +58,7 @@ Get available payment methods
```php
require __DIR__ . '/vendor/autoload.php';

\Paynl\Config::setTokenCode('AT-1234-5678');
\Paynl\Config::setApiToken('e41f83b246b706291ea9ad798ccfd9f0fee5e0ab');
\Paynl\Config::setServiceId('SL-3490-4320');

Expand All @@ -64,6 +70,7 @@ Start a transaction
```php
require __DIR__ . '/vendor/autoload.php';

\Paynl\Config::setTokenCode('AT-1234-5678');
\Paynl\Config::setApiToken('e41f83b246b706291ea9ad798ccfd9f0fee5e0ab');
\Paynl\Config::setServiceId('SL-3490-4320');

Expand Down Expand Up @@ -106,7 +113,7 @@ $result = \Paynl\Transaction::start(array(
'initials' => 'T',
'lastName' => 'Test',
'gender' => 'M',
'dob' => '14-05-1999',
'birthDate' => new DateTime('1990-01-10'),
'phoneNumber' => '0612345678',
'emailAddress' => '[email protected]',
),
Expand Down Expand Up @@ -139,6 +146,7 @@ On the return page, redirect the user to the thank you page or back to checkout
```php
require __DIR__ . '/vendor/autoload.php';

\Paynl\Config::setTokenCode('AT-1234-5678');
\Paynl\Config::setApiToken('e41f83b246b706291ea9ad798ccfd9f0fee5e0ab');

$transaction = \Paynl\Transaction::getForReturn();
Expand All @@ -157,11 +165,12 @@ On the exchange script, process the order
```php
require __DIR__ . '/vendor/autoload.php';

\Paynl\Config::setTokenCode('AT-1234-5678');
\Paynl\Config::setApiToken('e41f83b246b706291ea9ad798ccfd9f0fee5e0ab');

$transaction = \Paynl\Transaction::getForExchange();

if($transaction->isPaid()){
if($transaction->isPaid() || $transaction->isAuthorized()){
// process the payment
} elseif($transaction->isCanceled()){
// payment canceled, restock items
Expand All @@ -172,7 +181,10 @@ 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()?'Paid':'Not paid';
echo ($transaction->isPaid() || $transaction->isAuthorized())?'Paid':'Not paid';


```

### Testing
Please run ```vendor/bin/phpunit --bootstrap vendor/autoload.php tests/``` to test the application
38 changes: 24 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
{
"name": "paynl/sdk",
"require": {
"php-curl-class/php-curl-class": "^4.8"
},
"authors": [
{
"name": "Andy Pieters",
"email": "[email protected]"
}
],
"autoload":{
"psr-4": {
"Paynl\\": "src/"
}
"name": "paynl/sdk",
"require": {
"php-curl-class/php-curl-class": "^8.3",
"ext-json": "*",
"ext-curl": "*"
},
"suggest": {
"ext-simplexml": "*"
},
"require-dev": {
"phpunit/phpunit": "^4.8",
"php-coveralls/php-coveralls": "^1.0"
},
"authors": [
{
"name": "Andy Pieters",
"email": "[email protected]"
}
],
"autoload": {
"psr-4": {
"Paynl\\": "src/"
}
},
"license": "MIT"
}
12 changes: 12 additions & 0 deletions samples/DynamicUUID/decode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php
require_once "../../vendor/autoload.php";

$uuid = 'b0898a33-1234-1234-0000-494e56303031';
$secret = 'abcdef1234567890abcdef1234567890abcdef12';

try {
$decoded = \Paynl\DynamicUUID::decode($uuid, $secret);
var_dump($decoded);
} catch (\Paynl\Error\Error $e) {
echo "Error: ".$e->getMessage();
}
25 changes: 25 additions & 0 deletions samples/DynamicUUID/encode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
require_once "../../vendor/autoload.php";

$UUID = \Paynl\DynamicUUID::encode(
'SL-1234-1234',
'abcdef1234567890abcdef1234567890abcdef12',
'INV001'
);

$ideal = \Paynl\DynamicUUID::ideal($UUID, true);
// load qr image from url
echo "<img src='".$ideal['QRUrl']."'>";
// load qr image from base64
echo "<img src='data:image/png;base64,".$ideal['QRBase64']."'>";
// the url the qr-code points to
echo "<br /><a href='".$ideal['url']."'>".$ideal['url']."</a><br />";


$bancontact = \Paynl\DynamicUUID::bancontact($UUID, true);
// load qr image from url
echo "<img src='".$bancontact['QRUrl']."'>";
// load qr image from base64
echo "<img src='data:image/png;base64,".$bancontact['QRBase64']."'>";
// the url the qr-code points to
echo "<br /><a href='".$bancontact['url']."'>".$bancontact['url']."</a><br />";
9 changes: 9 additions & 0 deletions samples/DynamicUUID/validate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
require_once "../../vendor/autoload.php";

$uuid = 'sl49b880-1234-1234-inv2-018000178532';
$secret = 'abcdef1234567890abcdef1234567890abcdef12';

$isValid = \Paynl\DynamicUUID::validate($uuid, $secret);

echo $isValid?'The uuid is valid': 'The uuid is NOT valid';
5 changes: 0 additions & 5 deletions samples/config.php

This file was deleted.

9 changes: 9 additions & 0 deletions samples/config.sample.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
\Paynl\Config::setApiToken('bf81d83f6f8ca32bca272dfdcaf2f14902ff41');
\Paynl\Config::setServiceId('SL-3490-4320');
\Paynl\Config::setTokenCode('AT-0123-4567');

//optional: you can download it on https://curl.haxx.se/ca/cacert.pem
//\Paynl\Config::setCAInfoLocation('path/to/cacert.pem');
// Or you can skip verifyPeer
//\Paynl\Config::setVerifyPeer(false);
29 changes: 29 additions & 0 deletions samples/directDebit/add.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
require_once '../../vendor/autoload.php';
require_once '../config.php';
try {
$result = \Paynl\DirectDebit::add(array(
'amount' => 0.1,
'bankaccountHolder' => 'N. Klant',
'bankaccountNumber' => 'NL00RAB0123456789',

// optional
'bankaccountBic' => 'RABONL2U',
// 'exchangeUrl' => 'http://path_to_your_exchange/file.php',
'processDate' => new \DateTime('tomorrow'),
'description' => 'De omschrijving',
'ipAddress' => '192.168.20.123',
'email' => '[email protected]',
'promotorId' => '123456789',
'tool' => 'sdk',
'info' => 'info',
'object' => 'object',
'extra1' => 'extra1',
'extra2' => 'extra2',
'extra3' => 'extra3',
'currency' => 'EUR',
));
echo $result->getMandateId();
} catch (\Paynl\Error\Error $e) {
echo "Error: ".$e->getMessage();
}
9 changes: 9 additions & 0 deletions samples/directDebit/get.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
require_once '../../vendor/autoload.php';
require_once '../config.php';
try {
$result = \Paynl\DirectDebit::get('IO-9350-3111-3010');
var_dump($result->getData());
} catch (\Paynl\Error\Error $e) {
echo "Error: ".$e->getMessage();
}
29 changes: 29 additions & 0 deletions samples/directDebit/mandate/add.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
require_once '../../../vendor/autoload.php';
require_once '../../config.php';
try {
$result = \Paynl\DirectDebit\Mandate::add(array(
'amount' => 0.1,
'bankaccountHolder' => 'N. Klant',
'bankaccountNumber' => 'NL00RABO0123456789',

// optional
'bankaccountBic' => 'RABONL2U',
'processDate' => new \DateTime('tomorrow'),
// 'exchangeUrl' => 'http://path_to_your_exchange/file.php',
'description' => 'De omschrijving',
'ipAddress' => '192.168.20.123',
'email' => '[email protected]',
'promotorId' => '123456789',
'tool' => 'sdk',
'info' => 'info',
'object' => 'object',
'extra1' => 'extra1',
'extra2' => 'extra2',
'extra3' => 'extra3',
'currency' => 'EUR',
));
echo $result->getMandateId();
} catch (\Paynl\Error\Error $e) {
echo "Error: ".$e->getMessage();
}
14 changes: 14 additions & 0 deletions samples/directDebit/mandate/addTransaction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
require_once '../../../vendor/autoload.php';
require_once '../../config.php';
try {
$result = \Paynl\DirectDebit\Mandate::addTransaction(array(
'mandateId' => 'IO-6604-2112-1710',
'amount' => 0.10,
'description' => 'Handmatig herhaald',
'processDate' => new \DateTime('tomorrow'),
));
var_dump($result->getData());
} catch (\Paynl\Error\Error $e) {
echo "Error: ".$e->getMessage();
}
10 changes: 10 additions & 0 deletions samples/directDebit/mandate/get.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
require_once '../../../vendor/autoload.php';
require_once '../../config.php';
try {
$result = \Paynl\DirectDebit\Mandate::get('IO-6604-2112-1710');
$data = $result->getData();
var_dump($data['result']);
} catch (\Paynl\Error\Error $e) {
echo "Error: ".$e->getMessage();
}
32 changes: 32 additions & 0 deletions samples/directDebit/recurring/add.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
require_once '../../../vendor/autoload.php';
require_once '../../config.php';
try {
$result = \Paynl\DirectDebit\Recurring::add(array(
'amount' => 0.1,
'bankaccountHolder' => 'N Klant',
'bankaccountNumber' => 'NL00RABO0123456789',
'intervalValue' => 1,
'intervalPeriod' => Paynl\DirectDebit\Recurring::INTERVAL_DAY,
'intervalQuantity' => 3,
'bankaccountBic' => 'RABONL2U',
'processDate' => '08-07-2016',

// optional
// 'exchangeUrl' => 'http://path_to_your_exchange/file.php',
'description' => 'De omschrijving',
'ipAddress' => '192.168.20.123',
'email' => '[email protected]',
'promotorId' => '123456789',
'tool' => 'sdk',
'info' => 'info',
'object' => 'object',
'extra1' => 'extra1',
'extra2' => 'extra2',
'extra3' => 'extra3',
'currency' => 'EUR',
));
echo $result->getMandateId();
} catch (\Paynl\Error\Error $e) {
echo "Error: ".$e->getMessage();
}
10 changes: 10 additions & 0 deletions samples/directDebit/recurring/get.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
require_once '../../../vendor/autoload.php';
require_once '../../config.php';
try {
$result = \Paynl\DirectDebit\Recurring::get('IO-3674-2126-0710');
$data = $result->getData();
var_dump($data['result']);
} catch (\Paynl\Error\Error $e) {
echo "Error: ".$e->getMessage();
}
Loading

0 comments on commit 68b200f

Please sign in to comment.