Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 27 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p align="center">
<img src="https://www.pay.nl/uploads/1/brands/main_logo.png" />
<img src="https://www.pay.nl/uploads/1/brands/main_logo.png" alt=""/>
</p>
<h1 align="center">Pay. Omnipay driver</h1>

Expand All @@ -19,19 +19,18 @@ Pay. driver for the Omnipay payment processing library

# Available payment methods

Bank Payments | Creditcards | Gift cards & Vouchers | Pay by invoice | Others |
:-----------: | :-----------: | :-----------: | :-----------: | :-----------: |
iDEAL + QR |Visa | VVV Cadeaukaart | AfterPay | PayPal |
Bancontact + QR | Mastercard | Webshop Giftcard | Achteraf betalen via Billink | WeChatPay |
Giropay |American Express | FashionCheque | Focum AchterafBetalen.nl | AmazonPay |
MyBank | Carte Bancaire | Podium Cadeaukaart | Capayable Achteraf Betalen | Cashly |
SOFORT | PostePay | Gezondheidsbon | in3 keer betalen, 0% rente | Pay Fixed Price (phone) |
Maestro | Dankort | Fashion Giftcard | Klarna | Instore Payments (POS) |
Bank Transfer | Cartasi | GivaCard | SprayPay | Przelewy24 |
| Tikkie | De Cadeaukaart | YourGift | Creditclick | Apple Pay |
| Multibanco | | Paysafecard | | Payconiq
| | | Huis en Tuin Cadeau

| Bank Payments | Creditcards | Gift cards & Vouchers | Pay by invoice | Others |
|:---------------:|:----------------:|:---------------------:|:----------------------------:|:-----------------------:|
| iDEAL + QR | Visa | VVV Cadeaukaart | AfterPay | PayPal |
| Bancontact + QR | Mastercard | Webshop Giftcard | Achteraf betalen via Billink | WeChatPay |
| Giropay | American Express | FashionCheque | Focum AchterafBetalen.nl | AmazonPay |
| MyBank | Carte Bancaire | Podium Cadeaukaart | Capayable Achteraf Betalen | Cashly |
| SOFORT | PostePay | Gezondheidsbon | in3 keer betalen, 0% rente | Pay Fixed Price (phone) |
| Maestro | Dankort | Fashion Giftcard | Klarna | Instore Payments (POS) |
| Bank Transfer | Cartasi | GivaCard | SprayPay | Przelewy24 |
| Tikkie | De Cadeaukaart | YourGift | Creditclick | Apple Pay |
| Multibanco | | Paysafecard | | Payconiq |
| | | Huis en Tuin Cadeau | | |

# Requirements

Expand Down Expand Up @@ -59,22 +58,20 @@ The plugin is now installed

1. Create a new php file
2. Use the following code:

```php
# require autoloader
require_once('vendor/autoload.php');

use Omnipay\Omnipay;

# Setup payment gateway
$gateway = Omnipay::create('PaynlV3');

$gateway->setApiSecret('****************************************');
$gateway->setTokenCode('AT-####-####');
$gateway->setServiceId('SL-####-####');
```

