1 | <?php |
||
2 | /** |
||
3 | * Page payment. |
||
4 | * |
||
5 | * @author Pronamic <[email protected]> |
||
6 | * @copyright 2005-2022 Pronamic |
||
7 | * @license GPL-3.0-or-later |
||
8 | * @package Pronamic\WordPress\Pay\Gateways\Mollie |
||
9 | */ |
||
10 | |||
11 | namespace Pronamic\WordPress\Pay\Gateways\Mollie; |
||
12 | |||
13 | use Pronamic\WordPress\Pay\Admin\AdminPaymentPostType; |
||
14 | |||
15 | $mollie_payment_id = \filter_input( INPUT_GET, 'id', FILTER_SANITIZE_STRING ); |
||
16 | |||
17 | $payment = \get_pronamic_payment_by_transaction_id( $mollie_payment_id ); |
||
18 | |||
19 | $command_curl = null; |
||
20 | $command_httpie = null; |
||
21 | |||
22 | if ( null !== $payment ) { |
||
23 | $api_key = \get_post_meta( (int) $payment->get_config_id(), '_pronamic_gateway_mollie_api_key', true ); |
||
24 | |||
25 | $client = new Client( (string) $api_key ); |
||
26 | |||
27 | /** |
||
28 | * Payment. |
||
29 | * |
||
30 | * @link https://docs.mollie.com/reference/v2/payments-api/get-payment |
||
31 | */ |
||
32 | $mollie_payment = $client->get_payment( |
||
33 | $mollie_payment_id, |
||
34 | array( |
||
35 | 'embed' => 'chargebacks,refunds', |
||
36 | ) |
||
37 | ); |
||
38 | |||
39 | /** |
||
40 | * Commands. |
||
41 | */ |
||
42 | $url = \sprintf( 'https://api.mollie.com/v2/payments/%s', $mollie_payment_id ); |
||
43 | |||
44 | $command_curl = 'curl -X GET %s \\' . "\r\n"; |
||
45 | $command_curl .= "\t" . '-H "Authorization: Bearer %s"'; |
||
46 | |||
47 | $command_curl = \sprintf( $command_curl, $url, $api_key ); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
48 | |||
49 | $command_httpie = 'http GET %s \\' . "\r\n"; |
||
50 | $command_httpie .= "\t" . '"Authorization:Bearer %s"'; |
||
51 | |||
52 | $command_httpie = \sprintf( $command_httpie, $url, $api_key ); |
||
53 | } |
||
54 | |||
55 | ?> |
||
56 | <div class="wrap"> |
||
57 | <h1><?php echo \esc_html( \get_admin_page_title() ); ?></h1> |
||
58 | |||
59 | <h2> |
||
60 | <?php |
||
61 | |||
62 | echo \wp_kses( |
||
63 | \sprintf( |
||
64 | /* translators: %s: payment number */ |
||
65 | \__( 'Payment %s', 'pronamic_ideal' ), |
||
66 | \sprintf( |
||
67 | '<code>%s</code>', |
||
68 | $mollie_payment_id |
||
69 | ) |
||
70 | ), |
||
71 | array( |
||
72 | 'code' => array(), |
||
73 | ) |
||
74 | ); |
||
75 | |||
76 | ?> |
||
77 | </h2> |
||
78 | |||
79 | <table class="form-table"> |
||
80 | <tbody> |
||
81 | <tr> |
||
82 | <th scope="row"><?php \esc_html_e( 'ID', 'pronamic_ideal' ); ?></th> |
||
83 | <td> |
||
84 | <code><?php echo \esc_html( $mollie_payment_id ); ?></code> |
||
85 | </td> |
||
86 | </tr> |
||
87 | <tr> |
||
88 | <th scope="row"><?php \esc_html_e( 'Link', 'pronamic_ideal' ); ?></th> |
||
89 | <td> |
||
90 | <?php |
||
91 | |||
92 | $mollie_link = \sprintf( |
||
93 | 'https://www.mollie.com/dashboard/payments/%s', |
||
94 | $mollie_payment_id |
||
95 | ); |
||
96 | |||
97 | \printf( |
||
98 | '<a href="%s">%s</a>', |
||
99 | \esc_url( $mollie_link ), |
||
100 | \esc_html( $mollie_link ) |
||
101 | ); |
||
102 | |||
103 | ?> |
||
104 | </td> |
||
105 | </tr> |
||
106 | |||
107 | <?php if ( null !== $payment ) : ?> |
||
108 | |||
109 | <?php |
||
110 | |||
111 | $url = $payment->get_meta( 'mollie_change_payment_state_url' ); |
||
112 | |||
113 | if ( ! empty( $url ) ) : |
||
114 | |||
115 | ?> |
||
116 | |||
117 | <tr> |
||
118 | <th scope="row"><?php \esc_html_e( 'Change Payment State', 'pronamic_ideal' ); ?></th> |
||
119 | <td> |
||
120 | <?php |
||
121 | |||
122 | \printf( |
||
123 | '<a href="%1$s" title="%2$s">%3$s</a>', |
||
124 | \esc_url( $url ), |
||
125 | \esc_attr( \__( 'Change Payment State', 'pronamic_ideal' ) ), |
||
126 | \esc_html( $url ) |
||
127 | ); |
||
128 | |||
129 | ?> |
||
130 | </td> |
||
131 | </tr> |
||
132 | |||
133 | <?php endif; ?> |
||
134 | |||
135 | <tr> |
||
136 | <th scope="row"><?php \esc_html_e( 'Pronamic Pay Payment', 'pronamic_ideal' ); ?></th> |
||
137 | <td> |
||
138 | <?php |
||
139 | |||
140 | \do_action( |
||
141 | 'manage_' . AdminPaymentPostType::POST_TYPE . '_posts_custom_column', |
||
142 | 'pronamic_payment_title', |
||
143 | $payment->get_id() |
||
144 | ); |
||
145 | |||
146 | ?> |
||
147 | </td> |
||
148 | </tr> |
||
149 | |||
150 | <?php endif; ?> |
||
151 | |||
152 | <?php if ( pronamic_pay_plugin()->is_debug_mode() ) : ?> |
||
153 | |||
154 | <?php if ( null !== $command_curl ) : ?> |
||
155 | |||
156 | <tr> |
||
157 | <th scope="row"><?php \esc_html_e( 'cURL', 'pronamic_ideal' ); ?></th> |
||
158 | <td> |
||
159 | <pre style="margin: 0;"><?php echo \esc_html( $command_curl ); ?></pre> |
||
160 | </td> |
||
161 | </tr> |
||
162 | |||
163 | <?php endif; ?> |
||
164 | |||
165 | <?php if ( null !== $command_httpie ) : ?> |
||
166 | |||
167 | <tr> |
||
168 | <th scope="row"><?php \esc_html_e( 'HTTPie', 'pronamic_ideal' ); ?></th> |
||
169 | <td> |
||
170 | <pre style="margin: 0;"><?php echo \esc_html( $command_httpie ); ?></pre> |
||
171 | </td> |
||
172 | </tr> |
||
173 | |||
174 | <?php endif; ?> |
||
175 | |||
176 | <?php endif; ?> |
||
177 | |||
178 | </tbody> |
||
179 | </table> |
||
180 | </div> |
||
181 |