1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* CLI |
4
|
|
|
* |
5
|
|
|
* @author Pronamic <[email protected]> |
6
|
|
|
* @copyright 2005-2021 Pronamic |
7
|
|
|
* @license GPL-3.0-or-later |
8
|
|
|
* @package Pronamic\WordPress\Pay\Buckaroo |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace Pronamic\WordPress\Pay\Gateways\Buckaroo; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Title: CLI |
15
|
|
|
* Description: |
16
|
|
|
* Copyright: 2005-2021 Pronamic |
17
|
|
|
* Company: Pronamic |
18
|
|
|
* |
19
|
|
|
* @author Remco Tolsma |
20
|
|
|
* @version 2.1.0 |
21
|
|
|
* @since 2.1.0 |
22
|
|
|
* @link https://github.com/woocommerce/woocommerce/blob/3.9.0/includes/class-wc-cli.php |
23
|
|
|
*/ |
24
|
|
|
class CLI { |
25
|
|
|
/** |
26
|
|
|
* Construct CLI. |
27
|
|
|
*/ |
28
|
|
|
public function __construct( $integration ) { |
29
|
|
|
$this->integration = $integration; |
|
|
|
|
30
|
|
|
|
31
|
|
|
\WP_CLI::add_command( |
|
|
|
|
32
|
|
|
'pronamic-pay buckaroo transaction status', |
33
|
|
|
function( $args, $assoc_args ) { |
34
|
|
|
$this->wp_cli_transaction_status( $args, $assoc_args ); |
35
|
|
|
}, |
36
|
|
|
array( |
37
|
|
|
'shortdesc' => 'This returns the status for the provided transaction', |
38
|
|
|
) |
39
|
|
|
); |
40
|
|
|
|
41
|
|
|
\WP_CLI::add_command( |
42
|
|
|
'pronamic-pay buckaroo transaction refund-info', |
43
|
|
|
function( $args, $assoc_args ) { |
44
|
|
|
$this->wp_cli_transaction_refund_info( $args, $assoc_args ); |
45
|
|
|
}, |
46
|
|
|
array( |
47
|
|
|
'shortdesc' => 'This returns the refund info', |
48
|
|
|
) |
49
|
|
|
); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* CLI transaction status. |
54
|
|
|
* |
55
|
|
|
* @link https://testcheckout.buckaroo.nl/json/Docs/Api/GET-json-Transaction-Status-transactionKey |
56
|
|
|
* @param array<string> $args Arguments. |
57
|
|
|
* @param array<string> $assoc_args Associative arguments. |
58
|
|
|
* @return void |
59
|
|
|
*/ |
60
|
|
|
public function wp_cli_transaction_status( $args, $assoc_args ) { |
61
|
|
|
$gateway = $this->integration->get_gateway( $assoc_args['config_id'] ); |
62
|
|
|
|
63
|
|
|
foreach ( $args as $transaction_key ) { |
64
|
|
|
$result = $gateway->request( 'GET', 'Transaction/Status/' . $transaction_key ); |
65
|
|
|
|
66
|
|
|
\WP_CLI::line( \wp_json_encode( $result, \JSON_PRETTY_PRINT ) ); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* CLI transaction refund info. |
72
|
|
|
* |
73
|
|
|
* @link https://testcheckout.buckaroo.nl/json/Docs/Api/GET-json-Transaction-Status-transactionKey |
74
|
|
|
* @param array<string> $args Arguments. |
75
|
|
|
* @param array<string> $assoc_args Associative arguments. |
76
|
|
|
* @return void |
77
|
|
|
*/ |
78
|
|
|
public function wp_cli_transaction_refund_info( $args, $assoc_args ) { |
79
|
|
|
$gateway = $this->integration->get_gateway( $assoc_args['config_id'] ); |
80
|
|
|
|
81
|
|
|
foreach ( $args as $transaction_key ) { |
82
|
|
|
$result = $gateway->request( 'GET', 'Transaction/RefundInfo/' . $transaction_key ); |
83
|
|
|
|
84
|
|
|
\WP_CLI::line( \wp_json_encode( $result, \JSON_PRETTY_PRINT ) ); |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|