3. Enter the TokenCode, API token, ServiceId (these can be found in the Pay. My Pay Panel --> https://my.pay.nl/
3. Enter the TokenCode, API token, ServiceId (these can be found in the Pay. My Pay Panel --> https://my.pay.nl/)

Go to the *Settings* / *Sales locations* tab in the Pay. Scroll down to the sales location and there copy the SL code and the secret.

Expand Down Expand Up @@ -170,7 +167,7 @@ $response = $gateway->purchase(
'currency' => 'EUR',
'transactionReference' => 'referenceID1',
'clientIp' => '192.168.192.12',
'returnUrl' => 'http://www.yourdomain.com/return_from_pay',
'returnUrl' => 'https://www.yourdomain.com/return_from_pay',
'items' => $arrItems,
'card' => array(
'firstName' => 'Example',
Expand All @@ -195,11 +192,11 @@ $response = $gateway->purchase(
'billingCity' => 'Billingtown',
'billingPostcode' => '1234AB',
'billingState' => '',
'billingCountry' => 'NL'
'billingCountry' => 'NL'
)
]
)->send();

# Process response
if ($response->isSuccessful()) {
# Get the url for fetching the Transaction
Expand All @@ -218,10 +215,10 @@ if ($response->isSuccessful()) {

# Payment was successful
var_dump($response);

} elseif ($response->isRedirect()) {
# Get the url for fetching the Transaction
$redirectUrl = $response->getRedirectUrl();
$redirectUrl = $response->getRedirectUrl();
} else {
# Payment failed
echo $response->getMessage();
Expand Down Expand Up @@ -291,7 +288,7 @@ if ($response->isSuccessful()) {

```php
$response = $gateway->captureAmount([
'captureAmountUrl' => $captureAmountUrl,
'captureAmountUrl' => $captureAmountUrl,
'amount' => '14.00'
])->send();

Expand Down Expand Up @@ -320,7 +317,7 @@ $item->setProductId('SKU01')
$arrItems[] = $item;

$response = $gateway->captureProducts([
'captureAmountUrl' => $captureProductsUrl,
'captureAmountUrl' => $captureProductsUrl,
'items' => $arrItems
])->send();

Expand Down Expand Up @@ -400,10 +397,10 @@ To run all tests:

## Environment Variables

| Variable | Description |
|----------|--------------------------------------------------|
| Variable | Description |
|----------------------|--------------------------------------------------|
| `PAYNL_SERVICE_CODE` | Your Pay.nl service location code (SL-xxxx-xxxx) |
| `PAYNL_API_SECRET` | Your Pay.nl API token |
| `PAYNL_API_SECRET` | Your Pay.nl API token |

# Support
https://www.pay.nl
Expand Down
4 changes: 2 additions & 2 deletions src/Internal/PayOrderNotFoundResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class PayOrderNotFoundResponse {

protected $data;
private $orderNotFoundStatusCode = 'PAY-2001';
private string $orderNotFoundStatusCode = 'PAY-2001';

public function __construct($data)
{
Expand Down Expand Up @@ -35,4 +35,4 @@ public function orderNotFoundState()
{
return $this->getCode() !== null && $this->getCode() === $this->orderNotFoundStatusCode ? true : false;
}
}
}
16 changes: 7 additions & 9 deletions src/Message/Request/AbstractPaynlRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ abstract class AbstractPaynlRequest extends AbstractRequest
/**
* @var string
*/
private $restUri = 'https://rest.pay.nl/v2/';
private $baseUrlPrefix = 'https://connect.';
private $ordersEdnpoint = 'v1/orders';
private string $restUri = 'https://rest.pay.nl/v2/';
private string $baseUrlPrefix = 'https://connect.';
private string $ordersEndpoint = 'v1/orders';


/**
Expand All @@ -30,7 +30,7 @@ public function sendRequestOrderApi(array $data)

foreach ($coreDomains as $coreDomain) {
try {
$url = $this->baseUrlPrefix . $coreDomain . '/' . $this->ordersEdnpoint;
$url = $this->baseUrlPrefix . $coreDomain . '/' . $this->ordersEndpoint;
$response = $this->sendRequest($url, $data, 'POST', false);

if ($response->getStatusCode() === 500 || $response->getStatusCode() === 503 || $response->getStatusCode() == null) {
Expand Down Expand Up @@ -74,10 +74,8 @@ public function sendRequest(string $url, array $data = null, string $method = 'G
{
return json_decode($response->getBody(), true);
}
else
{
return $response;
}

return $response;
}

/**
Expand Down Expand Up @@ -153,7 +151,7 @@ public function getCoreDomains(): array
{
$coreDomains = $this->getParameter('coreDomains');
if (!isset($coreDomains) || count($coreDomains) == 0) {
return array('pay.nl');
return ['pay.nl'];
}

return $coreDomains;
Expand Down
6 changes: 3 additions & 3 deletions src/Message/Request/CaptureProductsRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function getData()
$this->validate('tokenCode', 'apiSecret', 'captureProductsUrl', 'items');
$data = [
'url' => $this->getCaptureProductsUrl(),
'products' => array()
'products' => [],
];

if ($items = $this->getItems()) {
Expand Down Expand Up @@ -63,8 +63,8 @@ public function getItems()
return $this->getParameter('items');
}

public function setItems($value)
public function setItems($items)
{
return $this->setParameter('items', $value);
return $this->setParameter('items', $items);
}
}
3 changes: 1 addition & 2 deletions tests/TestBaseOmniPay.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace tests;

use Dotenv\Dotenv;
use Omnipay\Omnipay;
use PHPUnit\Framework\TestCase;

Expand Down Expand Up @@ -58,4 +57,4 @@ public function getStandardOrderPurchase()
$response = $this->gateway->purchase($form)->send();
return $response;
}
}
}
6 changes: 3 additions & 3 deletions tests/cases/AbortFlowTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function testAbortFlowCorrect()
$stateResponse = $gateway->abort(['abortUrl' => $abortUrl])->send();

$this->assertTrue($stateResponse->isSuccessful());
$this->assertEquals($stateResponse->getOrderStateCode(), -90);
$this->assertEquals($stateResponse->getOrderState(), 'CANCEL');
$this->assertEquals(-90, $stateResponse->getOrderStateCode());
$this->assertEquals('CANCEL', $stateResponse->getOrderState());
}
}
}
4 changes: 2 additions & 2 deletions tests/cases/ApproveFlowTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ public function testApproveBadFlow()
$approveResponse = $gateway->approve(['approveUrl' => $approveUrl])->send();

$this->assertFalse($approveResponse->isSuccessful());
$this->assertEquals($approveResponse->getMessage(), 'PAY-2004');
$this->assertEquals('PAY-2004', $approveResponse->getMessage());
}
}
}
10 changes: 5 additions & 5 deletions tests/cases/CaptureFlowTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function testCaptureRegularBadFlow()
$captureResponse = $gateway->capture(['captureUrl' => $captureUrl])->send();

$this->assertFalse($captureResponse->isSuccessful());
$this->assertEquals($captureResponse->getMessage(), 'PAY-2008');
$this->assertEquals('PAY-2008', $captureResponse->getMessage());
}

public function testCaptureAmountRegularBadFlow()
Expand All @@ -31,7 +31,7 @@ public function testCaptureAmountRegularBadFlow()
$captureResponse = $gateway->captureAmount(['captureAmountUrl' => $captureAmountUrl, 'amount' => '5.00'])->send();

$this->assertFalse($captureResponse->isSuccessful());
$this->assertEquals($captureResponse->getMessage(), 'PAY-2008');
$this->assertEquals('PAY-2008', $captureResponse->getMessage());
}

public function testCaptureProductRegularBadFlow()
Expand All @@ -54,7 +54,7 @@ public function testCaptureProductRegularBadFlow()
$captureResponse = $gateway->captureProducts(['captureProductsUrl' => $captureProductsUrl, 'items' => $arrItems])->send();

$this->assertFalse($captureResponse->isSuccessful());
$this->assertEquals($captureResponse->getMessage(), 'PAY-2008');
$this->assertEquals('PAY-2008', $captureResponse->getMessage());
}

public function testCaptureProductNoProductsBadFlow()
Expand All @@ -67,6 +67,6 @@ public function testCaptureProductNoProductsBadFlow()
$captureResponse = $gateway->captureProducts(['captureProductsUrl' => $captureProductsUrl, 'items' => []])->send();

$this->assertFalse($captureResponse->isSuccessful());
$this->assertEquals($captureResponse->getMessage(), 'PAY-1422');
$this->assertEquals('PAY-1422', $captureResponse->getMessage());
}
}
}
4 changes: 2 additions & 2 deletions tests/cases/DeclineFlowTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ public function testDeclineBadFlow()
$declineResponse = $gateway->decline(['declineUrl' => $declineUrl])->send();

$this->assertFalse($declineResponse->isSuccessful());
$this->assertEquals($declineResponse->getMessage(), 'PAY-2005');
$this->assertEquals('PAY-2005', $declineResponse->getMessage());
}
}
}
4 changes: 2 additions & 2 deletions tests/cases/PurchaseFlowTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function testAddressesWontError()
'transactionReference' => 'referenceID1',
'clientIp' => '192.168.192.12',
'serviceId' => $this->getServiceCode(),
'returnUrl' => 'http://www.yourdomain.com/return_from_pay',
'returnUrl' => 'https://www.yourdomain.com/return_from_pay',
'card' => array(
'firstName' => 'Example',
'lastName' => 'User',
Expand Down Expand Up @@ -59,4 +59,4 @@ public function testPurchaseResponse()
$this->assertNotEmpty($response->getRedirectUrl());
$this->assertNotEmpty($response->getTransactionReference());
}
}
}
4 changes: 2 additions & 2 deletions tests/cases/VoidFlowTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ public function testVoidBadFlow()
$voidResponse = $gateway->void(['voidUrl' => $voidUrl])->send();

$this->assertFalse($voidResponse->isSuccessful());
$this->assertEquals($voidResponse->getMessage(), 'PAY-2009');
$this->assertEquals('PAY-2009', $voidResponse->getMessage());
}
}
}