Completed
Push — master ( e0b7f3...35aa58 )
by Roy
13s
created
includes/class-wc-stripe-payment-tokens.php 1 patch
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if ( ! defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -21,11 +21,11 @@  discard block
 block discarded – undo
21 21
 	public function __construct() {
22 22
 		self::$_this = $this;
23 23
 
24
-		add_filter( 'woocommerce_get_customer_payment_tokens', array( $this, 'woocommerce_get_customer_payment_tokens' ), 10, 3 );
25
-		add_filter( 'woocommerce_payment_methods_list_item', array( $this, 'get_account_saved_payment_methods_list_item_sepa' ), 10, 2 );
26
-		add_filter( 'woocommerce_get_credit_card_type_label', array( $this, 'normalize_sepa_label' ) );
27
-		add_action( 'woocommerce_payment_token_deleted', array( $this, 'woocommerce_payment_token_deleted' ), 10, 2 );
28
-		add_action( 'woocommerce_payment_token_set_default', array( $this, 'woocommerce_payment_token_set_default' ) );
24
+		add_filter('woocommerce_get_customer_payment_tokens', array($this, 'woocommerce_get_customer_payment_tokens'), 10, 3);
25
+		add_filter('woocommerce_payment_methods_list_item', array($this, 'get_account_saved_payment_methods_list_item_sepa'), 10, 2);
26
+		add_filter('woocommerce_get_credit_card_type_label', array($this, 'normalize_sepa_label'));
27
+		add_action('woocommerce_payment_token_deleted', array($this, 'woocommerce_payment_token_deleted'), 10, 2);
28
+		add_action('woocommerce_payment_token_set_default', array($this, 'woocommerce_payment_token_set_default'));
29 29
 	}
30 30
 
31 31
 	/**
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
 	 * @param string $label
47 47
 	 * @return string $label
48 48
 	 */
49
-	public function normalize_sepa_label( $label ) {
50
-		if ( 'sepa iban' === strtolower( $label ) ) {
49
+	public function normalize_sepa_label($label) {
50
+		if ('sepa iban' === strtolower($label)) {
51 51
 			return 'SEPA IBAN';
52 52
 		}
53 53
 
@@ -61,19 +61,19 @@  discard block
 block discarded – undo
61 61
 	 * @param int $customer_id
62 62
 	 * @return bool
63 63
 	 */
64
-	public static function customer_has_saved_methods( $customer_id ) {
65
-		$gateways = array( 'stripe', 'stripe_sepa' );
64
+	public static function customer_has_saved_methods($customer_id) {
65
+		$gateways = array('stripe', 'stripe_sepa');
66 66
 
67
-		if ( empty( $customer_id ) ) {
67
+		if (empty($customer_id)) {
68 68
 			return false;
69 69
 		}
70 70
 
71 71
 		$has_token = false;
72 72
 
73
-		foreach ( $gateways as $gateway ) {
74
-			$tokens = WC_Payment_Tokens::get_customer_tokens( $customer_id, $gateway );
73
+		foreach ($gateways as $gateway) {
74
+			$tokens = WC_Payment_Tokens::get_customer_tokens($customer_id, $gateway);
75 75
 
76
-			if ( ! empty( $tokens ) ) {
76
+			if ( ! empty($tokens)) {
77 77
 				$has_token = true;
78 78
 				break;
79 79
 			}
@@ -90,67 +90,67 @@  discard block
 block discarded – undo
90 90
 	 * @param array $tokens
91 91
 	 * @return array
92 92
 	 */
93
-	public function woocommerce_get_customer_payment_tokens( $tokens = array(), $customer_id, $gateway_id ) {
94
-		if ( is_user_logged_in() && class_exists( 'WC_Payment_Token_CC' ) ) {
93
+	public function woocommerce_get_customer_payment_tokens($tokens = array(), $customer_id, $gateway_id) {
94
+		if (is_user_logged_in() && class_exists('WC_Payment_Token_CC')) {
95 95
 			$stored_tokens = array();
96 96
 
97
-			foreach ( $tokens as $token ) {
97
+			foreach ($tokens as $token) {
98 98
 				$stored_tokens[] = $token->get_token();
99 99
 			}
100 100
 
101
-			if ( 'stripe' === $gateway_id ) {
102
-				$stripe_customer = new WC_Stripe_Customer( $customer_id );
101
+			if ('stripe' === $gateway_id) {
102
+				$stripe_customer = new WC_Stripe_Customer($customer_id);
103 103
 				$stripe_sources  = $stripe_customer->get_sources();
104 104
 
105
-				foreach ( $stripe_sources as $source ) {
106
-					if ( isset( $source->type ) && 'card' === $source->type ) {
107
-						if ( ! in_array( $source->id, $stored_tokens ) ) {
105
+				foreach ($stripe_sources as $source) {
106
+					if (isset($source->type) && 'card' === $source->type) {
107
+						if ( ! in_array($source->id, $stored_tokens)) {
108 108
 							$token = new WC_Payment_Token_CC();
109
-							$token->set_token( $source->id );
110
-							$token->set_gateway_id( 'stripe' );
111
-
112
-							if ( 'source' === $source->object && 'card' === $source->type ) {
113
-								$token->set_card_type( strtolower( $source->card->brand ) );
114
-								$token->set_last4( $source->card->last4 );
115
-								$token->set_expiry_month( $source->card->exp_month );
116
-								$token->set_expiry_year( $source->card->exp_year );
109
+							$token->set_token($source->id);
110
+							$token->set_gateway_id('stripe');
111
+
112
+							if ('source' === $source->object && 'card' === $source->type) {
113
+								$token->set_card_type(strtolower($source->card->brand));
114
+								$token->set_last4($source->card->last4);
115
+								$token->set_expiry_month($source->card->exp_month);
116
+								$token->set_expiry_year($source->card->exp_year);
117 117
 							}
118 118
 
119
-							$token->set_user_id( $customer_id );
119
+							$token->set_user_id($customer_id);
120 120
 							$token->save();
121
-							$tokens[ $token->get_id() ] = $token;
121
+							$tokens[$token->get_id()] = $token;
122 122
 						}
123 123
 					} else {
124
-						if ( ! in_array( $source->id, $stored_tokens ) && 'card' === $source->object ) {
124
+						if ( ! in_array($source->id, $stored_tokens) && 'card' === $source->object) {
125 125
 							$token = new WC_Payment_Token_CC();
126
-							$token->set_token( $source->id );
127
-							$token->set_gateway_id( 'stripe' );
128
-							$token->set_card_type( strtolower( $source->brand ) );
129
-							$token->set_last4( $source->last4 );
130
-							$token->set_expiry_month( $source->exp_month );
131
-							$token->set_expiry_year( $source->exp_year );
132
-							$token->set_user_id( $customer_id );
126
+							$token->set_token($source->id);
127
+							$token->set_gateway_id('stripe');
128
+							$token->set_card_type(strtolower($source->brand));
129
+							$token->set_last4($source->last4);
130
+							$token->set_expiry_month($source->exp_month);
131
+							$token->set_expiry_year($source->exp_year);
132
+							$token->set_user_id($customer_id);
133 133
 							$token->save();
134
-							$tokens[ $token->get_id() ] = $token;
134
+							$tokens[$token->get_id()] = $token;
135 135
 						}
136 136
 					}
137 137
 				}
138 138
 			}
139 139
 
140
-			if ( 'stripe_sepa' === $gateway_id ) {
141
-				$stripe_customer = new WC_Stripe_Customer( $customer_id );
140
+			if ('stripe_sepa' === $gateway_id) {
141
+				$stripe_customer = new WC_Stripe_Customer($customer_id);
142 142
 				$stripe_sources  = $stripe_customer->get_sources();
143 143
 
144
-				foreach ( $stripe_sources as $source ) {
145
-					if ( isset( $source->type ) && 'sepa_debit' === $source->type ) {
146
-						if ( ! in_array( $source->id, $stored_tokens ) ) {
144
+				foreach ($stripe_sources as $source) {
145
+					if (isset($source->type) && 'sepa_debit' === $source->type) {
146
+						if ( ! in_array($source->id, $stored_tokens)) {
147 147
 							$token = new WC_Payment_Token_SEPA();
148
-							$token->set_token( $source->id );
149
-							$token->set_gateway_id( 'stripe_sepa' );
150
-							$token->set_last4( $source->sepa_debit->last4 );
151
-							$token->set_user_id( $customer_id );
148
+							$token->set_token($source->id);
149
+							$token->set_gateway_id('stripe_sepa');
150
+							$token->set_last4($source->sepa_debit->last4);
151
+							$token->set_user_id($customer_id);
152 152
 							$token->save();
153
-							$tokens[ $token->get_id() ] = $token;
153
+							$tokens[$token->get_id()] = $token;
154 154
 						}
155 155
 					}
156 156
 				}
@@ -169,10 +169,10 @@  discard block
 block discarded – undo
169 169
 	 * @param  WC_Payment_Token $payment_token The payment token associated with this method entry
170 170
 	 * @return array                           Filtered item
171 171
 	 */
172
-	public function get_account_saved_payment_methods_list_item_sepa( $item, $payment_token ) {
173
-		if ( 'sepa' === strtolower( $payment_token->get_type() ) ) {
172
+	public function get_account_saved_payment_methods_list_item_sepa($item, $payment_token) {
173
+		if ('sepa' === strtolower($payment_token->get_type())) {
174 174
 			$item['method']['last4'] = $payment_token->get_last4();
175
-			$item['method']['brand'] = esc_html__( 'SEPA IBAN', 'woocommerce-gateway-stripe' );
175
+			$item['method']['brand'] = esc_html__('SEPA IBAN', 'woocommerce-gateway-stripe');
176 176
 		}
177 177
 
178 178
 		return $item;
@@ -184,10 +184,10 @@  discard block
 block discarded – undo
184 184
 	 * @since 3.1.0
185 185
 	 * @version 4.0.0
186 186
 	 */
187
-	public function woocommerce_payment_token_deleted( $token_id, $token ) {
188
-		if ( 'stripe' === $token->get_gateway_id() || 'stripe_sepa' === $token->get_gateway_id() ) {
189
-			$stripe_customer = new WC_Stripe_Customer( get_current_user_id() );
190
-			$stripe_customer->delete_source( $token->get_token() );
187
+	public function woocommerce_payment_token_deleted($token_id, $token) {
188
+		if ('stripe' === $token->get_gateway_id() || 'stripe_sepa' === $token->get_gateway_id()) {
189
+			$stripe_customer = new WC_Stripe_Customer(get_current_user_id());
190
+			$stripe_customer->delete_source($token->get_token());
191 191
 		}
192 192
 	}
193 193
 
@@ -197,12 +197,12 @@  discard block
 block discarded – undo
197 197
 	 * @since 3.1.0
198 198
 	 * @version 4.0.0
199 199
 	 */
200
-	public function woocommerce_payment_token_set_default( $token_id ) {
201
-		$token = WC_Payment_Tokens::get( $token_id );
200
+	public function woocommerce_payment_token_set_default($token_id) {
201
+		$token = WC_Payment_Tokens::get($token_id);
202 202
 
203
-		if ( 'stripe' === $token->get_gateway_id() || 'stripe_sepa' === $token->get_gateway_id() ) {
204
-			$stripe_customer = new WC_Stripe_Customer( get_current_user_id() );
205
-			$stripe_customer->set_default_source( $token->get_token() );
203
+		if ('stripe' === $token->get_gateway_id() || 'stripe_sepa' === $token->get_gateway_id()) {
204
+			$stripe_customer = new WC_Stripe_Customer(get_current_user_id());
205
+			$stripe_customer->set_default_source($token->get_token());
206 206
 		}
207 207
 	}
208 208
 }
Please login to merge, or discard this patch.
tests/phpunit/bootstrap.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,27 +1,27 @@
 block discarded – undo
1 1
 <?php
2
-$_tests_dir = getenv( 'WP_TESTS_DIR' );
3
-if ( ! $_tests_dir ) {
2
+$_tests_dir = getenv('WP_TESTS_DIR');
3
+if ( ! $_tests_dir) {
4 4
 	$_tests_dir = '/tmp/wordpress-tests-lib';
5 5
 }
6 6
 
7 7
 require_once $_tests_dir . '/includes/functions.php';
8 8
 
9 9
 function _manually_load_plugin() {
10
-	$plugin_dir = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/';
10
+	$plugin_dir = dirname(dirname(dirname(dirname(__FILE__)))) . '/';
11 11
 	require $plugin_dir . 'woocommerce/woocommerce.php';
12 12
 	require $plugin_dir . 'woocommerce-gateway-stripe/woocommerce-gateway-stripe.php';
13 13
 }
14 14
 
15
-tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
15
+tests_add_filter('muplugins_loaded', '_manually_load_plugin');
16 16
 
17 17
 require $_tests_dir . '/includes/bootstrap.php';
18 18
 
19
-$wc_tests_framework_base_dir = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/woocommerce/tests/framework/';
20
-require_once( $wc_tests_framework_base_dir . 'class-wc-mock-session-handler.php' );
19
+$wc_tests_framework_base_dir = dirname(dirname(dirname(dirname(__FILE__)))) . '/woocommerce/tests/framework/';
20
+require_once($wc_tests_framework_base_dir . 'class-wc-mock-session-handler.php');
21 21
 //require_once( $wc_tests_framework_base_dir . 'class-wc-unit-test-case.php' );
22
-require_once( $wc_tests_framework_base_dir . 'helpers/class-wc-helper-product.php' );
23
-require_once( $wc_tests_framework_base_dir . 'helpers/class-wc-helper-coupon.php' );
24
-require_once( $wc_tests_framework_base_dir . 'helpers/class-wc-helper-fee.php' );
25
-require_once( $wc_tests_framework_base_dir . 'helpers/class-wc-helper-shipping.php' );
26
-require_once( $wc_tests_framework_base_dir . 'helpers/class-wc-helper-customer.php' );
27
-require_once( $wc_tests_framework_base_dir . 'helpers/class-wc-helper-order.php' );
22
+require_once($wc_tests_framework_base_dir . 'helpers/class-wc-helper-product.php');
23
+require_once($wc_tests_framework_base_dir . 'helpers/class-wc-helper-coupon.php');
24
+require_once($wc_tests_framework_base_dir . 'helpers/class-wc-helper-fee.php');
25
+require_once($wc_tests_framework_base_dir . 'helpers/class-wc-helper-shipping.php');
26
+require_once($wc_tests_framework_base_dir . 'helpers/class-wc-helper-customer.php');
27
+require_once($wc_tests_framework_base_dir . 'helpers/class-wc-helper-order.php');
Please login to merge, or discard this patch.
includes/class-wc-stripe-sepa-payment-token.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'ABSPATH' ) ) {
3
+if ( ! defined('ABSPATH')) {
4 4
 	exit; // Exit if accessed directly
5 5
 }
6 6
 
@@ -35,10 +35,10 @@  discard block
 block discarded – undo
35 35
 	 * @param  string $deprecated Deprecated since WooCommerce 3.0
36 36
 	 * @return string
37 37
 	 */
38
-	public function get_display_name( $deprecated = '' ) {
38
+	public function get_display_name($deprecated = '') {
39 39
 		$display = sprintf(
40 40
 			/* translators: last 4 digits of IBAN account */
41
-			__( 'SEPA IBAN ending in %s', 'woocommerce-gateway-stripe' ),
41
+			__('SEPA IBAN ending in %s', 'woocommerce-gateway-stripe'),
42 42
 			$this->get_last4()
43 43
 		);
44 44
 
@@ -66,11 +66,11 @@  discard block
 block discarded – undo
66 66
 	 * @return boolean True if the passed data is valid
67 67
 	 */
68 68
 	public function validate() {
69
-		if ( false === parent::validate() ) {
69
+		if (false === parent::validate()) {
70 70
 			return false;
71 71
 		}
72 72
 
73
-		if ( ! $this->get_last4( 'edit' ) ) {
73
+		if ( ! $this->get_last4('edit')) {
74 74
 			return false;
75 75
 		}
76 76
 
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
 	 * @param  string $context
86 86
 	 * @return string Last 4 digits
87 87
 	 */
88
-	public function get_last4( $context = 'view' ) {
89
-		return WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $this->get_meta( 'last4' ) : $this->get_prop( 'last4', $context );
88
+	public function get_last4($context = 'view') {
89
+		return WC_Stripe_Helper::is_wc_lt('3.0') ? $this->get_meta('last4') : $this->get_prop('last4', $context);
90 90
 	}
91 91
 
92 92
 	/**
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	 * @version 4.0.0
96 96
 	 * @param string $last4
97 97
 	 */
98
-	public function set_last4( $last4 ) {
99
-		WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $this->add_meta_data( 'last4', $last4, true ) : $this->set_prop( 'last4', $last4 );
98
+	public function set_last4($last4) {
99
+		WC_Stripe_Helper::is_wc_lt('3.0') ? $this->add_meta_data('last4', $last4, true) : $this->set_prop('last4', $last4);
100 100
 	}
101 101
 }
Please login to merge, or discard this patch.
includes/compat/class-wc-stripe-pre-orders-compat.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if ( ! defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 	public $saved_cards;
12 12
 
13 13
 	public function __construct() {
14
-		$this->saved_cards = WC_Stripe_Helper::get_settings( 'stripe', 'saved_cards' );
14
+		$this->saved_cards = WC_Stripe_Helper::get_settings('stripe', 'saved_cards');
15 15
 	}
16 16
 
17 17
 	/**
@@ -19,68 +19,68 @@  discard block
 block discarded – undo
19 19
 	 * @param  int  $order_id
20 20
 	 * @return boolean
21 21
 	 */
22
-	public function is_pre_order( $order_id ) {
23
-		return WC_Pre_Orders_Order::order_contains_pre_order( $order_id );
22
+	public function is_pre_order($order_id) {
23
+		return WC_Pre_Orders_Order::order_contains_pre_order($order_id);
24 24
 	}
25 25
 
26 26
 	/**
27 27
 	 * Remove order meta
28 28
 	 * @param object $order
29 29
 	 */
30
-	public function remove_order_source_before_retry( $order ) {
31
-		$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
32
-		delete_post_meta( $order_id, '_stripe_source_id' );
30
+	public function remove_order_source_before_retry($order) {
31
+		$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
32
+		delete_post_meta($order_id, '_stripe_source_id');
33 33
 		// For BW compat will remove in the future.
34
-		delete_post_meta( $order_id, '_stripe_card_id' );
34
+		delete_post_meta($order_id, '_stripe_card_id');
35 35
 	}
36 36
 
37 37
 	/**
38 38
 	 * Remove order meta
39 39
 	 * @param  object $order
40 40
 	 */
41
-	public function remove_order_customer_before_retry( $order ) {
42
-		$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
43
-		delete_post_meta( $order_id, '_stripe_customer_id' );
41
+	public function remove_order_customer_before_retry($order) {
42
+		$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
43
+		delete_post_meta($order_id, '_stripe_customer_id');
44 44
 	}
45 45
 
46 46
 	/**
47 47
 	 * Process the pre-order when pay upon release is used.
48 48
 	 * @param int $order_id
49 49
 	 */
50
-	public function process_pre_order( $order_id ) {
50
+	public function process_pre_order($order_id) {
51 51
 		try {
52
-			$order = wc_get_order( $order_id );
52
+			$order = wc_get_order($order_id);
53 53
 
54 54
 			// This will throw exception if not valid.
55
-			$this->validate_minimum_order_amount( $order );
55
+			$this->validate_minimum_order_amount($order);
56 56
 
57
-			$prepared_source = $this->prepare_source( get_current_user_id(), true );
57
+			$prepared_source = $this->prepare_source(get_current_user_id(), true);
58 58
 
59 59
 			// We need a source on file to continue.
60
-			if ( empty( $prepared_source->customer ) || empty( $prepared_source->source ) ) {
61
-				throw new WC_Stripe_Exception( __( 'Unable to store payment details. Please try again.', 'woocommerce-gateway-stripe' ) );
60
+			if (empty($prepared_source->customer) || empty($prepared_source->source)) {
61
+				throw new WC_Stripe_Exception(__('Unable to store payment details. Please try again.', 'woocommerce-gateway-stripe'));
62 62
 			}
63 63
 
64
-			$this->save_source_to_order( $order, $prepared_source );
64
+			$this->save_source_to_order($order, $prepared_source);
65 65
 
66 66
 			// Remove cart
67 67
 			WC()->cart->empty_cart();
68 68
 
69 69
 			// Is pre ordered!
70
-			WC_Pre_Orders_Order::mark_order_as_pre_ordered( $order );
70
+			WC_Pre_Orders_Order::mark_order_as_pre_ordered($order);
71 71
 
72 72
 			// Return thank you page redirect
73 73
 			return array(
74 74
 				'result'   => 'success',
75
-				'redirect' => $this->get_return_url( $order ),
75
+				'redirect' => $this->get_return_url($order),
76 76
 			);
77
-		} catch ( WC_Stripe_Exception $e ) {
78
-			wc_add_notice( $e->getLocalizedMessage(), 'error' );
79
-			WC_Stripe_Logger::log( 'Pre Orders Error: ' . $e->getMessage() );
77
+		} catch (WC_Stripe_Exception $e) {
78
+			wc_add_notice($e->getLocalizedMessage(), 'error');
79
+			WC_Stripe_Logger::log('Pre Orders Error: ' . $e->getMessage());
80 80
 
81 81
 			return array(
82 82
 				'result'   => 'success',
83
-				'redirect' => $order->get_checkout_payment_url( true ),
83
+				'redirect' => $order->get_checkout_payment_url(true),
84 84
 			);
85 85
 		}
86 86
 	}
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	 * @param WC_Order $order
91 91
 	 * @return void
92 92
 	 */
93
-	public function process_pre_order_release_payment( $order ) {
93
+	public function process_pre_order_release_payment($order) {
94 94
 		try {
95 95
 			// Define some callbacks if the first attempt fails.
96 96
 			$retry_callbacks = array(
@@ -98,33 +98,33 @@  discard block
 block discarded – undo
98 98
 				'remove_order_customer_before_retry',
99 99
 			);
100 100
 
101
-			while ( 1 ) {
102
-				$source   = $this->prepare_order_source( $order );
103
-				$response = WC_Stripe_API::request( $this->generate_payment_request( $order, $source ) );
101
+			while (1) {
102
+				$source   = $this->prepare_order_source($order);
103
+				$response = WC_Stripe_API::request($this->generate_payment_request($order, $source));
104 104
 
105
-				if ( ! empty( $response->error ) ) {
106
-					if ( 0 === sizeof( $retry_callbacks ) ) {
107
-						throw new Exception( $response->error->message );
105
+				if ( ! empty($response->error)) {
106
+					if (0 === sizeof($retry_callbacks)) {
107
+						throw new Exception($response->error->message);
108 108
 					} else {
109
-						$retry_callback = array_shift( $retry_callbacks );
110
-						call_user_func( array( $this, $retry_callback ), $order );
109
+						$retry_callback = array_shift($retry_callbacks);
110
+						call_user_func(array($this, $retry_callback), $order);
111 111
 					}
112 112
 				} else {
113 113
 					// Successful
114
-					$this->process_response( $response, $order );
114
+					$this->process_response($response, $order);
115 115
 					break;
116 116
 				}
117 117
 			}
118
-		} catch ( Exception $e ) {
118
+		} catch (Exception $e) {
119 119
 			/* translators: error message */
120
-			$order_note = sprintf( __( 'Stripe Transaction Failed (%s)', 'woocommerce-gateway-stripe' ), $e->getMessage() );
120
+			$order_note = sprintf(__('Stripe Transaction Failed (%s)', 'woocommerce-gateway-stripe'), $e->getMessage());
121 121
 
122 122
 			// Mark order as failed if not already set,
123 123
 			// otherwise, make sure we add the order note so we can detect when someone fails to check out multiple times
124
-			if ( ! $order->has_status( 'failed' ) ) {
125
-				$order->update_status( 'failed', $order_note );
124
+			if ( ! $order->has_status('failed')) {
125
+				$order->update_status('failed', $order_note);
126 126
 			} else {
127
-				$order->add_order_note( $order_note );
127
+				$order->add_order_note($order_note);
128 128
 			}
129 129
 		}
130 130
 	}
Please login to merge, or discard this patch.
includes/class-wc-stripe-webhook-handler.php 1 patch
Spacing   +189 added lines, -189 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if ( ! defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -32,9 +32,9 @@  discard block
 block discarded – undo
32 32
 	 */
33 33
 	public function __construct() {
34 34
 		$this->retry_interval = 2;
35
-		$stripe_settings      = get_option( 'woocommerce_stripe_settings', array() );
36
-		$this->testmode       = ( ! empty( $stripe_settings['testmode'] ) && 'yes' === $stripe_settings['testmode'] ) ? true : false;
37
-		add_action( 'woocommerce_api_wc_stripe', array( $this, 'check_for_webhook' ) );
35
+		$stripe_settings      = get_option('woocommerce_stripe_settings', array());
36
+		$this->testmode       = ( ! empty($stripe_settings['testmode']) && 'yes' === $stripe_settings['testmode']) ? true : false;
37
+		add_action('woocommerce_api_wc_stripe', array($this, 'check_for_webhook'));
38 38
 	}
39 39
 
40 40
 	/**
@@ -44,24 +44,24 @@  discard block
 block discarded – undo
44 44
 	 * @version 4.0.0
45 45
 	 */
46 46
 	public function check_for_webhook() {
47
-		if ( ( 'POST' !== $_SERVER['REQUEST_METHOD'] )
48
-			|| ! isset( $_GET['wc-api'] )
49
-			|| ( 'wc_stripe' !== $_GET['wc-api'] )
47
+		if (('POST' !== $_SERVER['REQUEST_METHOD'])
48
+			|| ! isset($_GET['wc-api'])
49
+			|| ('wc_stripe' !== $_GET['wc-api'])
50 50
 		) {
51 51
 			return;
52 52
 		}
53 53
 
54
-		$request_body    = file_get_contents( 'php://input' );
55
-		$request_headers = array_change_key_case( $this->get_request_headers(), CASE_UPPER );
54
+		$request_body    = file_get_contents('php://input');
55
+		$request_headers = array_change_key_case($this->get_request_headers(), CASE_UPPER);
56 56
 
57 57
 		// Validate it to make sure it is legit.
58
-		if ( $this->is_valid_request( $request_headers, $request_body ) ) {
59
-			$this->process_webhook( $request_body );
60
-			status_header( 200 );
58
+		if ($this->is_valid_request($request_headers, $request_body)) {
59
+			$this->process_webhook($request_body);
60
+			status_header(200);
61 61
 			exit;
62 62
 		} else {
63
-			WC_Stripe_Logger::log( 'Incoming webhook failed validation: ' . print_r( $request_body, true ) );
64
-			status_header( 400 );
63
+			WC_Stripe_Logger::log('Incoming webhook failed validation: ' . print_r($request_body, true));
64
+			status_header(400);
65 65
 			exit;
66 66
 		}
67 67
 	}
@@ -76,12 +76,12 @@  discard block
 block discarded – undo
76 76
 	 * @param string $request_body The request body from Stripe.
77 77
 	 * @return bool
78 78
 	 */
79
-	public function is_valid_request( $request_headers = null, $request_body = null ) {
80
-		if ( null === $request_headers || null === $request_body ) {
79
+	public function is_valid_request($request_headers = null, $request_body = null) {
80
+		if (null === $request_headers || null === $request_body) {
81 81
 			return false;
82 82
 		}
83 83
 
84
-		if ( ! empty( $request_headers['USER-AGENT'] ) && ! preg_match( '/Stripe/', $request_headers['USER-AGENT'] ) ) {
84
+		if ( ! empty($request_headers['USER-AGENT']) && ! preg_match('/Stripe/', $request_headers['USER-AGENT'])) {
85 85
 			return false;
86 86
 		}
87 87
 
@@ -97,12 +97,12 @@  discard block
 block discarded – undo
97 97
 	 * @version 4.0.0
98 98
 	 */
99 99
 	public function get_request_headers() {
100
-		if ( ! function_exists( 'getallheaders' ) ) {
100
+		if ( ! function_exists('getallheaders')) {
101 101
 			$headers = array();
102 102
 
103
-			foreach ( $_SERVER as $name => $value ) {
104
-				if ( 'HTTP_' === substr( $name, 0, 5 ) ) {
105
-					$headers[ str_replace( ' ', '-', ucwords( strtolower( str_replace( '_', ' ', substr( $name, 5 ) ) ) ) ) ] = $value;
103
+			foreach ($_SERVER as $name => $value) {
104
+				if ('HTTP_' === substr($name, 0, 5)) {
105
+					$headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
106 106
 				}
107 107
 			}
108 108
 
@@ -121,30 +121,30 @@  discard block
 block discarded – undo
121 121
 	 * @param object $notification
122 122
 	 * @param bool $retry
123 123
 	 */
124
-	public function process_webhook_payment( $notification, $retry = true ) {
124
+	public function process_webhook_payment($notification, $retry = true) {
125 125
 		// The following 3 payment methods are synchronous so does not need to be handle via webhook.
126
-		if ( 'card' === $notification->data->object->type || 'sepa_debit' === $notification->data->object->type || 'three_d_secure' === $notification->data->object->type ) {
126
+		if ('card' === $notification->data->object->type || 'sepa_debit' === $notification->data->object->type || 'three_d_secure' === $notification->data->object->type) {
127 127
 			return;
128 128
 		}
129 129
 
130
-		$order = WC_Stripe_Helper::get_order_by_source_id( $notification->data->object->id );
130
+		$order = WC_Stripe_Helper::get_order_by_source_id($notification->data->object->id);
131 131
 
132
-		if ( ! $order ) {
133
-			WC_Stripe_Logger::log( 'Could not find order via source ID: ' . $notification->data->object->id );
132
+		if ( ! $order) {
133
+			WC_Stripe_Logger::log('Could not find order via source ID: ' . $notification->data->object->id);
134 134
 			return;
135 135
 		}
136 136
 
137
-		$order_id  = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
137
+		$order_id  = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
138 138
 		$source_id = $notification->data->object->id;
139 139
 
140
-		$is_pending_receiver = ( 'receiver' === $notification->data->object->flow );
140
+		$is_pending_receiver = ('receiver' === $notification->data->object->flow);
141 141
 
142 142
 		try {
143
-			if ( 'processing' === $order->get_status() || 'completed' === $order->get_status() ) {
143
+			if ('processing' === $order->get_status() || 'completed' === $order->get_status()) {
144 144
 				return;
145 145
 			}
146 146
 
147
-			if ( 'on-hold' === $order->get_status() && ! $is_pending_receiver ) {
147
+			if ('on-hold' === $order->get_status() && ! $is_pending_receiver) {
148 148
 				return;
149 149
 			}
150 150
 
@@ -152,94 +152,94 @@  discard block
 block discarded – undo
152 152
 			$response = null;
153 153
 
154 154
 			// This will throw exception if not valid.
155
-			$this->validate_minimum_order_amount( $order );
155
+			$this->validate_minimum_order_amount($order);
156 156
 
157
-			WC_Stripe_Logger::log( "Info: (Webhook) Begin processing payment for order $order_id for the amount of {$order->get_total()}" );
157
+			WC_Stripe_Logger::log("Info: (Webhook) Begin processing payment for order $order_id for the amount of {$order->get_total()}");
158 158
 
159 159
 			// Prep source object.
160 160
 			$source_object           = new stdClass();
161 161
 			$source_object->token_id = '';
162
-			$source_object->customer = $this->get_stripe_customer_id( $order );
162
+			$source_object->customer = $this->get_stripe_customer_id($order);
163 163
 			$source_object->source   = $source_id;
164 164
 
165 165
 			// Make the request.
166
-			$response = WC_Stripe_API::request( $this->generate_payment_request( $order, $source_object ), 'charges', 'POST', true );
166
+			$response = WC_Stripe_API::request($this->generate_payment_request($order, $source_object), 'charges', 'POST', true);
167 167
 			$headers  = $response['headers'];
168 168
 			$response = $response['body'];
169 169
 
170
-			if ( ! empty( $response->error ) ) {
170
+			if ( ! empty($response->error)) {
171 171
 				// Customer param wrong? The user may have been deleted on stripe's end. Remove customer_id. Can be retried without.
172
-				if ( $this->is_no_such_customer_error( $response->error ) ) {
173
-					if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
174
-						delete_user_meta( $order->customer_user, '_stripe_customer_id' );
175
-						delete_post_meta( $order_id, '_stripe_customer_id' );
172
+				if ($this->is_no_such_customer_error($response->error)) {
173
+					if (WC_Stripe_Helper::is_wc_lt('3.0')) {
174
+						delete_user_meta($order->customer_user, '_stripe_customer_id');
175
+						delete_post_meta($order_id, '_stripe_customer_id');
176 176
 					} else {
177
-						delete_user_meta( $order->get_customer_id(), '_stripe_customer_id' );
178
-						$order->delete_meta_data( '_stripe_customer_id' );
177
+						delete_user_meta($order->get_customer_id(), '_stripe_customer_id');
178
+						$order->delete_meta_data('_stripe_customer_id');
179 179
 						$order->save();
180 180
 					}
181 181
 				}
182 182
 
183
-				if ( $this->is_no_such_token_error( $response->error ) && $prepared_source->token_id ) {
183
+				if ($this->is_no_such_token_error($response->error) && $prepared_source->token_id) {
184 184
 					// Source param wrong? The CARD may have been deleted on stripe's end. Remove token and show message.
185
-					$wc_token = WC_Payment_Tokens::get( $prepared_source->token_id );
185
+					$wc_token = WC_Payment_Tokens::get($prepared_source->token_id);
186 186
 					$wc_token->delete();
187
-					$localized_message = __( 'This card is no longer available and has been removed.', 'woocommerce-gateway-stripe' );
188
-					$order->add_order_note( $localized_message );
189
-					throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message );
187
+					$localized_message = __('This card is no longer available and has been removed.', 'woocommerce-gateway-stripe');
188
+					$order->add_order_note($localized_message);
189
+					throw new WC_Stripe_Exception(print_r($response, true), $localized_message);
190 190
 				}
191 191
 
192 192
 				// We want to retry.
193
-				if ( $this->is_retryable_error( $response->error ) ) {
194
-					if ( $retry ) {
193
+				if ($this->is_retryable_error($response->error)) {
194
+					if ($retry) {
195 195
 						// Don't do anymore retries after this.
196
-						if ( 5 <= $this->retry_interval ) {
196
+						if (5 <= $this->retry_interval) {
197 197
 
198
-							return $this->process_webhook_payment( $notification, false );
198
+							return $this->process_webhook_payment($notification, false);
199 199
 						}
200 200
 
201
-						sleep( $this->retry_interval );
201
+						sleep($this->retry_interval);
202 202
 
203 203
 						$this->retry_interval++;
204
-						return $this->process_webhook_payment( $notification, true );
204
+						return $this->process_webhook_payment($notification, true);
205 205
 					} else {
206
-						$localized_message = __( 'Sorry, we are unable to process your payment at this time. Please retry later.', 'woocommerce-gateway-stripe' );
207
-						$order->add_order_note( $localized_message );
208
-						throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message );
206
+						$localized_message = __('Sorry, we are unable to process your payment at this time. Please retry later.', 'woocommerce-gateway-stripe');
207
+						$order->add_order_note($localized_message);
208
+						throw new WC_Stripe_Exception(print_r($response, true), $localized_message);
209 209
 					}
210 210
 				}
211 211
 
212 212
 				$localized_messages = WC_Stripe_Helper::get_localized_messages();
213 213
 
214
-				if ( 'card_error' === $response->error->type ) {
215
-					$localized_message = isset( $localized_messages[ $response->error->code ] ) ? $localized_messages[ $response->error->code ] : $response->error->message;
214
+				if ('card_error' === $response->error->type) {
215
+					$localized_message = isset($localized_messages[$response->error->code]) ? $localized_messages[$response->error->code] : $response->error->message;
216 216
 				} else {
217
-					$localized_message = isset( $localized_messages[ $response->error->type ] ) ? $localized_messages[ $response->error->type ] : $response->error->message;
217
+					$localized_message = isset($localized_messages[$response->error->type]) ? $localized_messages[$response->error->type] : $response->error->message;
218 218
 				}
219 219
 
220
-				$order->add_order_note( $localized_message );
220
+				$order->add_order_note($localized_message);
221 221
 
222
-				throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message );
222
+				throw new WC_Stripe_Exception(print_r($response, true), $localized_message);
223 223
 			}
224 224
 
225 225
 			// To prevent double processing the order on WC side.
226
-			if ( ! $this->is_original_request( $headers ) ) {
226
+			if ( ! $this->is_original_request($headers)) {
227 227
 				return;
228 228
 			}
229 229
 
230
-			do_action( 'wc_gateway_stripe_process_webhook_payment', $response, $order );
230
+			do_action('wc_gateway_stripe_process_webhook_payment', $response, $order);
231 231
 
232
-			$this->process_response( $response, $order );
232
+			$this->process_response($response, $order);
233 233
 
234
-		} catch ( WC_Stripe_Exception $e ) {
235
-			WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() );
234
+		} catch (WC_Stripe_Exception $e) {
235
+			WC_Stripe_Logger::log('Error: ' . $e->getMessage());
236 236
 
237
-			do_action( 'wc_gateway_stripe_process_webhook_payment_error', $order, $notification, $e );
237
+			do_action('wc_gateway_stripe_process_webhook_payment_error', $order, $notification, $e);
238 238
 
239
-			$statuses = array( 'pending', 'failed' );
239
+			$statuses = array('pending', 'failed');
240 240
 
241
-			if ( $order->has_status( $statuses ) ) {
242
-				$this->send_failed_order_email( $order_id );
241
+			if ($order->has_status($statuses)) {
242
+				$this->send_failed_order_email($order_id);
243 243
 			}
244 244
 		}
245 245
 	}
@@ -252,21 +252,21 @@  discard block
 block discarded – undo
252 252
 	 * @since 4.0.0
253 253
 	 * @param object $notification
254 254
 	 */
255
-	public function process_webhook_dispute( $notification ) {
256
-		$order = WC_Stripe_Helper::get_order_by_charge_id( $notification->data->object->charge );
255
+	public function process_webhook_dispute($notification) {
256
+		$order = WC_Stripe_Helper::get_order_by_charge_id($notification->data->object->charge);
257 257
 
258
-		if ( ! $order ) {
259
-			WC_Stripe_Logger::log( 'Could not find order via charge ID: ' . $notification->data->object->charge );
258
+		if ( ! $order) {
259
+			WC_Stripe_Logger::log('Could not find order via charge ID: ' . $notification->data->object->charge);
260 260
 			return;
261 261
 		}
262 262
 
263 263
 		/* translators: 1) The URL to the order. */
264
-		$order->update_status( 'on-hold', sprintf( __( 'A dispute was created for this order. Response is needed. Please go to your <a href="%s" title="Stripe Dashboard" target="_blank">Stripe Dashboard</a> to review this dispute.', 'woocommerce-gateway-stripe' ), $this->get_transaction_url( $order ) ) );
264
+		$order->update_status('on-hold', sprintf(__('A dispute was created for this order. Response is needed. Please go to your <a href="%s" title="Stripe Dashboard" target="_blank">Stripe Dashboard</a> to review this dispute.', 'woocommerce-gateway-stripe'), $this->get_transaction_url($order)));
265 265
 
266
-		do_action( 'wc_gateway_stripe_process_webhook_payment_error', $order, $notification );
266
+		do_action('wc_gateway_stripe_process_webhook_payment_error', $order, $notification);
267 267
 
268
-		$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
269
-		$this->send_failed_order_email( $order_id );
268
+		$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
269
+		$this->send_failed_order_email($order_id);
270 270
 	}
271 271
 
272 272
 	/**
@@ -277,44 +277,44 @@  discard block
 block discarded – undo
277 277
 	 * @version 4.0.0
278 278
 	 * @param object $notification
279 279
 	 */
280
-	public function process_webhook_capture( $notification ) {
281
-		$order = WC_Stripe_Helper::get_order_by_charge_id( $notification->data->object->id );
280
+	public function process_webhook_capture($notification) {
281
+		$order = WC_Stripe_Helper::get_order_by_charge_id($notification->data->object->id);
282 282
 
283
-		if ( ! $order ) {
284
-			WC_Stripe_Logger::log( 'Could not find order via charge ID: ' . $notification->data->object->id );
283
+		if ( ! $order) {
284
+			WC_Stripe_Logger::log('Could not find order via charge ID: ' . $notification->data->object->id);
285 285
 			return;
286 286
 		}
287 287
 
288
-		$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
288
+		$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
289 289
 
290
-		if ( 'stripe' === ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->payment_method : $order->get_payment_method() ) ) {
291
-			$charge   = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? get_post_meta( $order_id, '_transaction_id', true ) : $order->get_transaction_id();
292
-			$captured = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? get_post_meta( $order_id, '_stripe_charge_captured', true ) : $order->get_meta( '_stripe_charge_captured', true );
290
+		if ('stripe' === (WC_Stripe_Helper::is_wc_lt('3.0') ? $order->payment_method : $order->get_payment_method())) {
291
+			$charge   = WC_Stripe_Helper::is_wc_lt('3.0') ? get_post_meta($order_id, '_transaction_id', true) : $order->get_transaction_id();
292
+			$captured = WC_Stripe_Helper::is_wc_lt('3.0') ? get_post_meta($order_id, '_stripe_charge_captured', true) : $order->get_meta('_stripe_charge_captured', true);
293 293
 
294
-			if ( $charge && 'no' === $captured ) {
295
-				WC_Stripe_Helper::is_wc_lt( '3.0' ) ? update_post_meta( $order_id, '_stripe_charge_captured', 'yes' ) : $order->update_meta_data( '_stripe_charge_captured', 'yes' );
294
+			if ($charge && 'no' === $captured) {
295
+				WC_Stripe_Helper::is_wc_lt('3.0') ? update_post_meta($order_id, '_stripe_charge_captured', 'yes') : $order->update_meta_data('_stripe_charge_captured', 'yes');
296 296
 
297 297
 				// Store other data such as fees
298
-				WC_Stripe_Helper::is_wc_lt( '3.0' ) ? update_post_meta( $order_id, '_transaction_id', $notification->data->object->id ) : $order->set_transaction_id( $notification->data->object->id );
298
+				WC_Stripe_Helper::is_wc_lt('3.0') ? update_post_meta($order_id, '_transaction_id', $notification->data->object->id) : $order->set_transaction_id($notification->data->object->id);
299 299
 
300
-				if ( isset( $notification->data->object->balance_transaction ) ) {
301
-					$this->update_fees( $order, $notification->data->object->balance_transaction );
300
+				if (isset($notification->data->object->balance_transaction)) {
301
+					$this->update_fees($order, $notification->data->object->balance_transaction);
302 302
 				}
303 303
 
304 304
 				// Check and see if capture is partial.
305
-				if ( $this->is_partial_capture( $notification ) ) {
306
-					$partial_amount = $this->get_partial_amount_to_charge( $notification );
307
-					$order->set_total( $partial_amount );
305
+				if ($this->is_partial_capture($notification)) {
306
+					$partial_amount = $this->get_partial_amount_to_charge($notification);
307
+					$order->set_total($partial_amount);
308 308
 					/* translators: partial captured amount */
309
-					$order->add_order_note( sprintf( __( 'This charge was partially captured via Stripe Dashboard in the amount of: %s', 'woocommerce-gateway-stripe' ), $partial_amount ) );
309
+					$order->add_order_note(sprintf(__('This charge was partially captured via Stripe Dashboard in the amount of: %s', 'woocommerce-gateway-stripe'), $partial_amount));
310 310
 				} else {
311
-					$order->payment_complete( $notification->data->object->id );
311
+					$order->payment_complete($notification->data->object->id);
312 312
 
313 313
 					/* translators: transaction id */
314
-					$order->add_order_note( sprintf( __( 'Stripe charge complete (Charge ID: %s)', 'woocommerce-gateway-stripe' ), $notification->data->object->id ) );
314
+					$order->add_order_note(sprintf(__('Stripe charge complete (Charge ID: %s)', 'woocommerce-gateway-stripe'), $notification->data->object->id));
315 315
 				}
316 316
 
317
-				if ( is_callable( array( $order, 'save' ) ) ) {
317
+				if (is_callable(array($order, 'save'))) {
318 318
 					$order->save();
319 319
 				}
320 320
 			}
@@ -329,38 +329,38 @@  discard block
 block discarded – undo
329 329
 	 * @version 4.0.0
330 330
 	 * @param object $notification
331 331
 	 */
332
-	public function process_webhook_charge_succeeded( $notification ) {
332
+	public function process_webhook_charge_succeeded($notification) {
333 333
 		// The following payment methods are synchronous so does not need to be handle via webhook.
334
-		if ( ( isset( $notification->data->object->source->type ) && 'card' === $notification->data->object->source->type ) || ( isset( $notification->data->object->source->type ) && 'three_d_secure' === $notification->data->object->source->type ) ) {
334
+		if ((isset($notification->data->object->source->type) && 'card' === $notification->data->object->source->type) || (isset($notification->data->object->source->type) && 'three_d_secure' === $notification->data->object->source->type)) {
335 335
 			return;
336 336
 		}
337 337
 
338
-		$order = WC_Stripe_Helper::get_order_by_charge_id( $notification->data->object->id );
338
+		$order = WC_Stripe_Helper::get_order_by_charge_id($notification->data->object->id);
339 339
 
340
-		if ( ! $order ) {
341
-			WC_Stripe_Logger::log( 'Could not find order via charge ID: ' . $notification->data->object->id );
340
+		if ( ! $order) {
341
+			WC_Stripe_Logger::log('Could not find order via charge ID: ' . $notification->data->object->id);
342 342
 			return;
343 343
 		}
344 344
 
345
-		$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
345
+		$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
346 346
 
347
-		if ( 'on-hold' !== $order->get_status() ) {
347
+		if ('on-hold' !== $order->get_status()) {
348 348
 			return;
349 349
 		}
350 350
 
351 351
 		// Store other data such as fees
352
-		WC_Stripe_Helper::is_wc_lt( '3.0' ) ? update_post_meta( $order_id, '_transaction_id', $notification->data->object->id ) : $order->set_transaction_id( $notification->data->object->id );
352
+		WC_Stripe_Helper::is_wc_lt('3.0') ? update_post_meta($order_id, '_transaction_id', $notification->data->object->id) : $order->set_transaction_id($notification->data->object->id);
353 353
 
354
-		if ( isset( $notification->data->object->balance_transaction ) ) {
355
-			$this->update_fees( $order, $notification->data->object->balance_transaction );
354
+		if (isset($notification->data->object->balance_transaction)) {
355
+			$this->update_fees($order, $notification->data->object->balance_transaction);
356 356
 		}
357 357
 
358
-		$order->payment_complete( $notification->data->object->id );
358
+		$order->payment_complete($notification->data->object->id);
359 359
 
360 360
 		/* translators: transaction id */
361
-		$order->add_order_note( sprintf( __( 'Stripe charge complete (Charge ID: %s)', 'woocommerce-gateway-stripe' ), $notification->data->object->id ) );
361
+		$order->add_order_note(sprintf(__('Stripe charge complete (Charge ID: %s)', 'woocommerce-gateway-stripe'), $notification->data->object->id));
362 362
 
363
-		if ( is_callable( array( $order, 'save' ) ) ) {
363
+		if (is_callable(array($order, 'save'))) {
364 364
 			$order->save();
365 365
 		}
366 366
 	}
@@ -372,24 +372,24 @@  discard block
 block discarded – undo
372 372
 	 * @since 4.1.5 Can handle any fail payments from any methods.
373 373
 	 * @param object $notification
374 374
 	 */
375
-	public function process_webhook_charge_failed( $notification ) {
376
-		$order = WC_Stripe_Helper::get_order_by_charge_id( $notification->data->object->id );
375
+	public function process_webhook_charge_failed($notification) {
376
+		$order = WC_Stripe_Helper::get_order_by_charge_id($notification->data->object->id);
377 377
 
378
-		if ( ! $order ) {
379
-			WC_Stripe_Logger::log( 'Could not find order via charge ID: ' . $notification->data->object->id );
378
+		if ( ! $order) {
379
+			WC_Stripe_Logger::log('Could not find order via charge ID: ' . $notification->data->object->id);
380 380
 			return;
381 381
 		}
382 382
 
383
-		$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
383
+		$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
384 384
 
385 385
 		// If order status is already in failed status don't continue.
386
-		if ( 'failed' === $order->get_status() ) {
386
+		if ('failed' === $order->get_status()) {
387 387
 			return;
388 388
 		}
389 389
 
390
-		$order->update_status( 'failed', __( 'This payment failed to clear.', 'woocommerce-gateway-stripe' ) );
390
+		$order->update_status('failed', __('This payment failed to clear.', 'woocommerce-gateway-stripe'));
391 391
 
392
-		do_action( 'wc_gateway_stripe_process_webhook_payment_error', $order, $notification );
392
+		do_action('wc_gateway_stripe_process_webhook_payment_error', $order, $notification);
393 393
 	}
394 394
 
395 395
 	/**
@@ -400,24 +400,24 @@  discard block
 block discarded – undo
400 400
 	 * @version 4.0.0
401 401
 	 * @param object $notification
402 402
 	 */
403
-	public function process_webhook_source_canceled( $notification ) {
404
-		$order = WC_Stripe_Helper::get_order_by_charge_id( $notification->data->object->id );
403
+	public function process_webhook_source_canceled($notification) {
404
+		$order = WC_Stripe_Helper::get_order_by_charge_id($notification->data->object->id);
405 405
 
406 406
 		// If can't find order by charge ID, try source ID.
407
-		if ( ! $order ) {
408
-			$order = WC_Stripe_Helper::get_order_by_source_id( $notification->data->object->id );
407
+		if ( ! $order) {
408
+			$order = WC_Stripe_Helper::get_order_by_source_id($notification->data->object->id);
409 409
 
410
-			if ( ! $order ) {
411
-				WC_Stripe_Logger::log( 'Could not find order via charge/source ID: ' . $notification->data->object->id );
410
+			if ( ! $order) {
411
+				WC_Stripe_Logger::log('Could not find order via charge/source ID: ' . $notification->data->object->id);
412 412
 				return;
413 413
 			}
414 414
 		}
415 415
 
416
-		if ( 'cancelled' !== $order->get_status() ) {
417
-			$order->update_status( 'cancelled', __( 'This payment has cancelled.', 'woocommerce-gateway-stripe' ) );
416
+		if ('cancelled' !== $order->get_status()) {
417
+			$order->update_status('cancelled', __('This payment has cancelled.', 'woocommerce-gateway-stripe'));
418 418
 		}
419 419
 
420
-		do_action( 'wc_gateway_stripe_process_webhook_payment_error', $order, $notification );
420
+		do_action('wc_gateway_stripe_process_webhook_payment_error', $order, $notification);
421 421
 	}
422 422
 
423 423
 	/**
@@ -427,59 +427,59 @@  discard block
 block discarded – undo
427 427
 	 * @version 4.0.0
428 428
 	 * @param object $notification
429 429
 	 */
430
-	public function process_webhook_refund( $notification ) {
431
-		$order = WC_Stripe_Helper::get_order_by_charge_id( $notification->data->object->id );
430
+	public function process_webhook_refund($notification) {
431
+		$order = WC_Stripe_Helper::get_order_by_charge_id($notification->data->object->id);
432 432
 
433
-		if ( ! $order ) {
434
-			WC_Stripe_Logger::log( 'Could not find order via charge ID: ' . $notification->data->object->id );
433
+		if ( ! $order) {
434
+			WC_Stripe_Logger::log('Could not find order via charge ID: ' . $notification->data->object->id);
435 435
 			return;
436 436
 		}
437 437
 
438
-		$order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id();
438
+		$order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id();
439 439
 
440
-		if ( 'stripe' === ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->payment_method : $order->get_payment_method() ) ) {
441
-			$charge    = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? get_post_meta( $order_id, '_transaction_id', true ) : $order->get_transaction_id();
442
-			$captured  = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? get_post_meta( $order_id, '_stripe_charge_captured', true ) : $order->get_meta( '_stripe_charge_captured', true );
443
-			$refund_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? get_post_meta( $order_id, '_stripe_refund_id', true ) : $order->get_meta( '_stripe_refund_id', true );
440
+		if ('stripe' === (WC_Stripe_Helper::is_wc_lt('3.0') ? $order->payment_method : $order->get_payment_method())) {
441
+			$charge    = WC_Stripe_Helper::is_wc_lt('3.0') ? get_post_meta($order_id, '_transaction_id', true) : $order->get_transaction_id();
442
+			$captured  = WC_Stripe_Helper::is_wc_lt('3.0') ? get_post_meta($order_id, '_stripe_charge_captured', true) : $order->get_meta('_stripe_charge_captured', true);
443
+			$refund_id = WC_Stripe_Helper::is_wc_lt('3.0') ? get_post_meta($order_id, '_stripe_refund_id', true) : $order->get_meta('_stripe_refund_id', true);
444 444
 
445 445
 			// If the refund ID matches, don't continue to prevent double refunding.
446
-			if ( $notification->data->object->refunds->data[0]->id === $refund_id ) {
446
+			if ($notification->data->object->refunds->data[0]->id === $refund_id) {
447 447
 				return;
448 448
 			}
449 449
 
450 450
 			// Only refund captured charge.
451
-			if ( $charge ) {
452
-				$reason = ( isset( $captured ) && 'yes' === $captured ) ? __( 'Refunded via Stripe Dashboard', 'woocommerce-gateway-stripe' ) : __( 'Pre-Authorization Released via Stripe Dashboard', 'woocommerce-gateway-stripe' );
451
+			if ($charge) {
452
+				$reason = (isset($captured) && 'yes' === $captured) ? __('Refunded via Stripe Dashboard', 'woocommerce-gateway-stripe') : __('Pre-Authorization Released via Stripe Dashboard', 'woocommerce-gateway-stripe');
453 453
 
454 454
 				// Create the refund.
455 455
 				$refund = wc_create_refund(
456 456
 					array(
457 457
 						'order_id' => $order_id,
458
-						'amount'   => $this->get_refund_amount( $notification ),
458
+						'amount'   => $this->get_refund_amount($notification),
459 459
 						'reason'   => $reason,
460 460
 					)
461 461
 				);
462 462
 
463
-				if ( is_wp_error( $refund ) ) {
464
-					WC_Stripe_Logger::log( $refund->get_error_message() );
463
+				if (is_wp_error($refund)) {
464
+					WC_Stripe_Logger::log($refund->get_error_message());
465 465
 				}
466 466
 
467
-				WC_Stripe_Helper::is_wc_lt( '3.0' ) ? update_post_meta( $order_id, '_stripe_refund_id', $notification->data->object->refunds->data[0]->id ) : $order->update_meta_data( '_stripe_refund_id', $notification->data->object->refunds->data[0]->id );
467
+				WC_Stripe_Helper::is_wc_lt('3.0') ? update_post_meta($order_id, '_stripe_refund_id', $notification->data->object->refunds->data[0]->id) : $order->update_meta_data('_stripe_refund_id', $notification->data->object->refunds->data[0]->id);
468 468
 
469
-				$amount = wc_price( $notification->data->object->refunds->data[0]->amount / 100 );
469
+				$amount = wc_price($notification->data->object->refunds->data[0]->amount / 100);
470 470
 
471
-				if ( in_array( strtolower( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->get_order_currency() : $order->get_currency() ), WC_Stripe_Helper::no_decimal_currencies() ) ) {
472
-					$amount = wc_price( $notification->data->object->refunds->data[0]->amount );
471
+				if (in_array(strtolower(WC_Stripe_Helper::is_wc_lt('3.0') ? $order->get_order_currency() : $order->get_currency()), WC_Stripe_Helper::no_decimal_currencies())) {
472
+					$amount = wc_price($notification->data->object->refunds->data[0]->amount);
473 473
 				}
474 474
 
475
-				if ( isset( $notification->data->object->refunds->data[0]->balance_transaction ) ) {
476
-					$this->update_fees( $order, $notification->data->object->refunds->data[0]->balance_transaction );
475
+				if (isset($notification->data->object->refunds->data[0]->balance_transaction)) {
476
+					$this->update_fees($order, $notification->data->object->refunds->data[0]->balance_transaction);
477 477
 				}
478 478
 
479 479
 				/* translators: 1) dollar amount 2) transaction id 3) refund message */
480
-				$refund_message = ( isset( $captured ) && 'yes' === $captured ) ? sprintf( __( 'Refunded %1$s - Refund ID: %2$s - %3$s', 'woocommerce-gateway-stripe' ), $amount, $notification->data->object->refunds->data[0]->id, $reason ) : __( 'Pre-Authorization Released via Stripe Dashboard', 'woocommerce-gateway-stripe' );
480
+				$refund_message = (isset($captured) && 'yes' === $captured) ? sprintf(__('Refunded %1$s - Refund ID: %2$s - %3$s', 'woocommerce-gateway-stripe'), $amount, $notification->data->object->refunds->data[0]->id, $reason) : __('Pre-Authorization Released via Stripe Dashboard', 'woocommerce-gateway-stripe');
481 481
 
482
-				$order->add_order_note( $refund_message );
482
+				$order->add_order_note($refund_message);
483 483
 			}
484 484
 		}
485 485
 	}
@@ -490,21 +490,21 @@  discard block
 block discarded – undo
490 490
 	 * @since 4.0.6
491 491
 	 * @param object $notification
492 492
 	 */
493
-	public function process_review_opened( $notification ) {
494
-		$order = WC_Stripe_Helper::get_order_by_charge_id( $notification->data->object->charge );
493
+	public function process_review_opened($notification) {
494
+		$order = WC_Stripe_Helper::get_order_by_charge_id($notification->data->object->charge);
495 495
 
496
-		if ( ! $order ) {
497
-			WC_Stripe_Logger::log( 'Could not find order via charge ID: ' . $notification->data->object->charge );
496
+		if ( ! $order) {
497
+			WC_Stripe_Logger::log('Could not find order via charge ID: ' . $notification->data->object->charge);
498 498
 			return;
499 499
 		}
500 500
 
501 501
 		/* translators: 1) The URL to the order. 2) The reason type. */
502
-		$message = sprintf( __( 'A review has been opened for this order. Action is needed. Please go to your <a href="%1$s" title="Stripe Dashboard" target="_blank">Stripe Dashboard</a> to review the issue. Reason: (%2$s)', 'woocommerce-gateway-stripe' ), $this->get_transaction_url( $order ), $notification->data->object->reason );
502
+		$message = sprintf(__('A review has been opened for this order. Action is needed. Please go to your <a href="%1$s" title="Stripe Dashboard" target="_blank">Stripe Dashboard</a> to review the issue. Reason: (%2$s)', 'woocommerce-gateway-stripe'), $this->get_transaction_url($order), $notification->data->object->reason);
503 503
 
504
-		if ( apply_filters( 'wc_stripe_webhook_review_change_order_status', true, $order, $notification ) ) {
505
-			$order->update_status( 'on-hold', $message );
504
+		if (apply_filters('wc_stripe_webhook_review_change_order_status', true, $order, $notification)) {
505
+			$order->update_status('on-hold', $message);
506 506
 		} else {
507
-			$order->add_order_note( $message );
507
+			$order->add_order_note($message);
508 508
 		}
509 509
 	}
510 510
 
@@ -514,25 +514,25 @@  discard block
 block discarded – undo
514 514
 	 * @since 4.0.6
515 515
 	 * @param object $notification
516 516
 	 */
517
-	public function process_review_closed( $notification ) {
518
-		$order = WC_Stripe_Helper::get_order_by_charge_id( $notification->data->object->charge );
517
+	public function process_review_closed($notification) {
518
+		$order = WC_Stripe_Helper::get_order_by_charge_id($notification->data->object->charge);
519 519
 
520
-		if ( ! $order ) {
521
-			WC_Stripe_Logger::log( 'Could not find order via charge ID: ' . $notification->data->object->charge );
520
+		if ( ! $order) {
521
+			WC_Stripe_Logger::log('Could not find order via charge ID: ' . $notification->data->object->charge);
522 522
 			return;
523 523
 		}
524 524
 
525 525
 		/* translators: 1) The reason type. */
526
-		$message = sprintf( __( 'The opened review for this order is now closed. Reason: (%s)', 'woocommerce-gateway-stripe' ), $notification->data->object->reason );
526
+		$message = sprintf(__('The opened review for this order is now closed. Reason: (%s)', 'woocommerce-gateway-stripe'), $notification->data->object->reason);
527 527
 
528
-		if ( 'on-hold' === $order->get_status() ) {
529
-			if ( apply_filters( 'wc_stripe_webhook_review_change_order_status', true, $order, $notification ) ) {
530
-				$order->update_status( 'processing', $message );
528
+		if ('on-hold' === $order->get_status()) {
529
+			if (apply_filters('wc_stripe_webhook_review_change_order_status', true, $order, $notification)) {
530
+				$order->update_status('processing', $message);
531 531
 			} else {
532
-				$order->add_order_note( $message );
532
+				$order->add_order_note($message);
533 533
 			}
534 534
 		} else {
535
-			$order->add_order_note( $message );
535
+			$order->add_order_note($message);
536 536
 		}
537 537
 	}
538 538
 
@@ -543,7 +543,7 @@  discard block
 block discarded – undo
543 543
 	 * @version 4.0.0
544 544
 	 * @param object $notification
545 545
 	 */
546
-	public function is_partial_capture( $notification ) {
546
+	public function is_partial_capture($notification) {
547 547
 		return 0 < $notification->data->object->amount_refunded;
548 548
 	}
549 549
 
@@ -554,11 +554,11 @@  discard block
 block discarded – undo
554 554
 	 * @version 4.0.0
555 555
 	 * @param object $notification
556 556
 	 */
557
-	public function get_refund_amount( $notification ) {
558
-		if ( $this->is_partial_capture( $notification ) ) {
557
+	public function get_refund_amount($notification) {
558
+		if ($this->is_partial_capture($notification)) {
559 559
 			$amount = $notification->data->object->refunds->data[0]->amount / 100;
560 560
 
561
-			if ( in_array( strtolower( $notification->data->object->currency ), WC_Stripe_Helper::no_decimal_currencies() ) ) {
561
+			if (in_array(strtolower($notification->data->object->currency), WC_Stripe_Helper::no_decimal_currencies())) {
562 562
 				$amount = $notification->data->object->refunds->data[0]->amount;
563 563
 			}
564 564
 
@@ -575,12 +575,12 @@  discard block
 block discarded – undo
575 575
 	 * @version 4.0.0
576 576
 	 * @param object $notification
577 577
 	 */
578
-	public function get_partial_amount_to_charge( $notification ) {
579
-		if ( $this->is_partial_capture( $notification ) ) {
580
-			$amount = ( $notification->data->object->amount - $notification->data->object->amount_refunded ) / 100;
578
+	public function get_partial_amount_to_charge($notification) {
579
+		if ($this->is_partial_capture($notification)) {
580
+			$amount = ($notification->data->object->amount - $notification->data->object->amount_refunded) / 100;
581 581
 
582
-			if ( in_array( strtolower( $notification->data->object->currency ), WC_Stripe_Helper::no_decimal_currencies() ) ) {
583
-				$amount = ( $notification->data->object->amount - $notification->data->object->amount_refunded );
582
+			if (in_array(strtolower($notification->data->object->currency), WC_Stripe_Helper::no_decimal_currencies())) {
583
+				$amount = ($notification->data->object->amount - $notification->data->object->amount_refunded);
584 584
 			}
585 585
 
586 586
 			return $amount;
@@ -596,44 +596,44 @@  discard block
 block discarded – undo
596 596
 	 * @version 4.0.0
597 597
 	 * @param string $request_body
598 598
 	 */
599
-	public function process_webhook( $request_body ) {
600
-		$notification = json_decode( $request_body );
599
+	public function process_webhook($request_body) {
600
+		$notification = json_decode($request_body);
601 601
 
602
-		switch ( $notification->type ) {
602
+		switch ($notification->type) {
603 603
 			case 'source.chargeable':
604
-				$this->process_webhook_payment( $notification );
604
+				$this->process_webhook_payment($notification);
605 605
 				break;
606 606
 
607 607
 			case 'source.canceled':
608
-				$this->process_webhook_source_canceled( $notification );
608
+				$this->process_webhook_source_canceled($notification);
609 609
 				break;
610 610
 
611 611
 			case 'charge.succeeded':
612
-				$this->process_webhook_charge_succeeded( $notification );
612
+				$this->process_webhook_charge_succeeded($notification);
613 613
 				break;
614 614
 
615 615
 			case 'charge.failed':
616
-				$this->process_webhook_charge_failed( $notification );
616
+				$this->process_webhook_charge_failed($notification);
617 617
 				break;
618 618
 
619 619
 			case 'charge.captured':
620
-				$this->process_webhook_capture( $notification );
620
+				$this->process_webhook_capture($notification);
621 621
 				break;
622 622
 
623 623
 			case 'charge.dispute.created':
624
-				$this->process_webhook_dispute( $notification );
624
+				$this->process_webhook_dispute($notification);
625 625
 				break;
626 626
 
627 627
 			case 'charge.refunded':
628
-				$this->process_webhook_refund( $notification );
628
+				$this->process_webhook_refund($notification);
629 629
 				break;
630 630
 
631 631
 			case 'review.opened':
632
-				$this->process_review_opened( $notification );
632
+				$this->process_review_opened($notification);
633 633
 				break;
634 634
 
635 635
 			case 'review.closed':
636
-				$this->process_review_closed( $notification );
636
+				$this->process_review_closed($notification);
637 637
 				break;
638 638
 
639 639
 		}
Please login to merge, or discard this patch.
includes/admin/stripe-giropay-settings.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if ( ! defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -7,40 +7,40 @@  discard block
 block discarded – undo
7 7
 	'wc_stripe_giropay_settings',
8 8
 	array(
9 9
 		'geo_target'  => array(
10
-			'description' => __( 'Relevant Payer Geography: Germany', 'woocommerce-gateway-stripe' ),
10
+			'description' => __('Relevant Payer Geography: Germany', 'woocommerce-gateway-stripe'),
11 11
 			'type'        => 'title',
12 12
 		),
13 13
 		'guide'       => array(
14
-			'description' => __( '<a href="https://stripe.com/payments/payment-methods-guide#giropay" target="_blank">Payment Method Guide</a>', 'woocommerce-gateway-stripe' ),
14
+			'description' => __('<a href="https://stripe.com/payments/payment-methods-guide#giropay" target="_blank">Payment Method Guide</a>', 'woocommerce-gateway-stripe'),
15 15
 			'type'        => 'title',
16 16
 		),
17 17
 		'activation'  => array(
18
-			'description' => __( 'Must be activated from your Stripe Dashboard Settings <a href="https://dashboard.stripe.com/account/payments/settings" target="_blank">here</a>', 'woocommerce-gateway-stripe' ),
18
+			'description' => __('Must be activated from your Stripe Dashboard Settings <a href="https://dashboard.stripe.com/account/payments/settings" target="_blank">here</a>', 'woocommerce-gateway-stripe'),
19 19
 			'type'        => 'title',
20 20
 		),
21 21
 		'enabled'     => array(
22
-			'title'       => __( 'Enable/Disable', 'woocommerce-gateway-stripe' ),
23
-			'label'       => __( 'Enable Stripe Giropay', 'woocommerce-gateway-stripe' ),
22
+			'title'       => __('Enable/Disable', 'woocommerce-gateway-stripe'),
23
+			'label'       => __('Enable Stripe Giropay', 'woocommerce-gateway-stripe'),
24 24
 			'type'        => 'checkbox',
25 25
 			'description' => '',
26 26
 			'default'     => 'no',
27 27
 		),
28 28
 		'title'       => array(
29
-			'title'       => __( 'Title', 'woocommerce-gateway-stripe' ),
29
+			'title'       => __('Title', 'woocommerce-gateway-stripe'),
30 30
 			'type'        => 'text',
31
-			'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe' ),
32
-			'default'     => __( 'Giropay', 'woocommerce-gateway-stripe' ),
31
+			'description' => __('This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe'),
32
+			'default'     => __('Giropay', 'woocommerce-gateway-stripe'),
33 33
 			'desc_tip'    => true,
34 34
 		),
35 35
 		'description' => array(
36
-			'title'       => __( 'Description', 'woocommerce-gateway-stripe' ),
36
+			'title'       => __('Description', 'woocommerce-gateway-stripe'),
37 37
 			'type'        => 'text',
38
-			'description' => __( 'This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe' ),
39
-			'default'     => __( 'You will be redirected to Giropay.', 'woocommerce-gateway-stripe' ),
38
+			'description' => __('This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe'),
39
+			'default'     => __('You will be redirected to Giropay.', 'woocommerce-gateway-stripe'),
40 40
 			'desc_tip'    => true,
41 41
 		),
42 42
 		'webhook'     => array(
43
-			'title'       => __( 'Webhook Endpoints', 'woocommerce-gateway-stripe' ),
43
+			'title'       => __('Webhook Endpoints', 'woocommerce-gateway-stripe'),
44 44
 			'type'        => 'title',
45 45
 			/* translators: webhook URL */
46 46
 			'description' => $this->display_admin_settings_webhook_description(),
Please login to merge, or discard this patch.
includes/admin/stripe-bancontact-settings.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if ( ! defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -7,40 +7,40 @@  discard block
 block discarded – undo
7 7
 	'wc_stripe_bancontact_settings',
8 8
 	array(
9 9
 		'geo_target'  => array(
10
-			'description' => __( 'Relevant Payer Geography: Belgium', 'woocommerce-gateway-stripe' ),
10
+			'description' => __('Relevant Payer Geography: Belgium', 'woocommerce-gateway-stripe'),
11 11
 			'type'        => 'title',
12 12
 		),
13 13
 		'guide'       => array(
14
-			'description' => __( '<a href="https://stripe.com/payments/payment-methods-guide#bancontact" target="_blank">Payment Method Guide</a>', 'woocommerce-gateway-stripe' ),
14
+			'description' => __('<a href="https://stripe.com/payments/payment-methods-guide#bancontact" target="_blank">Payment Method Guide</a>', 'woocommerce-gateway-stripe'),
15 15
 			'type'        => 'title',
16 16
 		),
17 17
 		'activation'  => array(
18
-			'description' => __( 'Must be activated from your Stripe Dashboard Settings <a href="https://dashboard.stripe.com/account/payments/settings" target="_blank">here</a>', 'woocommerce-gateway-stripe' ),
18
+			'description' => __('Must be activated from your Stripe Dashboard Settings <a href="https://dashboard.stripe.com/account/payments/settings" target="_blank">here</a>', 'woocommerce-gateway-stripe'),
19 19
 			'type'        => 'title',
20 20
 		),
21 21
 		'enabled'     => array(
22
-			'title'       => __( 'Enable/Disable', 'woocommerce-gateway-stripe' ),
23
-			'label'       => __( 'Enable Stripe Bancontact', 'woocommerce-gateway-stripe' ),
22
+			'title'       => __('Enable/Disable', 'woocommerce-gateway-stripe'),
23
+			'label'       => __('Enable Stripe Bancontact', 'woocommerce-gateway-stripe'),
24 24
 			'type'        => 'checkbox',
25 25
 			'description' => '',
26 26
 			'default'     => 'no',
27 27
 		),
28 28
 		'title'       => array(
29
-			'title'       => __( 'Title', 'woocommerce-gateway-stripe' ),
29
+			'title'       => __('Title', 'woocommerce-gateway-stripe'),
30 30
 			'type'        => 'text',
31
-			'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe' ),
32
-			'default'     => __( 'Bancontact', 'woocommerce-gateway-stripe' ),
31
+			'description' => __('This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe'),
32
+			'default'     => __('Bancontact', 'woocommerce-gateway-stripe'),
33 33
 			'desc_tip'    => true,
34 34
 		),
35 35
 		'description' => array(
36
-			'title'       => __( 'Description', 'woocommerce-gateway-stripe' ),
36
+			'title'       => __('Description', 'woocommerce-gateway-stripe'),
37 37
 			'type'        => 'text',
38
-			'description' => __( 'This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe' ),
39
-			'default'     => __( 'You will be redirected to Bancontact.', 'woocommerce-gateway-stripe' ),
38
+			'description' => __('This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe'),
39
+			'default'     => __('You will be redirected to Bancontact.', 'woocommerce-gateway-stripe'),
40 40
 			'desc_tip'    => true,
41 41
 		),
42 42
 		'webhook'     => array(
43
-			'title'       => __( 'Webhook Endpoints', 'woocommerce-gateway-stripe' ),
43
+			'title'       => __('Webhook Endpoints', 'woocommerce-gateway-stripe'),
44 44
 			'type'        => 'title',
45 45
 			/* translators: webhook URL */
46 46
 			'description' => $this->display_admin_settings_webhook_description(),
Please login to merge, or discard this patch.
includes/admin/stripe-multibanco-settings.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if ( ! defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -7,36 +7,36 @@  discard block
 block discarded – undo
7 7
 	'wc_stripe_multibanco_settings',
8 8
 	array(
9 9
 		'geo_target'  => array(
10
-			'description' => __( 'Relevant Payer Geography: Portugal', 'woocommerce-gateway-stripe' ),
10
+			'description' => __('Relevant Payer Geography: Portugal', 'woocommerce-gateway-stripe'),
11 11
 			'type'        => 'title',
12 12
 		),
13 13
 		'activation'  => array(
14
-			'description' => __( 'Must be activated from your Stripe Dashboard Settings <a href="https://dashboard.stripe.com/account/payments/settings" target="_blank">here</a>', 'woocommerce-gateway-stripe' ),
14
+			'description' => __('Must be activated from your Stripe Dashboard Settings <a href="https://dashboard.stripe.com/account/payments/settings" target="_blank">here</a>', 'woocommerce-gateway-stripe'),
15 15
 			'type'        => 'title',
16 16
 		),
17 17
 		'enabled'     => array(
18
-			'title'       => __( 'Enable/Disable', 'woocommerce-gateway-stripe' ),
19
-			'label'       => __( 'Enable Stripe Multibanco', 'woocommerce-gateway-stripe' ),
18
+			'title'       => __('Enable/Disable', 'woocommerce-gateway-stripe'),
19
+			'label'       => __('Enable Stripe Multibanco', 'woocommerce-gateway-stripe'),
20 20
 			'type'        => 'checkbox',
21 21
 			'description' => '',
22 22
 			'default'     => 'no',
23 23
 		),
24 24
 		'title'       => array(
25
-			'title'       => __( 'Title', 'woocommerce-gateway-stripe' ),
25
+			'title'       => __('Title', 'woocommerce-gateway-stripe'),
26 26
 			'type'        => 'text',
27
-			'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe' ),
28
-			'default'     => __( 'Multibanco', 'woocommerce-gateway-stripe' ),
27
+			'description' => __('This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe'),
28
+			'default'     => __('Multibanco', 'woocommerce-gateway-stripe'),
29 29
 			'desc_tip'    => true,
30 30
 		),
31 31
 		'description' => array(
32
-			'title'       => __( 'Description', 'woocommerce-gateway-stripe' ),
32
+			'title'       => __('Description', 'woocommerce-gateway-stripe'),
33 33
 			'type'        => 'text',
34
-			'description' => __( 'This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe' ),
35
-			'default'     => __( 'You will be redirected to Multibanco.', 'woocommerce-gateway-stripe' ),
34
+			'description' => __('This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe'),
35
+			'default'     => __('You will be redirected to Multibanco.', 'woocommerce-gateway-stripe'),
36 36
 			'desc_tip'    => true,
37 37
 		),
38 38
 		'webhook'     => array(
39
-			'title'       => __( 'Webhook Endpoints', 'woocommerce-gateway-stripe' ),
39
+			'title'       => __('Webhook Endpoints', 'woocommerce-gateway-stripe'),
40 40
 			'type'        => 'title',
41 41
 			/* translators: webhook URL */
42 42
 			'description' => $this->display_admin_settings_webhook_description(),
Please login to merge, or discard this patch.
includes/admin/stripe-ideal-settings.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if ( ! defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -7,40 +7,40 @@  discard block
 block discarded – undo
7 7
 	'wc_stripe_ideal_settings',
8 8
 	array(
9 9
 		'geo_target'  => array(
10
-			'description' => __( 'Relevant Payer Geography: The Netherlands', 'woocommerce-gateway-stripe' ),
10
+			'description' => __('Relevant Payer Geography: The Netherlands', 'woocommerce-gateway-stripe'),
11 11
 			'type'        => 'title',
12 12
 		),
13 13
 		'guide'       => array(
14
-			'description' => __( '<a href="https://stripe.com/payments/payment-methods-guide#ideal" target="_blank">Payment Method Guide</a>', 'woocommerce-gateway-stripe' ),
14
+			'description' => __('<a href="https://stripe.com/payments/payment-methods-guide#ideal" target="_blank">Payment Method Guide</a>', 'woocommerce-gateway-stripe'),
15 15
 			'type'        => 'title',
16 16
 		),
17 17
 		'activation'  => array(
18
-			'description' => __( 'Must be activated from your Stripe Dashboard Settings <a href="https://dashboard.stripe.com/account/payments/settings" target="_blank">here</a>', 'woocommerce-gateway-stripe' ),
18
+			'description' => __('Must be activated from your Stripe Dashboard Settings <a href="https://dashboard.stripe.com/account/payments/settings" target="_blank">here</a>', 'woocommerce-gateway-stripe'),
19 19
 			'type'        => 'title',
20 20
 		),
21 21
 		'enabled'     => array(
22
-			'title'       => __( 'Enable/Disable', 'woocommerce-gateway-stripe' ),
23
-			'label'       => __( 'Enable Stripe iDeal', 'woocommerce-gateway-stripe' ),
22
+			'title'       => __('Enable/Disable', 'woocommerce-gateway-stripe'),
23
+			'label'       => __('Enable Stripe iDeal', 'woocommerce-gateway-stripe'),
24 24
 			'type'        => 'checkbox',
25 25
 			'description' => '',
26 26
 			'default'     => 'no',
27 27
 		),
28 28
 		'title'       => array(
29
-			'title'       => __( 'Title', 'woocommerce-gateway-stripe' ),
29
+			'title'       => __('Title', 'woocommerce-gateway-stripe'),
30 30
 			'type'        => 'text',
31
-			'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe' ),
32
-			'default'     => __( 'iDeal', 'woocommerce-gateway-stripe' ),
31
+			'description' => __('This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe'),
32
+			'default'     => __('iDeal', 'woocommerce-gateway-stripe'),
33 33
 			'desc_tip'    => true,
34 34
 		),
35 35
 		'description' => array(
36
-			'title'       => __( 'Description', 'woocommerce-gateway-stripe' ),
36
+			'title'       => __('Description', 'woocommerce-gateway-stripe'),
37 37
 			'type'        => 'text',
38
-			'description' => __( 'This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe' ),
39
-			'default'     => __( 'You will be redirected to iDeal.', 'woocommerce-gateway-stripe' ),
38
+			'description' => __('This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe'),
39
+			'default'     => __('You will be redirected to iDeal.', 'woocommerce-gateway-stripe'),
40 40
 			'desc_tip'    => true,
41 41
 		),
42 42
 		'webhook'     => array(
43
-			'title'       => __( 'Webhook Endpoints', 'woocommerce-gateway-stripe' ),
43
+			'title'       => __('Webhook Endpoints', 'woocommerce-gateway-stripe'),
44 44
 			'type'        => 'title',
45 45
 			/* translators: webhook URL */
46 46
 			'description' => $this->display_admin_settings_webhook_description(),
Please login to merge, or discard this patch.