Skip to content

Commit 7c13740

Browse files
committed
Merge branch 'release/4.0.0'
2 parents f2646e7 + 4ec29b7 commit 7c13740

File tree

21 files changed

+462
-340
lines changed

21 files changed

+462
-340
lines changed

.github/workflows/main.yaml

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -285,32 +285,3 @@ jobs:
285285
run: |
286286
composer run-script coveralls
287287
bash <(curl -s https://codecov.io/bash)
288-
289-
es-sass-linting:
290-
name: Scripts and Styles
291-
292-
runs-on: ubuntu-latest
293-
294-
steps:
295-
- uses: actions/checkout@v2
296-
297-
# https://github.com/actions/cache/blob/master/examples.md#macos-and-ubuntu
298-
- uses: actions/cache@v2
299-
with:
300-
path: ~/.npm
301-
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
302-
restore-keys: |
303-
${{ runner.os }}-node-
304-
305-
- uses: actions/setup-node@v1
306-
with:
307-
node-version: '12'
308-
309-
- name: Install Node packages
310-
run: npm install
311-
312-
- name: ESLint
313-
run: npm run-script eslint
314-
315-
- name: Sass Lint
316-
run: npm run-script sass-lint

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@
1919

2020
# WordPress
2121
/wordpress/
22+
/wp-content/

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ This projects adheres to [Semantic Versioning](http://semver.org/) and [Keep a C
77
## [Unreleased][unreleased]
88
-
99

10+
## [4.0.0] - 2022-01-11
11+
### Changed
12+
- Updated to https://github.com/pronamic/wp-pay-core/releases/tag/4.0.0.
13+
14+
### Fixed
15+
- Fix "Fatal error: Uncaught Exception: Could not JSON decode response, HTTP response: "400 Bad Request", HTTP body length: "67", JSON error: "Syntax error"." when getting issuers with invalid configuration.
16+
1017
## [3.0.2] - 2021-08-18
1118
- Fix "Fatal error: Uncaught Error: Undefined class constant 'V_PAY'".
1219

@@ -104,7 +111,8 @@ This projects adheres to [Semantic Versioning](http://semver.org/) and [Keep a C
104111
## [1.0.0] - 2015-01-19
105112
- First release.
106113

107-
[unreleased]: https://github.com/wp-pay-gateways/buckaroo/compare/3.0.2...HEAD
114+
[unreleased]: https://github.com/wp-pay-gateways/buckaroo/compare/4.0.0...HEAD
115+
[4.0.0]: https://github.com/wp-pay-gateways/buckaroo/compare/3.0.2...4.0.0
108116
[3.0.2]: https://github.com/wp-pay-gateways/buckaroo/compare/3.0.1...3.0.2
109117
[3.0.1]: https://github.com/wp-pay-gateways/buckaroo/compare/3.0.0...3.0.1
110118
[3.0.0]: https://github.com/wp-pay-gateways/buckaroo/compare/2.2.0...3.0.0

composer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
},
3434
"require": {
3535
"php": ">=5.6.20",
36-
"pronamic/wp-http": "^1.0",
37-
"wp-pay/core": "^3.0"
36+
"pronamic/wp-http": "^1.1",
37+
"wp-pay/core": "^4.0"
3838
},
3939
"require-dev": {
4040
"bamarni/composer-bin-plugin": "^1.4",
@@ -45,7 +45,8 @@
4545
"pronamic/wp-coding-standards": "^1.0",
4646
"roots/wordpress": "^5.8",
4747
"wp-cli/wp-cli": "^2.3",
48-
"wp-phpunit/wp-phpunit": "^5.8"
48+
"wp-phpunit/wp-phpunit": "^5.8",
49+
"yoast/phpunit-polyfills": "^1.0"
4950
},
5051
"scripts": {
5152
"coveralls": "vendor/bin/php-coveralls -v",

docs/hooks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Argument | Type | Description
3333
-------- | ---- | -----------
3434
`$push_url` | `string` | Buckaroo push URL.
3535

36-
Source: [src/Gateway.php](../src/Gateway.php), [line 116](../src/Gateway.php#L116-L125)
36+
Source: [src/Gateway.php](../src/Gateway.php), [line 137](../src/Gateway.php#L137-L146)
3737

3838

3939
<p align="center"><a href="https://github.com/pronamic/wp-documentor"><img src="https://cdn.jsdelivr.net/gh/pronamic/wp-documentor@main/logos/pronamic-wp-documentor.svgo-min.svg" alt="Pronamic WordPress Documentor" width="32" height="32"></a><br><em>Generated by <a href="https://github.com/pronamic/wp-documentor">Pronamic WordPress Documentor</a> <code>1.1.0</code></em><p>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "buckaroo",
3-
"version": "3.0.2",
3+
"version": "4.0.0",
44
"description": "Buckaroo driver for the WordPress payment processing library.",
55
"repository": {
66
"type": "git",

src/CLI.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* CLI
44
*
55
* @author Pronamic <info@pronamic.eu>
6-
* @copyright 2005-2021 Pronamic
6+
* @copyright 2005-2022 Pronamic
77
* @license GPL-3.0-or-later
88
* @package Pronamic\WordPress\Pay\Buckaroo
99
*/
@@ -13,7 +13,7 @@
1313
/**
1414
* Title: CLI
1515
* Description:
16-
* Copyright: 2005-2021 Pronamic
16+
* Copyright: 2005-2022 Pronamic
1717
* Company: Pronamic
1818
*
1919
* @author Remco Tolsma

src/Config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/**
88
* Title: Buckaroo config
99
* Description:
10-
* Copyright: 2005-2021 Pronamic
10+
* Copyright: 2005-2022 Pronamic
1111
* Company: Pronamic
1212
*
1313
* @author Remco Tolsma

src/Gateway.php

Lines changed: 59 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
use Pronamic\WordPress\Pay\Banks\BankAccountDetails;
77
use Pronamic\WordPress\Pay\Core\Gateway as Core_Gateway;
88
use Pronamic\WordPress\Pay\Core\PaymentMethods as Core_PaymentMethods;
9-
use Pronamic\WordPress\Pay\Core\Server;
109
use Pronamic\WordPress\Pay\Payments\Payment;
1110
use Pronamic\WordPress\Pay\Payments\PaymentStatus;
11+
use WP_Error;
1212

1313
/**
1414
* Title: Buckaroo gateway
1515
* Description:
16-
* Copyright: 2005-2021 Pronamic
16+
* Copyright: 2005-2022 Pronamic
1717
* Company: Pronamic
1818
*
1919
* @author Remco Tolsma
@@ -50,22 +50,44 @@ public function __construct( Config $config ) {
5050
public function get_issuers() {
5151
$groups = array();
5252

53-
$object = $this->request( 'GET', 'Transaction/Specification/ideal?serviceVersion=2' );
53+
// Check non-empty keys in configuration.
54+
if ( empty( $this->config->website_key ) || empty( $this->config->secret_key ) ) {
55+
return $groups;
56+
}
57+
58+
// Get iDEAL issuers.
59+
try {
60+
$object = $this->request( 'GET', 'Transaction/Specification/ideal?serviceVersion=2' );
61+
} catch ( \Exception $e ) {
62+
$this->set_error( new WP_Error( 'buckaroo_error', $e->getMessage() ) );
63+
64+
return $groups;
65+
}
66+
67+
if ( \property_exists( $object, 'Actions' ) ) {
68+
foreach ( $object->Actions as $action ) {
69+
// Check action name.
70+
if ( 'Pay' !== $action->Name ) {
71+
continue;
72+
}
5473

55-
foreach ( $object->Actions as $action ) {
56-
if ( 'Pay' === $action->Name ) {
5774
foreach ( $action->RequestParameters as $request_parameter ) {
58-
if ( 'issuer' === $request_parameter->Name ) {
59-
foreach ( $request_parameter->ListItemDescriptions as $item ) {
60-
if ( ! array_key_exists( $item->GroupName, $groups ) ) {
61-
$groups[ $item->GroupName ] = array(
62-
'name' => $item->GroupName,
63-
'options' => array(),
64-
);
65-
}
66-
67-
$groups[ $item->GroupName ]['options'][ $item->Value ] = $item->Description;
75+
// Check request parameter name.
76+
if ( 'issuer' !== $request_parameter->Name ) {
77+
continue;
78+
}
79+
80+
foreach ( $request_parameter->ListItemDescriptions as $item ) {
81+
// Make sure to add group.
82+
if ( ! array_key_exists( $item->GroupName, $groups ) ) {
83+
$groups[ $item->GroupName ] = array(
84+
'name' => $item->GroupName,
85+
'options' => array(),
86+
);
6887
}
88+
89+
// Add issuer to group.
90+
$groups[ $item->GroupName ]['options'][ $item->Value ] = $item->Description;
6991
}
7092
}
7193
}
@@ -270,11 +292,9 @@ public function start( Payment $payment ) {
270292
* @link https://testcheckout.buckaroo.nl/json/Docs/ResourceModel?modelName=ServicesRequest
271293
* @link https://testcheckout.buckaroo.nl/json/Docs/ResourceModel?modelName=ServiceRequest
272294
*/
273-
$payment_method = $payment->get_method();
274-
275-
switch ( $payment_method ) {
295+
switch ( $payment->get_payment_method() ) {
276296
/**
277-
* Paymet method American Express.
297+
* Payment method American Express.
278298
*
279299
* @link
280300
*/
@@ -324,7 +344,7 @@ public function start( Payment $payment ) {
324344
'Parameters' => array(
325345
array(
326346
'Name' => 'issuer',
327-
'Value' => $payment->get_issuer(),
347+
'Value' => $payment->get_meta( 'issuer' ),
328348
),
329349
),
330350
);
@@ -356,7 +376,7 @@ public function start( Payment $payment ) {
356376

357377
break;
358378
/**
359-
* Paymet method Maestro.
379+
* Payment method Maestro.
360380
*
361381
* @link
362382
*/
@@ -368,7 +388,7 @@ public function start( Payment $payment ) {
368388

369389
break;
370390
/**
371-
* Paymet method Mastercard.
391+
* Payment method Mastercard.
372392
*
373393
* @link
374394
*/
@@ -416,7 +436,7 @@ public function start( Payment $payment ) {
416436

417437
break;
418438
/**
419-
* Paymet method V PAY.
439+
* Payment method V PAY.
420440
*
421441
* @link https://dev.buckaroo.nl/PaymentMethods/Description/creditcards#top
422442
*/
@@ -428,7 +448,7 @@ public function start( Payment $payment ) {
428448

429449
break;
430450
/**
431-
* Paymet method Visa.
451+
* Payment method Visa.
432452
*
433453
* @link https://dev.buckaroo.nl/PaymentMethods/Description/creditcards#top
434454
*/
@@ -521,6 +541,7 @@ public function start( Payment $payment ) {
521541
* @param string $method HTTP request method.
522542
* @param string $endpoint JSON API endpoint.
523543
* @param object|null $data Data.
544+
* @return object
524545
*/
525546
public function request( $method, $endpoint, $data = null ) {
526547
$host = 'checkout.buckaroo.nl';
@@ -582,7 +603,20 @@ public function request( $method, $endpoint, $data = null ) {
582603
)
583604
);
584605

585-
$object = $response->json();
606+
try {
607+
$object = $response->json();
608+
} catch ( \Exception $e ) {
609+
// JSON error.
610+
$json_error = \json_last_error();
611+
612+
// Check authorization error.
613+
if ( \JSON_ERROR_NONE !== $json_error && 400 === $response->status() ) {
614+
throw new \Exception( $response->body() );
615+
}
616+
617+
// Re-throw original response exception.
618+
throw $e;
619+
}
586620

587621
/**
588622
* OK.

src/Integration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/**
88
* Title: Buckaroo integration
99
* Description:
10-
* Copyright: 2005-2021 Pronamic
10+
* Copyright: 2005-2022 Pronamic
1111
* Company: Pronamic
1212
*
1313
* @author Reüel van der Steege

0 commit comments

Comments
 (0)