@@ -1,184 +1,184 @@ |
||
| 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' => sprintf( __( 'Enable Apple Pay. Please see %1$sTerms & Conditions%2$s', 'woocommerce-gateway-stripe' ), '<a href="https://stripe.com/apple-pay/legal" target="_blank">', '</a>' ), |
|
| 143 | + 'title' => __('Apple Pay', 'woocommerce-gateway-stripe'), |
|
| 144 | + 'label' => sprintf(__('Enable Apple Pay. Please see %1$sTerms & Conditions%2$s', 'woocommerce-gateway-stripe'), '<a href="https://stripe.com/apple-pay/legal" target="_blank">', '</a>'), |
|
| 145 | 145 | 'type' => 'checkbox', |
| 146 | - 'description' => __( 'If enabled, users will be able to pay with Apple Pay.', 'woocommerce-gateway-stripe' ), |
|
| 146 | + 'description' => __('If enabled, users will be able to pay with Apple Pay.', 'woocommerce-gateway-stripe'), |
|
| 147 | 147 | 'default' => 'no', |
| 148 | 148 | 'desc_tip' => true, |
| 149 | 149 | ), |
| 150 | 150 | 'apple_pay_button' => array( |
| 151 | - 'title' => __( 'Apple Pay Button Style', 'woocommerce-gateway-stripe' ), |
|
| 152 | - 'label' => __( 'Button Style', 'woocommerce-gateway-stripe' ), |
|
| 151 | + 'title' => __('Apple Pay Button Style', 'woocommerce-gateway-stripe'), |
|
| 152 | + 'label' => __('Button Style', 'woocommerce-gateway-stripe'), |
|
| 153 | 153 | 'type' => 'select', |
| 154 | - 'description' => __( 'Select the button style you would like to show.', 'woocommerce-gateway-stripe' ), |
|
| 154 | + 'description' => __('Select the button style you would like to show.', 'woocommerce-gateway-stripe'), |
|
| 155 | 155 | 'default' => 'black', |
| 156 | 156 | 'desc_tip' => true, |
| 157 | 157 | 'options' => array( |
| 158 | - 'black' => __( 'Black', 'woocommerce-gateway-stripe' ), |
|
| 159 | - 'white' => __( 'White', 'woocommerce-gateway-stripe' ), |
|
| 158 | + 'black' => __('Black', 'woocommerce-gateway-stripe'), |
|
| 159 | + 'white' => __('White', 'woocommerce-gateway-stripe'), |
|
| 160 | 160 | ), |
| 161 | 161 | ), |
| 162 | 162 | 'apple_pay_button_lang' => array( |
| 163 | - 'title' => __( 'Apple Pay Button Language', 'woocommerce-gateway-stripe' ), |
|
| 164 | - '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' ), |
|
| 163 | + 'title' => __('Apple Pay Button Language', 'woocommerce-gateway-stripe'), |
|
| 164 | + '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'), |
|
| 165 | 165 | 'type' => 'text', |
| 166 | 166 | 'default' => 'en', |
| 167 | 167 | 'desc_tip' => false, |
| 168 | 168 | ), |
| 169 | 169 | 'saved_cards' => array( |
| 170 | - 'title' => __( 'Saved Cards', 'woocommerce-gateway-stripe' ), |
|
| 171 | - 'label' => __( 'Enable Payment via Saved Cards', 'woocommerce-gateway-stripe' ), |
|
| 170 | + 'title' => __('Saved Cards', 'woocommerce-gateway-stripe'), |
|
| 171 | + 'label' => __('Enable Payment via Saved Cards', 'woocommerce-gateway-stripe'), |
|
| 172 | 172 | 'type' => 'checkbox', |
| 173 | - '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' ), |
|
| 173 | + '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'), |
|
| 174 | 174 | 'default' => 'no', |
| 175 | 175 | 'desc_tip' => true, |
| 176 | 176 | ), |
| 177 | 177 | 'logging' => array( |
| 178 | - 'title' => __( 'Logging', 'woocommerce-gateway-stripe' ), |
|
| 179 | - 'label' => __( 'Log debug messages', 'woocommerce-gateway-stripe' ), |
|
| 178 | + 'title' => __('Logging', 'woocommerce-gateway-stripe'), |
|
| 179 | + 'label' => __('Log debug messages', 'woocommerce-gateway-stripe'), |
|
| 180 | 180 | 'type' => 'checkbox', |
| 181 | - 'description' => __( 'Save debug messages to the WooCommerce System Status log.', 'woocommerce-gateway-stripe' ), |
|
| 181 | + 'description' => __('Save debug messages to the WooCommerce System Status log.', 'woocommerce-gateway-stripe'), |
|
| 182 | 182 | 'default' => 'no', |
| 183 | 183 | 'desc_tip' => true, |
| 184 | 184 | ), |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 2 | +if ( ! defined('ABSPATH')) { |
|
| 3 | 3 | exit; |
| 4 | 4 | } |
| 5 | 5 | |
@@ -47,9 +47,9 @@ discard block |
||
| 47 | 47 | public function __construct() { |
| 48 | 48 | self::$_this = $this; |
| 49 | 49 | |
| 50 | - $this->_gateway_settings = get_option( 'woocommerce_stripe_settings', '' ); |
|
| 50 | + $this->_gateway_settings = get_option('woocommerce_stripe_settings', ''); |
|
| 51 | 51 | |
| 52 | - $this->statement_descriptor = ! empty( $this->_gateway_settings['statement_descriptor'] ) ? $this->_gateway_settings['statement_descriptor'] : wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ); |
|
| 52 | + $this->statement_descriptor = ! empty($this->_gateway_settings['statement_descriptor']) ? $this->_gateway_settings['statement_descriptor'] : wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES); |
|
| 53 | 53 | |
| 54 | 54 | $this->init(); |
| 55 | 55 | } |
@@ -66,30 +66,30 @@ discard block |
||
| 66 | 66 | * @version 3.1.0 |
| 67 | 67 | */ |
| 68 | 68 | public function init() { |
| 69 | - add_action( 'wp_enqueue_scripts', array( $this, 'payment_scripts' ) ); |
|
| 70 | - add_action( 'woocommerce_proceed_to_checkout', array( $this, 'display_apple_pay_button' ), 20 ); |
|
| 71 | - add_action( 'woocommerce_checkout_before_customer_details', array( $this, 'display_apple_pay_button' ) ); |
|
| 72 | - add_action( 'wc_ajax_wc_stripe_apple_pay', array( $this, 'process_apple_pay' ) ); |
|
| 73 | - add_action( 'wc_ajax_wc_stripe_generate_apple_pay_cart', array( $this, 'generate_apple_pay_cart' ) ); |
|
| 74 | - add_action( 'wc_ajax_wc_stripe_apple_pay_get_shipping_methods', array( $this, 'get_shipping_methods' ) ); |
|
| 75 | - add_action( 'wc_ajax_wc_stripe_apple_pay_update_shipping_method', array( $this, 'update_shipping_method' ) ); |
|
| 76 | - add_filter( 'woocommerce_gateway_title', array( $this, 'filter_gateway_title' ), 10, 2 ); |
|
| 69 | + add_action('wp_enqueue_scripts', array($this, 'payment_scripts')); |
|
| 70 | + add_action('woocommerce_proceed_to_checkout', array($this, 'display_apple_pay_button'), 20); |
|
| 71 | + add_action('woocommerce_checkout_before_customer_details', array($this, 'display_apple_pay_button')); |
|
| 72 | + add_action('wc_ajax_wc_stripe_apple_pay', array($this, 'process_apple_pay')); |
|
| 73 | + add_action('wc_ajax_wc_stripe_generate_apple_pay_cart', array($this, 'generate_apple_pay_cart')); |
|
| 74 | + add_action('wc_ajax_wc_stripe_apple_pay_get_shipping_methods', array($this, 'get_shipping_methods')); |
|
| 75 | + add_action('wc_ajax_wc_stripe_apple_pay_update_shipping_method', array($this, 'update_shipping_method')); |
|
| 76 | + add_filter('woocommerce_gateway_title', array($this, 'filter_gateway_title'), 10, 2); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | /** |
| 80 | 80 | * Filters the gateway title to reflect Apple Pay. |
| 81 | 81 | * |
| 82 | 82 | */ |
| 83 | - public function filter_gateway_title( $title, $id ) { |
|
| 83 | + public function filter_gateway_title($title, $id) { |
|
| 84 | 84 | global $post; |
| 85 | 85 | |
| 86 | - if ( ! is_object( $post ) ) { |
|
| 86 | + if ( ! is_object($post)) { |
|
| 87 | 87 | return $title; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - $method_title = get_post_meta( $post->ID, '_payment_method_title', true ); |
|
| 90 | + $method_title = get_post_meta($post->ID, '_payment_method_title', true); |
|
| 91 | 91 | |
| 92 | - if ( 'stripe' === $id && ! empty( $method_title ) ) { |
|
| 92 | + if ('stripe' === $id && ! empty($method_title)) { |
|
| 93 | 93 | return $method_title; |
| 94 | 94 | } |
| 95 | 95 | |
@@ -103,38 +103,38 @@ discard block |
||
| 103 | 103 | * @version 3.1.0 |
| 104 | 104 | */ |
| 105 | 105 | public function payment_scripts() { |
| 106 | - if ( ! is_cart() && ! is_checkout() && ! isset( $_GET['pay_for_order'] ) ) { |
|
| 106 | + if ( ! is_cart() && ! is_checkout() && ! isset($_GET['pay_for_order'])) { |
|
| 107 | 107 | return; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - if ( ! $this->is_supported_product_type() ) { |
|
| 110 | + if ( ! $this->is_supported_product_type()) { |
|
| 111 | 111 | return; |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 114 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
| 115 | 115 | |
| 116 | - wp_enqueue_style( 'stripe_apple_pay', plugins_url( 'assets/css/stripe-apple-pay.css', WC_STRIPE_MAIN_FILE ), array(), WC_STRIPE_VERSION ); |
|
| 116 | + wp_enqueue_style('stripe_apple_pay', plugins_url('assets/css/stripe-apple-pay.css', WC_STRIPE_MAIN_FILE), array(), WC_STRIPE_VERSION); |
|
| 117 | 117 | |
| 118 | - wp_enqueue_script( 'stripe', 'https://js.stripe.com/v2/', '', '1.0', true ); |
|
| 119 | - wp_enqueue_script( 'woocommerce_stripe_apple_pay', plugins_url( 'assets/js/stripe-apple-pay' . $suffix . '.js', WC_STRIPE_MAIN_FILE ), array( 'stripe' ), WC_STRIPE_VERSION, true ); |
|
| 118 | + wp_enqueue_script('stripe', 'https://js.stripe.com/v2/', '', '1.0', true); |
|
| 119 | + wp_enqueue_script('woocommerce_stripe_apple_pay', plugins_url('assets/js/stripe-apple-pay' . $suffix . '.js', WC_STRIPE_MAIN_FILE), array('stripe'), WC_STRIPE_VERSION, true); |
|
| 120 | 120 | |
| 121 | 121 | $publishable_key = 'yes' === $this->_gateway_settings['testmode'] ? $this->_gateway_settings['test_publishable_key'] : $this->_gateway_settings['publishable_key']; |
| 122 | 122 | |
| 123 | 123 | $stripe_params = array( |
| 124 | 124 | 'key' => $publishable_key, |
| 125 | 125 | 'currency_code' => get_woocommerce_currency(), |
| 126 | - 'country_code' => substr( get_option( 'woocommerce_default_country' ), 0, 2 ), |
|
| 126 | + 'country_code' => substr(get_option('woocommerce_default_country'), 0, 2), |
|
| 127 | 127 | 'label' => $this->statement_descriptor, |
| 128 | - 'ajaxurl' => WC_AJAX::get_endpoint( '%%endpoint%%' ), |
|
| 129 | - 'stripe_apple_pay_nonce' => wp_create_nonce( '_wc_stripe_apple_pay_nonce' ), |
|
| 130 | - 'stripe_apple_pay_cart_nonce' => wp_create_nonce( '_wc_stripe_apple_pay_cart_nonce' ), |
|
| 131 | - 'stripe_apple_pay_get_shipping_methods_nonce' => wp_create_nonce( '_wc_stripe_apple_pay_get_shipping_methods_nonce' ), |
|
| 132 | - 'stripe_apple_pay_update_shipping_method_nonce' => wp_create_nonce( '_wc_stripe_apple_pay_update_shipping_method_nonce' ), |
|
| 128 | + 'ajaxurl' => WC_AJAX::get_endpoint('%%endpoint%%'), |
|
| 129 | + 'stripe_apple_pay_nonce' => wp_create_nonce('_wc_stripe_apple_pay_nonce'), |
|
| 130 | + 'stripe_apple_pay_cart_nonce' => wp_create_nonce('_wc_stripe_apple_pay_cart_nonce'), |
|
| 131 | + 'stripe_apple_pay_get_shipping_methods_nonce' => wp_create_nonce('_wc_stripe_apple_pay_get_shipping_methods_nonce'), |
|
| 132 | + 'stripe_apple_pay_update_shipping_method_nonce' => wp_create_nonce('_wc_stripe_apple_pay_update_shipping_method_nonce'), |
|
| 133 | 133 | 'needs_shipping' => WC()->cart->needs_shipping() ? 'yes' : 'no', |
| 134 | 134 | 'is_cart_page' => is_cart() ? 'yes' : 'no', |
| 135 | 135 | ); |
| 136 | 136 | |
| 137 | - wp_localize_script( 'woocommerce_stripe_apple_pay', 'wc_stripe_apple_pay_params', apply_filters( 'wc_stripe_apple_pay_params', $stripe_params ) ); |
|
| 137 | + wp_localize_script('woocommerce_stripe_apple_pay', 'wc_stripe_apple_pay_params', apply_filters('wc_stripe_apple_pay_params', $stripe_params)); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -142,8 +142,8 @@ discard block |
||
| 142 | 142 | * |
| 143 | 143 | */ |
| 144 | 144 | public function is_supported_product_type() { |
| 145 | - foreach ( WC()->cart->get_cart() as $cart_item_key => $values ) { |
|
| 146 | - if ( 'subscription' === $values['data']->product_type ) { |
|
| 145 | + foreach (WC()->cart->get_cart() as $cart_item_key => $values) { |
|
| 146 | + if ('subscription' === $values['data']->product_type) { |
|
| 147 | 147 | return false; |
| 148 | 148 | } |
| 149 | 149 | } |
@@ -166,19 +166,19 @@ discard block |
||
| 166 | 166 | */ |
| 167 | 167 | if ( |
| 168 | 168 | 'yes' !== $this->_gateway_settings['apple_pay'] |
| 169 | - || ! isset( $gateways['stripe'] ) |
|
| 169 | + || ! isset($gateways['stripe']) |
|
| 170 | 170 | ) { |
| 171 | 171 | return; |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - if ( ! $this->is_supported_product_type() ) { |
|
| 174 | + if ( ! $this->is_supported_product_type()) { |
|
| 175 | 175 | return; |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - $apple_pay_button = ! empty( $this->_gateway_settings['apple_pay_button'] ) ? $this->_gateway_settings['apple_pay_button'] : 'black'; |
|
| 179 | - $button_lang = ! empty( $this->_gateway_settings['apple_pay_button_lang'] ) ? strtolower( $this->_gateway_settings['apple_pay_button_lang'] ) : 'en'; |
|
| 178 | + $apple_pay_button = ! empty($this->_gateway_settings['apple_pay_button']) ? $this->_gateway_settings['apple_pay_button'] : 'black'; |
|
| 179 | + $button_lang = ! empty($this->_gateway_settings['apple_pay_button_lang']) ? strtolower($this->_gateway_settings['apple_pay_button_lang']) : 'en'; |
|
| 180 | 180 | ?> |
| 181 | - <button class="apple-pay-button" lang="<?php echo esc_attr( $button_lang ); ?>" style="-webkit-appearance: -apple-pay-button; -apple-pay-button-type: buy; -apple-pay-button-style: <?php echo esc_attr( $apple_pay_button ); ?>;"></button> |
|
| 181 | + <button class="apple-pay-button" lang="<?php echo esc_attr($button_lang); ?>" style="-webkit-appearance: -apple-pay-button; -apple-pay-button-type: buy; -apple-pay-button-style: <?php echo esc_attr($apple_pay_button); ?>;"></button> |
|
| 182 | 182 | <?php |
| 183 | 183 | } |
| 184 | 184 | |
@@ -189,11 +189,11 @@ discard block |
||
| 189 | 189 | * @version 3.1.0 |
| 190 | 190 | */ |
| 191 | 191 | public function generate_apple_pay_cart() { |
| 192 | - if ( ! wp_verify_nonce( $_POST['nonce'], '_wc_stripe_apple_pay_cart_nonce' ) ) { |
|
| 193 | - wp_die( __( 'Cheatin’ huh?', 'woocommerce-gateway-stripe' ) ); |
|
| 192 | + if ( ! wp_verify_nonce($_POST['nonce'], '_wc_stripe_apple_pay_cart_nonce')) { |
|
| 193 | + wp_die(__('Cheatin’ huh?', 'woocommerce-gateway-stripe')); |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | - wp_send_json( array( 'line_items' => $this->build_line_items(), 'total' => WC()->cart->total ) ); |
|
| 196 | + wp_send_json(array('line_items' => $this->build_line_items(), 'total' => WC()->cart->total)); |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | /** |
@@ -203,29 +203,29 @@ discard block |
||
| 203 | 203 | * @version 3.1.0 |
| 204 | 204 | * @param array $address |
| 205 | 205 | */ |
| 206 | - public function calculate_shipping( $address = array() ) { |
|
| 207 | - $country = strtoupper( $address['countryCode'] ); |
|
| 208 | - $state = strtoupper( $address['administrativeArea'] ); |
|
| 206 | + public function calculate_shipping($address = array()) { |
|
| 207 | + $country = strtoupper($address['countryCode']); |
|
| 208 | + $state = strtoupper($address['administrativeArea']); |
|
| 209 | 209 | $postcode = $address['postalCode']; |
| 210 | 210 | $city = $address['locality']; |
| 211 | 211 | |
| 212 | 212 | WC()->shipping->reset_shipping(); |
| 213 | 213 | |
| 214 | - if ( $postcode && ! WC_Validation::is_postcode( $postcode, $country ) ) { |
|
| 215 | - throw new Exception( __( 'Please enter a valid postcode/ZIP.', 'woocommerce-gateway-stripe' ) ); |
|
| 216 | - } elseif ( $postcode ) { |
|
| 217 | - $postcode = wc_format_postcode( $postcode, $country ); |
|
| 214 | + if ($postcode && ! WC_Validation::is_postcode($postcode, $country)) { |
|
| 215 | + throw new Exception(__('Please enter a valid postcode/ZIP.', 'woocommerce-gateway-stripe')); |
|
| 216 | + } elseif ($postcode) { |
|
| 217 | + $postcode = wc_format_postcode($postcode, $country); |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | - if ( $country ) { |
|
| 221 | - WC()->customer->set_location( $country, $state, $postcode, $city ); |
|
| 222 | - WC()->customer->set_shipping_location( $country, $state, $postcode, $city ); |
|
| 220 | + if ($country) { |
|
| 221 | + WC()->customer->set_location($country, $state, $postcode, $city); |
|
| 222 | + WC()->customer->set_shipping_location($country, $state, $postcode, $city); |
|
| 223 | 223 | } else { |
| 224 | 224 | WC()->customer->set_to_base(); |
| 225 | 225 | WC()->customer->set_shipping_to_base(); |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | - WC()->customer->calculated_shipping( true ); |
|
| 228 | + WC()->customer->calculated_shipping(true); |
|
| 229 | 229 | |
| 230 | 230 | /** |
| 231 | 231 | * Set the shipping package. |
@@ -247,17 +247,17 @@ discard block |
||
| 247 | 247 | $packages[0]['destination']['postcode'] = $postcode; |
| 248 | 248 | $packages[0]['destination']['city'] = $city; |
| 249 | 249 | |
| 250 | - foreach ( WC()->cart->get_cart() as $item ) { |
|
| 251 | - if ( $item['data']->needs_shipping() ) { |
|
| 252 | - if ( isset( $item['line_total'] ) ) { |
|
| 250 | + foreach (WC()->cart->get_cart() as $item) { |
|
| 251 | + if ($item['data']->needs_shipping()) { |
|
| 252 | + if (isset($item['line_total'])) { |
|
| 253 | 253 | $packages[0]['contents_cost'] += $item['line_total']; |
| 254 | 254 | } |
| 255 | 255 | } |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | - $packages = apply_filters( 'woocommerce_cart_shipping_packages', $packages ); |
|
| 258 | + $packages = apply_filters('woocommerce_cart_shipping_packages', $packages); |
|
| 259 | 259 | |
| 260 | - WC()->shipping->calculate_shipping( $packages ); |
|
| 260 | + WC()->shipping->calculate_shipping($packages); |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | /** |
@@ -267,18 +267,18 @@ discard block |
||
| 267 | 267 | * @version 3.1.0 |
| 268 | 268 | */ |
| 269 | 269 | public function get_shipping_methods() { |
| 270 | - if ( ! wp_verify_nonce( $_POST['nonce'], '_wc_stripe_apple_pay_get_shipping_methods_nonce' ) ) { |
|
| 271 | - wp_die( __( 'Cheatin’ huh?', 'woocommerce-gateway-stripe' ) ); |
|
| 270 | + if ( ! wp_verify_nonce($_POST['nonce'], '_wc_stripe_apple_pay_get_shipping_methods_nonce')) { |
|
| 271 | + wp_die(__('Cheatin’ huh?', 'woocommerce-gateway-stripe')); |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | - if ( ! defined( 'WOOCOMMERCE_CART' ) ) { |
|
| 275 | - define( 'WOOCOMMERCE_CART', true ); |
|
| 274 | + if ( ! defined('WOOCOMMERCE_CART')) { |
|
| 275 | + define('WOOCOMMERCE_CART', true); |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | try { |
| 279 | - $address = array_map( 'wc_clean', $_POST['address'] ); |
|
| 279 | + $address = array_map('wc_clean', $_POST['address']); |
|
| 280 | 280 | |
| 281 | - $this->calculate_shipping( $address ); |
|
| 281 | + $this->calculate_shipping($address); |
|
| 282 | 282 | |
| 283 | 283 | // Set the shipping options. |
| 284 | 284 | $currency = get_woocommerce_currency(); |
@@ -286,13 +286,13 @@ discard block |
||
| 286 | 286 | |
| 287 | 287 | $packages = WC()->shipping->get_packages(); |
| 288 | 288 | |
| 289 | - if ( ! empty( $packages ) && WC()->customer->has_calculated_shipping() ) { |
|
| 290 | - foreach ( $packages as $package_key => $package ) { |
|
| 291 | - if ( empty( $package['rates'] ) ) { |
|
| 292 | - throw new Exception( __( 'Unable to find shipping method for address.', 'woocommerce-gateway-stripe' ) ); |
|
| 289 | + if ( ! empty($packages) && WC()->customer->has_calculated_shipping()) { |
|
| 290 | + foreach ($packages as $package_key => $package) { |
|
| 291 | + if (empty($package['rates'])) { |
|
| 292 | + throw new Exception(__('Unable to find shipping method for address.', 'woocommerce-gateway-stripe')); |
|
| 293 | 293 | } |
| 294 | 294 | |
| 295 | - foreach ( $package['rates'] as $key => $rate ) { |
|
| 295 | + foreach ($package['rates'] as $key => $rate) { |
|
| 296 | 296 | $data[] = array( |
| 297 | 297 | 'id' => $rate->id, |
| 298 | 298 | 'label' => $rate->label, |
@@ -306,16 +306,16 @@ discard block |
||
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | // Auto select the first shipping method. |
| 309 | - WC()->session->set( 'chosen_shipping_methods', array( $data[0]['id'] ) ); |
|
| 309 | + WC()->session->set('chosen_shipping_methods', array($data[0]['id'])); |
|
| 310 | 310 | |
| 311 | 311 | WC()->cart->calculate_totals(); |
| 312 | 312 | |
| 313 | - wp_send_json( array( 'success' => 'true', 'shipping_methods' => $this->build_shipping_methods( $data ), 'line_items' => $this->build_line_items(), 'total' => WC()->cart->total ) ); |
|
| 313 | + wp_send_json(array('success' => 'true', 'shipping_methods' => $this->build_shipping_methods($data), 'line_items' => $this->build_line_items(), 'total' => WC()->cart->total)); |
|
| 314 | 314 | } else { |
| 315 | - throw new Exception( __( 'Unable to find shipping method for address.', 'woocommerce-gateway-stripe' ) ); |
|
| 315 | + throw new Exception(__('Unable to find shipping method for address.', 'woocommerce-gateway-stripe')); |
|
| 316 | 316 | } |
| 317 | - } catch ( Exception $e ) { |
|
| 318 | - wp_send_json( array( 'success' => 'false', 'shipping_methods' => array(), 'line_items' => $this->build_line_items(), 'total' => WC()->cart->total ) ); |
|
| 317 | + } catch (Exception $e) { |
|
| 318 | + wp_send_json(array('success' => 'false', 'shipping_methods' => array(), 'line_items' => $this->build_line_items(), 'total' => WC()->cart->total)); |
|
| 319 | 319 | } |
| 320 | 320 | } |
| 321 | 321 | |
@@ -326,29 +326,29 @@ discard block |
||
| 326 | 326 | * @version 3.1.0 |
| 327 | 327 | */ |
| 328 | 328 | public function update_shipping_method() { |
| 329 | - if ( ! defined( 'WOOCOMMERCE_CART' ) ) { |
|
| 330 | - define( 'WOOCOMMERCE_CART', true ); |
|
| 329 | + if ( ! defined('WOOCOMMERCE_CART')) { |
|
| 330 | + define('WOOCOMMERCE_CART', true); |
|
| 331 | 331 | } |
| 332 | 332 | |
| 333 | - if ( ! wp_verify_nonce( $_POST['nonce'], '_wc_stripe_apple_pay_update_shipping_method_nonce' ) ) { |
|
| 334 | - wp_die( __( 'Cheatin’ huh?', 'woocommerce-gateway-stripe' ) ); |
|
| 333 | + if ( ! wp_verify_nonce($_POST['nonce'], '_wc_stripe_apple_pay_update_shipping_method_nonce')) { |
|
| 334 | + wp_die(__('Cheatin’ huh?', 'woocommerce-gateway-stripe')); |
|
| 335 | 335 | } |
| 336 | 336 | |
| 337 | - $selected_shipping_method = array_map( 'wc_clean', $_POST['selected_shipping_method'] ); |
|
| 337 | + $selected_shipping_method = array_map('wc_clean', $_POST['selected_shipping_method']); |
|
| 338 | 338 | |
| 339 | - WC()->session->set( 'chosen_shipping_methods', array( $selected_shipping_method['identifier'] ) ); |
|
| 339 | + WC()->session->set('chosen_shipping_methods', array($selected_shipping_method['identifier'])); |
|
| 340 | 340 | |
| 341 | 341 | WC()->cart->calculate_totals(); |
| 342 | 342 | |
| 343 | 343 | // Send back the new cart total. |
| 344 | 344 | $currency = get_woocommerce_currency(); |
| 345 | - $tax_total = max( 0, round( WC()->cart->tax_total + WC()->cart->shipping_tax_total, WC()->cart->dp ) ); |
|
| 345 | + $tax_total = max(0, round(WC()->cart->tax_total + WC()->cart->shipping_tax_total, WC()->cart->dp)); |
|
| 346 | 346 | $data = array( |
| 347 | 347 | 'total' => WC()->cart->total, |
| 348 | 348 | ); |
| 349 | 349 | |
| 350 | 350 | // Include fees and taxes as displayItems. |
| 351 | - foreach ( WC()->cart->fees as $key => $fee ) { |
|
| 351 | + foreach (WC()->cart->fees as $key => $fee) { |
|
| 352 | 352 | $data['items'][] = array( |
| 353 | 353 | 'label' => $fee->name, |
| 354 | 354 | 'amount' => array( |
@@ -357,9 +357,9 @@ discard block |
||
| 357 | 357 | ), |
| 358 | 358 | ); |
| 359 | 359 | } |
| 360 | - if ( 0 < $tax_total ) { |
|
| 360 | + if (0 < $tax_total) { |
|
| 361 | 361 | $data['items'][] = array( |
| 362 | - 'label' => __( 'Tax', 'woocommerce-gateway-stripe' ), |
|
| 362 | + 'label' => __('Tax', 'woocommerce-gateway-stripe'), |
|
| 363 | 363 | 'amount' => array( |
| 364 | 364 | 'currency' => $currency, |
| 365 | 365 | 'value' => $tax_total, |
@@ -367,7 +367,7 @@ discard block |
||
| 367 | 367 | ); |
| 368 | 368 | } |
| 369 | 369 | |
| 370 | - wp_send_json( array( 'success' => 'true', 'line_items' => $this->build_line_items(), 'total' => WC()->cart->total ) ); |
|
| 370 | + wp_send_json(array('success' => 'true', 'line_items' => $this->build_line_items(), 'total' => WC()->cart->total)); |
|
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | /** |
@@ -378,35 +378,35 @@ discard block |
||
| 378 | 378 | * @version 3.1.0 |
| 379 | 379 | */ |
| 380 | 380 | public function process_apple_pay() { |
| 381 | - if ( ! wp_verify_nonce( $_POST['nonce'], '_wc_stripe_apple_pay_nonce' ) ) { |
|
| 382 | - wp_die( __( 'Cheatin’ huh?', 'woocommerce-gateway-stripe' ) ); |
|
| 381 | + if ( ! wp_verify_nonce($_POST['nonce'], '_wc_stripe_apple_pay_nonce')) { |
|
| 382 | + wp_die(__('Cheatin’ huh?', 'woocommerce-gateway-stripe')); |
|
| 383 | 383 | } |
| 384 | 384 | |
| 385 | 385 | try { |
| 386 | - $result = array_map( 'wc_clean', $_POST['result'] ); |
|
| 386 | + $result = array_map('wc_clean', $_POST['result']); |
|
| 387 | 387 | |
| 388 | - $order = $this->create_order( $result ); |
|
| 388 | + $order = $this->create_order($result); |
|
| 389 | 389 | |
| 390 | 390 | // Handle payment. |
| 391 | - if ( $order->get_total() > 0 ) { |
|
| 391 | + if ($order->get_total() > 0) { |
|
| 392 | 392 | |
| 393 | - if ( $order->get_total() * 100 < WC_Stripe::get_minimum_amount() ) { |
|
| 394 | - return new WP_Error( 'stripe_error', 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 ) ) ); |
|
| 393 | + if ($order->get_total() * 100 < WC_Stripe::get_minimum_amount()) { |
|
| 394 | + return new WP_Error('stripe_error', 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))); |
|
| 395 | 395 | } |
| 396 | 396 | |
| 397 | - WC_Stripe::log( "Info: Begin processing payment for order $order->id for the amount of {$order->get_total()}" ); |
|
| 397 | + WC_Stripe::log("Info: Begin processing payment for order $order->id for the amount of {$order->get_total()}"); |
|
| 398 | 398 | |
| 399 | 399 | // Make the request. |
| 400 | - $response = WC_Stripe_API::request( $this->generate_payment_request( $order, $result['token']['id'] ) ); |
|
| 400 | + $response = WC_Stripe_API::request($this->generate_payment_request($order, $result['token']['id'])); |
|
| 401 | 401 | |
| 402 | - if ( is_wp_error( $response ) ) { |
|
| 402 | + if (is_wp_error($response)) { |
|
| 403 | 403 | $localized_messages = $this->get_localized_messages(); |
| 404 | 404 | |
| 405 | - throw new Exception( ( isset( $localized_messages[ $response->get_error_code() ] ) ? $localized_messages[ $response->get_error_code() ] : $response->get_error_message() ) ); |
|
| 405 | + throw new Exception((isset($localized_messages[$response->get_error_code()]) ? $localized_messages[$response->get_error_code()] : $response->get_error_message())); |
|
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | // Process valid response. |
| 409 | - $this->process_response( $response, $order ); |
|
| 409 | + $this->process_response($response, $order); |
|
| 410 | 410 | } else { |
| 411 | 411 | $order->payment_complete(); |
| 412 | 412 | } |
@@ -414,24 +414,24 @@ discard block |
||
| 414 | 414 | // Remove cart. |
| 415 | 415 | WC()->cart->empty_cart(); |
| 416 | 416 | |
| 417 | - update_post_meta( $order->id, '_customer_user', get_current_user_id() ); |
|
| 418 | - update_post_meta( $order->id, '_payment_method_title', __( 'Apple Pay (Stripe)', 'woocommerce-gateway-stripe' ) ); |
|
| 417 | + update_post_meta($order->id, '_customer_user', get_current_user_id()); |
|
| 418 | + update_post_meta($order->id, '_payment_method_title', __('Apple Pay (Stripe)', 'woocommerce-gateway-stripe')); |
|
| 419 | 419 | |
| 420 | 420 | // Return thank you page redirect. |
| 421 | - wp_send_json( array( |
|
| 421 | + wp_send_json(array( |
|
| 422 | 422 | 'success' => 'true', |
| 423 | - 'redirect' => $this->get_return_url( $order ), |
|
| 424 | - ) ); |
|
| 423 | + 'redirect' => $this->get_return_url($order), |
|
| 424 | + )); |
|
| 425 | 425 | |
| 426 | - } catch ( Exception $e ) { |
|
| 427 | - WC()->session->set( 'refresh_totals', true ); |
|
| 428 | - WC_Stripe::log( sprintf( __( 'Error: %s', 'woocommerce-gateway-stripe' ), $e->getMessage() ) ); |
|
| 426 | + } catch (Exception $e) { |
|
| 427 | + WC()->session->set('refresh_totals', true); |
|
| 428 | + WC_Stripe::log(sprintf(__('Error: %s', 'woocommerce-gateway-stripe'), $e->getMessage())); |
|
| 429 | 429 | |
| 430 | - if ( $order->has_status( array( 'pending', 'failed' ) ) ) { |
|
| 431 | - $this->send_failed_order_email( $order->id ); |
|
| 430 | + if ($order->has_status(array('pending', 'failed'))) { |
|
| 431 | + $this->send_failed_order_email($order->id); |
|
| 432 | 432 | } |
| 433 | 433 | |
| 434 | - wp_send_json( array( 'success' => 'false', 'msg' => $e->getMessage() ) ); |
|
| 434 | + wp_send_json(array('success' => 'false', 'msg' => $e->getMessage())); |
|
| 435 | 435 | } |
| 436 | 436 | } |
| 437 | 437 | |
@@ -441,14 +441,14 @@ discard block |
||
| 441 | 441 | * @param string $source token |
| 442 | 442 | * @return array() |
| 443 | 443 | */ |
| 444 | - protected function generate_payment_request( $order, $source ) { |
|
| 444 | + protected function generate_payment_request($order, $source) { |
|
| 445 | 445 | $post_data = array(); |
| 446 | - $post_data['currency'] = strtolower( $order->get_order_currency() ? $order->get_order_currency() : get_woocommerce_currency() ); |
|
| 447 | - $post_data['amount'] = $this->get_stripe_amount( $order->get_total(), $post_data['currency'] ); |
|
| 448 | - $post_data['description'] = sprintf( __( '%1$s - Order %2$s', 'woocommerce-gateway-stripe' ), $this->statement_descriptor, $order->get_order_number() ); |
|
| 446 | + $post_data['currency'] = strtolower($order->get_order_currency() ? $order->get_order_currency() : get_woocommerce_currency()); |
|
| 447 | + $post_data['amount'] = $this->get_stripe_amount($order->get_total(), $post_data['currency']); |
|
| 448 | + $post_data['description'] = sprintf(__('%1$s - Order %2$s', 'woocommerce-gateway-stripe'), $this->statement_descriptor, $order->get_order_number()); |
|
| 449 | 449 | $post_data['capture'] = 'yes' === $this->_gateway_settings['capture'] ? 'true' : 'false'; |
| 450 | 450 | |
| 451 | - if ( ! empty( $order->billing_email ) && apply_filters( 'wc_stripe_send_stripe_receipt', false ) ) { |
|
| 451 | + if ( ! empty($order->billing_email) && apply_filters('wc_stripe_send_stripe_receipt', false)) { |
|
| 452 | 452 | $post_data['receipt_email'] = $order->billing_email; |
| 453 | 453 | } |
| 454 | 454 | |
@@ -463,7 +463,7 @@ discard block |
||
| 463 | 463 | * @param WC_Order $order |
| 464 | 464 | * @param object $source |
| 465 | 465 | */ |
| 466 | - return apply_filters( 'wc_stripe_generate_payment_request', $post_data, $order ); |
|
| 466 | + return apply_filters('wc_stripe_generate_payment_request', $post_data, $order); |
|
| 467 | 467 | } |
| 468 | 468 | |
| 469 | 469 | /** |
@@ -472,14 +472,14 @@ discard block |
||
| 472 | 472 | * @since 3.1.0 |
| 473 | 473 | * @version 3.1.0 |
| 474 | 474 | */ |
| 475 | - public function build_shipping_methods( $shipping_methods ) { |
|
| 476 | - if ( empty( $shipping_methods ) ) { |
|
| 475 | + public function build_shipping_methods($shipping_methods) { |
|
| 476 | + if (empty($shipping_methods)) { |
|
| 477 | 477 | return array(); |
| 478 | 478 | } |
| 479 | 479 | |
| 480 | 480 | $shipping = array(); |
| 481 | 481 | |
| 482 | - foreach ( $shipping_methods as $method ) { |
|
| 482 | + foreach ($shipping_methods as $method) { |
|
| 483 | 483 | $shipping[] = array( |
| 484 | 484 | 'label' => $method['label'], |
| 485 | 485 | 'detail' => '', |
@@ -498,53 +498,53 @@ discard block |
||
| 498 | 498 | * @version 3.1.0 |
| 499 | 499 | */ |
| 500 | 500 | public function build_line_items() { |
| 501 | - if ( ! defined( 'WOOCOMMERCE_CART' ) ) { |
|
| 502 | - define( 'WOOCOMMERCE_CART', true ); |
|
| 501 | + if ( ! defined('WOOCOMMERCE_CART')) { |
|
| 502 | + define('WOOCOMMERCE_CART', true); |
|
| 503 | 503 | } |
| 504 | 504 | |
| 505 | - $decimals = apply_filters( 'wc_stripe_apple_pay_decimals', 2 ); |
|
| 505 | + $decimals = apply_filters('wc_stripe_apple_pay_decimals', 2); |
|
| 506 | 506 | |
| 507 | 507 | $items = array(); |
| 508 | 508 | |
| 509 | - foreach ( WC()->cart->get_cart() as $cart_item_key => $values ) { |
|
| 510 | - $amount = wc_format_decimal( $values['line_subtotal'], $decimals ); |
|
| 509 | + foreach (WC()->cart->get_cart() as $cart_item_key => $values) { |
|
| 510 | + $amount = wc_format_decimal($values['line_subtotal'], $decimals); |
|
| 511 | 511 | $quantity_label = 1 < $values['quantity'] ? ' (x' . $values['quantity'] . ')' : ''; |
| 512 | 512 | |
| 513 | 513 | $item = array( |
| 514 | 514 | 'type' => 'final', |
| 515 | 515 | 'label' => $values['data']->post->post_title . $quantity_label, |
| 516 | - 'amount' => wc_format_decimal( $amount, $decimals ), |
|
| 516 | + 'amount' => wc_format_decimal($amount, $decimals), |
|
| 517 | 517 | ); |
| 518 | 518 | |
| 519 | 519 | $items[] = $item; |
| 520 | 520 | } |
| 521 | 521 | |
| 522 | - $discounts = wc_format_decimal( WC()->cart->get_cart_discount_total(), $decimals ); |
|
| 523 | - $tax = wc_format_decimal( WC()->cart->tax_total + WC()->cart->shipping_tax_total, $decimals ); |
|
| 524 | - $shipping = wc_format_decimal( WC()->cart->shipping_total, $decimals ); |
|
| 525 | - $item_total = wc_format_decimal( WC()->cart->cart_contents_total, $decimals ) + $discounts; |
|
| 526 | - $order_total = wc_format_decimal( $item_total + $tax + $shipping, $decimals ); |
|
| 522 | + $discounts = wc_format_decimal(WC()->cart->get_cart_discount_total(), $decimals); |
|
| 523 | + $tax = wc_format_decimal(WC()->cart->tax_total + WC()->cart->shipping_tax_total, $decimals); |
|
| 524 | + $shipping = wc_format_decimal(WC()->cart->shipping_total, $decimals); |
|
| 525 | + $item_total = wc_format_decimal(WC()->cart->cart_contents_total, $decimals) + $discounts; |
|
| 526 | + $order_total = wc_format_decimal($item_total + $tax + $shipping, $decimals); |
|
| 527 | 527 | |
| 528 | - if ( wc_tax_enabled() ) { |
|
| 528 | + if (wc_tax_enabled()) { |
|
| 529 | 529 | $items[] = array( |
| 530 | 530 | 'type' => 'final', |
| 531 | - 'label' => __( 'Tax', 'woocommerce-gateway-stripe' ), |
|
| 531 | + 'label' => __('Tax', 'woocommerce-gateway-stripe'), |
|
| 532 | 532 | 'amount' => $tax, |
| 533 | 533 | ); |
| 534 | 534 | } |
| 535 | 535 | |
| 536 | - if ( WC()->cart->needs_shipping() ) { |
|
| 536 | + if (WC()->cart->needs_shipping()) { |
|
| 537 | 537 | $items[] = array( |
| 538 | 538 | 'type' => 'final', |
| 539 | - 'label' => __( 'Shipping', 'woocommerce-gateway-stripe' ), |
|
| 539 | + 'label' => __('Shipping', 'woocommerce-gateway-stripe'), |
|
| 540 | 540 | 'amount' => $shipping, |
| 541 | 541 | ); |
| 542 | 542 | } |
| 543 | 543 | |
| 544 | - if ( WC()->cart->has_discount() ) { |
|
| 544 | + if (WC()->cart->has_discount()) { |
|
| 545 | 545 | $items[] = array( |
| 546 | 546 | 'type' => 'final', |
| 547 | - 'label' => __( 'Discount', 'woocommerce-gateway-stripe' ), |
|
| 547 | + 'label' => __('Discount', 'woocommerce-gateway-stripe'), |
|
| 548 | 548 | 'amount' => $discounts, |
| 549 | 549 | ); |
| 550 | 550 | } |
@@ -560,24 +560,24 @@ discard block |
||
| 560 | 560 | * @param array $data |
| 561 | 561 | * @return object $order |
| 562 | 562 | */ |
| 563 | - public function create_order( $data = array() ) { |
|
| 564 | - if ( empty( $data ) ) { |
|
| 565 | - throw new Exception( sprintf( __( 'Error %d: Unable to create order. Please try again.', 'woocommerce-gateway-stripe' ), 520 ) ); |
|
| 563 | + public function create_order($data = array()) { |
|
| 564 | + if (empty($data)) { |
|
| 565 | + throw new Exception(sprintf(__('Error %d: Unable to create order. Please try again.', 'woocommerce-gateway-stripe'), 520)); |
|
| 566 | 566 | } |
| 567 | 567 | |
| 568 | 568 | $order = wc_create_order(); |
| 569 | 569 | |
| 570 | - if ( is_wp_error( $order ) ) { |
|
| 571 | - throw new Exception( sprintf( __( 'Error %d: Unable to create order. Please try again.', 'woocommerce-gateway-stripe' ), 520 ) ); |
|
| 572 | - } elseif ( false === $order ) { |
|
| 573 | - throw new Exception( sprintf( __( 'Error %d: Unable to create order. Please try again.', 'woocommerce-gateway-stripe' ), 521 ) ); |
|
| 570 | + if (is_wp_error($order)) { |
|
| 571 | + throw new Exception(sprintf(__('Error %d: Unable to create order. Please try again.', 'woocommerce-gateway-stripe'), 520)); |
|
| 572 | + } elseif (false === $order) { |
|
| 573 | + throw new Exception(sprintf(__('Error %d: Unable to create order. Please try again.', 'woocommerce-gateway-stripe'), 521)); |
|
| 574 | 574 | } else { |
| 575 | 575 | $order_id = $order->id; |
| 576 | - do_action( 'woocommerce_new_order', $order_id ); |
|
| 576 | + do_action('woocommerce_new_order', $order_id); |
|
| 577 | 577 | } |
| 578 | 578 | |
| 579 | 579 | // Store the line items to the new/resumed order |
| 580 | - foreach ( WC()->cart->get_cart() as $cart_item_key => $values ) { |
|
| 580 | + foreach (WC()->cart->get_cart() as $cart_item_key => $values) { |
|
| 581 | 581 | $item_id = $order->add_product( |
| 582 | 582 | $values['data'], |
| 583 | 583 | $values['quantity'], |
@@ -593,47 +593,47 @@ discard block |
||
| 593 | 593 | ) |
| 594 | 594 | ); |
| 595 | 595 | |
| 596 | - if ( ! $item_id ) { |
|
| 597 | - throw new Exception( sprintf( __( 'Error %d: Unable to create order. Please try again.', 'woocommerce-gateway-stripe' ), 525 ) ); |
|
| 596 | + if ( ! $item_id) { |
|
| 597 | + throw new Exception(sprintf(__('Error %d: Unable to create order. Please try again.', 'woocommerce-gateway-stripe'), 525)); |
|
| 598 | 598 | } |
| 599 | 599 | |
| 600 | 600 | // Allow plugins to add order item meta |
| 601 | - do_action( 'woocommerce_add_order_item_meta', $item_id, $values, $cart_item_key ); |
|
| 601 | + do_action('woocommerce_add_order_item_meta', $item_id, $values, $cart_item_key); |
|
| 602 | 602 | } |
| 603 | 603 | |
| 604 | 604 | // Store fees |
| 605 | - foreach ( WC()->cart->get_fees() as $fee_key => $fee ) { |
|
| 606 | - $item_id = $order->add_fee( $fee ); |
|
| 605 | + foreach (WC()->cart->get_fees() as $fee_key => $fee) { |
|
| 606 | + $item_id = $order->add_fee($fee); |
|
| 607 | 607 | |
| 608 | - if ( ! $item_id ) { |
|
| 609 | - throw new Exception( sprintf( __( 'Error %d: Unable to create order. Please try again.', 'woocommerce-gateway-stripe' ), 526 ) ); |
|
| 608 | + if ( ! $item_id) { |
|
| 609 | + throw new Exception(sprintf(__('Error %d: Unable to create order. Please try again.', 'woocommerce-gateway-stripe'), 526)); |
|
| 610 | 610 | } |
| 611 | 611 | |
| 612 | 612 | // Allow plugins to add order item meta to fees |
| 613 | - do_action( 'woocommerce_add_order_fee_meta', $order_id, $item_id, $fee, $fee_key ); |
|
| 613 | + do_action('woocommerce_add_order_fee_meta', $order_id, $item_id, $fee, $fee_key); |
|
| 614 | 614 | } |
| 615 | 615 | |
| 616 | 616 | // Store tax rows |
| 617 | - foreach ( array_keys( WC()->cart->taxes + WC()->cart->shipping_taxes ) as $tax_rate_id ) { |
|
| 618 | - if ( $tax_rate_id && ! $order->add_tax( $tax_rate_id, WC()->cart->get_tax_amount( $tax_rate_id ), WC()->cart->get_shipping_tax_amount( $tax_rate_id ) ) && apply_filters( 'woocommerce_cart_remove_taxes_zero_rate_id', 'zero-rated' ) !== $tax_rate_id ) { |
|
| 619 | - throw new Exception( sprintf( __( 'Error %d: Unable to create order. Please try again.', 'woocommerce-gateway-stripe' ), 528 ) ); |
|
| 617 | + foreach (array_keys(WC()->cart->taxes + WC()->cart->shipping_taxes) as $tax_rate_id) { |
|
| 618 | + if ($tax_rate_id && ! $order->add_tax($tax_rate_id, WC()->cart->get_tax_amount($tax_rate_id), WC()->cart->get_shipping_tax_amount($tax_rate_id)) && apply_filters('woocommerce_cart_remove_taxes_zero_rate_id', 'zero-rated') !== $tax_rate_id) { |
|
| 619 | + throw new Exception(sprintf(__('Error %d: Unable to create order. Please try again.', 'woocommerce-gateway-stripe'), 528)); |
|
| 620 | 620 | } |
| 621 | 621 | } |
| 622 | 622 | |
| 623 | 623 | // Store coupons |
| 624 | - foreach ( WC()->cart->get_coupons() as $code => $coupon ) { |
|
| 625 | - if ( ! $order->add_coupon( $code, WC()->cart->get_coupon_discount_amount( $code ), WC()->cart->get_coupon_discount_tax_amount( $code ) ) ) { |
|
| 626 | - throw new Exception( sprintf( __( 'Error %d: Unable to create order. Please try again.', 'woocommerce-gateway-stripe' ), 529 ) ); |
|
| 624 | + foreach (WC()->cart->get_coupons() as $code => $coupon) { |
|
| 625 | + if ( ! $order->add_coupon($code, WC()->cart->get_coupon_discount_amount($code), WC()->cart->get_coupon_discount_tax_amount($code))) { |
|
| 626 | + throw new Exception(sprintf(__('Error %d: Unable to create order. Please try again.', 'woocommerce-gateway-stripe'), 529)); |
|
| 627 | 627 | } |
| 628 | 628 | } |
| 629 | 629 | |
| 630 | 630 | // Billing address |
| 631 | 631 | $billing_address = array(); |
| 632 | - if ( ! empty( $data['token']['card'] ) ) { |
|
| 632 | + if ( ! empty($data['token']['card'])) { |
|
| 633 | 633 | // Name from Stripe is a full name string. |
| 634 | - $name = explode( ' ', $data['token']['card']['name'] ); |
|
| 635 | - $lastname = array_pop( $name ); |
|
| 636 | - $firstname = implode( ' ', $name ); |
|
| 634 | + $name = explode(' ', $data['token']['card']['name']); |
|
| 635 | + $lastname = array_pop($name); |
|
| 636 | + $firstname = implode(' ', $name); |
|
| 637 | 637 | $billing_address['first_name'] = $firstname; |
| 638 | 638 | $billing_address['last_name'] = $lastname; |
| 639 | 639 | $billing_address['email'] = $data['shippingContact']['emailAddress']; |
@@ -648,7 +648,7 @@ discard block |
||
| 648 | 648 | |
| 649 | 649 | // Shipping address. |
| 650 | 650 | $shipping_address = array(); |
| 651 | - if ( WC()->cart->needs_shipping() && ! empty( $data['shippingContact'] ) ) { |
|
| 651 | + if (WC()->cart->needs_shipping() && ! empty($data['shippingContact'])) { |
|
| 652 | 652 | $shipping_address['first_name'] = $data['shippingContact']['givenName']; |
| 653 | 653 | $shipping_address['last_name'] = $data['shippingContact']['familyName']; |
| 654 | 654 | $shipping_address['email'] = $data['shippingContact']['emailAddress']; |
@@ -659,7 +659,7 @@ discard block |
||
| 659 | 659 | $shipping_address['city'] = $data['shippingContact']['locality']; |
| 660 | 660 | $shipping_address['state'] = $data['shippingContact']['administrativeArea']; |
| 661 | 661 | $shipping_address['postcode'] = $data['shippingContact']['postalCode']; |
| 662 | - } elseif ( ! empty( $data['shippingContact'] ) ) { |
|
| 662 | + } elseif ( ! empty($data['shippingContact'])) { |
|
| 663 | 663 | $shipping_address['first_name'] = $firstname; |
| 664 | 664 | $shipping_address['last_name'] = $lastname; |
| 665 | 665 | $shipping_address['email'] = $data['shippingContact']['emailAddress']; |
@@ -672,34 +672,34 @@ discard block |
||
| 672 | 672 | $shipping_address['postcode'] = $data['token']['card']['address_zip']; |
| 673 | 673 | } |
| 674 | 674 | |
| 675 | - $order->set_address( $billing_address, 'billing' ); |
|
| 676 | - $order->set_address( $shipping_address, 'shipping' ); |
|
| 675 | + $order->set_address($billing_address, 'billing'); |
|
| 676 | + $order->set_address($shipping_address, 'shipping'); |
|
| 677 | 677 | |
| 678 | - WC()->shipping->calculate_shipping( WC()->cart->get_shipping_packages() ); |
|
| 678 | + WC()->shipping->calculate_shipping(WC()->cart->get_shipping_packages()); |
|
| 679 | 679 | |
| 680 | 680 | // Get the rate object selected by user. |
| 681 | - foreach ( WC()->shipping->get_packages() as $package_key => $package ) { |
|
| 682 | - foreach ( $package['rates'] as $key => $rate ) { |
|
| 681 | + foreach (WC()->shipping->get_packages() as $package_key => $package) { |
|
| 682 | + foreach ($package['rates'] as $key => $rate) { |
|
| 683 | 683 | // Loop through user chosen shipping methods. |
| 684 | - foreach ( WC()->session->get( 'chosen_shipping_methods' ) as $method ) { |
|
| 685 | - if ( $method === $key ) { |
|
| 686 | - $order->add_shipping( $rate ); |
|
| 684 | + foreach (WC()->session->get('chosen_shipping_methods') as $method) { |
|
| 685 | + if ($method === $key) { |
|
| 686 | + $order->add_shipping($rate); |
|
| 687 | 687 | } |
| 688 | 688 | } |
| 689 | 689 | } |
| 690 | 690 | } |
| 691 | 691 | |
| 692 | 692 | $available_gateways = WC()->payment_gateways->get_available_payment_gateways(); |
| 693 | - $order->set_payment_method( $available_gateways['stripe'] ); |
|
| 694 | - $order->set_total( WC()->cart->shipping_total, 'shipping' ); |
|
| 695 | - $order->set_total( WC()->cart->get_cart_discount_total(), 'cart_discount' ); |
|
| 696 | - $order->set_total( WC()->cart->get_cart_discount_tax_total(), 'cart_discount_tax' ); |
|
| 697 | - $order->set_total( WC()->cart->tax_total, 'tax' ); |
|
| 698 | - $order->set_total( WC()->cart->shipping_tax_total, 'shipping_tax' ); |
|
| 699 | - $order->set_total( WC()->cart->total ); |
|
| 693 | + $order->set_payment_method($available_gateways['stripe']); |
|
| 694 | + $order->set_total(WC()->cart->shipping_total, 'shipping'); |
|
| 695 | + $order->set_total(WC()->cart->get_cart_discount_total(), 'cart_discount'); |
|
| 696 | + $order->set_total(WC()->cart->get_cart_discount_tax_total(), 'cart_discount_tax'); |
|
| 697 | + $order->set_total(WC()->cart->tax_total, 'tax'); |
|
| 698 | + $order->set_total(WC()->cart->shipping_tax_total, 'shipping_tax'); |
|
| 699 | + $order->set_total(WC()->cart->total); |
|
| 700 | 700 | |
| 701 | 701 | // If we got here, the order was created without problems! |
| 702 | - wc_transaction_query( 'commit' ); |
|
| 702 | + wc_transaction_query('commit'); |
|
| 703 | 703 | |
| 704 | 704 | return $order; |
| 705 | 705 | } |