@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | */ |
| 118 | 118 | public function get_array() { |
| 119 | 119 | $array = array( |
| 120 | - 'amount' => number_format( $this->amount, 2, '.', '' ), |
|
| 120 | + 'amount' => number_format($this->amount, 2, '.', ''), |
|
| 121 | 121 | 'description' => $this->description, |
| 122 | 122 | 'method' => $this->method, |
| 123 | 123 | 'redirectUrl' => $this->redirect_url, |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | /* |
| 133 | 133 | * Array filter will remove values NULL, FALSE and empty strings ('') |
| 134 | 134 | */ |
| 135 | - $array = array_filter( $array ); |
|
| 135 | + $array = array_filter($array); |
|
| 136 | 136 | |
| 137 | 137 | return $array; |
| 138 | 138 | } |
@@ -7,31 +7,31 @@ |
||
| 7 | 7 | * @see https://github.com/WordPress/WordPress/blob/4.5.2/wp-admin/user-edit.php#L578-L600 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -$customer_id_live = get_user_meta( $user->ID, '_pronamic_pay_mollie_customer_id', true ); |
|
| 11 | -$customer_id_test = get_user_meta( $user->ID, '_pronamic_pay_mollie_customer_id_test', true ); |
|
| 10 | +$customer_id_live = get_user_meta($user->ID, '_pronamic_pay_mollie_customer_id', true); |
|
| 11 | +$customer_id_test = get_user_meta($user->ID, '_pronamic_pay_mollie_customer_id_test', true); |
|
| 12 | 12 | |
| 13 | 13 | ?> |
| 14 | -<h2><?php esc_html_e( 'Mollie', 'pronamic_ideal' ); ?></h2> |
|
| 14 | +<h2><?php esc_html_e('Mollie', 'pronamic_ideal'); ?></h2> |
|
| 15 | 15 | |
| 16 | 16 | <table class="form-table"> |
| 17 | 17 | <tr> |
| 18 | 18 | <th> |
| 19 | 19 | <label for="pronamic_pay_mollie_customer_id_live"> |
| 20 | - <?php esc_html_e( 'Customer live ID', 'pronamic_ideal' ); ?> |
|
| 20 | + <?php esc_html_e('Customer live ID', 'pronamic_ideal'); ?> |
|
| 21 | 21 | </label> |
| 22 | 22 | </th> |
| 23 | 23 | <td> |
| 24 | - <input id="pronamic_pay_mollie_customer_id_live" name="pronamic_pay_mollie_customer_id_live" type="text" value="<?php echo esc_attr( $customer_id_live ); ?>" class="regular-text" readonly="readonly" /> |
|
| 24 | + <input id="pronamic_pay_mollie_customer_id_live" name="pronamic_pay_mollie_customer_id_live" type="text" value="<?php echo esc_attr($customer_id_live); ?>" class="regular-text" readonly="readonly" /> |
|
| 25 | 25 | </td> |
| 26 | 26 | </tr> |
| 27 | 27 | <tr> |
| 28 | 28 | <th> |
| 29 | 29 | <label for="pronamic_pay_mollie_customer_id_test"> |
| 30 | - <?php esc_html_e( 'Customer test ID', 'pronamic_ideal' ); ?> |
|
| 30 | + <?php esc_html_e('Customer test ID', 'pronamic_ideal'); ?> |
|
| 31 | 31 | </label> |
| 32 | 32 | </th> |
| 33 | 33 | <td> |
| 34 | - <input id="pronamic_pay_mollie_customer_id_test" name="pronamic_pay_mollie_customer_id_test" type="text" value="<?php echo esc_attr( $customer_id_test ); ?>" class="regular-text" readonly="readonly" /> |
|
| 34 | + <input id="pronamic_pay_mollie_customer_id_test" name="pronamic_pay_mollie_customer_id_test" type="text" value="<?php echo esc_attr($customer_id_test); ?>" class="regular-text" readonly="readonly" /> |
|
| 35 | 35 | </td> |
| 36 | 36 | </tr> |
| 37 | 37 | </table> |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | * |
| 18 | 18 | * @return string|null |
| 19 | 19 | */ |
| 20 | - public static function transform( $locale ) { |
|
| 20 | + public static function transform($locale) { |
|
| 21 | 21 | // Supported locales |
| 22 | 22 | $supported = array( |
| 23 | 23 | Locales::DE, |
@@ -28,13 +28,13 @@ discard block |
||
| 28 | 28 | ); |
| 29 | 29 | |
| 30 | 30 | // Sub string |
| 31 | - $locale = substr( $locale, 0, 2 ); |
|
| 31 | + $locale = substr($locale, 0, 2); |
|
| 32 | 32 | |
| 33 | 33 | // Lower case |
| 34 | - $locale = strtolower( $locale ); |
|
| 34 | + $locale = strtolower($locale); |
|
| 35 | 35 | |
| 36 | 36 | // Is supported? |
| 37 | - if ( in_array( $locale, $supported, true ) ) { |
|
| 37 | + if (in_array($locale, $supported, true)) { |
|
| 38 | 38 | return $locale; |
| 39 | 39 | } |
| 40 | 40 | |
@@ -137,13 +137,13 @@ discard block |
||
| 137 | 137 | * |
| 138 | 138 | * @return string |
| 139 | 139 | */ |
| 140 | - public static function transform( $payment_method, $default = null ) { |
|
| 141 | - if ( ! is_scalar( $payment_method ) ) { |
|
| 140 | + public static function transform($payment_method, $default = null) { |
|
| 141 | + if ( ! is_scalar($payment_method)) { |
|
| 142 | 142 | return null; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - if ( isset( self::$map[ $payment_method ] ) ) { |
|
| 146 | - return self::$map[ $payment_method ]; |
|
| 145 | + if (isset(self::$map[$payment_method])) { |
|
| 146 | + return self::$map[$payment_method]; |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | return $default; |
@@ -158,14 +158,14 @@ discard block |
||
| 158 | 158 | * |
| 159 | 159 | * @return string |
| 160 | 160 | */ |
| 161 | - public static function transform_gateway_method( $method ) { |
|
| 162 | - if ( ! is_scalar( $method ) ) { |
|
| 161 | + public static function transform_gateway_method($method) { |
|
| 162 | + if ( ! is_scalar($method)) { |
|
| 163 | 163 | return null; |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - $payment_method = array_search( $method, self::$map, true ); |
|
| 166 | + $payment_method = array_search($method, self::$map, true); |
|
| 167 | 167 | |
| 168 | - if ( ! $payment_method ) { |
|
| 168 | + if ( ! $payment_method) { |
|
| 169 | 169 | return null; |
| 170 | 170 | } |
| 171 | 171 | |
@@ -19,8 +19,8 @@ discard block |
||
| 19 | 19 | * Settings constructor. |
| 20 | 20 | */ |
| 21 | 21 | public function __construct() { |
| 22 | - add_filter( 'pronamic_pay_gateway_sections', array( $this, 'sections' ) ); |
|
| 23 | - add_filter( 'pronamic_pay_gateway_fields', array( $this, 'fields' ) ); |
|
| 22 | + add_filter('pronamic_pay_gateway_sections', array($this, 'sections')); |
|
| 23 | + add_filter('pronamic_pay_gateway_fields', array($this, 'fields')); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /** |
@@ -30,19 +30,19 @@ discard block |
||
| 30 | 30 | * |
| 31 | 31 | * @return array |
| 32 | 32 | */ |
| 33 | - public function sections( array $sections ) { |
|
| 33 | + public function sections(array $sections) { |
|
| 34 | 34 | // General. |
| 35 | 35 | $sections['mollie'] = array( |
| 36 | - 'title' => __( 'Mollie', 'pronamic_ideal' ), |
|
| 37 | - 'methods' => array( 'mollie' ), |
|
| 38 | - 'description' => __( 'Account details are provided by the payment provider after registration. These settings need to match with the payment provider dashboard.', 'pronamic_ideal' ), |
|
| 36 | + 'title' => __('Mollie', 'pronamic_ideal'), |
|
| 37 | + 'methods' => array('mollie'), |
|
| 38 | + 'description' => __('Account details are provided by the payment provider after registration. These settings need to match with the payment provider dashboard.', 'pronamic_ideal'), |
|
| 39 | 39 | ); |
| 40 | 40 | |
| 41 | 41 | // Transaction feedback. |
| 42 | 42 | $sections['mollie_feedback'] = array( |
| 43 | - 'title' => __( 'Transaction feedback', 'pronamic_ideal' ), |
|
| 44 | - 'methods' => array( 'mollie' ), |
|
| 45 | - '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' ), |
|
| 43 | + 'title' => __('Transaction feedback', 'pronamic_ideal'), |
|
| 44 | + 'methods' => array('mollie'), |
|
| 45 | + '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'), |
|
| 46 | 46 | ); |
| 47 | 47 | |
| 48 | 48 | return $sections; |
@@ -55,40 +55,40 @@ discard block |
||
| 55 | 55 | * |
| 56 | 56 | * @return array |
| 57 | 57 | */ |
| 58 | - public function fields( array $fields ) { |
|
| 58 | + public function fields(array $fields) { |
|
| 59 | 59 | // API Key. |
| 60 | 60 | $fields[] = array( |
| 61 | 61 | 'filter' => FILTER_SANITIZE_STRING, |
| 62 | 62 | 'section' => 'mollie', |
| 63 | 63 | 'meta_key' => '_pronamic_gateway_mollie_api_key', |
| 64 | - 'title' => _x( 'API Key', 'mollie', 'pronamic_ideal' ), |
|
| 64 | + 'title' => _x('API Key', 'mollie', 'pronamic_ideal'), |
|
| 65 | 65 | 'type' => 'text', |
| 66 | - 'classes' => array( 'regular-text', 'code' ), |
|
| 67 | - 'methods' => array( 'mollie' ), |
|
| 68 | - 'tooltip' => __( 'API key as mentioned in the payment provider dashboard', 'pronamic_ideal' ), |
|
| 66 | + 'classes' => array('regular-text', 'code'), |
|
| 67 | + 'methods' => array('mollie'), |
|
| 68 | + 'tooltip' => __('API key as mentioned in the payment provider dashboard', 'pronamic_ideal'), |
|
| 69 | 69 | ); |
| 70 | 70 | |
| 71 | 71 | // Transaction feedback. |
| 72 | 72 | $fields[] = array( |
| 73 | 73 | 'section' => 'mollie', |
| 74 | - 'title' => __( 'Transaction feedback', 'pronamic_ideal' ), |
|
| 74 | + 'title' => __('Transaction feedback', 'pronamic_ideal'), |
|
| 75 | 75 | 'type' => 'description', |
| 76 | 76 | 'html' => sprintf( |
| 77 | 77 | '<span class="dashicons dashicons-yes"></span> %s', |
| 78 | - __( 'Payment status updates will be processed without any additional configuration.', 'pronamic_ideal' ) |
|
| 78 | + __('Payment status updates will be processed without any additional configuration.', 'pronamic_ideal') |
|
| 79 | 79 | ), |
| 80 | 80 | ); |
| 81 | 81 | |
| 82 | 82 | // Webhook. |
| 83 | 83 | $fields[] = array( |
| 84 | 84 | 'section' => 'mollie_feedback', |
| 85 | - 'title' => __( 'Webhook URL', 'pronamic_ideal' ), |
|
| 85 | + 'title' => __('Webhook URL', 'pronamic_ideal'), |
|
| 86 | 86 | 'type' => 'text', |
| 87 | - 'classes' => array( 'large-text', 'code' ), |
|
| 88 | - 'value' => add_query_arg( 'mollie_webhook', '', home_url( '/' ) ), |
|
| 87 | + 'classes' => array('large-text', 'code'), |
|
| 88 | + 'value' => add_query_arg('mollie_webhook', '', home_url('/')), |
|
| 89 | 89 | 'readonly' => true, |
| 90 | - 'methods' => array( 'mollie' ), |
|
| 91 | - 'tooltip' => __( 'The Webhook URL as sent with each transaction to receive automatic payment status updates on.', 'pronamic_ideal' ), |
|
| 90 | + 'methods' => array('mollie'), |
|
| 91 | + 'tooltip' => __('The Webhook URL as sent with each transaction to receive automatic payment status updates on.', 'pronamic_ideal'), |
|
| 92 | 92 | ); |
| 93 | 93 | |
| 94 | 94 | return $fields; |
@@ -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_mollie_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_mollie_api_key', true); |
|
| 22 | + $config->mode = get_post_meta($post_id, '_pronamic_gateway_mode', true); |
|
| 23 | 23 | |
| 24 | 24 | return $config; |
| 25 | 25 | } |
@@ -79,8 +79,8 @@ |
||
| 79 | 79 | * |
| 80 | 80 | * @return string|null Pay status. |
| 81 | 81 | */ |
| 82 | - public static function transform( $status ) { |
|
| 83 | - switch ( $status ) { |
|
| 82 | + public static function transform($status) { |
|
| 83 | + switch ($status) { |
|
| 84 | 84 | case self::PENDING: |
| 85 | 85 | case self::OPEN: |
| 86 | 86 | return Core_Statuses::OPEN; |
@@ -38,8 +38,8 @@ discard block |
||
| 38 | 38 | * |
| 39 | 39 | * @param Config $config |
| 40 | 40 | */ |
| 41 | - public function __construct( Config $config ) { |
|
| 42 | - parent::__construct( $config ); |
|
| 41 | + public function __construct(Config $config) { |
|
| 42 | + parent::__construct($config); |
|
| 43 | 43 | |
| 44 | 44 | $this->supports = array( |
| 45 | 45 | 'payment_status_request', |
@@ -48,18 +48,18 @@ discard block |
||
| 48 | 48 | 'recurring', |
| 49 | 49 | ); |
| 50 | 50 | |
| 51 | - $this->set_method( Core_Gateway::METHOD_HTTP_REDIRECT ); |
|
| 52 | - $this->set_slug( self::SLUG ); |
|
| 51 | + $this->set_method(Core_Gateway::METHOD_HTTP_REDIRECT); |
|
| 52 | + $this->set_slug(self::SLUG); |
|
| 53 | 53 | |
| 54 | - $this->client = new Client( $config->api_key ); |
|
| 55 | - $this->client->set_mode( $config->mode ); |
|
| 54 | + $this->client = new Client($config->api_key); |
|
| 55 | + $this->client->set_mode($config->mode); |
|
| 56 | 56 | |
| 57 | - if ( 'test' === $config->mode ) { |
|
| 57 | + if ('test' === $config->mode) { |
|
| 58 | 58 | $this->meta_key_customer_id = '_pronamic_pay_mollie_customer_id_test'; |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | // Actions. |
| 62 | - add_action( 'pronamic_payment_status_update', array( $this, 'copy_customer_id_to_wp_user' ), 99, 1 ); |
|
| 62 | + add_action('pronamic_payment_status_update', array($this, 'copy_customer_id_to_wp_user'), 99, 1); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | /** |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | $result = $this->client->get_issuers(); |
| 74 | 74 | |
| 75 | - if ( ! $result ) { |
|
| 75 | + if ( ! $result) { |
|
| 76 | 76 | $this->error = $this->client->get_error(); |
| 77 | 77 | |
| 78 | 78 | return $groups; |
@@ -94,51 +94,51 @@ discard block |
||
| 94 | 94 | $payment_methods = array(); |
| 95 | 95 | |
| 96 | 96 | // Set recurring types to get payment methods for. |
| 97 | - $recurring_types = array( null, Recurring::RECURRING, Recurring::FIRST ); |
|
| 97 | + $recurring_types = array(null, Recurring::RECURRING, Recurring::FIRST); |
|
| 98 | 98 | |
| 99 | 99 | $results = array(); |
| 100 | 100 | |
| 101 | - foreach ( $recurring_types as $recurring_type ) { |
|
| 101 | + foreach ($recurring_types as $recurring_type) { |
|
| 102 | 102 | // Get active payment methods for Mollie account. |
| 103 | - $result = $this->client->get_payment_methods( $recurring_type ); |
|
| 103 | + $result = $this->client->get_payment_methods($recurring_type); |
|
| 104 | 104 | |
| 105 | - if ( ! $result ) { |
|
| 105 | + if ( ! $result) { |
|
| 106 | 106 | $this->error = $this->client->get_error(); |
| 107 | 107 | |
| 108 | 108 | break; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - if ( Recurring::FIRST === $recurring_type ) { |
|
| 112 | - foreach ( $result as $method => $title ) { |
|
| 113 | - unset( $result[ $method ] ); |
|
| 111 | + if (Recurring::FIRST === $recurring_type) { |
|
| 112 | + foreach ($result as $method => $title) { |
|
| 113 | + unset($result[$method]); |
|
| 114 | 114 | |
| 115 | 115 | // Get WordPress payment method for direct debit method. |
| 116 | - $method = Methods::transform_gateway_method( $method ); |
|
| 117 | - $payment_method = array_search( $method, PaymentMethods::get_recurring_methods(), true ); |
|
| 116 | + $method = Methods::transform_gateway_method($method); |
|
| 117 | + $payment_method = array_search($method, PaymentMethods::get_recurring_methods(), true); |
|
| 118 | 118 | |
| 119 | - if ( $payment_method ) { |
|
| 120 | - $results[ $payment_method ] = $title; |
|
| 119 | + if ($payment_method) { |
|
| 120 | + $results[$payment_method] = $title; |
|
| 121 | 121 | } |
| 122 | 122 | } |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - $results = array_merge( $results, $result ); |
|
| 125 | + $results = array_merge($results, $result); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | // Transform to WordPress payment methods. |
| 129 | - foreach ( $results as $method => $title ) { |
|
| 130 | - if ( PaymentMethods::is_recurring_method( $method ) ) { |
|
| 129 | + foreach ($results as $method => $title) { |
|
| 130 | + if (PaymentMethods::is_recurring_method($method)) { |
|
| 131 | 131 | $payment_method = $method; |
| 132 | 132 | } else { |
| 133 | - $payment_method = Methods::transform_gateway_method( $method ); |
|
| 133 | + $payment_method = Methods::transform_gateway_method($method); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - if ( $payment_method ) { |
|
| 136 | + if ($payment_method) { |
|
| 137 | 137 | $payment_methods[] = $payment_method; |
| 138 | 138 | } |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - $payment_methods = array_unique( $payment_methods ); |
|
| 141 | + $payment_methods = array_unique($payment_methods); |
|
| 142 | 142 | |
| 143 | 143 | return $payment_methods; |
| 144 | 144 | } |
@@ -172,22 +172,22 @@ discard block |
||
| 172 | 172 | * @return string |
| 173 | 173 | */ |
| 174 | 174 | public function get_webhook_url() { |
| 175 | - $url = home_url( '/' ); |
|
| 175 | + $url = home_url('/'); |
|
| 176 | 176 | |
| 177 | - $host = wp_parse_url( $url, PHP_URL_HOST ); |
|
| 177 | + $host = wp_parse_url($url, PHP_URL_HOST); |
|
| 178 | 178 | |
| 179 | - if ( 'localhost' === $host ) { |
|
| 179 | + if ('localhost' === $host) { |
|
| 180 | 180 | // Mollie doesn't allow localhost. |
| 181 | 181 | return null; |
| 182 | - } elseif ( '.dev' === substr( $host, -4 ) ) { |
|
| 182 | + } elseif ('.dev' === substr($host, -4)) { |
|
| 183 | 183 | // Mollie doesn't allow the .dev TLD. |
| 184 | 184 | return null; |
| 185 | - } elseif ( '.local' === substr( $host, -6 ) ) { |
|
| 185 | + } elseif ('.local' === substr($host, -6)) { |
|
| 186 | 186 | // Mollie doesn't allow the .local TLD. |
| 187 | 187 | return null; |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - $url = add_query_arg( 'mollie_webhook', '', $url ); |
|
| 190 | + $url = add_query_arg('mollie_webhook', '', $url); |
|
| 191 | 191 | |
| 192 | 192 | return $url; |
| 193 | 193 | } |
@@ -197,19 +197,19 @@ discard block |
||
| 197 | 197 | * |
| 198 | 198 | * @see Pronamic_WP_Pay_Gateway::start() |
| 199 | 199 | */ |
| 200 | - public function start( Payment $payment ) { |
|
| 200 | + public function start(Payment $payment) { |
|
| 201 | 201 | $request = new PaymentRequest(); |
| 202 | 202 | |
| 203 | 203 | $request->amount = $payment->get_amount()->get_amount(); |
| 204 | 204 | $request->description = $payment->get_description(); |
| 205 | 205 | $request->redirect_url = $payment->get_return_url(); |
| 206 | 206 | $request->webhook_url = $this->get_webhook_url(); |
| 207 | - $request->locale = LocaleHelper::transform( $payment->get_language() ); |
|
| 207 | + $request->locale = LocaleHelper::transform($payment->get_language()); |
|
| 208 | 208 | |
| 209 | 209 | // Customer ID. |
| 210 | - $customer_id = $this->get_customer_id_for_payment( $payment ); |
|
| 210 | + $customer_id = $this->get_customer_id_for_payment($payment); |
|
| 211 | 211 | |
| 212 | - if ( ! empty( $customer_id ) ) { |
|
| 212 | + if ( ! empty($customer_id)) { |
|
| 213 | 213 | $request->customer_id = $customer_id; |
| 214 | 214 | } |
| 215 | 215 | |
@@ -219,49 +219,49 @@ discard block |
||
| 219 | 219 | // Subscription. |
| 220 | 220 | $subscription = $payment->get_subscription(); |
| 221 | 221 | |
| 222 | - if ( $subscription && PaymentMethods::is_recurring_method( $payment_method ) ) { |
|
| 222 | + if ($subscription && PaymentMethods::is_recurring_method($payment_method)) { |
|
| 223 | 223 | $request->recurring_type = $payment->get_recurring() ? Recurring::RECURRING : Recurring::FIRST; |
| 224 | 224 | |
| 225 | - if ( Recurring::FIRST === $request->recurring_type ) { |
|
| 226 | - $payment_method = PaymentMethods::get_first_payment_method( $payment_method ); |
|
| 225 | + if (Recurring::FIRST === $request->recurring_type) { |
|
| 226 | + $payment_method = PaymentMethods::get_first_payment_method($payment_method); |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - if ( Recurring::RECURRING === $request->recurring_type ) { |
|
| 230 | - $payment->set_action_url( $payment->get_return_url() ); |
|
| 229 | + if (Recurring::RECURRING === $request->recurring_type) { |
|
| 230 | + $payment->set_action_url($payment->get_return_url()); |
|
| 231 | 231 | } |
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | // Leap of faith if the WordPress payment method could not transform to a Mollie method? |
| 235 | - $request->method = Methods::transform( $payment_method, $payment_method ); |
|
| 235 | + $request->method = Methods::transform($payment_method, $payment_method); |
|
| 236 | 236 | |
| 237 | 237 | // Issuer. |
| 238 | - if ( Methods::IDEAL === $request->method ) { |
|
| 238 | + if (Methods::IDEAL === $request->method) { |
|
| 239 | 239 | // If payment method is iDEAL we set the user chosen issuer ID. |
| 240 | 240 | $request->issuer = $payment->get_issuer(); |
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | // Create payment. |
| 244 | - $result = $this->client->create_payment( $request ); |
|
| 244 | + $result = $this->client->create_payment($request); |
|
| 245 | 245 | |
| 246 | - if ( ! $result ) { |
|
| 246 | + if ( ! $result) { |
|
| 247 | 247 | $this->error = $this->client->get_error(); |
| 248 | 248 | |
| 249 | 249 | return false; |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | // Set transaction ID. |
| 253 | - if ( isset( $result->id ) ) { |
|
| 254 | - $payment->set_transaction_id( $result->id ); |
|
| 253 | + if (isset($result->id)) { |
|
| 254 | + $payment->set_transaction_id($result->id); |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | // Set status |
| 258 | - if ( isset( $result->status ) ) { |
|
| 259 | - $payment->set_status( Statuses::transform( $result->status ) ); |
|
| 258 | + if (isset($result->status)) { |
|
| 259 | + $payment->set_status(Statuses::transform($result->status)); |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | // Set action URL. |
| 263 | - if ( isset( $result->links, $result->links->paymentUrl ) ) { |
|
| 264 | - $payment->set_action_url( $result->links->paymentUrl ); |
|
| 263 | + if (isset($result->links, $result->links->paymentUrl)) { |
|
| 264 | + $payment->set_action_url($result->links->paymentUrl); |
|
| 265 | 265 | } |
| 266 | 266 | } |
| 267 | 267 | |
@@ -270,36 +270,36 @@ discard block |
||
| 270 | 270 | * |
| 271 | 271 | * @param Payment $payment |
| 272 | 272 | */ |
| 273 | - public function update_status( Payment $payment ) { |
|
| 274 | - $mollie_payment = $this->client->get_payment( $payment->get_transaction_id() ); |
|
| 273 | + public function update_status(Payment $payment) { |
|
| 274 | + $mollie_payment = $this->client->get_payment($payment->get_transaction_id()); |
|
| 275 | 275 | |
| 276 | - if ( ! $mollie_payment ) { |
|
| 277 | - $payment->set_status( Core_Statuses::FAILURE ); |
|
| 276 | + if ( ! $mollie_payment) { |
|
| 277 | + $payment->set_status(Core_Statuses::FAILURE); |
|
| 278 | 278 | |
| 279 | 279 | $this->error = $this->client->get_error(); |
| 280 | 280 | |
| 281 | 281 | return; |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | - $payment->set_status( Statuses::transform( $mollie_payment->status ) ); |
|
| 284 | + $payment->set_status(Statuses::transform($mollie_payment->status)); |
|
| 285 | 285 | |
| 286 | - if ( isset( $mollie_payment->details ) ) { |
|
| 286 | + if (isset($mollie_payment->details)) { |
|
| 287 | 287 | $details = $mollie_payment->details; |
| 288 | 288 | |
| 289 | - if ( isset( $details->consumerName ) ) { |
|
| 290 | - $payment->set_consumer_name( $details->consumerName ); |
|
| 289 | + if (isset($details->consumerName)) { |
|
| 290 | + $payment->set_consumer_name($details->consumerName); |
|
| 291 | 291 | } |
| 292 | 292 | |
| 293 | - if ( isset( $details->cardHolder ) ) { |
|
| 294 | - $payment->set_consumer_name( $details->cardHolder ); |
|
| 293 | + if (isset($details->cardHolder)) { |
|
| 294 | + $payment->set_consumer_name($details->cardHolder); |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | - if ( isset( $details->consumerAccount ) ) { |
|
| 298 | - $payment->set_consumer_iban( $details->consumerAccount ); |
|
| 297 | + if (isset($details->consumerAccount)) { |
|
| 298 | + $payment->set_consumer_iban($details->consumerAccount); |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | - if ( isset( $details->consumerBic ) ) { |
|
| 302 | - $payment->set_consumer_bic( $details->consumerBic ); |
|
| 301 | + if (isset($details->consumerBic)) { |
|
| 302 | + $payment->set_consumer_bic($details->consumerBic); |
|
| 303 | 303 | } |
| 304 | 304 | } |
| 305 | 305 | } |
@@ -311,42 +311,42 @@ discard block |
||
| 311 | 311 | * |
| 312 | 312 | * @return bool|string |
| 313 | 313 | */ |
| 314 | - public function get_customer_id_for_payment( Payment $payment ) { |
|
| 314 | + public function get_customer_id_for_payment(Payment $payment) { |
|
| 315 | 315 | // Get Mollie customer ID from user meta. |
| 316 | - $customer_id = $this->get_customer_id_by_wp_user_id( $payment->user_id ); |
|
| 316 | + $customer_id = $this->get_customer_id_by_wp_user_id($payment->user_id); |
|
| 317 | 317 | |
| 318 | 318 | $subscription = $payment->get_subscription(); |
| 319 | 319 | |
| 320 | 320 | // Get customer ID from subscription meta. |
| 321 | - if ( $subscription ) { |
|
| 322 | - $subscription_customer_id = $subscription->get_meta( 'mollie_customer_id' ); |
|
| 321 | + if ($subscription) { |
|
| 322 | + $subscription_customer_id = $subscription->get_meta('mollie_customer_id'); |
|
| 323 | 323 | |
| 324 | 324 | // Try to get (legacy) customer ID from first payment. |
| 325 | - if ( empty( $subscription_customer_id ) && $subscription->get_first_payment() ) { |
|
| 325 | + if (empty($subscription_customer_id) && $subscription->get_first_payment()) { |
|
| 326 | 326 | $first_payment = $subscription->get_first_payment(); |
| 327 | 327 | |
| 328 | - $subscription_customer_id = $first_payment->get_meta( 'mollie_customer_id' ); |
|
| 328 | + $subscription_customer_id = $first_payment->get_meta('mollie_customer_id'); |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | - if ( ! empty( $subscription_customer_id ) ) { |
|
| 331 | + if ( ! empty($subscription_customer_id)) { |
|
| 332 | 332 | $customer_id = $subscription_customer_id; |
| 333 | 333 | } |
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | // Create new customer if the customer does not exist at Mollie. |
| 337 | - if ( ( empty( $customer_id ) || ! $this->client->get_customer( $customer_id ) ) && Core_Recurring::RECURRING !== $payment->recurring_type ) { |
|
| 338 | - $customer_id = $this->client->create_customer( $payment->get_email(), $payment->get_customer_name() ); |
|
| 337 | + if ((empty($customer_id) || ! $this->client->get_customer($customer_id)) && Core_Recurring::RECURRING !== $payment->recurring_type) { |
|
| 338 | + $customer_id = $this->client->create_customer($payment->get_email(), $payment->get_customer_name()); |
|
| 339 | 339 | |
| 340 | - $this->update_wp_user_customer_id( $payment->user_id, $customer_id ); |
|
| 340 | + $this->update_wp_user_customer_id($payment->user_id, $customer_id); |
|
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | // Store customer ID in subscription meta. |
| 344 | - if ( $subscription && empty( $subscription_customer_id ) && ! empty( $customer_id ) ) { |
|
| 345 | - $subscription->set_meta( 'mollie_customer_id', $customer_id ); |
|
| 344 | + if ($subscription && empty($subscription_customer_id) && ! empty($customer_id)) { |
|
| 345 | + $subscription->set_meta('mollie_customer_id', $customer_id); |
|
| 346 | 346 | } |
| 347 | 347 | |
| 348 | 348 | // Copy customer ID from subscription to user meta. |
| 349 | - $this->copy_customer_id_to_wp_user( $payment ); |
|
| 349 | + $this->copy_customer_id_to_wp_user($payment); |
|
| 350 | 350 | |
| 351 | 351 | return $customer_id; |
| 352 | 352 | } |
@@ -358,12 +358,12 @@ discard block |
||
| 358 | 358 | * |
| 359 | 359 | * @return string |
| 360 | 360 | */ |
| 361 | - public function get_customer_id_by_wp_user_id( $user_id ) { |
|
| 362 | - if ( empty( $user_id ) ) { |
|
| 361 | + public function get_customer_id_by_wp_user_id($user_id) { |
|
| 362 | + if (empty($user_id)) { |
|
| 363 | 363 | return false; |
| 364 | 364 | } |
| 365 | 365 | |
| 366 | - return get_user_meta( $user_id, $this->meta_key_customer_id, true ); |
|
| 366 | + return get_user_meta($user_id, $this->meta_key_customer_id, true); |
|
| 367 | 367 | } |
| 368 | 368 | |
| 369 | 369 | /** |
@@ -374,16 +374,16 @@ discard block |
||
| 374 | 374 | * |
| 375 | 375 | * @return bool |
| 376 | 376 | */ |
| 377 | - private function update_wp_user_customer_id( $user_id, $customer_id ) { |
|
| 378 | - if ( empty( $user_id ) || is_bool( $user_id ) ) { |
|
| 377 | + private function update_wp_user_customer_id($user_id, $customer_id) { |
|
| 378 | + if (empty($user_id) || is_bool($user_id)) { |
|
| 379 | 379 | return false; |
| 380 | 380 | } |
| 381 | 381 | |
| 382 | - if ( ! is_string( $customer_id ) || empty( $customer_id ) || 1 === strlen( $customer_id ) ) { |
|
| 382 | + if ( ! is_string($customer_id) || empty($customer_id) || 1 === strlen($customer_id)) { |
|
| 383 | 383 | return false; |
| 384 | 384 | } |
| 385 | 385 | |
| 386 | - update_user_meta( $user_id, $this->meta_key_customer_id, $customer_id ); |
|
| 386 | + update_user_meta($user_id, $this->meta_key_customer_id, $customer_id); |
|
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | /** |
@@ -393,25 +393,25 @@ discard block |
||
| 393 | 393 | * |
| 394 | 394 | * @return void |
| 395 | 395 | */ |
| 396 | - public function copy_customer_id_to_wp_user( Payment $payment ) { |
|
| 397 | - if ( $this->config->id !== $payment->config_id ) { |
|
| 396 | + public function copy_customer_id_to_wp_user(Payment $payment) { |
|
| 397 | + if ($this->config->id !== $payment->config_id) { |
|
| 398 | 398 | return; |
| 399 | 399 | } |
| 400 | 400 | |
| 401 | 401 | $subscription = $payment->get_subscription(); |
| 402 | 402 | |
| 403 | - if ( ! $subscription || empty( $subscription->user_id ) ) { |
|
| 403 | + if ( ! $subscription || empty($subscription->user_id)) { |
|
| 404 | 404 | return; |
| 405 | 405 | } |
| 406 | 406 | |
| 407 | 407 | // Get customer ID from subscription meta. |
| 408 | - $customer_id = $subscription->get_meta( 'mollie_customer_id' ); |
|
| 408 | + $customer_id = $subscription->get_meta('mollie_customer_id'); |
|
| 409 | 409 | |
| 410 | - $user_customer_id = $this->get_customer_id_by_wp_user_id( $subscription->user_id ); |
|
| 410 | + $user_customer_id = $this->get_customer_id_by_wp_user_id($subscription->user_id); |
|
| 411 | 411 | |
| 412 | - if ( empty( $user_customer_id ) ) { |
|
| 412 | + if (empty($user_customer_id)) { |
|
| 413 | 413 | // Set customer ID as user meta. |
| 414 | - $this->update_wp_user_customer_id( $subscription->user_id, $customer_id ); |
|
| 414 | + $this->update_wp_user_customer_id($subscription->user_id, $customer_id); |
|
| 415 | 415 | } |
| 416 | 416 | } |
| 417 | 417 | } |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | * |
| 52 | 52 | * @param string $api_key |
| 53 | 53 | */ |
| 54 | - public function __construct( $api_key ) { |
|
| 54 | + public function __construct($api_key) { |
|
| 55 | 55 | $this->api_key = $api_key; |
| 56 | 56 | } |
| 57 | 57 | |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | * @since 1.1.9 |
| 62 | 62 | * @param string $mode |
| 63 | 63 | */ |
| 64 | - public function set_mode( $mode ) { |
|
| 64 | + public function set_mode($mode) { |
|
| 65 | 65 | $this->mode = $mode; |
| 66 | 66 | } |
| 67 | 67 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | * |
| 85 | 85 | * @return bool|object |
| 86 | 86 | */ |
| 87 | - private function send_request( $end_point, $method = 'GET', array $data = array(), $expected_response_code = 200 ) { |
|
| 87 | + private function send_request($end_point, $method = 'GET', array $data = array(), $expected_response_code = 200) { |
|
| 88 | 88 | // Request |
| 89 | 89 | $url = self::API_URL . $end_point; |
| 90 | 90 | |
@@ -100,26 +100,26 @@ discard block |
||
| 100 | 100 | ); |
| 101 | 101 | |
| 102 | 102 | // Response code |
| 103 | - $response_code = wp_remote_retrieve_response_code( $response ); |
|
| 103 | + $response_code = wp_remote_retrieve_response_code($response); |
|
| 104 | 104 | |
| 105 | - if ( $expected_response_code != $response_code ) { // WPCS: loose comparison ok. |
|
| 106 | - $this->error = new WP_Error( 'mollie_error', 'Unexpected response code.' ); |
|
| 105 | + if ($expected_response_code != $response_code) { // WPCS: loose comparison ok. |
|
| 106 | + $this->error = new WP_Error('mollie_error', 'Unexpected response code.'); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | // Body |
| 110 | - $body = wp_remote_retrieve_body( $response ); |
|
| 110 | + $body = wp_remote_retrieve_body($response); |
|
| 111 | 111 | |
| 112 | - $data = json_decode( $body ); |
|
| 112 | + $data = json_decode($body); |
|
| 113 | 113 | |
| 114 | - if ( ! is_object( $data ) ) { |
|
| 115 | - $this->error = new WP_Error( 'mollie_error', 'Could not parse response.' ); |
|
| 114 | + if ( ! is_object($data)) { |
|
| 115 | + $this->error = new WP_Error('mollie_error', 'Could not parse response.'); |
|
| 116 | 116 | |
| 117 | 117 | return false; |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | // Mollie error |
| 121 | - if ( isset( $data->error, $data->error->message ) ) { |
|
| 122 | - $this->error = new \WP_Error( 'mollie_error', $data->error->message, $data->error ); |
|
| 121 | + if (isset($data->error, $data->error->message)) { |
|
| 122 | + $this->error = new \WP_Error('mollie_error', $data->error->message, $data->error); |
|
| 123 | 123 | |
| 124 | 124 | return false; |
| 125 | 125 | } |
@@ -127,20 +127,20 @@ discard block |
||
| 127 | 127 | return $data; |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - public function create_payment( PaymentRequest $request ) { |
|
| 131 | - return $this->send_request( 'payments/', 'POST', $request->get_array(), 201 ); |
|
| 130 | + public function create_payment(PaymentRequest $request) { |
|
| 131 | + return $this->send_request('payments/', 'POST', $request->get_array(), 201); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | public function get_payments() { |
| 135 | - return $this->send_request( 'payments/', 'GET' ); |
|
| 135 | + return $this->send_request('payments/', 'GET'); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - public function get_payment( $payment_id ) { |
|
| 139 | - if ( empty( $payment_id ) ) { |
|
| 138 | + public function get_payment($payment_id) { |
|
| 139 | + if (empty($payment_id)) { |
|
| 140 | 140 | return false; |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - return $this->send_request( 'payments/' . $payment_id, 'GET' ); |
|
| 143 | + return $this->send_request('payments/' . $payment_id, 'GET'); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
@@ -149,21 +149,21 @@ discard block |
||
| 149 | 149 | * @return array |
| 150 | 150 | */ |
| 151 | 151 | public function get_issuers() { |
| 152 | - $response = $this->send_request( 'issuers/', 'GET' ); |
|
| 152 | + $response = $this->send_request('issuers/', 'GET'); |
|
| 153 | 153 | |
| 154 | - if ( false === $response ) { |
|
| 154 | + if (false === $response) { |
|
| 155 | 155 | return false; |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | $issuers = array(); |
| 159 | 159 | |
| 160 | - if ( isset( $response->data ) ) { |
|
| 161 | - foreach ( $response->data as $issuer ) { |
|
| 162 | - if ( Methods::IDEAL === $issuer->method ) { |
|
| 163 | - $id = Security::filter( $issuer->id ); |
|
| 164 | - $name = Security::filter( $issuer->name ); |
|
| 160 | + if (isset($response->data)) { |
|
| 161 | + foreach ($response->data as $issuer) { |
|
| 162 | + if (Methods::IDEAL === $issuer->method) { |
|
| 163 | + $id = Security::filter($issuer->id); |
|
| 164 | + $name = Security::filter($issuer->name); |
|
| 165 | 165 | |
| 166 | - $issuers[ $id ] = $name; |
|
| 166 | + $issuers[$id] = $name; |
|
| 167 | 167 | } |
| 168 | 168 | } |
| 169 | 169 | } |
@@ -178,27 +178,27 @@ discard block |
||
| 178 | 178 | * |
| 179 | 179 | * @return array |
| 180 | 180 | */ |
| 181 | - public function get_payment_methods( $recurring_type = '' ) { |
|
| 181 | + public function get_payment_methods($recurring_type = '') { |
|
| 182 | 182 | $data = array(); |
| 183 | 183 | |
| 184 | - if ( '' !== $recurring_type ) { |
|
| 184 | + if ('' !== $recurring_type) { |
|
| 185 | 185 | $data['recurringType'] = $recurring_type; |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | - $response = $this->send_request( 'methods/', 'GET', $data ); |
|
| 188 | + $response = $this->send_request('methods/', 'GET', $data); |
|
| 189 | 189 | |
| 190 | - if ( false === $response ) { |
|
| 190 | + if (false === $response) { |
|
| 191 | 191 | return false; |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | $payment_methods = array(); |
| 195 | 195 | |
| 196 | - if ( isset( $response->data ) ) { |
|
| 197 | - foreach ( $response->data as $payment_method ) { |
|
| 198 | - $id = Security::filter( $payment_method->id ); |
|
| 199 | - $name = Security::filter( $payment_method->description ); |
|
| 196 | + if (isset($response->data)) { |
|
| 197 | + foreach ($response->data as $payment_method) { |
|
| 198 | + $id = Security::filter($payment_method->id); |
|
| 199 | + $name = Security::filter($payment_method->description); |
|
| 200 | 200 | |
| 201 | - $payment_methods[ $id ] = $name; |
|
| 201 | + $payment_methods[$id] = $name; |
|
| 202 | 202 | } |
| 203 | 203 | } |
| 204 | 204 | |
@@ -215,8 +215,8 @@ discard block |
||
| 215 | 215 | * |
| 216 | 216 | * @return array|bool |
| 217 | 217 | */ |
| 218 | - public function create_customer( $email, $name ) { |
|
| 219 | - if ( empty( $email ) || empty( $name ) ) { |
|
| 218 | + public function create_customer($email, $name) { |
|
| 219 | + if (empty($email) || empty($name)) { |
|
| 220 | 220 | return false; |
| 221 | 221 | } |
| 222 | 222 | |
@@ -230,11 +230,11 @@ discard block |
||
| 230 | 230 | 201 |
| 231 | 231 | ); |
| 232 | 232 | |
| 233 | - if ( false === $response ) { |
|
| 233 | + if (false === $response) { |
|
| 234 | 234 | return false; |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | - if ( ! isset( $response->id ) ) { |
|
| 237 | + if ( ! isset($response->id)) { |
|
| 238 | 238 | return false; |
| 239 | 239 | } |
| 240 | 240 | |
@@ -250,18 +250,18 @@ discard block |
||
| 250 | 250 | * |
| 251 | 251 | * @return array |
| 252 | 252 | */ |
| 253 | - public function get_customer( $customer_id ) { |
|
| 254 | - if ( empty( $customer_id ) ) { |
|
| 253 | + public function get_customer($customer_id) { |
|
| 254 | + if (empty($customer_id)) { |
|
| 255 | 255 | return false; |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | - $response = $this->send_request( 'customers/' . $customer_id, 'GET', array(), 200 ); |
|
| 258 | + $response = $this->send_request('customers/' . $customer_id, 'GET', array(), 200); |
|
| 259 | 259 | |
| 260 | - if ( false === $response ) { |
|
| 260 | + if (false === $response) { |
|
| 261 | 261 | return false; |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | - if ( is_wp_error( $this->error ) ) { |
|
| 264 | + if (is_wp_error($this->error)) { |
|
| 265 | 265 | return false; |
| 266 | 266 | } |
| 267 | 267 | |
@@ -275,12 +275,12 @@ discard block |
||
| 275 | 275 | * |
| 276 | 276 | * @return array |
| 277 | 277 | */ |
| 278 | - public function get_mandates( $customer_id ) { |
|
| 279 | - if ( '' === $customer_id ) { |
|
| 278 | + public function get_mandates($customer_id) { |
|
| 279 | + if ('' === $customer_id) { |
|
| 280 | 280 | return false; |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | - return $this->send_request( 'customers/' . $customer_id . '/mandates?count=250', 'GET' ); |
|
| 283 | + return $this->send_request('customers/' . $customer_id . '/mandates?count=250', 'GET'); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | /** |
@@ -290,21 +290,21 @@ discard block |
||
| 290 | 290 | * |
| 291 | 291 | * @return boolean |
| 292 | 292 | */ |
| 293 | - public function has_valid_mandate( $customer_id, $payment_method = null ) { |
|
| 294 | - $mandates = $this->get_mandates( $customer_id ); |
|
| 293 | + public function has_valid_mandate($customer_id, $payment_method = null) { |
|
| 294 | + $mandates = $this->get_mandates($customer_id); |
|
| 295 | 295 | |
| 296 | - if ( ! $mandates ) { |
|
| 296 | + if ( ! $mandates) { |
|
| 297 | 297 | return false; |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | - $mollie_method = Methods::transform( $payment_method ); |
|
| 300 | + $mollie_method = Methods::transform($payment_method); |
|
| 301 | 301 | |
| 302 | - foreach ( $mandates->data as $mandate ) { |
|
| 303 | - if ( $mollie_method !== $mandate->method ) { |
|
| 302 | + foreach ($mandates->data as $mandate) { |
|
| 303 | + if ($mollie_method !== $mandate->method) { |
|
| 304 | 304 | continue; |
| 305 | 305 | } |
| 306 | 306 | |
| 307 | - if ( 'valid' === $mandate->status ) { |
|
| 307 | + if ('valid' === $mandate->status) { |
|
| 308 | 308 | return true; |
| 309 | 309 | } |
| 310 | 310 | } |
@@ -320,37 +320,37 @@ discard block |
||
| 320 | 320 | * |
| 321 | 321 | * @return string |
| 322 | 322 | */ |
| 323 | - public function get_first_valid_mandate_datetime( $customer_id, $payment_method = null ) { |
|
| 324 | - $mandates = $this->get_mandates( $customer_id ); |
|
| 323 | + public function get_first_valid_mandate_datetime($customer_id, $payment_method = null) { |
|
| 324 | + $mandates = $this->get_mandates($customer_id); |
|
| 325 | 325 | |
| 326 | - if ( ! $mandates ) { |
|
| 326 | + if ( ! $mandates) { |
|
| 327 | 327 | return null; |
| 328 | 328 | } |
| 329 | 329 | |
| 330 | - $mollie_method = Methods::transform( $payment_method ); |
|
| 330 | + $mollie_method = Methods::transform($payment_method); |
|
| 331 | 331 | |
| 332 | - foreach ( $mandates->data as $mandate ) { |
|
| 333 | - if ( $mollie_method !== $mandate->method ) { |
|
| 332 | + foreach ($mandates->data as $mandate) { |
|
| 333 | + if ($mollie_method !== $mandate->method) { |
|
| 334 | 334 | continue; |
| 335 | 335 | } |
| 336 | 336 | |
| 337 | - if ( 'valid' !== $mandate->status ) { |
|
| 337 | + if ('valid' !== $mandate->status) { |
|
| 338 | 338 | continue; |
| 339 | 339 | } |
| 340 | 340 | |
| 341 | - if ( ! isset( $valid_mandates ) ) { |
|
| 341 | + if ( ! isset($valid_mandates)) { |
|
| 342 | 342 | $valid_mandates = array(); |
| 343 | 343 | } |
| 344 | 344 | |
| 345 | - $valid_mandates[ $mandate->createdDatetime ] = $mandate; |
|
| 345 | + $valid_mandates[$mandate->createdDatetime] = $mandate; |
|
| 346 | 346 | } |
| 347 | 347 | |
| 348 | - if ( isset( $valid_mandates ) ) { |
|
| 349 | - ksort( $valid_mandates ); |
|
| 348 | + if (isset($valid_mandates)) { |
|
| 349 | + ksort($valid_mandates); |
|
| 350 | 350 | |
| 351 | - $mandate = array_shift( $valid_mandates ); |
|
| 351 | + $mandate = array_shift($valid_mandates); |
|
| 352 | 352 | |
| 353 | - $create_date = new DateTime( $mandate->createdDatetime ); |
|
| 353 | + $create_date = new DateTime($mandate->createdDatetime); |
|
| 354 | 354 | |
| 355 | 355 | return $create_date; |
| 356 | 356 | } |