@@ -23,10 +23,10 @@ |
||
23 | 23 | $this->provider = 'nocks'; |
24 | 24 | |
25 | 25 | // Actions |
26 | - $function = array( __NAMESPACE__ . '\Listener', 'listen' ); |
|
26 | + $function = array(__NAMESPACE__ . '\Listener', 'listen'); |
|
27 | 27 | |
28 | - if ( ! has_action( 'wp_loaded', $function ) ) { |
|
29 | - add_action( 'wp_loaded', $function ); |
|
28 | + if ( ! has_action('wp_loaded', $function)) { |
|
29 | + add_action('wp_loaded', $function); |
|
30 | 30 | } |
31 | 31 | } |
32 | 32 |
@@ -16,28 +16,28 @@ |
||
16 | 16 | */ |
17 | 17 | class Listener { |
18 | 18 | public static function listen() { |
19 | - if ( ! filter_has_var( INPUT_GET, 'nocks_webhook' ) ) { |
|
19 | + if ( ! filter_has_var(INPUT_GET, 'nocks_webhook')) { |
|
20 | 20 | return; |
21 | 21 | } |
22 | 22 | |
23 | - $transaction_id = file_get_contents( 'php://input' ); |
|
23 | + $transaction_id = file_get_contents('php://input'); |
|
24 | 24 | |
25 | - $payment = get_pronamic_payment_by_transaction_id( $transaction_id ); |
|
25 | + $payment = get_pronamic_payment_by_transaction_id($transaction_id); |
|
26 | 26 | |
27 | - if ( null === $payment ) { |
|
27 | + if (null === $payment) { |
|
28 | 28 | return; |
29 | 29 | } |
30 | 30 | |
31 | 31 | // Add note. |
32 | 32 | $note = sprintf( |
33 | 33 | /* translators: %s: Nocks */ |
34 | - __( 'Webhook requested by %s.', 'pronamic_ideal' ), |
|
35 | - __( 'Nocks', 'pronamic_ideal' ) |
|
34 | + __('Webhook requested by %s.', 'pronamic_ideal'), |
|
35 | + __('Nocks', 'pronamic_ideal') |
|
36 | 36 | ); |
37 | 37 | |
38 | - $payment->add_note( $note ); |
|
38 | + $payment->add_note($note); |
|
39 | 39 | |
40 | 40 | // Update payment. |
41 | - Plugin::update_payment( $payment, false ); |
|
41 | + Plugin::update_payment($payment, false); |
|
42 | 42 | } |
43 | 43 | } |
@@ -20,8 +20,8 @@ discard block |
||
20 | 20 | * Settings constructor. |
21 | 21 | */ |
22 | 22 | public function __construct() { |
23 | - add_filter( 'pronamic_pay_gateway_sections', array( $this, 'sections' ) ); |
|
24 | - add_filter( 'pronamic_pay_gateway_fields', array( $this, 'fields' ) ); |
|
23 | + add_filter('pronamic_pay_gateway_sections', array($this, 'sections')); |
|
24 | + add_filter('pronamic_pay_gateway_fields', array($this, 'fields')); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -31,17 +31,17 @@ discard block |
||
31 | 31 | * |
32 | 32 | * @return array |
33 | 33 | */ |
34 | - public function sections( array $sections ) { |
|
34 | + public function sections(array $sections) { |
|
35 | 35 | $sections['nocks'] = array( |
36 | - 'title' => __( 'Nocks', 'pronamic_ideal' ), |
|
37 | - 'methods' => array( 'nocks' ), |
|
36 | + 'title' => __('Nocks', 'pronamic_ideal'), |
|
37 | + 'methods' => array('nocks'), |
|
38 | 38 | ); |
39 | 39 | |
40 | 40 | // Transaction feedback. |
41 | 41 | $sections['nocks_feedback'] = array( |
42 | - 'title' => __( 'Transaction feedback', 'pronamic_ideal' ), |
|
43 | - 'methods' => array( 'nocks' ), |
|
44 | - 'description' => __( 'Payment status updates will be processed without any additional configuration. The <em>Webhook URL</em> is being used to receive the status updates.', 'pronamic_ideal' ), |
|
42 | + 'title' => __('Transaction feedback', 'pronamic_ideal'), |
|
43 | + 'methods' => array('nocks'), |
|
44 | + 'description' => __('Payment status updates will be processed without any additional configuration. The <em>Webhook URL</em> is being used to receive the status updates.', 'pronamic_ideal'), |
|
45 | 45 | ); |
46 | 46 | |
47 | 47 | return $sections; |
@@ -54,15 +54,15 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @return array |
56 | 56 | */ |
57 | - public function fields( array $fields ) { |
|
57 | + public function fields(array $fields) { |
|
58 | 58 | // Access token. |
59 | 59 | $fields[] = array( |
60 | 60 | 'filter' => FILTER_SANITIZE_STRING, |
61 | 61 | 'section' => 'nocks', |
62 | 62 | 'meta_key' => '_pronamic_gateway_nocks_access_token', |
63 | - 'title' => _x( 'Access Token', 'nocks', 'pronamic_ideal' ), |
|
63 | + 'title' => _x('Access Token', 'nocks', 'pronamic_ideal'), |
|
64 | 64 | 'type' => 'textarea', |
65 | - 'classes' => array( 'code' ), |
|
65 | + 'classes' => array('code'), |
|
66 | 66 | ); |
67 | 67 | |
68 | 68 | // Merchant profile. |
@@ -70,32 +70,32 @@ discard block |
||
70 | 70 | 'filter' => FILTER_SANITIZE_STRING, |
71 | 71 | 'section' => 'nocks', |
72 | 72 | 'meta_key' => '_pronamic_gateway_nocks_merchant_profile', |
73 | - 'title' => _x( 'Merchant Profile', 'nocks', 'pronamic_ideal' ), |
|
73 | + 'title' => _x('Merchant Profile', 'nocks', 'pronamic_ideal'), |
|
74 | 74 | 'type' => 'description', |
75 | - 'callback' => array( $this, 'field_merchant_profile' ), |
|
75 | + 'callback' => array($this, 'field_merchant_profile'), |
|
76 | 76 | ); |
77 | 77 | |
78 | 78 | // Transaction feedback. |
79 | 79 | $fields[] = array( |
80 | 80 | 'section' => 'nocks', |
81 | - 'title' => __( 'Transaction feedback', 'pronamic_ideal' ), |
|
81 | + 'title' => __('Transaction feedback', 'pronamic_ideal'), |
|
82 | 82 | 'type' => 'description', |
83 | 83 | 'html' => sprintf( |
84 | 84 | '<span class="dashicons dashicons-yes"></span> %s', |
85 | - __( 'Payment status updates will be processed without any additional configuration.', 'pronamic_ideal' ) |
|
85 | + __('Payment status updates will be processed without any additional configuration.', 'pronamic_ideal') |
|
86 | 86 | ), |
87 | 87 | ); |
88 | 88 | |
89 | 89 | // Webhook URL. |
90 | 90 | $fields[] = array( |
91 | 91 | 'section' => 'nocks_feedback', |
92 | - 'title' => __( 'Webhook URL', 'pronamic_ideal' ), |
|
92 | + 'title' => __('Webhook URL', 'pronamic_ideal'), |
|
93 | 93 | 'type' => 'text', |
94 | - 'classes' => array( 'large-text', 'code' ), |
|
95 | - 'value' => add_query_arg( 'nocks_webhook', '', home_url( '/' ) ), |
|
94 | + 'classes' => array('large-text', 'code'), |
|
95 | + 'value' => add_query_arg('nocks_webhook', '', home_url('/')), |
|
96 | 96 | 'readonly' => true, |
97 | - 'methods' => array( 'nocks' ), |
|
98 | - 'tooltip' => __( 'The Webhook URL as sent with each transaction to receive automatic payment status updates on.', 'pronamic_ideal' ), |
|
97 | + 'methods' => array('nocks'), |
|
98 | + 'tooltip' => __('The Webhook URL as sent with each transaction to receive automatic payment status updates on.', 'pronamic_ideal'), |
|
99 | 99 | ); |
100 | 100 | |
101 | 101 | return $fields; |
@@ -106,28 +106,28 @@ discard block |
||
106 | 106 | * |
107 | 107 | * @param array $field Settings field. |
108 | 108 | */ |
109 | - public function field_merchant_profile( $field ) { |
|
110 | - $access_token = get_post_meta( get_the_ID(), '_pronamic_gateway_nocks_access_token', true ); |
|
111 | - $merchant_profile = get_post_meta( get_the_ID(), '_pronamic_gateway_nocks_merchant_profile', true ); |
|
109 | + public function field_merchant_profile($field) { |
|
110 | + $access_token = get_post_meta(get_the_ID(), '_pronamic_gateway_nocks_access_token', true); |
|
111 | + $merchant_profile = get_post_meta(get_the_ID(), '_pronamic_gateway_nocks_merchant_profile', true); |
|
112 | 112 | |
113 | - if ( ! $access_token ) { |
|
114 | - esc_html_e( 'First enter an API Key and save the configuration, to be able to choose from your Nocks merchant profiles.', 'pronamic_ideal' ); |
|
113 | + if ( ! $access_token) { |
|
114 | + esc_html_e('First enter an API Key and save the configuration, to be able to choose from your Nocks merchant profiles.', 'pronamic_ideal'); |
|
115 | 115 | |
116 | 116 | return; |
117 | 117 | } |
118 | 118 | |
119 | 119 | $client = new Client(); |
120 | 120 | |
121 | - $client->set_access_token( $access_token ); |
|
121 | + $client->set_access_token($access_token); |
|
122 | 122 | |
123 | 123 | // Select merchant profile. |
124 | - printf( '<select name="%s">', esc_attr( $field['meta_key'] ) ); |
|
124 | + printf('<select name="%s">', esc_attr($field['meta_key'])); |
|
125 | 125 | |
126 | 126 | $options = array( |
127 | - __( '— Select Merchant Profile —', 'pronamic_ideal' ), |
|
127 | + __('— Select Merchant Profile —', 'pronamic_ideal'), |
|
128 | 128 | ); |
129 | 129 | |
130 | - $options = array_merge( $options, $client->get_merchant_profiles() ); |
|
130 | + $options = array_merge($options, $client->get_merchant_profiles()); |
|
131 | 131 | |
132 | 132 | $options = array( |
133 | 133 | array( |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | ), |
136 | 136 | ); |
137 | 137 | |
138 | - echo Pay_Util::select_options_grouped( $options, $merchant_profile ); // WPCS: xss ok. |
|
138 | + echo Pay_Util::select_options_grouped($options, $merchant_profile); // WPCS: xss ok. |
|
139 | 139 | |
140 | 140 | echo '</select>'; |
141 | 141 | } |
@@ -15,13 +15,13 @@ |
||
15 | 15 | * @since 1.0.0 |
16 | 16 | */ |
17 | 17 | class ConfigFactory extends GatewayConfigFactory { |
18 | - public function get_config( $post_id ) { |
|
18 | + public function get_config($post_id) { |
|
19 | 19 | $config = new Config(); |
20 | 20 | |
21 | 21 | $config->post_id = $post_id; |
22 | - $config->mode = get_post_meta( $post_id, '_pronamic_gateway_mode', true ); |
|
23 | - $config->access_token = get_post_meta( $post_id, '_pronamic_gateway_nocks_access_token', true ); |
|
24 | - $config->merchant_profile = get_post_meta( $post_id, '_pronamic_gateway_nocks_merchant_profile', true ); |
|
22 | + $config->mode = get_post_meta($post_id, '_pronamic_gateway_mode', true); |
|
23 | + $config->access_token = get_post_meta($post_id, '_pronamic_gateway_nocks_access_token', true); |
|
24 | + $config->merchant_profile = get_post_meta($post_id, '_pronamic_gateway_nocks_merchant_profile', true); |
|
25 | 25 | |
26 | 26 | return $config; |
27 | 27 | } |
@@ -64,8 +64,8 @@ |
||
64 | 64 | * |
65 | 65 | * @return string|null |
66 | 66 | */ |
67 | - public static function transform( $status ) { |
|
68 | - switch ( $status ) { |
|
67 | + public static function transform($status) { |
|
68 | + switch ($status) { |
|
69 | 69 | case self::CANCELLED: |
70 | 70 | return Core_Statuses::CANCELLED; |
71 | 71 |
@@ -60,8 +60,8 @@ |
||
60 | 60 | * |
61 | 61 | * @return string |
62 | 62 | */ |
63 | - public static function transform( $payment_method ) { |
|
64 | - switch ( $payment_method ) { |
|
63 | + public static function transform($payment_method) { |
|
64 | + switch ($payment_method) { |
|
65 | 65 | case PaymentMethods::GULDEN: |
66 | 66 | return self::GULDEN; |
67 | 67 | default: |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @param string $access_token Access token. |
75 | 75 | */ |
76 | - public function set_access_token( $access_token ) { |
|
76 | + public function set_access_token($access_token) { |
|
77 | 77 | $this->access_token = $access_token; |
78 | 78 | } |
79 | 79 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * |
90 | 90 | * @param string $merchant_profile Merchant profile id. |
91 | 91 | */ |
92 | - public function set_merchant_profile( $merchant_profile ) { |
|
92 | + public function set_merchant_profile($merchant_profile) { |
|
93 | 93 | $this->merchant_profile = $merchant_profile; |
94 | 94 | } |
95 | 95 | |
@@ -98,17 +98,17 @@ discard block |
||
98 | 98 | */ |
99 | 99 | public function get_issuers() { |
100 | 100 | return array( |
101 | - 'ABNANL2A' => __( 'ABN Amro', 'pronamic_ideal' ), |
|
102 | - 'RABONL2U' => __( 'Rabobank', 'pronamic_ideal' ), |
|
103 | - 'INGBNL2A' => __( 'ING Bank', 'pronamic_ideal' ), |
|
104 | - 'SNSBNL2A' => __( 'SNS Bank', 'pronamic_ideal' ), |
|
105 | - 'ASNBNL21' => __( 'ASN Bank', 'pronamic_ideal' ), |
|
106 | - 'RBRBNL21' => __( 'RegioBank', 'pronamic_ideal' ), |
|
107 | - 'TRIONL2U' => __( 'Triodos Bank', 'pronamic_ideal' ), |
|
108 | - 'FVLBNL22' => __( 'Van Lanschot', 'pronamic_ideal' ), |
|
109 | - 'KNABNL2H' => __( 'Knab', 'pronamic_ideal' ), |
|
110 | - 'BUNQNL2A' => __( 'Bunq', 'pronamic_ideal' ), |
|
111 | - 'MOYONL21' => __( 'MoneYou', 'pronamic_ideal' ), |
|
101 | + 'ABNANL2A' => __('ABN Amro', 'pronamic_ideal'), |
|
102 | + 'RABONL2U' => __('Rabobank', 'pronamic_ideal'), |
|
103 | + 'INGBNL2A' => __('ING Bank', 'pronamic_ideal'), |
|
104 | + 'SNSBNL2A' => __('SNS Bank', 'pronamic_ideal'), |
|
105 | + 'ASNBNL21' => __('ASN Bank', 'pronamic_ideal'), |
|
106 | + 'RBRBNL21' => __('RegioBank', 'pronamic_ideal'), |
|
107 | + 'TRIONL2U' => __('Triodos Bank', 'pronamic_ideal'), |
|
108 | + 'FVLBNL22' => __('Van Lanschot', 'pronamic_ideal'), |
|
109 | + 'KNABNL2H' => __('Knab', 'pronamic_ideal'), |
|
110 | + 'BUNQNL2A' => __('Bunq', 'pronamic_ideal'), |
|
111 | + 'MOYONL21' => __('MoneYou', 'pronamic_ideal'), |
|
112 | 112 | ); |
113 | 113 | } |
114 | 114 | |
@@ -122,15 +122,15 @@ discard block |
||
122 | 122 | * |
123 | 123 | * @return bool|object |
124 | 124 | */ |
125 | - private function send_request( $end_point, $method = 'GET', array $data = array(), $expected_response_code = 200 ) { |
|
125 | + private function send_request($end_point, $method = 'GET', array $data = array(), $expected_response_code = 200) { |
|
126 | 126 | // Request. |
127 | 127 | $url = self::API_URL . $end_point; |
128 | 128 | |
129 | - if ( is_array( $data ) && ! empty( $data ) ) { |
|
130 | - $data = wp_json_encode( $data ); |
|
129 | + if (is_array($data) && ! empty($data)) { |
|
130 | + $data = wp_json_encode($data); |
|
131 | 131 | } |
132 | 132 | |
133 | - $response = wp_remote_request( $url, array( |
|
133 | + $response = wp_remote_request($url, array( |
|
134 | 134 | 'method' => $method, |
135 | 135 | 'headers' => array( |
136 | 136 | 'Accept' => 'application/json', |
@@ -138,29 +138,29 @@ discard block |
||
138 | 138 | 'Authorization' => 'Bearer ' . $this->get_access_token(), |
139 | 139 | ), |
140 | 140 | 'body' => $data, |
141 | - ) ); |
|
141 | + )); |
|
142 | 142 | |
143 | 143 | // Response code. |
144 | - $response_code = wp_remote_retrieve_response_code( $response ); |
|
144 | + $response_code = wp_remote_retrieve_response_code($response); |
|
145 | 145 | |
146 | - if ( $expected_response_code != $response_code ) { // WPCS: loose comparison ok. |
|
147 | - $this->error = new WP_Error( 'nocks_error', 'Unexpected response code.' ); |
|
146 | + if ($expected_response_code != $response_code) { // WPCS: loose comparison ok. |
|
147 | + $this->error = new WP_Error('nocks_error', 'Unexpected response code.'); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | // Body. |
151 | - $body = wp_remote_retrieve_body( $response ); |
|
151 | + $body = wp_remote_retrieve_body($response); |
|
152 | 152 | |
153 | - $data = json_decode( $body ); |
|
153 | + $data = json_decode($body); |
|
154 | 154 | |
155 | - if ( ! is_object( $data ) ) { |
|
156 | - $this->error = new WP_Error( 'nocks_error', 'Could not parse response.' ); |
|
155 | + if ( ! is_object($data)) { |
|
156 | + $this->error = new WP_Error('nocks_error', 'Could not parse response.'); |
|
157 | 157 | |
158 | 158 | return false; |
159 | 159 | } |
160 | 160 | |
161 | 161 | // Nocks error. |
162 | - if ( isset( $data->error, $data->error->message ) ) { |
|
163 | - $this->error = new WP_Error( 'nocks_error', $data->error->message, $data->error ); |
|
162 | + if (isset($data->error, $data->error->message)) { |
|
163 | + $this->error = new WP_Error('nocks_error', $data->error->message, $data->error); |
|
164 | 164 | |
165 | 165 | return false; |
166 | 166 | } |
@@ -176,12 +176,12 @@ discard block |
||
176 | 176 | public function get_merchant_profiles() { |
177 | 177 | $profiles = array(); |
178 | 178 | |
179 | - $merchants = $this->send_request( 'merchant', 'GET' ); |
|
179 | + $merchants = $this->send_request('merchant', 'GET'); |
|
180 | 180 | |
181 | - if ( $merchants ) { |
|
182 | - foreach ( $merchants->data as $merchant ) { |
|
183 | - foreach ( $merchant->merchant_profiles->data as $profile ) { |
|
184 | - $profiles[ $profile->uuid ] = $merchant->name . ' - ' . $profile->name; |
|
181 | + if ($merchants) { |
|
182 | + foreach ($merchants->data as $merchant) { |
|
183 | + foreach ($merchant->merchant_profiles->data as $profile) { |
|
184 | + $profiles[$profile->uuid] = $merchant->name . ' - ' . $profile->name; |
|
185 | 185 | } |
186 | 186 | } |
187 | 187 | } |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | * |
197 | 197 | * @return array|bool|mixed|object |
198 | 198 | */ |
199 | - public function start_transaction( Transaction $transaction ) { |
|
199 | + public function start_transaction(Transaction $transaction) { |
|
200 | 200 | return $this->send_request( |
201 | 201 | 'transaction', |
202 | 202 | 'POST', |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | * |
213 | 213 | * @return array|bool|mixed|object |
214 | 214 | */ |
215 | - public function get_transaction( $transaction_uuid ) { |
|
215 | + public function get_transaction($transaction_uuid) { |
|
216 | 216 | return $this->send_request( |
217 | 217 | 'transaction/' . $transaction_uuid, |
218 | 218 | 'GET' |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | * |
230 | 230 | * @return array|bool|mixed|object |
231 | 231 | */ |
232 | - public function get_transaction_quote( $source_currency, $target_currency, $amount, $payment_method ) { |
|
232 | + public function get_transaction_quote($source_currency, $target_currency, $amount, $payment_method) { |
|
233 | 233 | $data = array( |
234 | 234 | 'source_currency' => $source_currency, |
235 | 235 | 'target_currency' => $target_currency, |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | 'amount' => (string) $amount, |
239 | 239 | 'currency' => $source_currency, |
240 | 240 | ), |
241 | - 'payment_method' => array( 'method' => $payment_method ), |
|
241 | + 'payment_method' => array('method' => $payment_method), |
|
242 | 242 | ); |
243 | 243 | |
244 | 244 | return $this->send_request( |
@@ -30,16 +30,16 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @param Config $config Config. |
32 | 32 | */ |
33 | - public function __construct( Config $config ) { |
|
34 | - parent::__construct( $config ); |
|
33 | + public function __construct(Config $config) { |
|
34 | + parent::__construct($config); |
|
35 | 35 | |
36 | - $this->set_method( self::METHOD_HTTP_REDIRECT ); |
|
36 | + $this->set_method(self::METHOD_HTTP_REDIRECT); |
|
37 | 37 | |
38 | 38 | // Client. |
39 | 39 | $this->client = new Client(); |
40 | 40 | |
41 | - $this->client->set_access_token( $config->access_token ); |
|
42 | - $this->client->set_merchant_profile( $config->merchant_profile ); |
|
41 | + $this->client->set_access_token($config->access_token); |
|
42 | + $this->client->set_merchant_profile($config->merchant_profile); |
|
43 | 43 | |
44 | 44 | // Feature supports. |
45 | 45 | $this->supports = array( |
@@ -65,22 +65,22 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @param Payment $payment The payment. |
67 | 67 | */ |
68 | - public function start( Payment $payment ) { |
|
68 | + public function start(Payment $payment) { |
|
69 | 69 | $payment_method = $payment->get_method(); |
70 | 70 | $currency = $payment->get_total_amount()->get_currency()->get_alphabetic_code(); |
71 | 71 | $amount = $payment->get_total_amount()->get_value(); |
72 | 72 | |
73 | - if ( empty( $payment_method ) ) { |
|
73 | + if (empty($payment_method)) { |
|
74 | 74 | $payment_method = PaymentMethods::GULDEN; |
75 | 75 | } |
76 | 76 | |
77 | - if ( PaymentMethods::GULDEN === $payment_method ) { |
|
78 | - switch ( $currency ) { |
|
77 | + if (PaymentMethods::GULDEN === $payment_method) { |
|
78 | + switch ($currency) { |
|
79 | 79 | case 'EUR': |
80 | 80 | // Convert to EUR. |
81 | - $quote = $this->client->get_transaction_quote( 'EUR', 'NLG', $amount, Methods::IDEAL ); |
|
81 | + $quote = $this->client->get_transaction_quote('EUR', 'NLG', $amount, Methods::IDEAL); |
|
82 | 82 | |
83 | - if ( $quote ) { |
|
83 | + if ($quote) { |
|
84 | 84 | $amount = $quote->data->target_amount->amount; |
85 | 85 | $currency = 'NLG'; |
86 | 86 | } |
@@ -96,39 +96,39 @@ discard block |
||
96 | 96 | $transaction->description = $payment->get_description(); |
97 | 97 | $transaction->currency = $currency; |
98 | 98 | $transaction->amount = $amount; |
99 | - $transaction->payment_method = Methods::transform( $payment->get_method() ); |
|
99 | + $transaction->payment_method = Methods::transform($payment->get_method()); |
|
100 | 100 | $transaction->redirect_url = $payment->get_return_url(); |
101 | - $transaction->callback_url = add_query_arg( 'nocks_webhook', '', home_url( '/' ) ); |
|
101 | + $transaction->callback_url = add_query_arg('nocks_webhook', '', home_url('/')); |
|
102 | 102 | $transaction->description = $payment->get_description(); |
103 | 103 | |
104 | - if ( null !== $payment->get_customer() ) { |
|
104 | + if (null !== $payment->get_customer()) { |
|
105 | 105 | $transaction->locale = $payment->get_customer()->get_locale(); |
106 | 106 | } |
107 | 107 | |
108 | 108 | // Issuer. |
109 | - if ( Methods::IDEAL === $transaction->payment_method ) { |
|
109 | + if (Methods::IDEAL === $transaction->payment_method) { |
|
110 | 110 | $transaction->issuer = $payment->get_issuer(); |
111 | 111 | } |
112 | 112 | |
113 | 113 | // Start transaction. |
114 | - $result = $this->client->start_transaction( $transaction ); |
|
114 | + $result = $this->client->start_transaction($transaction); |
|
115 | 115 | |
116 | 116 | // Handle errors. |
117 | 117 | $error = $this->client->get_error(); |
118 | 118 | |
119 | - if ( is_wp_error( $error ) ) { |
|
119 | + if (is_wp_error($error)) { |
|
120 | 120 | $this->error = $error; |
121 | 121 | |
122 | 122 | return; |
123 | 123 | } |
124 | 124 | |
125 | 125 | // Update payment. |
126 | - if ( isset( $result->data->payments->data[0]->uuid ) ) { |
|
127 | - $payment->set_transaction_id( $result->data->uuid ); |
|
126 | + if (isset($result->data->payments->data[0]->uuid)) { |
|
127 | + $payment->set_transaction_id($result->data->uuid); |
|
128 | 128 | } |
129 | 129 | |
130 | - if ( isset( $result->data->payments->data[0]->metadata->url ) ) { |
|
131 | - $payment->set_action_url( $result->data->payments->data[0]->metadata->url ); |
|
130 | + if (isset($result->data->payments->data[0]->metadata->url)) { |
|
131 | + $payment->set_action_url($result->data->payments->data[0]->metadata->url); |
|
132 | 132 | } |
133 | 133 | } |
134 | 134 | |
@@ -137,23 +137,23 @@ discard block |
||
137 | 137 | * |
138 | 138 | * @param Payment $payment The payment. |
139 | 139 | */ |
140 | - public function update_status( Payment $payment ) { |
|
140 | + public function update_status(Payment $payment) { |
|
141 | 141 | $transaction_id = $payment->get_transaction_id(); |
142 | 142 | |
143 | - $nocks_payment = $this->client->get_transaction( $transaction_id ); |
|
143 | + $nocks_payment = $this->client->get_transaction($transaction_id); |
|
144 | 144 | |
145 | - if ( ! $nocks_payment ) { |
|
146 | - $payment->set_status( Core_Statuses::FAILURE ); |
|
145 | + if ( ! $nocks_payment) { |
|
146 | + $payment->set_status(Core_Statuses::FAILURE); |
|
147 | 147 | |
148 | 148 | $this->error = $this->client->get_error(); |
149 | 149 | |
150 | 150 | return; |
151 | 151 | } |
152 | 152 | |
153 | - if ( is_object( $nocks_payment ) && isset( $nocks_payment->data->status ) ) { |
|
154 | - $status = Statuses::transform( $nocks_payment->data->status ); |
|
153 | + if (is_object($nocks_payment) && isset($nocks_payment->data->status)) { |
|
154 | + $status = Statuses::transform($nocks_payment->data->status); |
|
155 | 155 | |
156 | - $payment->set_status( $status ); |
|
156 | + $payment->set_status($status); |
|
157 | 157 | } |
158 | 158 | } |
159 | 159 | } |