@@ -1,149 +1,149 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 2 | +if ( ! defined('ABSPATH')) { |
|
| 3 | 3 | exit; |
| 4 | 4 | } |
| 5 | 5 | |
| 6 | -return apply_filters( 'wc_stripe_settings', |
|
| 6 | +return apply_filters('wc_stripe_settings', |
|
| 7 | 7 | array( |
| 8 | 8 | 'enabled' => array( |
| 9 | - 'title' => __( 'Enable/Disable', 'woocommerce-gateway-stripe' ), |
|
| 10 | - 'label' => __( 'Enable Stripe', 'woocommerce-gateway-stripe' ), |
|
| 9 | + 'title' => __('Enable/Disable', 'woocommerce-gateway-stripe'), |
|
| 10 | + 'label' => __('Enable Stripe', 'woocommerce-gateway-stripe'), |
|
| 11 | 11 | 'type' => 'checkbox', |
| 12 | 12 | 'description' => '', |
| 13 | 13 | 'default' => 'no', |
| 14 | 14 | ), |
| 15 | 15 | 'title' => array( |
| 16 | - 'title' => __( 'Title', 'woocommerce-gateway-stripe' ), |
|
| 16 | + 'title' => __('Title', 'woocommerce-gateway-stripe'), |
|
| 17 | 17 | 'type' => 'text', |
| 18 | - 'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe' ), |
|
| 19 | - 'default' => __( 'Credit Card (Stripe)', 'woocommerce-gateway-stripe' ), |
|
| 18 | + 'description' => __('This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe'), |
|
| 19 | + 'default' => __('Credit Card (Stripe)', 'woocommerce-gateway-stripe'), |
|
| 20 | 20 | 'desc_tip' => true, |
| 21 | 21 | ), |
| 22 | 22 | 'description' => array( |
| 23 | - 'title' => __( 'Description', 'woocommerce-gateway-stripe' ), |
|
| 23 | + 'title' => __('Description', 'woocommerce-gateway-stripe'), |
|
| 24 | 24 | 'type' => 'text', |
| 25 | - 'description' => __( 'This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe' ), |
|
| 26 | - 'default' => __( 'Pay with your credit card via Stripe.', 'woocommerce-gateway-stripe' ), |
|
| 25 | + 'description' => __('This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe'), |
|
| 26 | + 'default' => __('Pay with your credit card via Stripe.', 'woocommerce-gateway-stripe'), |
|
| 27 | 27 | 'desc_tip' => true, |
| 28 | 28 | ), |
| 29 | 29 | 'testmode' => array( |
| 30 | - 'title' => __( 'Test mode', 'woocommerce-gateway-stripe' ), |
|
| 31 | - 'label' => __( 'Enable Test Mode', 'woocommerce-gateway-stripe' ), |
|
| 30 | + 'title' => __('Test mode', 'woocommerce-gateway-stripe'), |
|
| 31 | + 'label' => __('Enable Test Mode', 'woocommerce-gateway-stripe'), |
|
| 32 | 32 | 'type' => 'checkbox', |
| 33 | - 'description' => __( 'Place the payment gateway in test mode using test API keys.', 'woocommerce-gateway-stripe' ), |
|
| 33 | + 'description' => __('Place the payment gateway in test mode using test API keys.', 'woocommerce-gateway-stripe'), |
|
| 34 | 34 | 'default' => 'yes', |
| 35 | 35 | 'desc_tip' => true, |
| 36 | 36 | ), |
| 37 | 37 | 'test_secret_key' => array( |
| 38 | - 'title' => __( 'Test Secret Key', 'woocommerce-gateway-stripe' ), |
|
| 38 | + 'title' => __('Test Secret Key', 'woocommerce-gateway-stripe'), |
|
| 39 | 39 | 'type' => 'text', |
| 40 | - 'description' => __( 'Get your API keys from your stripe account.', 'woocommerce-gateway-stripe' ), |
|
| 40 | + 'description' => __('Get your API keys from your stripe account.', 'woocommerce-gateway-stripe'), |
|
| 41 | 41 | 'default' => '', |
| 42 | 42 | 'desc_tip' => true, |
| 43 | 43 | ), |
| 44 | 44 | 'test_publishable_key' => array( |
| 45 | - 'title' => __( 'Test Publishable Key', 'woocommerce-gateway-stripe' ), |
|
| 45 | + 'title' => __('Test Publishable Key', 'woocommerce-gateway-stripe'), |
|
| 46 | 46 | 'type' => 'text', |
| 47 | - 'description' => __( 'Get your API keys from your stripe account.', 'woocommerce-gateway-stripe' ), |
|
| 47 | + 'description' => __('Get your API keys from your stripe account.', 'woocommerce-gateway-stripe'), |
|
| 48 | 48 | 'default' => '', |
| 49 | 49 | 'desc_tip' => true, |
| 50 | 50 | ), |
| 51 | 51 | 'secret_key' => array( |
| 52 | - 'title' => __( 'Live Secret Key', 'woocommerce-gateway-stripe' ), |
|
| 52 | + 'title' => __('Live Secret Key', 'woocommerce-gateway-stripe'), |
|
| 53 | 53 | 'type' => 'text', |
| 54 | - 'description' => __( 'Get your API keys from your stripe account.', 'woocommerce-gateway-stripe' ), |
|
| 54 | + 'description' => __('Get your API keys from your stripe account.', 'woocommerce-gateway-stripe'), |
|
| 55 | 55 | 'default' => '', |
| 56 | 56 | 'desc_tip' => true, |
| 57 | 57 | ), |
| 58 | 58 | 'publishable_key' => array( |
| 59 | - 'title' => __( 'Live Publishable Key', 'woocommerce-gateway-stripe' ), |
|
| 59 | + 'title' => __('Live Publishable Key', 'woocommerce-gateway-stripe'), |
|
| 60 | 60 | 'type' => 'text', |
| 61 | - 'description' => __( 'Get your API keys from your stripe account.', 'woocommerce-gateway-stripe' ), |
|
| 61 | + 'description' => __('Get your API keys from your stripe account.', 'woocommerce-gateway-stripe'), |
|
| 62 | 62 | 'default' => '', |
| 63 | 63 | 'desc_tip' => true, |
| 64 | 64 | ), |
| 65 | 65 | 'statement_descriptor' => array( |
| 66 | - 'title' => __( 'Statement Descriptor', 'woocommerce-gateway-stripe' ), |
|
| 66 | + 'title' => __('Statement Descriptor', 'woocommerce-gateway-stripe'), |
|
| 67 | 67 | 'type' => 'text', |
| 68 | - 'description' => __( 'Extra information about a charge. This will appear on your customer’s credit card statement.', 'woocommerce-gateway-stripe' ), |
|
| 68 | + 'description' => __('Extra information about a charge. This will appear on your customer’s credit card statement.', 'woocommerce-gateway-stripe'), |
|
| 69 | 69 | 'default' => '', |
| 70 | 70 | 'desc_tip' => true, |
| 71 | 71 | ), |
| 72 | 72 | 'capture' => array( |
| 73 | - 'title' => __( 'Capture', 'woocommerce-gateway-stripe' ), |
|
| 74 | - 'label' => __( 'Capture charge immediately', 'woocommerce-gateway-stripe' ), |
|
| 73 | + 'title' => __('Capture', 'woocommerce-gateway-stripe'), |
|
| 74 | + 'label' => __('Capture charge immediately', 'woocommerce-gateway-stripe'), |
|
| 75 | 75 | 'type' => 'checkbox', |
| 76 | - 'description' => __( 'Whether or not to immediately capture the charge. When unchecked, the charge issues an authorization and will need to be captured later. Uncaptured charges expire in 7 days.', 'woocommerce-gateway-stripe' ), |
|
| 76 | + 'description' => __('Whether or not to immediately capture the charge. When unchecked, the charge issues an authorization and will need to be captured later. Uncaptured charges expire in 7 days.', 'woocommerce-gateway-stripe'), |
|
| 77 | 77 | 'default' => 'yes', |
| 78 | 78 | 'desc_tip' => true, |
| 79 | 79 | ), |
| 80 | 80 | 'stripe_checkout' => array( |
| 81 | - 'title' => __( 'Stripe Checkout', 'woocommerce-gateway-stripe' ), |
|
| 82 | - 'label' => __( 'Enable Stripe Checkout', 'woocommerce-gateway-stripe' ), |
|
| 81 | + 'title' => __('Stripe Checkout', 'woocommerce-gateway-stripe'), |
|
| 82 | + 'label' => __('Enable Stripe Checkout', 'woocommerce-gateway-stripe'), |
|
| 83 | 83 | 'type' => 'checkbox', |
| 84 | - 'description' => __( 'If enabled, this option shows a "pay" button and modal credit card form on the checkout, instead of credit card fields directly on the page.', 'woocommerce-gateway-stripe' ), |
|
| 84 | + 'description' => __('If enabled, this option shows a "pay" button and modal credit card form on the checkout, instead of credit card fields directly on the page.', 'woocommerce-gateway-stripe'), |
|
| 85 | 85 | 'default' => 'no', |
| 86 | 86 | 'desc_tip' => true, |
| 87 | 87 | ), |
| 88 | 88 | 'allow_remember_me' => array( |
| 89 | - 'title' => __( 'Allow Remember Me', 'woocommerce-gateway-stripe' ), |
|
| 90 | - 'label' => __( 'Enable Remember Me', 'woocommerce-gateway-stripe' ), |
|
| 89 | + 'title' => __('Allow Remember Me', 'woocommerce-gateway-stripe'), |
|
| 90 | + 'label' => __('Enable Remember Me', 'woocommerce-gateway-stripe'), |
|
| 91 | 91 | 'type' => 'checkbox', |
| 92 | - 'description' => __( 'If enabled, this option shows a "Remember Me" checkbox which when checked by the customer will persist their details.', 'woocommerce-gateway-stripe' ), |
|
| 92 | + 'description' => __('If enabled, this option shows a "Remember Me" checkbox which when checked by the customer will persist their details.', 'woocommerce-gateway-stripe'), |
|
| 93 | 93 | 'default' => 'yes', |
| 94 | 94 | 'desc_tip' => true, |
| 95 | 95 | ), |
| 96 | 96 | 'stripe_checkout_locale' => array( |
| 97 | - 'title' => __( 'Stripe Checkout locale', 'woocommerce-gateway-stripe' ), |
|
| 97 | + 'title' => __('Stripe Checkout locale', 'woocommerce-gateway-stripe'), |
|
| 98 | 98 | 'type' => 'select', |
| 99 | 99 | 'class' => 'wc-enhanced-select', |
| 100 | - 'description' => __( 'Language to display in Stripe Checkout modal. Specify Auto to display Checkout in the user\'s preferred language, if available. English will be used by default.', 'woocommerce-gateway-stripe' ), |
|
| 100 | + 'description' => __('Language to display in Stripe Checkout modal. Specify Auto to display Checkout in the user\'s preferred language, if available. English will be used by default.', 'woocommerce-gateway-stripe'), |
|
| 101 | 101 | 'default' => 'en', |
| 102 | 102 | 'desc_tip' => true, |
| 103 | 103 | 'options' => array( |
| 104 | - 'auto' => __( 'Auto', 'woocommerce-gateway-stripe' ), |
|
| 105 | - 'zh' => __( 'Simplified Chinese', 'woocommerce-gateway-stripe' ), |
|
| 106 | - 'da' => __( 'Danish', 'woocommerce-gateway-stripe' ), |
|
| 107 | - 'nl' => __( 'Dutch', 'woocommerce-gateway-stripe' ), |
|
| 108 | - 'en' => __( 'English', 'woocommerce-gateway-stripe' ), |
|
| 109 | - 'fi' => __( 'Finnish', 'woocommerce-gateway-stripe' ), |
|
| 110 | - 'fr' => __( 'French', 'woocommerce-gateway-stripe' ), |
|
| 111 | - 'de' => __( 'German', 'woocommerce-gateway-stripe' ), |
|
| 112 | - 'it' => __( 'Italian', 'woocommerce-gateway-stripe' ), |
|
| 113 | - 'ja' => __( 'Japanese', 'woocommerce-gateway-stripe' ), |
|
| 114 | - 'no' => __( 'Norwegian', 'woocommerce-gateway-stripe' ), |
|
| 115 | - 'es' => __( 'Spanish', 'woocommerce-gateway-stripe' ), |
|
| 116 | - 'sv' => __( 'Swedish', 'woocommerce-gateway-stripe' ), |
|
| 104 | + 'auto' => __('Auto', 'woocommerce-gateway-stripe'), |
|
| 105 | + 'zh' => __('Simplified Chinese', 'woocommerce-gateway-stripe'), |
|
| 106 | + 'da' => __('Danish', 'woocommerce-gateway-stripe'), |
|
| 107 | + 'nl' => __('Dutch', 'woocommerce-gateway-stripe'), |
|
| 108 | + 'en' => __('English', 'woocommerce-gateway-stripe'), |
|
| 109 | + 'fi' => __('Finnish', 'woocommerce-gateway-stripe'), |
|
| 110 | + 'fr' => __('French', 'woocommerce-gateway-stripe'), |
|
| 111 | + 'de' => __('German', 'woocommerce-gateway-stripe'), |
|
| 112 | + 'it' => __('Italian', 'woocommerce-gateway-stripe'), |
|
| 113 | + 'ja' => __('Japanese', 'woocommerce-gateway-stripe'), |
|
| 114 | + 'no' => __('Norwegian', 'woocommerce-gateway-stripe'), |
|
| 115 | + 'es' => __('Spanish', 'woocommerce-gateway-stripe'), |
|
| 116 | + 'sv' => __('Swedish', 'woocommerce-gateway-stripe'), |
|
| 117 | 117 | ), |
| 118 | 118 | ), |
| 119 | 119 | 'stripe_bitcoin' => array( |
| 120 | - 'title' => __( 'Bitcoin Currency', 'woocommerce-gateway-stripe' ), |
|
| 121 | - 'label' => __( 'Enable Bitcoin Currency', 'woocommerce-gateway-stripe' ), |
|
| 120 | + 'title' => __('Bitcoin Currency', 'woocommerce-gateway-stripe'), |
|
| 121 | + 'label' => __('Enable Bitcoin Currency', 'woocommerce-gateway-stripe'), |
|
| 122 | 122 | 'type' => 'checkbox', |
| 123 | - 'description' => __( 'If enabled, an option to accept bitcoin will show on the checkout modal. Note: Stripe Checkout needs to be enabled and store currency must be set to USD.', 'woocommerce-gateway-stripe' ), |
|
| 123 | + 'description' => __('If enabled, an option to accept bitcoin will show on the checkout modal. Note: Stripe Checkout needs to be enabled and store currency must be set to USD.', 'woocommerce-gateway-stripe'), |
|
| 124 | 124 | 'default' => 'no', |
| 125 | 125 | 'desc_tip' => true, |
| 126 | 126 | ), |
| 127 | 127 | 'stripe_checkout_image' => array( |
| 128 | - 'title' => __( 'Stripe Checkout Image', 'woocommerce-gateway-stripe' ), |
|
| 129 | - 'description' => __( 'Optionally enter the URL to a 128x128px image of your brand or product. e.g. <code>https://yoursite.com/wp-content/uploads/2013/09/yourimage.jpg</code>', 'woocommerce-gateway-stripe' ), |
|
| 128 | + 'title' => __('Stripe Checkout Image', 'woocommerce-gateway-stripe'), |
|
| 129 | + 'description' => __('Optionally enter the URL to a 128x128px image of your brand or product. e.g. <code>https://yoursite.com/wp-content/uploads/2013/09/yourimage.jpg</code>', 'woocommerce-gateway-stripe'), |
|
| 130 | 130 | 'type' => 'text', |
| 131 | 131 | 'default' => '', |
| 132 | 132 | 'desc_tip' => true, |
| 133 | 133 | ), |
| 134 | 134 | 'request_payment_api' => array( |
| 135 | - 'title' => __( 'Payment Request API', 'woocommerce-gateway-stripe' ), |
|
| 136 | - 'label' => __( 'Enable Payment Request API', 'woocommerce-gateway-stripe' ), |
|
| 135 | + 'title' => __('Payment Request API', 'woocommerce-gateway-stripe'), |
|
| 136 | + 'label' => __('Enable Payment Request API', 'woocommerce-gateway-stripe'), |
|
| 137 | 137 | 'type' => 'checkbox', |
| 138 | - 'description' => __( 'If enabled, users will be able to pay using the Payment Request API if supported by the browser.', 'woocommerce-gateway-stripe' ), |
|
| 138 | + 'description' => __('If enabled, users will be able to pay using the Payment Request API if supported by the browser.', 'woocommerce-gateway-stripe'), |
|
| 139 | 139 | 'default' => 'no', |
| 140 | 140 | 'desc_tip' => true, |
| 141 | 141 | ), |
| 142 | 142 | 'apple_pay' => array( |
| 143 | - 'title' => __( 'Apple Pay', 'woocommerce-gateway-stripe' ), |
|
| 144 | - 'label' => __( 'Enable Apple Pay.', 'woocommerce-gateway-stripe' ), |
|
| 143 | + 'title' => __('Apple Pay', 'woocommerce-gateway-stripe'), |
|
| 144 | + 'label' => __('Enable Apple Pay.', 'woocommerce-gateway-stripe'), |
|
| 145 | 145 | 'type' => 'checkbox', |
| 146 | - 'description' => sprintf( __( '%1$sBy using Apple Pay, you agree to %2$s and %3$s\'s terms of service.', 'woocommerce-gateway-stripe' ), '<br />', '<a href="https://stripe.com/apple-pay/legal" target="_blank">Stripe</a>', '<a href="https://developer.apple.com/apple-pay/acceptable-use-guidelines-for-websites/" target="_blank">Apple</a>' ), |
|
| 146 | + 'description' => sprintf(__('%1$sBy using Apple Pay, you agree to %2$s and %3$s\'s terms of service.', 'woocommerce-gateway-stripe'), '<br />', '<a href="https://stripe.com/apple-pay/legal" target="_blank">Stripe</a>', '<a href="https://developer.apple.com/apple-pay/acceptable-use-guidelines-for-websites/" target="_blank">Apple</a>'), |
|
| 147 | 147 | 'default' => 'no', |
| 148 | 148 | 'desc_tip' => false, |
| 149 | 149 | ), |
@@ -151,37 +151,37 @@ discard block |
||
| 151 | 151 | 'type' => 'apple_pay_domain', |
| 152 | 152 | ), |
| 153 | 153 | 'apple_pay_button' => array( |
| 154 | - 'title' => __( 'Apple Pay Button Style', 'woocommerce-gateway-stripe' ), |
|
| 155 | - 'label' => __( 'Button Style', 'woocommerce-gateway-stripe' ), |
|
| 154 | + 'title' => __('Apple Pay Button Style', 'woocommerce-gateway-stripe'), |
|
| 155 | + 'label' => __('Button Style', 'woocommerce-gateway-stripe'), |
|
| 156 | 156 | 'type' => 'select', |
| 157 | - 'description' => __( 'Select the button style you would like to show.', 'woocommerce-gateway-stripe' ), |
|
| 157 | + 'description' => __('Select the button style you would like to show.', 'woocommerce-gateway-stripe'), |
|
| 158 | 158 | 'default' => 'black', |
| 159 | 159 | 'desc_tip' => true, |
| 160 | 160 | 'options' => array( |
| 161 | - 'black' => __( 'Black', 'woocommerce-gateway-stripe' ), |
|
| 162 | - 'white' => __( 'White', 'woocommerce-gateway-stripe' ), |
|
| 161 | + 'black' => __('Black', 'woocommerce-gateway-stripe'), |
|
| 162 | + 'white' => __('White', 'woocommerce-gateway-stripe'), |
|
| 163 | 163 | ), |
| 164 | 164 | ), |
| 165 | 165 | 'apple_pay_button_lang' => array( |
| 166 | - 'title' => __( 'Apple Pay Button Language', 'woocommerce-gateway-stripe' ), |
|
| 167 | - 'description' => __( 'Enter the 2 letter ISO code for the language you would like your Apple Pay Button to display in. Reference available ISO codes here <code>http://www.w3schools.com/tags/ref_language_codes.asp</code>', 'woocommerce-gateway-stripe' ), |
|
| 166 | + 'title' => __('Apple Pay Button Language', 'woocommerce-gateway-stripe'), |
|
| 167 | + 'description' => __('Enter the 2 letter ISO code for the language you would like your Apple Pay Button to display in. Reference available ISO codes here <code>http://www.w3schools.com/tags/ref_language_codes.asp</code>', 'woocommerce-gateway-stripe'), |
|
| 168 | 168 | 'type' => 'text', |
| 169 | 169 | 'default' => 'en', |
| 170 | 170 | 'desc_tip' => false, |
| 171 | 171 | ), |
| 172 | 172 | 'saved_cards' => array( |
| 173 | - 'title' => __( 'Saved Cards', 'woocommerce-gateway-stripe' ), |
|
| 174 | - 'label' => __( 'Enable Payment via Saved Cards', 'woocommerce-gateway-stripe' ), |
|
| 173 | + 'title' => __('Saved Cards', 'woocommerce-gateway-stripe'), |
|
| 174 | + 'label' => __('Enable Payment via Saved Cards', 'woocommerce-gateway-stripe'), |
|
| 175 | 175 | 'type' => 'checkbox', |
| 176 | - 'description' => __( 'If enabled, users will be able to pay with a saved card during checkout. Card details are saved on Stripe servers, not on your store.', 'woocommerce-gateway-stripe' ), |
|
| 176 | + 'description' => __('If enabled, users will be able to pay with a saved card during checkout. Card details are saved on Stripe servers, not on your store.', 'woocommerce-gateway-stripe'), |
|
| 177 | 177 | 'default' => 'no', |
| 178 | 178 | 'desc_tip' => true, |
| 179 | 179 | ), |
| 180 | 180 | 'logging' => array( |
| 181 | - 'title' => __( 'Logging', 'woocommerce-gateway-stripe' ), |
|
| 182 | - 'label' => __( 'Log debug messages', 'woocommerce-gateway-stripe' ), |
|
| 181 | + 'title' => __('Logging', 'woocommerce-gateway-stripe'), |
|
| 182 | + 'label' => __('Log debug messages', 'woocommerce-gateway-stripe'), |
|
| 183 | 183 | 'type' => 'checkbox', |
| 184 | - 'description' => __( 'Save debug messages to the WooCommerce System Status log.', 'woocommerce-gateway-stripe' ), |
|
| 184 | + 'description' => __('Save debug messages to the WooCommerce System Status log.', 'woocommerce-gateway-stripe'), |
|
| 185 | 185 | 'default' => 'no', |
| 186 | 186 | 'desc_tip' => true, |
| 187 | 187 | ), |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 2 | +if ( ! defined('ABSPATH')) { |
|
| 3 | 3 | exit; |
| 4 | 4 | } |
| 5 | 5 | |
@@ -120,8 +120,8 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | public function __construct() { |
| 122 | 122 | $this->id = 'stripe'; |
| 123 | - $this->method_title = __( 'Stripe', 'woocommerce-gateway-stripe' ); |
|
| 124 | - $this->method_description = __( 'Stripe works by adding credit card fields on the checkout and then sending the details to Stripe for verification.', 'woocommerce-gateway-stripe' ); |
|
| 123 | + $this->method_title = __('Stripe', 'woocommerce-gateway-stripe'); |
|
| 124 | + $this->method_description = __('Stripe works by adding credit card fields on the checkout and then sending the details to Stripe for verification.', 'woocommerce-gateway-stripe'); |
|
| 125 | 125 | $this->has_fields = true; |
| 126 | 126 | $this->view_transaction_url = 'https://dashboard.stripe.com/payments/%s'; |
| 127 | 127 | $this->supports = array( |
@@ -149,41 +149,41 @@ discard block |
||
| 149 | 149 | $this->init_settings(); |
| 150 | 150 | |
| 151 | 151 | // Get setting values. |
| 152 | - $this->title = $this->get_option( 'title' ); |
|
| 153 | - $this->description = $this->get_option( 'description' ); |
|
| 154 | - $this->enabled = $this->get_option( 'enabled' ); |
|
| 155 | - $this->testmode = 'yes' === $this->get_option( 'testmode' ); |
|
| 156 | - $this->capture = 'yes' === $this->get_option( 'capture', 'yes' ); |
|
| 157 | - $this->statement_descriptor = $this->get_option( 'statement_descriptor', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
| 158 | - $this->stripe_checkout = 'yes' === $this->get_option( 'stripe_checkout' ); |
|
| 159 | - $this->stripe_checkout_locale = $this->get_option( 'stripe_checkout_locale' ); |
|
| 160 | - $this->stripe_checkout_image = $this->get_option( 'stripe_checkout_image', '' ); |
|
| 161 | - $this->saved_cards = 'yes' === $this->get_option( 'saved_cards' ); |
|
| 162 | - $this->secret_key = $this->testmode ? $this->get_option( 'test_secret_key' ) : $this->get_option( 'secret_key' ); |
|
| 163 | - $this->publishable_key = $this->testmode ? $this->get_option( 'test_publishable_key' ) : $this->get_option( 'publishable_key' ); |
|
| 164 | - $this->bitcoin = 'USD' === strtoupper( get_woocommerce_currency() ) && 'yes' === $this->get_option( 'stripe_bitcoin' ); |
|
| 165 | - $this->apple_pay = 'yes' === $this->get_option( 'apple_pay' ); |
|
| 166 | - $this->apple_pay_domain_set = 'yes' === $this->get_option( 'apple_pay_domain_set', 'no' ); |
|
| 167 | - $this->apple_pay_button = $this->get_option( 'apple_pay_button', 'black' ); |
|
| 168 | - $this->logging = 'yes' === $this->get_option( 'logging' ); |
|
| 169 | - $this->allow_remember_me = 'yes' === $this->get_option( 'allow_remember_me', 'no' ); |
|
| 170 | - |
|
| 171 | - if ( $this->stripe_checkout ) { |
|
| 172 | - $this->order_button_text = __( 'Continue to payment', 'woocommerce-gateway-stripe' ); |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - if ( $this->testmode ) { |
|
| 176 | - $this->description .= ' ' . sprintf( __( 'TEST MODE ENABLED. In test mode, you can use the card number 4242424242424242 with any CVC and a valid expiration date or check the documentation "<a href="%s">Testing Stripe</a>" for more card numbers.', 'woocommerce-gateway-stripe' ), 'https://stripe.com/docs/testing' ); |
|
| 177 | - $this->description = trim( $this->description ); |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - WC_Stripe_API::set_secret_key( $this->secret_key ); |
|
| 152 | + $this->title = $this->get_option('title'); |
|
| 153 | + $this->description = $this->get_option('description'); |
|
| 154 | + $this->enabled = $this->get_option('enabled'); |
|
| 155 | + $this->testmode = 'yes' === $this->get_option('testmode'); |
|
| 156 | + $this->capture = 'yes' === $this->get_option('capture', 'yes'); |
|
| 157 | + $this->statement_descriptor = $this->get_option('statement_descriptor', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
| 158 | + $this->stripe_checkout = 'yes' === $this->get_option('stripe_checkout'); |
|
| 159 | + $this->stripe_checkout_locale = $this->get_option('stripe_checkout_locale'); |
|
| 160 | + $this->stripe_checkout_image = $this->get_option('stripe_checkout_image', ''); |
|
| 161 | + $this->saved_cards = 'yes' === $this->get_option('saved_cards'); |
|
| 162 | + $this->secret_key = $this->testmode ? $this->get_option('test_secret_key') : $this->get_option('secret_key'); |
|
| 163 | + $this->publishable_key = $this->testmode ? $this->get_option('test_publishable_key') : $this->get_option('publishable_key'); |
|
| 164 | + $this->bitcoin = 'USD' === strtoupper(get_woocommerce_currency()) && 'yes' === $this->get_option('stripe_bitcoin'); |
|
| 165 | + $this->apple_pay = 'yes' === $this->get_option('apple_pay'); |
|
| 166 | + $this->apple_pay_domain_set = 'yes' === $this->get_option('apple_pay_domain_set', 'no'); |
|
| 167 | + $this->apple_pay_button = $this->get_option('apple_pay_button', 'black'); |
|
| 168 | + $this->logging = 'yes' === $this->get_option('logging'); |
|
| 169 | + $this->allow_remember_me = 'yes' === $this->get_option('allow_remember_me', 'no'); |
|
| 170 | + |
|
| 171 | + if ($this->stripe_checkout) { |
|
| 172 | + $this->order_button_text = __('Continue to payment', 'woocommerce-gateway-stripe'); |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + if ($this->testmode) { |
|
| 176 | + $this->description .= ' ' . sprintf(__('TEST MODE ENABLED. In test mode, you can use the card number 4242424242424242 with any CVC and a valid expiration date or check the documentation "<a href="%s">Testing Stripe</a>" for more card numbers.', 'woocommerce-gateway-stripe'), 'https://stripe.com/docs/testing'); |
|
| 177 | + $this->description = trim($this->description); |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + WC_Stripe_API::set_secret_key($this->secret_key); |
|
| 181 | 181 | |
| 182 | 182 | // Hooks. |
| 183 | - add_action( 'wp_enqueue_scripts', array( $this, 'payment_scripts' ) ); |
|
| 184 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) ); |
|
| 185 | - add_action( 'admin_notices', array( $this, 'admin_notices' ) ); |
|
| 186 | - add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) ); |
|
| 183 | + add_action('wp_enqueue_scripts', array($this, 'payment_scripts')); |
|
| 184 | + add_action('admin_enqueue_scripts', array($this, 'admin_scripts')); |
|
| 185 | + add_action('admin_notices', array($this, 'admin_notices')); |
|
| 186 | + add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options')); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | /** |
@@ -197,16 +197,16 @@ discard block |
||
| 197 | 197 | ?> |
| 198 | 198 | <tr valign="top"> |
| 199 | 199 | <th scope="row" class="titledesc"> |
| 200 | - <label for="wc-to-square"><?php esc_html_e( 'Apple Pay Domain Verification', 'woocommerce-gateway-stripe' ); ?></label> |
|
| 201 | - <?php echo wc_help_tip( __( 'Click button to verify your domain with Apple Pay. This is required.', 'woocommerce-gateway-stripe' ) ); ?> |
|
| 200 | + <label for="wc-to-square"><?php esc_html_e('Apple Pay Domain Verification', 'woocommerce-gateway-stripe'); ?></label> |
|
| 201 | + <?php echo wc_help_tip(__('Click button to verify your domain with Apple Pay. This is required.', 'woocommerce-gateway-stripe')); ?> |
|
| 202 | 202 | </th> |
| 203 | 203 | <td class="forminp"> |
| 204 | - <?php if ( ! empty( $this->secret_key ) && ! $this->apple_pay_domain_set ) { ?> |
|
| 205 | - <a href="#" id="wc-gateway-stripe-apple-pay-domain" class="button button-secondary"><?php esc_html_e( 'Verify Domain', 'woocommerce-gateway-stripe' ); ?></a> |
|
| 204 | + <?php if ( ! empty($this->secret_key) && ! $this->apple_pay_domain_set) { ?> |
|
| 205 | + <a href="#" id="wc-gateway-stripe-apple-pay-domain" class="button button-secondary"><?php esc_html_e('Verify Domain', 'woocommerce-gateway-stripe'); ?></a> |
|
| 206 | 206 | <p class="wc-stripe-apple-pay-domain-message" style="color:green;"></p> |
| 207 | 207 | <?php } else { ?> |
| 208 | - <a href="#" id="wc-gateway-stripe-apple-pay-domain" class="button button-secondary"><?php esc_html_e( 'Re-verify Domain', 'woocommerce-gateway-stripe' ); ?></a> |
|
| 209 | - <p class="wc-stripe-apple-pay-domain-message" style="color:green;"><?php esc_html_e( 'Your domain has been verified with Apple Pay!', 'woocommerce-gateway-stripe' ); ?></p> |
|
| 208 | + <a href="#" id="wc-gateway-stripe-apple-pay-domain" class="button button-secondary"><?php esc_html_e('Re-verify Domain', 'woocommerce-gateway-stripe'); ?></a> |
|
| 209 | + <p class="wc-stripe-apple-pay-domain-message" style="color:green;"><?php esc_html_e('Your domain has been verified with Apple Pay!', 'woocommerce-gateway-stripe'); ?></p> |
|
| 210 | 210 | <?php } ?> |
| 211 | 211 | <input type="hidden" name="woocommerce_stripe_apple_pay_domain_set" class="wc-gateway-stripe-apple-pay-domain-set" /> |
| 212 | 212 | </td> |
@@ -222,8 +222,8 @@ discard block |
||
| 222 | 222 | * @version 3.1.0 |
| 223 | 223 | * @param string $key |
| 224 | 224 | */ |
| 225 | - public function validate_apple_pay_domain_field( $key ) { |
|
| 226 | - $value = isset( $_POST['woocommerce_stripe_apple_pay_domain_set'] ) ? 'yes' : 'no'; |
|
| 225 | + public function validate_apple_pay_domain_field($key) { |
|
| 226 | + $value = isset($_POST['woocommerce_stripe_apple_pay_domain_set']) ? 'yes' : 'no'; |
|
| 227 | 227 | |
| 228 | 228 | return $value; |
| 229 | 229 | } |
@@ -235,24 +235,24 @@ discard block |
||
| 235 | 235 | * @return string |
| 236 | 236 | */ |
| 237 | 237 | public function get_icon() { |
| 238 | - $ext = version_compare( WC()->version, '2.6', '>=' ) ? '.svg' : '.png'; |
|
| 239 | - $style = version_compare( WC()->version, '2.6', '>=' ) ? 'style="margin-left: 0.3em"' : ''; |
|
| 238 | + $ext = version_compare(WC()->version, '2.6', '>=') ? '.svg' : '.png'; |
|
| 239 | + $style = version_compare(WC()->version, '2.6', '>=') ? 'style="margin-left: 0.3em"' : ''; |
|
| 240 | 240 | |
| 241 | - $icon = '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/visa' . $ext ) . '" alt="Visa" width="32" ' . $style . ' />'; |
|
| 242 | - $icon .= '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/mastercard' . $ext ) . '" alt="Mastercard" width="32" ' . $style . ' />'; |
|
| 243 | - $icon .= '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/amex' . $ext ) . '" alt="Amex" width="32" ' . $style . ' />'; |
|
| 241 | + $icon = '<img src="' . WC_HTTPS::force_https_url(WC()->plugin_url() . '/assets/images/icons/credit-cards/visa' . $ext) . '" alt="Visa" width="32" ' . $style . ' />'; |
|
| 242 | + $icon .= '<img src="' . WC_HTTPS::force_https_url(WC()->plugin_url() . '/assets/images/icons/credit-cards/mastercard' . $ext) . '" alt="Mastercard" width="32" ' . $style . ' />'; |
|
| 243 | + $icon .= '<img src="' . WC_HTTPS::force_https_url(WC()->plugin_url() . '/assets/images/icons/credit-cards/amex' . $ext) . '" alt="Amex" width="32" ' . $style . ' />'; |
|
| 244 | 244 | |
| 245 | - if ( 'USD' === get_woocommerce_currency() ) { |
|
| 246 | - $icon .= '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/discover' . $ext ) . '" alt="Discover" width="32" ' . $style . ' />'; |
|
| 247 | - $icon .= '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/jcb' . $ext ) . '" alt="JCB" width="32" ' . $style . ' />'; |
|
| 248 | - $icon .= '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/diners' . $ext ) . '" alt="Diners" width="32" ' . $style . ' />'; |
|
| 245 | + if ('USD' === get_woocommerce_currency()) { |
|
| 246 | + $icon .= '<img src="' . WC_HTTPS::force_https_url(WC()->plugin_url() . '/assets/images/icons/credit-cards/discover' . $ext) . '" alt="Discover" width="32" ' . $style . ' />'; |
|
| 247 | + $icon .= '<img src="' . WC_HTTPS::force_https_url(WC()->plugin_url() . '/assets/images/icons/credit-cards/jcb' . $ext) . '" alt="JCB" width="32" ' . $style . ' />'; |
|
| 248 | + $icon .= '<img src="' . WC_HTTPS::force_https_url(WC()->plugin_url() . '/assets/images/icons/credit-cards/diners' . $ext) . '" alt="Diners" width="32" ' . $style . ' />'; |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | - if ( $this->bitcoin && $this->stripe_checkout ) { |
|
| 252 | - $icon .= '<img src="' . WC_HTTPS::force_https_url( plugins_url( '/assets/images/bitcoin' . $ext, WC_STRIPE_MAIN_FILE ) ) . '" alt="Bitcoin" width="24" ' . $style . ' />'; |
|
| 251 | + if ($this->bitcoin && $this->stripe_checkout) { |
|
| 252 | + $icon .= '<img src="' . WC_HTTPS::force_https_url(plugins_url('/assets/images/bitcoin' . $ext, WC_STRIPE_MAIN_FILE)) . '" alt="Bitcoin" width="24" ' . $style . ' />'; |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | - return apply_filters( 'woocommerce_gateway_icon', $icon, $this->id ); |
|
| 255 | + return apply_filters('woocommerce_gateway_icon', $icon, $this->id); |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | /** |
@@ -263,11 +263,11 @@ discard block |
||
| 263 | 263 | * |
| 264 | 264 | * @return float|int |
| 265 | 265 | */ |
| 266 | - public function get_stripe_amount( $total, $currency = '' ) { |
|
| 267 | - if ( ! $currency ) { |
|
| 266 | + public function get_stripe_amount($total, $currency = '') { |
|
| 267 | + if ( ! $currency) { |
|
| 268 | 268 | $currency = get_woocommerce_currency(); |
| 269 | 269 | } |
| 270 | - switch ( strtoupper( $currency ) ) { |
|
| 270 | + switch (strtoupper($currency)) { |
|
| 271 | 271 | // Zero decimal currencies. |
| 272 | 272 | case 'BIF' : |
| 273 | 273 | case 'CLP' : |
@@ -284,10 +284,10 @@ discard block |
||
| 284 | 284 | case 'XAF' : |
| 285 | 285 | case 'XOF' : |
| 286 | 286 | case 'XPF' : |
| 287 | - $total = absint( $total ); |
|
| 287 | + $total = absint($total); |
|
| 288 | 288 | break; |
| 289 | 289 | default : |
| 290 | - $total = round( $total, 2 ) * 100; // In cents. |
|
| 290 | + $total = round($total, 2) * 100; // In cents. |
|
| 291 | 291 | break; |
| 292 | 292 | } |
| 293 | 293 | return $total; |
@@ -297,13 +297,13 @@ discard block |
||
| 297 | 297 | * Check if SSL is enabled and notify the user |
| 298 | 298 | */ |
| 299 | 299 | public function admin_notices() { |
| 300 | - if ( 'no' === $this->enabled ) { |
|
| 300 | + if ('no' === $this->enabled) { |
|
| 301 | 301 | return; |
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | // Show message if enabled and FORCE SSL is disabled and WordpressHTTPS plugin is not detected. |
| 305 | - if ( ( function_exists( 'wc_site_is_https' ) && ! wc_site_is_https() ) && ( 'no' === get_option( 'woocommerce_force_ssl_checkout' ) && ! class_exists( 'WordPressHTTPS' ) ) ) { |
|
| 306 | - echo '<div class="error stripe-ssl-message"><p>' . sprintf( __( 'Stripe is enabled, but the <a href="%s">force SSL option</a> is disabled; your checkout may not be secure! Please enable SSL and ensure your server has a valid SSL certificate - Stripe will only work in test mode.', 'woocommerce-gateway-stripe' ), admin_url( 'admin.php?page=wc-settings&tab=checkout' ) ) . '</p></div>'; |
|
| 305 | + if ((function_exists('wc_site_is_https') && ! wc_site_is_https()) && ('no' === get_option('woocommerce_force_ssl_checkout') && ! class_exists('WordPressHTTPS'))) { |
|
| 306 | + echo '<div class="error stripe-ssl-message"><p>' . sprintf(__('Stripe is enabled, but the <a href="%s">force SSL option</a> is disabled; your checkout may not be secure! Please enable SSL and ensure your server has a valid SSL certificate - Stripe will only work in test mode.', 'woocommerce-gateway-stripe'), admin_url('admin.php?page=wc-settings&tab=checkout')) . '</p></div>'; |
|
| 307 | 307 | } |
| 308 | 308 | } |
| 309 | 309 | |
@@ -311,11 +311,11 @@ discard block |
||
| 311 | 311 | * Check if this gateway is enabled |
| 312 | 312 | */ |
| 313 | 313 | public function is_available() { |
| 314 | - if ( 'yes' === $this->enabled ) { |
|
| 315 | - if ( ! $this->testmode && is_checkout() && ! is_ssl() ) { |
|
| 314 | + if ('yes' === $this->enabled) { |
|
| 315 | + if ( ! $this->testmode && is_checkout() && ! is_ssl()) { |
|
| 316 | 316 | return false; |
| 317 | 317 | } |
| 318 | - if ( ! $this->secret_key || ! $this->publishable_key ) { |
|
| 318 | + if ( ! $this->secret_key || ! $this->publishable_key) { |
|
| 319 | 319 | return false; |
| 320 | 320 | } |
| 321 | 321 | return true; |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | * Initialise Gateway Settings Form Fields |
| 328 | 328 | */ |
| 329 | 329 | public function init_form_fields() { |
| 330 | - $this->form_fields = include( 'settings-stripe.php' ); |
|
| 330 | + $this->form_fields = include('settings-stripe.php'); |
|
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | /** |
@@ -335,54 +335,54 @@ discard block |
||
| 335 | 335 | */ |
| 336 | 336 | public function payment_fields() { |
| 337 | 337 | $user = wp_get_current_user(); |
| 338 | - $display_tokenization = $this->supports( 'tokenization' ) && is_checkout() && $this->saved_cards; |
|
| 338 | + $display_tokenization = $this->supports('tokenization') && is_checkout() && $this->saved_cards; |
|
| 339 | 339 | $total = WC()->cart->total; |
| 340 | 340 | |
| 341 | 341 | // If paying from order, we need to get total from order not cart. |
| 342 | - if ( isset( $_GET['pay_for_order'] ) && isset( $_GET['key'] ) ) { |
|
| 343 | - $order = wc_get_order( wc_get_order_id_by_order_key( wc_clean( $_GET['key'] ) ) ); |
|
| 342 | + if (isset($_GET['pay_for_order']) && isset($_GET['key'])) { |
|
| 343 | + $order = wc_get_order(wc_get_order_id_by_order_key(wc_clean($_GET['key']))); |
|
| 344 | 344 | $total = $order->get_total(); |
| 345 | 345 | } |
| 346 | 346 | |
| 347 | - if ( $user->ID ) { |
|
| 348 | - $user_email = get_user_meta( $user->ID, 'billing_email', true ); |
|
| 347 | + if ($user->ID) { |
|
| 348 | + $user_email = get_user_meta($user->ID, 'billing_email', true); |
|
| 349 | 349 | $user_email = $user_email ? $user_email : $user->user_email; |
| 350 | 350 | } else { |
| 351 | 351 | $user_email = ''; |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | - if ( is_add_payment_method_page() ) { |
|
| 355 | - $pay_button_text = __( 'Add Card', 'woocommerce-gateway-stripe' ); |
|
| 354 | + if (is_add_payment_method_page()) { |
|
| 355 | + $pay_button_text = __('Add Card', 'woocommerce-gateway-stripe'); |
|
| 356 | 356 | } else { |
| 357 | 357 | $pay_button_text = ''; |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | echo '<div |
| 361 | 361 | id="stripe-payment-data" |
| 362 | - data-panel-label="' . esc_attr( $pay_button_text ) . '" |
|
| 362 | + data-panel-label="' . esc_attr($pay_button_text) . '" |
|
| 363 | 363 | data-description="" |
| 364 | - data-email="' . esc_attr( $user_email ) . '" |
|
| 365 | - data-amount="' . esc_attr( $this->get_stripe_amount( $total ) ) . '" |
|
| 366 | - data-name="' . esc_attr( $this->statement_descriptor ) . '" |
|
| 367 | - data-currency="' . esc_attr( strtolower( get_woocommerce_currency() ) ) . '" |
|
| 368 | - data-image="' . esc_attr( $this->stripe_checkout_image ) . '" |
|
| 369 | - data-bitcoin="' . esc_attr( $this->bitcoin ? 'true' : 'false' ) . '" |
|
| 370 | - data-locale="' . esc_attr( $this->stripe_checkout_locale ? $this->stripe_checkout_locale : 'en' ) . '" |
|
| 371 | - data-allow-remember-me="' . esc_attr( $this->allow_remember_me ? 'true' : 'false' ) . '">'; |
|
| 364 | + data-email="' . esc_attr($user_email) . '" |
|
| 365 | + data-amount="' . esc_attr($this->get_stripe_amount($total)) . '" |
|
| 366 | + data-name="' . esc_attr($this->statement_descriptor) . '" |
|
| 367 | + data-currency="' . esc_attr(strtolower(get_woocommerce_currency())) . '" |
|
| 368 | + data-image="' . esc_attr($this->stripe_checkout_image) . '" |
|
| 369 | + data-bitcoin="' . esc_attr($this->bitcoin ? 'true' : 'false') . '" |
|
| 370 | + data-locale="' . esc_attr($this->stripe_checkout_locale ? $this->stripe_checkout_locale : 'en') . '" |
|
| 371 | + data-allow-remember-me="' . esc_attr($this->allow_remember_me ? 'true' : 'false') . '">'; |
|
| 372 | 372 | |
| 373 | - if ( $this->description ) { |
|
| 374 | - echo apply_filters( 'wc_stripe_description', wpautop( wp_kses_post( $this->description ) ) ); |
|
| 373 | + if ($this->description) { |
|
| 374 | + echo apply_filters('wc_stripe_description', wpautop(wp_kses_post($this->description))); |
|
| 375 | 375 | } |
| 376 | 376 | |
| 377 | - if ( $display_tokenization ) { |
|
| 377 | + if ($display_tokenization) { |
|
| 378 | 378 | $this->tokenization_script(); |
| 379 | 379 | $this->saved_payment_methods(); |
| 380 | 380 | } |
| 381 | 381 | |
| 382 | - if ( ! $this->stripe_checkout ) { |
|
| 382 | + if ( ! $this->stripe_checkout) { |
|
| 383 | 383 | $this->form(); |
| 384 | 384 | |
| 385 | - if ( $display_tokenization ) { |
|
| 385 | + if ($display_tokenization) { |
|
| 386 | 386 | $this->save_payment_method_checkbox(); |
| 387 | 387 | } |
| 388 | 388 | } |
@@ -398,20 +398,20 @@ discard block |
||
| 398 | 398 | * @return array |
| 399 | 399 | */ |
| 400 | 400 | public function get_localized_messages() { |
| 401 | - return apply_filters( 'wc_stripe_localized_messages', array( |
|
| 402 | - 'invalid_number' => __( 'The card number is not a valid credit card number.', 'woocommerce-gateway-stripe' ), |
|
| 403 | - 'invalid_expiry_month' => __( 'The card\'s expiration month is invalid.', 'woocommerce-gateway-stripe' ), |
|
| 404 | - 'invalid_expiry_year' => __( 'The card\'s expiration year is invalid.', 'woocommerce-gateway-stripe' ), |
|
| 405 | - 'invalid_cvc' => __( 'The card\'s security code is invalid.', 'woocommerce-gateway-stripe' ), |
|
| 406 | - 'incorrect_number' => __( 'The card number is incorrect.', 'woocommerce-gateway-stripe' ), |
|
| 407 | - 'expired_card' => __( 'The card has expired.', 'woocommerce-gateway-stripe' ), |
|
| 408 | - 'incorrect_cvc' => __( 'The card\'s security code is incorrect.', 'woocommerce-gateway-stripe' ), |
|
| 409 | - 'incorrect_zip' => __( 'The card\'s zip code failed validation.', 'woocommerce-gateway-stripe' ), |
|
| 410 | - 'card_declined' => __( 'The card was declined.', 'woocommerce-gateway-stripe' ), |
|
| 411 | - 'missing' => __( 'There is no card on a customer that is being charged.', 'woocommerce-gateway-stripe' ), |
|
| 412 | - 'processing_error' => __( 'An error occurred while processing the card.', 'woocommerce-gateway-stripe' ), |
|
| 413 | - 'invalid_request_error' => __( 'Could not find payment information.', 'woocommerce-gateway-stripe' ), |
|
| 414 | - ) ); |
|
| 401 | + return apply_filters('wc_stripe_localized_messages', array( |
|
| 402 | + 'invalid_number' => __('The card number is not a valid credit card number.', 'woocommerce-gateway-stripe'), |
|
| 403 | + 'invalid_expiry_month' => __('The card\'s expiration month is invalid.', 'woocommerce-gateway-stripe'), |
|
| 404 | + 'invalid_expiry_year' => __('The card\'s expiration year is invalid.', 'woocommerce-gateway-stripe'), |
|
| 405 | + 'invalid_cvc' => __('The card\'s security code is invalid.', 'woocommerce-gateway-stripe'), |
|
| 406 | + 'incorrect_number' => __('The card number is incorrect.', 'woocommerce-gateway-stripe'), |
|
| 407 | + 'expired_card' => __('The card has expired.', 'woocommerce-gateway-stripe'), |
|
| 408 | + 'incorrect_cvc' => __('The card\'s security code is incorrect.', 'woocommerce-gateway-stripe'), |
|
| 409 | + 'incorrect_zip' => __('The card\'s zip code failed validation.', 'woocommerce-gateway-stripe'), |
|
| 410 | + 'card_declined' => __('The card was declined.', 'woocommerce-gateway-stripe'), |
|
| 411 | + 'missing' => __('There is no card on a customer that is being charged.', 'woocommerce-gateway-stripe'), |
|
| 412 | + 'processing_error' => __('An error occurred while processing the card.', 'woocommerce-gateway-stripe'), |
|
| 413 | + 'invalid_request_error' => __('Could not find payment information.', 'woocommerce-gateway-stripe'), |
|
| 414 | + )); |
|
| 415 | 415 | } |
| 416 | 416 | |
| 417 | 417 | /** |
@@ -421,29 +421,29 @@ discard block |
||
| 421 | 421 | * @version 3.1.0 |
| 422 | 422 | */ |
| 423 | 423 | public function admin_scripts() { |
| 424 | - if ( 'woocommerce_page_wc-settings' !== get_current_screen()->id ) { |
|
| 424 | + if ('woocommerce_page_wc-settings' !== get_current_screen()->id) { |
|
| 425 | 425 | return; |
| 426 | 426 | } |
| 427 | 427 | |
| 428 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 428 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
| 429 | 429 | |
| 430 | - wp_enqueue_script( 'woocommerce_stripe_admin', plugins_url( 'assets/js/stripe-admin' . $suffix . '.js', WC_STRIPE_MAIN_FILE ), array(), WC_STRIPE_VERSION, true ); |
|
| 430 | + wp_enqueue_script('woocommerce_stripe_admin', plugins_url('assets/js/stripe-admin' . $suffix . '.js', WC_STRIPE_MAIN_FILE), array(), WC_STRIPE_VERSION, true); |
|
| 431 | 431 | |
| 432 | 432 | $stripe_admin_params = array( |
| 433 | 433 | 'localized_messages' => array( |
| 434 | - 'not_valid_live_key_msg' => __( 'This is not a valid live key. Live keys start with "sk_live_" and "pk_live_".', 'woocommerce-gateway-stripe' ), |
|
| 435 | - 'not_valid_test_key_msg' => __( 'This is not a valid test key. Test keys start with "sk_test_" and "pk_test_".', 'woocommerce-gateway-stripe' ), |
|
| 436 | - 're_verify_button_text' => __( 'Re-verify Domain', 'woocommerce-gateway-stripe' ), |
|
| 437 | - 'missing_secret_key' => __( 'Missing Secret Key. Please set the secret key field above and re-try.', 'woocommerce-gateway-stripe' ), |
|
| 438 | - 'verifying_button_text' => __( 'Verifying Domain...', 'woocommerce-gateway-stripe' ), |
|
| 434 | + 'not_valid_live_key_msg' => __('This is not a valid live key. Live keys start with "sk_live_" and "pk_live_".', 'woocommerce-gateway-stripe'), |
|
| 435 | + 'not_valid_test_key_msg' => __('This is not a valid test key. Test keys start with "sk_test_" and "pk_test_".', 'woocommerce-gateway-stripe'), |
|
| 436 | + 're_verify_button_text' => __('Re-verify Domain', 'woocommerce-gateway-stripe'), |
|
| 437 | + 'missing_secret_key' => __('Missing Secret Key. Please set the secret key field above and re-try.', 'woocommerce-gateway-stripe'), |
|
| 438 | + 'verifying_button_text' => __('Verifying Domain...', 'woocommerce-gateway-stripe'), |
|
| 439 | 439 | ), |
| 440 | - 'ajaxurl' => admin_url( 'admin-ajax.php' ), |
|
| 440 | + 'ajaxurl' => admin_url('admin-ajax.php'), |
|
| 441 | 441 | 'nonce' => array( |
| 442 | - 'apple_pay_domain_nonce' => wp_create_nonce( '_wc_stripe_apple_pay_domain_nonce' ), |
|
| 442 | + 'apple_pay_domain_nonce' => wp_create_nonce('_wc_stripe_apple_pay_domain_nonce'), |
|
| 443 | 443 | ), |
| 444 | 444 | ); |
| 445 | 445 | |
| 446 | - wp_localize_script( 'woocommerce_stripe_admin', 'wc_stripe_admin_params', apply_filters( 'wc_stripe_admin_params', $stripe_admin_params ) ); |
|
| 446 | + wp_localize_script('woocommerce_stripe_admin', 'wc_stripe_admin_params', apply_filters('wc_stripe_admin_params', $stripe_admin_params)); |
|
| 447 | 447 | } |
| 448 | 448 | |
| 449 | 449 | /** |
@@ -454,30 +454,30 @@ discard block |
||
| 454 | 454 | * @access public |
| 455 | 455 | */ |
| 456 | 456 | public function payment_scripts() { |
| 457 | - if ( ! is_cart() && ! is_checkout() && ! isset( $_GET['pay_for_order'] ) ) { |
|
| 457 | + if ( ! is_cart() && ! is_checkout() && ! isset($_GET['pay_for_order'])) { |
|
| 458 | 458 | return; |
| 459 | 459 | } |
| 460 | 460 | |
| 461 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 461 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
| 462 | 462 | |
| 463 | - if ( $this->stripe_checkout ) { |
|
| 464 | - wp_enqueue_script( 'stripe_checkout', 'https://checkout.stripe.com/v2/checkout.js', '', '2.0', true ); |
|
| 465 | - wp_enqueue_script( 'woocommerce_stripe', plugins_url( 'assets/js/stripe-checkout' . $suffix . '.js', WC_STRIPE_MAIN_FILE ), array( 'stripe' ), WC_STRIPE_VERSION, true ); |
|
| 463 | + if ($this->stripe_checkout) { |
|
| 464 | + wp_enqueue_script('stripe_checkout', 'https://checkout.stripe.com/v2/checkout.js', '', '2.0', true); |
|
| 465 | + wp_enqueue_script('woocommerce_stripe', plugins_url('assets/js/stripe-checkout' . $suffix . '.js', WC_STRIPE_MAIN_FILE), array('stripe'), WC_STRIPE_VERSION, true); |
|
| 466 | 466 | } else { |
| 467 | - wp_enqueue_script( 'stripe', 'https://js.stripe.com/v2/', '', '1.0', true ); |
|
| 468 | - wp_enqueue_script( 'woocommerce_stripe', plugins_url( 'assets/js/stripe' . $suffix . '.js', WC_STRIPE_MAIN_FILE ), array( 'jquery-payment', 'stripe' ), WC_STRIPE_VERSION, true ); |
|
| 467 | + wp_enqueue_script('stripe', 'https://js.stripe.com/v2/', '', '1.0', true); |
|
| 468 | + wp_enqueue_script('woocommerce_stripe', plugins_url('assets/js/stripe' . $suffix . '.js', WC_STRIPE_MAIN_FILE), array('jquery-payment', 'stripe'), WC_STRIPE_VERSION, true); |
|
| 469 | 469 | } |
| 470 | 470 | |
| 471 | 471 | $stripe_params = array( |
| 472 | 472 | 'key' => $this->publishable_key, |
| 473 | - 'i18n_terms' => __( 'Please accept the terms and conditions first', 'woocommerce-gateway-stripe' ), |
|
| 474 | - 'i18n_required_fields' => __( 'Please fill in required checkout fields first', 'woocommerce-gateway-stripe' ), |
|
| 473 | + 'i18n_terms' => __('Please accept the terms and conditions first', 'woocommerce-gateway-stripe'), |
|
| 474 | + 'i18n_required_fields' => __('Please fill in required checkout fields first', 'woocommerce-gateway-stripe'), |
|
| 475 | 475 | ); |
| 476 | 476 | |
| 477 | 477 | // If we're on the pay page we need to pass stripe.js the address of the order. |
| 478 | - if ( isset( $_GET['pay_for_order'] ) && 'true' === $_GET['pay_for_order'] ) { |
|
| 479 | - $order_id = wc_get_order_id_by_order_key( urldecode( $_GET['key'] ) ); |
|
| 480 | - $order = wc_get_order( $order_id ); |
|
| 478 | + if (isset($_GET['pay_for_order']) && 'true' === $_GET['pay_for_order']) { |
|
| 479 | + $order_id = wc_get_order_id_by_order_key(urldecode($_GET['key'])); |
|
| 480 | + $order = wc_get_order($order_id); |
|
| 481 | 481 | |
| 482 | 482 | $stripe_params['billing_first_name'] = $order->billing_first_name; |
| 483 | 483 | $stripe_params['billing_last_name'] = $order->billing_last_name; |
@@ -489,14 +489,14 @@ discard block |
||
| 489 | 489 | $stripe_params['billing_country'] = $order->billing_country; |
| 490 | 490 | } |
| 491 | 491 | |
| 492 | - $stripe_params['no_prepaid_card_msg'] = __( 'Sorry, we\'re not accepting prepaid cards at this time.', 'woocommerce-gateway-stripe' ); |
|
| 493 | - $stripe_params['allow_prepaid_card'] = apply_filters( 'wc_stripe_allow_prepaid_card', true ) ? 'yes' : 'no'; |
|
| 494 | - $stripe_params['stripe_checkout_require_billing_address'] = apply_filters( 'wc_stripe_checkout_require_billing_address', false ) ? 'yes' : 'no'; |
|
| 492 | + $stripe_params['no_prepaid_card_msg'] = __('Sorry, we\'re not accepting prepaid cards at this time.', 'woocommerce-gateway-stripe'); |
|
| 493 | + $stripe_params['allow_prepaid_card'] = apply_filters('wc_stripe_allow_prepaid_card', true) ? 'yes' : 'no'; |
|
| 494 | + $stripe_params['stripe_checkout_require_billing_address'] = apply_filters('wc_stripe_checkout_require_billing_address', false) ? 'yes' : 'no'; |
|
| 495 | 495 | |
| 496 | 496 | // merge localized messages to be use in JS |
| 497 | - $stripe_params = array_merge( $stripe_params, $this->get_localized_messages() ); |
|
| 497 | + $stripe_params = array_merge($stripe_params, $this->get_localized_messages()); |
|
| 498 | 498 | |
| 499 | - wp_localize_script( 'woocommerce_stripe', 'wc_stripe_params', apply_filters( 'wc_stripe_params', $stripe_params ) ); |
|
| 499 | + wp_localize_script('woocommerce_stripe', 'wc_stripe_params', apply_filters('wc_stripe_params', $stripe_params)); |
|
| 500 | 500 | } |
| 501 | 501 | |
| 502 | 502 | /** |
@@ -505,31 +505,31 @@ discard block |
||
| 505 | 505 | * @param object $source |
| 506 | 506 | * @return array() |
| 507 | 507 | */ |
| 508 | - protected function generate_payment_request( $order, $source ) { |
|
| 508 | + protected function generate_payment_request($order, $source) { |
|
| 509 | 509 | $post_data = array(); |
| 510 | - $post_data['currency'] = strtolower( $order->get_order_currency() ? $order->get_order_currency() : get_woocommerce_currency() ); |
|
| 511 | - $post_data['amount'] = $this->get_stripe_amount( $order->get_total(), $post_data['currency'] ); |
|
| 512 | - $post_data['description'] = sprintf( __( '%1$s - Order %2$s', 'woocommerce-gateway-stripe' ), $this->statement_descriptor, $order->get_order_number() ); |
|
| 510 | + $post_data['currency'] = strtolower($order->get_order_currency() ? $order->get_order_currency() : get_woocommerce_currency()); |
|
| 511 | + $post_data['amount'] = $this->get_stripe_amount($order->get_total(), $post_data['currency']); |
|
| 512 | + $post_data['description'] = sprintf(__('%1$s - Order %2$s', 'woocommerce-gateway-stripe'), $this->statement_descriptor, $order->get_order_number()); |
|
| 513 | 513 | $post_data['capture'] = $this->capture ? 'true' : 'false'; |
| 514 | 514 | |
| 515 | - if ( ! empty( $order->billing_email ) && apply_filters( 'wc_stripe_send_stripe_receipt', false ) ) { |
|
| 515 | + if ( ! empty($order->billing_email) && apply_filters('wc_stripe_send_stripe_receipt', false)) { |
|
| 516 | 516 | $post_data['receipt_email'] = $order->billing_email; |
| 517 | 517 | } |
| 518 | 518 | |
| 519 | - $post_data['expand[]'] = 'balance_transaction'; |
|
| 519 | + $post_data['expand[]'] = 'balance_transaction'; |
|
| 520 | 520 | |
| 521 | 521 | $metadata = array( |
| 522 | - __( 'Customer Name', 'woocommerce-gateway-stripe' ) => sanitize_text_field( $order->billing_first_name ) . ' ' . sanitize_text_field( $order->billing_last_name ), |
|
| 523 | - __( 'Customer Email', 'woocommerce-gateway-stripe' ) => sanitize_email( $order->billing_email ), |
|
| 522 | + __('Customer Name', 'woocommerce-gateway-stripe') => sanitize_text_field($order->billing_first_name) . ' ' . sanitize_text_field($order->billing_last_name), |
|
| 523 | + __('Customer Email', 'woocommerce-gateway-stripe') => sanitize_email($order->billing_email), |
|
| 524 | 524 | ); |
| 525 | 525 | |
| 526 | - $post_data['metadata'] = apply_filters( 'wc_stripe_payment_metadata', $metadata, $order, $source ); |
|
| 526 | + $post_data['metadata'] = apply_filters('wc_stripe_payment_metadata', $metadata, $order, $source); |
|
| 527 | 527 | |
| 528 | - if ( $source->customer ) { |
|
| 528 | + if ($source->customer) { |
|
| 529 | 529 | $post_data['customer'] = $source->customer; |
| 530 | 530 | } |
| 531 | 531 | |
| 532 | - if ( $source->source ) { |
|
| 532 | + if ($source->source) { |
|
| 533 | 533 | $post_data['source'] = $source->source; |
| 534 | 534 | } |
| 535 | 535 | |
@@ -541,7 +541,7 @@ discard block |
||
| 541 | 541 | * @param WC_Order $order |
| 542 | 542 | * @param object $source |
| 543 | 543 | */ |
| 544 | - return apply_filters( 'wc_stripe_generate_payment_request', $post_data, $order, $source ); |
|
| 544 | + return apply_filters('wc_stripe_generate_payment_request', $post_data, $order, $source); |
|
| 545 | 545 | } |
| 546 | 546 | |
| 547 | 547 | /** |
@@ -553,37 +553,37 @@ discard block |
||
| 553 | 553 | * @throws Exception When card was not added or for and invalid card. |
| 554 | 554 | * @return object |
| 555 | 555 | */ |
| 556 | - protected function get_source( $user_id, $force_customer = false ) { |
|
| 557 | - $stripe_customer = new WC_Stripe_Customer( $user_id ); |
|
| 556 | + protected function get_source($user_id, $force_customer = false) { |
|
| 557 | + $stripe_customer = new WC_Stripe_Customer($user_id); |
|
| 558 | 558 | $stripe_source = false; |
| 559 | 559 | $token_id = false; |
| 560 | 560 | |
| 561 | 561 | // New CC info was entered and we have a new token to process |
| 562 | - if ( isset( $_POST['stripe_token'] ) ) { |
|
| 563 | - $stripe_token = wc_clean( $_POST['stripe_token'] ); |
|
| 564 | - $maybe_saved_card = isset( $_POST['wc-stripe-new-payment-method'] ) && ! empty( $_POST['wc-stripe-new-payment-method'] ); |
|
| 562 | + if (isset($_POST['stripe_token'])) { |
|
| 563 | + $stripe_token = wc_clean($_POST['stripe_token']); |
|
| 564 | + $maybe_saved_card = isset($_POST['wc-stripe-new-payment-method']) && ! empty($_POST['wc-stripe-new-payment-method']); |
|
| 565 | 565 | |
| 566 | 566 | // This is true if the user wants to store the card to their account. |
| 567 | - if ( ( $user_id && $this->saved_cards && $maybe_saved_card ) || $force_customer ) { |
|
| 568 | - $stripe_source = $stripe_customer->add_card( $stripe_token ); |
|
| 567 | + if (($user_id && $this->saved_cards && $maybe_saved_card) || $force_customer) { |
|
| 568 | + $stripe_source = $stripe_customer->add_card($stripe_token); |
|
| 569 | 569 | |
| 570 | - if ( is_wp_error( $stripe_source ) ) { |
|
| 571 | - throw new Exception( $stripe_source->get_error_message() ); |
|
| 570 | + if (is_wp_error($stripe_source)) { |
|
| 571 | + throw new Exception($stripe_source->get_error_message()); |
|
| 572 | 572 | } |
| 573 | 573 | } else { |
| 574 | 574 | // Not saving token, so don't define customer either. |
| 575 | 575 | $stripe_source = $stripe_token; |
| 576 | 576 | $stripe_customer = false; |
| 577 | 577 | } |
| 578 | - } elseif ( isset( $_POST['wc-stripe-payment-token'] ) && 'new' !== $_POST['wc-stripe-payment-token'] ) { |
|
| 578 | + } elseif (isset($_POST['wc-stripe-payment-token']) && 'new' !== $_POST['wc-stripe-payment-token']) { |
|
| 579 | 579 | // Use an existing token, and then process the payment |
| 580 | 580 | |
| 581 | - $token_id = wc_clean( $_POST['wc-stripe-payment-token'] ); |
|
| 582 | - $token = WC_Payment_Tokens::get( $token_id ); |
|
| 581 | + $token_id = wc_clean($_POST['wc-stripe-payment-token']); |
|
| 582 | + $token = WC_Payment_Tokens::get($token_id); |
|
| 583 | 583 | |
| 584 | - if ( ! $token || $token->get_user_id() !== get_current_user_id() ) { |
|
| 585 | - WC()->session->set( 'refresh_totals', true ); |
|
| 586 | - throw new Exception( __( 'Invalid payment method. Please input a new card number.', 'woocommerce-gateway-stripe' ) ); |
|
| 584 | + if ( ! $token || $token->get_user_id() !== get_current_user_id()) { |
|
| 585 | + WC()->session->set('refresh_totals', true); |
|
| 586 | + throw new Exception(__('Invalid payment method. Please input a new card number.', 'woocommerce-gateway-stripe')); |
|
| 587 | 587 | } |
| 588 | 588 | |
| 589 | 589 | $stripe_source = $token->get_token(); |
@@ -607,16 +607,16 @@ discard block |
||
| 607 | 607 | * @param object $order |
| 608 | 608 | * @return object |
| 609 | 609 | */ |
| 610 | - protected function get_order_source( $order = null ) { |
|
| 610 | + protected function get_order_source($order = null) { |
|
| 611 | 611 | $stripe_customer = new WC_Stripe_Customer(); |
| 612 | 612 | $stripe_source = false; |
| 613 | 613 | $token_id = false; |
| 614 | 614 | |
| 615 | - if ( $order ) { |
|
| 616 | - if ( $meta_value = get_post_meta( $order->id, '_stripe_customer_id', true ) ) { |
|
| 617 | - $stripe_customer->set_id( $meta_value ); |
|
| 615 | + if ($order) { |
|
| 616 | + if ($meta_value = get_post_meta($order->id, '_stripe_customer_id', true)) { |
|
| 617 | + $stripe_customer->set_id($meta_value); |
|
| 618 | 618 | } |
| 619 | - if ( $meta_value = get_post_meta( $order->id, '_stripe_card_id', true ) ) { |
|
| 619 | + if ($meta_value = get_post_meta($order->id, '_stripe_card_id', true)) { |
|
| 620 | 620 | $stripe_source = $meta_value; |
| 621 | 621 | } |
| 622 | 622 | } |
@@ -639,57 +639,57 @@ discard block |
||
| 639 | 639 | * |
| 640 | 640 | * @return array|void |
| 641 | 641 | */ |
| 642 | - public function process_payment( $order_id, $retry = true, $force_customer = false ) { |
|
| 642 | + public function process_payment($order_id, $retry = true, $force_customer = false) { |
|
| 643 | 643 | try { |
| 644 | - $order = wc_get_order( $order_id ); |
|
| 645 | - $source = $this->get_source( get_current_user_id(), $force_customer ); |
|
| 644 | + $order = wc_get_order($order_id); |
|
| 645 | + $source = $this->get_source(get_current_user_id(), $force_customer); |
|
| 646 | 646 | |
| 647 | - if ( empty( $source->source ) && empty( $source->customer ) ) { |
|
| 648 | - $error_msg = __( 'Please enter your card details to make a payment.', 'woocommerce-gateway-stripe' ); |
|
| 649 | - $error_msg .= ' ' . __( 'Developers: Please make sure that you are including jQuery and there are no JavaScript errors on the page.', 'woocommerce-gateway-stripe' ); |
|
| 650 | - throw new Exception( $error_msg ); |
|
| 647 | + if (empty($source->source) && empty($source->customer)) { |
|
| 648 | + $error_msg = __('Please enter your card details to make a payment.', 'woocommerce-gateway-stripe'); |
|
| 649 | + $error_msg .= ' ' . __('Developers: Please make sure that you are including jQuery and there are no JavaScript errors on the page.', 'woocommerce-gateway-stripe'); |
|
| 650 | + throw new Exception($error_msg); |
|
| 651 | 651 | } |
| 652 | 652 | |
| 653 | 653 | // Store source to order meta. |
| 654 | - $this->save_source( $order, $source ); |
|
| 654 | + $this->save_source($order, $source); |
|
| 655 | 655 | |
| 656 | 656 | // Handle payment. |
| 657 | - if ( $order->get_total() > 0 ) { |
|
| 657 | + if ($order->get_total() > 0) { |
|
| 658 | 658 | |
| 659 | - if ( $order->get_total() * 100 < WC_Stripe::get_minimum_amount() ) { |
|
| 660 | - throw new Exception( sprintf( __( 'Sorry, the minimum allowed order total is %1$s to use this payment method.', 'woocommerce-gateway-stripe' ), wc_price( WC_Stripe::get_minimum_amount() / 100 ) ) ); |
|
| 659 | + if ($order->get_total() * 100 < WC_Stripe::get_minimum_amount()) { |
|
| 660 | + throw new Exception(sprintf(__('Sorry, the minimum allowed order total is %1$s to use this payment method.', 'woocommerce-gateway-stripe'), wc_price(WC_Stripe::get_minimum_amount() / 100))); |
|
| 661 | 661 | } |
| 662 | 662 | |
| 663 | - $this->log( "Info: Begin processing payment for order $order_id for the amount of {$order->get_total()}" ); |
|
| 663 | + $this->log("Info: Begin processing payment for order $order_id for the amount of {$order->get_total()}"); |
|
| 664 | 664 | |
| 665 | 665 | // Make the request. |
| 666 | - $response = WC_Stripe_API::request( $this->generate_payment_request( $order, $source ) ); |
|
| 666 | + $response = WC_Stripe_API::request($this->generate_payment_request($order, $source)); |
|
| 667 | 667 | |
| 668 | - if ( is_wp_error( $response ) ) { |
|
| 668 | + if (is_wp_error($response)) { |
|
| 669 | 669 | // Customer param wrong? The user may have been deleted on stripe's end. Remove customer_id. Can be retried without. |
| 670 | - if ( 'customer' === $response->get_error_code() && $retry ) { |
|
| 671 | - delete_user_meta( get_current_user_id(), '_stripe_customer_id' ); |
|
| 672 | - return $this->process_payment( $order_id, false, $force_customer ); |
|
| 670 | + if ('customer' === $response->get_error_code() && $retry) { |
|
| 671 | + delete_user_meta(get_current_user_id(), '_stripe_customer_id'); |
|
| 672 | + return $this->process_payment($order_id, false, $force_customer); |
|
| 673 | 673 | // Source param wrong? The CARD may have been deleted on stripe's end. Remove token and show message. |
| 674 | - } elseif ( 'source' === $response->get_error_code() && $source->token_id ) { |
|
| 675 | - $token = WC_Payment_Tokens::get( $source->token_id ); |
|
| 674 | + } elseif ('source' === $response->get_error_code() && $source->token_id) { |
|
| 675 | + $token = WC_Payment_Tokens::get($source->token_id); |
|
| 676 | 676 | $token->delete(); |
| 677 | - $message = __( 'This card is no longer available and has been removed.', 'woocommerce-gateway-stripe' ); |
|
| 678 | - $order->add_order_note( $message ); |
|
| 679 | - throw new Exception( $message ); |
|
| 677 | + $message = __('This card is no longer available and has been removed.', 'woocommerce-gateway-stripe'); |
|
| 678 | + $order->add_order_note($message); |
|
| 679 | + throw new Exception($message); |
|
| 680 | 680 | } |
| 681 | 681 | |
| 682 | 682 | $localized_messages = $this->get_localized_messages(); |
| 683 | 683 | |
| 684 | - $message = isset( $localized_messages[ $response->get_error_code() ] ) ? $localized_messages[ $response->get_error_code() ] : $response->get_error_message(); |
|
| 684 | + $message = isset($localized_messages[$response->get_error_code()]) ? $localized_messages[$response->get_error_code()] : $response->get_error_message(); |
|
| 685 | 685 | |
| 686 | - $order->add_order_note( $message ); |
|
| 686 | + $order->add_order_note($message); |
|
| 687 | 687 | |
| 688 | - throw new Exception( $message ); |
|
| 688 | + throw new Exception($message); |
|
| 689 | 689 | } |
| 690 | 690 | |
| 691 | 691 | // Process valid response. |
| 692 | - $this->process_response( $response, $order ); |
|
| 692 | + $this->process_response($response, $order); |
|
| 693 | 693 | } else { |
| 694 | 694 | $order->payment_complete(); |
| 695 | 695 | } |
@@ -697,23 +697,23 @@ discard block |
||
| 697 | 697 | // Remove cart. |
| 698 | 698 | WC()->cart->empty_cart(); |
| 699 | 699 | |
| 700 | - do_action( 'wc_gateway_stripe_process_payment', $response, $order ); |
|
| 700 | + do_action('wc_gateway_stripe_process_payment', $response, $order); |
|
| 701 | 701 | |
| 702 | 702 | // Return thank you page redirect. |
| 703 | 703 | return array( |
| 704 | 704 | 'result' => 'success', |
| 705 | - 'redirect' => $this->get_return_url( $order ), |
|
| 705 | + 'redirect' => $this->get_return_url($order), |
|
| 706 | 706 | ); |
| 707 | 707 | |
| 708 | - } catch ( Exception $e ) { |
|
| 709 | - wc_add_notice( $e->getMessage(), 'error' ); |
|
| 710 | - $this->log( sprintf( __( 'Error: %s', 'woocommerce-gateway-stripe' ), $e->getMessage() ) ); |
|
| 708 | + } catch (Exception $e) { |
|
| 709 | + wc_add_notice($e->getMessage(), 'error'); |
|
| 710 | + $this->log(sprintf(__('Error: %s', 'woocommerce-gateway-stripe'), $e->getMessage())); |
|
| 711 | 711 | |
| 712 | - if ( $order->has_status( array( 'pending', 'failed' ) ) ) { |
|
| 713 | - $this->send_failed_order_email( $order_id ); |
|
| 712 | + if ($order->has_status(array('pending', 'failed'))) { |
|
| 713 | + $this->send_failed_order_email($order_id); |
|
| 714 | 714 | } |
| 715 | 715 | |
| 716 | - do_action( 'wc_gateway_stripe_process_payment_error', $e, $order ); |
|
| 716 | + do_action('wc_gateway_stripe_process_payment_error', $e, $order); |
|
| 717 | 717 | |
| 718 | 718 | return array( |
| 719 | 719 | 'result' => 'fail', |
@@ -728,52 +728,52 @@ discard block |
||
| 728 | 728 | * @param WC_Order $order For to which the source applies. |
| 729 | 729 | * @param stdClass $source Source information. |
| 730 | 730 | */ |
| 731 | - protected function save_source( $order, $source ) { |
|
| 731 | + protected function save_source($order, $source) { |
|
| 732 | 732 | // Store source in the order. |
| 733 | - if ( $source->customer ) { |
|
| 734 | - update_post_meta( $order->id, '_stripe_customer_id', $source->customer ); |
|
| 733 | + if ($source->customer) { |
|
| 734 | + update_post_meta($order->id, '_stripe_customer_id', $source->customer); |
|
| 735 | 735 | } |
| 736 | - if ( $source->source ) { |
|
| 737 | - update_post_meta( $order->id, '_stripe_card_id', $source->source ); |
|
| 736 | + if ($source->source) { |
|
| 737 | + update_post_meta($order->id, '_stripe_card_id', $source->source); |
|
| 738 | 738 | } |
| 739 | 739 | } |
| 740 | 740 | |
| 741 | 741 | /** |
| 742 | 742 | * Store extra meta data for an order from a Stripe Response. |
| 743 | 743 | */ |
| 744 | - public function process_response( $response, $order ) { |
|
| 745 | - $this->log( 'Processing response: ' . print_r( $response, true ) ); |
|
| 744 | + public function process_response($response, $order) { |
|
| 745 | + $this->log('Processing response: ' . print_r($response, true)); |
|
| 746 | 746 | |
| 747 | 747 | // Store charge data |
| 748 | - update_post_meta( $order->id, '_stripe_charge_id', $response->id ); |
|
| 749 | - update_post_meta( $order->id, '_stripe_charge_captured', $response->captured ? 'yes' : 'no' ); |
|
| 748 | + update_post_meta($order->id, '_stripe_charge_id', $response->id); |
|
| 749 | + update_post_meta($order->id, '_stripe_charge_captured', $response->captured ? 'yes' : 'no'); |
|
| 750 | 750 | |
| 751 | 751 | // Store other data such as fees |
| 752 | - if ( isset( $response->balance_transaction ) && isset( $response->balance_transaction->fee ) ) { |
|
| 752 | + if (isset($response->balance_transaction) && isset($response->balance_transaction->fee)) { |
|
| 753 | 753 | // Fees and Net needs to both come from Stripe to be accurate as the returned |
| 754 | 754 | // values are in the local currency of the Stripe account, not from WC. |
| 755 | - $fee = ! empty( $response->balance_transaction->fee ) ? number_format( $response->balance_transaction->fee / 100, 2, '.', '' ) : 0; |
|
| 756 | - $net = ! empty( $response->balance_transaction->net ) ? number_format( $response->balance_transaction->net / 100, 2, '.', '' ) : 0; |
|
| 757 | - update_post_meta( $order->id, 'Stripe Fee', $fee ); |
|
| 758 | - update_post_meta( $order->id, 'Net Revenue From Stripe', $net ); |
|
| 755 | + $fee = ! empty($response->balance_transaction->fee) ? number_format($response->balance_transaction->fee / 100, 2, '.', '') : 0; |
|
| 756 | + $net = ! empty($response->balance_transaction->net) ? number_format($response->balance_transaction->net / 100, 2, '.', '') : 0; |
|
| 757 | + update_post_meta($order->id, 'Stripe Fee', $fee); |
|
| 758 | + update_post_meta($order->id, 'Net Revenue From Stripe', $net); |
|
| 759 | 759 | } |
| 760 | 760 | |
| 761 | - if ( $response->captured ) { |
|
| 762 | - $order->payment_complete( $response->id ); |
|
| 761 | + if ($response->captured) { |
|
| 762 | + $order->payment_complete($response->id); |
|
| 763 | 763 | |
| 764 | - $message = sprintf( __( 'Stripe charge complete (Charge ID: %s)', 'woocommerce-gateway-stripe' ), $response->id ); |
|
| 765 | - $order->add_order_note( $message ); |
|
| 766 | - $this->log( 'Success: ' . $message ); |
|
| 764 | + $message = sprintf(__('Stripe charge complete (Charge ID: %s)', 'woocommerce-gateway-stripe'), $response->id); |
|
| 765 | + $order->add_order_note($message); |
|
| 766 | + $this->log('Success: ' . $message); |
|
| 767 | 767 | |
| 768 | 768 | } else { |
| 769 | - add_post_meta( $order->id, '_transaction_id', $response->id, true ); |
|
| 769 | + add_post_meta($order->id, '_transaction_id', $response->id, true); |
|
| 770 | 770 | |
| 771 | - if ( $order->has_status( array( 'pending', 'failed' ) ) ) { |
|
| 771 | + if ($order->has_status(array('pending', 'failed'))) { |
|
| 772 | 772 | $order->reduce_order_stock(); |
| 773 | 773 | } |
| 774 | 774 | |
| 775 | - $order->update_status( 'on-hold', sprintf( __( 'Stripe charge authorized (Charge ID: %s). Process order to take payment, or cancel to remove the pre-authorization.', 'woocommerce-gateway-stripe' ), $response->id ) ); |
|
| 776 | - $this->log( "Successful auth: $response->id" ); |
|
| 775 | + $order->update_status('on-hold', sprintf(__('Stripe charge authorized (Charge ID: %s). Process order to take payment, or cancel to remove the pre-authorization.', 'woocommerce-gateway-stripe'), $response->id)); |
|
| 776 | + $this->log("Successful auth: $response->id"); |
|
| 777 | 777 | } |
| 778 | 778 | |
| 779 | 779 | return $response; |
@@ -785,32 +785,32 @@ discard block |
||
| 785 | 785 | * @since 3.0.0 |
| 786 | 786 | */ |
| 787 | 787 | public function add_payment_method() { |
| 788 | - if ( empty( $_POST['stripe_token'] ) || ! is_user_logged_in() ) { |
|
| 789 | - wc_add_notice( __( 'There was a problem adding the card.', 'woocommerce-gateway-stripe' ), 'error' ); |
|
| 788 | + if (empty($_POST['stripe_token']) || ! is_user_logged_in()) { |
|
| 789 | + wc_add_notice(__('There was a problem adding the card.', 'woocommerce-gateway-stripe'), 'error'); |
|
| 790 | 790 | return; |
| 791 | 791 | } |
| 792 | 792 | |
| 793 | - $stripe_customer = new WC_Stripe_Customer( get_current_user_id() ); |
|
| 794 | - $card = $stripe_customer->add_card( wc_clean( $_POST['stripe_token'] ) ); |
|
| 793 | + $stripe_customer = new WC_Stripe_Customer(get_current_user_id()); |
|
| 794 | + $card = $stripe_customer->add_card(wc_clean($_POST['stripe_token'])); |
|
| 795 | 795 | |
| 796 | - if ( is_wp_error( $card ) ) { |
|
| 796 | + if (is_wp_error($card)) { |
|
| 797 | 797 | $localized_messages = $this->get_localized_messages(); |
| 798 | - $error_msg = __( 'There was a problem adding the card.', 'woocommerce-gateway-stripe' ); |
|
| 798 | + $error_msg = __('There was a problem adding the card.', 'woocommerce-gateway-stripe'); |
|
| 799 | 799 | |
| 800 | 800 | // loop through the errors to find matching localized message |
| 801 | - foreach ( $card->errors as $error => $msg ) { |
|
| 802 | - if ( isset( $localized_messages[ $error ] ) ) { |
|
| 803 | - $error_msg = $localized_messages[ $error ]; |
|
| 801 | + foreach ($card->errors as $error => $msg) { |
|
| 802 | + if (isset($localized_messages[$error])) { |
|
| 803 | + $error_msg = $localized_messages[$error]; |
|
| 804 | 804 | } |
| 805 | 805 | } |
| 806 | 806 | |
| 807 | - wc_add_notice( $error_msg, 'error' ); |
|
| 807 | + wc_add_notice($error_msg, 'error'); |
|
| 808 | 808 | return; |
| 809 | 809 | } |
| 810 | 810 | |
| 811 | 811 | return array( |
| 812 | 812 | 'result' => 'success', |
| 813 | - 'redirect' => wc_get_endpoint_url( 'payment-methods' ), |
|
| 813 | + 'redirect' => wc_get_endpoint_url('payment-methods'), |
|
| 814 | 814 | ); |
| 815 | 815 | } |
| 816 | 816 | |
@@ -820,36 +820,36 @@ discard block |
||
| 820 | 820 | * @param float $amount |
| 821 | 821 | * @return bool |
| 822 | 822 | */ |
| 823 | - public function process_refund( $order_id, $amount = null, $reason = '' ) { |
|
| 824 | - $order = wc_get_order( $order_id ); |
|
| 823 | + public function process_refund($order_id, $amount = null, $reason = '') { |
|
| 824 | + $order = wc_get_order($order_id); |
|
| 825 | 825 | |
| 826 | - if ( ! $order || ! $order->get_transaction_id() ) { |
|
| 826 | + if ( ! $order || ! $order->get_transaction_id()) { |
|
| 827 | 827 | return false; |
| 828 | 828 | } |
| 829 | 829 | |
| 830 | 830 | $body = array(); |
| 831 | 831 | |
| 832 | - if ( ! is_null( $amount ) ) { |
|
| 833 | - $body['amount'] = $this->get_stripe_amount( $amount ); |
|
| 832 | + if ( ! is_null($amount)) { |
|
| 833 | + $body['amount'] = $this->get_stripe_amount($amount); |
|
| 834 | 834 | } |
| 835 | 835 | |
| 836 | - if ( $reason ) { |
|
| 836 | + if ($reason) { |
|
| 837 | 837 | $body['metadata'] = array( |
| 838 | 838 | 'reason' => $reason, |
| 839 | 839 | ); |
| 840 | 840 | } |
| 841 | 841 | |
| 842 | - $this->log( "Info: Beginning refund for order $order_id for the amount of {$amount}" ); |
|
| 842 | + $this->log("Info: Beginning refund for order $order_id for the amount of {$amount}"); |
|
| 843 | 843 | |
| 844 | - $response = WC_Stripe_API::request( $body, 'charges/' . $order->get_transaction_id() . '/refunds' ); |
|
| 844 | + $response = WC_Stripe_API::request($body, 'charges/' . $order->get_transaction_id() . '/refunds'); |
|
| 845 | 845 | |
| 846 | - if ( is_wp_error( $response ) ) { |
|
| 847 | - $this->log( 'Error: ' . $response->get_error_message() ); |
|
| 846 | + if (is_wp_error($response)) { |
|
| 847 | + $this->log('Error: ' . $response->get_error_message()); |
|
| 848 | 848 | return $response; |
| 849 | - } elseif ( ! empty( $response->id ) ) { |
|
| 850 | - $refund_message = sprintf( __( 'Refunded %1$s - Refund ID: %2$s - Reason: %3$s', 'woocommerce-gateway-stripe' ), wc_price( $response->amount / 100 ), $response->id, $reason ); |
|
| 851 | - $order->add_order_note( $refund_message ); |
|
| 852 | - $this->log( 'Success: ' . html_entity_decode( strip_tags( $refund_message ) ) ); |
|
| 849 | + } elseif ( ! empty($response->id)) { |
|
| 850 | + $refund_message = sprintf(__('Refunded %1$s - Refund ID: %2$s - Reason: %3$s', 'woocommerce-gateway-stripe'), wc_price($response->amount / 100), $response->id, $reason); |
|
| 851 | + $order->add_order_note($refund_message); |
|
| 852 | + $this->log('Success: ' . html_entity_decode(strip_tags($refund_message))); |
|
| 853 | 853 | return true; |
| 854 | 854 | } |
| 855 | 855 | } |
@@ -862,10 +862,10 @@ discard block |
||
| 862 | 862 | * @param int $order_id |
| 863 | 863 | * @return null |
| 864 | 864 | */ |
| 865 | - public function send_failed_order_email( $order_id ) { |
|
| 865 | + public function send_failed_order_email($order_id) { |
|
| 866 | 866 | $emails = WC()->mailer()->get_emails(); |
| 867 | - if ( ! empty( $emails ) && ! empty( $order_id ) ) { |
|
| 868 | - $emails['WC_Email_Failed_Order']->trigger( $order_id ); |
|
| 867 | + if ( ! empty($emails) && ! empty($order_id)) { |
|
| 868 | + $emails['WC_Email_Failed_Order']->trigger($order_id); |
|
| 869 | 869 | } |
| 870 | 870 | } |
| 871 | 871 | |
@@ -877,9 +877,9 @@ discard block |
||
| 877 | 877 | * |
| 878 | 878 | * @param string $message |
| 879 | 879 | */ |
| 880 | - public function log( $message ) { |
|
| 881 | - if ( $this->logging ) { |
|
| 882 | - WC_Stripe::log( $message ); |
|
| 880 | + public function log($message) { |
|
| 881 | + if ($this->logging) { |
|
| 882 | + WC_Stripe::log($message); |
|
| 883 | 883 | } |
| 884 | 884 | } |
| 885 | 885 | } |