@@ -87,8 +87,8 @@ |
||
| 87 | 87 | * |
| 88 | 88 | * @return string |
| 89 | 89 | */ |
| 90 | - public static function transform( $payment_method ) { |
|
| 91 | - switch ( $payment_method ) { |
|
| 90 | + public static function transform($payment_method) { |
|
| 91 | + switch ($payment_method) { |
|
| 92 | 92 | case Core_PaymentMethods::BANCONTACT: |
| 93 | 93 | return self::BANCONTACT; |
| 94 | 94 | |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | public function get_array() { |
| 45 | 45 | $array = array( |
| 46 | - 'amount' => Core_Util::amount_to_cents( $this->amount ), |
|
| 46 | + 'amount' => Core_Util::amount_to_cents($this->amount), |
|
| 47 | 47 | 'currency' => $this->currency, |
| 48 | 48 | 'description' => $this->description, |
| 49 | 49 | 'return_url' => $this->return_url, |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | ); |
| 52 | 52 | |
| 53 | 53 | // Array filter will remove values NULL, FALSE and empty strings ('') |
| 54 | - $array = array_filter( $array ); |
|
| 54 | + $array = array_filter($array); |
|
| 55 | 55 | |
| 56 | 56 | // Add payment method |
| 57 | 57 | $payment_method = array( |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | ); |
| 60 | 60 | |
| 61 | 61 | // Add payment method details |
| 62 | - switch ( $this->method ) { |
|
| 62 | + switch ($this->method) { |
|
| 63 | 63 | case PaymentMethods::IDEAL: |
| 64 | 64 | $payment_method['payment_method_details'] = array( |
| 65 | 65 | 'issuer_id' => $this->issuer, |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | break; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - $array['transactions'] = array( $payment_method ); |
|
| 71 | + $array['transactions'] = array($payment_method); |
|
| 72 | 72 | |
| 73 | 73 | return $array; |
| 74 | 74 | } |
@@ -24,19 +24,19 @@ discard block |
||
| 24 | 24 | * |
| 25 | 25 | * @param Config $config |
| 26 | 26 | */ |
| 27 | - public function __construct( Config $config ) { |
|
| 28 | - parent::__construct( $config ); |
|
| 27 | + public function __construct(Config $config) { |
|
| 28 | + parent::__construct($config); |
|
| 29 | 29 | |
| 30 | 30 | $this->supports = array( |
| 31 | 31 | 'payment_status_request', |
| 32 | 32 | ); |
| 33 | 33 | |
| 34 | - $this->set_method( Gateway::METHOD_HTTP_REDIRECT ); |
|
| 35 | - $this->set_has_feedback( true ); |
|
| 36 | - $this->set_amount_minimum( 0.01 ); |
|
| 34 | + $this->set_method(Gateway::METHOD_HTTP_REDIRECT); |
|
| 35 | + $this->set_has_feedback(true); |
|
| 36 | + $this->set_amount_minimum(0.01); |
|
| 37 | 37 | |
| 38 | 38 | // Client |
| 39 | - $this->client = new Client( $config->api_key ); |
|
| 39 | + $this->client = new Client($config->api_key); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | $result = $this->client->get_issuers(); |
| 51 | 51 | |
| 52 | - if ( $result ) { |
|
| 52 | + if ($result) { |
|
| 53 | 53 | $groups[] = array( |
| 54 | 54 | 'options' => $result, |
| 55 | 55 | ); |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | $error = $this->client->get_error(); |
| 59 | 59 | |
| 60 | - if ( is_wp_error( $error ) ) { |
|
| 60 | + if (is_wp_error($error)) { |
|
| 61 | 61 | $this->error = $error; |
| 62 | 62 | } |
| 63 | 63 | |
@@ -67,11 +67,11 @@ discard block |
||
| 67 | 67 | public function get_issuer_field() { |
| 68 | 68 | $payment_method = $this->get_payment_method(); |
| 69 | 69 | |
| 70 | - if ( null === $payment_method || PaymentMethods::IDEAL === $payment_method ) { |
|
| 70 | + if (null === $payment_method || PaymentMethods::IDEAL === $payment_method) { |
|
| 71 | 71 | return array( |
| 72 | 72 | 'id' => 'pronamic_ideal_issuer_id', |
| 73 | 73 | 'name' => 'pronamic_ideal_issuer_id', |
| 74 | - 'label' => __( 'Choose your bank', 'pronamic_ideal' ), |
|
| 74 | + 'label' => __('Choose your bank', 'pronamic_ideal'), |
|
| 75 | 75 | 'required' => true, |
| 76 | 76 | 'type' => 'select', |
| 77 | 77 | 'choices' => $this->get_transient_issuers(), |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | * |
| 111 | 111 | * @see Pronamic_WP_Pay_Gateway::start() |
| 112 | 112 | */ |
| 113 | - public function start( Payment $payment ) { |
|
| 113 | + public function start(Payment $payment) { |
|
| 114 | 114 | $request = new OrderRequest(); |
| 115 | 115 | |
| 116 | 116 | $request->currency = $payment->get_currency(); |
@@ -124,32 +124,32 @@ discard block |
||
| 124 | 124 | |
| 125 | 125 | $payment_method = $payment->get_method(); |
| 126 | 126 | |
| 127 | - if ( empty( $payment_method ) && ! empty( $issuer ) ) { |
|
| 127 | + if (empty($payment_method) && ! empty($issuer)) { |
|
| 128 | 128 | $payment_method = PaymentMethods::IDEAL; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - if ( PaymentMethods::IDEAL === $payment_method ) { |
|
| 131 | + if (PaymentMethods::IDEAL === $payment_method) { |
|
| 132 | 132 | $request->issuer = $issuer; |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - $request->method = Methods::transform( $payment_method ); |
|
| 135 | + $request->method = Methods::transform($payment_method); |
|
| 136 | 136 | |
| 137 | - $order = $this->client->create_order( $request ); |
|
| 137 | + $order = $this->client->create_order($request); |
|
| 138 | 138 | |
| 139 | - if ( $order ) { |
|
| 140 | - $payment->set_transaction_id( $order->id ); |
|
| 139 | + if ($order) { |
|
| 140 | + $payment->set_transaction_id($order->id); |
|
| 141 | 141 | |
| 142 | - $action_url = add_query_arg( array( |
|
| 142 | + $action_url = add_query_arg(array( |
|
| 143 | 143 | 'payment_redirect' => $payment->get_id(), |
| 144 | 144 | 'key' => $payment->key, |
| 145 | - ), home_url( '/' ) ); |
|
| 145 | + ), home_url('/')); |
|
| 146 | 146 | |
| 147 | - if ( PaymentMethods::BANK_TRANSFER === $payment_method ) { |
|
| 147 | + if (PaymentMethods::BANK_TRANSFER === $payment_method) { |
|
| 148 | 148 | // Set payment redirect message with received transaction reference. |
| 149 | 149 | // @see https://s3-eu-west-1.amazonaws.com/wl1-apidocs/api.kassacompleet.nl/index.html#payment-methods-without-the-redirect-flow-performing_redirect-requirement |
| 150 | 150 | $message = sprintf( |
| 151 | 151 | /* translators: 1: payment provider name, 2: PSP account name, 3: PSP account number, 4: PSP account BIC, 5: formatted amount, 6: transaction reference */ |
| 152 | - __( 'You have chosen the payment method "Bank transfer". To complete your payment, please transfer the amount to the payment service provider (%1$s). |
|
| 152 | + __('You have chosen the payment method "Bank transfer". To complete your payment, please transfer the amount to the payment service provider (%1$s). |
|
| 153 | 153 | |
| 154 | 154 | <strong>Account holder:</strong> %2$s |
| 155 | 155 | <strong>Account IBAN:</strong> %3$s |
@@ -157,8 +157,8 @@ discard block |
||
| 157 | 157 | <strong>Amount:</strong> %5$s |
| 158 | 158 | <strong>Transaction reference:</strong> %6$s |
| 159 | 159 | |
| 160 | -<em>Please note: only payments with the mentioned transaction reference can be processed.</em>', 'pronamic_ideal' ), |
|
| 161 | - __( 'ING', 'pronamic_ideal' ), |
|
| 160 | +<em>Please note: only payments with the mentioned transaction reference can be processed.</em>', 'pronamic_ideal'), |
|
| 161 | + __('ING', 'pronamic_ideal'), |
|
| 162 | 162 | 'ING PSP', |
| 163 | 163 | 'NL13INGB0005300060', |
| 164 | 164 | 'INGBNL2A', |
@@ -166,19 +166,19 @@ discard block |
||
| 166 | 166 | $order->transactions[0]->payment_method_details->reference |
| 167 | 167 | ); |
| 168 | 168 | |
| 169 | - $payment->set_meta( 'payment_redirect_message', $message ); |
|
| 169 | + $payment->set_meta('payment_redirect_message', $message); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | - if ( isset( $order->transactions[0]->payment_url ) ) { |
|
| 172 | + if (isset($order->transactions[0]->payment_url)) { |
|
| 173 | 173 | $action_url = $order->transactions[0]->payment_url; |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - $payment->set_action_url( $action_url ); |
|
| 176 | + $payment->set_action_url($action_url); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | $error = $this->client->get_error(); |
| 180 | 180 | |
| 181 | - if ( is_wp_error( $error ) ) { |
|
| 181 | + if (is_wp_error($error)) { |
|
| 182 | 182 | $this->error = $error; |
| 183 | 183 | } |
| 184 | 184 | } |
@@ -188,36 +188,36 @@ discard block |
||
| 188 | 188 | * |
| 189 | 189 | * @param Payment $payment |
| 190 | 190 | */ |
| 191 | - public function update_status( Payment $payment ) { |
|
| 191 | + public function update_status(Payment $payment) { |
|
| 192 | 192 | $transaction_id = $payment->get_transaction_id(); |
| 193 | 193 | |
| 194 | - if ( empty( $transaction_id ) ) { |
|
| 194 | + if (empty($transaction_id)) { |
|
| 195 | 195 | return; |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | - $order = $this->client->get_order( $transaction_id ); |
|
| 198 | + $order = $this->client->get_order($transaction_id); |
|
| 199 | 199 | |
| 200 | - if ( ! is_object( $order ) ) { |
|
| 200 | + if ( ! is_object($order)) { |
|
| 201 | 201 | return; |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | - $payment->set_status( Statuses::transform( $order->status ) ); |
|
| 204 | + $payment->set_status(Statuses::transform($order->status)); |
|
| 205 | 205 | |
| 206 | - if ( isset( $order->transactions[0]->payment_method_details ) ) { |
|
| 206 | + if (isset($order->transactions[0]->payment_method_details)) { |
|
| 207 | 207 | $details = $order->transactions[0]->payment_method_details; |
| 208 | 208 | |
| 209 | - if ( isset( $details->consumer_name ) ) { |
|
| 210 | - $payment->set_consumer_name( $details->consumer_name ); |
|
| 209 | + if (isset($details->consumer_name)) { |
|
| 210 | + $payment->set_consumer_name($details->consumer_name); |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | - if ( isset( $details->consumer_iban ) ) { |
|
| 214 | - $payment->set_consumer_iban( $details->consumer_iban ); |
|
| 213 | + if (isset($details->consumer_iban)) { |
|
| 214 | + $payment->set_consumer_iban($details->consumer_iban); |
|
| 215 | 215 | } |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | $error = $this->client->get_error(); |
| 219 | 219 | |
| 220 | - if ( is_wp_error( $error ) ) { |
|
| 220 | + if (is_wp_error($error)) { |
|
| 221 | 221 | $this->error = $error; |
| 222 | 222 | } |
| 223 | 223 | } |
@@ -16,30 +16,30 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | class Settings extends GatewaySettings { |
| 18 | 18 | public function __construct() { |
| 19 | - add_filter( 'pronamic_pay_gateway_sections', array( $this, 'sections' ) ); |
|
| 20 | - add_filter( 'pronamic_pay_gateway_fields', array( $this, 'fields' ) ); |
|
| 19 | + add_filter('pronamic_pay_gateway_sections', array($this, 'sections')); |
|
| 20 | + add_filter('pronamic_pay_gateway_fields', array($this, 'fields')); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - public function sections( array $sections ) { |
|
| 23 | + public function sections(array $sections) { |
|
| 24 | 24 | // iDEAL |
| 25 | 25 | $sections['ing_kassa_compleet'] = array( |
| 26 | - 'title' => __( 'ING Kassa Compleet', 'pronamic_ideal' ), |
|
| 27 | - 'methods' => array( 'ing_kassa_compleet' ), |
|
| 26 | + 'title' => __('ING Kassa Compleet', 'pronamic_ideal'), |
|
| 27 | + 'methods' => array('ing_kassa_compleet'), |
|
| 28 | 28 | 'description' => sprintf( |
| 29 | 29 | /* translators: 1: ING */ |
| 30 | - __( 'Account details are provided by %1$s after registration. These settings need to match with the %1$s dashboard.', 'pronamic_ideal' ), |
|
| 31 | - __( 'ING', 'pronamic_ideal' ) |
|
| 30 | + __('Account details are provided by %1$s after registration. These settings need to match with the %1$s dashboard.', 'pronamic_ideal'), |
|
| 31 | + __('ING', 'pronamic_ideal') |
|
| 32 | 32 | ), |
| 33 | 33 | ); |
| 34 | 34 | |
| 35 | 35 | // Transaction feedback |
| 36 | 36 | $sections['ing_kassa_compleet_feedback'] = array( |
| 37 | - 'title' => __( 'Transaction feedback', 'pronamic_ideal' ), |
|
| 38 | - 'methods' => array( 'ing_kassa_compleet' ), |
|
| 37 | + 'title' => __('Transaction feedback', 'pronamic_ideal'), |
|
| 38 | + 'methods' => array('ing_kassa_compleet'), |
|
| 39 | 39 | 'description' => sprintf( |
| 40 | 40 | /* translators: %s: ING Kassa Compleet */ |
| 41 | - __( 'Set the Webhook URL in the %s dashboard to receive automatic transaction status updates.', 'pronamic_ideal' ), |
|
| 42 | - __( 'ING Kassa Compleet', 'pronamic_ideal' ) |
|
| 41 | + __('Set the Webhook URL in the %s dashboard to receive automatic transaction status updates.', 'pronamic_ideal'), |
|
| 42 | + __('ING Kassa Compleet', 'pronamic_ideal') |
|
| 43 | 43 | ), |
| 44 | 44 | ); |
| 45 | 45 | |
@@ -47,23 +47,23 @@ discard block |
||
| 47 | 47 | return $sections; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - public function fields( array $fields ) { |
|
| 50 | + public function fields(array $fields) { |
|
| 51 | 51 | // API Key |
| 52 | 52 | $fields[] = array( |
| 53 | 53 | 'filter' => FILTER_SANITIZE_STRING, |
| 54 | 54 | 'section' => 'ing_kassa_compleet', |
| 55 | 55 | 'meta_key' => '_pronamic_gateway_ing_kassa_compleet_api_key', |
| 56 | - 'title' => _x( 'API Key', 'ing_kassa_compleet', 'pronamic_ideal' ), |
|
| 56 | + 'title' => _x('API Key', 'ing_kassa_compleet', 'pronamic_ideal'), |
|
| 57 | 57 | 'type' => 'text', |
| 58 | - 'classes' => array( 'regular-text', 'code' ), |
|
| 59 | - 'methods' => array( 'ing_kassa_compleet' ), |
|
| 58 | + 'classes' => array('regular-text', 'code'), |
|
| 59 | + 'methods' => array('ing_kassa_compleet'), |
|
| 60 | 60 | 'tooltip' => sprintf( |
| 61 | 61 | '%s %s.', |
| 62 | - __( 'API key', 'pronamic_ideal' ), |
|
| 62 | + __('API key', 'pronamic_ideal'), |
|
| 63 | 63 | sprintf( |
| 64 | 64 | /* translators: %s: ING Kassa Compleet */ |
| 65 | - __( 'as mentioned in the %s dashboard', 'pronamic_ideal' ), |
|
| 66 | - __( 'ING Kassa Compleet', 'pronamic_ideal' ) |
|
| 65 | + __('as mentioned in the %s dashboard', 'pronamic_ideal'), |
|
| 66 | + __('ING Kassa Compleet', 'pronamic_ideal') |
|
| 67 | 67 | ) |
| 68 | 68 | ), |
| 69 | 69 | ); |
@@ -71,27 +71,27 @@ discard block |
||
| 71 | 71 | // Transaction feedback |
| 72 | 72 | $fields[] = array( |
| 73 | 73 | 'section' => 'ing_kassa_compleet', |
| 74 | - 'methods' => array( 'ing_kassa_compleet' ), |
|
| 75 | - 'title' => __( 'Transaction feedback', 'pronamic_ideal' ), |
|
| 74 | + 'methods' => array('ing_kassa_compleet'), |
|
| 75 | + 'title' => __('Transaction feedback', 'pronamic_ideal'), |
|
| 76 | 76 | 'type' => 'description', |
| 77 | 77 | 'html' => sprintf( |
| 78 | 78 | '<span class="dashicons dashicons-warning"></span> %s', |
| 79 | - __( 'Receiving payment status updates needs additional configuration, if not yet completed.', 'pronamic_ideal' ) |
|
| 79 | + __('Receiving payment status updates needs additional configuration, if not yet completed.', 'pronamic_ideal') |
|
| 80 | 80 | ), |
| 81 | 81 | ); |
| 82 | 82 | |
| 83 | 83 | // Webhook URL |
| 84 | 84 | $fields[] = array( |
| 85 | 85 | 'section' => 'ing_kassa_compleet_feedback', |
| 86 | - 'title' => __( 'Webhook URL', 'pronamic_ideal' ), |
|
| 86 | + 'title' => __('Webhook URL', 'pronamic_ideal'), |
|
| 87 | 87 | 'type' => 'text', |
| 88 | - 'classes' => array( 'large-text', 'code' ), |
|
| 89 | - 'value' => add_query_arg( 'ing_kassa_compleet_webhook', '', home_url( '/' ) ), |
|
| 88 | + 'classes' => array('large-text', 'code'), |
|
| 89 | + 'value' => add_query_arg('ing_kassa_compleet_webhook', '', home_url('/')), |
|
| 90 | 90 | 'readonly' => true, |
| 91 | 91 | 'tooltip' => sprintf( |
| 92 | 92 | /* translators: %s: ING Kassa Compleet */ |
| 93 | - __( 'Copy the Webhook URL to the %s dashboard to receive automatic transaction status updates.', 'pronamic_ideal' ), |
|
| 94 | - __( 'ING Kassa Compleet', 'pronamic_ideal' ) |
|
| 93 | + __('Copy the Webhook URL to the %s dashboard to receive automatic transaction status updates.', 'pronamic_ideal'), |
|
| 94 | + __('ING Kassa Compleet', 'pronamic_ideal') |
|
| 95 | 95 | ), |
| 96 | 96 | ); |
| 97 | 97 | |
@@ -66,8 +66,8 @@ |
||
| 66 | 66 | * |
| 67 | 67 | * @return string|null |
| 68 | 68 | */ |
| 69 | - public static function transform( $status ) { |
|
| 70 | - switch ( $status ) { |
|
| 69 | + public static function transform($status) { |
|
| 70 | + switch ($status) { |
|
| 71 | 71 | case self::ERROR: |
| 72 | 72 | return Core_Statuses::FAILURE; |
| 73 | 73 | |
@@ -23,10 +23,10 @@ |
||
| 23 | 23 | $this->dashboard_url = 'https://portal.kassacompleet.nl/'; |
| 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 | |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | /** |
| 41 | 41 | * Constructs and initalize an ING Kassa Compleet client object |
| 42 | 42 | */ |
| 43 | - public function __construct( $api_key ) { |
|
| 43 | + public function __construct($api_key) { |
|
| 44 | 44 | $this->api_key = $api_key; |
| 45 | 45 | } |
| 46 | 46 | |
@@ -60,44 +60,44 @@ discard block |
||
| 60 | 60 | * @param string $method |
| 61 | 61 | * @param array $data |
| 62 | 62 | */ |
| 63 | - private function send_request( $endpoint, $method = 'POST', array $data = array() ) { |
|
| 63 | + private function send_request($endpoint, $method = 'POST', array $data = array()) { |
|
| 64 | 64 | $url = self::API_URL . $endpoint; |
| 65 | 65 | |
| 66 | 66 | $headers = array( |
| 67 | - 'Authorization' => 'Basic ' . base64_encode( $this->api_key . ':' ), |
|
| 67 | + 'Authorization' => 'Basic ' . base64_encode($this->api_key . ':'), |
|
| 68 | 68 | ); |
| 69 | 69 | |
| 70 | - if ( is_array( $data ) && ! empty( $data ) ) { |
|
| 71 | - $data = wp_json_encode( $data ); |
|
| 70 | + if (is_array($data) && ! empty($data)) { |
|
| 71 | + $data = wp_json_encode($data); |
|
| 72 | 72 | |
| 73 | 73 | $headers['Content-Type'] = 'application/json'; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - $return = wp_remote_request( $url, array( |
|
| 76 | + $return = wp_remote_request($url, array( |
|
| 77 | 77 | 'method' => $method, |
| 78 | 78 | 'headers' => $headers, |
| 79 | 79 | 'body' => $data, |
| 80 | - ) ); |
|
| 80 | + )); |
|
| 81 | 81 | |
| 82 | 82 | return $return; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - public function create_order( OrderRequest $request ) { |
|
| 85 | + public function create_order(OrderRequest $request) { |
|
| 86 | 86 | $result = null; |
| 87 | 87 | |
| 88 | 88 | $data = $request->get_array(); |
| 89 | 89 | |
| 90 | - $response = $this->send_request( 'orders/', 'POST', $data ); |
|
| 90 | + $response = $this->send_request('orders/', 'POST', $data); |
|
| 91 | 91 | |
| 92 | - $response_code = wp_remote_retrieve_response_code( $response ); |
|
| 92 | + $response_code = wp_remote_retrieve_response_code($response); |
|
| 93 | 93 | |
| 94 | - $body = wp_remote_retrieve_body( $response ); |
|
| 94 | + $body = wp_remote_retrieve_body($response); |
|
| 95 | 95 | |
| 96 | 96 | // NULL is returned if the json cannot be decoded or if the encoded data is deeper than the recursion limit. |
| 97 | - $ing_result = json_decode( $body ); |
|
| 97 | + $ing_result = json_decode($body); |
|
| 98 | 98 | |
| 99 | - if ( 201 === $response_code ) { |
|
| 100 | - if ( $ing_result && 'error' === $ing_result->status ) { |
|
| 99 | + if (201 === $response_code) { |
|
| 100 | + if ($ing_result && 'error' === $ing_result->status) { |
|
| 101 | 101 | $error_msg = $ing_result->transactions[0]->reason; |
| 102 | 102 | $error = $ing_result->transactions[0]; |
| 103 | 103 | } else { |
@@ -107,36 +107,36 @@ discard block |
||
| 107 | 107 | $error_msg = ''; |
| 108 | 108 | $error = ''; |
| 109 | 109 | |
| 110 | - if ( $ing_result ) { |
|
| 110 | + if ($ing_result) { |
|
| 111 | 111 | $error_msg = $ing_result->error->value; |
| 112 | 112 | $error = $ing_result->error; |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - if ( 401 === $response_code ) { |
|
| 115 | + if (401 === $response_code) { |
|
| 116 | 116 | // The default error message for an unauthorized API call does not mention the API key in any way. |
| 117 | 117 | $error_msg .= ' Please check the API key.'; |
| 118 | 118 | } |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - if ( isset( $error_msg, $error ) ) { |
|
| 122 | - $this->error = new WP_Error( 'ing_kassa_compleet_error', $error_msg, $error ); |
|
| 121 | + if (isset($error_msg, $error)) { |
|
| 122 | + $this->error = new WP_Error('ing_kassa_compleet_error', $error_msg, $error); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | return $result; |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - public function get_order( $order_id ) { |
|
| 128 | + public function get_order($order_id) { |
|
| 129 | 129 | $result = null; |
| 130 | 130 | |
| 131 | - $response = $this->send_request( 'orders/' . $order_id . '/', 'GET' ); |
|
| 131 | + $response = $this->send_request('orders/' . $order_id . '/', 'GET'); |
|
| 132 | 132 | |
| 133 | - $response_code = wp_remote_retrieve_response_code( $response ); |
|
| 133 | + $response_code = wp_remote_retrieve_response_code($response); |
|
| 134 | 134 | |
| 135 | - if ( 200 === $response_code ) { |
|
| 136 | - $body = wp_remote_retrieve_body( $response ); |
|
| 135 | + if (200 === $response_code) { |
|
| 136 | + $body = wp_remote_retrieve_body($response); |
|
| 137 | 137 | |
| 138 | 138 | // NULL is returned if the json cannot be decoded or if the encoded data is deeper than the recursion limit. |
| 139 | - $result = json_decode( $body ); |
|
| 139 | + $result = json_decode($body); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | return $result; |
@@ -150,42 +150,42 @@ discard block |
||
| 150 | 150 | public function get_issuers() { |
| 151 | 151 | $issuers = false; |
| 152 | 152 | |
| 153 | - $response = $this->send_request( 'ideal/issuers/', 'GET' ); |
|
| 153 | + $response = $this->send_request('ideal/issuers/', 'GET'); |
|
| 154 | 154 | |
| 155 | - $response_code = wp_remote_retrieve_response_code( $response ); |
|
| 155 | + $response_code = wp_remote_retrieve_response_code($response); |
|
| 156 | 156 | |
| 157 | - if ( 200 === $response_code ) { |
|
| 158 | - $body = wp_remote_retrieve_body( $response ); |
|
| 157 | + if (200 === $response_code) { |
|
| 158 | + $body = wp_remote_retrieve_body($response); |
|
| 159 | 159 | |
| 160 | 160 | // NULL is returned if the json cannot be decoded or if the encoded data is deeper than the recursion limit. |
| 161 | - $result = json_decode( $body ); |
|
| 161 | + $result = json_decode($body); |
|
| 162 | 162 | |
| 163 | - if ( null !== $result ) { |
|
| 163 | + if (null !== $result) { |
|
| 164 | 164 | $issuers = array(); |
| 165 | 165 | |
| 166 | - foreach ( $result as $issuer ) { |
|
| 167 | - $id = Security::filter( $issuer->id ); |
|
| 168 | - $name = Security::filter( $issuer->name ); |
|
| 166 | + foreach ($result as $issuer) { |
|
| 167 | + $id = Security::filter($issuer->id); |
|
| 168 | + $name = Security::filter($issuer->name); |
|
| 169 | 169 | |
| 170 | - $issuers[ $id ] = $name; |
|
| 170 | + $issuers[$id] = $name; |
|
| 171 | 171 | } |
| 172 | 172 | } |
| 173 | 173 | } else { |
| 174 | - $body = wp_remote_retrieve_body( $response ); |
|
| 174 | + $body = wp_remote_retrieve_body($response); |
|
| 175 | 175 | |
| 176 | - $ing_result = json_decode( $body ); |
|
| 176 | + $ing_result = json_decode($body); |
|
| 177 | 177 | |
| 178 | 178 | $error_msg = $ing_result->error->value; |
| 179 | 179 | |
| 180 | - if ( 401 === $response_code ) { |
|
| 180 | + if (401 === $response_code) { |
|
| 181 | 181 | // An unauthorized API call has nothing to do with the browser of the user in our case, remove to prevent confusion. |
| 182 | - $error_msg = str_replace( "You either supplied the wrong credentials (e.g. a bad password), or your browser doesn't understand how to supply the credentials required.", '', $error_msg ); |
|
| 182 | + $error_msg = str_replace("You either supplied the wrong credentials (e.g. a bad password), or your browser doesn't understand how to supply the credentials required.", '', $error_msg); |
|
| 183 | 183 | |
| 184 | 184 | // The default error message for an unauthorized API call does not mention the API key in any way. |
| 185 | 185 | $error_msg .= ' Please check the API key.'; |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | - $this->error = new WP_Error( 'ing_kassa_compleet_error', $error_msg, $ing_result->error ); |
|
| 188 | + $this->error = new WP_Error('ing_kassa_compleet_error', $error_msg, $ing_result->error); |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | return $issuers; |
@@ -15,11 +15,11 @@ |
||
| 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 | - $config->api_key = get_post_meta( $post_id, '_pronamic_gateway_ing_kassa_compleet_api_key', true ); |
|
| 22 | - $config->mode = get_post_meta( $post_id, '_pronamic_gateway_mode', true ); |
|
| 21 | + $config->api_key = get_post_meta($post_id, '_pronamic_gateway_ing_kassa_compleet_api_key', true); |
|
| 22 | + $config->mode = get_post_meta($post_id, '_pronamic_gateway_mode', true); |
|
| 23 | 23 | |
| 24 | 24 | return $config; |
| 25 | 25 | } |
@@ -19,30 +19,30 @@ |
||
| 19 | 19 | * Listen to ING Kassa Compleet webhook requests. |
| 20 | 20 | */ |
| 21 | 21 | public static function listen() { |
| 22 | - if ( ! filter_has_var( INPUT_GET, 'ing_kassa_compleet_webhook' ) ) { |
|
| 22 | + if ( ! filter_has_var(INPUT_GET, 'ing_kassa_compleet_webhook')) { |
|
| 23 | 23 | return; |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - $data = json_decode( file_get_contents( 'php://input' ) ); |
|
| 26 | + $data = json_decode(file_get_contents('php://input')); |
|
| 27 | 27 | |
| 28 | - if ( is_object( $data ) && isset( $data->order_id ) ) { |
|
| 29 | - $payment = get_pronamic_payment_by_transaction_id( $data->order_id ); |
|
| 28 | + if (is_object($data) && isset($data->order_id)) { |
|
| 29 | + $payment = get_pronamic_payment_by_transaction_id($data->order_id); |
|
| 30 | 30 | |
| 31 | - if ( null === $payment ) { |
|
| 31 | + if (null === $payment) { |
|
| 32 | 32 | return; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | // Add note. |
| 36 | 36 | $note = sprintf( |
| 37 | 37 | /* translators: %s: ING */ |
| 38 | - __( 'Webhook requested by %s.', 'pronamic_ideal' ), |
|
| 39 | - __( 'ING', 'pronamic_ideal' ) |
|
| 38 | + __('Webhook requested by %s.', 'pronamic_ideal'), |
|
| 39 | + __('ING', 'pronamic_ideal') |
|
| 40 | 40 | ); |
| 41 | 41 | |
| 42 | - $payment->add_note( $note ); |
|
| 42 | + $payment->add_note($note); |
|
| 43 | 43 | |
| 44 | 44 | // Update payment. |
| 45 | - Plugin::update_payment( $payment, false ); |
|
| 45 | + Plugin::update_payment($payment, false); |
|
| 46 | 46 | } |
| 47 | 47 | } |
| 48 | 48 | } |