Skip to content

Commit f86af8e

Browse files
committed
feat/omni-core-provided
1 parent a4d709b commit f86af8e

38 files changed

+998
-285
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ vendor/*
33
samples/*
44
logs/*
55
composer.lock
6-
build/*
6+
build/*
7+
.env
8+
phpunit.xml

README.md

+153-27
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Pay. driver for the Omnipay payment processing library
1313
- [Installation](#installation)
1414
- [Update instructions](#update-instructions)
1515
- [Usage](#usage)
16+
- [Tests](#test)
1617
- [Support](#support)
1718

1819

@@ -34,7 +35,10 @@ Bank Transfer | Cartasi | GivaCard | SprayPay | Przelewy24 |
3435

3536
# Requirements
3637

37-
PHP 5.6 or higher
38+
Before running the tests, make sure you have:
39+
- PHP installed (7.4 or higher recommended)
40+
- Composer installed
41+
- A Pay.nl account with API credentials
3842

3943

4044
# Installation
@@ -66,10 +70,11 @@ use Omnipay\Omnipay;
6670
$gateway = Omnipay::create('PaynlV3');
6771

6872
$gateway->setApiSecret('****************************************');
69-
$gateway->setTokenCode('SL-####-####');
73+
$gateway->setTokenCode('AT-####-####');
74+
$gateway->setServiceId('SL-####-####');
7075
```
7176

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

7479
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.
7580

@@ -90,9 +95,7 @@ The plugin has now been updated
9095
# Usage
9196
### Get payment methods
9297
```php
93-
$response = $gateway->fetchPaymentMethods([
94-
'serviceId' => "SL-####-####",
95-
])->send();
98+
$response = $gateway->fetchPaymentMethods()->send();
9699

97100
$response->getPaymentMethods();
98101

@@ -107,9 +110,7 @@ foreach ($response->getPaymentMethods() as $paymentMethod) {
107110

108111
### Get Issuers (Ideal)
109112
```php
110-
$response = $gateway->fetchIssuers([
111-
'serviceId' => "SL-####-####",
112-
])->send();
113+
$response = $gateway->fetchIssuers()->send();
113114

114115
$response->getIssuers();
115116

@@ -205,26 +206,76 @@ if ($response->isSuccessful()) {
205206
$statusUrl = $response->getStatusUrl();
206207
$voidUrl = $response->getVoidUrl();
207208
$redirectUrl = $response->getRedirectUrl();
209+
$givenCaptureUrl = $response->getCaptureUrl();
210+
$givenCaptureAmountUrl = $response->getCaptureAmountUrl();
211+
$givenCaptureProductsUrl = $response->getCaptureProductsUrl();
212+
$abortUrl = $response->getAbortUrl();
213+
$approveUrl = $response->getApproveUrl();
214+
$declineUrl = $response->getDeclineUrl();
215+
$debugUrl = $response->getDebugUrl();
216+
$checkoutUrl = $response->getCheckoutUrl();
217+
}
208218

209219
# Payment was successful
210220
var_dump($response);
211221

212222
} elseif ($response->isRedirect()) {
213223
# Get the url for fetching the Transaction
214-
get
215-
224+
$redirectUrl = $response->getRedirectUrl();
216225
} else {
217-
218226
# Payment failed
219227
echo $response->getMessage();
220228
}
221229
```
222230
### Get a transaction (Order:status)
223231

224232
```php
225-
$response = $gateway->fetchTransaction([
226-
'transactionReference' => "##########",
227-
])->send();
233+
$response = $gateway->fetchTransaction(['stateUrl' => $statusUrl])->send();
234+
235+
if ($response->isSuccessful()) {
236+
# Get was successful
237+
print_r($response);
238+
239+
} else {
240+
# Get failed
241+
echo $response->getMessage();
242+
}
243+
```
244+
245+
### Approve order (Order:approve)
246+
247+
```php
248+
$response = $gateway->approve(['approveUrl' => $approveUrl])->send();
249+
250+
if ($response->isSuccessful()) {
251+
# Get was successful
252+
print_r($response);
253+
254+
} else {
255+
# Get failed
256+
echo $response->getMessage();
257+
}
258+
```
259+
260+
### Approve order (Order:Decline)
261+
262+
```php
263+
$response = $gateway->decline(['declineUrl' => $declineUrl])->send();
264+
265+
if ($response->isSuccessful()) {
266+
# Get was successful
267+
print_r($response);
268+
269+
} else {
270+
# Get failed
271+
echo $response->getMessage();
272+
}
273+
```
274+
275+
### Capture order (Order:Capture)
276+
277+
```php
278+
$response = $gateway->capture(['captureUrl' => $captureUrl])->send();
228279

229280
if ($response->isSuccessful()) {
230281
# Get was successful
@@ -236,19 +287,41 @@ if ($response->isSuccessful()) {
236287
}
237288
```
238289

239-
### Refund a transaction
290+
### Capture amount order (Order:CaptureAmount)
291+
240292
```php
241-
$response = $gateway->refund([
242-
'transactionReference' => '##########'
243-
])->send();```
293+
$response = $gateway->captureAmount([
294+
'captureAmountUrl' => $captureAmountUrl,
295+
'amount' => '14.00'
296+
])->send();
297+
298+
if ($response->isSuccessful()) {
299+
# Get was successful
300+
print_r($response);
301+
302+
} else {
303+
# Get failed
304+
echo $response->getMessage();
305+
}
306+
```
307+
308+
### Capture products order (Order:CaptureProducts)
244309

245-
### Capture a transaction
246310
```php
311+
$arrItems = array();
312+
$item = new Item();
313+
$item->setProductId('SKU01')
314+
->setProductType('ARTICLE')
315+
->setVatPercentage(21)
316+
->setDescription('Description')
317+
->setPrice('10')
318+
->setQuantity(4);
319+
320+
$arrItems[] = $item;
247321

248-
$response = $gateway->capture([
249-
'transactionReference' => '##########',
250-
'amount' => '23.32',
251-
'items' => array(),
322+
$response = $gateway->captureProducts([
323+
'captureAmountUrl' => $captureProductsUrl,
324+
'items' => $arrItems
252325
])->send();
253326

254327
if ($response->isSuccessful()) {
@@ -259,15 +332,29 @@ if ($response->isSuccessful()) {
259332
# Get failed
260333
echo $response->getMessage();
261334
}
335+
```
336+
337+
### Capture products order (Order:Abort)
338+
339+
```php
340+
$response = $gateway->abort([
341+
'abortUrl' => $abortUrl
342+
])->send();
262343

344+
if ($response->isSuccessful()) {
345+
# Get was successful
346+
print_r($response);
347+
348+
} else {
349+
# Get failed
350+
echo $response->getMessage();
351+
}
263352
```
264353

265354
### Void a transaction
266355

267356
```php
268-
$response = $gateway->void([
269-
'transactionReference' => "##########",
270-
])->send();
357+
$response = $gateway->void(['voidUrl' => $voidUrl])->send();
271358

272359
if ($response->isSuccessful()) {
273360
# Get was successful
@@ -279,6 +366,45 @@ if ($response->isSuccessful()) {
279366
}
280367
```
281368

369+
# Test
370+
371+
Before running the tests, make sure you have:
372+
- PHP installed (7.4 or higher recommended)
373+
- Composer installed
374+
- A Pay.nl account with API credentials
375+
376+
## Setup
377+
378+
1. Install dependencies:
379+
```bash
380+
composer install
381+
```
382+
383+
2. Create a copy of the phpunit configuration file:
384+
```bash
385+
cp phpunit.xml.dist phpunit.xml
386+
```
387+
388+
3. Configure environment variables in your `phpunit.xml`:
389+
390+
Replace the empty values with your Pay.nl credentials:
391+
392+
> **Note**: Never commit your actual API credentials to version control. The `phpunit.xml` file should be in your `.gitignore`.
393+
394+
## Running Tests
395+
396+
To run all tests:
397+
```bash
398+
./vendor/bin/phpunit --testsuite "Omni pay v3 tests"
399+
```
400+
401+
## Environment Variables
402+
403+
| Variable | Description |
404+
|----------|--------------------------------------------------|
405+
| `PAYNL_SERVICE_CODE` | Your Pay.nl service location code (SL-xxxx-xxxx) |
406+
| `PAYNL_API_SECRET` | Your Pay.nl API token |
407+
282408
# Support
283409
https://www.pay.nl
284410

composer.json

+10-6
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,28 @@
33
"description": "Pay.nl driver for the Omnipay PHP payment processing library based on the V3 PayNL orders API",
44
"type": "library",
55
"require": {
6+
"php": "^7.4|^8",
7+
"phpunit/phpunit": "^10.0",
68
"omnipay/common": "^3.3",
79
"ext-json": "*"
810
},
11+
"require-dev": {
12+
"php-http/guzzle7-adapter": "^1"
13+
},
914
"license": "MIT",
1015
"autoload": {
1116
"psr-4": {
1217
"Omnipay\\PaynlV3\\": "src/"
1318
}
1419
},
15-
"authors": [
16-
{
17-
"name": "Bas van der Ven",
18-
"email": "[email protected]"
20+
"autoload-dev": {
21+
"psr-4": {
22+
"tests\\": "tests/"
1923
}
20-
],
24+
},
2125
"config": {
2226
"allow-plugins": {
23-
"php-http/discovery": false
27+
"php-http/discovery": true
2428
}
2529
}
2630
}

phpunit.xml.dist

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<phpunit colors="true" bootstrap="vendor/autoload.php">
2+
<php>
3+
<env name="PAYNL_SERVICE_CODE" value="" force="true"/>
4+
<env name="PAYNL_API_SECRET" value="" force="true"/>
5+
</php>
6+
<testsuites>
7+
<testsuite name="Omni pay v3 tests">
8+
<directory>tests</directory>
9+
</testsuite>
10+
</testsuites>
11+
</phpunit>

0 commit comments

Comments
 (0)