Version Description
- Updated - WC tested to 4.3.0
- Updated - Bumped PHP min version to 5.6
- Updated - Stripe php lib version 7.39.0
- Updated - Apple domain registration check for existing domain
- Fixed - Notice on cart page when payment request button active and cart emptied
- Fixed - Google Pay fee line item in wallet
- Added - New filters for API requests
Download this release
Release Info
Developer | mr.clayton |
Plugin | Payment Plugins for Stripe WooCommerce |
Version | 3.1.6 |
Comparing to | |
See all releases |
Code changes from version 3.1.5 to 3.1.6
- assets/css/stripe.css +3 -0
- assets/js/frontend/applepay-cart.js +12 -0
- assets/js/frontend/local-payment.js +13 -8
- assets/js/frontend/payment-request.js +12 -0
- assets/js/frontend/wc-stripe.js +3 -0
- assets/js/frontend/wc-stripe.min.js +1 -1
- i18n/languages/woo-stripe-payment.pot +544 -561
- includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php +265 -268
- includes/abstract/abstract-wc-payment-gateway-stripe.php +1387 -1330
- includes/abstract/abstract-wc-payment-token-stripe.php +178 -173
- includes/abstract/abstract-wc-stripe-payment.php +238 -231
- includes/abstract/abstract-wc-stripe-rest-controller.php +104 -105
- includes/abstract/abstract-wc-stripe-settings.php +27 -29
- includes/admin/class-wc-stripe-admin-assets.php +99 -99
- includes/admin/class-wc-stripe-admin-menus.php +39 -45
- includes/admin/class-wc-stripe-admin-notices.php +67 -59
- includes/admin/class-wc-stripe-admin-settings.php +89 -104
- includes/admin/class-wc-stripe-admin-user-edit.php +109 -114
- includes/admin/meta-boxes/class-wc-stripe-admin-meta-box-product-data.php +92 -97
- includes/admin/meta-boxes/class-wc-stripe-admin-order-metaboxes.php +104 -105
- includes/admin/meta-boxes/views/html-charge-data-subview.php +90 -88
- includes/admin/meta-boxes/views/html-order-actions.php +52 -46
- includes/admin/meta-boxes/views/html-order-charge-data.php +37 -37
- includes/admin/meta-boxes/views/html-order-pay.php +59 -59
- includes/admin/meta-boxes/views/html-product-data.php +82 -62
- includes/admin/settings/class-wc-stripe-api-settings.php +188 -175
- includes/admin/views/html-ach-fee.php +33 -29
- includes/admin/views/html-button-demo.php +17 -13
- includes/admin/views/html-button.php +16 -13
- includes/admin/views/html-description.php +1 -1
- includes/admin/views/html-paragraph.php +15 -14
- includes/admin/views/html-settings-local-payments-nav.php +17 -12
- includes/admin/views/html-settings-nav.php +25 -18
- includes/admin/views/html-stripe-connect.php +19 -14
- includes/admin/views/html-user-profile.php +95 -95
- includes/class-stripe.php +304 -295
- includes/class-wc-stripe-api-operation.php +134 -0
- includes/class-wc-stripe-constants.php +46 -46
- includes/class-wc-stripe-customer-manager.php +195 -182
- includes/class-wc-stripe-field-manager.php +256 -246
- includes/class-wc-stripe-frontend-notices.php +58 -58
- includes/class-wc-stripe-frontend-scripts.php +162 -148
- includes/class-wc-stripe-gateway-ach.php +0 -99
- includes/class-wc-stripe-gateway-conversions.php +36 -40
- includes/class-wc-stripe-gateway.php +444 -495
- includes/class-wc-stripe-install.php +40 -36
- includes/class-wc-stripe-payment-charge-local.php +74 -71
- includes/class-wc-stripe-payment-charge.php +179 -173
- includes/class-wc-stripe-payment-factory.php +42 -42
- includes/class-wc-stripe-payment-intent.php +337 -321
- includes/class-wc-stripe-product-gateway-option.php +109 -102
- includes/class-wc-stripe-product-option.php +103 -102
- includes/class-wc-stripe-redirect-handler.php +91 -92
- includes/class-wc-stripe-rest-api.php +113 -119
- includes/class-wc-stripe-update.php +67 -62
- includes/controllers/class-wc-stripe-controller-cart.php +358 -335
- includes/controllers/class-wc-stripe-controller-checkout.php +265 -229
- includes/controllers/class-wc-stripe-controller-gateway-settings.php +237 -194
- includes/controllers/class-wc-stripe-controller-googlepay.php +160 -154
- includes/controllers/class-wc-stripe-controller-order-actions.php +318 -300
- includes/controllers/class-wc-stripe-controller-payment-intent.php +89 -88
- includes/controllers/class-wc-stripe-controller-payment-method.php +52 -49
- includes/controllers/class-wc-stripe-controller-product-data.php +83 -79
- includes/controllers/class-wc-stripe-controller-webhook.php +62 -58
- includes/gateways/class-wc-payment-gateway-stripe-ach-v2.php +0 -233
- includes/gateways/class-wc-payment-gateway-stripe-ach.php +352 -331
- includes/gateways/class-wc-payment-gateway-stripe-alipay.php +33 -34
- includes/gateways/class-wc-payment-gateway-stripe-applepay.php +115 -90
- includes/gateways/class-wc-payment-gateway-stripe-bancontact.php +33 -34
- includes/gateways/class-wc-payment-gateway-stripe-cc.php +173 -164
- includes/gateways/class-wc-payment-gateway-stripe-eps.php +32 -33
- includes/gateways/class-wc-payment-gateway-stripe-fpx.php +38 -39
- includes/gateways/class-wc-payment-gateway-stripe-giropay.php +32 -33
- includes/gateways/class-wc-payment-gateway-stripe-googlepay.php +329 -278
- includes/gateways/class-wc-payment-gateway-stripe-ideal.php +34 -35
- includes/gateways/class-wc-payment-gateway-stripe-klarna.php +298 -277
- includes/gateways/class-wc-payment-gateway-stripe-multibanco.php +32 -33
- includes/gateways/class-wc-payment-gateway-stripe-p24.php +32 -33
- includes/gateways/class-wc-payment-gateway-stripe-payment-request.php +98 -87
- includes/gateways/class-wc-payment-gateway-stripe-sepa.php +64 -60
- includes/gateways/class-wc-payment-gateway-stripe-sofort.php +37 -43
- includes/gateways/class-wc-payment-gateway-stripe-wechat.php +73 -67
- includes/gateways/settings/ach-settings-v2.php +115 -101
- includes/gateways/settings/ach-settings.php +124 -102
- includes/gateways/settings/applepay-settings.php +125 -112
- includes/gateways/settings/cc-settings.php +148 -139
- includes/gateways/settings/googlepay-settings.php +153 -126
- includes/gateways/settings/payment-request-settings.php +115 -95
- includes/tokens/class-wc-payment-token-stripe-ach.php +85 -83
- includes/tokens/class-wc-payment-token-stripe-applepay.php +17 -16
- includes/tokens/class-wc-payment-token-stripe-cc.php +126 -122
- includes/tokens/class-wc-payment-token-stripe-googlepay.php +21 -21
- includes/tokens/class-wc-payment-token-stripe-local-payment.php +40 -41
- includes/traits/wc-stripe-controller-cart-trait.php +28 -25
- includes/traits/wc-stripe-payment-token-traits.php +38 -65
- includes/traits/wc-stripe-payment-traits.php +122 -101
- includes/traits/wc-stripe-settings-trait.php +178 -160
- includes/updates/update-3.0.7.php +38 -42
- includes/updates/update-3.1.0.php +55 -60
- includes/updates/update-3.1.1.php +7 -7
- includes/updates/update-3.1.6.php +5 -0
- includes/wc-stripe-functions.php +1243 -1175
- includes/wc-stripe-hooks.php +29 -28
- includes/wc-stripe-webhook-functions.php +150 -149
- readme.txt +10 -2
- stripe-payments.php +5 -6
- stripe-php-6.40.0/CHANGELOG.md +0 -578
assets/css/stripe.css
CHANGED
@@ -593,4 +593,7 @@ li[class*=payment_method_stripe_] div.wc-stripe_payment_request-container.has_to
|
|
593 |
}
|
594 |
#wc-stripe-card-element.StripeElement--webkit-autofill{
|
595 |
background-color: transparent !important;
|
|
|
|
|
|
|
596 |
}
|
593 |
}
|
594 |
#wc-stripe-card-element.StripeElement--webkit-autofill{
|
595 |
background-color: transparent !important;
|
596 |
+
}
|
597 |
+
#wc_stripe_local_payment_stripe_klarna .stripe-klarna-categories{
|
598 |
+
list-style: none;
|
599 |
}
|
assets/js/frontend/applepay-cart.js
CHANGED
@@ -33,6 +33,9 @@
|
|
33 |
* @return {[type]}
|
34 |
*/
|
35 |
ApplePay.prototype.updated_html = function() {
|
|
|
|
|
|
|
36 |
if (this.can_pay) {
|
37 |
this.create_button();
|
38 |
$(this.container).show().addClass('active').parent().addClass('active');
|
@@ -40,6 +43,15 @@
|
|
40 |
}
|
41 |
}
|
42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
new ApplePay();
|
44 |
|
45 |
}(jQuery, window.wc_stripe))
|
33 |
* @return {[type]}
|
34 |
*/
|
35 |
ApplePay.prototype.updated_html = function() {
|
36 |
+
if (!$(this.container).length) {
|
37 |
+
this.can_pay = false;
|
38 |
+
}
|
39 |
if (this.can_pay) {
|
40 |
this.create_button();
|
41 |
$(this.container).show().addClass('active').parent().addClass('active');
|
43 |
}
|
44 |
}
|
45 |
|
46 |
+
/**
|
47 |
+
* Called when the cart has been emptied
|
48 |
+
* @param {[type]} e [description]
|
49 |
+
* @return {[type]} [description]
|
50 |
+
*/
|
51 |
+
ApplePay.prototype.cart_emptied = function(e) {
|
52 |
+
this.can_pay = false;
|
53 |
+
}
|
54 |
+
|
55 |
new ApplePay();
|
56 |
|
57 |
}(jQuery, window.wc_stripe))
|
assets/js/frontend/local-payment.js
CHANGED
@@ -238,9 +238,12 @@
|
|
238 |
}
|
239 |
|
240 |
Klarna.prototype.category_change = function(e) {
|
241 |
-
$(
|
242 |
-
|
243 |
-
|
|
|
|
|
|
|
244 |
}
|
245 |
|
246 |
Klarna.prototype.hashChange = function(e) {
|
@@ -256,16 +259,16 @@
|
|
256 |
window.Klarna.Payments.init({
|
257 |
client_token: source.klarna.client_token
|
258 |
}, function(response) {
|
259 |
-
|
260 |
}.bind(this));
|
261 |
this.payment_categories = source.klarna.payment_method_categories.split(",");
|
262 |
-
this.render_ui();
|
263 |
this.show_place_order();
|
264 |
}
|
265 |
}
|
266 |
}
|
267 |
|
268 |
-
Klarna.prototype.render_ui = function() {
|
269 |
if (this.payment_categories.length > 0) {
|
270 |
$('#wc_stripe_local_payment_stripe_klarna').show();
|
271 |
for (var i = 0; i < this.payment_categories.length; i++) {
|
@@ -285,7 +288,9 @@
|
|
285 |
}
|
286 |
}
|
287 |
}
|
288 |
-
|
|
|
|
|
289 |
}
|
290 |
}
|
291 |
|
@@ -327,7 +332,7 @@
|
|
327 |
|
328 |
Klarna.prototype.updated_checkout = function() {
|
329 |
if (this.payment_categories) {
|
330 |
-
this.render_ui();
|
331 |
}
|
332 |
}
|
333 |
|
238 |
}
|
239 |
|
240 |
Klarna.prototype.category_change = function(e) {
|
241 |
+
var $el = $(e.currentTarget);
|
242 |
+
if ($el.is(':checked')) {
|
243 |
+
$('[id^="klarna-instance-"]').slideUp();
|
244 |
+
var category = $('[name="klarna_category"]:checked').val();
|
245 |
+
$('#klarna-instance-' + category).slideDown();
|
246 |
+
}
|
247 |
}
|
248 |
|
249 |
Klarna.prototype.hashChange = function(e) {
|
259 |
window.Klarna.Payments.init({
|
260 |
client_token: source.klarna.client_token
|
261 |
}, function(response) {
|
262 |
+
|
263 |
}.bind(this));
|
264 |
this.payment_categories = source.klarna.payment_method_categories.split(",");
|
265 |
+
this.render_ui(true);
|
266 |
this.show_place_order();
|
267 |
}
|
268 |
}
|
269 |
}
|
270 |
|
271 |
+
Klarna.prototype.render_ui = function(trigger_change) {
|
272 |
if (this.payment_categories.length > 0) {
|
273 |
$('#wc_stripe_local_payment_stripe_klarna').show();
|
274 |
for (var i = 0; i < this.payment_categories.length; i++) {
|
288 |
}
|
289 |
}
|
290 |
}
|
291 |
+
if (trigger_change) {
|
292 |
+
$('[id^="klarna-category-"]:visible [name="klarna_category"]').first().prop('checked', true).trigger('change');
|
293 |
+
}
|
294 |
}
|
295 |
}
|
296 |
|
332 |
|
333 |
Klarna.prototype.updated_checkout = function() {
|
334 |
if (this.payment_categories) {
|
335 |
+
this.render_ui(false);
|
336 |
}
|
337 |
}
|
338 |
|
assets/js/frontend/payment-request.js
CHANGED
@@ -147,6 +147,9 @@
|
|
147 |
* @return {[type]} [description]
|
148 |
*/
|
149 |
PaymentRequest.prototype.updated_html = function() {
|
|
|
|
|
|
|
150 |
if (this.can_pay) {
|
151 |
this.paymentRequestButton.destroy();
|
152 |
this.initialize();
|
@@ -160,6 +163,15 @@
|
|
160 |
}
|
161 |
}));
|
162 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
}
|
164 |
|
165 |
// Checkout page functionality
|
147 |
* @return {[type]} [description]
|
148 |
*/
|
149 |
PaymentRequest.prototype.updated_html = function() {
|
150 |
+
if (!$(this.container).length) {
|
151 |
+
this.can_pay = false;
|
152 |
+
}
|
153 |
if (this.can_pay) {
|
154 |
this.paymentRequestButton.destroy();
|
155 |
this.initialize();
|
163 |
}
|
164 |
}));
|
165 |
}
|
166 |
+
|
167 |
+
/**
|
168 |
+
* Called when the cart has been emptied
|
169 |
+
* @param {[type]} e [description]
|
170 |
+
* @return {[type]} [description]
|
171 |
+
*/
|
172 |
+
PaymentRequest.prototype.cart_emptied = function(e) {
|
173 |
+
this.can_pay = false;
|
174 |
+
}
|
175 |
}
|
176 |
|
177 |
// Checkout page functionality
|
assets/js/frontend/wc-stripe.js
CHANGED
@@ -1150,6 +1150,7 @@
|
|
1150 |
// cart events
|
1151 |
$(document.body).on('updated_wc_div', this.updated_html.bind(this));
|
1152 |
$(document.body).on('updated_cart_totals', this.updated_html.bind(this));
|
|
|
1153 |
}
|
1154 |
|
1155 |
wc_stripe.CartGateway.prototype.needs_shipping = function() {
|
@@ -1172,6 +1173,8 @@
|
|
1172 |
|
1173 |
}
|
1174 |
|
|
|
|
|
1175 |
wc_stripe.CartGateway.prototype.add_cart_totals_class = function() {
|
1176 |
$('.cart_totals').addClass('stripe_cart_gateway_active');
|
1177 |
}
|
1150 |
// cart events
|
1151 |
$(document.body).on('updated_wc_div', this.updated_html.bind(this));
|
1152 |
$(document.body).on('updated_cart_totals', this.updated_html.bind(this));
|
1153 |
+
$(document.body).on('wc_cart_emptied', this.cart_emptied.bind(this));
|
1154 |
}
|
1155 |
|
1156 |
wc_stripe.CartGateway.prototype.needs_shipping = function() {
|
1173 |
|
1174 |
}
|
1175 |
|
1176 |
+
wc_stripe.CartGateway.prototype.cart_emptied = function(e) {}
|
1177 |
+
|
1178 |
wc_stripe.CartGateway.prototype.add_cart_totals_class = function() {
|
1179 |
$('.cart_totals').addClass('stripe_cart_gateway_active');
|
1180 |
}
|
assets/js/frontend/wc-stripe.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(t,e){t.wc_stripe={};var i=null;wc_stripe.BaseGateway=function(t){this.params=t,this.gateway_id=this.params.gateway_id,this.token_selector=this.params.token_selector,this.saved_method_selector=this.params.saved_method_selector,this.payment_intent_selector=this.params.payment_intent_selector,this.payment_token_received=!1,this.stripe=i,this.elements=i.elements(e.extend({},{locale:"auto"},this.get_element_options())),this.initialize()},wc_stripe.BaseGateway.prototype.get_page=function(){return wc_stripe_params_v3.page},wc_stripe.BaseGateway.prototype.set_nonce=function(t){e(this.token_selector).val(t)},wc_stripe.BaseGateway.prototype.get_element_options=function(){return{}},wc_stripe.BaseGateway.prototype.initialize=function(){},wc_stripe.BaseGateway.prototype.create_button=function(){},wc_stripe.BaseGateway.prototype.is_gateway_selected=function(){return e('[name="payment_method"]:checked').val()===this.gateway_id},wc_stripe.BaseGateway.prototype.is_saved_method_selected=function(){return this.is_gateway_selected()&&"saved"===e('[name="'+this.gateway_id+'_payment_type_key"]:checked').val()},wc_stripe.BaseGateway.prototype.has_checkout_error=function(){return e("#wc_stripe_checkout_error").length>0&&this.is_gateway_selected()},wc_stripe.BaseGateway.prototype.submit_error=function(t){-1==(t=this.get_error_message(t)).indexOf("</ul>")&&(t='<div class="woocommerce-error">'+t+"</div>"),this.submit_message(t)},wc_stripe.BaseGateway.prototype.submit_error_code=function(t){},wc_stripe.BaseGateway.prototype.get_error_message=function(t){return"object"==typeof t&&t.code&&(t=wc_stripe_messages[t.code]?wc_stripe_messages[t.code]:t.message),t},wc_stripe.BaseGateway.prototype.submit_message=function(t){e(".woocommerce-error, .woocommerce-message, .woocommerce-info").remove();var i=e(this.message_container);i.closest("form").length&&(i=i.closest("form")),i.prepend(t),i.removeClass("processing").unblock(),i.find(".input-text, select, input:checkbox").blur(),e.scroll_to_notices?e.scroll_to_notices(i):e("html, body").animate({scrollTop:i.offset().top-100},1e3)},wc_stripe.BaseGateway.prototype.get_first_name=function(t){return e("#"+t+"_first_name").val()},wc_stripe.BaseGateway.prototype.get_last_name=function(t){return e("#"+t+"_last_name").val()},wc_stripe.BaseGateway.prototype.should_save_method=function(){return e("#"+this.gateway_id+"_save_source_key").is(":checked")},wc_stripe.BaseGateway.prototype.is_add_payment_method_page=function(){return e(document.body).hasClass("woocommerce-add-payment-method")},wc_stripe.BaseGateway.prototype.get_selected_payment_method=function(){return e(this.saved_method_selector).val()},wc_stripe.BaseGateway.prototype.needs_shipping=function(){return"1"===this.params.needs_shipping},wc_stripe.BaseGateway.prototype.get_currency=function(){return e("#wc_stripe_currency").val()},wc_stripe.BaseGateway.prototype.get_country=function(){return e("#wc_stripe_country").val()},wc_stripe.BaseGateway.prototype.get_customer_name=function(t){return e(t+"_first_name").val()+" "+e(t+"_last_name").val()},wc_stripe.BaseGateway.prototype.get_customer_email=function(){return e("#billing_email").val()},wc_stripe.BaseGateway.prototype.get_address_field_hash=function(t){for(var i=["_first_name","_last_name","_address_1","_address_2","_postcode","_city","_state","_country"],a="",n=0;n<i.length;n++)a+=e(t+i[n]).val()+"_";return a},wc_stripe.BaseGateway.prototype.block=function(){e.blockUI({message:null,overlayCSS:{background:"#fff",opacity:.6}})},wc_stripe.BaseGateway.prototype.unblock=function(){e.unblockUI()},wc_stripe.BaseGateway.prototype.get_form=function(){return e(this.token_selector).closest("form")},wc_stripe.BaseGateway.prototype.get_total_price=function(){return e("#wc_stripe_order_total").data("amount")},wc_stripe.BaseGateway.prototype.get_total_price_cents=function(){return e("#wc_stripe_order_total_cents").data("amount")},wc_stripe.BaseGateway.prototype.set_total_price=function(t){e("#wc_stripe_order_total").data("amount",t)},wc_stripe.BaseGateway.prototype.set_total_price_cents=function(t){e("#wc_stripe_order_total_cents").data("amount",t)},wc_stripe.BaseGateway.prototype.set_payment_method=function(t){e('[name="payment_method"][value="'+t+'"]').prop("checked",!0).trigger("click")},wc_stripe.BaseGateway.prototype.set_selected_shipping_methods=function(t){if(t&&e('[name^="shipping_method"]').length)for(var i in t){var a=t[i];e('[name="shipping_method['+i+']"][value="'+a+'"]').prop("checked",!0).trigger("change")}},wc_stripe.BaseGateway.prototype.on_token_received=function(t){this.payment_token_received=!0,e(this.token_selector).val(t.id),this.process_checkout()},wc_stripe.BaseGateway.prototype.createPaymentRequest=function(){try{this.paymentRequest=i.paymentRequest(this.get_payment_request_options())}catch(t){return void this.submit_error(t.message)}this.needs_shipping()&&(this.paymentRequest.on("shippingaddresschange",this.update_shipping_address.bind(this)),this.paymentRequest.on("shippingoptionchange",this.update_shipping_method.bind(this))),this.paymentRequest.on("paymentmethod",this.on_payment_method_received.bind(this))},wc_stripe.BaseGateway.prototype.get_payment_request_options=function(){var t={country:this.params.country_code,currency:this.get_currency().toLowerCase(),total:{amount:this.get_total_price_cents(),label:this.params.total_label,pending:!0},requestPayerName:!0,requestPayerEmail:e("#billing_email").length>0,requestPayerPhone:e("#billing_phone").length>0,requestShipping:this.needs_shipping()},i=this.get_display_items(),a=this.get_shipping_options();return i&&(t.displayItems=i),this.needs_shipping()&&a&&(t.shippingOptions=a),t},wc_stripe.BaseGateway.prototype.get_payment_request_update=function(t){var i={currency:this.get_currency().toLowerCase(),total:{amount:parseInt(this.get_total_price_cents()),label:this.params.total_label,pending:!0}},a=this.get_display_items(),n=this.get_shipping_options();return a&&(i.displayItems=a),this.needs_shipping()&&n&&(i.shippingOptions=n),t&&(i=e.extend(!0,{},i,t)),i},wc_stripe.BaseGateway.prototype.get_display_items=function(){return e("#wc_stripe_display_items").data("items")},wc_stripe.BaseGateway.prototype.set_display_items=function(t){e("#wc_stripe_display_items").data("items",t)},wc_stripe.BaseGateway.prototype.get_shipping_options=function(){return e("#wc_stripe_shipping_options").data("items")},wc_stripe.BaseGateway.prototype.set_shipping_options=function(t){e("#wc_stripe_shipping_options").data("items",t)},wc_stripe.BaseGateway.prototype.map_address=function(t){return{city:t.city,postcode:t.postalCode,state:t.region,country:t.country}},wc_stripe.BaseGateway.prototype.on_payment_method_received=function(e){try{this.payment_response=e,this.populate_checkout_fields(e),e.complete("success"),this.on_token_received(e.paymentMethod)}catch(e){t.alert(e)}},wc_stripe.BaseGateway.prototype.populate_checkout_fields=function(t){e(this.token_selector).val(t.paymentMethod.id),this.populate_address_fields(t)},wc_stripe.BaseGateway.prototype.populate_address_fields=function(t){var i=this.address_mappings();if(t.payerName&&i.payerName.set(t.payerName),t.payerEmail&&i.payerEmail.set(t.payerEmail),t.payerPhone&&i.payerPhone.set(t.payerPhone),t.shippingAddress){var a=t.shippingAddress;for(var n in a)i[n]&&i[n].set.call(this,a[n],"#shipping")}if(t.paymentMethod.billing_details.address){a=t.paymentMethod.billing_details.address;for(var n in a)i[n]&&i[n].set.call(this,a[n],"#billing")}this.maybe_set_ship_to_different(),e('[name="billing_country"]').trigger("change")},wc_stripe.BaseGateway.prototype.address_mappings=function(){return{payerName:{set:function(t,i){var a=t.split(" ");a.length>0&&e("#billing_first_name").val(a[0]),a.length>1&&e("#billing_last_name").val(a[1])},get:function(t){return e("#billing_first_name").val()+" "+e("#billing_last_name").val()}},payerEmail:{set:function(t){e("#billing_email").val(t)},get:function(){return e("#billing_email").val()}},payerPhone:{set:function(t){e("#billing_phone").val(t)},get:function(){return e("#billing_phone").val()}},recipient:{set:function(t,i){var a=t.split(" ");a.length>0&&e(i+"_first_name").val(a[0]),a.length>1&&e(i+"_last_name").val(a[1])},get:function(t){return e(t+"_first_name").val()+" "+e(t+"_last_name").val()}},country:{set:function(t,i){e(i+"_country").val(t)},get:function(t){return e(t+"_country").val()}},addressLine:{set:function(t,i){t.length>0&&e(i+"_address_1").val(t[0]),t.length>1&&e(i+"_address_2").val(t[1])},get:function(t){return[e(t+"_address_1").val(),e(t+"_address_2").val()]}},line1:{set:function(t,i){e(i+"_address_1").val(t)},get:function(t){return e(t+"_address_1").val()}},line2:{set:function(t,i){e(i+"_address_2").val(t)},get:function(t){return e(t+"_address_2").val()}},region:{set:function(t,i){e(i+"_state").val(t)},get:function(t){e(t+"_state").val()}},state:{set:function(t,i){e(i+"_state").val(t)},get:function(t){e(t+"_state").val()}},city:{set:function(t,i){e(i+"_city").val(t)},get:function(t){e(t+"_city").val()}},postalCode:{set:function(t,i){e(i+"_postcode").val(t)},get:function(t){e(t+"_postcode").val()}},postal_code:{set:function(t,i){e(i+"_postcode").val(t)},get:function(t){e(t+"_postcode").val()}}}},wc_stripe.BaseGateway.prototype.process_checkout=function(){return new Promise(function(i,a){this.block(),e.ajax({url:this.params.routes.checkout,method:"POST",dataType:"json",data:e.extend({},this.serialize_form(this.get_form()),{payment_method:this.gateway_id,page_id:this.get_page()}),beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",this.params.rest_nonce)}.bind(this)}).done(function(e){e.reload?t.location.reload():"success"===e.result?t.location=e.redirect:(e.messages&&this.submit_error(e.messages),this.unblock())}.bind(this)).fail(function(t,e,i){this.unblock(),this.submit_error(i)}.bind(this))}.bind(this))},wc_stripe.BaseGateway.prototype.serialize_form=function(t){var i=t.find("input").filter(function(t,i){return!e(i).is('[name^="add-to-cart"]')}.bind(this)).serializeArray(),a={};for(var n in i){var s=i[n];a[s.name]=s.value}return a.payment_method=this.gateway_id,a},wc_stripe.BaseGateway.prototype.map_shipping_methods=function(t){var e={};if("default"!==t){var i=t.match(/^(\d):(.+)$/);i.length>1&&(e[i[1]]=i[2])}return e},wc_stripe.BaseGateway.prototype.maybe_set_ship_to_different=function(){e('[name="ship_to_different_address"]').length&&e('[name="ship_to_different_address"]').prop("checked",this.get_address_field_hash("#billing")!==this.get_address_field_hash("#shipping")).trigger("change")},wc_stripe.BaseGateway.prototype.update_shipping_address=function(t){return new Promise(function(i,a){e.ajax({url:this.params.routes.shipping_address,method:"POST",dataType:"json",data:{address:this.map_address(t.shippingAddress),payment_method:this.gateway_id,page_id:this.get_page()},beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",this.params.rest_nonce)}.bind(this)}).done(function(e){e.code?(t.updateWith(e.data.newData),a(e.data)):(t.updateWith(e.data.newData),i(e.data))}.bind(this)).fail(function(t,e,i){}.bind(this))}.bind(this))},wc_stripe.BaseGateway.prototype.update_shipping_method=function(t){return new Promise(function(i,a){e.ajax({url:this.params.routes.shipping_method,method:"POST",dataType:"json",data:{shipping_methods:this.map_shipping_methods(t.shippingOption.id),payment_method:this.gateway_id,page_id:this.get_page()},beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",this.params.rest_nonce)}.bind(this)}).done(function(e){e.code?(t.updateWith(e.data.newData),a(e.data)):(this.set_selected_shipping_methods(e.data.shipping_methods),t.updateWith(e.data.newData),i(e.data))}.bind(this)).fail(function(t,e,i){this.submit_error(i)}.bind(this))}.bind(this))},wc_stripe.CheckoutGateway=function(){this.container=this.message_container="li.payment_method_"+this.gateway_id,this.banner_container="li.banner_payment_method_"+this.gateway_id,e(document.body).on("update_checkout",this.update_checkout.bind(this)),e(document.body).on("updated_checkout",this.updated_checkout.bind(this)),e(document.body).on("checkout_error",this.checkout_error.bind(this)),e(this.token_selector).closest("form").on("checkout_place_order_"+this.gateway_id,this.checkout_place_order.bind(this)),e(document.body).on("wc_stripe_new_method_"+this.gateway_id,this.on_show_new_methods.bind(this)),e(document.body).on("wc_stripe_saved_method_"+this.gateway_id,this.on_show_saved_methods.bind(this)),e(document.body).on("wc_stripe_payment_method_selected",this.on_payment_method_selected.bind(this)),this.banner_enabled()&&e(".woocommerce-billing-fields").length&&e(".wc-stripe-banner-checkout").css("max-width",e(".woocommerce-billing-fields").outerWidth(!0)),this.order_review()},wc_stripe.CheckoutGateway.prototype.order_review=function(){var e=t.location.href.match(/order_review.+payment_method=([\w]+).+payment_nonce=(.+)/);if(e&&e.length>1){var i=e[1],a=e[2];this.gateway_id===i&&(this.payment_token_received=!0,this.set_nonce(a),this.set_use_new_option(!0))}},wc_stripe.CheckoutGateway.prototype.updated_checkout=function(){},wc_stripe.CheckoutGateway.prototype.update_checkout=function(){},wc_stripe.CheckoutGateway.prototype.checkout_error=function(){this.has_checkout_error()&&(this.payment_token_received=!1,this.payment_response=null,this.show_payment_button(),this.hide_place_order())},wc_stripe.CheckoutGateway.prototype.is_valid_checkout=function(){return!(e('[name="terms"]').length&&!e('[name="terms"]').is(":checked"))},wc_stripe.CheckoutGateway.prototype.get_payment_method=function(){return e('[name="payment_method"]:checked').val()},wc_stripe.CheckoutGateway.prototype.set_use_new_option=function(t){e("#"+this.gateway_id+"_use_new").prop("checked",t).trigger("change")},wc_stripe.CheckoutGateway.prototype.checkout_place_order=function(){return this.is_valid_checkout()?!!this.is_saved_method_selected()||this.payment_token_received:(this.submit_error(this.params.messages.terms),!1)},wc_stripe.CheckoutGateway.prototype.on_token_received=function(t){this.payment_token_received=!0,e(this.token_selector).val(t.id),this.hide_payment_button(),this.show_place_order()},wc_stripe.CheckoutGateway.prototype.block=function(){e("form.checkout").block({message:null,overlayCSS:{background:"#fff",opacity:.6}})},wc_stripe.CheckoutGateway.prototype.unblock=function(){e("form.checkout").unblock()},wc_stripe.CheckoutGateway.prototype.hide_place_order=function(){e("#place_order").addClass("wc-stripe-hide")},wc_stripe.CheckoutGateway.prototype.show_place_order=function(){e("#place_order").removeClass("wc-stripe-hide")},wc_stripe.CheckoutGateway.prototype.on_show_new_methods=function(){this.payment_token_received?(this.show_place_order(),this.hide_payment_button()):(this.hide_place_order(),this.show_payment_button())},wc_stripe.CheckoutGateway.prototype.on_show_saved_methods=function(){this.hide_payment_button(),this.show_place_order()},wc_stripe.CheckoutGateway.prototype.show_payment_button=function(){this.$button&&this.$button.show()},wc_stripe.CheckoutGateway.prototype.hide_payment_button=function(){this.$button&&this.$button.hide()},wc_stripe.CheckoutGateway.prototype.trigger_payment_method_selected=function(){this.on_payment_method_selected(null,e('[name="payment_method"]:checked').val())},wc_stripe.CheckoutGateway.prototype.on_payment_method_selected=function(t,e){e===this.gateway_id?this.payment_token_received||this.is_saved_method_selected()?(this.hide_payment_button(),this.show_place_order()):(this.show_payment_button(),this.hide_place_order()):(this.hide_payment_button(),e.indexOf("stripe_")<0&&this.show_place_order())},wc_stripe.CheckoutGateway.prototype.banner_enabled=function(){return"1"===this.params.banner_enabled},wc_stripe.CheckoutGateway.prototype.checkout_fields_valid=function(){if("undefined"==typeof wc_stripe_checkout_fields)return!0;var t=Object.keys(wc_stripe_checkout_fields.billing),i=Object.keys(wc_stripe_checkout_fields.shipping);function a(t,i){for(var a=0;a<t.length;a++){if(i[t[a]].required){var n=e("#"+t[a]).val();if(void 0===n||0==n.length)return void(valid=!1)}}}return valid=!0,a(t,wc_stripe_checkout_fields.billing),this.needs_shipping()&&e("#ship-to-different-address-checkbox").is(":checked")&&a(i,wc_stripe_checkout_fields.shipping),valid=this.is_valid_checkout(),valid},wc_stripe.ProductGateway=function(){this.container="li.payment_method_"+this.gateway_id,this.message_container="div.product",e(document.body).on("wc_stripe_updated_rest_nonce",this.set_rest_nonce.bind(this)),e("form.cart").on("found_variation",this.found_variation.bind(this)),e("form.cart").on("reset_data",this.reset_variation_data.bind(this)),this.buttonWidth=e("div.quantity").outerWidth(!0)+e(".single_add_to_cart_button").outerWidth(),(marginLeft=e(".single_add_to_cart_button").css("marginLeft"))&&(this.buttonWidth+=parseInt(marginLeft.replace("px",""))),e(this.container).css("max-width",this.buttonWidth+"px")},wc_stripe.ProductGateway.prototype.get_quantity=function(){return parseInt(e('[name="quantity"]').val())},wc_stripe.ProductGateway.prototype.set_rest_nonce=function(t,e){this.params.rest_nonce=e},wc_stripe.ProductGateway.prototype.found_variation=function(t,e){var i=this.get_product_data();i.price=e.display_price,i.needs_shipping=!e.is_virtual,i.variation=e,this.set_product_data(i),this.enable_payment_button()},wc_stripe.ProductGateway.prototype.reset_variation_data=function(){this.disable_payment_button()},wc_stripe.ProductGateway.prototype.disable_payment_button=function(){this.$button&&this.get_button().prop("disabled",!0).addClass("disabled")},wc_stripe.ProductGateway.prototype.enable_payment_button=function(){this.$button&&this.get_button().prop("disabled",!1).removeClass("disabled")},wc_stripe.ProductGateway.prototype.get_button=function(){return this.$button},wc_stripe.ProductGateway.prototype.is_variable_product=function(){return e('[name="variation_id"]').length>0},wc_stripe.ProductGateway.prototype.needs_shipping=function(){return this.get_product_data().needs_shipping},wc_stripe.ProductGateway.prototype.get_product_data=function(){return e("#wc_stripe_product_data").data("product")},wc_stripe.ProductGateway.prototype.set_product_data=function(t){e("#wc_stripe_product_data").data("product",t)},wc_stripe.ProductGateway.prototype.add_to_cart=function(){return new Promise(function(t,i){this.block(),e.ajax({url:this.params.routes.add_to_cart,method:"POST",dataType:"json",data:{product_id:e("#product_id").val(),variation_id:this.is_variable_product()?e('[name="variation_id"]').val():0,qty:e('[name="quantity"]').val(),payment_method:this.gateway_id,page_id:this.get_page()},beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",this.params.rest_nonce)}.bind(this)}).done(function(a,n,s){this.unblock(),e(document.body).triggerHandler("wc_stripe_updated_rest_nonce",s.getResponseHeader("X-WP-Nonce")),a.code?(this.submit_error(a.message),i(a)):(this.set_total_price(a.data.total),this.set_total_price_cents(a.data.totalCents),this.set_display_items(a.data.displayItems),t(a.data))}.bind(this)).fail(function(t,e,i){this.unblock(),this.submit_error(i)}.bind(this))}.bind(this))},wc_stripe.ProductGateway.prototype.cart_calculation=function(t){return new Promise(function(i,a){e.ajax({url:this.params.routes.cart_calculation,method:"POST",dataType:"json",data:{product_id:e("#product_id").val(),variation_id:this.is_variable_product()&&t?t:0,qty:e('[name="quantity"]').val(),payment_method:this.gateway_id},beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",this.params.rest_nonce)}.bind(this)}).done(function(t,a,n){e(document.body).triggerHandler("wc_stripe_updated_rest_nonce",n.getResponseHeader("X-WP-Nonce")),t.code?this.cart_calculation_error=!0:(this.set_total_price(t.data.total),this.set_total_price_cents(t.data.totalCents),this.set_display_items(t.data.displayItems),i(t.data))}.bind(this)).fail(function(t,e,i){}.bind(this))}.bind(this))},wc_stripe.CartGateway=function(){this.container="li.payment_method_"+this.gateway_id,this.message_container="div.woocommerce",e(document.body).on("updated_wc_div",this.updated_html.bind(this)),e(document.body).on("updated_cart_totals",this.updated_html.bind(this))},wc_stripe.CartGateway.prototype.needs_shipping=function(){return 1===e("#wc_stripe_needs_shipping").data("value")},wc_stripe.CartGateway.prototype.submit_error=function(t){this.submit_message(this.get_error_message(t))},wc_stripe.CartGateway.prototype.updated_html=function(t){},wc_stripe.CartGateway.prototype.add_cart_totals_class=function(){e(".cart_totals").addClass("stripe_cart_gateway_active")},wc_stripe.GooglePay=function(){};const a={apiVersion:2,apiVersionMinor:0},n={type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY"],allowedCardNetworks:["AMEX","DISCOVER","INTERAC","JCB","MASTERCARD","VISA"]}};wc_stripe.GooglePay.prototype.address_mappings=function(t){return{name:{set:function(t,i){var a=t.split(" ");e(i+"_first_name").val(a[0]),e(i+"_last_name").val(a[1])},get:function(t){return e(t+"_first_name").val()+e(t+"_last_name").val()}},postalCode:{set:function(t,i){e(i+"_postcode").val(t)},get:function(t){return e(t+"_postcode").val()}},countryCode:{set:function(t,i){e(i+"_country").val(t)},get:function(t){return e(t+"_country").val()}},phoneNumber:{set:function(t,i){e("#billing_phone").val(t)},get:function(){return"#billing_phone".val()}},address1:{set:function(t,i){e(i+"_address_1").val(t)},get:function(t){return e(t+"_address_1").val()}},address2:{set:function(t,i){e(i+"_address_2").val(t)},get:function(t){return e(t+"_address_2").val()}},locality:{set:function(t,i){e(i+"_city").val(t)},get:function(t){return e(t+"_city").val()}},administrativeArea:{set:function(t,i){e(i+"_state").val(t)},get:function(t){return e(t+"_state").val()}}}},wc_stripe.GooglePay.prototype.serialize_form=function(t){return e.extend({},wc_stripe.BaseGateway.prototype.serialize_form.apply(this,arguments),{order_review:!this.dynamic_price_enabled()})},wc_stripe.GooglePay.prototype.populate_address_fields=function(t){var i=t.paymentMethodData.info.billingAddress,a=this.address_mappings();for(var n in i)a[n]&&a[n].set.call(this,i[n],"#billing");if(t.shippingAddress)for(var n in t.shippingAddress)a[n]&&a[n].set.call(this,t.shippingAddress[n],"#shipping");t.email&&e("#billing_email").val(t.email),this.maybe_set_ship_to_different(),e('[name="billing_country"]').trigger("change")},wc_stripe.GooglePay.prototype.map_address=function(t){return{city:t.locality,postcode:t.postalCode,state:t.administrativeArea,country:t.countryCode}},wc_stripe.GooglePay.prototype.update_payment_data=function(t){return new Promise(function(i,a){e.when(e.ajax({url:this.params.routes.payment_data,dataType:"json",method:"POST",data:{shipping_address:this.map_address(t.shippingAddress),shipping_methods:this.map_shipping_methods(t.shippingOptionData.id),shipping_method_id:t.shippingOptionData.id,page_id:this.get_page()},beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",this.params.rest_nonce)}.bind(this)})).done(function(t){t.code?a(t.data.data):i(t.data)}.bind(this)).fail(function(){a()}.bind(this))}.bind(this))},wc_stripe.GooglePay.prototype.on_payment_data_changed=function(t){return new Promise(function(e,i){this.update_payment_data(t).then(function(i){e(i.paymentRequestUpdate),this.set_selected_shipping_methods(i.shipping_methods),this.payment_data_updated(i,t)}.bind(this)).catch(function(t){e(t)}.bind(this))}.bind(this))},wc_stripe.GooglePay.prototype.payment_data_updated=function(t){},wc_stripe.GooglePay.prototype.get_googlepay_display_items=function(){return e("#googlepay_display_items").data("items")},wc_stripe.GooglePay.prototype.set_googlepay_display_items=function(t){e("#googlepay_display_items").data("items",t)},wc_stripe.GooglePay.prototype.get_shipping_options=function(){return e("#googlepay_shipping_options").data("items")},wc_stripe.GooglePay.prototype.get_merchant_info=function(){var t={merchantId:this.params.merchant_id,merchantName:this.params.merchant_name};return"TEST"===this.params.environment&&delete t.merchantId,t},wc_stripe.GooglePay.prototype.dynamic_price_enabled=function(){return"1"===this.params.dynamic_price},wc_stripe.GooglePay.prototype.get_payment_options=function(){var t={environment:this.params.environment,merchantInfo:this.get_merchant_info()};return this.dynamic_price_enabled()&&(this.needs_shipping()&&this.get_total_price_cents()>0?t.paymentDataCallbacks={onPaymentDataChanged:this.on_payment_data_changed.bind(this),onPaymentAuthorized:function(t){return new Promise(function(t,e){t({transactionState:"SUCCESS"})}.bind(this))}.bind(this)}:t.paymentDataCallbacks={onPaymentAuthorized:function(t){return new Promise(function(t,e){t({transactionState:"SUCCESS"})}.bind(this))}}),t},wc_stripe.GooglePay.prototype.build_payment_request=function(){var t=e.extend({},a,{emailRequired:!0,merchantInfo:this.get_merchant_info(),allowedPaymentMethods:[e.extend({type:"CARD",tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:"stripe","stripe:version":"2018-10-31","stripe:publishableKey":this.params.api_key}}},n)],shippingAddressRequired:this.needs_shipping()&&this.get_total_price_cents()>0,transactionInfo:{currencyCode:this.get_currency(),totalPriceStatus:"ESTIMATED",totalPrice:this.get_total_price().toString(),displayItems:this.get_googlepay_display_items(),totalPriceLabel:this.params.total_price_label}});return t.allowedPaymentMethods[0].parameters.billingAddressRequired=!0,t.allowedPaymentMethods[0].parameters.billingAddressParameters={format:"FULL",phoneNumberRequired:e("#billing_phone").length>0},this.dynamic_price_enabled()&&(this.needs_shipping()&&this.get_total_price_cents()>0?(t.shippingAddressParameters={},t.shippingOptionRequired=!0,t.shippingOptionParameters={shippingOptions:this.get_shipping_options()},t.callbackIntents=["SHIPPING_ADDRESS","SHIPPING_OPTION","PAYMENT_AUTHORIZATION"]):t.callbackIntents=["PAYMENT_AUTHORIZATION"]),t},wc_stripe.GooglePay.prototype.createPaymentsClient=function(){this.paymentsClient=new google.payments.api.PaymentsClient(this.get_payment_options())},wc_stripe.GooglePay.prototype.isReadyToPay=function(){return new Promise(function(t){var i=e.extend({},a);i.allowedPaymentMethods=[n],this.paymentsClient.isReadyToPay(i).then(function(){this.can_pay=!0,this.create_button(),t()}.bind(this)).catch(function(t){this.submit_error(t)}.bind(this))}.bind(this))},wc_stripe.GooglePay.prototype.create_button=function(){this.$button&&this.$button.remove(),this.$button=e(this.paymentsClient.createButton({onClick:this.start.bind(this),buttonColor:this.params.button_color,buttonType:this.params.button_style})),this.$button.addClass("gpay-button-container")},wc_stripe.GooglePay.prototype.start=function(){this.createPaymentsClient(),this.paymentsClient.loadPaymentData(this.build_payment_request()).then(function(t){var e=JSON.parse(t.paymentMethodData.tokenizationData.token);this.populate_address_fields(t),this.on_token_received(e)}.bind(this)).catch(function(t){"CANCELED"!==t.statusCode&&(t.statusMessage&&t.statusMessage.indexOf("paymentDataRequest.callbackIntent")>-1?this.submit_error_code("DEVELOPER_ERROR_WHITELIST"):this.submit_error(t.statusMessage))}.bind(this))},wc_stripe.ApplePay=function(){},wc_stripe.ApplePay.prototype.initialize=function(){e(document.body).on("click",".apple-pay-button",this.start.bind(this)),this.createPaymentRequest(),this.canMakePayment()},wc_stripe.ApplePay.prototype.create_button=function(){this.$button&&this.$button.remove(),this.$button=e(this.params.button),this.append_button()},wc_stripe.ApplePay.prototype.canMakePayment=function(){return new Promise(function(t,i){this.paymentRequest.canMakePayment().then(function(i){i&&i.applePay&&(this.can_pay=!0,this.create_button(),e(this.container).show(),t(i))}.bind(this))}.bind(this))},wc_stripe.ApplePay.prototype.start=function(t){t.preventDefault(),this.paymentRequest.update(this.get_payment_request_update({total:{pending:!1}})),this.paymentRequest.show()},wc_stripe.PaymentRequest=function(){},wc_stripe.PaymentRequest.prototype.initialize=function(){this.createPaymentRequest(),this.canMakePayment(),this.paymentRequestButton=this.createPaymentRequestButton(),this.paymentRequestButton.on("click",this.button_click.bind(this))},wc_stripe.PaymentRequest.prototype.button_click=function(t){},wc_stripe.PaymentRequest.prototype.createPaymentRequestButton=function(){return this.elements.create("paymentRequestButton",{paymentRequest:this.paymentRequest,style:{paymentRequestButton:{type:this.params.button.type,theme:this.params.button.theme,height:this.params.button.height}}})},wc_stripe.PaymentRequest.prototype.canMakePayment=function(){return new Promise(function(t,i){this.paymentRequest.canMakePayment().then(function(i){i&&!i.applePay&&(this.can_pay=!0,this.create_button(),e(this.container).show(),t(i))}.bind(this))}.bind(this))},wc_stripe.PaymentRequest.prototype.create_button=function(){this.paymentRequestButton.mount("#wc-stripe-payment-request-container")};try{i=Stripe(wc_stripe_params_v3.api_key,{stripeAccount:wc_stripe_params_v3.account})}catch(e){return t.alert(e),void console.log(e)}}(window,jQuery);
|
1 |
+
!function(t,e){t.wc_stripe={};var i=null;wc_stripe.BaseGateway=function(t){this.params=t,this.gateway_id=this.params.gateway_id,this.token_selector=this.params.token_selector,this.saved_method_selector=this.params.saved_method_selector,this.payment_intent_selector=this.params.payment_intent_selector,this.payment_token_received=!1,this.stripe=i,this.elements=i.elements(e.extend({},{locale:"auto"},this.get_element_options())),this.initialize()},wc_stripe.BaseGateway.prototype.get_page=function(){return wc_stripe_params_v3.page},wc_stripe.BaseGateway.prototype.set_nonce=function(t){e(this.token_selector).val(t)},wc_stripe.BaseGateway.prototype.get_element_options=function(){return{}},wc_stripe.BaseGateway.prototype.initialize=function(){},wc_stripe.BaseGateway.prototype.create_button=function(){},wc_stripe.BaseGateway.prototype.is_gateway_selected=function(){return e('[name="payment_method"]:checked').val()===this.gateway_id},wc_stripe.BaseGateway.prototype.is_saved_method_selected=function(){return this.is_gateway_selected()&&"saved"===e('[name="'+this.gateway_id+'_payment_type_key"]:checked').val()},wc_stripe.BaseGateway.prototype.has_checkout_error=function(){return e("#wc_stripe_checkout_error").length>0&&this.is_gateway_selected()},wc_stripe.BaseGateway.prototype.submit_error=function(t){-1==(t=this.get_error_message(t)).indexOf("</ul>")&&(t='<div class="woocommerce-error">'+t+"</div>"),this.submit_message(t)},wc_stripe.BaseGateway.prototype.submit_error_code=function(t){},wc_stripe.BaseGateway.prototype.get_error_message=function(t){return"object"==typeof t&&t.code&&(t=wc_stripe_messages[t.code]?wc_stripe_messages[t.code]:t.message),t},wc_stripe.BaseGateway.prototype.submit_message=function(t){e(".woocommerce-error, .woocommerce-message, .woocommerce-info").remove();var i=e(this.message_container);i.closest("form").length&&(i=i.closest("form")),i.prepend(t),i.removeClass("processing").unblock(),i.find(".input-text, select, input:checkbox").blur(),e.scroll_to_notices?e.scroll_to_notices(i):e("html, body").animate({scrollTop:i.offset().top-100},1e3)},wc_stripe.BaseGateway.prototype.get_first_name=function(t){return e("#"+t+"_first_name").val()},wc_stripe.BaseGateway.prototype.get_last_name=function(t){return e("#"+t+"_last_name").val()},wc_stripe.BaseGateway.prototype.should_save_method=function(){return e("#"+this.gateway_id+"_save_source_key").is(":checked")},wc_stripe.BaseGateway.prototype.is_add_payment_method_page=function(){return e(document.body).hasClass("woocommerce-add-payment-method")},wc_stripe.BaseGateway.prototype.get_selected_payment_method=function(){return e(this.saved_method_selector).val()},wc_stripe.BaseGateway.prototype.needs_shipping=function(){return"1"===this.params.needs_shipping},wc_stripe.BaseGateway.prototype.get_currency=function(){return e("#wc_stripe_currency").val()},wc_stripe.BaseGateway.prototype.get_country=function(){return e("#wc_stripe_country").val()},wc_stripe.BaseGateway.prototype.get_customer_name=function(t){return e(t+"_first_name").val()+" "+e(t+"_last_name").val()},wc_stripe.BaseGateway.prototype.get_customer_email=function(){return e("#billing_email").val()},wc_stripe.BaseGateway.prototype.get_address_field_hash=function(t){for(var i=["_first_name","_last_name","_address_1","_address_2","_postcode","_city","_state","_country"],a="",n=0;n<i.length;n++)a+=e(t+i[n]).val()+"_";return a},wc_stripe.BaseGateway.prototype.block=function(){e.blockUI({message:null,overlayCSS:{background:"#fff",opacity:.6}})},wc_stripe.BaseGateway.prototype.unblock=function(){e.unblockUI()},wc_stripe.BaseGateway.prototype.get_form=function(){return e(this.token_selector).closest("form")},wc_stripe.BaseGateway.prototype.get_total_price=function(){return e("#wc_stripe_order_total").data("amount")},wc_stripe.BaseGateway.prototype.get_total_price_cents=function(){return e("#wc_stripe_order_total_cents").data("amount")},wc_stripe.BaseGateway.prototype.set_total_price=function(t){e("#wc_stripe_order_total").data("amount",t)},wc_stripe.BaseGateway.prototype.set_total_price_cents=function(t){e("#wc_stripe_order_total_cents").data("amount",t)},wc_stripe.BaseGateway.prototype.set_payment_method=function(t){e('[name="payment_method"][value="'+t+'"]').prop("checked",!0).trigger("click")},wc_stripe.BaseGateway.prototype.set_selected_shipping_methods=function(t){if(t&&e('[name^="shipping_method"]').length)for(var i in t){var a=t[i];e('[name="shipping_method['+i+']"][value="'+a+'"]').prop("checked",!0).trigger("change")}},wc_stripe.BaseGateway.prototype.on_token_received=function(t){this.payment_token_received=!0,e(this.token_selector).val(t.id),this.process_checkout()},wc_stripe.BaseGateway.prototype.createPaymentRequest=function(){try{this.paymentRequest=i.paymentRequest(this.get_payment_request_options())}catch(t){return void this.submit_error(t.message)}this.needs_shipping()&&(this.paymentRequest.on("shippingaddresschange",this.update_shipping_address.bind(this)),this.paymentRequest.on("shippingoptionchange",this.update_shipping_method.bind(this))),this.paymentRequest.on("paymentmethod",this.on_payment_method_received.bind(this))},wc_stripe.BaseGateway.prototype.get_payment_request_options=function(){var t={country:this.params.country_code,currency:this.get_currency().toLowerCase(),total:{amount:this.get_total_price_cents(),label:this.params.total_label,pending:!0},requestPayerName:!0,requestPayerEmail:e("#billing_email").length>0,requestPayerPhone:e("#billing_phone").length>0,requestShipping:this.needs_shipping()},i=this.get_display_items(),a=this.get_shipping_options();return i&&(t.displayItems=i),this.needs_shipping()&&a&&(t.shippingOptions=a),t},wc_stripe.BaseGateway.prototype.get_payment_request_update=function(t){var i={currency:this.get_currency().toLowerCase(),total:{amount:parseInt(this.get_total_price_cents()),label:this.params.total_label,pending:!0}},a=this.get_display_items(),n=this.get_shipping_options();return a&&(i.displayItems=a),this.needs_shipping()&&n&&(i.shippingOptions=n),t&&(i=e.extend(!0,{},i,t)),i},wc_stripe.BaseGateway.prototype.get_display_items=function(){return e("#wc_stripe_display_items").data("items")},wc_stripe.BaseGateway.prototype.set_display_items=function(t){e("#wc_stripe_display_items").data("items",t)},wc_stripe.BaseGateway.prototype.get_shipping_options=function(){return e("#wc_stripe_shipping_options").data("items")},wc_stripe.BaseGateway.prototype.set_shipping_options=function(t){e("#wc_stripe_shipping_options").data("items",t)},wc_stripe.BaseGateway.prototype.map_address=function(t){return{city:t.city,postcode:t.postalCode,state:t.region,country:t.country}},wc_stripe.BaseGateway.prototype.on_payment_method_received=function(e){try{this.payment_response=e,this.populate_checkout_fields(e),e.complete("success"),this.on_token_received(e.paymentMethod)}catch(e){t.alert(e)}},wc_stripe.BaseGateway.prototype.populate_checkout_fields=function(t){e(this.token_selector).val(t.paymentMethod.id),this.populate_address_fields(t)},wc_stripe.BaseGateway.prototype.populate_address_fields=function(t){var i=this.address_mappings();if(t.payerName&&i.payerName.set(t.payerName),t.payerEmail&&i.payerEmail.set(t.payerEmail),t.payerPhone&&i.payerPhone.set(t.payerPhone),t.shippingAddress){var a=t.shippingAddress;for(var n in a)i[n]&&i[n].set.call(this,a[n],"#shipping")}if(t.paymentMethod.billing_details.address){a=t.paymentMethod.billing_details.address;for(var n in a)i[n]&&i[n].set.call(this,a[n],"#billing")}this.maybe_set_ship_to_different(),e('[name="billing_country"]').trigger("change")},wc_stripe.BaseGateway.prototype.address_mappings=function(){return{payerName:{set:function(t,i){var a=t.split(" ");a.length>0&&e("#billing_first_name").val(a[0]),a.length>1&&e("#billing_last_name").val(a[1])},get:function(t){return e("#billing_first_name").val()+" "+e("#billing_last_name").val()}},payerEmail:{set:function(t){e("#billing_email").val(t)},get:function(){return e("#billing_email").val()}},payerPhone:{set:function(t){e("#billing_phone").val(t)},get:function(){return e("#billing_phone").val()}},recipient:{set:function(t,i){var a=t.split(" ");a.length>0&&e(i+"_first_name").val(a[0]),a.length>1&&e(i+"_last_name").val(a[1])},get:function(t){return e(t+"_first_name").val()+" "+e(t+"_last_name").val()}},country:{set:function(t,i){e(i+"_country").val(t)},get:function(t){return e(t+"_country").val()}},addressLine:{set:function(t,i){t.length>0&&e(i+"_address_1").val(t[0]),t.length>1&&e(i+"_address_2").val(t[1])},get:function(t){return[e(t+"_address_1").val(),e(t+"_address_2").val()]}},line1:{set:function(t,i){e(i+"_address_1").val(t)},get:function(t){return e(t+"_address_1").val()}},line2:{set:function(t,i){e(i+"_address_2").val(t)},get:function(t){return e(t+"_address_2").val()}},region:{set:function(t,i){e(i+"_state").val(t)},get:function(t){e(t+"_state").val()}},state:{set:function(t,i){e(i+"_state").val(t)},get:function(t){e(t+"_state").val()}},city:{set:function(t,i){e(i+"_city").val(t)},get:function(t){e(t+"_city").val()}},postalCode:{set:function(t,i){e(i+"_postcode").val(t)},get:function(t){e(t+"_postcode").val()}},postal_code:{set:function(t,i){e(i+"_postcode").val(t)},get:function(t){e(t+"_postcode").val()}}}},wc_stripe.BaseGateway.prototype.process_checkout=function(){return new Promise(function(i,a){this.block(),e.ajax({url:this.params.routes.checkout,method:"POST",dataType:"json",data:e.extend({},this.serialize_form(this.get_form()),{payment_method:this.gateway_id,page_id:this.get_page()}),beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",this.params.rest_nonce)}.bind(this)}).done(function(e){e.reload?t.location.reload():"success"===e.result?t.location=e.redirect:(e.messages&&this.submit_error(e.messages),this.unblock())}.bind(this)).fail(function(t,e,i){this.unblock(),this.submit_error(i)}.bind(this))}.bind(this))},wc_stripe.BaseGateway.prototype.serialize_form=function(t){var i=t.find("input").filter(function(t,i){return!e(i).is('[name^="add-to-cart"]')}.bind(this)).serializeArray(),a={};for(var n in i){var s=i[n];a[s.name]=s.value}return a.payment_method=this.gateway_id,a},wc_stripe.BaseGateway.prototype.map_shipping_methods=function(t){var e={};if("default"!==t){var i=t.match(/^(\d):(.+)$/);i.length>1&&(e[i[1]]=i[2])}return e},wc_stripe.BaseGateway.prototype.maybe_set_ship_to_different=function(){e('[name="ship_to_different_address"]').length&&e('[name="ship_to_different_address"]').prop("checked",this.get_address_field_hash("#billing")!==this.get_address_field_hash("#shipping")).trigger("change")},wc_stripe.BaseGateway.prototype.update_shipping_address=function(t){return new Promise(function(i,a){e.ajax({url:this.params.routes.shipping_address,method:"POST",dataType:"json",data:{address:this.map_address(t.shippingAddress),payment_method:this.gateway_id,page_id:this.get_page()},beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",this.params.rest_nonce)}.bind(this)}).done(function(e){e.code?(t.updateWith(e.data.newData),a(e.data)):(t.updateWith(e.data.newData),i(e.data))}.bind(this)).fail(function(t,e,i){}.bind(this))}.bind(this))},wc_stripe.BaseGateway.prototype.update_shipping_method=function(t){return new Promise(function(i,a){e.ajax({url:this.params.routes.shipping_method,method:"POST",dataType:"json",data:{shipping_methods:this.map_shipping_methods(t.shippingOption.id),payment_method:this.gateway_id,page_id:this.get_page()},beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",this.params.rest_nonce)}.bind(this)}).done(function(e){e.code?(t.updateWith(e.data.newData),a(e.data)):(this.set_selected_shipping_methods(e.data.shipping_methods),t.updateWith(e.data.newData),i(e.data))}.bind(this)).fail(function(t,e,i){this.submit_error(i)}.bind(this))}.bind(this))},wc_stripe.CheckoutGateway=function(){this.container=this.message_container="li.payment_method_"+this.gateway_id,this.banner_container="li.banner_payment_method_"+this.gateway_id,e(document.body).on("update_checkout",this.update_checkout.bind(this)),e(document.body).on("updated_checkout",this.updated_checkout.bind(this)),e(document.body).on("checkout_error",this.checkout_error.bind(this)),e(this.token_selector).closest("form").on("checkout_place_order_"+this.gateway_id,this.checkout_place_order.bind(this)),e(document.body).on("wc_stripe_new_method_"+this.gateway_id,this.on_show_new_methods.bind(this)),e(document.body).on("wc_stripe_saved_method_"+this.gateway_id,this.on_show_saved_methods.bind(this)),e(document.body).on("wc_stripe_payment_method_selected",this.on_payment_method_selected.bind(this)),this.banner_enabled()&&e(".woocommerce-billing-fields").length&&e(".wc-stripe-banner-checkout").css("max-width",e(".woocommerce-billing-fields").outerWidth(!0)),this.order_review()},wc_stripe.CheckoutGateway.prototype.order_review=function(){var e=t.location.href.match(/order_review.+payment_method=([\w]+).+payment_nonce=(.+)/);if(e&&e.length>1){var i=e[1],a=e[2];this.gateway_id===i&&(this.payment_token_received=!0,this.set_nonce(a),this.set_use_new_option(!0))}},wc_stripe.CheckoutGateway.prototype.updated_checkout=function(){},wc_stripe.CheckoutGateway.prototype.update_checkout=function(){},wc_stripe.CheckoutGateway.prototype.checkout_error=function(){this.has_checkout_error()&&(this.payment_token_received=!1,this.payment_response=null,this.show_payment_button(),this.hide_place_order())},wc_stripe.CheckoutGateway.prototype.is_valid_checkout=function(){return!(e('[name="terms"]').length&&!e('[name="terms"]').is(":checked"))},wc_stripe.CheckoutGateway.prototype.get_payment_method=function(){return e('[name="payment_method"]:checked').val()},wc_stripe.CheckoutGateway.prototype.set_use_new_option=function(t){e("#"+this.gateway_id+"_use_new").prop("checked",t).trigger("change")},wc_stripe.CheckoutGateway.prototype.checkout_place_order=function(){return this.is_valid_checkout()?!!this.is_saved_method_selected()||this.payment_token_received:(this.submit_error(this.params.messages.terms),!1)},wc_stripe.CheckoutGateway.prototype.on_token_received=function(t){this.payment_token_received=!0,e(this.token_selector).val(t.id),this.hide_payment_button(),this.show_place_order()},wc_stripe.CheckoutGateway.prototype.block=function(){e("form.checkout").block({message:null,overlayCSS:{background:"#fff",opacity:.6}})},wc_stripe.CheckoutGateway.prototype.unblock=function(){e("form.checkout").unblock()},wc_stripe.CheckoutGateway.prototype.hide_place_order=function(){e("#place_order").addClass("wc-stripe-hide")},wc_stripe.CheckoutGateway.prototype.show_place_order=function(){e("#place_order").removeClass("wc-stripe-hide")},wc_stripe.CheckoutGateway.prototype.on_show_new_methods=function(){this.payment_token_received?(this.show_place_order(),this.hide_payment_button()):(this.hide_place_order(),this.show_payment_button())},wc_stripe.CheckoutGateway.prototype.on_show_saved_methods=function(){this.hide_payment_button(),this.show_place_order()},wc_stripe.CheckoutGateway.prototype.show_payment_button=function(){this.$button&&this.$button.show()},wc_stripe.CheckoutGateway.prototype.hide_payment_button=function(){this.$button&&this.$button.hide()},wc_stripe.CheckoutGateway.prototype.trigger_payment_method_selected=function(){this.on_payment_method_selected(null,e('[name="payment_method"]:checked').val())},wc_stripe.CheckoutGateway.prototype.on_payment_method_selected=function(t,e){e===this.gateway_id?this.payment_token_received||this.is_saved_method_selected()?(this.hide_payment_button(),this.show_place_order()):(this.show_payment_button(),this.hide_place_order()):(this.hide_payment_button(),e.indexOf("stripe_")<0&&this.show_place_order())},wc_stripe.CheckoutGateway.prototype.banner_enabled=function(){return"1"===this.params.banner_enabled},wc_stripe.CheckoutGateway.prototype.checkout_fields_valid=function(){if("undefined"==typeof wc_stripe_checkout_fields)return!0;var t=Object.keys(wc_stripe_checkout_fields.billing),i=Object.keys(wc_stripe_checkout_fields.shipping);function a(t,i){for(var a=0;a<t.length;a++){if(i[t[a]].required){var n=e("#"+t[a]).val();if(void 0===n||0==n.length)return void(valid=!1)}}}return valid=!0,a(t,wc_stripe_checkout_fields.billing),this.needs_shipping()&&e("#ship-to-different-address-checkbox").is(":checked")&&a(i,wc_stripe_checkout_fields.shipping),valid=this.is_valid_checkout(),valid},wc_stripe.ProductGateway=function(){this.container="li.payment_method_"+this.gateway_id,this.message_container="div.product",e(document.body).on("wc_stripe_updated_rest_nonce",this.set_rest_nonce.bind(this)),e("form.cart").on("found_variation",this.found_variation.bind(this)),e("form.cart").on("reset_data",this.reset_variation_data.bind(this)),this.buttonWidth=e("div.quantity").outerWidth(!0)+e(".single_add_to_cart_button").outerWidth(),(marginLeft=e(".single_add_to_cart_button").css("marginLeft"))&&(this.buttonWidth+=parseInt(marginLeft.replace("px",""))),e(this.container).css("max-width",this.buttonWidth+"px")},wc_stripe.ProductGateway.prototype.get_quantity=function(){return parseInt(e('[name="quantity"]').val())},wc_stripe.ProductGateway.prototype.set_rest_nonce=function(t,e){this.params.rest_nonce=e},wc_stripe.ProductGateway.prototype.found_variation=function(t,e){var i=this.get_product_data();i.price=e.display_price,i.needs_shipping=!e.is_virtual,i.variation=e,this.set_product_data(i),this.enable_payment_button()},wc_stripe.ProductGateway.prototype.reset_variation_data=function(){this.disable_payment_button()},wc_stripe.ProductGateway.prototype.disable_payment_button=function(){this.$button&&this.get_button().prop("disabled",!0).addClass("disabled")},wc_stripe.ProductGateway.prototype.enable_payment_button=function(){this.$button&&this.get_button().prop("disabled",!1).removeClass("disabled")},wc_stripe.ProductGateway.prototype.get_button=function(){return this.$button},wc_stripe.ProductGateway.prototype.is_variable_product=function(){return e('[name="variation_id"]').length>0},wc_stripe.ProductGateway.prototype.needs_shipping=function(){return this.get_product_data().needs_shipping},wc_stripe.ProductGateway.prototype.get_product_data=function(){return e("#wc_stripe_product_data").data("product")},wc_stripe.ProductGateway.prototype.set_product_data=function(t){e("#wc_stripe_product_data").data("product",t)},wc_stripe.ProductGateway.prototype.add_to_cart=function(){return new Promise(function(t,i){this.block(),e.ajax({url:this.params.routes.add_to_cart,method:"POST",dataType:"json",data:{product_id:e("#product_id").val(),variation_id:this.is_variable_product()?e('[name="variation_id"]').val():0,qty:e('[name="quantity"]').val(),payment_method:this.gateway_id,page_id:this.get_page()},beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",this.params.rest_nonce)}.bind(this)}).done(function(a,n,s){this.unblock(),e(document.body).triggerHandler("wc_stripe_updated_rest_nonce",s.getResponseHeader("X-WP-Nonce")),a.code?(this.submit_error(a.message),i(a)):(this.set_total_price(a.data.total),this.set_total_price_cents(a.data.totalCents),this.set_display_items(a.data.displayItems),t(a.data))}.bind(this)).fail(function(t,e,i){this.unblock(),this.submit_error(i)}.bind(this))}.bind(this))},wc_stripe.ProductGateway.prototype.cart_calculation=function(t){return new Promise(function(i,a){e.ajax({url:this.params.routes.cart_calculation,method:"POST",dataType:"json",data:{product_id:e("#product_id").val(),variation_id:this.is_variable_product()&&t?t:0,qty:e('[name="quantity"]').val(),payment_method:this.gateway_id},beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",this.params.rest_nonce)}.bind(this)}).done(function(t,a,n){e(document.body).triggerHandler("wc_stripe_updated_rest_nonce",n.getResponseHeader("X-WP-Nonce")),t.code?this.cart_calculation_error=!0:(this.set_total_price(t.data.total),this.set_total_price_cents(t.data.totalCents),this.set_display_items(t.data.displayItems),i(t.data))}.bind(this)).fail(function(t,e,i){}.bind(this))}.bind(this))},wc_stripe.CartGateway=function(){this.container="li.payment_method_"+this.gateway_id,this.message_container="div.woocommerce",e(document.body).on("updated_wc_div",this.updated_html.bind(this)),e(document.body).on("updated_cart_totals",this.updated_html.bind(this)),e(document.body).on("wc_cart_emptied",this.cart_emptied.bind(this))},wc_stripe.CartGateway.prototype.needs_shipping=function(){return 1===e("#wc_stripe_needs_shipping").data("value")},wc_stripe.CartGateway.prototype.submit_error=function(t){this.submit_message(this.get_error_message(t))},wc_stripe.CartGateway.prototype.updated_html=function(t){},wc_stripe.CartGateway.prototype.cart_emptied=function(t){},wc_stripe.CartGateway.prototype.add_cart_totals_class=function(){e(".cart_totals").addClass("stripe_cart_gateway_active")},wc_stripe.GooglePay=function(){};const a={apiVersion:2,apiVersionMinor:0},n={type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY"],allowedCardNetworks:["AMEX","DISCOVER","INTERAC","JCB","MASTERCARD","VISA"]}};wc_stripe.GooglePay.prototype.address_mappings=function(t){return{name:{set:function(t,i){var a=t.split(" ");e(i+"_first_name").val(a[0]),e(i+"_last_name").val(a[1])},get:function(t){return e(t+"_first_name").val()+e(t+"_last_name").val()}},postalCode:{set:function(t,i){e(i+"_postcode").val(t)},get:function(t){return e(t+"_postcode").val()}},countryCode:{set:function(t,i){e(i+"_country").val(t)},get:function(t){return e(t+"_country").val()}},phoneNumber:{set:function(t,i){e("#billing_phone").val(t)},get:function(){return"#billing_phone".val()}},address1:{set:function(t,i){e(i+"_address_1").val(t)},get:function(t){return e(t+"_address_1").val()}},address2:{set:function(t,i){e(i+"_address_2").val(t)},get:function(t){return e(t+"_address_2").val()}},locality:{set:function(t,i){e(i+"_city").val(t)},get:function(t){return e(t+"_city").val()}},administrativeArea:{set:function(t,i){e(i+"_state").val(t)},get:function(t){return e(t+"_state").val()}}}},wc_stripe.GooglePay.prototype.serialize_form=function(t){return e.extend({},wc_stripe.BaseGateway.prototype.serialize_form.apply(this,arguments),{order_review:!this.dynamic_price_enabled()})},wc_stripe.GooglePay.prototype.populate_address_fields=function(t){var i=t.paymentMethodData.info.billingAddress,a=this.address_mappings();for(var n in i)a[n]&&a[n].set.call(this,i[n],"#billing");if(t.shippingAddress)for(var n in t.shippingAddress)a[n]&&a[n].set.call(this,t.shippingAddress[n],"#shipping");t.email&&e("#billing_email").val(t.email),this.maybe_set_ship_to_different(),e('[name="billing_country"]').trigger("change")},wc_stripe.GooglePay.prototype.map_address=function(t){return{city:t.locality,postcode:t.postalCode,state:t.administrativeArea,country:t.countryCode}},wc_stripe.GooglePay.prototype.update_payment_data=function(t){return new Promise(function(i,a){e.when(e.ajax({url:this.params.routes.payment_data,dataType:"json",method:"POST",data:{shipping_address:this.map_address(t.shippingAddress),shipping_methods:this.map_shipping_methods(t.shippingOptionData.id),shipping_method_id:t.shippingOptionData.id,page_id:this.get_page()},beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",this.params.rest_nonce)}.bind(this)})).done(function(t){t.code?a(t.data.data):i(t.data)}.bind(this)).fail(function(){a()}.bind(this))}.bind(this))},wc_stripe.GooglePay.prototype.on_payment_data_changed=function(t){return new Promise(function(e,i){this.update_payment_data(t).then(function(i){e(i.paymentRequestUpdate),this.set_selected_shipping_methods(i.shipping_methods),this.payment_data_updated(i,t)}.bind(this)).catch(function(t){e(t)}.bind(this))}.bind(this))},wc_stripe.GooglePay.prototype.payment_data_updated=function(t){},wc_stripe.GooglePay.prototype.get_googlepay_display_items=function(){return e("#googlepay_display_items").data("items")},wc_stripe.GooglePay.prototype.set_googlepay_display_items=function(t){e("#googlepay_display_items").data("items",t)},wc_stripe.GooglePay.prototype.get_shipping_options=function(){return e("#googlepay_shipping_options").data("items")},wc_stripe.GooglePay.prototype.get_merchant_info=function(){var t={merchantId:this.params.merchant_id,merchantName:this.params.merchant_name};return"TEST"===this.params.environment&&delete t.merchantId,t},wc_stripe.GooglePay.prototype.dynamic_price_enabled=function(){return"1"===this.params.dynamic_price},wc_stripe.GooglePay.prototype.get_payment_options=function(){var t={environment:this.params.environment,merchantInfo:this.get_merchant_info()};return this.dynamic_price_enabled()&&(this.needs_shipping()&&this.get_total_price_cents()>0?t.paymentDataCallbacks={onPaymentDataChanged:this.on_payment_data_changed.bind(this),onPaymentAuthorized:function(t){return new Promise(function(t,e){t({transactionState:"SUCCESS"})}.bind(this))}.bind(this)}:t.paymentDataCallbacks={onPaymentAuthorized:function(t){return new Promise(function(t,e){t({transactionState:"SUCCESS"})}.bind(this))}}),t},wc_stripe.GooglePay.prototype.build_payment_request=function(){var t=e.extend({},a,{emailRequired:!0,merchantInfo:this.get_merchant_info(),allowedPaymentMethods:[e.extend({type:"CARD",tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:"stripe","stripe:version":"2018-10-31","stripe:publishableKey":this.params.api_key}}},n)],shippingAddressRequired:this.needs_shipping()&&this.get_total_price_cents()>0,transactionInfo:{currencyCode:this.get_currency(),totalPriceStatus:"ESTIMATED",totalPrice:this.get_total_price().toString(),displayItems:this.get_googlepay_display_items(),totalPriceLabel:this.params.total_price_label}});return t.allowedPaymentMethods[0].parameters.billingAddressRequired=!0,t.allowedPaymentMethods[0].parameters.billingAddressParameters={format:"FULL",phoneNumberRequired:e("#billing_phone").length>0},this.dynamic_price_enabled()&&(this.needs_shipping()&&this.get_total_price_cents()>0?(t.shippingAddressParameters={},t.shippingOptionRequired=!0,t.shippingOptionParameters={shippingOptions:this.get_shipping_options()},t.callbackIntents=["SHIPPING_ADDRESS","SHIPPING_OPTION","PAYMENT_AUTHORIZATION"]):t.callbackIntents=["PAYMENT_AUTHORIZATION"]),t},wc_stripe.GooglePay.prototype.createPaymentsClient=function(){this.paymentsClient=new google.payments.api.PaymentsClient(this.get_payment_options())},wc_stripe.GooglePay.prototype.isReadyToPay=function(){return new Promise(function(t){var i=e.extend({},a);i.allowedPaymentMethods=[n],this.paymentsClient.isReadyToPay(i).then(function(){this.can_pay=!0,this.create_button(),t()}.bind(this)).catch(function(t){this.submit_error(t)}.bind(this))}.bind(this))},wc_stripe.GooglePay.prototype.create_button=function(){this.$button&&this.$button.remove(),this.$button=e(this.paymentsClient.createButton({onClick:this.start.bind(this),buttonColor:this.params.button_color,buttonType:this.params.button_style})),this.$button.addClass("gpay-button-container")},wc_stripe.GooglePay.prototype.start=function(){this.createPaymentsClient(),this.paymentsClient.loadPaymentData(this.build_payment_request()).then(function(t){var e=JSON.parse(t.paymentMethodData.tokenizationData.token);this.populate_address_fields(t),this.on_token_received(e)}.bind(this)).catch(function(t){"CANCELED"!==t.statusCode&&(t.statusMessage&&t.statusMessage.indexOf("paymentDataRequest.callbackIntent")>-1?this.submit_error_code("DEVELOPER_ERROR_WHITELIST"):this.submit_error(t.statusMessage))}.bind(this))},wc_stripe.ApplePay=function(){},wc_stripe.ApplePay.prototype.initialize=function(){e(document.body).on("click",".apple-pay-button",this.start.bind(this)),this.createPaymentRequest(),this.canMakePayment()},wc_stripe.ApplePay.prototype.create_button=function(){this.$button&&this.$button.remove(),this.$button=e(this.params.button),this.append_button()},wc_stripe.ApplePay.prototype.canMakePayment=function(){return new Promise(function(t,i){this.paymentRequest.canMakePayment().then(function(i){i&&i.applePay&&(this.can_pay=!0,this.create_button(),e(this.container).show(),t(i))}.bind(this))}.bind(this))},wc_stripe.ApplePay.prototype.start=function(t){t.preventDefault(),this.paymentRequest.update(this.get_payment_request_update({total:{pending:!1}})),this.paymentRequest.show()},wc_stripe.PaymentRequest=function(){},wc_stripe.PaymentRequest.prototype.initialize=function(){this.createPaymentRequest(),this.canMakePayment(),this.paymentRequestButton=this.createPaymentRequestButton(),this.paymentRequestButton.on("click",this.button_click.bind(this))},wc_stripe.PaymentRequest.prototype.button_click=function(t){},wc_stripe.PaymentRequest.prototype.createPaymentRequestButton=function(){return this.elements.create("paymentRequestButton",{paymentRequest:this.paymentRequest,style:{paymentRequestButton:{type:this.params.button.type,theme:this.params.button.theme,height:this.params.button.height}}})},wc_stripe.PaymentRequest.prototype.canMakePayment=function(){return new Promise(function(t,i){this.paymentRequest.canMakePayment().then(function(i){i&&!i.applePay&&(this.can_pay=!0,this.create_button(),e(this.container).show(),t(i))}.bind(this))}.bind(this))},wc_stripe.PaymentRequest.prototype.create_button=function(){this.paymentRequestButton.mount("#wc-stripe-payment-request-container")};try{i=Stripe(wc_stripe_params_v3.api_key,{stripeAccount:wc_stripe_params_v3.account})}catch(e){return t.alert(e),void console.log(e)}}(window,jQuery);
|
i18n/languages/woo-stripe-payment.pot
CHANGED
@@ -2,14 +2,14 @@
|
|
2 |
# This file is distributed under the same license as the Stripe For WooCommerce plugin.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: Stripe For WooCommerce 3.1.
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/woo-stripe-payment\n"
|
7 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
8 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
9 |
"MIME-Version: 1.0\n"
|
10 |
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
"Content-Transfer-Encoding: 8bit\n"
|
12 |
-
"POT-Creation-Date: 2020-
|
13 |
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
14 |
"X-Generator: WP-CLI 2.4.0\n"
|
15 |
"X-Domain: woo-stripe-payment\n"
|
@@ -30,212 +30,212 @@ msgstr ""
|
|
30 |
msgid "Payment Plugins, support@paymentplugins.com"
|
31 |
msgstr ""
|
32 |
|
33 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:
|
34 |
-
#: includes/admin/meta-boxes/views/html-product-data.php:
|
35 |
-
#: includes/gateways/settings/ach-settings-v2.php:
|
36 |
-
#: includes/gateways/settings/ach-settings.php:
|
37 |
-
#: includes/gateways/settings/applepay-settings.php:
|
38 |
#: includes/gateways/settings/cc-settings.php:4
|
39 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
40 |
-
#: includes/gateways/settings/payment-request-settings.php:
|
41 |
msgid "Enabled"
|
42 |
msgstr ""
|
43 |
|
44 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:
|
45 |
msgid "If enabled, your site can accept %s payments through Stripe."
|
46 |
msgstr ""
|
47 |
|
48 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:
|
49 |
-
#: includes/gateways/settings/ach-settings-v2.php:
|
50 |
-
#: includes/gateways/settings/ach-settings.php:
|
51 |
-
#: includes/gateways/settings/applepay-settings.php:
|
52 |
-
#: includes/gateways/settings/cc-settings.php:
|
53 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
54 |
-
#: includes/gateways/settings/payment-request-settings.php:
|
55 |
msgid "General Settings"
|
56 |
msgstr ""
|
57 |
|
58 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:
|
59 |
#: includes/admin/meta-boxes/views/html-charge-data-subview.php:47
|
60 |
-
#: includes/gateways/settings/ach-settings-v2.php:
|
61 |
-
#: includes/gateways/settings/ach-settings.php:
|
62 |
-
#: includes/gateways/settings/applepay-settings.php:
|
63 |
-
#: includes/gateways/settings/cc-settings.php:
|
64 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
65 |
-
#: includes/gateways/settings/payment-request-settings.php:
|
66 |
msgid "Title"
|
67 |
msgstr ""
|
68 |
|
69 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:
|
70 |
-
#: includes/gateways/settings/ach-settings-v2.php:
|
71 |
-
#: includes/gateways/settings/ach-settings.php:
|
72 |
-
#: includes/gateways/settings/applepay-settings.php:
|
73 |
-
#: includes/gateways/settings/cc-settings.php:
|
74 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
75 |
-
#: includes/gateways/settings/payment-request-settings.php:
|
76 |
msgid "Description"
|
77 |
msgstr ""
|
78 |
|
79 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:
|
80 |
-
#: includes/gateways/settings/ach-settings-v2.php:
|
81 |
-
#: includes/gateways/settings/ach-settings.php:
|
82 |
-
#: includes/gateways/settings/applepay-settings.php:
|
83 |
-
#: includes/gateways/settings/cc-settings.php:
|
84 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
85 |
-
#: includes/gateways/settings/payment-request-settings.php:
|
86 |
msgid "Leave blank if you don't want a description to show for the gateway."
|
87 |
msgstr ""
|
88 |
|
89 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:
|
90 |
msgid "Order %s"
|
91 |
msgstr ""
|
92 |
|
93 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:
|
94 |
msgid "Gateway will appear when store currency is <strong>%s</strong>"
|
95 |
msgstr ""
|
96 |
|
97 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:
|
98 |
msgid " & billing country is <strong>%s</strong>"
|
99 |
msgstr ""
|
100 |
|
101 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
102 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-ach.php:
|
103 |
msgid "Error processing payment. Reason: %s"
|
104 |
msgstr ""
|
105 |
|
106 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
107 |
-
msgid "Charge %s is pending. Payment Method: %s. Payment will be completed once charge.succeeded webhook received from Stripe."
|
108 |
msgstr ""
|
109 |
|
110 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
111 |
-
msgid "Order %s successful in Stripe. Charge: %s. Payment Method: %s"
|
112 |
msgstr ""
|
113 |
|
114 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
115 |
msgid "charge"
|
116 |
msgstr ""
|
117 |
|
118 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
119 |
msgid "authorization"
|
120 |
msgstr ""
|
121 |
|
122 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
123 |
-
#: includes/controllers/class-wc-stripe-controller-cart.php:
|
124 |
-
#: includes/controllers/class-wc-stripe-controller-cart.php:
|
125 |
-
#: includes/controllers/class-wc-stripe-controller-googlepay.php:
|
126 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:
|
127 |
msgid "Total"
|
128 |
msgstr ""
|
129 |
|
130 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
131 |
msgid "User must be logged in."
|
132 |
msgstr ""
|
133 |
|
134 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
135 |
msgid "Error saving your payment method. Reason: %s"
|
136 |
msgstr ""
|
137 |
|
138 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
139 |
msgid "Error saving payment method. Reason: %s"
|
140 |
msgstr ""
|
141 |
|
142 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
143 |
msgid "Order refunded in Stripe. Amount: %s"
|
144 |
msgstr ""
|
145 |
|
146 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
147 |
msgid "Order amount captured in Stripe. Amount: %s"
|
148 |
msgstr ""
|
149 |
|
150 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
151 |
msgid "Error capturing charge in Stripe. Reason: %s"
|
152 |
msgstr ""
|
153 |
|
154 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
155 |
msgid "Error voiding charge. Reason: %s"
|
156 |
msgstr ""
|
157 |
|
158 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
159 |
msgid "Charge voided in Stripe."
|
160 |
msgstr ""
|
161 |
|
162 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
163 |
msgid "n/a"
|
164 |
msgstr ""
|
165 |
|
166 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
167 |
#: includes/admin/meta-boxes/views/html-order-pay.php:42
|
168 |
msgid "New Card"
|
169 |
msgstr ""
|
170 |
|
171 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
172 |
#: includes/admin/meta-boxes/views/html-order-pay.php:30
|
173 |
msgid "Saved Cards"
|
174 |
msgstr ""
|
175 |
|
176 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
177 |
msgid "Attemp to save payment method failed. Reason: %s"
|
178 |
msgstr ""
|
179 |
|
180 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
181 |
msgid "We were not able to save your payment method. To prevent billing issues with your subscription, please add a payment method to the subscription."
|
182 |
msgstr ""
|
183 |
|
184 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
185 |
msgid "We were not able to save your payment method. Reason: %s"
|
186 |
msgstr ""
|
187 |
|
188 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
189 |
msgid "Payment Method Token"
|
190 |
msgstr ""
|
191 |
|
192 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
193 |
msgid "Recurring payment for order failed. Reason: %s"
|
194 |
msgstr ""
|
195 |
|
196 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
197 |
msgid "Recurring payment captured in Stripe. Payment method: %s"
|
198 |
msgstr ""
|
199 |
|
200 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
201 |
msgid "Recurring payment authorized in Stripe. Payment method: %s"
|
202 |
msgstr ""
|
203 |
|
204 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
205 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
206 |
msgid "Customer must manually complete payment for payment method %s"
|
207 |
msgstr ""
|
208 |
|
209 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
210 |
msgid "Error saving payment method for subscription. Reason: %s"
|
211 |
msgstr ""
|
212 |
|
213 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
214 |
-
#: includes/abstract/abstract-wc-stripe-payment.php:
|
215 |
-
msgid "Order %s from %s"
|
216 |
msgstr ""
|
217 |
|
218 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
219 |
msgid "Pre-order payment for order failed. Reason: %s"
|
220 |
msgstr ""
|
221 |
|
222 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
223 |
msgid "Pre-order payment captured in Stripe. Payment method: %s"
|
224 |
msgstr ""
|
225 |
|
226 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
227 |
msgid "Pre-order payment authorized in Stripe. Payment method: %s"
|
228 |
msgstr ""
|
229 |
|
230 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
231 |
msgid "Cannot process payment"
|
232 |
msgstr ""
|
233 |
|
234 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
235 |
msgid "Increase your conversion rate by offering %1$s on your Product and Cart pages, or at the top of the checkout page. <br/><strong>Note:</strong> you can control which products display %s by going to the product edit page."
|
236 |
msgstr ""
|
237 |
|
238 |
-
#: includes/abstract/abstract-wc-stripe-payment.php:
|
239 |
msgid "Transaction Id cannot be empty."
|
240 |
msgstr ""
|
241 |
|
@@ -243,55 +243,55 @@ msgstr ""
|
|
243 |
msgid "You do not have permissions to access this resource."
|
244 |
msgstr ""
|
245 |
|
246 |
-
#: includes/admin/class-wc-stripe-admin-menus.php:
|
247 |
msgid "Stripe Gateway"
|
248 |
msgstr ""
|
249 |
|
250 |
-
#: includes/admin/class-wc-stripe-admin-menus.php:
|
251 |
-
#: includes/class-wc-stripe-install.php:
|
252 |
msgid "Settings"
|
253 |
msgstr ""
|
254 |
|
255 |
-
#: includes/admin/class-wc-stripe-admin-menus.php:
|
256 |
msgid "Logs"
|
257 |
msgstr ""
|
258 |
|
259 |
-
#: includes/admin/class-wc-stripe-admin-menus.php:
|
260 |
-
#: includes/admin/views/html-settings-nav.php:
|
261 |
-
#: includes/class-wc-stripe-install.php:
|
262 |
msgid "Documentation"
|
263 |
msgstr ""
|
264 |
|
265 |
#: includes/admin/class-wc-stripe-admin-notices.php:51
|
266 |
msgid ""
|
267 |
-
"At Stripe's request we have updated how the Stripe for WooCommerce\
|
268 |
-
"
|
269 |
-
"
|
270 |
msgstr ""
|
271 |
|
272 |
-
#: includes/admin/class-wc-stripe-admin-settings.php:
|
273 |
msgid "Local Gateways"
|
274 |
msgstr ""
|
275 |
|
276 |
-
#: includes/admin/class-wc-stripe-admin-settings.php:
|
277 |
msgid "Stripe Email Options"
|
278 |
msgstr ""
|
279 |
|
280 |
-
#: includes/admin/class-wc-stripe-admin-settings.php:
|
281 |
msgid "Email Receipt"
|
282 |
msgstr ""
|
283 |
|
284 |
-
#: includes/admin/class-wc-stripe-admin-settings.php:
|
285 |
msgid "If enabled, an email receipt will be sent to the customer by Stripe when the order is processed."
|
286 |
msgstr ""
|
287 |
|
288 |
-
#: includes/admin/meta-boxes/class-wc-stripe-admin-meta-box-product-data.php:
|
289 |
msgid "Stripe Settings"
|
290 |
msgstr ""
|
291 |
|
292 |
#: includes/admin/meta-boxes/views/html-charge-data-subview.php:9
|
293 |
-
#: includes/admin/views/html-user-profile.php:
|
294 |
-
#: includes/admin/views/html-user-profile.php:
|
295 |
msgid "Actions"
|
296 |
msgstr ""
|
297 |
|
@@ -300,13 +300,13 @@ msgid "capture amount"
|
|
300 |
msgstr ""
|
301 |
|
302 |
#: includes/admin/meta-boxes/views/html-charge-data-subview.php:14
|
303 |
-
#: includes/admin/meta-boxes/views/html-order-actions.php:
|
304 |
#: includes/admin/meta-boxes/views/html-order-pay.php:23
|
305 |
-
#: includes/admin/meta-boxes/views/html-product-data.php:
|
306 |
-
#: includes/gateways/settings/applepay-settings.php:
|
307 |
-
#: includes/gateways/settings/cc-settings.php:
|
308 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
309 |
-
#: includes/gateways/settings/payment-request-settings.php:
|
310 |
msgid "Capture"
|
311 |
msgstr ""
|
312 |
|
@@ -319,13 +319,13 @@ msgid "Charge Data"
|
|
319 |
msgstr ""
|
320 |
|
321 |
#: includes/admin/meta-boxes/views/html-charge-data-subview.php:24
|
322 |
-
#: includes/admin/settings/class-wc-stripe-api-settings.php:
|
323 |
msgid "Mode"
|
324 |
msgstr ""
|
325 |
|
326 |
#: includes/admin/meta-boxes/views/html-charge-data-subview.php:25
|
327 |
-
#: includes/admin/settings/class-wc-stripe-api-settings.php:
|
328 |
-
#: includes/controllers/class-wc-stripe-controller-gateway-settings.php:
|
329 |
msgid "Live"
|
330 |
msgstr ""
|
331 |
|
@@ -342,14 +342,14 @@ msgid "Customer"
|
|
342 |
msgstr ""
|
343 |
|
344 |
#: includes/admin/meta-boxes/views/html-charge-data-subview.php:45
|
345 |
-
#: includes/admin/views/html-user-profile.php:
|
346 |
-
#: includes/admin/views/html-user-profile.php:
|
347 |
msgid "Payment Method"
|
348 |
msgstr ""
|
349 |
|
350 |
#: includes/admin/meta-boxes/views/html-charge-data-subview.php:51
|
351 |
-
#: includes/admin/views/html-ach-fee.php:
|
352 |
-
#: includes/gateways/settings/payment-request-settings.php:
|
353 |
msgid "Type"
|
354 |
msgstr ""
|
355 |
|
@@ -379,39 +379,39 @@ msgstr ""
|
|
379 |
msgid "Riska Data"
|
380 |
msgstr ""
|
381 |
|
382 |
-
#: includes/admin/meta-boxes/views/html-charge-data-subview.php:
|
383 |
msgid "Score"
|
384 |
msgstr ""
|
385 |
|
386 |
-
#: includes/admin/meta-boxes/views/html-charge-data-subview.php:
|
387 |
msgid "Level"
|
388 |
msgstr ""
|
389 |
|
390 |
-
#: includes/admin/meta-boxes/views/html-order-actions.php:
|
391 |
msgid "Charge Status"
|
392 |
msgstr ""
|
393 |
|
394 |
-
#: includes/admin/meta-boxes/views/html-order-actions.php:
|
395 |
msgid "Authorization Expires"
|
396 |
msgstr ""
|
397 |
|
398 |
-
#: includes/admin/meta-boxes/views/html-order-actions.php:
|
399 |
msgid "There are no actions available at this time."
|
400 |
msgstr ""
|
401 |
|
402 |
-
#: includes/admin/meta-boxes/views/html-order-actions.php:
|
403 |
msgid "Capture Charge"
|
404 |
msgstr ""
|
405 |
|
406 |
-
#: includes/admin/meta-boxes/views/html-order-actions.php:
|
407 |
msgid "Total available to capture"
|
408 |
msgstr ""
|
409 |
|
410 |
-
#: includes/admin/meta-boxes/views/html-order-actions.php:
|
411 |
msgid "Amount To Capture"
|
412 |
msgstr ""
|
413 |
|
414 |
-
#: includes/admin/meta-boxes/views/html-order-actions.php:
|
415 |
msgid "Cancel"
|
416 |
msgstr ""
|
417 |
|
@@ -428,20 +428,20 @@ msgid "Admins can process customer orders over the phone using this functionalit
|
|
428 |
msgstr ""
|
429 |
|
430 |
#: includes/admin/meta-boxes/views/html-order-pay.php:21
|
431 |
-
#: includes/admin/meta-boxes/views/html-product-data.php:
|
432 |
-
#: includes/gateways/settings/applepay-settings.php:
|
433 |
-
#: includes/gateways/settings/cc-settings.php:
|
434 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
435 |
-
#: includes/gateways/settings/payment-request-settings.php:
|
436 |
msgid "Charge Type"
|
437 |
msgstr ""
|
438 |
|
439 |
#: includes/admin/meta-boxes/views/html-order-pay.php:24
|
440 |
-
#: includes/admin/meta-boxes/views/html-product-data.php:
|
441 |
-
#: includes/gateways/settings/applepay-settings.php:
|
442 |
-
#: includes/gateways/settings/cc-settings.php:
|
443 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
444 |
-
#: includes/gateways/settings/payment-request-settings.php:
|
445 |
msgid "Authorize"
|
446 |
msgstr ""
|
447 |
|
@@ -453,127 +453,127 @@ msgstr ""
|
|
453 |
msgid "In this section you can control which gateways are displayed on the product page."
|
454 |
msgstr ""
|
455 |
|
456 |
-
#: includes/admin/meta-boxes/views/html-product-data.php:
|
457 |
msgid "Method"
|
458 |
msgstr ""
|
459 |
|
460 |
-
#: includes/admin/meta-boxes/views/html-product-data.php:
|
461 |
msgid "Button Position"
|
462 |
msgstr ""
|
463 |
|
464 |
-
#: includes/admin/meta-boxes/views/html-product-data.php:
|
465 |
msgid "Below add to cart"
|
466 |
msgstr ""
|
467 |
|
468 |
-
#: includes/admin/meta-boxes/views/html-product-data.php:
|
469 |
msgid "Above add to cart"
|
470 |
msgstr ""
|
471 |
|
472 |
-
#: includes/admin/meta-boxes/views/html-product-data.php:
|
473 |
msgid "The location of the payment buttons in relation to the Add to Cart button."
|
474 |
msgstr ""
|
475 |
|
476 |
-
#: includes/admin/meta-boxes/views/html-product-data.php:
|
477 |
msgid "Save"
|
478 |
msgstr ""
|
479 |
|
480 |
#: includes/admin/settings/class-wc-stripe-api-settings.php:15
|
481 |
-
#: includes/admin/settings/class-wc-stripe-api-settings.php:
|
482 |
msgid "API Settings"
|
483 |
msgstr ""
|
484 |
|
485 |
-
#: includes/admin/settings/class-wc-stripe-api-settings.php:
|
486 |
-
#: includes/controllers/class-wc-stripe-controller-gateway-settings.php:
|
487 |
msgid "Test"
|
488 |
msgstr ""
|
489 |
|
490 |
-
#: includes/admin/settings/class-wc-stripe-api-settings.php:
|
491 |
msgid "The mode determines if you are processing test transactions or live transactions on your site. Test mode allows you to simulate payments so you can test your integration."
|
492 |
msgstr ""
|
493 |
|
494 |
-
#: includes/admin/settings/class-wc-stripe-api-settings.php:
|
495 |
msgid "Account ID"
|
496 |
msgstr ""
|
497 |
|
498 |
-
#: includes/admin/settings/class-wc-stripe-api-settings.php:
|
499 |
msgid "This is your Stripe Connect ID and serves as a unique identifier."
|
500 |
msgstr ""
|
501 |
|
502 |
-
#: includes/admin/settings/class-wc-stripe-api-settings.php:
|
503 |
msgid "Connect Stripe Account"
|
504 |
msgstr ""
|
505 |
|
506 |
-
#: includes/admin/settings/class-wc-stripe-api-settings.php:
|
507 |
msgid "Click to Connect"
|
508 |
msgstr ""
|
509 |
|
510 |
-
#: includes/admin/settings/class-wc-stripe-api-settings.php:
|
511 |
msgid "We make it easy to connect Stripe to your site. Click the Connect button to go through our connect flow."
|
512 |
msgstr ""
|
513 |
|
|
|
514 |
#: includes/admin/settings/class-wc-stripe-api-settings.php:63
|
515 |
-
#: includes/admin/settings/class-wc-stripe-api-settings.php:64
|
516 |
msgid "Connection Test"
|
517 |
msgstr ""
|
518 |
|
519 |
-
#: includes/admin/settings/class-wc-stripe-api-settings.php:
|
520 |
msgid "Click this button to perform a connection test. If successful, your site is connected to Stripe."
|
521 |
msgstr ""
|
522 |
|
523 |
-
#: includes/admin/settings/class-wc-stripe-api-settings.php:
|
524 |
msgid "Webhook url"
|
525 |
msgstr ""
|
526 |
|
527 |
-
#: includes/admin/settings/class-wc-stripe-api-settings.php:
|
528 |
-
msgid "<strong>Important:</strong> the webhook url is called by Stripe when events occur in your account, like a source becomes chargeable. You must add this webhook to your Stripe Dashboard if you are using any of the local gateways. %sWebhook guide%s"
|
529 |
msgstr ""
|
530 |
|
531 |
-
#: includes/admin/settings/class-wc-stripe-api-settings.php:
|
532 |
msgid "Live Webhook Secret"
|
533 |
msgstr ""
|
534 |
|
535 |
-
#: includes/admin/settings/class-wc-stripe-api-settings.php:
|
536 |
-
#: includes/admin/settings/class-wc-stripe-api-settings.php:
|
537 |
-
msgid "The webhook secret is used to authenticate webhooks sent from Stripe. It ensures no 3rd party can send you events, pretending to be Stripe. %sWebhook guide%s"
|
538 |
msgstr ""
|
539 |
|
540 |
-
#: includes/admin/settings/class-wc-stripe-api-settings.php:
|
541 |
msgid "Test Webhook Secret"
|
542 |
msgstr ""
|
543 |
|
544 |
-
#: includes/admin/settings/class-wc-stripe-api-settings.php:
|
545 |
msgid "Debug Log"
|
546 |
msgstr ""
|
547 |
|
548 |
-
#: includes/admin/settings/class-wc-stripe-api-settings.php:
|
549 |
msgid "When enabled, the plugin logs important errors and info that can help you troubleshoot potential issues."
|
550 |
msgstr ""
|
551 |
|
552 |
-
#: includes/admin/settings/class-wc-stripe-api-settings.php:
|
553 |
msgid "%s Your Stripe account has been connected. You can now accept Live and Test payments. You can Re-Connect if you want to recycle your API keys for security."
|
554 |
msgstr ""
|
555 |
|
556 |
-
#: includes/admin/settings/class-wc-stripe-api-settings.php:
|
557 |
msgid "Click To Re-Connect"
|
558 |
msgstr ""
|
559 |
|
560 |
-
#: includes/admin/settings/class-wc-stripe-api-settings.php:
|
561 |
msgid "Please try again."
|
562 |
msgstr ""
|
563 |
|
564 |
-
#: includes/admin/settings/class-wc-stripe-api-settings.php:
|
565 |
msgid "We were not able to connect your Stripe account. Reason: %s"
|
566 |
msgstr ""
|
567 |
|
568 |
-
#: includes/admin/settings/class-wc-stripe-api-settings.php:
|
569 |
msgid "Your Stripe account has been connected to your WooCommerce store. You may now accept payments in Live and Test mode."
|
570 |
msgstr ""
|
571 |
|
572 |
-
#: includes/admin/views/html-ach-fee.php:
|
573 |
msgid "Taxable"
|
574 |
msgstr ""
|
575 |
|
576 |
-
#: includes/admin/views/html-ach-fee.php:
|
577 |
msgid "Value"
|
578 |
msgstr ""
|
579 |
|
@@ -585,39 +585,39 @@ msgstr ""
|
|
585 |
msgid "Live ID"
|
586 |
msgstr ""
|
587 |
|
588 |
-
#: includes/admin/views/html-user-profile.php:
|
589 |
msgid "Test ID"
|
590 |
msgstr ""
|
591 |
|
592 |
-
#: includes/admin/views/html-user-profile.php:
|
593 |
msgid "Stripe Live Payment Methods"
|
594 |
msgstr ""
|
595 |
|
596 |
-
#: includes/admin/views/html-user-profile.php:
|
597 |
-
#: includes/admin/views/html-user-profile.php:
|
598 |
msgid "Payment Gateway"
|
599 |
msgstr ""
|
600 |
|
601 |
-
#: includes/admin/views/html-user-profile.php:
|
602 |
-
#: includes/admin/views/html-user-profile.php:
|
603 |
msgid "Token"
|
604 |
msgstr ""
|
605 |
|
606 |
-
#: includes/admin/views/html-user-profile.php:
|
607 |
-
#: includes/admin/views/html-user-profile.php:
|
608 |
msgid "No Action"
|
609 |
msgstr ""
|
610 |
|
611 |
-
#: includes/admin/views/html-user-profile.php:
|
612 |
-
#: includes/admin/views/html-user-profile.php:
|
613 |
msgid "Delete"
|
614 |
msgstr ""
|
615 |
|
616 |
-
#: includes/admin/views/html-user-profile.php:
|
617 |
msgid "No live payment methods saved"
|
618 |
msgstr ""
|
619 |
|
620 |
-
#: includes/admin/views/html-user-profile.php:
|
621 |
msgid "Stripe Test Payment Methods"
|
622 |
msgstr ""
|
623 |
|
@@ -626,109 +626,105 @@ msgid "No test payment methods saved"
|
|
626 |
msgstr ""
|
627 |
|
628 |
#: includes/admin/views/html-user-profile.php:94
|
629 |
-
msgid "%snote:%s payment methods will be deleted in Stripe if you use the delete action."
|
630 |
msgstr ""
|
631 |
|
632 |
-
#: includes/class-wc-stripe-customer-manager.php:
|
633 |
-
#: includes/class-wc-stripe-customer-manager.php:
|
634 |
msgid "Error saving customer. Reason: %s"
|
635 |
msgstr ""
|
636 |
|
637 |
-
#: includes/class-wc-stripe-frontend-notices.php:
|
638 |
msgid "Your payment is being processed and your order status will be updated once the funds are received."
|
639 |
msgstr ""
|
640 |
|
641 |
-
#: includes/class-wc-stripe-frontend-scripts.php:
|
642 |
msgid "No matches found"
|
643 |
msgstr ""
|
644 |
|
645 |
-
#: includes/class-wc-stripe-
|
646 |
-
msgid "Please update your ACH environment to Production to match your Stripe API Mode."
|
647 |
-
msgstr ""
|
648 |
-
|
649 |
-
#: includes/class-wc-stripe-redirect-handler.php:39
|
650 |
msgid "Error retrieving payment source. Reason: %s"
|
651 |
msgstr ""
|
652 |
|
653 |
-
#: includes/class-wc-stripe-redirect-handler.php:
|
654 |
msgid "Payment authorization failed. Please select another payment method."
|
655 |
msgstr ""
|
656 |
|
657 |
-
#: includes/class-wc-stripe-redirect-handler.php:
|
658 |
msgid "Payment authorization failed."
|
659 |
msgstr ""
|
660 |
|
661 |
-
#: includes/class-wc-stripe-rest-api.php:
|
662 |
msgid "%1$s is an invalid controller name."
|
663 |
msgstr ""
|
664 |
|
665 |
-
#: includes/class-wc-stripe-update.php:
|
666 |
msgid "Thank you for updating Stripe for WooCommerce to version %1$s."
|
667 |
msgstr ""
|
668 |
|
669 |
-
#: includes/controllers/class-wc-stripe-controller-cart.php:
|
670 |
msgid "Quantity must be greater than zero."
|
671 |
msgstr ""
|
672 |
|
673 |
-
#: includes/controllers/class-wc-stripe-controller-checkout.php:
|
674 |
-
msgid "Some required fields were missing. Please click %shere%s to complete your payment."
|
675 |
msgstr ""
|
676 |
|
677 |
-
#: includes/controllers/class-wc-stripe-controller-checkout.php:
|
678 |
msgid "Please review your order details then click Place Order."
|
679 |
msgstr ""
|
680 |
|
681 |
-
#: includes/controllers/class-wc-stripe-controller-gateway-settings.php:
|
682 |
msgid "You cannot register your domain until you have configured your Live API keys."
|
683 |
msgstr ""
|
684 |
|
685 |
-
#: includes/controllers/class-wc-stripe-controller-gateway-settings.php:
|
686 |
msgid "Domain registered successfully. You can confirm in your Stripe Dashboard at https://dashboard.stripe.com/account/apple_pay."
|
687 |
msgstr ""
|
688 |
|
689 |
-
#: includes/controllers/class-wc-stripe-controller-gateway-settings.php:
|
690 |
msgid "You must configure your secret key before creating webhooks."
|
691 |
msgstr ""
|
692 |
|
693 |
-
#: includes/controllers/class-wc-stripe-controller-gateway-settings.php:
|
694 |
msgid "There is already a webhook configured for this site. If you want to delete the webhook, login to your Stripe Dashboard."
|
695 |
msgstr ""
|
696 |
|
697 |
-
#: includes/controllers/class-wc-stripe-controller-gateway-settings.php:
|
698 |
msgid "Webhook created in Stripe for %s environment. You can test your webhook by logging in to the Stripe dashboard"
|
699 |
msgstr ""
|
700 |
|
701 |
-
#: includes/controllers/class-wc-stripe-controller-gateway-settings.php:
|
702 |
msgid "Mode: %s. Invalid secret key. Please check your entry."
|
703 |
msgstr ""
|
704 |
|
705 |
-
#: includes/controllers/class-wc-stripe-controller-gateway-settings.php:
|
706 |
-
#: includes/controllers/class-wc-stripe-controller-gateway-settings.php:
|
707 |
msgid "Mode: %s. Invalid publishable key. Please check your entry."
|
708 |
msgstr ""
|
709 |
|
710 |
-
#: includes/controllers/class-wc-stripe-controller-gateway-settings.php:
|
711 |
msgid "Connection test to Stripe was successful. Mode: %s."
|
712 |
msgstr ""
|
713 |
|
714 |
-
#: includes/controllers/class-wc-stripe-controller-googlepay.php:
|
715 |
msgid "Your shipping address is not serviceable."
|
716 |
msgstr ""
|
717 |
|
718 |
-
#: includes/controllers/class-wc-stripe-controller-order-actions.php:
|
719 |
msgid "Invalid amount entered."
|
720 |
msgstr ""
|
721 |
|
722 |
-
#: includes/controllers/class-wc-stripe-controller-order-actions.php:
|
723 |
-
#: includes/controllers/class-wc-stripe-controller-order-actions.php:
|
724 |
msgid "Order total must be greater than zero."
|
725 |
msgstr ""
|
726 |
|
727 |
-
#: includes/controllers/class-wc-stripe-controller-order-actions.php:
|
728 |
-
msgid "This order has already been processed. Transaction ID: %s. Payment method: %s"
|
729 |
msgstr ""
|
730 |
|
731 |
-
#: includes/controllers/class-wc-stripe-controller-order-actions.php:
|
732 |
msgid "Order customer Id and payment method customer Id do not match."
|
733 |
msgstr ""
|
734 |
|
@@ -736,98 +732,91 @@ msgstr ""
|
|
736 |
msgid "Error creating payment intent. Reason: %s"
|
737 |
msgstr ""
|
738 |
|
739 |
-
#: includes/controllers/class-wc-stripe-controller-payment-intent.php:
|
740 |
msgid "Invalid order id provided"
|
741 |
msgstr ""
|
742 |
|
743 |
-
#: includes/controllers/class-wc-stripe-controller-payment-intent.php:
|
744 |
msgid "You are not authorized to update this order."
|
745 |
msgstr ""
|
746 |
|
747 |
-
#: includes/controllers/class-wc-stripe-controller-webhook.php:
|
748 |
-
#: includes/controllers/class-wc-stripe-controller-webhook.php:
|
749 |
msgid "Invalid signature received. Verify that your webhook secret is correct."
|
750 |
msgstr ""
|
751 |
|
752 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-ach-v2.php:26
|
753 |
#: includes/gateways/class-wc-payment-gateway-stripe-ach.php:26
|
754 |
msgid "ACH"
|
755 |
msgstr ""
|
756 |
|
757 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-ach-v2.php:29
|
758 |
#: includes/gateways/class-wc-payment-gateway-stripe-ach.php:29
|
759 |
msgid "Stripe ACH"
|
760 |
msgstr ""
|
761 |
|
762 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-ach-v2.php:30
|
763 |
#: includes/gateways/class-wc-payment-gateway-stripe-ach.php:30
|
764 |
msgid "ACH gateway that integrates with your Stripe account."
|
765 |
msgstr ""
|
766 |
|
767 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-ach-v2.php:32
|
768 |
#: includes/gateways/class-wc-payment-gateway-stripe-ach.php:32
|
769 |
msgid "Bank Payment"
|
770 |
msgstr ""
|
771 |
|
772 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-ach
|
773 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-ach.php:203
|
774 |
msgid "Saved Banks"
|
775 |
msgstr ""
|
776 |
|
777 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-ach
|
778 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-ach.php:207
|
779 |
msgid "New Bank"
|
780 |
msgstr ""
|
781 |
|
782 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-ach
|
783 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-ach.php:243
|
784 |
msgid "You must set the API mode to live in order to enable the Plaid development environment."
|
785 |
msgstr ""
|
786 |
|
787 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-alipay.php:
|
788 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-alipay.php:
|
789 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-alipay.php:
|
790 |
msgid "Alipay"
|
791 |
msgstr ""
|
792 |
|
793 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-alipay.php:
|
794 |
msgid "Alipay gateway that integrates with your Stripe account."
|
795 |
msgstr ""
|
796 |
|
797 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-applepay.php:
|
798 |
-
#: includes/gateways/settings/applepay-settings.php:
|
799 |
msgid "Apple Pay"
|
800 |
msgstr ""
|
801 |
|
802 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-applepay.php:
|
803 |
msgid "Stripe Apple Pay"
|
804 |
msgstr ""
|
805 |
|
806 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-applepay.php:
|
807 |
msgid "Apple Pay gateway that integrates with your Stripe account."
|
808 |
msgstr ""
|
809 |
|
810 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-applepay.php:
|
811 |
msgid "Please update you product quantity before using Apple Pay."
|
812 |
msgstr ""
|
813 |
|
814 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-applepay.php:
|
815 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-payment-request.php:
|
816 |
msgid "Please select a product option before updating quantity."
|
817 |
msgstr ""
|
818 |
|
819 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-bancontact.php:
|
820 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-bancontact.php:
|
821 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-bancontact.php:
|
822 |
msgid "Bancontact"
|
823 |
msgstr ""
|
824 |
|
825 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-bancontact.php:
|
826 |
msgid "Bancontact gateway that integrates with your Stripe account."
|
827 |
msgstr ""
|
828 |
|
829 |
#: includes/gateways/class-wc-payment-gateway-stripe-cc.php:19
|
830 |
-
#: includes/gateways/settings/cc-settings.php:
|
831 |
msgid "Credit Cards"
|
832 |
msgstr ""
|
833 |
|
@@ -839,38 +828,38 @@ msgstr ""
|
|
839 |
msgid "Credit card gateway that integrates with your Stripe account."
|
840 |
msgstr ""
|
841 |
|
842 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-eps.php:
|
843 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-eps.php:
|
844 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-eps.php:
|
845 |
msgid "EPS"
|
846 |
msgstr ""
|
847 |
|
848 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-eps.php:
|
849 |
msgid "EPS gateway that integrates with your Stripe account."
|
850 |
msgstr ""
|
851 |
|
|
|
852 |
#: includes/gateways/class-wc-payment-gateway-stripe-fpx.php:26
|
853 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-fpx.php:
|
854 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-fpx.php:30
|
855 |
msgid "FPX"
|
856 |
msgstr ""
|
857 |
|
858 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-fpx.php:
|
859 |
msgid "FPX gateway that integrates with your Stripe account."
|
860 |
msgstr ""
|
861 |
|
862 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-giropay.php:
|
863 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-giropay.php:
|
864 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-giropay.php:
|
865 |
msgid "Giropay"
|
866 |
msgstr ""
|
867 |
|
868 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-giropay.php:
|
869 |
msgid "Giropay gateway that integrates with your Stripe account."
|
870 |
msgstr ""
|
871 |
|
872 |
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:20
|
873 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
874 |
msgid "Google Pay"
|
875 |
msgstr ""
|
876 |
|
@@ -882,143 +871,141 @@ msgstr ""
|
|
882 |
msgid "Google Pay gateway that integrates with your Stripe account."
|
883 |
msgstr ""
|
884 |
|
885 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:
|
886 |
msgid "Please update you product quantity before using Google Pay."
|
887 |
msgstr ""
|
888 |
|
889 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:
|
890 |
msgid "Subscription"
|
891 |
msgstr ""
|
892 |
|
893 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:
|
894 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:
|
895 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:
|
896 |
-
#: includes/wc-stripe-functions.php:
|
897 |
-
#: includes/wc-stripe-functions.php:
|
898 |
msgid "Shipping"
|
899 |
msgstr ""
|
900 |
|
901 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:
|
902 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:
|
903 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:
|
904 |
-
#: includes/wc-stripe-functions.php:
|
905 |
-
#: includes/wc-stripe-functions.php:
|
906 |
msgid "Discount"
|
907 |
msgstr ""
|
908 |
|
909 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:
|
910 |
-
#: includes/wc-stripe-functions.php:
|
911 |
msgid "Fees"
|
912 |
msgstr ""
|
913 |
|
914 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:
|
915 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:
|
916 |
-
#: includes/wc-stripe-functions.php:
|
917 |
msgid "Tax"
|
918 |
msgstr ""
|
919 |
|
920 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:
|
921 |
-
#: includes/wc-stripe-functions.php:512
|
922 |
msgid "Waiting..."
|
923 |
msgstr ""
|
924 |
|
925 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:
|
926 |
-
#: includes/wc-stripe-functions.php:513
|
927 |
msgid "loading shipping methods..."
|
928 |
msgstr ""
|
929 |
|
|
|
930 |
#: includes/gateways/class-wc-payment-gateway-stripe-ideal.php:28
|
931 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-ideal.php:
|
932 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-ideal.php:32
|
933 |
msgid "iDEAL"
|
934 |
msgstr ""
|
935 |
|
936 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-ideal.php:
|
937 |
msgid "Ideal gateway that integrates with your Stripe account."
|
938 |
msgstr ""
|
939 |
|
940 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:
|
941 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:
|
942 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:
|
943 |
msgid "Klarna"
|
944 |
msgstr ""
|
945 |
|
946 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:
|
947 |
msgid "Klarna gateway that integrates with your Stripe account."
|
948 |
msgstr ""
|
949 |
|
950 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:
|
951 |
msgid "Payment Categories"
|
952 |
msgstr ""
|
953 |
|
954 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:
|
955 |
-
msgid "
|
956 |
msgstr ""
|
957 |
|
958 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:
|
959 |
msgid "Fee"
|
960 |
msgstr ""
|
961 |
|
962 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:
|
963 |
msgid "Pay Now"
|
964 |
msgstr ""
|
965 |
|
966 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:
|
967 |
msgid "Pay Later"
|
968 |
msgstr ""
|
969 |
|
970 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:
|
971 |
msgid "Pay Over Time"
|
972 |
msgstr ""
|
973 |
|
974 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:
|
975 |
-
msgid "Click %shere%s for Klarna test payment methods."
|
976 |
msgstr ""
|
977 |
|
978 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:
|
979 |
msgid "Your purchase is not approved."
|
980 |
msgstr ""
|
981 |
|
982 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-multibanco.php:
|
983 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-multibanco.php:
|
984 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-multibanco.php:
|
985 |
msgid "Multibanco"
|
986 |
msgstr ""
|
987 |
|
988 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-multibanco.php:
|
989 |
msgid "Multibanco gateway that integrates with your Stripe account."
|
990 |
msgstr ""
|
991 |
|
992 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-p24.php:
|
993 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-p24.php:
|
994 |
msgid "Przelewy24"
|
995 |
msgstr ""
|
996 |
|
997 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-p24.php:
|
998 |
msgid "P24 gateway that integrates with your Stripe account."
|
999 |
msgstr ""
|
1000 |
|
1001 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-p24.php:
|
1002 |
msgid "P24"
|
1003 |
msgstr ""
|
1004 |
|
1005 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-payment-request.php:
|
1006 |
msgid "PaymentRequest Gateway"
|
1007 |
msgstr ""
|
1008 |
|
1009 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-payment-request.php:
|
1010 |
msgid "Stripe Payment Request"
|
1011 |
msgstr ""
|
1012 |
|
1013 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-payment-request.php:
|
1014 |
msgid "Gateway that renders based on the user's browser. Chrome payment methods, Microsoft pay, etc."
|
1015 |
msgstr ""
|
1016 |
|
1017 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-payment-request.php:
|
1018 |
msgid "Please update you product quantity before paying."
|
1019 |
msgstr ""
|
1020 |
|
1021 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-payment-request.php:
|
1022 |
msgid "Adding to cart..."
|
1023 |
msgstr ""
|
1024 |
|
@@ -1035,812 +1022,808 @@ msgstr ""
|
|
1035 |
msgid "Sepa gateway that integrates with your Stripe account."
|
1036 |
msgstr ""
|
1037 |
|
1038 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-sepa.php:
|
1039 |
msgid ""
|
1040 |
-
"By providing your IBAN and confirming this payment, you are\
|
1041 |
-
"\t\t\tauthorizing %s and Stripe, our payment service provider, to send instructions to your bank to debit your account\
|
1042 |
-
"\t\t\tand your bank to debit your account in accordance with those instructions. You are entitled to a refund from your bank under the\
|
1043 |
"\t\t\tterms and conditions of your agreement with your bank. A refund must be claimed within 8 weeks starting from the date on which your account was debited."
|
1044 |
msgstr ""
|
1045 |
|
1046 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-sepa.php:
|
1047 |
msgid "Company Name"
|
1048 |
msgstr ""
|
1049 |
|
1050 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-sepa.php:
|
1051 |
msgid "The name of your company that will appear in the SEPA mandate."
|
1052 |
msgstr ""
|
1053 |
|
1054 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-sepa.php:
|
1055 |
msgid "SEPA Test Accounts"
|
1056 |
msgstr ""
|
1057 |
|
1058 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-sofort.php:
|
1059 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-sofort.php:
|
1060 |
msgid "Sofort"
|
1061 |
msgstr ""
|
1062 |
|
1063 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-sofort.php:
|
1064 |
msgid "Sofort gateway that integrates with your Stripe account."
|
1065 |
msgstr ""
|
1066 |
|
1067 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-sofort.php:
|
1068 |
msgid "SOFORT"
|
1069 |
msgstr ""
|
1070 |
|
1071 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-wechat.php:
|
1072 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-wechat.php:
|
1073 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-wechat.php:
|
1074 |
msgid "WeChat"
|
1075 |
msgstr ""
|
1076 |
|
1077 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-wechat.php:
|
1078 |
msgid "WeChat gateway that integrates with your Stripe account."
|
1079 |
msgstr ""
|
1080 |
|
1081 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-wechat.php:
|
1082 |
msgid "Scan the QR code using your WeChat app. Once scanned click the Place Order button."
|
1083 |
msgstr ""
|
1084 |
|
1085 |
-
#: includes/gateways/settings/ach-settings-v2.php:
|
1086 |
-
#: includes/gateways/settings/ach-settings.php:
|
1087 |
msgid "For US customers only."
|
1088 |
msgstr ""
|
1089 |
|
1090 |
-
#: includes/gateways/settings/ach-settings-v2.php:
|
1091 |
-
#: includes/gateways/settings/ach-settings.php:
|
1092 |
-
msgid "Read through our %sdocumentation%s to configure ACH payments"
|
1093 |
msgstr ""
|
1094 |
|
1095 |
-
#: includes/gateways/settings/ach-settings-v2.php:
|
1096 |
-
#: includes/gateways/settings/ach-settings.php:
|
1097 |
msgid "If enabled, your site can accept ACH payments through Stripe."
|
1098 |
msgstr ""
|
1099 |
|
1100 |
-
#: includes/gateways/settings/ach-settings-v2.php:
|
1101 |
-
#: includes/gateways/settings/ach-settings.php:
|
1102 |
msgid "Plaid Environment"
|
1103 |
msgstr ""
|
1104 |
|
1105 |
-
#: includes/gateways/settings/ach-settings-v2.php:
|
1106 |
-
#: includes/gateways/settings/ach-settings.php:
|
1107 |
msgid "Sandbox"
|
1108 |
msgstr ""
|
1109 |
|
1110 |
-
#: includes/gateways/settings/ach-settings-v2.php:
|
1111 |
-
#: includes/gateways/settings/ach-settings.php:
|
1112 |
msgid "Development"
|
1113 |
msgstr ""
|
1114 |
|
1115 |
-
#: includes/gateways/settings/ach-settings-v2.php:
|
1116 |
-
#: includes/gateways/settings/ach-settings.php:
|
1117 |
msgid "Production"
|
1118 |
msgstr ""
|
1119 |
|
1120 |
-
#: includes/gateways/settings/ach-settings-v2.php:
|
1121 |
msgid "This setting determines the Plaid environment you are connecting with. When you are ready to accept live transactions, switch this option to Production.<br><strong>Production</strong> - accept live ACH payments <br><strong>Development</strong> - use real bank login details with test transactions <br><strong>Sandbox</strong> - test integration using test credentials"
|
1122 |
msgstr ""
|
1123 |
|
1124 |
-
#: includes/gateways/settings/ach-settings-v2.php:
|
1125 |
-
#: includes/gateways/settings/ach-settings.php:
|
1126 |
msgid "ACH Payment"
|
1127 |
msgstr ""
|
1128 |
|
1129 |
-
#: includes/gateways/settings/ach-settings-v2.php:
|
1130 |
-
#: includes/gateways/settings/ach-settings.php:
|
1131 |
msgid "Client Name"
|
1132 |
msgstr ""
|
1133 |
|
1134 |
-
#: includes/gateways/settings/ach-settings-v2.php:
|
1135 |
-
#: includes/gateways/settings/ach-settings.php:
|
1136 |
msgid "The name that appears on the ACH payment screen."
|
1137 |
msgstr ""
|
1138 |
|
1139 |
-
#: includes/gateways/settings/ach-settings-v2.php:
|
1140 |
-
#: includes/gateways/settings/ach-settings.php:
|
1141 |
msgid "ACH Display"
|
1142 |
msgstr ""
|
1143 |
|
1144 |
-
#: includes/gateways/settings/ach-settings-v2.php:
|
1145 |
-
#: includes/gateways/settings/ach-settings.php:
|
1146 |
msgid "ACH Fee"
|
1147 |
msgstr ""
|
1148 |
|
1149 |
-
#: includes/gateways/settings/ach-settings-v2.php:
|
1150 |
-
#: includes/gateways/settings/ach-settings.php:
|
1151 |
msgid "None"
|
1152 |
msgstr ""
|
1153 |
|
1154 |
-
#: includes/gateways/settings/ach-settings-v2.php:
|
1155 |
-
#: includes/gateways/settings/ach-settings.php:
|
1156 |
msgid "Amount"
|
1157 |
msgstr ""
|
1158 |
|
1159 |
-
#: includes/gateways/settings/ach-settings-v2.php:
|
1160 |
-
#: includes/gateways/settings/ach-settings.php:
|
1161 |
msgid "Percentage"
|
1162 |
msgstr ""
|
1163 |
|
1164 |
-
#: includes/gateways/settings/ach-settings-v2.php:
|
1165 |
-
#: includes/gateways/settings/ach-settings.php:
|
1166 |
msgid "You can assign a fee to the order for ACH payments. Amount is a static amount and percentage is a percentage of the cart amount."
|
1167 |
msgstr ""
|
1168 |
|
1169 |
-
#: includes/gateways/settings/ach-settings.php:
|
1170 |
msgid "The active Plaid environment. You must set API mode to live to use Plaid's development environment."
|
1171 |
msgstr ""
|
1172 |
|
1173 |
-
#: includes/gateways/settings/ach-settings.php:
|
1174 |
msgid "ID that identifies your Plaid account."
|
1175 |
msgstr ""
|
1176 |
|
1177 |
-
#: includes/gateways/settings/ach-settings.php:
|
1178 |
msgid "Used to identify ACH payments initiated from your site."
|
1179 |
msgstr ""
|
1180 |
|
1181 |
-
#: includes/gateways/settings/ach-settings.php:
|
1182 |
msgid "Sandbox Secret"
|
1183 |
msgstr ""
|
1184 |
|
1185 |
-
#: includes/gateways/settings/ach-settings.php:
|
1186 |
msgid "Key that acts as a password when connecting to Plaid's sandbox environment."
|
1187 |
msgstr ""
|
1188 |
|
1189 |
-
#: includes/gateways/settings/ach-settings.php:
|
1190 |
msgid "Development Secret"
|
1191 |
msgstr ""
|
1192 |
|
1193 |
-
#: includes/gateways/settings/ach-settings.php:
|
1194 |
msgid "Development allows you to test real bank credentials with test transactions."
|
1195 |
msgstr ""
|
1196 |
|
1197 |
-
#: includes/gateways/settings/ach-settings.php:
|
1198 |
msgid "Production Secret"
|
1199 |
msgstr ""
|
1200 |
|
1201 |
-
#: includes/gateways/settings/ach-settings.php:
|
1202 |
msgid "Key that acts as a password when connecting to Plaid's production environment."
|
1203 |
msgstr ""
|
1204 |
|
1205 |
-
#: includes/gateways/settings/applepay-settings.php:
|
1206 |
msgid "Register Domain"
|
1207 |
msgstr ""
|
1208 |
|
1209 |
-
#: includes/gateways/settings/applepay-settings.php:
|
1210 |
-
msgid "This plugin attemps to add the domain association file to your server automatically when you click the Register Domain button. If that fails due to file permssions, you must add the <strong>%s.well-known/apple-developer-merchantid-domain-association%s</strong> file to your domain and register your domain within the Stripe Dashboard."
|
1211 |
msgstr ""
|
1212 |
|
1213 |
-
#: includes/gateways/settings/applepay-settings.php:
|
1214 |
msgid "In order for Apple Pay to display, you must test with an iOS device and have a payment method saved in the Apple Wallet."
|
1215 |
msgstr ""
|
1216 |
|
1217 |
-
#: includes/gateways/settings/applepay-settings.php:
|
1218 |
-
#: includes/gateways/settings/payment-request-settings.php:
|
1219 |
msgid "If enabled, your site can accept Apple Pay payments through Stripe."
|
1220 |
msgstr ""
|
1221 |
|
1222 |
-
#: includes/gateways/settings/applepay-settings.php:
|
1223 |
-
#: includes/gateways/settings/cc-settings.php:
|
1224 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1225 |
-
#: includes/gateways/settings/payment-request-settings.php:
|
1226 |
msgid "Credit Card Display"
|
1227 |
msgstr ""
|
1228 |
|
1229 |
-
#: includes/gateways/settings/applepay-settings.php:
|
1230 |
-
#: includes/gateways/settings/cc-settings.php:
|
1231 |
-
#: includes/gateways/settings/payment-request-settings.php:
|
1232 |
msgid "This option determines whether the customer's funds are captured immediately or authorized and can be captured at a later date."
|
1233 |
msgstr ""
|
1234 |
|
1235 |
-
#: includes/gateways/settings/applepay-settings.php:
|
1236 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1237 |
-
#: includes/gateways/settings/payment-request-settings.php:
|
1238 |
msgid "Payment Sections"
|
1239 |
msgstr ""
|
1240 |
|
1241 |
-
#: includes/gateways/settings/applepay-settings.php:
|
1242 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1243 |
-
#: includes/gateways/settings/payment-request-settings.php:
|
1244 |
msgid "Product Page"
|
1245 |
msgstr ""
|
1246 |
|
1247 |
-
#: includes/gateways/settings/applepay-settings.php:
|
1248 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1249 |
-
#: includes/gateways/settings/payment-request-settings.php:
|
1250 |
msgid "Cart Page"
|
1251 |
msgstr ""
|
1252 |
|
1253 |
-
#: includes/gateways/settings/applepay-settings.php:
|
1254 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1255 |
-
#: includes/gateways/settings/payment-request-settings.php:
|
1256 |
msgid "Top of Checkout"
|
1257 |
msgstr ""
|
1258 |
|
1259 |
-
#: includes/gateways/settings/applepay-settings.php:
|
1260 |
-
#: includes/gateways/settings/cc-settings.php:
|
1261 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1262 |
-
#: includes/gateways/settings/payment-request-settings.php:
|
1263 |
msgid "Order Status"
|
1264 |
msgstr ""
|
1265 |
|
1266 |
-
#: includes/gateways/settings/applepay-settings.php:
|
1267 |
-
#: includes/gateways/settings/cc-settings.php:
|
1268 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1269 |
-
#: includes/gateways/settings/payment-request-settings.php:
|
1270 |
msgid "Default"
|
1271 |
msgstr ""
|
1272 |
|
1273 |
-
#: includes/gateways/settings/applepay-settings.php:
|
1274 |
-
#: includes/gateways/settings/cc-settings.php:
|
1275 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1276 |
-
#: includes/gateways/settings/payment-request-settings.php:
|
1277 |
msgid "This is the status of the order once payment is complete. If <b>Default</b> is selected, then WooCommerce will set the order status automatically based on internal logic which states if a product is virtual and downloadable then status is set to complete. Products that require shipping are set to Processing. Default is the recommended setting as it allows standard WooCommerce code to process the order status."
|
1278 |
msgstr ""
|
1279 |
|
1280 |
-
#: includes/gateways/settings/applepay-settings.php:
|
1281 |
-
#: includes/gateways/settings/payment-request-settings.php:
|
1282 |
msgid "Button Settings"
|
1283 |
msgstr ""
|
1284 |
|
1285 |
-
#: includes/gateways/settings/applepay-settings.php:
|
1286 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1287 |
msgid "Button Design"
|
1288 |
msgstr ""
|
1289 |
|
1290 |
-
#: includes/gateways/settings/applepay-settings.php:
|
1291 |
msgid "Black Button"
|
1292 |
msgstr ""
|
1293 |
|
1294 |
-
#: includes/gateways/settings/applepay-settings.php:
|
1295 |
msgid "White With Black Line"
|
1296 |
msgstr ""
|
1297 |
|
1298 |
-
#: includes/gateways/settings/applepay-settings.php:
|
1299 |
msgid "White Button"
|
1300 |
msgstr ""
|
1301 |
|
1302 |
-
#: includes/gateways/settings/applepay-settings.php:
|
1303 |
msgid "This is the style for all Apple Pay buttons presented on your store."
|
1304 |
msgstr ""
|
1305 |
|
1306 |
-
#: includes/gateways/settings/applepay-settings.php:
|
1307 |
msgid "Checkout button type"
|
1308 |
msgstr ""
|
1309 |
|
1310 |
-
#: includes/gateways/settings/applepay-settings.php:
|
1311 |
-
#: includes/gateways/settings/applepay-settings.php:
|
1312 |
-
#: includes/gateways/settings/applepay-settings.php:
|
1313 |
msgid "Standard Button"
|
1314 |
msgstr ""
|
1315 |
|
1316 |
-
#: includes/gateways/settings/applepay-settings.php:
|
1317 |
-
#: includes/gateways/settings/applepay-settings.php:
|
1318 |
-
#: includes/gateways/settings/applepay-settings.php:
|
1319 |
msgid "Buy with Apple Pay"
|
1320 |
msgstr ""
|
1321 |
|
1322 |
-
#: includes/gateways/settings/applepay-settings.php:
|
1323 |
msgid "Cart button type"
|
1324 |
msgstr ""
|
1325 |
|
1326 |
-
#: includes/gateways/settings/applepay-settings.php:
|
1327 |
msgid "Product button type"
|
1328 |
msgstr ""
|
1329 |
|
1330 |
-
#: includes/gateways/settings/cc-settings.php:
|
1331 |
msgid "If enabled, your site can accept credit card payments through Stripe."
|
1332 |
msgstr ""
|
1333 |
|
1334 |
-
#: includes/gateways/settings/cc-settings.php:
|
1335 |
-
msgid "%sTest cards%s"
|
1336 |
msgstr ""
|
1337 |
|
1338 |
-
#: includes/gateways/settings/cc-settings.php:
|
1339 |
msgid "Allow Credit Card Save"
|
1340 |
msgstr ""
|
1341 |
|
1342 |
-
#: includes/gateways/settings/cc-settings.php:
|
1343 |
msgid "If enabled, a checkbox will be available on the checkout page allowing your customers to save their credit card. The payment methods are stored securely in Stripe's vault and never touch your server. Note: if the cart contains a subscription, there will be no checkbox because the payment method will be saved automatically. There will also be no checkbox for guest checkout as a user must be logged in to save a payment method."
|
1344 |
msgstr ""
|
1345 |
|
1346 |
-
#: includes/gateways/settings/cc-settings.php:
|
1347 |
msgid "Force 3D Secure"
|
1348 |
msgstr ""
|
1349 |
|
1350 |
-
#: includes/gateways/settings/cc-settings.php:
|
1351 |
-
msgid "Stripe internally determines when 3D secure should be presented based on their SCA engine. If <strong>Force 3D Secure</strong> is enabled, 3D Secure will be forced for ALL credit card transactions. In test mode 3D secure only shows for %s3DS Test Cards%s regardless of this setting."
|
1352 |
msgstr ""
|
1353 |
|
1354 |
-
#: includes/gateways/settings/cc-settings.php:
|
1355 |
msgid "Generic Errors"
|
1356 |
msgstr ""
|
1357 |
|
1358 |
-
#: includes/gateways/settings/cc-settings.php:
|
1359 |
msgid "If enabled, credit card errors will be generic when presented to the customer. Merchants may prefer to not provide details on why a card was not accepted for security purposes."
|
1360 |
msgstr ""
|
1361 |
|
1362 |
-
#: includes/gateways/settings/cc-settings.php:
|
1363 |
msgid "Credit Card Form"
|
1364 |
msgstr ""
|
1365 |
|
1366 |
-
#: includes/gateways/settings/cc-settings.php:
|
1367 |
msgid "Card Form"
|
1368 |
msgstr ""
|
1369 |
|
1370 |
-
#: includes/gateways/settings/cc-settings.php:
|
1371 |
msgid "Stripe form"
|
1372 |
msgstr ""
|
1373 |
|
1374 |
-
#: includes/gateways/settings/cc-settings.php:
|
1375 |
msgid "Custom form"
|
1376 |
msgstr ""
|
1377 |
|
1378 |
-
#: includes/gateways/settings/cc-settings.php:
|
1379 |
msgid "The Stripe form option displays a CC form rendered by Stripe. It works well with most themes. The custom card forms are offered if you want more options on the CC form design."
|
1380 |
msgstr ""
|
1381 |
|
1382 |
-
#: includes/gateways/settings/cc-settings.php:
|
1383 |
msgid "Custom Form"
|
1384 |
msgstr ""
|
1385 |
|
1386 |
-
#: includes/gateways/settings/cc-settings.php:
|
1387 |
msgid "The design of the credit card form."
|
1388 |
msgstr ""
|
1389 |
|
1390 |
-
#: includes/gateways/settings/cc-settings.php:
|
1391 |
msgid "Postal Code"
|
1392 |
msgstr ""
|
1393 |
|
1394 |
-
#: includes/gateways/settings/cc-settings.php:
|
1395 |
msgid "If enabled, the CC form will show the postal code on the checkout page. If disabled, the billing field's postal code will be used. The postal code will show on the Add Payment Method page for security reasons."
|
1396 |
msgstr ""
|
1397 |
|
1398 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1399 |
msgid "GPay Business Console"
|
1400 |
msgstr ""
|
1401 |
|
1402 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1403 |
msgid "When test mode is enabled, Google Pay will work without a merchant ID, allowing you to capture the necessary screenshots the Google API team needs to approve your integration request."
|
1404 |
msgstr ""
|
1405 |
|
1406 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1407 |
-
msgid "If you don't want to request a Google Merchant ID, you can use the %sPayment Request Gateway%s which has a Google Pay integration through Stripe via the Chrome browser."
|
1408 |
msgstr ""
|
1409 |
|
1410 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1411 |
msgid "If enabled, your site can accept Google Pay payments through Stripe."
|
1412 |
msgstr ""
|
1413 |
|
1414 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1415 |
msgid "Dynamic Price"
|
1416 |
msgstr ""
|
1417 |
|
1418 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1419 |
msgid "If enabled, the Google Payment sheet will show the order line items. You must have Google whitelist you for callback intents."
|
1420 |
msgstr ""
|
1421 |
|
1422 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1423 |
msgid "Merchant ID"
|
1424 |
msgstr ""
|
1425 |
|
1426 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1427 |
msgid "Your Google Merchant ID is given to you by the Google API team once you register for Google Pay. While testing in TEST mode you can leave this value blank and Google Pay will work."
|
1428 |
msgstr ""
|
1429 |
|
1430 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1431 |
msgid "This option determines whether the customer's funds are capture immediately or authorized and can be captured at a later date."
|
1432 |
msgstr ""
|
1433 |
|
1434 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1435 |
msgid "Merchant Name"
|
1436 |
msgstr ""
|
1437 |
|
1438 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1439 |
msgid "The name of your business as it appears on the Google Pay payment sheet."
|
1440 |
msgstr ""
|
1441 |
|
1442 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1443 |
msgid "Icon"
|
1444 |
msgstr ""
|
1445 |
|
1446 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1447 |
msgid "With Outline"
|
1448 |
msgstr ""
|
1449 |
|
1450 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1451 |
msgid "Standard"
|
1452 |
msgstr ""
|
1453 |
|
1454 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1455 |
msgid "This is the icon style that appears next to the gateway on the checkout page. Google's API team typically requires the With Outline option on the checkout page for branding purposes."
|
1456 |
msgstr ""
|
1457 |
|
1458 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1459 |
msgid "Button Options"
|
1460 |
msgstr ""
|
1461 |
|
1462 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1463 |
msgid "Button Color"
|
1464 |
msgstr ""
|
1465 |
|
1466 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1467 |
msgid "Black"
|
1468 |
msgstr ""
|
1469 |
|
1470 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1471 |
msgid "White"
|
1472 |
msgstr ""
|
1473 |
|
1474 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1475 |
msgid "The button color of the GPay button."
|
1476 |
msgstr ""
|
1477 |
|
1478 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1479 |
msgid "Button Style"
|
1480 |
msgstr ""
|
1481 |
|
1482 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1483 |
msgid "Long"
|
1484 |
msgstr ""
|
1485 |
|
1486 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1487 |
msgid "Short"
|
1488 |
msgstr ""
|
1489 |
|
1490 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1491 |
msgid "The button style of the GPay button."
|
1492 |
msgstr ""
|
1493 |
|
1494 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1495 |
msgid "If you can't see the Google Pay button, try switching to a Chrome browser."
|
1496 |
msgstr ""
|
1497 |
|
1498 |
-
#: includes/gateways/settings/payment-request-settings.php:
|
1499 |
msgid ""
|
1500 |
-
"The PaymentRequest gateway uses your customer's browser to render payment options like Google Pay and Microsoft Pay. You can either use the Google Pay gateway for example, or this gateway.\
|
1501 |
"\t\t\t\t\t\tThe difference is this gateway uses Stripe's PaymentRequest Button rather than render a Google Pay specific button."
|
1502 |
msgstr ""
|
1503 |
|
1504 |
-
#: includes/gateways/settings/payment-request-settings.php:
|
1505 |
msgid "Browser Payments"
|
1506 |
msgstr ""
|
1507 |
|
1508 |
-
#: includes/gateways/settings/payment-request-settings.php:
|
1509 |
msgid "default"
|
1510 |
msgstr ""
|
1511 |
|
1512 |
-
#: includes/gateways/settings/payment-request-settings.php:
|
1513 |
msgid "buy"
|
1514 |
msgstr ""
|
1515 |
|
1516 |
-
#: includes/gateways/settings/payment-request-settings.php:
|
1517 |
msgid "This defines the type of button that will display."
|
1518 |
msgstr ""
|
1519 |
|
1520 |
-
#: includes/gateways/settings/payment-request-settings.php:
|
1521 |
msgid "Theme"
|
1522 |
msgstr ""
|
1523 |
|
1524 |
-
#: includes/gateways/settings/payment-request-settings.php:
|
1525 |
msgid "dark"
|
1526 |
msgstr ""
|
1527 |
|
1528 |
-
#: includes/gateways/settings/payment-request-settings.php:
|
1529 |
msgid "light"
|
1530 |
msgstr ""
|
1531 |
|
1532 |
-
#: includes/gateways/settings/payment-request-settings.php:
|
1533 |
msgid "light-outline"
|
1534 |
msgstr ""
|
1535 |
|
1536 |
-
#: includes/gateways/settings/payment-request-settings.php:
|
1537 |
msgid "This defines the color scheme for the button."
|
1538 |
msgstr ""
|
1539 |
|
1540 |
-
#: includes/gateways/settings/payment-request-settings.php:
|
1541 |
msgid "Height"
|
1542 |
msgstr ""
|
1543 |
|
1544 |
-
#: includes/gateways/settings/payment-request-settings.php:
|
1545 |
msgid "The height of the button. Max height is 64"
|
1546 |
msgstr ""
|
1547 |
|
1548 |
-
#: includes/tokens/class-wc-payment-token-stripe-ach.php:
|
1549 |
-
#: includes/tokens/class-wc-payment-token-stripe-ach.php:
|
1550 |
-
#: includes/tokens/class-wc-payment-token-stripe-cc.php:
|
1551 |
msgid "Type Ending In"
|
1552 |
msgstr ""
|
1553 |
|
1554 |
-
#: includes/tokens/class-wc-payment-token-stripe-ach.php:
|
1555 |
msgid "{bank_name} ending in {last4}"
|
1556 |
msgstr ""
|
1557 |
|
1558 |
-
#: includes/tokens/class-wc-payment-token-stripe-ach.php:
|
1559 |
msgid "{bank_name} **** {last4}"
|
1560 |
msgstr ""
|
1561 |
|
1562 |
-
#: includes/tokens/class-wc-payment-token-stripe-cc.php:
|
1563 |
msgid "{brand} ending in {last4}"
|
1564 |
msgstr ""
|
1565 |
|
1566 |
-
#: includes/tokens/class-wc-payment-token-stripe-cc.php:
|
1567 |
msgid "Type Masked Number"
|
1568 |
msgstr ""
|
1569 |
|
1570 |
-
#: includes/tokens/class-wc-payment-token-stripe-cc.php:
|
1571 |
msgid "Type Dash Masked Number"
|
1572 |
msgstr ""
|
1573 |
|
1574 |
-
#: includes/tokens/class-wc-payment-token-stripe-cc.php:
|
1575 |
msgid "Type Last 4"
|
1576 |
msgstr ""
|
1577 |
|
1578 |
-
#: includes/tokens/class-wc-payment-token-stripe-cc.php:
|
1579 |
msgid "Type Dash & Last 4"
|
1580 |
msgstr ""
|
1581 |
|
1582 |
-
#: includes/tokens/class-wc-payment-token-stripe-cc.php:
|
1583 |
msgid "Last Four"
|
1584 |
msgstr ""
|
1585 |
|
1586 |
-
#: includes/tokens/class-wc-payment-token-stripe-cc.php:
|
1587 |
msgid "Card Type"
|
1588 |
msgstr ""
|
1589 |
|
1590 |
-
#: includes/tokens/class-wc-payment-token-stripe-local-payment.php:
|
1591 |
msgid "Gateway Title"
|
1592 |
msgstr ""
|
1593 |
|
1594 |
-
#: includes/
|
1595 |
-
|
1596 |
-
msgstr ""
|
1597 |
-
|
1598 |
-
#: includes/updates/update-3.1.0.php:31
|
1599 |
-
#: includes/updates/update-3.1.0.php:60
|
1600 |
msgid "Stripe For WooCommerce Update"
|
1601 |
msgstr ""
|
1602 |
|
1603 |
-
#: includes/updates/update-3.1.0.php:
|
1604 |
msgid "Greetings from Payment Plugins,"
|
1605 |
msgstr ""
|
1606 |
|
1607 |
-
#: includes/updates/update-3.1.0.php:
|
1608 |
msgid "At Stripe's request, we have updated Stripe for WooCommerce to use the new Stripe Connect integration. This new integration offers even more security. Stripe is requesting that all merchants switch."
|
1609 |
msgstr ""
|
1610 |
|
1611 |
-
#: includes/updates/update-3.1.0.php:
|
1612 |
-
msgid "Click %shere%s to be redirected to your Stripe API settings page then click the <strong>Click to Connect</strong> button."
|
1613 |
msgstr ""
|
1614 |
|
1615 |
-
#: includes/updates/update-3.1.0.php:
|
1616 |
msgid "Kind Regards,"
|
1617 |
msgstr ""
|
1618 |
|
1619 |
-
#: includes/wc-stripe-functions.php:
|
1620 |
msgid "Bootstrap form"
|
1621 |
msgstr ""
|
1622 |
|
1623 |
-
#: includes/wc-stripe-functions.php:
|
1624 |
msgid "Simple form"
|
1625 |
msgstr ""
|
1626 |
|
1627 |
-
#: includes/wc-stripe-functions.php:
|
1628 |
msgid "Minimalist form"
|
1629 |
msgstr ""
|
1630 |
|
1631 |
-
#: includes/wc-stripe-functions.php:
|
1632 |
msgid "Inline Form"
|
1633 |
msgstr ""
|
1634 |
|
1635 |
-
#: includes/wc-stripe-functions.php:
|
1636 |
msgid "Rounded Form"
|
1637 |
msgstr ""
|
1638 |
|
1639 |
-
#: includes/wc-stripe-functions.php:
|
1640 |
msgid "There was an error processing your credit card."
|
1641 |
msgstr ""
|
1642 |
|
1643 |
-
#: includes/wc-stripe-functions.php:
|
1644 |
msgid "Your card number is incomplete."
|
1645 |
msgstr ""
|
1646 |
|
1647 |
-
#: includes/wc-stripe-functions.php:
|
1648 |
msgid "The card number is incorrect. Check the card's number or use a different card."
|
1649 |
msgstr ""
|
1650 |
|
1651 |
-
#: includes/wc-stripe-functions.php:
|
1652 |
msgid "The card's security code is incorrect. Check the card's security code or use a different card."
|
1653 |
msgstr ""
|
1654 |
|
1655 |
-
#: includes/wc-stripe-functions.php:
|
1656 |
msgid "The card's ZIP code is incorrect. Check the card's ZIP code or use a different card."
|
1657 |
msgstr ""
|
1658 |
|
1659 |
-
#: includes/wc-stripe-functions.php:
|
1660 |
-
#: includes/wc-stripe-functions.php:
|
1661 |
msgid "The card number is invalid. Check the card details or use a different card."
|
1662 |
msgstr ""
|
1663 |
|
1664 |
-
#: includes/wc-stripe-functions.php:
|
1665 |
msgid "This value provided to the field contains characters that are unsupported by the field."
|
1666 |
msgstr ""
|
1667 |
|
1668 |
-
#: includes/wc-stripe-functions.php:
|
1669 |
msgid "The card's security code is invalid. Check the card's security code or use a different card."
|
1670 |
msgstr ""
|
1671 |
|
1672 |
-
#: includes/wc-stripe-functions.php:
|
1673 |
msgid "The card's expiration month is incorrect. Check the expiration date or use a different card."
|
1674 |
msgstr ""
|
1675 |
|
1676 |
-
#: includes/wc-stripe-functions.php:
|
1677 |
msgid "The card's expiration year is incorrect. Check the expiration date or use a different card."
|
1678 |
msgstr ""
|
1679 |
|
1680 |
-
#: includes/wc-stripe-functions.php:
|
1681 |
msgid "The card's address is incorrect. Check the card's address or use a different card."
|
1682 |
msgstr ""
|
1683 |
|
1684 |
-
#: includes/wc-stripe-functions.php:
|
1685 |
msgid "The card has expired. Check the expiration date or use a different card."
|
1686 |
msgstr ""
|
1687 |
|
1688 |
-
#: includes/wc-stripe-functions.php:
|
1689 |
msgid "The card has been declined."
|
1690 |
msgstr ""
|
1691 |
|
1692 |
-
#: includes/wc-stripe-functions.php:
|
1693 |
msgid "Your card's expiration year is in the past."
|
1694 |
msgstr ""
|
1695 |
|
1696 |
-
#: includes/wc-stripe-functions.php:
|
1697 |
msgid "The bank account number provided is invalid (e.g., missing digits). Bank account information varies from country to country. We recommend creating validations in your entry forms based on the bank account formats we provide."
|
1698 |
msgstr ""
|
1699 |
|
1700 |
-
#: includes/wc-stripe-functions.php:
|
1701 |
msgid "The specified amount is greater than the maximum amount allowed. Use a lower amount and try again."
|
1702 |
msgstr ""
|
1703 |
|
1704 |
-
#: includes/wc-stripe-functions.php:
|
1705 |
msgid "The specified amount is less than the minimum amount allowed. Use a higher amount and try again."
|
1706 |
msgstr ""
|
1707 |
|
1708 |
-
#: includes/wc-stripe-functions.php:
|
1709 |
msgid "The payment requires authentication to proceed. If your customer is off session, notify your customer to return to your application and complete the payment. If you provided the error_on_requires_action parameter, then your customer should try another card that does not require authentication."
|
1710 |
msgstr ""
|
1711 |
|
1712 |
-
#: includes/wc-stripe-functions.php:
|
1713 |
msgid "The transfer or payout could not be completed because the associated account does not have a sufficient balance available. Create a new transfer or payout using an amount less than or equal to the account's available balance."
|
1714 |
msgstr ""
|
1715 |
|
1716 |
-
#: includes/wc-stripe-functions.php:
|
1717 |
msgid "The bank account provided can not be used to charge, either because it is not verified yet or it is not supported."
|
1718 |
msgstr ""
|
1719 |
|
1720 |
-
#: includes/wc-stripe-functions.php:
|
1721 |
msgid "The bank account provided already exists on the specified Customer object. If the bank account should also be attached to a different customer, include the correct customer ID when making the request again."
|
1722 |
msgstr ""
|
1723 |
|
1724 |
-
#: includes/wc-stripe-functions.php:
|
1725 |
msgid "The bank account provided cannot be used for payouts. A different bank account must be used."
|
1726 |
msgstr ""
|
1727 |
|
1728 |
-
#: includes/wc-stripe-functions.php:
|
1729 |
msgid "Your Connect platform is attempting to share an unverified bank account with a connected account."
|
1730 |
msgstr ""
|
1731 |
|
1732 |
-
#: includes/wc-stripe-functions.php:
|
1733 |
msgid "The bank account cannot be verified, either because the microdeposit amounts provided do not match the actual amounts, or because verification has failed too many times."
|
1734 |
msgstr ""
|
1735 |
|
1736 |
-
#: includes/wc-stripe-functions.php:
|
1737 |
msgid "This card has been declined too many times. You can try to charge this card again after 24 hours. We suggest reaching out to your customer to make sure they have entered all of their information correctly and that there are no issues with their card."
|
1738 |
msgstr ""
|
1739 |
|
1740 |
-
#: includes/wc-stripe-functions.php:
|
1741 |
msgid "The charge you're attempting to capture has already been captured. Update the request with an uncaptured charge ID."
|
1742 |
msgstr ""
|
1743 |
|
1744 |
-
#: includes/wc-stripe-functions.php:
|
1745 |
msgid "The charge you're attempting to refund has already been refunded. Update the request to use the ID of a charge that has not been refunded."
|
1746 |
msgstr ""
|
1747 |
|
1748 |
-
#: includes/wc-stripe-functions.php:
|
1749 |
msgid "The charge you're attempting to refund has been charged back. Check the disputes documentation to learn how to respond to the dispute."
|
1750 |
msgstr ""
|
1751 |
|
1752 |
-
#: includes/wc-stripe-functions.php:
|
1753 |
msgid "This charge would cause you to exceed your rolling-window processing limit for this source type. Please retry the charge later, or contact us to request a higher processing limit."
|
1754 |
msgstr ""
|
1755 |
|
1756 |
-
#: includes/wc-stripe-functions.php:
|
1757 |
msgid "The charge cannot be captured as the authorization has expired. Auth and capture charges must be captured within seven days."
|
1758 |
msgstr ""
|
1759 |
|
1760 |
-
#: includes/wc-stripe-functions.php:
|
1761 |
msgid "One or more provided parameters was not allowed for the given operation on the Charge. Check our API reference or the returned error message to see which values were not correct for that Charge."
|
1762 |
msgstr ""
|
1763 |
|
1764 |
-
#: includes/wc-stripe-functions.php:
|
1765 |
msgid "The email address is invalid (e.g., not properly formatted). Check that the email address is properly formatted and only includes allowed characters."
|
1766 |
msgstr ""
|
1767 |
|
1768 |
-
#: includes/wc-stripe-functions.php:
|
1769 |
msgid "The idempotency key provided is currently being used in another request. This occurs if your integration is making duplicate requests simultaneously."
|
1770 |
msgstr ""
|
1771 |
|
1772 |
-
#: includes/wc-stripe-functions.php:
|
1773 |
msgid "The specified amount is invalid. The charge amount must be a positive integer in the smallest currency unit, and not exceed the minimum or maximum amount."
|
1774 |
msgstr ""
|
1775 |
|
1776 |
-
#: includes/wc-stripe-functions.php:
|
1777 |
msgid "The source cannot be used because it is not in the correct state (e.g., a charge request is trying to use a source with a pending, failed, or consumed source). Check the status of the source you are attempting to use."
|
1778 |
msgstr ""
|
1779 |
|
1780 |
-
#: includes/wc-stripe-functions.php:
|
1781 |
msgid "Both a customer and source ID have been provided, but the source has not been saved to the customer. To create a charge for a customer with a specified source, you must first save the card details."
|
1782 |
msgstr ""
|
1783 |
|
1784 |
-
#: includes/wc-stripe-functions.php:
|
1785 |
msgid "The ZIP code provided was incorrect."
|
1786 |
msgstr ""
|
1787 |
|
1788 |
-
#: includes/wc-stripe-functions.php:
|
1789 |
msgid "An error occurred while processing the card. Try again later or with a different payment method."
|
1790 |
msgstr ""
|
1791 |
|
1792 |
-
#: includes/wc-stripe-functions.php:
|
1793 |
msgid "The card does not support this type of purchase."
|
1794 |
msgstr ""
|
1795 |
|
1796 |
-
#: includes/wc-stripe-functions.php:
|
1797 |
-
#: includes/wc-stripe-functions.php:
|
1798 |
-
#: includes/wc-stripe-functions.php:
|
1799 |
msgid "The card has been declined for an unknown reason."
|
1800 |
msgstr ""
|
1801 |
|
1802 |
-
#: includes/wc-stripe-functions.php:
|
1803 |
msgid "The customer has exceeded the balance or credit limit available on their card."
|
1804 |
msgstr ""
|
1805 |
|
1806 |
-
#: includes/wc-stripe-functions.php:
|
1807 |
msgid "The card does not support the specified currency."
|
1808 |
msgstr ""
|
1809 |
|
1810 |
-
#: includes/wc-stripe-functions.php:
|
1811 |
msgid "The payment has been declined as Stripe suspects it is fraudulent."
|
1812 |
msgstr ""
|
1813 |
|
1814 |
-
#: includes/wc-stripe-functions.php:
|
1815 |
msgid "The PIN entered is incorrect. "
|
1816 |
msgstr ""
|
1817 |
|
1818 |
-
#: includes/wc-stripe-functions.php:
|
1819 |
msgid "The card has insufficient funds to complete the purchase."
|
1820 |
msgstr ""
|
1821 |
|
1822 |
-
#: includes/wc-stripe-functions.php:
|
1823 |
msgid "Please select a payment method before proceeding."
|
1824 |
msgstr ""
|
1825 |
|
1826 |
-
#: includes/wc-stripe-functions.php:
|
1827 |
msgid "Please enter your IBAN before proceeding."
|
1828 |
msgstr ""
|
1829 |
|
1830 |
-
#: includes/wc-stripe-functions.php:
|
1831 |
msgid "Please select a bank before proceeding"
|
1832 |
msgstr ""
|
1833 |
|
1834 |
-
#: includes/wc-stripe-webhook-functions.php:
|
1835 |
msgid "Charge.succeeded webhook received. Payment has been completed."
|
1836 |
msgstr ""
|
1837 |
|
1838 |
-
#: includes/wc-stripe-webhook-functions.php:
|
1839 |
-
msgid "payment_intent.succeeded webhook
|
1840 |
msgstr ""
|
1841 |
|
1842 |
#: stripe-payments.php:17
|
1843 |
-
msgid "Your PHP version is %s but Stripe requires version 5.
|
1844 |
msgstr ""
|
1845 |
|
1846 |
#: templates/cart/payment-methods.php:13
|
2 |
# This file is distributed under the same license as the Stripe For WooCommerce plugin.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: Stripe For WooCommerce 3.1.6\n"
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/woo-stripe-payment\n"
|
7 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
8 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
9 |
"MIME-Version: 1.0\n"
|
10 |
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
"Content-Transfer-Encoding: 8bit\n"
|
12 |
+
"POT-Creation-Date: 2020-07-03T16:13:39+00:00\n"
|
13 |
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
14 |
"X-Generator: WP-CLI 2.4.0\n"
|
15 |
"X-Domain: woo-stripe-payment\n"
|
30 |
msgid "Payment Plugins, support@paymentplugins.com"
|
31 |
msgstr ""
|
32 |
|
33 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:101
|
34 |
+
#: includes/admin/meta-boxes/views/html-product-data.php:14
|
35 |
+
#: includes/gateways/settings/ach-settings-v2.php:9
|
36 |
+
#: includes/gateways/settings/ach-settings.php:9
|
37 |
+
#: includes/gateways/settings/applepay-settings.php:11
|
38 |
#: includes/gateways/settings/cc-settings.php:4
|
39 |
+
#: includes/gateways/settings/googlepay-settings.php:22
|
40 |
+
#: includes/gateways/settings/payment-request-settings.php:12
|
41 |
msgid "Enabled"
|
42 |
msgstr ""
|
43 |
|
44 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:106
|
45 |
msgid "If enabled, your site can accept %s payments through Stripe."
|
46 |
msgstr ""
|
47 |
|
48 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:110
|
49 |
+
#: includes/gateways/settings/ach-settings-v2.php:64
|
50 |
+
#: includes/gateways/settings/ach-settings.php:73
|
51 |
+
#: includes/gateways/settings/applepay-settings.php:20
|
52 |
+
#: includes/gateways/settings/cc-settings.php:17
|
53 |
+
#: includes/gateways/settings/googlepay-settings.php:31
|
54 |
+
#: includes/gateways/settings/payment-request-settings.php:21
|
55 |
msgid "General Settings"
|
56 |
msgstr ""
|
57 |
|
58 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:114
|
59 |
#: includes/admin/meta-boxes/views/html-charge-data-subview.php:47
|
60 |
+
#: includes/gateways/settings/ach-settings-v2.php:68
|
61 |
+
#: includes/gateways/settings/ach-settings.php:77
|
62 |
+
#: includes/gateways/settings/applepay-settings.php:24
|
63 |
+
#: includes/gateways/settings/cc-settings.php:21
|
64 |
+
#: includes/gateways/settings/googlepay-settings.php:48
|
65 |
+
#: includes/gateways/settings/payment-request-settings.php:25
|
66 |
msgid "Title"
|
67 |
msgstr ""
|
68 |
|
69 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:120
|
70 |
+
#: includes/gateways/settings/ach-settings-v2.php:74
|
71 |
+
#: includes/gateways/settings/ach-settings.php:83
|
72 |
+
#: includes/gateways/settings/applepay-settings.php:30
|
73 |
+
#: includes/gateways/settings/cc-settings.php:27
|
74 |
+
#: includes/gateways/settings/googlepay-settings.php:54
|
75 |
+
#: includes/gateways/settings/payment-request-settings.php:31
|
76 |
msgid "Description"
|
77 |
msgstr ""
|
78 |
|
79 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:123
|
80 |
+
#: includes/gateways/settings/ach-settings-v2.php:77
|
81 |
+
#: includes/gateways/settings/ach-settings.php:86
|
82 |
+
#: includes/gateways/settings/applepay-settings.php:33
|
83 |
+
#: includes/gateways/settings/cc-settings.php:30
|
84 |
+
#: includes/gateways/settings/googlepay-settings.php:57
|
85 |
+
#: includes/gateways/settings/payment-request-settings.php:34
|
86 |
msgid "Leave blank if you don't want a description to show for the gateway."
|
87 |
msgstr ""
|
88 |
|
89 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:172
|
90 |
msgid "Order %s"
|
91 |
msgstr ""
|
92 |
|
93 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:241
|
94 |
msgid "Gateway will appear when store currency is <strong>%s</strong>"
|
95 |
msgstr ""
|
96 |
|
97 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:244
|
98 |
msgid " & billing country is <strong>%s</strong>"
|
99 |
msgstr ""
|
100 |
|
101 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:344
|
102 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-ach.php:115
|
103 |
msgid "Error processing payment. Reason: %s"
|
104 |
msgstr ""
|
105 |
|
106 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:352
|
107 |
+
msgid "Charge %1$s is pending. Payment Method: %2$s. Payment will be completed once charge.succeeded webhook received from Stripe."
|
108 |
msgstr ""
|
109 |
|
110 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:360
|
111 |
+
msgid "Order %1$s successful in Stripe. Charge: %2$s. Payment Method: %3$s"
|
112 |
msgstr ""
|
113 |
|
114 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:360
|
115 |
msgid "charge"
|
116 |
msgstr ""
|
117 |
|
118 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:360
|
119 |
msgid "authorization"
|
120 |
msgstr ""
|
121 |
|
122 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:404
|
123 |
+
#: includes/controllers/class-wc-stripe-controller-cart.php:128
|
124 |
+
#: includes/controllers/class-wc-stripe-controller-cart.php:187
|
125 |
+
#: includes/controllers/class-wc-stripe-controller-googlepay.php:135
|
126 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:101
|
127 |
msgid "Total"
|
128 |
msgstr ""
|
129 |
|
130 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:463
|
131 |
msgid "User must be logged in."
|
132 |
msgstr ""
|
133 |
|
134 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:475
|
135 |
msgid "Error saving your payment method. Reason: %s"
|
136 |
msgstr ""
|
137 |
|
138 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:490
|
139 |
msgid "Error saving payment method. Reason: %s"
|
140 |
msgstr ""
|
141 |
|
142 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:509
|
143 |
msgid "Order refunded in Stripe. Amount: %s"
|
144 |
msgstr ""
|
145 |
|
146 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:547
|
147 |
msgid "Order amount captured in Stripe. Amount: %s"
|
148 |
msgstr ""
|
149 |
|
150 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:557
|
151 |
msgid "Error capturing charge in Stripe. Reason: %s"
|
152 |
msgstr ""
|
153 |
|
154 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:578
|
155 |
msgid "Error voiding charge. Reason: %s"
|
156 |
msgstr ""
|
157 |
|
158 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:580
|
159 |
msgid "Charge voided in Stripe."
|
160 |
msgstr ""
|
161 |
|
162 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:750
|
163 |
msgid "n/a"
|
164 |
msgstr ""
|
165 |
|
166 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:778
|
167 |
#: includes/admin/meta-boxes/views/html-order-pay.php:42
|
168 |
msgid "New Card"
|
169 |
msgstr ""
|
170 |
|
171 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:782
|
172 |
#: includes/admin/meta-boxes/views/html-order-pay.php:30
|
173 |
msgid "Saved Cards"
|
174 |
msgstr ""
|
175 |
|
176 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:955
|
177 |
msgid "Attemp to save payment method failed. Reason: %s"
|
178 |
msgstr ""
|
179 |
|
180 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:977
|
181 |
msgid "We were not able to save your payment method. To prevent billing issues with your subscription, please add a payment method to the subscription."
|
182 |
msgstr ""
|
183 |
|
184 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:979
|
185 |
msgid "We were not able to save your payment method. Reason: %s"
|
186 |
msgstr ""
|
187 |
|
188 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:1013
|
189 |
msgid "Payment Method Token"
|
190 |
msgstr ""
|
191 |
|
192 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:1033
|
193 |
msgid "Recurring payment for order failed. Reason: %s"
|
194 |
msgstr ""
|
195 |
|
196 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:1046
|
197 |
msgid "Recurring payment captured in Stripe. Payment method: %s"
|
198 |
msgstr ""
|
199 |
|
200 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:1048
|
201 |
msgid "Recurring payment authorized in Stripe. Payment method: %s"
|
202 |
msgstr ""
|
203 |
|
204 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:1051
|
205 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:1308
|
206 |
msgid "Customer must manually complete payment for payment method %s"
|
207 |
msgstr ""
|
208 |
|
209 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:1067
|
210 |
msgid "Error saving payment method for subscription. Reason: %s"
|
211 |
msgstr ""
|
212 |
|
213 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:1126
|
214 |
+
#: includes/abstract/abstract-wc-stripe-payment.php:182
|
215 |
+
msgid "Order %1$s from %2$s"
|
216 |
msgstr ""
|
217 |
|
218 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:1295
|
219 |
msgid "Pre-order payment for order failed. Reason: %s"
|
220 |
msgstr ""
|
221 |
|
222 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:1303
|
223 |
msgid "Pre-order payment captured in Stripe. Payment method: %s"
|
224 |
msgstr ""
|
225 |
|
226 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:1305
|
227 |
msgid "Pre-order payment authorized in Stripe. Payment method: %s"
|
228 |
msgstr ""
|
229 |
|
230 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:1377
|
231 |
msgid "Cannot process payment"
|
232 |
msgstr ""
|
233 |
|
234 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:1385
|
235 |
msgid "Increase your conversion rate by offering %1$s on your Product and Cart pages, or at the top of the checkout page. <br/><strong>Note:</strong> you can control which products display %s by going to the product edit page."
|
236 |
msgstr ""
|
237 |
|
238 |
+
#: includes/abstract/abstract-wc-stripe-payment.php:104
|
239 |
msgid "Transaction Id cannot be empty."
|
240 |
msgstr ""
|
241 |
|
243 |
msgid "You do not have permissions to access this resource."
|
244 |
msgstr ""
|
245 |
|
246 |
+
#: includes/admin/class-wc-stripe-admin-menus.php:19
|
247 |
msgid "Stripe Gateway"
|
248 |
msgstr ""
|
249 |
|
250 |
+
#: includes/admin/class-wc-stripe-admin-menus.php:23
|
251 |
+
#: includes/class-wc-stripe-install.php:32
|
252 |
msgid "Settings"
|
253 |
msgstr ""
|
254 |
|
255 |
+
#: includes/admin/class-wc-stripe-admin-menus.php:24
|
256 |
msgid "Logs"
|
257 |
msgstr ""
|
258 |
|
259 |
+
#: includes/admin/class-wc-stripe-admin-menus.php:25
|
260 |
+
#: includes/admin/views/html-settings-nav.php:24
|
261 |
+
#: includes/class-wc-stripe-install.php:33
|
262 |
msgid "Documentation"
|
263 |
msgstr ""
|
264 |
|
265 |
#: includes/admin/class-wc-stripe-admin-notices.php:51
|
266 |
msgid ""
|
267 |
+
"At Stripe's request we have updated how the Stripe for WooCommerce\n"
|
268 |
+
" plugin integrates with Stripe. This new integration offers even more security and \n"
|
269 |
+
" Stripe is requesting that all merchants switch. %1$sUpdate Integration%2$s"
|
270 |
msgstr ""
|
271 |
|
272 |
+
#: includes/admin/class-wc-stripe-admin-settings.php:61
|
273 |
msgid "Local Gateways"
|
274 |
msgstr ""
|
275 |
|
276 |
+
#: includes/admin/class-wc-stripe-admin-settings.php:73
|
277 |
msgid "Stripe Email Options"
|
278 |
msgstr ""
|
279 |
|
280 |
+
#: includes/admin/class-wc-stripe-admin-settings.php:77
|
281 |
msgid "Email Receipt"
|
282 |
msgstr ""
|
283 |
|
284 |
+
#: includes/admin/class-wc-stripe-admin-settings.php:80
|
285 |
msgid "If enabled, an email receipt will be sent to the customer by Stripe when the order is processed."
|
286 |
msgstr ""
|
287 |
|
288 |
+
#: includes/admin/meta-boxes/class-wc-stripe-admin-meta-box-product-data.php:19
|
289 |
msgid "Stripe Settings"
|
290 |
msgstr ""
|
291 |
|
292 |
#: includes/admin/meta-boxes/views/html-charge-data-subview.php:9
|
293 |
+
#: includes/admin/views/html-user-profile.php:36
|
294 |
+
#: includes/admin/views/html-user-profile.php:69
|
295 |
msgid "Actions"
|
296 |
msgstr ""
|
297 |
|
300 |
msgstr ""
|
301 |
|
302 |
#: includes/admin/meta-boxes/views/html-charge-data-subview.php:14
|
303 |
+
#: includes/admin/meta-boxes/views/html-order-actions.php:48
|
304 |
#: includes/admin/meta-boxes/views/html-order-pay.php:23
|
305 |
+
#: includes/admin/meta-boxes/views/html-product-data.php:51
|
306 |
+
#: includes/gateways/settings/applepay-settings.php:52
|
307 |
+
#: includes/gateways/settings/cc-settings.php:49
|
308 |
+
#: includes/gateways/settings/googlepay-settings.php:76
|
309 |
+
#: includes/gateways/settings/payment-request-settings.php:53
|
310 |
msgid "Capture"
|
311 |
msgstr ""
|
312 |
|
319 |
msgstr ""
|
320 |
|
321 |
#: includes/admin/meta-boxes/views/html-charge-data-subview.php:24
|
322 |
+
#: includes/admin/settings/class-wc-stripe-api-settings.php:34
|
323 |
msgid "Mode"
|
324 |
msgstr ""
|
325 |
|
326 |
#: includes/admin/meta-boxes/views/html-charge-data-subview.php:25
|
327 |
+
#: includes/admin/settings/class-wc-stripe-api-settings.php:38
|
328 |
+
#: includes/controllers/class-wc-stripe-controller-gateway-settings.php:193
|
329 |
msgid "Live"
|
330 |
msgstr ""
|
331 |
|
342 |
msgstr ""
|
343 |
|
344 |
#: includes/admin/meta-boxes/views/html-charge-data-subview.php:45
|
345 |
+
#: includes/admin/views/html-user-profile.php:34
|
346 |
+
#: includes/admin/views/html-user-profile.php:67
|
347 |
msgid "Payment Method"
|
348 |
msgstr ""
|
349 |
|
350 |
#: includes/admin/meta-boxes/views/html-charge-data-subview.php:51
|
351 |
+
#: includes/admin/views/html-ach-fee.php:12
|
352 |
+
#: includes/gateways/settings/payment-request-settings.php:86
|
353 |
msgid "Type"
|
354 |
msgstr ""
|
355 |
|
379 |
msgid "Riska Data"
|
380 |
msgstr ""
|
381 |
|
382 |
+
#: includes/admin/meta-boxes/views/html-charge-data-subview.php:81
|
383 |
msgid "Score"
|
384 |
msgstr ""
|
385 |
|
386 |
+
#: includes/admin/meta-boxes/views/html-charge-data-subview.php:86
|
387 |
msgid "Level"
|
388 |
msgstr ""
|
389 |
|
390 |
+
#: includes/admin/meta-boxes/views/html-order-actions.php:2
|
391 |
msgid "Charge Status"
|
392 |
msgstr ""
|
393 |
|
394 |
+
#: includes/admin/meta-boxes/views/html-order-actions.php:9
|
395 |
msgid "Authorization Expires"
|
396 |
msgstr ""
|
397 |
|
398 |
+
#: includes/admin/meta-boxes/views/html-order-actions.php:18
|
399 |
msgid "There are no actions available at this time."
|
400 |
msgstr ""
|
401 |
|
402 |
+
#: includes/admin/meta-boxes/views/html-order-actions.php:27
|
403 |
msgid "Capture Charge"
|
404 |
msgstr ""
|
405 |
|
406 |
+
#: includes/admin/meta-boxes/views/html-order-actions.php:35
|
407 |
msgid "Total available to capture"
|
408 |
msgstr ""
|
409 |
|
410 |
+
#: includes/admin/meta-boxes/views/html-order-actions.php:39
|
411 |
msgid "Amount To Capture"
|
412 |
msgstr ""
|
413 |
|
414 |
+
#: includes/admin/meta-boxes/views/html-order-actions.php:49
|
415 |
msgid "Cancel"
|
416 |
msgstr ""
|
417 |
|
428 |
msgstr ""
|
429 |
|
430 |
#: includes/admin/meta-boxes/views/html-order-pay.php:21
|
431 |
+
#: includes/admin/meta-boxes/views/html-product-data.php:15
|
432 |
+
#: includes/gateways/settings/applepay-settings.php:48
|
433 |
+
#: includes/gateways/settings/cc-settings.php:45
|
434 |
+
#: includes/gateways/settings/googlepay-settings.php:72
|
435 |
+
#: includes/gateways/settings/payment-request-settings.php:49
|
436 |
msgid "Charge Type"
|
437 |
msgstr ""
|
438 |
|
439 |
#: includes/admin/meta-boxes/views/html-order-pay.php:24
|
440 |
+
#: includes/admin/meta-boxes/views/html-product-data.php:53
|
441 |
+
#: includes/gateways/settings/applepay-settings.php:53
|
442 |
+
#: includes/gateways/settings/cc-settings.php:50
|
443 |
+
#: includes/gateways/settings/googlepay-settings.php:77
|
444 |
+
#: includes/gateways/settings/payment-request-settings.php:54
|
445 |
msgid "Authorize"
|
446 |
msgstr ""
|
447 |
|
453 |
msgid "In this section you can control which gateways are displayed on the product page."
|
454 |
msgstr ""
|
455 |
|
456 |
+
#: includes/admin/meta-boxes/views/html-product-data.php:13
|
457 |
msgid "Method"
|
458 |
msgstr ""
|
459 |
|
460 |
+
#: includes/admin/meta-boxes/views/html-product-data.php:64
|
461 |
msgid "Button Position"
|
462 |
msgstr ""
|
463 |
|
464 |
+
#: includes/admin/meta-boxes/views/html-product-data.php:66
|
465 |
msgid "Below add to cart"
|
466 |
msgstr ""
|
467 |
|
468 |
+
#: includes/admin/meta-boxes/views/html-product-data.php:67
|
469 |
msgid "Above add to cart"
|
470 |
msgstr ""
|
471 |
|
472 |
+
#: includes/admin/meta-boxes/views/html-product-data.php:70
|
473 |
msgid "The location of the payment buttons in relation to the Add to Cart button."
|
474 |
msgstr ""
|
475 |
|
476 |
+
#: includes/admin/meta-boxes/views/html-product-data.php:79
|
477 |
msgid "Save"
|
478 |
msgstr ""
|
479 |
|
480 |
#: includes/admin/settings/class-wc-stripe-api-settings.php:15
|
481 |
+
#: includes/admin/settings/class-wc-stripe-api-settings.php:30
|
482 |
msgid "API Settings"
|
483 |
msgstr ""
|
484 |
|
485 |
+
#: includes/admin/settings/class-wc-stripe-api-settings.php:37
|
486 |
+
#: includes/controllers/class-wc-stripe-controller-gateway-settings.php:193
|
487 |
msgid "Test"
|
488 |
msgstr ""
|
489 |
|
490 |
+
#: includes/admin/settings/class-wc-stripe-api-settings.php:42
|
491 |
msgid "The mode determines if you are processing test transactions or live transactions on your site. Test mode allows you to simulate payments so you can test your integration."
|
492 |
msgstr ""
|
493 |
|
494 |
+
#: includes/admin/settings/class-wc-stripe-api-settings.php:46
|
495 |
msgid "Account ID"
|
496 |
msgstr ""
|
497 |
|
498 |
+
#: includes/admin/settings/class-wc-stripe-api-settings.php:51
|
499 |
msgid "This is your Stripe Connect ID and serves as a unique identifier."
|
500 |
msgstr ""
|
501 |
|
502 |
+
#: includes/admin/settings/class-wc-stripe-api-settings.php:55
|
503 |
msgid "Connect Stripe Account"
|
504 |
msgstr ""
|
505 |
|
506 |
+
#: includes/admin/settings/class-wc-stripe-api-settings.php:56
|
507 |
msgid "Click to Connect"
|
508 |
msgstr ""
|
509 |
|
510 |
+
#: includes/admin/settings/class-wc-stripe-api-settings.php:58
|
511 |
msgid "We make it easy to connect Stripe to your site. Click the Connect button to go through our connect flow."
|
512 |
msgstr ""
|
513 |
|
514 |
+
#: includes/admin/settings/class-wc-stripe-api-settings.php:62
|
515 |
#: includes/admin/settings/class-wc-stripe-api-settings.php:63
|
|
|
516 |
msgid "Connection Test"
|
517 |
msgstr ""
|
518 |
|
519 |
+
#: includes/admin/settings/class-wc-stripe-api-settings.php:65
|
520 |
msgid "Click this button to perform a connection test. If successful, your site is connected to Stripe."
|
521 |
msgstr ""
|
522 |
|
523 |
+
#: includes/admin/settings/class-wc-stripe-api-settings.php:69
|
524 |
msgid "Webhook url"
|
525 |
msgstr ""
|
526 |
|
527 |
+
#: includes/admin/settings/class-wc-stripe-api-settings.php:72
|
528 |
+
msgid "<strong>Important:</strong> the webhook url is called by Stripe when events occur in your account, like a source becomes chargeable. You must add this webhook to your Stripe Dashboard if you are using any of the local gateways. %1$sWebhook guide%2$s"
|
529 |
msgstr ""
|
530 |
|
531 |
+
#: includes/admin/settings/class-wc-stripe-api-settings.php:76
|
532 |
msgid "Live Webhook Secret"
|
533 |
msgstr ""
|
534 |
|
535 |
+
#: includes/admin/settings/class-wc-stripe-api-settings.php:77
|
536 |
+
#: includes/admin/settings/class-wc-stripe-api-settings.php:83
|
537 |
+
msgid "The webhook secret is used to authenticate webhooks sent from Stripe. It ensures no 3rd party can send you events, pretending to be Stripe. %1$sWebhook guide%2$s"
|
538 |
msgstr ""
|
539 |
|
540 |
+
#: includes/admin/settings/class-wc-stripe-api-settings.php:82
|
541 |
msgid "Test Webhook Secret"
|
542 |
msgstr ""
|
543 |
|
544 |
+
#: includes/admin/settings/class-wc-stripe-api-settings.php:87
|
545 |
msgid "Debug Log"
|
546 |
msgstr ""
|
547 |
|
548 |
+
#: includes/admin/settings/class-wc-stripe-api-settings.php:91
|
549 |
msgid "When enabled, the plugin logs important errors and info that can help you troubleshoot potential issues."
|
550 |
msgstr ""
|
551 |
|
552 |
+
#: includes/admin/settings/class-wc-stripe-api-settings.php:96
|
553 |
msgid "%s Your Stripe account has been connected. You can now accept Live and Test payments. You can Re-Connect if you want to recycle your API keys for security."
|
554 |
msgstr ""
|
555 |
|
556 |
+
#: includes/admin/settings/class-wc-stripe-api-settings.php:118
|
557 |
msgid "Click To Re-Connect"
|
558 |
msgstr ""
|
559 |
|
560 |
+
#: includes/admin/settings/class-wc-stripe-api-settings.php:136
|
561 |
msgid "Please try again."
|
562 |
msgstr ""
|
563 |
|
564 |
+
#: includes/admin/settings/class-wc-stripe-api-settings.php:139
|
565 |
msgid "We were not able to connect your Stripe account. Reason: %s"
|
566 |
msgstr ""
|
567 |
|
568 |
+
#: includes/admin/settings/class-wc-stripe-api-settings.php:168
|
569 |
msgid "Your Stripe account has been connected to your WooCommerce store. You may now accept payments in Live and Test mode."
|
570 |
msgstr ""
|
571 |
|
572 |
+
#: includes/admin/views/html-ach-fee.php:20
|
573 |
msgid "Taxable"
|
574 |
msgstr ""
|
575 |
|
576 |
+
#: includes/admin/views/html-ach-fee.php:27
|
577 |
msgid "Value"
|
578 |
msgstr ""
|
579 |
|
585 |
msgid "Live ID"
|
586 |
msgstr ""
|
587 |
|
588 |
+
#: includes/admin/views/html-user-profile.php:20
|
589 |
msgid "Test ID"
|
590 |
msgstr ""
|
591 |
|
592 |
+
#: includes/admin/views/html-user-profile.php:28
|
593 |
msgid "Stripe Live Payment Methods"
|
594 |
msgstr ""
|
595 |
|
596 |
+
#: includes/admin/views/html-user-profile.php:33
|
597 |
+
#: includes/admin/views/html-user-profile.php:66
|
598 |
msgid "Payment Gateway"
|
599 |
msgstr ""
|
600 |
|
601 |
+
#: includes/admin/views/html-user-profile.php:35
|
602 |
+
#: includes/admin/views/html-user-profile.php:68
|
603 |
msgid "Token"
|
604 |
msgstr ""
|
605 |
|
606 |
+
#: includes/admin/views/html-user-profile.php:52
|
607 |
+
#: includes/admin/views/html-user-profile.php:85
|
608 |
msgid "No Action"
|
609 |
msgstr ""
|
610 |
|
611 |
+
#: includes/admin/views/html-user-profile.php:53
|
612 |
+
#: includes/admin/views/html-user-profile.php:86
|
613 |
msgid "Delete"
|
614 |
msgstr ""
|
615 |
|
616 |
+
#: includes/admin/views/html-user-profile.php:59
|
617 |
msgid "No live payment methods saved"
|
618 |
msgstr ""
|
619 |
|
620 |
+
#: includes/admin/views/html-user-profile.php:61
|
621 |
msgid "Stripe Test Payment Methods"
|
622 |
msgstr ""
|
623 |
|
626 |
msgstr ""
|
627 |
|
628 |
#: includes/admin/views/html-user-profile.php:94
|
629 |
+
msgid "%1$snote:%2$s payment methods will be deleted in Stripe if you use the delete action."
|
630 |
msgstr ""
|
631 |
|
632 |
+
#: includes/class-wc-stripe-customer-manager.php:29
|
633 |
+
#: includes/class-wc-stripe-customer-manager.php:38
|
634 |
msgid "Error saving customer. Reason: %s"
|
635 |
msgstr ""
|
636 |
|
637 |
+
#: includes/class-wc-stripe-frontend-notices.php:35
|
638 |
msgid "Your payment is being processed and your order status will be updated once the funds are received."
|
639 |
msgstr ""
|
640 |
|
641 |
+
#: includes/class-wc-stripe-frontend-scripts.php:67
|
642 |
msgid "No matches found"
|
643 |
msgstr ""
|
644 |
|
645 |
+
#: includes/class-wc-stripe-redirect-handler.php:35
|
|
|
|
|
|
|
|
|
646 |
msgid "Error retrieving payment source. Reason: %s"
|
647 |
msgstr ""
|
648 |
|
649 |
+
#: includes/class-wc-stripe-redirect-handler.php:51
|
650 |
msgid "Payment authorization failed. Please select another payment method."
|
651 |
msgstr ""
|
652 |
|
653 |
+
#: includes/class-wc-stripe-redirect-handler.php:52
|
654 |
msgid "Payment authorization failed."
|
655 |
msgstr ""
|
656 |
|
657 |
+
#: includes/class-wc-stripe-rest-api.php:41
|
658 |
msgid "%1$s is an invalid controller name."
|
659 |
msgstr ""
|
660 |
|
661 |
+
#: includes/class-wc-stripe-update.php:46
|
662 |
msgid "Thank you for updating Stripe for WooCommerce to version %1$s."
|
663 |
msgstr ""
|
664 |
|
665 |
+
#: includes/controllers/class-wc-stripe-controller-cart.php:87
|
666 |
msgid "Quantity must be greater than zero."
|
667 |
msgstr ""
|
668 |
|
669 |
+
#: includes/controllers/class-wc-stripe-controller-checkout.php:199
|
670 |
+
msgid "Some required fields were missing. Please click %1$shere%2$s to complete your payment."
|
671 |
msgstr ""
|
672 |
|
673 |
+
#: includes/controllers/class-wc-stripe-controller-checkout.php:248
|
674 |
msgid "Please review your order details then click Place Order."
|
675 |
msgstr ""
|
676 |
|
677 |
+
#: includes/controllers/class-wc-stripe-controller-gateway-settings.php:91
|
678 |
msgid "You cannot register your domain until you have configured your Live API keys."
|
679 |
msgstr ""
|
680 |
|
681 |
+
#: includes/controllers/class-wc-stripe-controller-gateway-settings.php:120
|
682 |
msgid "Domain registered successfully. You can confirm in your Stripe Dashboard at https://dashboard.stripe.com/account/apple_pay."
|
683 |
msgstr ""
|
684 |
|
685 |
+
#: includes/controllers/class-wc-stripe-controller-gateway-settings.php:144
|
686 |
msgid "You must configure your secret key before creating webhooks."
|
687 |
msgstr ""
|
688 |
|
689 |
+
#: includes/controllers/class-wc-stripe-controller-gateway-settings.php:157
|
690 |
msgid "There is already a webhook configured for this site. If you want to delete the webhook, login to your Stripe Dashboard."
|
691 |
msgstr ""
|
692 |
|
693 |
+
#: includes/controllers/class-wc-stripe-controller-gateway-settings.php:191
|
694 |
msgid "Webhook created in Stripe for %s environment. You can test your webhook by logging in to the Stripe dashboard"
|
695 |
msgstr ""
|
696 |
|
697 |
+
#: includes/controllers/class-wc-stripe-controller-gateway-settings.php:214
|
698 |
msgid "Mode: %s. Invalid secret key. Please check your entry."
|
699 |
msgstr ""
|
700 |
|
701 |
+
#: includes/controllers/class-wc-stripe-controller-gateway-settings.php:226
|
702 |
+
#: includes/controllers/class-wc-stripe-controller-gateway-settings.php:229
|
703 |
msgid "Mode: %s. Invalid publishable key. Please check your entry."
|
704 |
msgstr ""
|
705 |
|
706 |
+
#: includes/controllers/class-wc-stripe-controller-gateway-settings.php:235
|
707 |
msgid "Connection test to Stripe was successful. Mode: %s."
|
708 |
msgstr ""
|
709 |
|
710 |
+
#: includes/controllers/class-wc-stripe-controller-googlepay.php:89
|
711 |
msgid "Your shipping address is not serviceable."
|
712 |
msgstr ""
|
713 |
|
714 |
+
#: includes/controllers/class-wc-stripe-controller-order-actions.php:125
|
715 |
msgid "Invalid amount entered."
|
716 |
msgstr ""
|
717 |
|
718 |
+
#: includes/controllers/class-wc-stripe-controller-order-actions.php:179
|
719 |
+
#: includes/controllers/class-wc-stripe-controller-order-actions.php:182
|
720 |
msgid "Order total must be greater than zero."
|
721 |
msgstr ""
|
722 |
|
723 |
+
#: includes/controllers/class-wc-stripe-controller-order-actions.php:192
|
724 |
+
msgid "This order has already been processed. Transaction ID: %1$s. Payment method: %2$s"
|
725 |
msgstr ""
|
726 |
|
727 |
+
#: includes/controllers/class-wc-stripe-controller-order-actions.php:201
|
728 |
msgid "Order customer Id and payment method customer Id do not match."
|
729 |
msgstr ""
|
730 |
|
732 |
msgid "Error creating payment intent. Reason: %s"
|
733 |
msgstr ""
|
734 |
|
735 |
+
#: includes/controllers/class-wc-stripe-controller-payment-intent.php:72
|
736 |
msgid "Invalid order id provided"
|
737 |
msgstr ""
|
738 |
|
739 |
+
#: includes/controllers/class-wc-stripe-controller-payment-intent.php:78
|
740 |
msgid "You are not authorized to update this order."
|
741 |
msgstr ""
|
742 |
|
743 |
+
#: includes/controllers/class-wc-stripe-controller-webhook.php:52
|
744 |
+
#: includes/controllers/class-wc-stripe-controller-webhook.php:53
|
745 |
msgid "Invalid signature received. Verify that your webhook secret is correct."
|
746 |
msgstr ""
|
747 |
|
|
|
748 |
#: includes/gateways/class-wc-payment-gateway-stripe-ach.php:26
|
749 |
msgid "ACH"
|
750 |
msgstr ""
|
751 |
|
|
|
752 |
#: includes/gateways/class-wc-payment-gateway-stripe-ach.php:29
|
753 |
msgid "Stripe ACH"
|
754 |
msgstr ""
|
755 |
|
|
|
756 |
#: includes/gateways/class-wc-payment-gateway-stripe-ach.php:30
|
757 |
msgid "ACH gateway that integrates with your Stripe account."
|
758 |
msgstr ""
|
759 |
|
|
|
760 |
#: includes/gateways/class-wc-payment-gateway-stripe-ach.php:32
|
761 |
msgid "Bank Payment"
|
762 |
msgstr ""
|
763 |
|
764 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-ach.php:217
|
|
|
765 |
msgid "Saved Banks"
|
766 |
msgstr ""
|
767 |
|
768 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-ach.php:221
|
|
|
769 |
msgid "New Bank"
|
770 |
msgstr ""
|
771 |
|
772 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-ach.php:265
|
|
|
773 |
msgid "You must set the API mode to live in order to enable the Plaid development environment."
|
774 |
msgstr ""
|
775 |
|
776 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-alipay.php:24
|
777 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-alipay.php:27
|
778 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-alipay.php:30
|
779 |
msgid "Alipay"
|
780 |
msgstr ""
|
781 |
|
782 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-alipay.php:28
|
783 |
msgid "Alipay gateway that integrates with your Stripe account."
|
784 |
msgstr ""
|
785 |
|
786 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-applepay.php:22
|
787 |
+
#: includes/gateways/settings/applepay-settings.php:25
|
788 |
msgid "Apple Pay"
|
789 |
msgstr ""
|
790 |
|
791 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-applepay.php:25
|
792 |
msgid "Stripe Apple Pay"
|
793 |
msgstr ""
|
794 |
|
795 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-applepay.php:26
|
796 |
msgid "Apple Pay gateway that integrates with your Stripe account."
|
797 |
msgstr ""
|
798 |
|
799 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-applepay.php:85
|
800 |
msgid "Please update you product quantity before using Apple Pay."
|
801 |
msgstr ""
|
802 |
|
803 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-applepay.php:86
|
804 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-payment-request.php:78
|
805 |
msgid "Please select a product option before updating quantity."
|
806 |
msgstr ""
|
807 |
|
808 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-bancontact.php:24
|
809 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-bancontact.php:27
|
810 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-bancontact.php:30
|
811 |
msgid "Bancontact"
|
812 |
msgstr ""
|
813 |
|
814 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-bancontact.php:28
|
815 |
msgid "Bancontact gateway that integrates with your Stripe account."
|
816 |
msgstr ""
|
817 |
|
818 |
#: includes/gateways/class-wc-payment-gateway-stripe-cc.php:19
|
819 |
+
#: includes/gateways/settings/cc-settings.php:22
|
820 |
msgid "Credit Cards"
|
821 |
msgstr ""
|
822 |
|
828 |
msgid "Credit card gateway that integrates with your Stripe account."
|
829 |
msgstr ""
|
830 |
|
831 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-eps.php:23
|
832 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-eps.php:26
|
833 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-eps.php:29
|
834 |
msgid "EPS"
|
835 |
msgstr ""
|
836 |
|
837 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-eps.php:27
|
838 |
msgid "EPS gateway that integrates with your Stripe account."
|
839 |
msgstr ""
|
840 |
|
841 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-fpx.php:25
|
842 |
#: includes/gateways/class-wc-payment-gateway-stripe-fpx.php:26
|
843 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-fpx.php:29
|
|
|
844 |
msgid "FPX"
|
845 |
msgstr ""
|
846 |
|
847 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-fpx.php:27
|
848 |
msgid "FPX gateway that integrates with your Stripe account."
|
849 |
msgstr ""
|
850 |
|
851 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-giropay.php:23
|
852 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-giropay.php:26
|
853 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-giropay.php:29
|
854 |
msgid "Giropay"
|
855 |
msgstr ""
|
856 |
|
857 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-giropay.php:27
|
858 |
msgid "Giropay gateway that integrates with your Stripe account."
|
859 |
msgstr ""
|
860 |
|
861 |
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:20
|
862 |
+
#: includes/gateways/settings/googlepay-settings.php:49
|
863 |
msgid "Google Pay"
|
864 |
msgstr ""
|
865 |
|
871 |
msgid "Google Pay gateway that integrates with your Stripe account."
|
872 |
msgstr ""
|
873 |
|
874 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:103
|
875 |
msgid "Please update you product quantity before using Google Pay."
|
876 |
msgstr ""
|
877 |
|
878 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:117
|
879 |
msgid "Subscription"
|
880 |
msgstr ""
|
881 |
|
882 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:147
|
883 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:198
|
884 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:202
|
885 |
+
#: includes/wc-stripe-functions.php:401
|
886 |
+
#: includes/wc-stripe-functions.php:457
|
887 |
msgid "Shipping"
|
888 |
msgstr ""
|
889 |
|
890 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:155
|
891 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:220
|
892 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:212
|
893 |
+
#: includes/wc-stripe-functions.php:418
|
894 |
+
#: includes/wc-stripe-functions.php:465
|
895 |
msgid "Discount"
|
896 |
msgstr ""
|
897 |
|
898 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:166
|
899 |
+
#: includes/wc-stripe-functions.php:476
|
900 |
msgid "Fees"
|
901 |
msgstr ""
|
902 |
|
903 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:234
|
904 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:234
|
905 |
+
#: includes/wc-stripe-functions.php:426
|
906 |
msgid "Tax"
|
907 |
msgstr ""
|
908 |
|
909 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:274
|
|
|
910 |
msgid "Waiting..."
|
911 |
msgstr ""
|
912 |
|
913 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:275
|
|
|
914 |
msgid "loading shipping methods..."
|
915 |
msgstr ""
|
916 |
|
917 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-ideal.php:27
|
918 |
#: includes/gateways/class-wc-payment-gateway-stripe-ideal.php:28
|
919 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-ideal.php:31
|
|
|
920 |
msgid "iDEAL"
|
921 |
msgstr ""
|
922 |
|
923 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-ideal.php:29
|
924 |
msgid "Ideal gateway that integrates with your Stripe account."
|
925 |
msgstr ""
|
926 |
|
927 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:22
|
928 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:25
|
929 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:28
|
930 |
msgid "Klarna"
|
931 |
msgstr ""
|
932 |
|
933 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:26
|
934 |
msgid "Klarna gateway that integrates with your Stripe account."
|
935 |
msgstr ""
|
936 |
|
937 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:102
|
938 |
msgid "Payment Categories"
|
939 |
msgstr ""
|
940 |
|
941 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:108
|
942 |
+
msgid "These are the payment categories that will be displayed on the checkout page if they are supported. Note, depending on the customer's billing country, not all enabled options may show."
|
943 |
msgstr ""
|
944 |
|
945 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:226
|
946 |
msgid "Fee"
|
947 |
msgstr ""
|
948 |
|
949 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:270
|
950 |
msgid "Pay Now"
|
951 |
msgstr ""
|
952 |
|
953 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:271
|
954 |
msgid "Pay Later"
|
955 |
msgstr ""
|
956 |
|
957 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:272
|
958 |
msgid "Pay Over Time"
|
959 |
msgstr ""
|
960 |
|
961 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:288
|
962 |
+
msgid "Click %1$shere%2$s for Klarna test payment methods."
|
963 |
msgstr ""
|
964 |
|
965 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:294
|
966 |
msgid "Your purchase is not approved."
|
967 |
msgstr ""
|
968 |
|
969 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-multibanco.php:23
|
970 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-multibanco.php:26
|
971 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-multibanco.php:29
|
972 |
msgid "Multibanco"
|
973 |
msgstr ""
|
974 |
|
975 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-multibanco.php:27
|
976 |
msgid "Multibanco gateway that integrates with your Stripe account."
|
977 |
msgstr ""
|
978 |
|
979 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-p24.php:23
|
980 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-p24.php:26
|
981 |
msgid "Przelewy24"
|
982 |
msgstr ""
|
983 |
|
984 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-p24.php:27
|
985 |
msgid "P24 gateway that integrates with your Stripe account."
|
986 |
msgstr ""
|
987 |
|
988 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-p24.php:29
|
989 |
msgid "P24"
|
990 |
msgstr ""
|
991 |
|
992 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-payment-request.php:23
|
993 |
msgid "PaymentRequest Gateway"
|
994 |
msgstr ""
|
995 |
|
996 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-payment-request.php:26
|
997 |
msgid "Stripe Payment Request"
|
998 |
msgstr ""
|
999 |
|
1000 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-payment-request.php:27
|
1001 |
msgid "Gateway that renders based on the user's browser. Chrome payment methods, Microsoft pay, etc."
|
1002 |
msgstr ""
|
1003 |
|
1004 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-payment-request.php:76
|
1005 |
msgid "Please update you product quantity before paying."
|
1006 |
msgstr ""
|
1007 |
|
1008 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-payment-request.php:77
|
1009 |
msgid "Adding to cart..."
|
1010 |
msgstr ""
|
1011 |
|
1022 |
msgid "Sepa gateway that integrates with your Stripe account."
|
1023 |
msgstr ""
|
1024 |
|
1025 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-sepa.php:33
|
1026 |
msgid ""
|
1027 |
+
"By providing your IBAN and confirming this payment, you are\n"
|
1028 |
+
"\t\t\tauthorizing %s and Stripe, our payment service provider, to send instructions to your bank to debit your account\n"
|
1029 |
+
"\t\t\tand your bank to debit your account in accordance with those instructions. You are entitled to a refund from your bank under the\n"
|
1030 |
"\t\t\tterms and conditions of your agreement with your bank. A refund must be claimed within 8 weeks starting from the date on which your account was debited."
|
1031 |
msgstr ""
|
1032 |
|
1033 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-sepa.php:51
|
1034 |
msgid "Company Name"
|
1035 |
msgstr ""
|
1036 |
|
1037 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-sepa.php:55
|
1038 |
msgid "The name of your company that will appear in the SEPA mandate."
|
1039 |
msgstr ""
|
1040 |
|
1041 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-sepa.php:62
|
1042 |
msgid "SEPA Test Accounts"
|
1043 |
msgstr ""
|
1044 |
|
1045 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-sofort.php:24
|
1046 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-sofort.php:27
|
1047 |
msgid "Sofort"
|
1048 |
msgstr ""
|
1049 |
|
1050 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-sofort.php:28
|
1051 |
msgid "Sofort gateway that integrates with your Stripe account."
|
1052 |
msgstr ""
|
1053 |
|
1054 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-sofort.php:30
|
1055 |
msgid "SOFORT"
|
1056 |
msgstr ""
|
1057 |
|
1058 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-wechat.php:24
|
1059 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-wechat.php:27
|
1060 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-wechat.php:30
|
1061 |
msgid "WeChat"
|
1062 |
msgstr ""
|
1063 |
|
1064 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-wechat.php:28
|
1065 |
msgid "WeChat gateway that integrates with your Stripe account."
|
1066 |
msgstr ""
|
1067 |
|
1068 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-wechat.php:70
|
1069 |
msgid "Scan the QR code using your WeChat app. Once scanned click the Place Order button."
|
1070 |
msgstr ""
|
1071 |
|
1072 |
+
#: includes/gateways/settings/ach-settings-v2.php:5
|
1073 |
+
#: includes/gateways/settings/ach-settings.php:5
|
1074 |
msgid "For US customers only."
|
1075 |
msgstr ""
|
1076 |
|
1077 |
+
#: includes/gateways/settings/ach-settings-v2.php:6
|
1078 |
+
#: includes/gateways/settings/ach-settings.php:6
|
1079 |
+
msgid "Read through our %1$sdocumentation%2$s to configure ACH payments"
|
1080 |
msgstr ""
|
1081 |
|
1082 |
+
#: includes/gateways/settings/ach-settings-v2.php:14
|
1083 |
+
#: includes/gateways/settings/ach-settings.php:14
|
1084 |
msgid "If enabled, your site can accept ACH payments through Stripe."
|
1085 |
msgstr ""
|
1086 |
|
1087 |
+
#: includes/gateways/settings/ach-settings-v2.php:18
|
1088 |
+
#: includes/gateways/settings/ach-settings.php:18
|
1089 |
msgid "Plaid Environment"
|
1090 |
msgstr ""
|
1091 |
|
1092 |
+
#: includes/gateways/settings/ach-settings-v2.php:20
|
1093 |
+
#: includes/gateways/settings/ach-settings.php:21
|
1094 |
msgid "Sandbox"
|
1095 |
msgstr ""
|
1096 |
|
1097 |
+
#: includes/gateways/settings/ach-settings-v2.php:21
|
1098 |
+
#: includes/gateways/settings/ach-settings.php:22
|
1099 |
msgid "Development"
|
1100 |
msgstr ""
|
1101 |
|
1102 |
+
#: includes/gateways/settings/ach-settings-v2.php:22
|
1103 |
+
#: includes/gateways/settings/ach-settings.php:23
|
1104 |
msgid "Production"
|
1105 |
msgstr ""
|
1106 |
|
1107 |
+
#: includes/gateways/settings/ach-settings-v2.php:24
|
1108 |
msgid "This setting determines the Plaid environment you are connecting with. When you are ready to accept live transactions, switch this option to Production.<br><strong>Production</strong> - accept live ACH payments <br><strong>Development</strong> - use real bank login details with test transactions <br><strong>Sandbox</strong> - test integration using test credentials"
|
1109 |
msgstr ""
|
1110 |
|
1111 |
+
#: includes/gateways/settings/ach-settings-v2.php:69
|
1112 |
+
#: includes/gateways/settings/ach-settings.php:78
|
1113 |
msgid "ACH Payment"
|
1114 |
msgstr ""
|
1115 |
|
1116 |
+
#: includes/gateways/settings/ach-settings-v2.php:82
|
1117 |
+
#: includes/gateways/settings/ach-settings.php:91
|
1118 |
msgid "Client Name"
|
1119 |
msgstr ""
|
1120 |
|
1121 |
+
#: includes/gateways/settings/ach-settings-v2.php:84
|
1122 |
+
#: includes/gateways/settings/ach-settings.php:93
|
1123 |
msgid "The name that appears on the ACH payment screen."
|
1124 |
msgstr ""
|
1125 |
|
1126 |
+
#: includes/gateways/settings/ach-settings-v2.php:88
|
1127 |
+
#: includes/gateways/settings/ach-settings.php:97
|
1128 |
msgid "ACH Display"
|
1129 |
msgstr ""
|
1130 |
|
1131 |
+
#: includes/gateways/settings/ach-settings-v2.php:98
|
1132 |
+
#: includes/gateways/settings/ach-settings.php:107
|
1133 |
msgid "ACH Fee"
|
1134 |
msgstr ""
|
1135 |
|
1136 |
+
#: includes/gateways/settings/ach-settings-v2.php:108
|
1137 |
+
#: includes/gateways/settings/ach-settings.php:117
|
1138 |
msgid "None"
|
1139 |
msgstr ""
|
1140 |
|
1141 |
+
#: includes/gateways/settings/ach-settings-v2.php:109
|
1142 |
+
#: includes/gateways/settings/ach-settings.php:118
|
1143 |
msgid "Amount"
|
1144 |
msgstr ""
|
1145 |
|
1146 |
+
#: includes/gateways/settings/ach-settings-v2.php:110
|
1147 |
+
#: includes/gateways/settings/ach-settings.php:119
|
1148 |
msgid "Percentage"
|
1149 |
msgstr ""
|
1150 |
|
1151 |
+
#: includes/gateways/settings/ach-settings-v2.php:113
|
1152 |
+
#: includes/gateways/settings/ach-settings.php:122
|
1153 |
msgid "You can assign a fee to the order for ACH payments. Amount is a static amount and percentage is a percentage of the cart amount."
|
1154 |
msgstr ""
|
1155 |
|
1156 |
+
#: includes/gateways/settings/ach-settings.php:26
|
1157 |
msgid "The active Plaid environment. You must set API mode to live to use Plaid's development environment."
|
1158 |
msgstr ""
|
1159 |
|
1160 |
+
#: includes/gateways/settings/ach-settings.php:36
|
1161 |
msgid "ID that identifies your Plaid account."
|
1162 |
msgstr ""
|
1163 |
|
1164 |
+
#: includes/gateways/settings/ach-settings.php:43
|
1165 |
msgid "Used to identify ACH payments initiated from your site."
|
1166 |
msgstr ""
|
1167 |
|
1168 |
+
#: includes/gateways/settings/ach-settings.php:51
|
1169 |
msgid "Sandbox Secret"
|
1170 |
msgstr ""
|
1171 |
|
1172 |
+
#: includes/gateways/settings/ach-settings.php:54
|
1173 |
msgid "Key that acts as a password when connecting to Plaid's sandbox environment."
|
1174 |
msgstr ""
|
1175 |
|
1176 |
+
#: includes/gateways/settings/ach-settings.php:58
|
1177 |
msgid "Development Secret"
|
1178 |
msgstr ""
|
1179 |
|
1180 |
+
#: includes/gateways/settings/ach-settings.php:61
|
1181 |
msgid "Development allows you to test real bank credentials with test transactions."
|
1182 |
msgstr ""
|
1183 |
|
1184 |
+
#: includes/gateways/settings/ach-settings.php:65
|
1185 |
msgid "Production Secret"
|
1186 |
msgstr ""
|
1187 |
|
1188 |
+
#: includes/gateways/settings/ach-settings.php:68
|
1189 |
msgid "Key that acts as a password when connecting to Plaid's production environment."
|
1190 |
msgstr ""
|
1191 |
|
1192 |
+
#: includes/gateways/settings/applepay-settings.php:5
|
1193 |
msgid "Register Domain"
|
1194 |
msgstr ""
|
1195 |
|
1196 |
+
#: includes/gateways/settings/applepay-settings.php:5
|
1197 |
+
msgid "This plugin attemps to add the domain association file to your server automatically when you click the Register Domain button. If that fails due to file permssions, you must add the <strong>%1$s.well-known/apple-developer-merchantid-domain-association%2$s</strong> file to your domain and register your domain within the Stripe Dashboard."
|
1198 |
msgstr ""
|
1199 |
|
1200 |
+
#: includes/gateways/settings/applepay-settings.php:7
|
1201 |
msgid "In order for Apple Pay to display, you must test with an iOS device and have a payment method saved in the Apple Wallet."
|
1202 |
msgstr ""
|
1203 |
|
1204 |
+
#: includes/gateways/settings/applepay-settings.php:16
|
1205 |
+
#: includes/gateways/settings/payment-request-settings.php:17
|
1206 |
msgid "If enabled, your site can accept Apple Pay payments through Stripe."
|
1207 |
msgstr ""
|
1208 |
|
1209 |
+
#: includes/gateways/settings/applepay-settings.php:37
|
1210 |
+
#: includes/gateways/settings/cc-settings.php:34
|
1211 |
+
#: includes/gateways/settings/googlepay-settings.php:61
|
1212 |
+
#: includes/gateways/settings/payment-request-settings.php:38
|
1213 |
msgid "Credit Card Display"
|
1214 |
msgstr ""
|
1215 |
|
1216 |
+
#: includes/gateways/settings/applepay-settings.php:56
|
1217 |
+
#: includes/gateways/settings/cc-settings.php:53
|
1218 |
+
#: includes/gateways/settings/payment-request-settings.php:57
|
1219 |
msgid "This option determines whether the customer's funds are captured immediately or authorized and can be captured at a later date."
|
1220 |
msgstr ""
|
1221 |
|
1222 |
+
#: includes/gateways/settings/applepay-settings.php:60
|
1223 |
+
#: includes/gateways/settings/googlepay-settings.php:84
|
1224 |
+
#: includes/gateways/settings/payment-request-settings.php:61
|
1225 |
msgid "Payment Sections"
|
1226 |
msgstr ""
|
1227 |
|
1228 |
+
#: includes/gateways/settings/applepay-settings.php:63
|
1229 |
+
#: includes/gateways/settings/googlepay-settings.php:87
|
1230 |
+
#: includes/gateways/settings/payment-request-settings.php:64
|
1231 |
msgid "Product Page"
|
1232 |
msgstr ""
|
1233 |
|
1234 |
+
#: includes/gateways/settings/applepay-settings.php:64
|
1235 |
+
#: includes/gateways/settings/googlepay-settings.php:88
|
1236 |
+
#: includes/gateways/settings/payment-request-settings.php:65
|
1237 |
msgid "Cart Page"
|
1238 |
msgstr ""
|
1239 |
|
1240 |
+
#: includes/gateways/settings/applepay-settings.php:65
|
1241 |
+
#: includes/gateways/settings/googlepay-settings.php:89
|
1242 |
+
#: includes/gateways/settings/payment-request-settings.php:66
|
1243 |
msgid "Top of Checkout"
|
1244 |
msgstr ""
|
1245 |
|
1246 |
+
#: includes/gateways/settings/applepay-settings.php:72
|
1247 |
+
#: includes/gateways/settings/cc-settings.php:57
|
1248 |
+
#: includes/gateways/settings/googlepay-settings.php:96
|
1249 |
+
#: includes/gateways/settings/payment-request-settings.php:73
|
1250 |
msgid "Order Status"
|
1251 |
msgstr ""
|
1252 |
|
1253 |
+
#: includes/gateways/settings/applepay-settings.php:75
|
1254 |
+
#: includes/gateways/settings/cc-settings.php:60
|
1255 |
+
#: includes/gateways/settings/googlepay-settings.php:99
|
1256 |
+
#: includes/gateways/settings/payment-request-settings.php:76
|
1257 |
msgid "Default"
|
1258 |
msgstr ""
|
1259 |
|
1260 |
+
#: includes/gateways/settings/applepay-settings.php:77
|
1261 |
+
#: includes/gateways/settings/cc-settings.php:62
|
1262 |
+
#: includes/gateways/settings/googlepay-settings.php:101
|
1263 |
+
#: includes/gateways/settings/payment-request-settings.php:78
|
1264 |
msgid "This is the status of the order once payment is complete. If <b>Default</b> is selected, then WooCommerce will set the order status automatically based on internal logic which states if a product is virtual and downloadable then status is set to complete. Products that require shipping are set to Processing. Default is the recommended setting as it allows standard WooCommerce code to process the order status."
|
1265 |
msgstr ""
|
1266 |
|
1267 |
+
#: includes/gateways/settings/applepay-settings.php:81
|
1268 |
+
#: includes/gateways/settings/payment-request-settings.php:82
|
1269 |
msgid "Button Settings"
|
1270 |
msgstr ""
|
1271 |
|
1272 |
+
#: includes/gateways/settings/applepay-settings.php:85
|
1273 |
+
#: includes/gateways/settings/googlepay-settings.php:149
|
1274 |
msgid "Button Design"
|
1275 |
msgstr ""
|
1276 |
|
1277 |
+
#: includes/gateways/settings/applepay-settings.php:89
|
1278 |
msgid "Black Button"
|
1279 |
msgstr ""
|
1280 |
|
1281 |
+
#: includes/gateways/settings/applepay-settings.php:90
|
1282 |
msgid "White With Black Line"
|
1283 |
msgstr ""
|
1284 |
|
1285 |
+
#: includes/gateways/settings/applepay-settings.php:91
|
1286 |
msgid "White Button"
|
1287 |
msgstr ""
|
1288 |
|
1289 |
+
#: includes/gateways/settings/applepay-settings.php:93
|
1290 |
msgid "This is the style for all Apple Pay buttons presented on your store."
|
1291 |
msgstr ""
|
1292 |
|
1293 |
+
#: includes/gateways/settings/applepay-settings.php:96
|
1294 |
msgid "Checkout button type"
|
1295 |
msgstr ""
|
1296 |
|
1297 |
+
#: includes/gateways/settings/applepay-settings.php:99
|
1298 |
+
#: includes/gateways/settings/applepay-settings.php:109
|
1299 |
+
#: includes/gateways/settings/applepay-settings.php:119
|
1300 |
msgid "Standard Button"
|
1301 |
msgstr ""
|
1302 |
|
1303 |
+
#: includes/gateways/settings/applepay-settings.php:100
|
1304 |
+
#: includes/gateways/settings/applepay-settings.php:110
|
1305 |
+
#: includes/gateways/settings/applepay-settings.php:120
|
1306 |
msgid "Buy with Apple Pay"
|
1307 |
msgstr ""
|
1308 |
|
1309 |
+
#: includes/gateways/settings/applepay-settings.php:106
|
1310 |
msgid "Cart button type"
|
1311 |
msgstr ""
|
1312 |
|
1313 |
+
#: includes/gateways/settings/applepay-settings.php:116
|
1314 |
msgid "Product button type"
|
1315 |
msgstr ""
|
1316 |
|
1317 |
+
#: includes/gateways/settings/cc-settings.php:9
|
1318 |
msgid "If enabled, your site can accept credit card payments through Stripe."
|
1319 |
msgstr ""
|
1320 |
|
1321 |
+
#: includes/gateways/settings/cc-settings.php:13
|
1322 |
+
msgid "%1$sTest cards%2$s"
|
1323 |
msgstr ""
|
1324 |
|
1325 |
+
#: includes/gateways/settings/cc-settings.php:68
|
1326 |
msgid "Allow Credit Card Save"
|
1327 |
msgstr ""
|
1328 |
|
1329 |
+
#: includes/gateways/settings/cc-settings.php:70
|
1330 |
msgid "If enabled, a checkbox will be available on the checkout page allowing your customers to save their credit card. The payment methods are stored securely in Stripe's vault and never touch your server. Note: if the cart contains a subscription, there will be no checkbox because the payment method will be saved automatically. There will also be no checkbox for guest checkout as a user must be logged in to save a payment method."
|
1331 |
msgstr ""
|
1332 |
|
1333 |
+
#: includes/gateways/settings/cc-settings.php:73
|
1334 |
msgid "Force 3D Secure"
|
1335 |
msgstr ""
|
1336 |
|
1337 |
+
#: includes/gateways/settings/cc-settings.php:78
|
1338 |
+
msgid "Stripe internally determines when 3D secure should be presented based on their SCA engine. If <strong>Force 3D Secure</strong> is enabled, 3D Secure will be forced for ALL credit card transactions. In test mode 3D secure only shows for %1$s3DS Test Cards%2$s regardless of this setting."
|
1339 |
msgstr ""
|
1340 |
|
1341 |
+
#: includes/gateways/settings/cc-settings.php:81
|
1342 |
msgid "Generic Errors"
|
1343 |
msgstr ""
|
1344 |
|
1345 |
+
#: includes/gateways/settings/cc-settings.php:86
|
1346 |
msgid "If enabled, credit card errors will be generic when presented to the customer. Merchants may prefer to not provide details on why a card was not accepted for security purposes."
|
1347 |
msgstr ""
|
1348 |
|
1349 |
+
#: includes/gateways/settings/cc-settings.php:108
|
1350 |
msgid "Credit Card Form"
|
1351 |
msgstr ""
|
1352 |
|
1353 |
+
#: includes/gateways/settings/cc-settings.php:111
|
1354 |
msgid "Card Form"
|
1355 |
msgstr ""
|
1356 |
|
1357 |
+
#: includes/gateways/settings/cc-settings.php:114
|
1358 |
msgid "Stripe form"
|
1359 |
msgstr ""
|
1360 |
|
1361 |
+
#: includes/gateways/settings/cc-settings.php:115
|
1362 |
msgid "Custom form"
|
1363 |
msgstr ""
|
1364 |
|
1365 |
+
#: includes/gateways/settings/cc-settings.php:118
|
1366 |
msgid "The Stripe form option displays a CC form rendered by Stripe. It works well with most themes. The custom card forms are offered if you want more options on the CC form design."
|
1367 |
msgstr ""
|
1368 |
|
1369 |
+
#: includes/gateways/settings/cc-settings.php:121
|
1370 |
msgid "Custom Form"
|
1371 |
msgstr ""
|
1372 |
|
1373 |
+
#: includes/gateways/settings/cc-settings.php:125
|
1374 |
msgid "The design of the credit card form."
|
1375 |
msgstr ""
|
1376 |
|
1377 |
+
#: includes/gateways/settings/cc-settings.php:130
|
1378 |
msgid "Postal Code"
|
1379 |
msgstr ""
|
1380 |
|
1381 |
+
#: includes/gateways/settings/cc-settings.php:133
|
1382 |
msgid "If enabled, the CC form will show the postal code on the checkout page. If disabled, the billing field's postal code will be used. The postal code will show on the Add Payment Method page for security reasons."
|
1383 |
msgstr ""
|
1384 |
|
1385 |
+
#: includes/gateways/settings/googlepay-settings.php:5
|
1386 |
msgid "GPay Business Console"
|
1387 |
msgstr ""
|
1388 |
|
1389 |
+
#: includes/gateways/settings/googlepay-settings.php:7
|
1390 |
msgid "When test mode is enabled, Google Pay will work without a merchant ID, allowing you to capture the necessary screenshots the Google API team needs to approve your integration request."
|
1391 |
msgstr ""
|
1392 |
|
1393 |
+
#: includes/gateways/settings/googlepay-settings.php:14
|
1394 |
+
msgid "If you don't want to request a Google Merchant ID, you can use the %1$sPayment Request Gateway%2$s which has a Google Pay integration through Stripe via the Chrome browser."
|
1395 |
msgstr ""
|
1396 |
|
1397 |
+
#: includes/gateways/settings/googlepay-settings.php:27
|
1398 |
msgid "If enabled, your site can accept Google Pay payments through Stripe."
|
1399 |
msgstr ""
|
1400 |
|
1401 |
+
#: includes/gateways/settings/googlepay-settings.php:34
|
1402 |
msgid "Dynamic Price"
|
1403 |
msgstr ""
|
1404 |
|
1405 |
+
#: includes/gateways/settings/googlepay-settings.php:38
|
1406 |
msgid "If enabled, the Google Payment sheet will show the order line items. You must have Google whitelist you for callback intents."
|
1407 |
msgstr ""
|
1408 |
|
1409 |
+
#: includes/gateways/settings/googlepay-settings.php:42
|
1410 |
msgid "Merchant ID"
|
1411 |
msgstr ""
|
1412 |
|
1413 |
+
#: includes/gateways/settings/googlepay-settings.php:44
|
1414 |
msgid "Your Google Merchant ID is given to you by the Google API team once you register for Google Pay. While testing in TEST mode you can leave this value blank and Google Pay will work."
|
1415 |
msgstr ""
|
1416 |
|
1417 |
+
#: includes/gateways/settings/googlepay-settings.php:80
|
1418 |
msgid "This option determines whether the customer's funds are capture immediately or authorized and can be captured at a later date."
|
1419 |
msgstr ""
|
1420 |
|
1421 |
+
#: includes/gateways/settings/googlepay-settings.php:105
|
1422 |
msgid "Merchant Name"
|
1423 |
msgstr ""
|
1424 |
|
1425 |
+
#: includes/gateways/settings/googlepay-settings.php:107
|
1426 |
msgid "The name of your business as it appears on the Google Pay payment sheet."
|
1427 |
msgstr ""
|
1428 |
|
1429 |
+
#: includes/gateways/settings/googlepay-settings.php:111
|
1430 |
msgid "Icon"
|
1431 |
msgstr ""
|
1432 |
|
1433 |
+
#: includes/gateways/settings/googlepay-settings.php:114
|
1434 |
msgid "With Outline"
|
1435 |
msgstr ""
|
1436 |
|
1437 |
+
#: includes/gateways/settings/googlepay-settings.php:115
|
1438 |
msgid "Standard"
|
1439 |
msgstr ""
|
1440 |
|
1441 |
+
#: includes/gateways/settings/googlepay-settings.php:119
|
1442 |
msgid "This is the icon style that appears next to the gateway on the checkout page. Google's API team typically requires the With Outline option on the checkout page for branding purposes."
|
1443 |
msgstr ""
|
1444 |
|
1445 |
+
#: includes/gateways/settings/googlepay-settings.php:123
|
1446 |
msgid "Button Options"
|
1447 |
msgstr ""
|
1448 |
|
1449 |
+
#: includes/gateways/settings/googlepay-settings.php:126
|
1450 |
msgid "Button Color"
|
1451 |
msgstr ""
|
1452 |
|
1453 |
+
#: includes/gateways/settings/googlepay-settings.php:130
|
1454 |
msgid "Black"
|
1455 |
msgstr ""
|
1456 |
|
1457 |
+
#: includes/gateways/settings/googlepay-settings.php:131
|
1458 |
msgid "White"
|
1459 |
msgstr ""
|
1460 |
|
1461 |
+
#: includes/gateways/settings/googlepay-settings.php:134
|
1462 |
msgid "The button color of the GPay button."
|
1463 |
msgstr ""
|
1464 |
|
1465 |
+
#: includes/gateways/settings/googlepay-settings.php:137
|
1466 |
msgid "Button Style"
|
1467 |
msgstr ""
|
1468 |
|
1469 |
+
#: includes/gateways/settings/googlepay-settings.php:141
|
1470 |
msgid "Long"
|
1471 |
msgstr ""
|
1472 |
|
1473 |
+
#: includes/gateways/settings/googlepay-settings.php:142
|
1474 |
msgid "Short"
|
1475 |
msgstr ""
|
1476 |
|
1477 |
+
#: includes/gateways/settings/googlepay-settings.php:145
|
1478 |
msgid "The button style of the GPay button."
|
1479 |
msgstr ""
|
1480 |
|
1481 |
+
#: includes/gateways/settings/googlepay-settings.php:151
|
1482 |
msgid "If you can't see the Google Pay button, try switching to a Chrome browser."
|
1483 |
msgstr ""
|
1484 |
|
1485 |
+
#: includes/gateways/settings/payment-request-settings.php:5
|
1486 |
msgid ""
|
1487 |
+
"The PaymentRequest gateway uses your customer's browser to render payment options like Google Pay and Microsoft Pay. You can either use the Google Pay gateway for example, or this gateway.\n"
|
1488 |
"\t\t\t\t\t\tThe difference is this gateway uses Stripe's PaymentRequest Button rather than render a Google Pay specific button."
|
1489 |
msgstr ""
|
1490 |
|
1491 |
+
#: includes/gateways/settings/payment-request-settings.php:26
|
1492 |
msgid "Browser Payments"
|
1493 |
msgstr ""
|
1494 |
|
1495 |
+
#: includes/gateways/settings/payment-request-settings.php:88
|
1496 |
msgid "default"
|
1497 |
msgstr ""
|
1498 |
|
1499 |
+
#: includes/gateways/settings/payment-request-settings.php:90
|
1500 |
msgid "buy"
|
1501 |
msgstr ""
|
1502 |
|
1503 |
+
#: includes/gateways/settings/payment-request-settings.php:94
|
1504 |
msgid "This defines the type of button that will display."
|
1505 |
msgstr ""
|
1506 |
|
1507 |
+
#: includes/gateways/settings/payment-request-settings.php:98
|
1508 |
msgid "Theme"
|
1509 |
msgstr ""
|
1510 |
|
1511 |
+
#: includes/gateways/settings/payment-request-settings.php:100
|
1512 |
msgid "dark"
|
1513 |
msgstr ""
|
1514 |
|
1515 |
+
#: includes/gateways/settings/payment-request-settings.php:101
|
1516 |
msgid "light"
|
1517 |
msgstr ""
|
1518 |
|
1519 |
+
#: includes/gateways/settings/payment-request-settings.php:102
|
1520 |
msgid "light-outline"
|
1521 |
msgstr ""
|
1522 |
|
1523 |
+
#: includes/gateways/settings/payment-request-settings.php:106
|
1524 |
msgid "This defines the color scheme for the button."
|
1525 |
msgstr ""
|
1526 |
|
1527 |
+
#: includes/gateways/settings/payment-request-settings.php:110
|
1528 |
msgid "Height"
|
1529 |
msgstr ""
|
1530 |
|
1531 |
+
#: includes/gateways/settings/payment-request-settings.php:113
|
1532 |
msgid "The height of the button. Max height is 64"
|
1533 |
msgstr ""
|
1534 |
|
1535 |
+
#: includes/tokens/class-wc-payment-token-stripe-ach.php:70
|
1536 |
+
#: includes/tokens/class-wc-payment-token-stripe-ach.php:75
|
1537 |
+
#: includes/tokens/class-wc-payment-token-stripe-cc.php:90
|
1538 |
msgid "Type Ending In"
|
1539 |
msgstr ""
|
1540 |
|
1541 |
+
#: includes/tokens/class-wc-payment-token-stripe-ach.php:72
|
1542 |
msgid "{bank_name} ending in {last4}"
|
1543 |
msgstr ""
|
1544 |
|
1545 |
+
#: includes/tokens/class-wc-payment-token-stripe-ach.php:77
|
1546 |
msgid "{bank_name} **** {last4}"
|
1547 |
msgstr ""
|
1548 |
|
1549 |
+
#: includes/tokens/class-wc-payment-token-stripe-cc.php:92
|
1550 |
msgid "{brand} ending in {last4}"
|
1551 |
msgstr ""
|
1552 |
|
1553 |
+
#: includes/tokens/class-wc-payment-token-stripe-cc.php:95
|
1554 |
msgid "Type Masked Number"
|
1555 |
msgstr ""
|
1556 |
|
1557 |
+
#: includes/tokens/class-wc-payment-token-stripe-cc.php:100
|
1558 |
msgid "Type Dash Masked Number"
|
1559 |
msgstr ""
|
1560 |
|
1561 |
+
#: includes/tokens/class-wc-payment-token-stripe-cc.php:105
|
1562 |
msgid "Type Last 4"
|
1563 |
msgstr ""
|
1564 |
|
1565 |
+
#: includes/tokens/class-wc-payment-token-stripe-cc.php:110
|
1566 |
msgid "Type Dash & Last 4"
|
1567 |
msgstr ""
|
1568 |
|
1569 |
+
#: includes/tokens/class-wc-payment-token-stripe-cc.php:115
|
1570 |
msgid "Last Four"
|
1571 |
msgstr ""
|
1572 |
|
1573 |
+
#: includes/tokens/class-wc-payment-token-stripe-cc.php:120
|
1574 |
msgid "Card Type"
|
1575 |
msgstr ""
|
1576 |
|
1577 |
+
#: includes/tokens/class-wc-payment-token-stripe-local-payment.php:30
|
1578 |
msgid "Gateway Title"
|
1579 |
msgstr ""
|
1580 |
|
1581 |
+
#: includes/updates/update-3.1.0.php:28
|
1582 |
+
#: includes/updates/update-3.1.0.php:55
|
|
|
|
|
|
|
|
|
1583 |
msgid "Stripe For WooCommerce Update"
|
1584 |
msgstr ""
|
1585 |
|
1586 |
+
#: includes/updates/update-3.1.0.php:30
|
1587 |
msgid "Greetings from Payment Plugins,"
|
1588 |
msgstr ""
|
1589 |
|
1590 |
+
#: includes/updates/update-3.1.0.php:31
|
1591 |
msgid "At Stripe's request, we have updated Stripe for WooCommerce to use the new Stripe Connect integration. This new integration offers even more security. Stripe is requesting that all merchants switch."
|
1592 |
msgstr ""
|
1593 |
|
1594 |
+
#: includes/updates/update-3.1.0.php:32
|
1595 |
+
msgid "Click %1$shere%2$s to be redirected to your Stripe API settings page then click the <strong>Click to Connect</strong> button."
|
1596 |
msgstr ""
|
1597 |
|
1598 |
+
#: includes/updates/update-3.1.0.php:35
|
1599 |
msgid "Kind Regards,"
|
1600 |
msgstr ""
|
1601 |
|
1602 |
+
#: includes/wc-stripe-functions.php:808
|
1603 |
msgid "Bootstrap form"
|
1604 |
msgstr ""
|
1605 |
|
1606 |
+
#: includes/wc-stripe-functions.php:834
|
1607 |
msgid "Simple form"
|
1608 |
msgstr ""
|
1609 |
|
1610 |
+
#: includes/wc-stripe-functions.php:857
|
1611 |
msgid "Minimalist form"
|
1612 |
msgstr ""
|
1613 |
|
1614 |
+
#: includes/wc-stripe-functions.php:883
|
1615 |
msgid "Inline Form"
|
1616 |
msgstr ""
|
1617 |
|
1618 |
+
#: includes/wc-stripe-functions.php:905
|
1619 |
msgid "Rounded Form"
|
1620 |
msgstr ""
|
1621 |
|
1622 |
+
#: includes/wc-stripe-functions.php:1120
|
1623 |
msgid "There was an error processing your credit card."
|
1624 |
msgstr ""
|
1625 |
|
1626 |
+
#: includes/wc-stripe-functions.php:1121
|
1627 |
msgid "Your card number is incomplete."
|
1628 |
msgstr ""
|
1629 |
|
1630 |
+
#: includes/wc-stripe-functions.php:1122
|
1631 |
msgid "The card number is incorrect. Check the card's number or use a different card."
|
1632 |
msgstr ""
|
1633 |
|
1634 |
+
#: includes/wc-stripe-functions.php:1123
|
1635 |
msgid "The card's security code is incorrect. Check the card's security code or use a different card."
|
1636 |
msgstr ""
|
1637 |
|
1638 |
+
#: includes/wc-stripe-functions.php:1124
|
1639 |
msgid "The card's ZIP code is incorrect. Check the card's ZIP code or use a different card."
|
1640 |
msgstr ""
|
1641 |
|
1642 |
+
#: includes/wc-stripe-functions.php:1125
|
1643 |
+
#: includes/wc-stripe-functions.php:1130
|
1644 |
msgid "The card number is invalid. Check the card details or use a different card."
|
1645 |
msgstr ""
|
1646 |
|
1647 |
+
#: includes/wc-stripe-functions.php:1126
|
1648 |
msgid "This value provided to the field contains characters that are unsupported by the field."
|
1649 |
msgstr ""
|
1650 |
|
1651 |
+
#: includes/wc-stripe-functions.php:1127
|
1652 |
msgid "The card's security code is invalid. Check the card's security code or use a different card."
|
1653 |
msgstr ""
|
1654 |
|
1655 |
+
#: includes/wc-stripe-functions.php:1128
|
1656 |
msgid "The card's expiration month is incorrect. Check the expiration date or use a different card."
|
1657 |
msgstr ""
|
1658 |
|
1659 |
+
#: includes/wc-stripe-functions.php:1129
|
1660 |
msgid "The card's expiration year is incorrect. Check the expiration date or use a different card."
|
1661 |
msgstr ""
|
1662 |
|
1663 |
+
#: includes/wc-stripe-functions.php:1131
|
1664 |
msgid "The card's address is incorrect. Check the card's address or use a different card."
|
1665 |
msgstr ""
|
1666 |
|
1667 |
+
#: includes/wc-stripe-functions.php:1132
|
1668 |
msgid "The card has expired. Check the expiration date or use a different card."
|
1669 |
msgstr ""
|
1670 |
|
1671 |
+
#: includes/wc-stripe-functions.php:1133
|
1672 |
msgid "The card has been declined."
|
1673 |
msgstr ""
|
1674 |
|
1675 |
+
#: includes/wc-stripe-functions.php:1134
|
1676 |
msgid "Your card's expiration year is in the past."
|
1677 |
msgstr ""
|
1678 |
|
1679 |
+
#: includes/wc-stripe-functions.php:1135
|
1680 |
msgid "The bank account number provided is invalid (e.g., missing digits). Bank account information varies from country to country. We recommend creating validations in your entry forms based on the bank account formats we provide."
|
1681 |
msgstr ""
|
1682 |
|
1683 |
+
#: includes/wc-stripe-functions.php:1136
|
1684 |
msgid "The specified amount is greater than the maximum amount allowed. Use a lower amount and try again."
|
1685 |
msgstr ""
|
1686 |
|
1687 |
+
#: includes/wc-stripe-functions.php:1137
|
1688 |
msgid "The specified amount is less than the minimum amount allowed. Use a higher amount and try again."
|
1689 |
msgstr ""
|
1690 |
|
1691 |
+
#: includes/wc-stripe-functions.php:1138
|
1692 |
msgid "The payment requires authentication to proceed. If your customer is off session, notify your customer to return to your application and complete the payment. If you provided the error_on_requires_action parameter, then your customer should try another card that does not require authentication."
|
1693 |
msgstr ""
|
1694 |
|
1695 |
+
#: includes/wc-stripe-functions.php:1139
|
1696 |
msgid "The transfer or payout could not be completed because the associated account does not have a sufficient balance available. Create a new transfer or payout using an amount less than or equal to the account's available balance."
|
1697 |
msgstr ""
|
1698 |
|
1699 |
+
#: includes/wc-stripe-functions.php:1140
|
1700 |
msgid "The bank account provided can not be used to charge, either because it is not verified yet or it is not supported."
|
1701 |
msgstr ""
|
1702 |
|
1703 |
+
#: includes/wc-stripe-functions.php:1141
|
1704 |
msgid "The bank account provided already exists on the specified Customer object. If the bank account should also be attached to a different customer, include the correct customer ID when making the request again."
|
1705 |
msgstr ""
|
1706 |
|
1707 |
+
#: includes/wc-stripe-functions.php:1142
|
1708 |
msgid "The bank account provided cannot be used for payouts. A different bank account must be used."
|
1709 |
msgstr ""
|
1710 |
|
1711 |
+
#: includes/wc-stripe-functions.php:1143
|
1712 |
msgid "Your Connect platform is attempting to share an unverified bank account with a connected account."
|
1713 |
msgstr ""
|
1714 |
|
1715 |
+
#: includes/wc-stripe-functions.php:1144
|
1716 |
msgid "The bank account cannot be verified, either because the microdeposit amounts provided do not match the actual amounts, or because verification has failed too many times."
|
1717 |
msgstr ""
|
1718 |
|
1719 |
+
#: includes/wc-stripe-functions.php:1145
|
1720 |
msgid "This card has been declined too many times. You can try to charge this card again after 24 hours. We suggest reaching out to your customer to make sure they have entered all of their information correctly and that there are no issues with their card."
|
1721 |
msgstr ""
|
1722 |
|
1723 |
+
#: includes/wc-stripe-functions.php:1146
|
1724 |
msgid "The charge you're attempting to capture has already been captured. Update the request with an uncaptured charge ID."
|
1725 |
msgstr ""
|
1726 |
|
1727 |
+
#: includes/wc-stripe-functions.php:1147
|
1728 |
msgid "The charge you're attempting to refund has already been refunded. Update the request to use the ID of a charge that has not been refunded."
|
1729 |
msgstr ""
|
1730 |
|
1731 |
+
#: includes/wc-stripe-functions.php:1148
|
1732 |
msgid "The charge you're attempting to refund has been charged back. Check the disputes documentation to learn how to respond to the dispute."
|
1733 |
msgstr ""
|
1734 |
|
1735 |
+
#: includes/wc-stripe-functions.php:1149
|
1736 |
msgid "This charge would cause you to exceed your rolling-window processing limit for this source type. Please retry the charge later, or contact us to request a higher processing limit."
|
1737 |
msgstr ""
|
1738 |
|
1739 |
+
#: includes/wc-stripe-functions.php:1150
|
1740 |
msgid "The charge cannot be captured as the authorization has expired. Auth and capture charges must be captured within seven days."
|
1741 |
msgstr ""
|
1742 |
|
1743 |
+
#: includes/wc-stripe-functions.php:1151
|
1744 |
msgid "One or more provided parameters was not allowed for the given operation on the Charge. Check our API reference or the returned error message to see which values were not correct for that Charge."
|
1745 |
msgstr ""
|
1746 |
|
1747 |
+
#: includes/wc-stripe-functions.php:1152
|
1748 |
msgid "The email address is invalid (e.g., not properly formatted). Check that the email address is properly formatted and only includes allowed characters."
|
1749 |
msgstr ""
|
1750 |
|
1751 |
+
#: includes/wc-stripe-functions.php:1153
|
1752 |
msgid "The idempotency key provided is currently being used in another request. This occurs if your integration is making duplicate requests simultaneously."
|
1753 |
msgstr ""
|
1754 |
|
1755 |
+
#: includes/wc-stripe-functions.php:1154
|
1756 |
msgid "The specified amount is invalid. The charge amount must be a positive integer in the smallest currency unit, and not exceed the minimum or maximum amount."
|
1757 |
msgstr ""
|
1758 |
|
1759 |
+
#: includes/wc-stripe-functions.php:1155
|
1760 |
msgid "The source cannot be used because it is not in the correct state (e.g., a charge request is trying to use a source with a pending, failed, or consumed source). Check the status of the source you are attempting to use."
|
1761 |
msgstr ""
|
1762 |
|
1763 |
+
#: includes/wc-stripe-functions.php:1156
|
1764 |
msgid "Both a customer and source ID have been provided, but the source has not been saved to the customer. To create a charge for a customer with a specified source, you must first save the card details."
|
1765 |
msgstr ""
|
1766 |
|
1767 |
+
#: includes/wc-stripe-functions.php:1157
|
1768 |
msgid "The ZIP code provided was incorrect."
|
1769 |
msgstr ""
|
1770 |
|
1771 |
+
#: includes/wc-stripe-functions.php:1158
|
1772 |
msgid "An error occurred while processing the card. Try again later or with a different payment method."
|
1773 |
msgstr ""
|
1774 |
|
1775 |
+
#: includes/wc-stripe-functions.php:1159
|
1776 |
msgid "The card does not support this type of purchase."
|
1777 |
msgstr ""
|
1778 |
|
1779 |
+
#: includes/wc-stripe-functions.php:1160
|
1780 |
+
#: includes/wc-stripe-functions.php:1163
|
1781 |
+
#: includes/wc-stripe-functions.php:1165
|
1782 |
msgid "The card has been declined for an unknown reason."
|
1783 |
msgstr ""
|
1784 |
|
1785 |
+
#: includes/wc-stripe-functions.php:1161
|
1786 |
msgid "The customer has exceeded the balance or credit limit available on their card."
|
1787 |
msgstr ""
|
1788 |
|
1789 |
+
#: includes/wc-stripe-functions.php:1162
|
1790 |
msgid "The card does not support the specified currency."
|
1791 |
msgstr ""
|
1792 |
|
1793 |
+
#: includes/wc-stripe-functions.php:1164
|
1794 |
msgid "The payment has been declined as Stripe suspects it is fraudulent."
|
1795 |
msgstr ""
|
1796 |
|
1797 |
+
#: includes/wc-stripe-functions.php:1166
|
1798 |
msgid "The PIN entered is incorrect. "
|
1799 |
msgstr ""
|
1800 |
|
1801 |
+
#: includes/wc-stripe-functions.php:1167
|
1802 |
msgid "The card has insufficient funds to complete the purchase."
|
1803 |
msgstr ""
|
1804 |
|
1805 |
+
#: includes/wc-stripe-functions.php:1168
|
1806 |
msgid "Please select a payment method before proceeding."
|
1807 |
msgstr ""
|
1808 |
|
1809 |
+
#: includes/wc-stripe-functions.php:1169
|
1810 |
msgid "Please enter your IBAN before proceeding."
|
1811 |
msgstr ""
|
1812 |
|
1813 |
+
#: includes/wc-stripe-functions.php:1170
|
1814 |
msgid "Please select a bank before proceeding"
|
1815 |
msgstr ""
|
1816 |
|
1817 |
+
#: includes/wc-stripe-webhook-functions.php:81
|
1818 |
msgid "Charge.succeeded webhook received. Payment has been completed."
|
1819 |
msgstr ""
|
1820 |
|
1821 |
+
#: includes/wc-stripe-webhook-functions.php:119
|
1822 |
+
msgid "payment_intent.succeeded webhook received. Payment has been completed."
|
1823 |
msgstr ""
|
1824 |
|
1825 |
#: stripe-payments.php:17
|
1826 |
+
msgid "Your PHP version is %s but Stripe requires version 5.6+."
|
1827 |
msgstr ""
|
1828 |
|
1829 |
#: templates/cart/payment-methods.php:13
|
includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php
CHANGED
@@ -1,268 +1,265 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
if (! class_exists
|
5 |
-
return;
|
6 |
-
}
|
7 |
-
|
8 |
-
|
9 |
-
*
|
10 |
-
*
|
11 |
-
* @
|
12 |
-
*
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
*
|
21 |
-
*
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
$this->
|
34 |
-
|
35 |
-
|
36 |
-
$this->settings[
|
37 |
-
$this->settings[
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
) );
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
return
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
'
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
),
|
115 |
-
'
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
'element_params'
|
142 |
-
'routes' =>
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
'
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
'
|
175 |
-
'
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
$currency
|
210 |
-
$
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
}
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
if ($this->
|
244 |
-
$desc .= sprintf
|
245 |
-
}
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
*
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
return apply_filters ( 'wc_stripe_order_button_text', $text, $this );
|
267 |
-
}
|
268 |
-
}
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
if ( ! class_exists( 'WC_Payment_Gateway_Stripe' ) ) {
|
5 |
+
return;
|
6 |
+
}
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Local payment method classes should extend this abstract class
|
10 |
+
*
|
11 |
+
* @package Stripe/Abstract
|
12 |
+
* @author Payment Plugins
|
13 |
+
*
|
14 |
+
*/
|
15 |
+
abstract class WC_Payment_Gateway_Stripe_Local_Payment extends WC_Payment_Gateway_Stripe {
|
16 |
+
|
17 |
+
protected $tab_title = '';
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Currencies this gateway accepts
|
21 |
+
*get_source_args
|
22 |
+
* @var array
|
23 |
+
*/
|
24 |
+
protected $currencies = array();
|
25 |
+
|
26 |
+
protected $local_payment_type = '';
|
27 |
+
|
28 |
+
public $countries = array();
|
29 |
+
|
30 |
+
protected $local_payment_description = '';
|
31 |
+
|
32 |
+
public function __construct() {
|
33 |
+
$this->token_type = 'Stripe_Local';
|
34 |
+
$this->template_name = 'local-payment.php';
|
35 |
+
parent::__construct();
|
36 |
+
$this->settings['method_format'] = 'gateway_title';
|
37 |
+
$this->settings['charge_type'] = 'capture';
|
38 |
+
$this->settings['order_status'] = 'default';
|
39 |
+
}
|
40 |
+
|
41 |
+
public function hooks() {
|
42 |
+
parent::hooks();
|
43 |
+
add_filter( 'wc_stripe_local_gateway_tabs', array( $this, 'local_gateway_tab' ) );
|
44 |
+
remove_filter( 'wc_stripe_settings_nav_tabs', array( $this, 'admin_nav_tab' ) );
|
45 |
+
add_filter( 'wc_stripe_local_gateways_tab', array( $this, 'admin_nav_tab' ) );
|
46 |
+
add_action( 'woocommerce_settings_checkout_stripe_local_gateways_' . $this->id, array( $this, 'admin_options' ) );
|
47 |
+
add_action( 'wc_stripe_settings_before_options_stripe_local_gateways_' . $this->id, array( $this, 'navigation_menu' ) );
|
48 |
+
add_action( 'woocommerce_update_options_checkout_stripe_local_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
*
|
53 |
+
* @param \Stripe\Source $source
|
54 |
+
* @param WC_Order $order
|
55 |
+
*/
|
56 |
+
public function get_source_redirect_url( $source, $order ) {
|
57 |
+
return $source->redirect->url;
|
58 |
+
}
|
59 |
+
|
60 |
+
public function output_settings_nav() {
|
61 |
+
parent::output_settings_nav();
|
62 |
+
include wc_stripe()->plugin_path() . 'includes/admin/views/html-settings-local-payments-nav.php';
|
63 |
+
}
|
64 |
+
|
65 |
+
public function init_form_fields() {
|
66 |
+
$this->form_fields = apply_filters( 'wc_stripe_form_fields_' . $this->id, $this->get_local_payment_settings() );
|
67 |
+
}
|
68 |
+
|
69 |
+
public function init_supports() {
|
70 |
+
$this->supports = array( 'tokenization', 'products', 'refunds' );
|
71 |
+
}
|
72 |
+
|
73 |
+
public function process_payment( $order_id ) {
|
74 |
+
$result = parent::process_payment( $order_id );
|
75 |
+
|
76 |
+
if ( defined( WC_Stripe_Constants::WOOCOMMERCE_STRIPE_ORDER_PAY ) && $result['result'] == 'success' ) {
|
77 |
+
wp_send_json(
|
78 |
+
array(
|
79 |
+
'success' => true,
|
80 |
+
'redirect' => $result['redirect'],
|
81 |
+
),
|
82 |
+
200
|
83 |
+
);
|
84 |
+
exit();
|
85 |
+
}
|
86 |
+
return $result;
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Return an array of form fields for the gateway.
|
91 |
+
*
|
92 |
+
* @return array
|
93 |
+
*/
|
94 |
+
public function get_local_payment_settings() {
|
95 |
+
return array(
|
96 |
+
'desc' => array(
|
97 |
+
'type' => 'description',
|
98 |
+
'description' => $this->get_payment_description(),
|
99 |
+
),
|
100 |
+
'enabled' => array(
|
101 |
+
'title' => __( 'Enabled', 'woo-stripe-payment' ),
|
102 |
+
'type' => 'checkbox',
|
103 |
+
'default' => 'no',
|
104 |
+
'value' => 'yes',
|
105 |
+
'desc_tip' => true,
|
106 |
+
'description' => sprintf( __( 'If enabled, your site can accept %s payments through Stripe.', 'woo-stripe-payment' ), $this->get_method_title() ),
|
107 |
+
),
|
108 |
+
'general_settings' => array(
|
109 |
+
'type' => 'title',
|
110 |
+
'title' => __( 'General Settings', 'woo-stripe-payment' ),
|
111 |
+
),
|
112 |
+
'title_text' => array(
|
113 |
+
'type' => 'text',
|
114 |
+
'title' => __( 'Title', 'woo-stripe-payment' ),
|
115 |
+
'default' => $this->get_method_title(),
|
116 |
+
'desc_tip' => true,
|
117 |
+
'description' => sprintf( __( 'Title of the %s gateway' ), $this->get_method_title() ),
|
118 |
+
),
|
119 |
+
'description' => array(
|
120 |
+
'title' => __( 'Description', 'woo-stripe-payment' ),
|
121 |
+
'type' => 'text',
|
122 |
+
'default' => '',
|
123 |
+
'description' => __( 'Leave blank if you don\'t want a description to show for the gateway.', 'woo-stripe-payment' ),
|
124 |
+
'desc_tip' => true,
|
125 |
+
),
|
126 |
+
);
|
127 |
+
}
|
128 |
+
|
129 |
+
public function get_localized_params() {
|
130 |
+
return array_merge_recursive(
|
131 |
+
parent::get_localized_params(),
|
132 |
+
array(
|
133 |
+
'local_payment_type' => $this->local_payment_type,
|
134 |
+
'return_url' => add_query_arg(
|
135 |
+
array(
|
136 |
+
'_payment_nonce' => wp_create_nonce( 'local-payment' ),
|
137 |
+
'wc-stripe-local-gateway' => $this->id,
|
138 |
+
),
|
139 |
+
wc_get_checkout_url()
|
140 |
+
),
|
141 |
+
'element_params' => $this->get_element_params(),
|
142 |
+
'routes' => array( 'order_pay' => wc_stripe()->rest_api->checkout->rest_url( 'order-pay' ) ),
|
143 |
+
)
|
144 |
+
);
|
145 |
+
}
|
146 |
+
|
147 |
+
public function get_element_params() {
|
148 |
+
return array(
|
149 |
+
'style' => array(
|
150 |
+
'base' => array(
|
151 |
+
'padding' => '10px 12px',
|
152 |
+
'color' => '#32325d',
|
153 |
+
'fontFamily' => '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif',
|
154 |
+
'fontSmoothing' => 'antialiased',
|
155 |
+
'fontSize' => '16px',
|
156 |
+
'::placeholder' => array( 'color' => '#aab7c4' ),
|
157 |
+
),
|
158 |
+
'invalid' => array( 'color' => '#fa755a' ),
|
159 |
+
),
|
160 |
+
);
|
161 |
+
}
|
162 |
+
|
163 |
+
/**
|
164 |
+
*
|
165 |
+
* @param WC_Order $order
|
166 |
+
*/
|
167 |
+
public function get_source_args( $order ) {
|
168 |
+
return array(
|
169 |
+
'type' => $this->local_payment_type,
|
170 |
+
'amount' => wc_stripe_add_number_precision( $order->get_total(), $order->get_currency() ),
|
171 |
+
'currency' => $order->get_currency(),
|
172 |
+
'statement_descriptor' => sprintf( __( 'Order %s', 'woo-stripe-payment' ), $order->get_order_number() ),
|
173 |
+
'owner' => array(
|
174 |
+
'name' => $this->payment_object->get_name_from_order( $order, 'billing' ),
|
175 |
+
'email' => $order->get_billing_email(),
|
176 |
+
),
|
177 |
+
'redirect' => array( 'return_url' => $this->get_local_payment_return_url( $order ) ),
|
178 |
+
);
|
179 |
+
}
|
180 |
+
|
181 |
+
/**
|
182 |
+
*
|
183 |
+
* @param WC_Order $order
|
184 |
+
* @return string
|
185 |
+
*/
|
186 |
+
protected function get_local_payment_return_url( $order ) {
|
187 |
+
global $wp;
|
188 |
+
if ( isset( $wp->query_vars['order-pay'] ) ) {
|
189 |
+
$url = $order->get_checkout_payment_url();
|
190 |
+
} else {
|
191 |
+
$url = wc_get_checkout_url();
|
192 |
+
}
|
193 |
+
return add_query_arg(
|
194 |
+
array(
|
195 |
+
'_payment_nonce' => wp_create_nonce( 'local-payment' ),
|
196 |
+
'wc-stripe-local-gateway' => $this->id,
|
197 |
+
),
|
198 |
+
$url
|
199 |
+
);
|
200 |
+
}
|
201 |
+
|
202 |
+
public function is_local_payment_available() {
|
203 |
+
global $wp;
|
204 |
+
if ( isset( $wp->query_vars['order-pay'] ) ) {
|
205 |
+
$order = wc_get_order( absint( $wp->query_vars['order-pay'] ) );
|
206 |
+
$currency = $order->get_currency();
|
207 |
+
$billing_country = $order->get_billing_country();
|
208 |
+
} else {
|
209 |
+
$currency = get_woocommerce_currency();
|
210 |
+
$customer = WC()->customer;
|
211 |
+
$billing_country = $customer ? $customer->get_billing_country() : null;
|
212 |
+
if ( ! $billing_country ) {
|
213 |
+
$billing_country = WC()->countries->get_base_country();
|
214 |
+
}
|
215 |
+
}
|
216 |
+
if ( empty( $this->countries ) ) {
|
217 |
+
return in_array( $currency, $this->currencies );
|
218 |
+
} else {
|
219 |
+
return $billing_country && in_array( $currency, $this->currencies ) && in_array( $billing_country, $this->countries );
|
220 |
+
}
|
221 |
+
}
|
222 |
+
|
223 |
+
public function get_payment_token( $method_id, $method_details = array() ) {
|
224 |
+
/**
|
225 |
+
*
|
226 |
+
* @var WC_Payment_Token_Stripe_Local $token
|
227 |
+
*/
|
228 |
+
$token = parent::get_payment_token( $method_id, $method_details );
|
229 |
+
$token->set_gateway_title( $this->title );
|
230 |
+
return $token;
|
231 |
+
}
|
232 |
+
|
233 |
+
/**
|
234 |
+
* Return a description for (for admin sections) describing the required currency & or billing country(s).
|
235 |
+
*
|
236 |
+
* @return string
|
237 |
+
*/
|
238 |
+
protected function get_payment_description() {
|
239 |
+
$desc = '';
|
240 |
+
if ( $this->currencies ) {
|
241 |
+
$desc .= sprintf( __( 'Gateway will appear when store currency is <strong>%s</strong>', 'woo-stripe-payment' ), implode( ', ', $this->currencies ) );
|
242 |
+
}
|
243 |
+
if ( $this->countries ) {
|
244 |
+
$desc .= sprintf( __( ' & billing country is <strong>%s</strong>', 'woo-stripe-payment' ), implode( ', ', $this->countries ) );
|
245 |
+
}
|
246 |
+
return $desc;
|
247 |
+
}
|
248 |
+
|
249 |
+
/**
|
250 |
+
* Return a description of the payment method.
|
251 |
+
*/
|
252 |
+
public function get_local_payment_description() {
|
253 |
+
return apply_filters( 'wc_stripe_local_payment_description', $this->local_payment_description );
|
254 |
+
}
|
255 |
+
|
256 |
+
/**
|
257 |
+
*
|
258 |
+
* @since 3.1.3
|
259 |
+
* @param string $text
|
260 |
+
* @return string
|
261 |
+
*/
|
262 |
+
public function get_order_button_text( $text ) {
|
263 |
+
return apply_filters( 'wc_stripe_order_button_text', $text, $this );
|
264 |
+
}
|
265 |
+
}
|
|
|
|
|
|
includes/abstract/abstract-wc-payment-gateway-stripe.php
CHANGED
@@ -1,1330 +1,1387 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
if (! class_exists
|
5 |
-
return;
|
6 |
-
}
|
7 |
-
|
8 |
-
require_once
|
9 |
-
require_once
|
10 |
-
require_once
|
11 |
-
|
12 |
-
require_once
|
13 |
-
|
14 |
-
/**
|
15 |
-
*
|
16 |
-
* @since 3.0.0
|
17 |
-
* @author PaymentPlugins
|
18 |
-
* @package Stripe/Abstract
|
19 |
-
*
|
20 |
-
*/
|
21 |
-
abstract class WC_Payment_Gateway_Stripe extends WC_Payment_Gateway {
|
22 |
-
|
23 |
-
use WC_Stripe_Settings_Trait;
|
24 |
-
|
25 |
-
/**
|
26 |
-
*
|
27 |
-
* @var WC_Stripe_Payment
|
28 |
-
*/
|
29 |
-
public $payment_object;
|
30 |
-
|
31 |
-
/**
|
32 |
-
*
|
33 |
-
* @var string
|
34 |
-
*/
|
35 |
-
public $token_key;
|
36 |
-
|
37 |
-
/**
|
38 |
-
*
|
39 |
-
* @var string
|
40 |
-
*/
|
41 |
-
public $saved_method_key;
|
42 |
-
|
43 |
-
/**
|
44 |
-
*
|
45 |
-
* @var string
|
46 |
-
*/
|
47 |
-
public $payment_type_key;
|
48 |
-
|
49 |
-
/**
|
50 |
-
*
|
51 |
-
* @var string
|
52 |
-
*/
|
53 |
-
public $payment_intent_key;
|
54 |
-
|
55 |
-
/**
|
56 |
-
*
|
57 |
-
* @var string
|
58 |
-
*/
|
59 |
-
public $save_source_key;
|
60 |
-
|
61 |
-
/**
|
62 |
-
*
|
63 |
-
* @var string
|
64 |
-
*/
|
65 |
-
public $template_name;
|
66 |
-
|
67 |
-
/**
|
68 |
-
*
|
69 |
-
* @var bool
|
70 |
-
*/
|
71 |
-
protected $checkout_error = false;
|
72 |
-
|
73 |
-
/**
|
74 |
-
* Used to create an instance of a WC_Payment_Token
|
75 |
-
*
|
76 |
-
* @var string
|
77 |
-
*/
|
78 |
-
protected $token_type;
|
79 |
-
|
80 |
-
/**
|
81 |
-
*
|
82 |
-
* @var WC_Stripe_Gateway
|
83 |
-
*/
|
84 |
-
protected $gateway;
|
85 |
-
|
86 |
-
/**
|
87 |
-
*
|
88 |
-
* @var WP_Error
|
89 |
-
*/
|
90 |
-
protected $wp_error;
|
91 |
-
|
92 |
-
/**
|
93 |
-
*
|
94 |
-
* @var string
|
95 |
-
*/
|
96 |
-
protected $payment_method_token = null;
|
97 |
-
|
98 |
-
/**
|
99 |
-
*
|
100 |
-
* @var string
|
101 |
-
*/
|
102 |
-
protected $new_source_token = null;
|
103 |
-
|
104 |
-
/**
|
105 |
-
* Is the payment method synchronous or asynchronous
|
106 |
-
*
|
107 |
-
* @var bool
|
108 |
-
*/
|
109 |
-
public $synchronous = true;
|
110 |
-
|
111 |
-
/**
|
112 |
-
*
|
113 |
-
* @var array
|
114 |
-
*/
|
115 |
-
protected $post_payment_processes =
|
116 |
-
|
117 |
-
/**
|
118 |
-
*
|
119 |
-
* @var bool
|
120 |
-
*/
|
121 |
-
public $processing_payment = false;
|
122 |
-
|
123 |
-
public function __construct() {
|
124 |
-
$this->token_key
|
125 |
-
$this->saved_method_key
|
126 |
-
$this->save_source_key
|
127 |
-
$this->payment_type_key
|
128 |
-
$this->payment_intent_key = $this->id . '_payment_intent_key';
|
129 |
-
$this->has_fields
|
130 |
-
$this->init_form_fields
|
131 |
-
$this->init_settings
|
132 |
-
$this->title
|
133 |
-
$this->description = $this->get_option
|
134 |
-
$this->hooks
|
135 |
-
$this->init_supports
|
136 |
-
$this->gateway = WC_Stripe_Gateway::load
|
137 |
-
|
138 |
-
$this->payment_object = $this->get_payment_object
|
139 |
-
}
|
140 |
-
|
141 |
-
public function hooks() {
|
142 |
-
add_filter
|
143 |
-
|
144 |
-
) );
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
add_action
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
$this->enqueue_checkout_scripts
|
261 |
-
}
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
if (
|
266 |
-
$this->
|
267 |
-
}
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
*
|
286 |
-
*
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
*
|
294 |
-
*
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
}
|
299 |
-
|
300 |
-
/**
|
301 |
-
* Enqueue scripts needed by the gateway on the
|
302 |
-
*
|
303 |
-
* @param WC_Stripe_Frontend_Scripts $scripts
|
304 |
-
*/
|
305 |
-
public function
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
*
|
310 |
-
* @
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
if (
|
332 |
-
return $this->
|
333 |
-
}
|
334 |
-
|
335 |
-
|
336 |
-
if ($
|
337 |
-
return $this->
|
338 |
-
}
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
),
|
394 |
-
'
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
*
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
$
|
424 |
-
$order->
|
425 |
-
$order->
|
426 |
-
$order->
|
427 |
-
|
428 |
-
|
429 |
-
$order
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
$subscription->
|
435 |
-
$subscription->
|
436 |
-
$subscription->update_meta_data
|
437 |
-
$subscription->
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
*
|
447 |
-
*
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
*
|
457 |
-
*
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
return array( 'result' => 'error'
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
*
|
499 |
-
*
|
500 |
-
*
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
$
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
'
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
*
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
*
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
*
|
652 |
-
*
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
*
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
*
|
689 |
-
*
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
$
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
*
|
714 |
-
*
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
if (
|
795 |
-
return
|
796 |
-
}
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
if (
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
*
|
839 |
-
*
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
*
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
*
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
*
|
904 |
-
*
|
905 |
-
* @return
|
906 |
-
*/
|
907 |
-
public function
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
*
|
925 |
-
*
|
926 |
-
* @param
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
*
|
943 |
-
*
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
*
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
}
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
*
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
$
|
1039 |
-
|
1040 |
-
//
|
1041 |
-
$
|
1042 |
-
|
1043 |
-
$
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
}
|
1054 |
-
|
1055 |
-
/**
|
1056 |
-
*
|
1057 |
-
*
|
1058 |
-
* @param string $
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
$
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
return
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
|
1121 |
-
|
1122 |
-
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
1129 |
-
|
1130 |
-
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
1137 |
-
|
1138 |
-
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
1143 |
-
|
1144 |
-
|
1145 |
-
|
1146 |
-
|
1147 |
-
|
1148 |
-
|
1149 |
-
|
1150 |
-
|
1151 |
-
|
1152 |
-
|
1153 |
-
|
1154 |
-
|
1155 |
-
|
1156 |
-
|
1157 |
-
|
1158 |
-
|
1159 |
-
|
1160 |
-
|
1161 |
-
|
1162 |
-
|
1163 |
-
|
1164 |
-
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
-
|
1180 |
-
}
|
1181 |
-
|
1182 |
-
/**
|
1183 |
-
*
|
1184 |
-
*
|
1185 |
-
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
1190 |
-
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
-
|
1195 |
-
|
1196 |
-
|
1197 |
-
|
1198 |
-
|
1199 |
-
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
1209 |
-
|
1210 |
-
*
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
1216 |
-
}
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
|
1229 |
-
|
1230 |
-
|
1231 |
-
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
|
1236 |
-
|
1237 |
-
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
-
|
1257 |
-
|
1258 |
-
|
1259 |
-
|
1260 |
-
|
1261 |
-
|
1262 |
-
|
1263 |
-
|
1264 |
-
|
1265 |
-
|
1266 |
-
|
1267 |
-
|
1268 |
-
|
1269 |
-
|
1270 |
-
|
1271 |
-
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
1275 |
-
|
1276 |
-
|
1277 |
-
|
1278 |
-
|
1279 |
-
|
1280 |
-
|
1281 |
-
|
1282 |
-
|
1283 |
-
|
1284 |
-
|
1285 |
-
|
1286 |
-
|
1287 |
-
|
1288 |
-
|
1289 |
-
|
1290 |
-
|
1291 |
-
|
1292 |
-
|
1293 |
-
|
1294 |
-
|
1295 |
-
|
1296 |
-
}
|
1297 |
-
|
1298 |
-
|
1299 |
-
|
1300 |
-
|
1301 |
-
|
1302 |
-
|
1303 |
-
|
1304 |
-
|
1305 |
-
|
1306 |
-
|
1307 |
-
|
1308 |
-
|
1309 |
-
|
1310 |
-
|
1311 |
-
|
1312 |
-
|
1313 |
-
|
1314 |
-
|
1315 |
-
|
1316 |
-
|
1317 |
-
|
1318 |
-
|
1319 |
-
|
1320 |
-
|
1321 |
-
|
1322 |
-
|
1323 |
-
|
1324 |
-
|
1325 |
-
|
1326 |
-
|
1327 |
-
|
1328 |
-
|
1329 |
-
|
1330 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
if ( ! class_exists( 'WC_Payment_Gateway' ) ) {
|
5 |
+
return;
|
6 |
+
}
|
7 |
+
|
8 |
+
require_once( WC_STRIPE_PLUGIN_FILE_PATH . 'includes/class-wc-stripe-payment-intent.php' );
|
9 |
+
require_once( WC_STRIPE_PLUGIN_FILE_PATH . 'includes/class-wc-stripe-payment-charge.php' );
|
10 |
+
require_once( WC_STRIPE_PLUGIN_FILE_PATH . 'includes/class-wc-stripe-payment-charge-local.php' );
|
11 |
+
|
12 |
+
require_once( WC_STRIPE_PLUGIN_FILE_PATH . 'includes/traits/wc-stripe-payment-traits.php' );
|
13 |
+
|
14 |
+
/**
|
15 |
+
*
|
16 |
+
* @since 3.0.0
|
17 |
+
* @author PaymentPlugins
|
18 |
+
* @package Stripe/Abstract
|
19 |
+
*
|
20 |
+
*/
|
21 |
+
abstract class WC_Payment_Gateway_Stripe extends WC_Payment_Gateway {
|
22 |
+
|
23 |
+
use WC_Stripe_Settings_Trait;
|
24 |
+
|
25 |
+
/**
|
26 |
+
*
|
27 |
+
* @var WC_Stripe_Payment
|
28 |
+
*/
|
29 |
+
public $payment_object;
|
30 |
+
|
31 |
+
/**
|
32 |
+
*
|
33 |
+
* @var string
|
34 |
+
*/
|
35 |
+
public $token_key;
|
36 |
+
|
37 |
+
/**
|
38 |
+
*
|
39 |
+
* @var string
|
40 |
+
*/
|
41 |
+
public $saved_method_key;
|
42 |
+
|
43 |
+
/**
|
44 |
+
*
|
45 |
+
* @var string
|
46 |
+
*/
|
47 |
+
public $payment_type_key;
|
48 |
+
|
49 |
+
/**
|
50 |
+
*
|
51 |
+
* @var string
|
52 |
+
*/
|
53 |
+
public $payment_intent_key;
|
54 |
+
|
55 |
+
/**
|
56 |
+
*
|
57 |
+
* @var string
|
58 |
+
*/
|
59 |
+
public $save_source_key;
|
60 |
+
|
61 |
+
/**
|
62 |
+
*
|
63 |
+
* @var string
|
64 |
+
*/
|
65 |
+
public $template_name;
|
66 |
+
|
67 |
+
/**
|
68 |
+
*
|
69 |
+
* @var bool
|
70 |
+
*/
|
71 |
+
protected $checkout_error = false;
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Used to create an instance of a WC_Payment_Token
|
75 |
+
*
|
76 |
+
* @var string
|
77 |
+
*/
|
78 |
+
protected $token_type;
|
79 |
+
|
80 |
+
/**
|
81 |
+
*
|
82 |
+
* @var WC_Stripe_Gateway
|
83 |
+
*/
|
84 |
+
protected $gateway;
|
85 |
+
|
86 |
+
/**
|
87 |
+
*
|
88 |
+
* @var WP_Error
|
89 |
+
*/
|
90 |
+
protected $wp_error;
|
91 |
+
|
92 |
+
/**
|
93 |
+
*
|
94 |
+
* @var string
|
95 |
+
*/
|
96 |
+
protected $payment_method_token = null;
|
97 |
+
|
98 |
+
/**
|
99 |
+
*
|
100 |
+
* @var string
|
101 |
+
*/
|
102 |
+
protected $new_source_token = null;
|
103 |
+
|
104 |
+
/**
|
105 |
+
* Is the payment method synchronous or asynchronous
|
106 |
+
*
|
107 |
+
* @var bool
|
108 |
+
*/
|
109 |
+
public $synchronous = true;
|
110 |
+
|
111 |
+
/**
|
112 |
+
*
|
113 |
+
* @var array
|
114 |
+
*/
|
115 |
+
protected $post_payment_processes = array();
|
116 |
+
|
117 |
+
/**
|
118 |
+
*
|
119 |
+
* @var bool
|
120 |
+
*/
|
121 |
+
public $processing_payment = false;
|
122 |
+
|
123 |
+
public function __construct() {
|
124 |
+
$this->token_key = $this->id . '_token_key';
|
125 |
+
$this->saved_method_key = $this->id . '_saved_method_key';
|
126 |
+
$this->save_source_key = $this->id . '_save_source_key';
|
127 |
+
$this->payment_type_key = $this->id . '_payment_type_key';
|
128 |
+
$this->payment_intent_key = $this->id . '_payment_intent_key';
|
129 |
+
$this->has_fields = true;
|
130 |
+
$this->init_form_fields();
|
131 |
+
$this->init_settings();
|
132 |
+
$this->title = $this->get_option( 'title_text' );
|
133 |
+
$this->description = $this->get_option( 'description' );
|
134 |
+
$this->hooks();
|
135 |
+
$this->init_supports();
|
136 |
+
$this->gateway = WC_Stripe_Gateway::load();
|
137 |
+
|
138 |
+
$this->payment_object = $this->get_payment_object();
|
139 |
+
}
|
140 |
+
|
141 |
+
public function hooks() {
|
142 |
+
add_filter( 'wc_stripe_settings_nav_tabs', array( $this, 'admin_nav_tab' ) );
|
143 |
+
add_action( 'woocommerce_settings_checkout_' . $this->id, array( $this, 'enqueue_admin_scripts' ) );
|
144 |
+
add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
|
145 |
+
add_filter( 'woocommerce_payment_methods_list_item', array( $this, 'payment_methods_list_item' ), 10, 2 );
|
146 |
+
add_action( 'wc_stripe_payment_token_deleted_' . $this->id, array( $this, 'delete_payment_method' ), 10, 2 );
|
147 |
+
add_filter( 'woocommerce_subscription_payment_meta', array( $this, 'subscription_payment_meta' ), 10, 2 );
|
148 |
+
add_action( 'woocommerce_scheduled_subscription_payment_' . $this->id, array( $this, 'scheduled_subscription_payment' ), 10, 2 );
|
149 |
+
if ( ! is_admin() ) {
|
150 |
+
add_action( 'woocommerce_subscriptions_pre_update_payment_method', array( $this, 'subscriptions_pre_update_payment_method' ), 10, 3 );
|
151 |
+
add_action( 'woocommerce_subscription_payment_method_updated_to_' . $this->id, array( $this, 'subscription_payment_method_updated' ) );
|
152 |
+
}
|
153 |
+
add_action( 'wc_pre_orders_process_pre_order_completion_payment_' . $this->id, array( $this, 'process_pre_order_payment' ) );
|
154 |
+
}
|
155 |
+
|
156 |
+
public function init_supports() {
|
157 |
+
$this->supports = array(
|
158 |
+
'tokenization',
|
159 |
+
'products',
|
160 |
+
'subscriptions',
|
161 |
+
'add_payment_method',
|
162 |
+
'subscription_cancellation',
|
163 |
+
'multiple_subscriptions',
|
164 |
+
'subscription_amount_changes',
|
165 |
+
'subscription_date_changes',
|
166 |
+
'default_credit_card_form',
|
167 |
+
'refunds',
|
168 |
+
'pre-orders',
|
169 |
+
'subscription_payment_method_change_admin',
|
170 |
+
'subscription_reactivation',
|
171 |
+
'subscription_suspension',
|
172 |
+
'subscription_payment_method_change_customer',
|
173 |
+
);
|
174 |
+
}
|
175 |
+
|
176 |
+
public function init_form_fields() {
|
177 |
+
$this->form_fields = include wc_stripe()->plugin_path() . 'includes/gateways/settings/' . str_replace( array( 'stripe_', '_' ), array(
|
178 |
+
'',
|
179 |
+
'-'
|
180 |
+
), $this->id ) .
|
181 |
+
'-settings.php';
|
182 |
+
$this->form_fields = apply_filters( 'wc_stripe_form_fields_' . $this->id, $this->form_fields );
|
183 |
+
}
|
184 |
+
|
185 |
+
public function get_method_formats() {
|
186 |
+
$class_name = 'WC_Payment_Token_' . $this->token_type;
|
187 |
+
if ( class_exists( $class_name ) ) {
|
188 |
+
/**
|
189 |
+
*
|
190 |
+
* @var WC_Payment_Token_Stripe
|
191 |
+
*/
|
192 |
+
$token = new $class_name();
|
193 |
+
|
194 |
+
return $token->get_formats();
|
195 |
+
}
|
196 |
+
|
197 |
+
return array();
|
198 |
+
}
|
199 |
+
|
200 |
+
public function enqueue_admin_scripts() {
|
201 |
+
}
|
202 |
+
|
203 |
+
public function payment_fields() {
|
204 |
+
$this->enqueue_frontend_scripts();
|
205 |
+
wc_stripe_token_field( $this );
|
206 |
+
wc_stripe_payment_intent_field( $this );
|
207 |
+
wc_stripe_get_template(
|
208 |
+
'checkout/stripe-payment-method.php',
|
209 |
+
array(
|
210 |
+
'gateway' => $this,
|
211 |
+
'tokens' => is_add_payment_method_page() ? null : $this->get_tokens(),
|
212 |
+
)
|
213 |
+
);
|
214 |
+
}
|
215 |
+
|
216 |
+
/**
|
217 |
+
* Output the product payment fields.
|
218 |
+
*/
|
219 |
+
public function product_fields() {
|
220 |
+
global $product;
|
221 |
+
$this->enqueue_frontend_scripts( 'product' );
|
222 |
+
wc_stripe_token_field( $this );
|
223 |
+
wc_stripe_get_template(
|
224 |
+
'product/' . $this->template_name,
|
225 |
+
array(
|
226 |
+
'gateway' => $this,
|
227 |
+
'product' => $product,
|
228 |
+
)
|
229 |
+
);
|
230 |
+
}
|
231 |
+
|
232 |
+
public function cart_fields() {
|
233 |
+
$this->enqueue_frontend_scripts( 'cart' );
|
234 |
+
wc_stripe_token_field( $this );
|
235 |
+
wc_stripe_get_template( 'cart/' . $this->template_name, array( 'gateway' => $this ) );
|
236 |
+
}
|
237 |
+
|
238 |
+
/**
|
239 |
+
* Enqueue scripts needed by the gateway on the frontend of the WC shop.
|
240 |
+
*
|
241 |
+
* @param WC_Stripe_Frontend_Scripts $scripts
|
242 |
+
*/
|
243 |
+
public function enqueue_frontend_scripts( $page = '' ) {
|
244 |
+
global $wp;
|
245 |
+
if ( $page ) {
|
246 |
+
if ( 'product' === $page ) {
|
247 |
+
$this->enqueue_product_scripts( wc_stripe()->scripts() );
|
248 |
+
} elseif ( 'cart' === $page ) {
|
249 |
+
$this->enqueue_cart_scripts( wc_stripe()->scripts() );
|
250 |
+
} elseif ( 'checkout' === $page ) {
|
251 |
+
$this->enqueue_checkout_scripts( wc_stripe()->scripts() );
|
252 |
+
} else {
|
253 |
+
$this->enqueue_frontend_scripts();
|
254 |
+
}
|
255 |
+
} else {
|
256 |
+
if ( is_add_payment_method_page() ) {
|
257 |
+
$this->enqueue_add_payment_method_scripts( wc_stripe()->scripts() );
|
258 |
+
}
|
259 |
+
if ( is_checkout() ) {
|
260 |
+
$this->enqueue_checkout_scripts( wc_stripe()->scripts() );
|
261 |
+
}
|
262 |
+
if ( is_cart() ) {
|
263 |
+
$this->enqueue_cart_scripts( wc_stripe()->scripts() );
|
264 |
+
}
|
265 |
+
if ( is_product() ) {
|
266 |
+
$this->enqueue_product_scripts( wc_stripe()->scripts() );
|
267 |
+
}
|
268 |
+
}
|
269 |
+
if ( ! empty( wc_stripe()->scripts()->enqueued_scripts ) ) {
|
270 |
+
wc_stripe()->scripts()->enqueue_script( 'form-handler' );
|
271 |
+
wp_enqueue_style( wc_stripe()->scripts()->prefix . 'styles', wc_stripe()->assets_url( 'css/stripe.css' ), array(), wc_stripe()->version() );
|
272 |
+
}
|
273 |
+
}
|
274 |
+
|
275 |
+
/**
|
276 |
+
* Enqueue scripts needed by the gateway on the checkout page.
|
277 |
+
*
|
278 |
+
* @param WC_Stripe_Frontend_Scripts $scripts
|
279 |
+
*/
|
280 |
+
public function enqueue_checkout_scripts( $scripts ) {
|
281 |
+
}
|
282 |
+
|
283 |
+
/**
|
284 |
+
* Enqueue scripts needed by the gateway on the add payment method page.
|
285 |
+
*
|
286 |
+
* @param WC_Stripe_Frontend_Scripts $scripts
|
287 |
+
*/
|
288 |
+
public function enqueue_add_payment_method_scripts( $scripts ) {
|
289 |
+
$this->enqueue_checkout_scripts( $scripts );
|
290 |
+
}
|
291 |
+
|
292 |
+
/**
|
293 |
+
* Enqueue scripts needed by the gateway on the cart page.
|
294 |
+
*
|
295 |
+
* @param WC_Stripe_Frontend_Scripts $scripts
|
296 |
+
*/
|
297 |
+
public function enqueue_cart_scripts( $scripts ) {
|
298 |
+
}
|
299 |
+
|
300 |
+
/**
|
301 |
+
* Enqueue scripts needed by the gateway on the product page.
|
302 |
+
*
|
303 |
+
* @param WC_Stripe_Frontend_Scripts $scripts
|
304 |
+
*/
|
305 |
+
public function enqueue_product_scripts( $scripts ) {
|
306 |
+
}
|
307 |
+
|
308 |
+
/**
|
309 |
+
*
|
310 |
+
* {@inheritDoc}
|
311 |
+
*
|
312 |
+
* @see WC_Payment_Gateway::process_payment()
|
313 |
+
*/
|
314 |
+
public function process_payment( $order_id ) {
|
315 |
+
$order = wc_get_order( $order_id );
|
316 |
+
|
317 |
+
if ( $this->is_change_payment_method_request() ) {
|
318 |
+
return array(
|
319 |
+
'result' => 'success',
|
320 |
+
'redirect' => $order->get_view_order_url(),
|
321 |
+
);
|
322 |
+
}
|
323 |
+
|
324 |
+
do_action( 'wc_stripe_before_process_payment', $order, $this->id );
|
325 |
+
|
326 |
+
if ( wc_notice_count( 'error' ) > 0 ) {
|
327 |
+
return $this->get_order_error();
|
328 |
+
}
|
329 |
+
$this->processing_payment = true;
|
330 |
+
|
331 |
+
if ( $this->order_contains_pre_order( $order ) && $this->pre_order_requires_tokenization( $order ) ) {
|
332 |
+
return $this->process_pre_order( $order );
|
333 |
+
}
|
334 |
+
|
335 |
+
// if order total is zero, then save meta but don't process payment.
|
336 |
+
if ( $order->get_total() == 0 ) {
|
337 |
+
return $this->process_zero_total_order( $order );
|
338 |
+
}
|
339 |
+
|
340 |
+
$result = $this->payment_object->process_payment( $order, $this );
|
341 |
+
|
342 |
+
if ( is_wp_error( $result ) ) {
|
343 |
+
wc_add_notice( $this->is_active( 'generic_error' ) ? $this->get_generic_error( $result ) : $result->get_error_message(), 'error' );
|
344 |
+
$order->update_status( 'failed', sprintf( __( 'Error processing payment. Reason: %s', 'woo-stripe-payment' ), $result->get_error_message() ) );
|
345 |
+
|
346 |
+
return $this->get_order_error();
|
347 |
+
}
|
348 |
+
|
349 |
+
if ( $result->complete_payment ) {
|
350 |
+
$this->save_order_meta( $order, $result->charge );
|
351 |
+
if ( 'pending' === $result->charge->status ) {
|
352 |
+
$order->update_status( apply_filters( 'wc_stripe_pending_charge_status', 'on-hold', $order, $this ), sprintf( __( 'Charge %1$s is pending. Payment Method: %2$s. Payment will be completed once charge.succeeded webhook received from Stripe.', 'woo-stripe-payment' ), $order->get_transaction_id(), $order->get_payment_method_title() ) );
|
353 |
+
} else {
|
354 |
+
if ( $result->charge->captured ) {
|
355 |
+
$order->payment_complete( $result->charge->id );
|
356 |
+
} else {
|
357 |
+
$order_status = $this->get_option( 'order_status' );
|
358 |
+
$order->update_status( apply_filters( 'wc_stripe_authorized_order_status', 'default' === $order_status ? 'on-hold' : $order_status, $order, $this ) );
|
359 |
+
}
|
360 |
+
$order->add_order_note( sprintf( __( 'Order %1$s successful in Stripe. Charge: %2$s. Payment Method: %3$s', 'woo-stripe-payment' ), $result->charge->captured ? __( 'charge', 'woo-stripe-payment' ) : __( 'authorization', 'woo-stripe-payment' ), $order->get_transaction_id(), $order->get_payment_method_title() ) );
|
361 |
+
}
|
362 |
+
|
363 |
+
$this->trigger_post_payment_processes( $order, $this );
|
364 |
+
|
365 |
+
WC()->cart->empty_cart();
|
366 |
+
|
367 |
+
return array(
|
368 |
+
'result' => 'success',
|
369 |
+
'redirect' => $order->get_checkout_order_received_url(),
|
370 |
+
);
|
371 |
+
} else {
|
372 |
+
return array(
|
373 |
+
'result' => 'success',
|
374 |
+
'redirect' => $result->redirect,
|
375 |
+
);
|
376 |
+
}
|
377 |
+
}
|
378 |
+
|
379 |
+
/**
|
380 |
+
*
|
381 |
+
* @return array
|
382 |
+
*/
|
383 |
+
public function get_localized_params() {
|
384 |
+
return array(
|
385 |
+
'gateway_id' => $this->id,
|
386 |
+
'api_key' => wc_stripe_get_publishable_key(),
|
387 |
+
'saved_method_selector' => '[name="' . $this->saved_method_key . '"]',
|
388 |
+
'token_selector' => '[name="' . $this->token_key . '"]',
|
389 |
+
'payment_intent_selector' => '[name="' . $this->payment_intent_key . '"]',
|
390 |
+
'messages' => array( 'terms' => __( 'Please read and accept the terms and conditions to proceed with your order.', 'woocommerce' ) ),
|
391 |
+
'routes' => array(
|
392 |
+
'setup_intent' => wc_stripe()->rest_api->payment_intent->rest_url( 'setup-intent' ),
|
393 |
+
'sync_intent' => wc_stripe()->rest_api->payment_intent->rest_url( 'sync-payment-intent' ),
|
394 |
+
'add_to_cart' => wc_stripe()->rest_api->cart->rest_url( 'add-to-cart' ),
|
395 |
+
'cart_calculation' => wc_stripe()->rest_api->cart->rest_url( 'cart-calculation' ),
|
396 |
+
'shipping_method' => wc_stripe()->rest_api->cart->rest_url( 'shipping-method' ),
|
397 |
+
'shipping_address' => wc_stripe()->rest_api->cart->rest_url( 'shipping-address' ),
|
398 |
+
'checkout' => wc_stripe()->rest_api->checkout->rest_url( 'checkout' ),
|
399 |
+
),
|
400 |
+
'rest_nonce' => wp_create_nonce( 'wp_rest' ),
|
401 |
+
'needs_shipping' => $this->get_needs_shipping(),
|
402 |
+
'banner_enabled' => $this->banner_checkout_enabled(),
|
403 |
+
'currency' => get_woocommerce_currency(),
|
404 |
+
'total_label' => __( 'Total', 'woo-stripe-payment' ),
|
405 |
+
'country_code' => wc_get_base_location()['country'],
|
406 |
+
);
|
407 |
+
}
|
408 |
+
|
409 |
+
/**
|
410 |
+
* Save the Stripe data to the order.
|
411 |
+
*
|
412 |
+
* @param WC_Order $order
|
413 |
+
* @param \Stripe\Charge $charge
|
414 |
+
*/
|
415 |
+
public function save_order_meta( $order, $charge ) {
|
416 |
+
/**
|
417 |
+
*
|
418 |
+
* @var WC_Payment_Token_Stripe $token
|
419 |
+
*/
|
420 |
+
$token = $this->get_payment_token( $this->get_payment_method_from_charge( $charge ), $charge->payment_method_details );
|
421 |
+
$order->set_transaction_id( $charge->id );
|
422 |
+
$order->set_payment_method_title( $token->get_payment_method_title() );
|
423 |
+
$order->update_meta_data( WC_Stripe_Constants::MODE, wc_stripe_mode() );
|
424 |
+
$order->update_meta_data( WC_Stripe_Constants::CHARGE_STATUS, $charge->status );
|
425 |
+
$order->update_meta_data( WC_Stripe_Constants::PAYMENT_METHOD_TOKEN, $token->get_token() );
|
426 |
+
$order->save();
|
427 |
+
|
428 |
+
// if WCS is active and there are subscriptions in the order, save meta data
|
429 |
+
if ( wcs_stripe_active() && wcs_order_contains_subscription( $order ) ) {
|
430 |
+
foreach ( wcs_get_subscriptions_for_order( $order ) as $subscription ) {
|
431 |
+
$subscription->set_transaction_id( $charge->id );
|
432 |
+
$subscription->set_payment_method_title( $token->get_payment_method_title() );
|
433 |
+
$subscription->update_meta_data( WC_Stripe_Constants::MODE, wc_stripe_mode() );
|
434 |
+
$subscription->update_meta_data( WC_Stripe_Constants::CHARGE_STATUS, $charge->status );
|
435 |
+
$subscription->update_meta_data( WC_Stripe_Constants::PAYMENT_METHOD_TOKEN, $token->get_token() );
|
436 |
+
$subscription->update_meta_data( WC_Stripe_Constants::CUSTOMER_ID, wc_stripe_get_customer_id( $order->get_user_id() ) );
|
437 |
+
$subscription->save();
|
438 |
+
}
|
439 |
+
}
|
440 |
+
}
|
441 |
+
|
442 |
+
/**
|
443 |
+
* Given a charge object, return the ID of the payment method used for the charge.
|
444 |
+
*
|
445 |
+
* @param \Stripe\Charge $charge
|
446 |
+
*
|
447 |
+
* @since 3.0.6
|
448 |
+
*/
|
449 |
+
public function get_payment_method_from_charge( $charge ) {
|
450 |
+
return $this->payment_object->get_payment_method_from_charge( $charge );
|
451 |
+
}
|
452 |
+
|
453 |
+
/**
|
454 |
+
*
|
455 |
+
* {@inheritDoc}
|
456 |
+
*
|
457 |
+
* @see WC_Payment_Gateway::add_payment_method()
|
458 |
+
*/
|
459 |
+
public function add_payment_method() {
|
460 |
+
$user_id = get_current_user_id();
|
461 |
+
try {
|
462 |
+
if ( ! is_user_logged_in() ) {
|
463 |
+
throw new Exception( __( 'User must be logged in.', 'woo-stripe-payment' ) );
|
464 |
+
}
|
465 |
+
|
466 |
+
$customer_id = wc_stripe_get_customer_id( $user_id );
|
467 |
+
|
468 |
+
if ( empty( $customer_id ) ) {
|
469 |
+
$customer_id = $this->create_customer( $user_id );
|
470 |
+
}
|
471 |
+
|
472 |
+
$result = $this->create_payment_method( $this->get_new_source_token(), $customer_id );
|
473 |
+
|
474 |
+
if ( is_wp_error( $result ) ) {
|
475 |
+
wc_add_notice( sprintf( __( 'Error saving your payment method. Reason: %s', 'woo-stripe-payment' ), $result->get_error_message() ), 'error' );
|
476 |
+
|
477 |
+
return array( 'result' => 'error' );
|
478 |
+
}
|
479 |
+
$result->set_user_id( $user_id );
|
480 |
+
$result->save();
|
481 |
+
WC_Payment_Tokens::set_users_default( $user_id, $result->get_id() );
|
482 |
+
|
483 |
+
do_action( 'wc_stripe_add_payment_method_success', $result );
|
484 |
+
|
485 |
+
return array(
|
486 |
+
'result' => 'success',
|
487 |
+
'redirect' => wc_get_account_endpoint_url( 'payment-methods' ),
|
488 |
+
);
|
489 |
+
} catch ( \Stripe\Error\Base $e ) {
|
490 |
+
wc_add_notice( sprintf( __( 'Error saving payment method. Reason: %s', 'woo-stripe-payment' ), $e->getMessage() ), 'error' );
|
491 |
+
|
492 |
+
return array( 'result' => 'error' );
|
493 |
+
}
|
494 |
+
}
|
495 |
+
|
496 |
+
/**
|
497 |
+
*
|
498 |
+
* {@inheritDoc}
|
499 |
+
*
|
500 |
+
* @see WC_Payment_Gateway::process_refund()
|
501 |
+
*/
|
502 |
+
public function process_refund( $order_id, $amount = null, $reason = '' ) {
|
503 |
+
$order = wc_get_order( $order_id );
|
504 |
+
$result = $this->payment_object->process_refund( $order, $amount );
|
505 |
+
|
506 |
+
if ( ! is_wp_error( $result ) ) {
|
507 |
+
$order->add_order_note(
|
508 |
+
sprintf(
|
509 |
+
__( 'Order refunded in Stripe. Amount: %s', 'woo-stripe-payment' ),
|
510 |
+
wc_price(
|
511 |
+
$amount,
|
512 |
+
array(
|
513 |
+
'currency' => $order->get_currency(),
|
514 |
+
)
|
515 |
+
)
|
516 |
+
)
|
517 |
+
);
|
518 |
+
}
|
519 |
+
|
520 |
+
return $result;
|
521 |
+
}
|
522 |
+
|
523 |
+
/**
|
524 |
+
* Captures the charge for the Stripe order.
|
525 |
+
*
|
526 |
+
* @param float $amount
|
527 |
+
* @param WC_Order $order
|
528 |
+
*/
|
529 |
+
public function capture_charge( $amount, $order ) {
|
530 |
+
$result = $this->gateway->charges->mode( wc_stripe_order_mode( $order ) )->retrieve( $order->get_transaction_id() );
|
531 |
+
|
532 |
+
if ( is_wp_error( $result ) ) {
|
533 |
+
return;
|
534 |
+
} else {
|
535 |
+
if ( ! $result->captured ) {
|
536 |
+
$result = $this->payment_object->capture_charge( $amount, $order );
|
537 |
+
|
538 |
+
if ( ! is_wp_error( $result ) ) {
|
539 |
+
remove_action( 'woocommerce_order_status_completed', 'wc_stripe_order_status_completed' );
|
540 |
+
$order->payment_complete();
|
541 |
+
if ( $amount != $order->get_total() ) {
|
542 |
+
$order->set_total( $amount );
|
543 |
+
$order->save();
|
544 |
+
}
|
545 |
+
$order->add_order_note(
|
546 |
+
sprintf(
|
547 |
+
__( 'Order amount captured in Stripe. Amount: %s', 'woo-stripe-payment' ),
|
548 |
+
wc_price(
|
549 |
+
$amount,
|
550 |
+
array(
|
551 |
+
'currency' => $order->get_currency(),
|
552 |
+
)
|
553 |
+
)
|
554 |
+
)
|
555 |
+
);
|
556 |
+
} else {
|
557 |
+
$order->add_order_note( sprintf( __( 'Error capturing charge in Stripe. Reason: %s', 'woo-stripe-payment' ), $result->get_error_message() ) );
|
558 |
+
}
|
559 |
+
}
|
560 |
+
}
|
561 |
+
|
562 |
+
return $result;
|
563 |
+
}
|
564 |
+
|
565 |
+
/**
|
566 |
+
* Void the Stripe charge.
|
567 |
+
*
|
568 |
+
* @param WC_Order $order
|
569 |
+
*/
|
570 |
+
public function void_charge( $order ) {
|
571 |
+
// @3.1.1 - check added so errors aren't encountered if the order can't be voided
|
572 |
+
if ( ! $this->payment_object->can_void_order( $order ) ) {
|
573 |
+
return;
|
574 |
+
}
|
575 |
+
$result = $this->payment_object->void_charge( $order );
|
576 |
+
|
577 |
+
if ( is_wp_error( $result ) ) {
|
578 |
+
$order->add_order_note( sprintf( __( 'Error voiding charge. Reason: %s', 'woo-stripe-payment' ), $result->get_error_message() ) );
|
579 |
+
} else {
|
580 |
+
$order->add_order_note( __( 'Charge voided in Stripe.', 'woo-stripe-payment' ) );
|
581 |
+
}
|
582 |
+
}
|
583 |
+
|
584 |
+
/**
|
585 |
+
* Return the \Stripe\Charge object
|
586 |
+
*
|
587 |
+
* @param String $charge_id
|
588 |
+
* @param String $mode
|
589 |
+
*
|
590 |
+
* @return WP_Error|\Stripe\Charge
|
591 |
+
*/
|
592 |
+
public function retrieve_charge( $charge_id, $mode = '' ) {
|
593 |
+
return $this->gateway->charges->mode( $mode )->retrieve( $charge_id );
|
594 |
+
}
|
595 |
+
|
596 |
+
/**
|
597 |
+
*
|
598 |
+
* @param string $method_id
|
599 |
+
* @param \Stripe\Card|array $method_details
|
600 |
+
*/
|
601 |
+
public function get_payment_token( $method_id, $method_details = null ) {
|
602 |
+
$class_name = 'WC_Payment_Token_' . $this->token_type;
|
603 |
+
if ( class_exists( $class_name ) ) {
|
604 |
+
/**
|
605 |
+
*
|
606 |
+
* @var WC_Payment_Token_Stripe $token
|
607 |
+
*/
|
608 |
+
$token = new $class_name( '', $method_details );
|
609 |
+
$token->set_token( $method_id );
|
610 |
+
$token->set_gateway_id( $this->id );
|
611 |
+
$token->set_format( $this->get_option( 'method_format' ) );
|
612 |
+
$token->set_environment( wc_stripe_mode() );
|
613 |
+
if ( $method_details ) {
|
614 |
+
$token->details_to_props( $method_details );
|
615 |
+
}
|
616 |
+
|
617 |
+
return $token;
|
618 |
+
}
|
619 |
+
}
|
620 |
+
|
621 |
+
/**
|
622 |
+
* Return a failed order response.
|
623 |
+
*
|
624 |
+
* @return array
|
625 |
+
*/
|
626 |
+
public function get_order_error() {
|
627 |
+
wc_stripe_set_checkout_error();
|
628 |
+
|
629 |
+
return array( 'result' => WC_Stripe_Constants::FAILURE );
|
630 |
+
}
|
631 |
+
|
632 |
+
/**
|
633 |
+
* Return the payment source the customer has chosen to use.
|
634 |
+
* This can be a saved source
|
635 |
+
* or a one time use source.
|
636 |
+
*/
|
637 |
+
public function get_payment_source() {
|
638 |
+
if ( $this->use_saved_source() ) {
|
639 |
+
return $this->get_saved_source_id();
|
640 |
+
} else {
|
641 |
+
if ( $this->payment_method_token ) {
|
642 |
+
return $this->payment_method_token;
|
643 |
+
}
|
644 |
+
|
645 |
+
return $this->get_new_source_token();
|
646 |
+
}
|
647 |
+
}
|
648 |
+
|
649 |
+
/**
|
650 |
+
* Returns the payment method the customer wants to use.
|
651 |
+
* This can be a saved payment method
|
652 |
+
* or a new payment method.
|
653 |
+
*/
|
654 |
+
public function get_payment_method_from_request() {
|
655 |
+
return $this->get_payment_source();
|
656 |
+
}
|
657 |
+
|
658 |
+
public function get_payment_intent_id() {
|
659 |
+
return ! empty( $_POST[ $this->payment_intent_key ] ) ? $_POST[ $this->payment_intent_key ] : '';
|
660 |
+
}
|
661 |
+
|
662 |
+
/**
|
663 |
+
* Return true of the customer is using a saved payment method.
|
664 |
+
*/
|
665 |
+
public function use_saved_source() {
|
666 |
+
return ( ! empty( $_POST[ $this->payment_type_key ] ) && $_POST[ $this->payment_type_key ] === 'saved' ) || $this->payment_method_token;
|
667 |
+
}
|
668 |
+
|
669 |
+
/**
|
670 |
+
*
|
671 |
+
* @deprecated
|
672 |
+
*
|
673 |
+
*/
|
674 |
+
public function get_new_source_id() {
|
675 |
+
return $this->get_new_source_token();
|
676 |
+
}
|
677 |
+
|
678 |
+
public function get_new_source_token() {
|
679 |
+
return null != $this->new_source_token ? $this->new_source_token : ( ! empty( $_POST[ $this->token_key ] ) ? $_POST[ $this->token_key ] : '' );
|
680 |
+
}
|
681 |
+
|
682 |
+
public function get_saved_source_id() {
|
683 |
+
return ! empty( $_POST[ $this->saved_method_key ] ) ? $_POST[ $this->saved_method_key ] : $this->payment_method_token;
|
684 |
+
}
|
685 |
+
|
686 |
+
/**
|
687 |
+
* Create a customer in the stripe gateway.
|
688 |
+
*
|
689 |
+
* @param int $user_id
|
690 |
+
*/
|
691 |
+
public function create_customer( $user_id ) {
|
692 |
+
$customer = WC()->customer;
|
693 |
+
$response = $this->gateway->customers->create(
|
694 |
+
apply_filters( 'wc_stripe_customer_args', array(
|
695 |
+
'email' => $customer->get_email(),
|
696 |
+
'name' => sprintf( '%s %s', $customer->get_first_name(), $customer->get_last_name() ),
|
697 |
+
'phone' => $customer->get_billing_phone(),
|
698 |
+
'metadata' => array(
|
699 |
+
'user_id' => $customer->get_id(),
|
700 |
+
'username' => $customer->get_username(),
|
701 |
+
'website' => get_site_url(),
|
702 |
+
),
|
703 |
+
) )
|
704 |
+
);
|
705 |
+
if ( ! is_wp_error( $response ) ) {
|
706 |
+
wc_stripe_save_customer( $response->id, $user_id );
|
707 |
+
}
|
708 |
+
|
709 |
+
return $customer;
|
710 |
+
}
|
711 |
+
|
712 |
+
/**
|
713 |
+
* Creates a payment method in Stripe.
|
714 |
+
*
|
715 |
+
* @param string $id
|
716 |
+
* payment method id
|
717 |
+
* @param string $customer_id
|
718 |
+
* WC Stripe customer ID
|
719 |
+
*
|
720 |
+
* @return WC_Payment_Token_Stripe|WP_Error
|
721 |
+
*/
|
722 |
+
public function create_payment_method( $id, $customer_id ) {
|
723 |
+
$token = $this->get_payment_token( $id );
|
724 |
+
$token->set_customer_id( $customer_id );
|
725 |
+
|
726 |
+
$result = $token->save_payment_method();
|
727 |
+
|
728 |
+
if ( is_wp_error( $result ) ) {
|
729 |
+
return $result;
|
730 |
+
} else {
|
731 |
+
$token->set_token( $result->id );
|
732 |
+
$token->details_to_props( $result );
|
733 |
+
|
734 |
+
return $token;
|
735 |
+
}
|
736 |
+
}
|
737 |
+
|
738 |
+
/**
|
739 |
+
*
|
740 |
+
* @param array $item
|
741 |
+
* @param WC_Payment_Token_Stripe_CC $payment_token
|
742 |
+
*/
|
743 |
+
public function payment_methods_list_item( $item, $payment_token ) {
|
744 |
+
if ( $payment_token->get_type() === $this->token_type ) {
|
745 |
+
$item['method']['last4'] = $payment_token->get_last4();
|
746 |
+
$item['method']['brand'] = ucfirst( $payment_token->get_brand() );
|
747 |
+
if ( $payment_token->has_expiration() ) {
|
748 |
+
$item['expires'] = sprintf( '%s / %s', $payment_token->get_exp_month(), $payment_token->get_exp_year() );
|
749 |
+
} else {
|
750 |
+
$item['expires'] = __( 'n/a', 'woo-stripe-payment' );
|
751 |
+
}
|
752 |
+
$item['wc_stripe_method'] = true;
|
753 |
+
}
|
754 |
+
|
755 |
+
return $item;
|
756 |
+
}
|
757 |
+
|
758 |
+
/**
|
759 |
+
*
|
760 |
+
* @param string $token_id
|
761 |
+
* @param WC_Payment_Token_Stripe $token
|
762 |
+
*/
|
763 |
+
public function delete_payment_method( $token_id, $token ) {
|
764 |
+
$token->delete_from_stripe();
|
765 |
+
}
|
766 |
+
|
767 |
+
public function saved_payment_methods( $tokens = array() ) {
|
768 |
+
wc_stripe_get_template(
|
769 |
+
'payment-methods.php',
|
770 |
+
array(
|
771 |
+
'tokens' => $tokens,
|
772 |
+
'gateway' => $this,
|
773 |
+
)
|
774 |
+
);
|
775 |
+
}
|
776 |
+
|
777 |
+
public function get_new_method_label() {
|
778 |
+
return __( 'New Card', 'woo-stripe-payment' );
|
779 |
+
}
|
780 |
+
|
781 |
+
public function get_saved_methods_label() {
|
782 |
+
return __( 'Saved Cards', 'woo-stripe-payment' );
|
783 |
+
}
|
784 |
+
|
785 |
+
/**
|
786 |
+
* Return true if shipping is needed.
|
787 |
+
* Shipping is based on things like if the cart or product needs shipping.
|
788 |
+
*
|
789 |
+
* @return bool
|
790 |
+
*/
|
791 |
+
public function get_needs_shipping() {
|
792 |
+
if ( is_checkout() || is_cart() ) {
|
793 |
+
global $wp;
|
794 |
+
if ( wcs_stripe_active() && WC_Subscriptions_Change_Payment_Gateway::$is_request_to_change_payment ) {
|
795 |
+
return false;
|
796 |
+
}
|
797 |
+
// return false if this is the order pay page. Gateways that have payment sheets don't need
|
798 |
+
// to make any changes to the order.
|
799 |
+
if ( ! empty( $wp->query_vars['order-pay'] ) ) {
|
800 |
+
return false;
|
801 |
+
}
|
802 |
+
|
803 |
+
return WC()->cart->needs_shipping();
|
804 |
+
}
|
805 |
+
if ( is_product() ) {
|
806 |
+
global $product;
|
807 |
+
|
808 |
+
return is_a( $product, 'WC_Product' ) && $product->needs_shipping();
|
809 |
+
}
|
810 |
+
}
|
811 |
+
|
812 |
+
/**
|
813 |
+
* Return true of the payment method should be saved.
|
814 |
+
*
|
815 |
+
* @param WC_Order $order
|
816 |
+
*
|
817 |
+
* @return bool
|
818 |
+
*/
|
819 |
+
public function should_save_payment_method( $order ) {
|
820 |
+
if ( ! $this->use_saved_source() ) {
|
821 |
+
if ( wcs_stripe_active() ) {
|
822 |
+
if ( wcs_order_contains_subscription( $order ) && $this->supports( 'subscriptions' ) ) {
|
823 |
+
return true;
|
824 |
+
}
|
825 |
+
if ( wcs_cart_contains_renewal() ) {
|
826 |
+
return true;
|
827 |
+
}
|
828 |
+
}
|
829 |
+
if ( ! empty( $_POST[ $this->save_source_key ] ) ) {
|
830 |
+
return true;
|
831 |
+
}
|
832 |
+
}
|
833 |
+
|
834 |
+
return false;
|
835 |
+
}
|
836 |
+
|
837 |
+
/**
|
838 |
+
* Returns true if the save payment method checkbox can be displayed.
|
839 |
+
*
|
840 |
+
* @return boolean
|
841 |
+
*/
|
842 |
+
public function show_save_source() {
|
843 |
+
global $wp;
|
844 |
+
if ( wcs_stripe_active() ) {
|
845 |
+
if ( WC_Subscriptions_Cart::cart_contains_subscription() ) {
|
846 |
+
return false;
|
847 |
+
}
|
848 |
+
if ( WC_Subscriptions_Change_Payment_Gateway::$is_request_to_change_payment ) {
|
849 |
+
return false;
|
850 |
+
}
|
851 |
+
if ( wcs_cart_contains_renewal() ) {
|
852 |
+
return false;
|
853 |
+
}
|
854 |
+
}
|
855 |
+
// @since 3.1.5
|
856 |
+
if ( wc_stripe_pre_orders_active() && WC_Pre_Orders_Cart::cart_contains_pre_order() ) {
|
857 |
+
return ! WC_Pre_Orders_Product::product_is_charged_upon_release( WC_Pre_Orders_Cart::get_pre_order_product() );
|
858 |
+
}
|
859 |
+
|
860 |
+
return is_user_logged_in() && is_checkout() && $this->is_active( 'save_card_enabled' );
|
861 |
+
}
|
862 |
+
|
863 |
+
/**
|
864 |
+
* Returns a formatted array of items for display in the payment gateway's payment sheet.
|
865 |
+
*
|
866 |
+
* @param bool $encode
|
867 |
+
*
|
868 |
+
* @return []
|
869 |
+
*/
|
870 |
+
public function get_display_items( $encode = false ) {
|
871 |
+
}
|
872 |
+
|
873 |
+
/**
|
874 |
+
* Returns a formatted array of shipping methods for display in the payment gateway's
|
875 |
+
* payment sheet.
|
876 |
+
*
|
877 |
+
* @param bool $encode
|
878 |
+
*
|
879 |
+
* @return []
|
880 |
+
*/
|
881 |
+
public function get_shipping_methods( $encode = false ) {
|
882 |
+
}
|
883 |
+
|
884 |
+
/**
|
885 |
+
* Return true if product page checkout is enabled for this gateway
|
886 |
+
*
|
887 |
+
* @return bool
|
888 |
+
*/
|
889 |
+
public function product_checkout_enabled() {
|
890 |
+
return in_array( 'product', $this->get_option( 'payment_sections', array() ) );
|
891 |
+
}
|
892 |
+
|
893 |
+
/**
|
894 |
+
* Return true if cart page checkout is enabled for this gateway
|
895 |
+
*
|
896 |
+
* @return bool
|
897 |
+
*/
|
898 |
+
public function cart_checkout_enabled() {
|
899 |
+
return in_array( 'cart', $this->get_option( 'payment_sections', array() ) );
|
900 |
+
}
|
901 |
+
|
902 |
+
/**
|
903 |
+
* Return true if checkout page banner is enabled for this gateway
|
904 |
+
*
|
905 |
+
* @return bool
|
906 |
+
*/
|
907 |
+
public function banner_checkout_enabled() {
|
908 |
+
global $wp;
|
909 |
+
|
910 |
+
return empty( $wp->query_vars['order-pay'] ) && $this->supports( 'wc_stripe_banner_checkout' ) &&
|
911 |
+
in_array( 'checkout_banner', $this->get_option( 'payment_sections', array() ) );
|
912 |
+
}
|
913 |
+
|
914 |
+
/**
|
915 |
+
* Decorate the response with data specific to the gateway.
|
916 |
+
*
|
917 |
+
* @param [] $data
|
918 |
+
*/
|
919 |
+
public function add_to_cart_response( $data ) {
|
920 |
+
return $data;
|
921 |
+
}
|
922 |
+
|
923 |
+
/**
|
924 |
+
* Decorate the update shipping method reponse with data.
|
925 |
+
*
|
926 |
+
* @param [] $data
|
927 |
+
*/
|
928 |
+
public function get_update_shipping_method_response( $data ) {
|
929 |
+
return $data;
|
930 |
+
}
|
931 |
+
|
932 |
+
/**
|
933 |
+
* Decorate the update shipping address respond with data.
|
934 |
+
*
|
935 |
+
* @param [] $data
|
936 |
+
*/
|
937 |
+
public function get_update_shipping_address_response( $data ) {
|
938 |
+
return apply_filters( 'wc_stripe_update_shipping_address_response', $data );
|
939 |
+
}
|
940 |
+
|
941 |
+
/**
|
942 |
+
* Save the customer's payment method.
|
943 |
+
* If the payment method has already been saved to the customer
|
944 |
+
* then simply return true.
|
945 |
+
*
|
946 |
+
* @param string $id
|
947 |
+
* @param WC_Order $order
|
948 |
+
*
|
949 |
+
* @return WP_Error|bool
|
950 |
+
*/
|
951 |
+
public function save_payment_method( $id, $order ) {
|
952 |
+
$token = $this->create_payment_method( $id, wc_stripe_get_customer_id( $order->get_user_id() ) );
|
953 |
+
if ( is_wp_error( $token ) ) {
|
954 |
+
$this->wp_error = $token;
|
955 |
+
$order->add_order_note( sprintf( __( 'Attemp to save payment method failed. Reason: %s', 'woo-stripe-payment' ), $token->get_error_message() ) );
|
956 |
+
|
957 |
+
return $token;
|
958 |
+
}
|
959 |
+
$token->set_user_id( $order->get_user_id() );
|
960 |
+
$token->save();
|
961 |
+
|
962 |
+
// set token value so it can be used for other processes.
|
963 |
+
$this->payment_method_token = $token->get_token();
|
964 |
+
|
965 |
+
return true;
|
966 |
+
}
|
967 |
+
|
968 |
+
/**
|
969 |
+
* Set an error on the order.
|
970 |
+
* This error is used on the frontend to alert customer's to a failed payment method save.
|
971 |
+
*
|
972 |
+
* @param WC_Order $order
|
973 |
+
* @param WP_Error $error
|
974 |
+
*/
|
975 |
+
public function set_payment_save_error( $order, $error ) {
|
976 |
+
if ( wcs_stripe_active() && wcs_order_contains_subscription( $order ) ) {
|
977 |
+
$message = __( 'We were not able to save your payment method. To prevent billing issues with your subscription, please add a payment method to the subscription.', 'woo-stripe-payment' );
|
978 |
+
} else {
|
979 |
+
$message = sprintf( __( 'We were not able to save your payment method. Reason: %s', 'woo-stripe-payment' ), $error->get_error_message() );
|
980 |
+
}
|
981 |
+
$order->update_meta_data( '_wc_stripe_order_error', $message );
|
982 |
+
$order->save();
|
983 |
+
}
|
984 |
+
|
985 |
+
/**
|
986 |
+
*
|
987 |
+
* @param string $token_id
|
988 |
+
* @param int $user_id
|
989 |
+
*
|
990 |
+
* @return null|WC_Payment_Token_Stripe_CC
|
991 |
+
*/
|
992 |
+
public function get_token( $token_id, $user_id ) {
|
993 |
+
$tokens = WC_Payment_Tokens::get_customer_tokens( $user_id, $this->id );
|
994 |
+
foreach ( $tokens as $token ) {
|
995 |
+
if ( $token_id === $token->get_token() ) {
|
996 |
+
return $token;
|
997 |
+
}
|
998 |
+
}
|
999 |
+
|
1000 |
+
return null;
|
1001 |
+
}
|
1002 |
+
|
1003 |
+
/**
|
1004 |
+
*
|
1005 |
+
* @param array $payment_meta
|
1006 |
+
* @param WC_Subscription $subscription
|
1007 |
+
*/
|
1008 |
+
public function subscription_payment_meta( $payment_meta, $subscription ) {
|
1009 |
+
$payment_meta[ $this->id ] = array(
|
1010 |
+
'post_meta' => array(
|
1011 |
+
WC_Stripe_Constants::PAYMENT_METHOD_TOKEN => array(
|
1012 |
+
'value' => $this->get_order_meta_data( WC_Stripe_Constants::PAYMENT_METHOD_TOKEN, $subscription ),
|
1013 |
+
'label' => __( 'Payment Method Token', 'woo-stripe-payment' ),
|
1014 |
+
),
|
1015 |
+
),
|
1016 |
+
);
|
1017 |
+
|
1018 |
+
return $payment_meta;
|
1019 |
+
}
|
1020 |
+
|
1021 |
+
/**
|
1022 |
+
*
|
1023 |
+
* @param float $amount
|
1024 |
+
* @param WC_Order $order
|
1025 |
+
*/
|
1026 |
+
public function scheduled_subscription_payment( $amount, $order ) {
|
1027 |
+
$this->processing_payment = true;
|
1028 |
+
|
1029 |
+
$result = $this->payment_object->scheduled_subscription_payment( $amount, $order );
|
1030 |
+
|
1031 |
+
if ( is_wp_error( $result ) ) {
|
1032 |
+
$order->update_status( 'failed' );
|
1033 |
+
$order->add_order_note( sprintf( __( 'Recurring payment for order failed. Reason: %s', 'woo-stripe-payment' ), $result->get_error_message() ) );
|
1034 |
+
|
1035 |
+
return;
|
1036 |
+
}
|
1037 |
+
|
1038 |
+
$this->save_order_meta( $order, $result->charge );
|
1039 |
+
|
1040 |
+
// set the payment method token that was used to process the renewal order.
|
1041 |
+
$this->payment_method_token = $order->get_meta( WC_Stripe_Constants::PAYMENT_METHOD_TOKEN );
|
1042 |
+
|
1043 |
+
if ( $result->complete_payment ) {
|
1044 |
+
if ( $result->charge->captured ) {
|
1045 |
+
$order->payment_complete( $result->charge->id );
|
1046 |
+
$order->add_order_note( sprintf( __( 'Recurring payment captured in Stripe. Payment method: %s', 'woo-stripe-payment' ), $order->get_payment_method_title() ) );
|
1047 |
+
} else {
|
1048 |
+
$order->update_status( apply_filters( 'wc_stripe_authorized_renewal_order_status', 'on-hold', $order, $this ), sprintf( __( 'Recurring payment authorized in Stripe. Payment method: %s', 'woo-stripe-payment' ), $order->get_payment_method_title() ) );
|
1049 |
+
}
|
1050 |
+
} else {
|
1051 |
+
$order->update_status( 'pending', sprintf( __( 'Customer must manually complete payment for payment method %s', 'woo-stripe-payment' ), $order->get_payment_method_title() ) );
|
1052 |
+
}
|
1053 |
+
}
|
1054 |
+
|
1055 |
+
/**
|
1056 |
+
*
|
1057 |
+
* @param WC_Subscription $subscription
|
1058 |
+
* @param string $new_payment_method
|
1059 |
+
* @param string $old_payment_method
|
1060 |
+
*/
|
1061 |
+
public function subscriptions_pre_update_payment_method( $subscription, $new_payment_method, $old_payment_method ) {
|
1062 |
+
if ( $new_payment_method === $this->id ) {
|
1063 |
+
// customer is using a new payment method so we need to save it.
|
1064 |
+
if ( ! $this->use_saved_source() ) {
|
1065 |
+
$result = $this->save_payment_method( $this->get_new_source_token(), $subscription );
|
1066 |
+
if ( is_wp_error( $result ) ) {
|
1067 |
+
wc_add_notice( sprintf( __( 'Error saving payment method for subscription. Reason: %s', 'woo-stripe-payment' ), $result->get_error_message() ), 'error' );
|
1068 |
+
// redirect to change payment method page.
|
1069 |
+
wp_safe_redirect( $subscription->get_view_order_url() );
|
1070 |
+
exit();
|
1071 |
+
}
|
1072 |
+
} else {
|
1073 |
+
if ( ! $this->payment_method_token ) {
|
1074 |
+
// set the payment method token so it can be used downstream.
|
1075 |
+
$this->payment_method_token = $this->get_payment_source();
|
1076 |
+
}
|
1077 |
+
}
|
1078 |
+
}
|
1079 |
+
}
|
1080 |
+
|
1081 |
+
/**
|
1082 |
+
* Update the subscription with the new meta data for the gateway.
|
1083 |
+
* Save any new method the customer is trying to use.
|
1084 |
+
*
|
1085 |
+
* @param WC_Subscription $subscription
|
1086 |
+
*/
|
1087 |
+
public function subscription_payment_method_updated( $subscription ) {
|
1088 |
+
$token = $this->get_token( $this->payment_method_token, $subscription->get_user_id() );
|
1089 |
+
|
1090 |
+
// update the meta data needed by the gateway to process a subscription payment.
|
1091 |
+
$subscription->update_meta_data( WC_Stripe_Constants::PAYMENT_METHOD_TOKEN, $this->payment_method_token );
|
1092 |
+
$subscription->set_payment_method_title( $token->get_payment_method_title() );
|
1093 |
+
$subscription->save();
|
1094 |
+
}
|
1095 |
+
|
1096 |
+
/**
|
1097 |
+
* Return true if this request is to change the payment method of a WC Subscription.
|
1098 |
+
*
|
1099 |
+
* @return bool
|
1100 |
+
*/
|
1101 |
+
public function is_change_payment_method_request() {
|
1102 |
+
return wcs_stripe_active() && did_action( 'woocommerce_subscriptions_pre_update_payment_method' );
|
1103 |
+
}
|
1104 |
+
|
1105 |
+
/**
|
1106 |
+
* Sets the ID of a payment token.
|
1107 |
+
*
|
1108 |
+
* @param string $id
|
1109 |
+
*/
|
1110 |
+
public function set_payment_method_token( $id ) {
|
1111 |
+
$this->payment_method_token = $id;
|
1112 |
+
}
|
1113 |
+
|
1114 |
+
public function set_new_source_token( $token ) {
|
1115 |
+
$this->new_source_token = $token;
|
1116 |
+
}
|
1117 |
+
|
1118 |
+
/**
|
1119 |
+
*
|
1120 |
+
* @param WC_Order $order
|
1121 |
+
*
|
1122 |
+
* @deprecated
|
1123 |
+
*
|
1124 |
+
*/
|
1125 |
+
public function get_order_description( $order ) {
|
1126 |
+
return sprintf( __( 'Order %1$s from %2$s', 'woo-stripe-payment' ), $order->get_order_number(), get_bloginfo( 'name' ) );
|
1127 |
+
}
|
1128 |
+
|
1129 |
+
/**
|
1130 |
+
*
|
1131 |
+
* @param WC_Order $order
|
1132 |
+
*/
|
1133 |
+
public function process_zero_total_order( $order ) {
|
1134 |
+
// save payment method if necessary
|
1135 |
+
if ( $this->should_save_payment_method( $order ) ) {
|
1136 |
+
$result = $this->save_payment_method( $this->get_new_source_token(), $order );
|
1137 |
+
if ( is_wp_error( $result ) ) {
|
1138 |
+
wc_add_notice( $result->get_error_message(), 'error' );
|
1139 |
+
|
1140 |
+
return $this->get_order_error();
|
1141 |
+
}
|
1142 |
+
} else {
|
1143 |
+
$this->payment_method_token = $this->get_saved_source_id();
|
1144 |
+
}
|
1145 |
+
$this->save_zero_total_meta( $order );
|
1146 |
+
$order_status = $this->get_option( 'order_status' );
|
1147 |
+
if ( 'capture' === $this->get_option( 'charge_type' ) ) {
|
1148 |
+
$order->payment_complete();
|
1149 |
+
} else {
|
1150 |
+
$order_status = $this->get_option( 'order_status' );
|
1151 |
+
$order->update_status( apply_filters( 'wc_stripe_authorized_order_status', 'default' === $order_status ? 'on-hold' : $order_status, $order, $this ) );
|
1152 |
+
}
|
1153 |
+
WC()->cart->empty_cart();
|
1154 |
+
|
1155 |
+
return array(
|
1156 |
+
'result' => 'success',
|
1157 |
+
'redirect' => $order->get_checkout_order_received_url(),
|
1158 |
+
);
|
1159 |
+
}
|
1160 |
+
|
1161 |
+
public function process_pre_order( $order ) {
|
1162 |
+
// maybe save payment method
|
1163 |
+
if ( ! $this->use_saved_source() ) {
|
1164 |
+
$result = $this->save_payment_method( $this->get_new_source_token(), $order );
|
1165 |
+
if ( is_wp_error( $result ) ) {
|
1166 |
+
wc_add_notice( $result->get_error_message(), 'error' );
|
1167 |
+
|
1168 |
+
return $this->get_order_error();
|
1169 |
+
}
|
1170 |
+
} else {
|
1171 |
+
$this->payment_method_token = $this->get_saved_source_id();
|
1172 |
+
}
|
1173 |
+
WC_Pre_Orders_Order::mark_order_as_pre_ordered( $order );
|
1174 |
+
$this->save_zero_total_meta( $order );
|
1175 |
+
|
1176 |
+
return array(
|
1177 |
+
'result' => 'success',
|
1178 |
+
'redirect' => $order->get_checkout_order_received_url(),
|
1179 |
+
);
|
1180 |
+
}
|
1181 |
+
|
1182 |
+
/**
|
1183 |
+
*
|
1184 |
+
* @param WC_Order $order
|
1185 |
+
*/
|
1186 |
+
protected function save_zero_total_meta( $order ) {
|
1187 |
+
$token = $this->get_token( $this->payment_method_token, $order->get_user_id() );
|
1188 |
+
$order->set_payment_method_title( $token->get_payment_method_title() );
|
1189 |
+
$order->update_meta_data( WC_Stripe_Constants::MODE, wc_stripe_mode() );
|
1190 |
+
$order->update_meta_data( WC_Stripe_Constants::PAYMENT_METHOD_TOKEN, $token->get_token() );
|
1191 |
+
$order->update_meta_data( WC_Stripe_Constants::CUSTOMER_ID, wc_stripe_get_customer_id( $order->get_user_id() ) );
|
1192 |
+
$order->save();
|
1193 |
+
|
1194 |
+
if ( wcs_stripe_active() && wcs_order_contains_subscription( $order ) ) {
|
1195 |
+
foreach ( wcs_get_subscriptions_for_order( $order ) as $subscription ) {
|
1196 |
+
/**
|
1197 |
+
*
|
1198 |
+
* @var WC_Subscription $subscription
|
1199 |
+
*/
|
1200 |
+
$subscription->set_payment_method_title( $token->get_payment_method_title() );
|
1201 |
+
$subscription->update_meta_data( WC_Stripe_Constants::MODE, wc_stripe_mode() );
|
1202 |
+
$subscription->update_meta_data( WC_Stripe_Constants::PAYMENT_METHOD_TOKEN, $token->get_token() );
|
1203 |
+
$subscription->update_meta_data( WC_Stripe_Constants::CUSTOMER_ID, wc_stripe_get_customer_id( $order->get_user_id() ) );
|
1204 |
+
$subscription->save();
|
1205 |
+
}
|
1206 |
+
}
|
1207 |
+
}
|
1208 |
+
|
1209 |
+
/**
|
1210 |
+
* Pre orders can't be mixed with regular products.
|
1211 |
+
*
|
1212 |
+
* @param WC_Order $order
|
1213 |
+
*/
|
1214 |
+
protected function order_contains_pre_order( $order ) {
|
1215 |
+
return wc_stripe_pre_orders_active() && WC_Pre_Orders_Order::order_contains_pre_order( $order );
|
1216 |
+
}
|
1217 |
+
|
1218 |
+
/**
|
1219 |
+
*
|
1220 |
+
* @param WC_Order $order
|
1221 |
+
*
|
1222 |
+
* @return boolean
|
1223 |
+
*/
|
1224 |
+
protected function pre_order_requires_tokenization( $order ) {
|
1225 |
+
return WC_Pre_Orders_Order::order_requires_payment_tokenization( $order );
|
1226 |
+
}
|
1227 |
+
|
1228 |
+
/**
|
1229 |
+
* Sets a lock on the order.
|
1230 |
+
* Default behavior is a 2 minute lock.
|
1231 |
+
*
|
1232 |
+
* @param WC_Order|int $order
|
1233 |
+
*/
|
1234 |
+
public function set_order_lock( $order ) {
|
1235 |
+
$order_id = ( is_object( $order ) ? $order->get_id() : $order );
|
1236 |
+
set_transient( 'stripe_lock_order_' . $order_id, $order_id, apply_filters( 'wc_stripe_set_order_lock', 2 * MINUTE_IN_SECONDS ) );
|
1237 |
+
}
|
1238 |
+
|
1239 |
+
/**
|
1240 |
+
* Removes the lock on the order
|
1241 |
+
*
|
1242 |
+
* @param WC_Order|int $order
|
1243 |
+
*/
|
1244 |
+
public function release_order_lock( $order ) {
|
1245 |
+
delete_transient( 'stripe_lock_order_' . ( is_object( $order ) ? $order->get_id() : $order ) );
|
1246 |
+
}
|
1247 |
+
|
1248 |
+
/**
|
1249 |
+
* Returns true of the order has been locked.
|
1250 |
+
* If the lock exists and is greater than current time
|
1251 |
+
* method returns true;
|
1252 |
+
*
|
1253 |
+
* @param WC_Order|int $order
|
1254 |
+
*/
|
1255 |
+
public function has_order_lock( $order ) {
|
1256 |
+
$lock = get_transient( 'stripe_lock_order_' . ( is_object( $order ) ? $order->get_id() : $order ) );
|
1257 |
+
|
1258 |
+
return $lock !== false;
|
1259 |
+
}
|
1260 |
+
|
1261 |
+
public function set_post_payment_process( $callback ) {
|
1262 |
+
$this->post_payment_processes[] = $callback;
|
1263 |
+
}
|
1264 |
+
|
1265 |
+
/**
|
1266 |
+
*
|
1267 |
+
* @param WC_Order $order
|
1268 |
+
* @param WC_Payment_Gateway_Stripe $gateway
|
1269 |
+
*/
|
1270 |
+
public function trigger_post_payment_processes( $order, $gateway ) {
|
1271 |
+
foreach ( $this->post_payment_processes as $callback ) {
|
1272 |
+
call_user_func_array( $callback, func_get_args() );
|
1273 |
+
}
|
1274 |
+
}
|
1275 |
+
|
1276 |
+
public function validate_payment_sections_field( $key, $value ) {
|
1277 |
+
if ( empty( $value ) ) {
|
1278 |
+
$value = array();
|
1279 |
+
}
|
1280 |
+
|
1281 |
+
return $value;
|
1282 |
+
}
|
1283 |
+
|
1284 |
+
/**
|
1285 |
+
*
|
1286 |
+
* @param WC_Order $order
|
1287 |
+
*/
|
1288 |
+
public function process_pre_order_payment( $order ) {
|
1289 |
+
$this->processing_payment = true;
|
1290 |
+
|
1291 |
+
$result = $this->payment_object->process_pre_order_payment( $order );
|
1292 |
+
|
1293 |
+
if ( is_wp_error( $result ) ) {
|
1294 |
+
$order->update_status( 'failed' );
|
1295 |
+
$order->add_order_note( sprintf( __( 'Pre-order payment for order failed. Reason: %s', 'woo-stripe-payment' ), $result->get_error_message() ) );
|
1296 |
+
} else {
|
1297 |
+
if ( $result->complete_payment ) {
|
1298 |
+
|
1299 |
+
$this->save_order_meta( $order, $result->charge );
|
1300 |
+
|
1301 |
+
if ( $result->charge->captured ) {
|
1302 |
+
$order->payment_complete( $result->charge->id );
|
1303 |
+
$order->add_order_note( sprintf( __( 'Pre-order payment captured in Stripe. Payment method: %s', 'woo-stripe-payment' ), $order->get_payment_method_title() ) );
|
1304 |
+
} else {
|
1305 |
+
$order->update_status( apply_filters( 'wc_stripe_authorized_preorder_order_status', 'on-hold', $order, $this ), sprintf( __( 'Pre-order payment authorized in Stripe. Payment method: %s', 'woo-stripe-payment' ), $order->get_payment_method_title() ) );
|
1306 |
+
}
|
1307 |
+
} else {
|
1308 |
+
$order->update_status( 'pending', sprintf( __( 'Customer must manually complete payment for payment method %s', 'woo-stripe-payment' ), $order->get_payment_method_title() ) );
|
1309 |
+
}
|
1310 |
+
}
|
1311 |
+
}
|
1312 |
+
|
1313 |
+
/**
|
1314 |
+
* Given a meta key, see if there is a value for that key in another plugin.
|
1315 |
+
* This acts as a lazy conversion
|
1316 |
+
* method for merchants that have switched to our plugin from other plugins.
|
1317 |
+
*
|
1318 |
+
* @param string $meta_key
|
1319 |
+
* @param WC_Order $order
|
1320 |
+
* @param string $context
|
1321 |
+
*
|
1322 |
+
* @since 3.1.0
|
1323 |
+
*/
|
1324 |
+
public function get_order_meta_data( $meta_key, $order, $context = 'view' ) {
|
1325 |
+
$value = $order->get_meta( $meta_key, true, $context );
|
1326 |
+
// value is empty so check metadata from other plugins
|
1327 |
+
if ( empty( $value ) ) {
|
1328 |
+
$keys = array();
|
1329 |
+
switch ( $meta_key ) {
|
1330 |
+
case WC_Stripe_Constants::PAYMENT_METHOD_TOKEN:
|
1331 |
+
$keys = array( WC_Stripe_Constants::SOURCE_ID );
|
1332 |
+
break;
|
1333 |
+
case WC_Stripe_Constants::CUSTOMER_ID:
|
1334 |
+
$keys = array( WC_Stripe_Constants::STRIPE_CUSTOMER_ID );
|
1335 |
+
break;
|
1336 |
+
case WC_Stripe_Constants::PAYMENT_INTENT_ID:
|
1337 |
+
$keys = array( WC_Stripe_Constants::STRIPE_INTENT_ID );
|
1338 |
+
}
|
1339 |
+
if ( $keys ) {
|
1340 |
+
$meta_data = $order->get_meta_data();
|
1341 |
+
if ( $meta_data ) {
|
1342 |
+
$keys = array_intersect( wp_list_pluck( $meta_data, 'key' ), $keys );
|
1343 |
+
$array_keys = array_keys( $keys );
|
1344 |
+
if ( ! empty( $array_keys ) ) {
|
1345 |
+
$value = $meta_data[ current( $array_keys ) ]->value;
|
1346 |
+
update_post_meta( $order->get_id(), $meta_key, $value );
|
1347 |
+
}
|
1348 |
+
}
|
1349 |
+
}
|
1350 |
+
}
|
1351 |
+
|
1352 |
+
return $value;
|
1353 |
+
}
|
1354 |
+
|
1355 |
+
/**
|
1356 |
+
* Gateways can override this method to add attributes to the Stripe object before it's
|
1357 |
+
* sent to Stripe.
|
1358 |
+
*
|
1359 |
+
* @param array $args
|
1360 |
+
* @param WC_Order $order
|
1361 |
+
*/
|
1362 |
+
public function add_stripe_order_args( &$args, $order ) {
|
1363 |
+
}
|
1364 |
+
|
1365 |
+
/**
|
1366 |
+
*
|
1367 |
+
* @param WP_Error $result
|
1368 |
+
*
|
1369 |
+
* @since 3.1.1
|
1370 |
+
*/
|
1371 |
+
public function get_generic_error( $result = null ) {
|
1372 |
+
$messages = wc_stripe_get_error_messages();
|
1373 |
+
if ( isset( $messages["{$this->id}_generic"] ) ) {
|
1374 |
+
return $messages["{$this->id}_generic"];
|
1375 |
+
}
|
1376 |
+
|
1377 |
+
return null != $result ? $result->get_error_message() : __( 'Cannot process payment', 'woo-stripe-payment' );
|
1378 |
+
}
|
1379 |
+
|
1380 |
+
/**
|
1381 |
+
*
|
1382 |
+
* @since 3.1.2
|
1383 |
+
*/
|
1384 |
+
private function get_payment_section_description() {
|
1385 |
+
return sprintf( __( 'Increase your conversion rate by offering %1$s on your Product and Cart pages, or at the top of the checkout page. <br/><strong>Note:</strong> you can control which products display %s by going to the product edit page.', 'woo-stripe-payment' ), $this->get_method_title() );
|
1386 |
+
}
|
1387 |
+
}
|
includes/abstract/abstract-wc-payment-token-stripe.php
CHANGED
@@ -1,173 +1,178 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
require_once
|
5 |
-
|
6 |
-
/**
|
7 |
-
*
|
8 |
-
* @since 3.0.0
|
9 |
-
* @author PaymentPlugins
|
10 |
-
* @package Stripe/Abstract
|
11 |
-
*
|
12 |
-
*/
|
13 |
-
abstract class WC_Payment_Token_Stripe extends WC_Payment_Token {
|
14 |
-
|
15 |
-
protected $has_expiration = false;
|
16 |
-
|
17 |
-
protected $object_type = 'payment_token';
|
18 |
-
|
19 |
-
/**
|
20 |
-
*
|
21 |
-
* @since 3.1.0
|
22 |
-
* @var string
|
23 |
-
*/
|
24 |
-
protected $stripe_payment_type;
|
25 |
-
|
26 |
-
protected $extra_data = array(
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
*
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
public function
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
$
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
}
|
92 |
-
$data[ '{' . $k . '}' ] = $this->
|
93 |
-
}
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
*
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
return
|
117 |
-
}
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
*
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
'
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
*
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
require_once( WC_STRIPE_PLUGIN_FILE_PATH . 'includes/traits/wc-stripe-payment-token-traits.php' );
|
5 |
+
|
6 |
+
/**
|
7 |
+
*
|
8 |
+
* @since 3.0.0
|
9 |
+
* @author PaymentPlugins
|
10 |
+
* @package Stripe/Abstract
|
11 |
+
*
|
12 |
+
*/
|
13 |
+
abstract class WC_Payment_Token_Stripe extends WC_Payment_Token {
|
14 |
+
|
15 |
+
protected $has_expiration = false;
|
16 |
+
|
17 |
+
protected $object_type = 'payment_token';
|
18 |
+
|
19 |
+
/**
|
20 |
+
*
|
21 |
+
* @since 3.1.0
|
22 |
+
* @var string
|
23 |
+
*/
|
24 |
+
protected $stripe_payment_type;
|
25 |
+
|
26 |
+
protected $extra_data = array(
|
27 |
+
'format' => '',
|
28 |
+
'environment' => 'production',
|
29 |
+
'brand' => '',
|
30 |
+
'customer_id' => '',
|
31 |
+
);
|
32 |
+
|
33 |
+
protected $stripe_data = array();
|
34 |
+
|
35 |
+
/**
|
36 |
+
* The format of the payment method
|
37 |
+
*
|
38 |
+
* @var string
|
39 |
+
*/
|
40 |
+
protected $format = '';
|
41 |
+
|
42 |
+
public function __construct( $token = '' ) {
|
43 |
+
// use reflection to merge all extra data keys.
|
44 |
+
$this->extra_data = array_merge( $this->extra_data, $this->get_stripe_data( $this ) );
|
45 |
+
parent::__construct( $token );
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
*
|
50 |
+
* @param mixed $details
|
51 |
+
*/
|
52 |
+
public abstract function details_to_props( $details );
|
53 |
+
|
54 |
+
public function set_format( $value ) {
|
55 |
+
$this->format = $value;
|
56 |
+
}
|
57 |
+
|
58 |
+
public function set_environment( $value ) {
|
59 |
+
$this->set_prop( 'environment', $value );
|
60 |
+
}
|
61 |
+
|
62 |
+
public function set_customer_id( $value ) {
|
63 |
+
$this->set_prop( 'customer_id', $value );
|
64 |
+
}
|
65 |
+
|
66 |
+
public function get_format() {
|
67 |
+
return $this->format;
|
68 |
+
}
|
69 |
+
|
70 |
+
public function get_environment() {
|
71 |
+
return $this->get_prop( 'environment' );
|
72 |
+
}
|
73 |
+
|
74 |
+
public function get_customer_id() {
|
75 |
+
return $this->get_prop( 'customer_id' );
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Return a human readable representation of the payment method.
|
80 |
+
*/
|
81 |
+
public function get_payment_method_title( $format = '' ) {
|
82 |
+
$format = empty( $format ) ? $this->get_format() : $format;
|
83 |
+
$format = $this->get_formats()[ $format ]['format'];
|
84 |
+
$data = $this->get_props_data();
|
85 |
+
return apply_filters( 'wc_stripe_payment_method_title', str_replace( array_keys( $data ), $data, $format ), $this );
|
86 |
+
}
|
87 |
+
|
88 |
+
public function get_props_data() {
|
89 |
+
$data = array();
|
90 |
+
foreach ( $this->extra_data as $k => $v ) {
|
91 |
+
if ( method_exists( $this, "get_{$k}" ) ) {
|
92 |
+
$data[ '{' . $k . '}' ] = $this->{"get_$k"}();
|
93 |
+
} else {
|
94 |
+
$data[ '{' . $k . '}' ] = $this->get_prop( $k );
|
95 |
+
}
|
96 |
+
}
|
97 |
+
return $data;
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Returns an array of merged attributes comprised of the $stripe_data property.
|
102 |
+
*
|
103 |
+
* @param object $instance
|
104 |
+
*/
|
105 |
+
public function get_stripe_data( $instance ) {
|
106 |
+
$data = array();
|
107 |
+
try {
|
108 |
+
$class = new ReflectionClass( $instance );
|
109 |
+
$props = $class->getDefaultProperties();
|
110 |
+
if ( isset( $props['stripe_data'] ) ) {
|
111 |
+
$data = $props['stripe_data'];
|
112 |
+
}
|
113 |
+
if ( is_subclass_of( get_parent_class( $instance ), 'WC_Payment_Token_Stripe' ) ) {
|
114 |
+
$data = array_merge( $this->get_stripe_data( get_parent_class( $instance ) ), $data );
|
115 |
+
}
|
116 |
+
return $data;
|
117 |
+
} catch ( Exception $e ) {
|
118 |
+
return array();
|
119 |
+
}
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Return a json array of data that represents the object.
|
124 |
+
*
|
125 |
+
* @return array
|
126 |
+
*/
|
127 |
+
public function to_json() {
|
128 |
+
return apply_filters(
|
129 |
+
'wc_stripe_get_' . $this->object_type . '_json',
|
130 |
+
array(
|
131 |
+
'id' => $this->get_id(),
|
132 |
+
'type' => $this->get_type(),
|
133 |
+
'token' => $this->get_token(),
|
134 |
+
'title' => $this->get_payment_method_title(),
|
135 |
+
'gateway' => $this->get_gateway_id(),
|
136 |
+
)
|
137 |
+
);
|
138 |
+
}
|
139 |
+
|
140 |
+
/**
|
141 |
+
* Return formats used by the token to display a human readable title.
|
142 |
+
*/
|
143 |
+
public abstract function get_formats();
|
144 |
+
|
145 |
+
public function get_brand( $context = 'view' ) {
|
146 |
+
return wc_get_credit_card_type_label( $this->get_prop( 'brand', $context ) );
|
147 |
+
}
|
148 |
+
|
149 |
+
public function set_brand( $value ) {
|
150 |
+
$this->set_prop( 'brand', $value );
|
151 |
+
}
|
152 |
+
|
153 |
+
public function get_html_classes() {
|
154 |
+
return '';
|
155 |
+
}
|
156 |
+
|
157 |
+
public function has_expiration() {
|
158 |
+
return $this->has_expiration;
|
159 |
+
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
*
|
163 |
+
* @since 3.1.0
|
164 |
+
*/
|
165 |
+
public abstract function delete_from_stripe();
|
166 |
+
|
167 |
+
/**
|
168 |
+
*
|
169 |
+
* @since 3.1.0
|
170 |
+
*/
|
171 |
+
public abstract function save_payment_method();
|
172 |
+
|
173 |
+
public static function token_exists( $token_id, $user_id ) {
|
174 |
+
global $wpdb;
|
175 |
+
$count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->prefix}woocommerce_payment_tokens WHERE token = %s AND gateway_id LIKE %s AND user_id = %d", $token_id, '%stripe_%', $user_id ) );
|
176 |
+
return $count > 0;
|
177 |
+
}
|
178 |
+
}
|
includes/abstract/abstract-wc-stripe-payment.php
CHANGED
@@ -1,231 +1,238 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
/**
|
5 |
-
*
|
6 |
-
* @author PaymentPlugins
|
7 |
-
* @since 3.1.0
|
8 |
-
*
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
*
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
*
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
*
|
27 |
-
* @param
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
$this->
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
*
|
41 |
-
*
|
42 |
-
* @param
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
*
|
49 |
-
* @param
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
*
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
*
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
*
|
68 |
-
* @param
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
*
|
75 |
-
* @param
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
*
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
*
|
88 |
-
*
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
*
|
95 |
-
* @param
|
96 |
-
* @
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
*
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
*
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
*
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
'
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
/**
|
5 |
+
*
|
6 |
+
* @author PaymentPlugins
|
7 |
+
* @since 3.1.0
|
8 |
+
* @package Stripe/Abstract
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
abstract class WC_Stripe_Payment {
|
12 |
+
|
13 |
+
/**
|
14 |
+
*
|
15 |
+
* @var WC_Payment_Gateway_Stripe
|
16 |
+
*/
|
17 |
+
protected $payment_method;
|
18 |
+
|
19 |
+
/**
|
20 |
+
*
|
21 |
+
* @var WC_Stripe_Gateway
|
22 |
+
*/
|
23 |
+
protected $gateway;
|
24 |
+
|
25 |
+
/**
|
26 |
+
*
|
27 |
+
* @param WC_Payment_Gateway_Stripe $payment_method
|
28 |
+
* @param WC_Stripe_Gateway $gateway
|
29 |
+
*/
|
30 |
+
public function __construct( $payment_method, $gateway ) {
|
31 |
+
$this->payment_method = $payment_method;
|
32 |
+
$this->gateway = $gateway;
|
33 |
+
}
|
34 |
+
|
35 |
+
public function get_gateway() {
|
36 |
+
return $this->gateway;
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Process the payment for the order.
|
41 |
+
*
|
42 |
+
* @param WC_Order $order
|
43 |
+
* @param WC_Payment_Gateway_Stripe $payment_method
|
44 |
+
*/
|
45 |
+
public abstract function process_payment( $order );
|
46 |
+
|
47 |
+
/**
|
48 |
+
*
|
49 |
+
* @param float $amount
|
50 |
+
* @param WC_Order $order
|
51 |
+
*/
|
52 |
+
public abstract function capture_charge( $amount, $order );
|
53 |
+
|
54 |
+
/**
|
55 |
+
*
|
56 |
+
* @param WC_Order $order
|
57 |
+
*/
|
58 |
+
public abstract function void_charge( $order );
|
59 |
+
|
60 |
+
/**
|
61 |
+
*
|
62 |
+
* @param \Stripe\Charge $charge
|
63 |
+
*/
|
64 |
+
public abstract function get_payment_method_from_charge( $charge );
|
65 |
+
|
66 |
+
/**
|
67 |
+
*
|
68 |
+
* @param array $args
|
69 |
+
* @param WC_Order $order
|
70 |
+
*/
|
71 |
+
public abstract function add_order_payment_method( &$args, $order );
|
72 |
+
|
73 |
+
/**
|
74 |
+
*
|
75 |
+
* @param float $amount
|
76 |
+
* @param WC_Order $order
|
77 |
+
*/
|
78 |
+
public abstract function scheduled_subscription_payment( $amount, $order );
|
79 |
+
|
80 |
+
/**
|
81 |
+
*
|
82 |
+
* @param WC_Order $order
|
83 |
+
*/
|
84 |
+
public abstract function process_pre_order_payment( $order );
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Return true if the charge can be voided.
|
88 |
+
*
|
89 |
+
* @param WC_Order $order
|
90 |
+
*/
|
91 |
+
public abstract function can_void_order( $order );
|
92 |
+
|
93 |
+
/**
|
94 |
+
*
|
95 |
+
* @param WC_Order $order
|
96 |
+
* @param float $amount
|
97 |
+
*
|
98 |
+
* @throws Exception
|
99 |
+
*/
|
100 |
+
public function process_refund( $order, $amount = null ) {
|
101 |
+
$charge = $order->get_transaction_id();
|
102 |
+
try {
|
103 |
+
if ( empty( $charge ) ) {
|
104 |
+
throw new Exception( __( 'Transaction Id cannot be empty.', 'woo-stripe-payment' ) );
|
105 |
+
}
|
106 |
+
$result = $this->gateway->refunds->mode( wc_stripe_order_mode( $order ) )->create(
|
107 |
+
array(
|
108 |
+
'charge' => $charge,
|
109 |
+
'amount' => wc_stripe_add_number_precision(
|
110 |
+
$amount,
|
111 |
+
$order->get_currency()
|
112 |
+
),
|
113 |
+
)
|
114 |
+
);
|
115 |
+
if ( ! is_wp_error( $result ) ) {
|
116 |
+
return true;
|
117 |
+
}
|
118 |
+
|
119 |
+
return $result;
|
120 |
+
} catch ( Exception $e ) {
|
121 |
+
return new WP_Error( 'refund-error', $e->getMessage() );
|
122 |
+
}
|
123 |
+
}
|
124 |
+
|
125 |
+
/**
|
126 |
+
* Return a failed order response.
|
127 |
+
*
|
128 |
+
* @return array
|
129 |
+
*/
|
130 |
+
public function order_error() {
|
131 |
+
wc_stripe_set_checkout_error();
|
132 |
+
|
133 |
+
return array( 'result' => 'failure' );
|
134 |
+
}
|
135 |
+
|
136 |
+
/**
|
137 |
+
*
|
138 |
+
* @param array $args
|
139 |
+
* @param WC_Order $order
|
140 |
+
*/
|
141 |
+
public function add_general_order_args( &$args, $order ) {
|
142 |
+
$this->add_order_amount( $args, $order );
|
143 |
+
$this->add_order_currency( $args, $order );
|
144 |
+
$this->add_order_description( $args, $order );
|
145 |
+
$this->add_order_shipping_address( $args, $order );
|
146 |
+
$this->add_order_metadata( $args, $order );
|
147 |
+
$this->add_order_payment_method( $args, $order );
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
*
|
152 |
+
* @param array $args
|
153 |
+
* @param WC_Order $order
|
154 |
+
*/
|
155 |
+
public function add_order_metadata( &$args, $order ) {
|
156 |
+
$meta_data = array(
|
157 |
+
'gateway_id' => $this->payment_method->id,
|
158 |
+
'order_id' => $order->get_order_number(),
|
159 |
+
'user_id' => $order->get_user_id(),
|
160 |
+
'customer_id' => wc_stripe_get_customer_id( $order->get_user_id() ),
|
161 |
+
'ip_address' => $order->get_customer_ip_address(),
|
162 |
+
'user_agent' => isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : 'unavailable',
|
163 |
+
'partner' => 'PaymentPlugins',
|
164 |
+
'created' => time(),
|
165 |
+
);
|
166 |
+
foreach ( $order->get_items( 'line_item' ) as $item ) {
|
167 |
+
/**
|
168 |
+
*
|
169 |
+
* @var WC_Order_Item_Product $item
|
170 |
+
*/
|
171 |
+
$meta_data[ 'product_' . $item->get_product_id() ] = sprintf( '%s x %s', $item->get_name(), $item->get_quantity() );
|
172 |
+
}
|
173 |
+
$args['metadata'] = apply_filters( 'wc_stripe_order_meta_data', $meta_data, $order );
|
174 |
+
}
|
175 |
+
|
176 |
+
/**
|
177 |
+
*
|
178 |
+
* @param array $args
|
179 |
+
* @param WC_Order $order
|
180 |
+
*/
|
181 |
+
public function add_order_description( &$args, $order ) {
|
182 |
+
$args['description'] = sprintf( __( 'Order %1$s from %2$s', 'woo-stripe-payment' ), $order->get_order_number(), get_bloginfo( 'name' ) );
|
183 |
+
}
|
184 |
+
|
185 |
+
/**
|
186 |
+
*
|
187 |
+
* @param array $args
|
188 |
+
* @param WC_Order $order
|
189 |
+
* @param float $amount
|
190 |
+
*/
|
191 |
+
public function add_order_amount( &$args, $order, $amount = null ) {
|
192 |
+
$args['amount'] = wc_stripe_add_number_precision( $amount ? $amount : $order->get_total(), $order->get_currency() );
|
193 |
+
}
|
194 |
+
|
195 |
+
/**
|
196 |
+
*
|
197 |
+
* @param array $args
|
198 |
+
* @param WC_Order $order
|
199 |
+
*/
|
200 |
+
public function add_order_currency( &$args, $order ) {
|
201 |
+
$args['currency'] = $order->get_currency();
|
202 |
+
}
|
203 |
+
|
204 |
+
/**
|
205 |
+
*
|
206 |
+
* @param array $args
|
207 |
+
* @param WC_Order $order
|
208 |
+
*/
|
209 |
+
public function add_order_shipping_address( &$args, $order ) {
|
210 |
+
if ( wc_stripe_order_has_shipping_address( $order ) ) {
|
211 |
+
$args['shipping'] = array(
|
212 |
+
'address' => array(
|
213 |
+
'city' => $order->get_shipping_city(),
|
214 |
+
'country' => $order->get_shipping_country(),
|
215 |
+
'line1' => $order->get_shipping_address_1(),
|
216 |
+
'line2' => $order->get_shipping_address_2(),
|
217 |
+
'postal_code' => $order->get_shipping_postcode(),
|
218 |
+
'state' => $order->get_shipping_state(),
|
219 |
+
),
|
220 |
+
'name' => $this->get_name_from_order( $order, 'shipping' ),
|
221 |
+
);
|
222 |
+
} else {
|
223 |
+
$args['shipping'] = array();
|
224 |
+
}
|
225 |
+
}
|
226 |
+
|
227 |
+
/**
|
228 |
+
*
|
229 |
+
* @param WC_Order $order
|
230 |
+
*/
|
231 |
+
public function get_name_from_order( $order, $type ) {
|
232 |
+
if ( $type === 'billing' ) {
|
233 |
+
return sprintf( '%s %s', $order->get_billing_first_name(), $order->get_billing_last_name() );
|
234 |
+
} else {
|
235 |
+
return sprintf( '%s %s', $order->get_shipping_first_name(), $order->get_shipping_last_name() );
|
236 |
+
}
|
237 |
+
}
|
238 |
+
}
|
includes/abstract/abstract-wc-stripe-rest-controller.php
CHANGED
@@ -1,105 +1,104 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
/**
|
5 |
-
*
|
6 |
-
* @author PaymentPlugins
|
7 |
-
* @package Stripe/Abstract
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
abstract class WC_Stripe_Rest_Controller {
|
11 |
-
|
12 |
-
protected $namespace = '';
|
13 |
-
|
14 |
-
/**
|
15 |
-
*
|
16 |
-
* @var WP_Error
|
17 |
-
*/
|
18 |
-
protected $error = null;
|
19 |
-
|
20 |
-
/**
|
21 |
-
*
|
22 |
-
* @param string $route
|
23 |
-
*/
|
24 |
-
protected function register_authenticated_route($route) {
|
25 |
-
$routes
|
26 |
-
$route
|
27 |
-
$routes[ md5
|
28 |
-
update_option
|
29 |
-
}
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Register all routes that the controller uses.
|
33 |
-
*/
|
34 |
-
abstract public function register_routes();
|
35 |
-
|
36 |
-
public function rest_uri($uri = '') {
|
37 |
-
$rest_uri = wc_stripe
|
38 |
-
if ($uri) {
|
39 |
-
$rest_uri = trailingslashit
|
40 |
-
}
|
41 |
-
return trim
|
42 |
-
}
|
43 |
-
|
44 |
-
public function rest_url($uri = '') {
|
45 |
-
$rest_url = wc_stripe
|
46 |
-
if ($uri) {
|
47 |
-
$rest_url = trailingslashit
|
48 |
-
}
|
49 |
-
return $rest_url;
|
50 |
-
}
|
51 |
-
|
52 |
-
/**
|
53 |
-
*
|
54 |
-
* @param WP_REST_Request $request
|
55 |
-
*/
|
56 |
-
public function admin_permission_check($request) {
|
57 |
-
if (! current_user_can
|
58 |
-
return new WP_Error
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
*
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
}
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
/**
|
5 |
+
*
|
6 |
+
* @author PaymentPlugins
|
7 |
+
* @package Stripe/Abstract
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
abstract class WC_Stripe_Rest_Controller {
|
11 |
+
|
12 |
+
protected $namespace = '';
|
13 |
+
|
14 |
+
/**
|
15 |
+
*
|
16 |
+
* @var WP_Error
|
17 |
+
*/
|
18 |
+
protected $error = null;
|
19 |
+
|
20 |
+
/**
|
21 |
+
*
|
22 |
+
* @param string $route
|
23 |
+
*/
|
24 |
+
protected function register_authenticated_route( $route ) {
|
25 |
+
$routes = get_option( 'wc_stripe_authenticated_routes', array() );
|
26 |
+
$route = '/' . trim( $route, '/' );
|
27 |
+
$routes[ md5( $route ) ] = $route;
|
28 |
+
update_option( 'wc_stripe_authenticated_routes', $routes );
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Register all routes that the controller uses.
|
33 |
+
*/
|
34 |
+
abstract public function register_routes();
|
35 |
+
|
36 |
+
public function rest_uri( $uri = '' ) {
|
37 |
+
$rest_uri = wc_stripe()->rest_api->rest_uri() . ( ! empty( $this->namespace ) ? $this->namespace : '' );
|
38 |
+
if ( $uri ) {
|
39 |
+
$rest_uri = trailingslashit( $rest_uri ) . $uri;
|
40 |
+
}
|
41 |
+
return trim( $rest_uri, '/' );
|
42 |
+
}
|
43 |
+
|
44 |
+
public function rest_url( $uri = '' ) {
|
45 |
+
$rest_url = wc_stripe()->rest_api->rest_url() . ( ! empty( $this->namespace ) ? trailingslashit( $this->namespace ) : '' );
|
46 |
+
if ( $uri ) {
|
47 |
+
$rest_url = trailingslashit( $rest_url ) . $uri;
|
48 |
+
}
|
49 |
+
return $rest_url;
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
*
|
54 |
+
* @param WP_REST_Request $request
|
55 |
+
*/
|
56 |
+
public function admin_permission_check( $request ) {
|
57 |
+
if ( ! current_user_can( 'administrator' ) ) {
|
58 |
+
return new WP_Error( 'permission-error', __( 'You do not have permissions to access this resource.', 'woo-stripe-payment' ), array( 'status' => 403 ) );
|
59 |
+
}
|
60 |
+
|
61 |
+
return true;
|
62 |
+
}
|
63 |
+
|
64 |
+
protected function get_error_messages() {
|
65 |
+
return $this->get_messages( 'error' );
|
66 |
+
}
|
67 |
+
|
68 |
+
protected function get_messages( $types = 'all' ) {
|
69 |
+
$notices = wc_get_notices();
|
70 |
+
if ( $types !== 'all' ) {
|
71 |
+
$types = (array) $types;
|
72 |
+
foreach ( $notices as $type => $notice ) {
|
73 |
+
if ( ! in_array( $type, $types ) ) {
|
74 |
+
unset( $notices[ $type ] );
|
75 |
+
}
|
76 |
+
}
|
77 |
+
}
|
78 |
+
wc_set_notices( $notices );
|
79 |
+
ob_start();
|
80 |
+
$messages = wc_print_notices();
|
81 |
+
return ob_get_clean();
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Allows a status code of 200 to be returned even if there is a validation error.
|
86 |
+
*
|
87 |
+
* @param WP_Error $error
|
88 |
+
*/
|
89 |
+
protected function add_validation_error( $error ) {
|
90 |
+
$data = $error->get_error_data();
|
91 |
+
if ( ! is_array( $data ) ) {
|
92 |
+
$data = array();
|
93 |
+
}
|
94 |
+
$error->add_data( array_merge( $data, array( 'status' => 200 ) ) );
|
95 |
+
$this->error = $error;
|
96 |
+
add_filter(
|
97 |
+
'rest_request_before_callbacks',
|
98 |
+
function ( $response ) {
|
99 |
+
return $this->error ? $this->error : response;
|
100 |
+
}
|
101 |
+
);
|
102 |
+
return $error;
|
103 |
+
}
|
104 |
+
}
|
|
includes/abstract/abstract-wc-stripe-settings.php
CHANGED
@@ -1,29 +1,27 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
/**
|
5 |
-
*
|
6 |
-
* @author PaymentPlugins
|
7 |
-
* @package Stripe/Abstract
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
abstract class WC_Stripe_Settings_API extends WC_Settings_API {
|
11 |
-
|
12 |
-
use WC_Stripe_Settings_Trait;
|
13 |
-
|
14 |
-
public function __construct() {
|
15 |
-
$this->init_form_fields
|
16 |
-
$this->init_settings
|
17 |
-
$this->hooks
|
18 |
-
}
|
19 |
-
|
20 |
-
public function hooks() {
|
21 |
-
add_action
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
}
|
29 |
-
}
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
/**
|
5 |
+
*
|
6 |
+
* @author PaymentPlugins
|
7 |
+
* @package Stripe/Abstract
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
abstract class WC_Stripe_Settings_API extends WC_Settings_API {
|
11 |
+
|
12 |
+
use WC_Stripe_Settings_Trait;
|
13 |
+
|
14 |
+
public function __construct() {
|
15 |
+
$this->init_form_fields();
|
16 |
+
$this->init_settings();
|
17 |
+
$this->hooks();
|
18 |
+
}
|
19 |
+
|
20 |
+
public function hooks() {
|
21 |
+
add_action( 'wc_stripe_localize_' . $this->id . '_settings', array( $this, 'localize_settings' ) );
|
22 |
+
}
|
23 |
+
|
24 |
+
public function localize_settings() {
|
25 |
+
return $this->settings;
|
26 |
+
}
|
27 |
+
}
|
|
|
|
includes/admin/class-wc-stripe-admin-assets.php
CHANGED
@@ -1,99 +1,99 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
/**
|
5 |
-
*
|
6 |
-
* @package Stripe/Admin
|
7 |
-
*/
|
8 |
-
class WC_Stripe_Admin_Assets {
|
9 |
-
|
10 |
-
public function __construct() {
|
11 |
-
add_action
|
12 |
-
|
13 |
-
) );
|
14 |
-
|
15 |
-
add_action
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
)
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
'jquery',
|
36 |
-
|
37 |
-
|
38 |
-
'jquery',
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
)
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
'
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
) );
|
91 |
-
}
|
92 |
-
}
|
93 |
-
|
94 |
-
public static function localize_advanced_scripts() {
|
95 |
-
global $current_section, $wc_stripe_subsection;
|
96 |
-
do_action
|
97 |
-
}
|
98 |
-
}
|
99 |
-
new WC_Stripe_Admin_Assets
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
/**
|
5 |
+
*
|
6 |
+
* @package Stripe/Admin
|
7 |
+
*/
|
8 |
+
class WC_Stripe_Admin_Assets {
|
9 |
+
|
10 |
+
public function __construct() {
|
11 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
|
12 |
+
|
13 |
+
add_action( 'wp_print_scripts', array( __CLASS__, 'localize_scripts' ) );
|
14 |
+
|
15 |
+
add_action( 'admin_footer', array( __CLASS__, 'localize_scripts' ) );
|
16 |
+
add_action( 'wc_stripe_localize_stripe_advanced_settings', array( __CLASS__, 'localize_advanced_scripts' ) );
|
17 |
+
}
|
18 |
+
|
19 |
+
public function enqueue_scripts() {
|
20 |
+
global $current_section, $wc_stripe_subsection;
|
21 |
+
$screen = get_current_screen();
|
22 |
+
$screen_id = $screen ? $screen->id : '';
|
23 |
+
$js_path = wc_stripe()->assets_url() . 'js/';
|
24 |
+
$css_path = wc_stripe()->assets_url() . 'css/';
|
25 |
+
|
26 |
+
wp_register_script( 'wc-stripe-admin-settings', $js_path . 'admin/admin-settings.js', array( 'jquery', 'jquery-blockui' ), wc_stripe()->version, true );
|
27 |
+
wp_register_script( 'wc-stripe-meta-boxes-order', $js_path . 'admin/meta-boxes-order.js', array( 'jquery', 'jquery-blockui' ), wc_stripe()->version, true );
|
28 |
+
wp_register_script( 'wc-stripe-meta-boxes-subscription', $js_path . 'admin/meta-boxes-subscription.js', array( 'jquery', 'jquery-blockui' ), wc_stripe()->version, true );
|
29 |
+
wp_register_script(
|
30 |
+
'wc-stripe-product-data',
|
31 |
+
$js_path . 'admin/meta-boxes-product-data.js',
|
32 |
+
array(
|
33 |
+
'jquery',
|
34 |
+
'jquery-blockui',
|
35 |
+
'jquery-ui-sortable',
|
36 |
+
'jquery-ui-widget',
|
37 |
+
'jquery-ui-core',
|
38 |
+
'jquery-tiptip',
|
39 |
+
),
|
40 |
+
wc_stripe()->version(),
|
41 |
+
true
|
42 |
+
);
|
43 |
+
wp_register_style( 'wc-stripe-admin-style', $css_path . 'admin/admin.css', array(), wc_stripe()->version );
|
44 |
+
|
45 |
+
if ( strpos( $screen_id, 'wc-settings' ) !== false ) {
|
46 |
+
if ( isset( $_REQUEST['section'] ) && preg_match( '/stripe_[\w]*/', $_REQUEST['section'] ) ) {
|
47 |
+
wp_enqueue_script( 'wc-stripe-admin-settings' );
|
48 |
+
wp_enqueue_style( 'wc-stripe-admin-style' );
|
49 |
+
wp_enqueue_script( 'stripe-help-widget', $js_path . 'admin/help-widget.js', array(), wc_stripe()->version(), true );
|
50 |
+
wp_localize_script(
|
51 |
+
'wc-stripe-admin-settings',
|
52 |
+
'wc_stripe_setting_params',
|
53 |
+
array(
|
54 |
+
'routes' => array(
|
55 |
+
'apple_domain' => wc_stripe()->rest_api->settings->rest_url( 'apple-domain' ),
|
56 |
+
'create_webhook' => wc_stripe()->rest_api->settings->rest_url( 'create-webook' ),
|
57 |
+
'connection_test' => wc_stripe()->rest_api->settings->rest_url( 'connection-test' ),
|
58 |
+
),
|
59 |
+
'rest_nonce' => wp_create_nonce( 'wp_rest' ),
|
60 |
+
)
|
61 |
+
);
|
62 |
+
}
|
63 |
+
}
|
64 |
+
if ( $screen_id === 'shop_order' ) {
|
65 |
+
wp_enqueue_style( 'wc-stripe-admin-style' );
|
66 |
+
}
|
67 |
+
if ( $screen_id === 'product' ) {
|
68 |
+
wp_enqueue_script( 'wc-stripe-product-data' );
|
69 |
+
wp_enqueue_style( 'wc-stripe-admin-style' );
|
70 |
+
wp_localize_script(
|
71 |
+
'wc-stripe-product-data',
|
72 |
+
'wc_stripe_product_params',
|
73 |
+
array(
|
74 |
+
'_wpnonce' => wp_create_nonce( 'wp_rest' ),
|
75 |
+
'routes' => array(
|
76 |
+
'enable_gateway' => wc_stripe()->rest_api->product_data->rest_url( 'gateway' ),
|
77 |
+
'save' => wc_stripe()->rest_api->product_data->rest_url( 'save' ),
|
78 |
+
),
|
79 |
+
)
|
80 |
+
);
|
81 |
+
}
|
82 |
+
}
|
83 |
+
|
84 |
+
public static function localize_scripts() {
|
85 |
+
global $current_section, $wc_stripe_subsection;
|
86 |
+
if ( ! empty( $current_section ) ) {
|
87 |
+
$wc_stripe_subsection = isset( $_GET['sub_section'] ) ? sanitize_title( $_GET['sub_section'] ) : '';
|
88 |
+
do_action( 'wc_stripe_localize_' . $current_section . '_settings' );
|
89 |
+
// added for WC 3.0.0 compatability.
|
90 |
+
remove_action( 'admin_footer', array( __CLASS__, 'localize_scripts' ) );
|
91 |
+
}
|
92 |
+
}
|
93 |
+
|
94 |
+
public static function localize_advanced_scripts() {
|
95 |
+
global $current_section, $wc_stripe_subsection;
|
96 |
+
do_action( 'wc_stripe_localize_' . $wc_stripe_subsection . '_settings' );
|
97 |
+
}
|
98 |
+
}
|
99 |
+
new WC_Stripe_Admin_Assets();
|
includes/admin/class-wc-stripe-admin-menus.php
CHANGED
@@ -1,45 +1,39 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
/**
|
5 |
-
*
|
6 |
-
* @since 3.0.0
|
7 |
-
* @package Stripe/Admin
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
class WC_Stripe_Admin_Menus {
|
11 |
-
|
12 |
-
public static function init() {
|
13 |
-
add_action
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
}
|
27 |
-
|
28 |
-
public static function
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
public static function data_migration_page() {
|
42 |
-
include 'views/html-data-migration.php';
|
43 |
-
}
|
44 |
-
}
|
45 |
-
WC_Stripe_Admin_Menus::init ();
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
/**
|
5 |
+
*
|
6 |
+
* @since 3.0.0
|
7 |
+
* @package Stripe/Admin
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
class WC_Stripe_Admin_Menus {
|
11 |
+
|
12 |
+
public static function init() {
|
13 |
+
add_action( 'admin_menu', array( __CLASS__, 'admin_menu' ), 10 );
|
14 |
+
add_action( 'admin_menu', array( __CLASS__, 'sub_menu' ), 20 );
|
15 |
+
add_action( 'admin_head', array( __CLASS__, 'remove_submenu' ) );
|
16 |
+
}
|
17 |
+
|
18 |
+
public static function admin_menu() {
|
19 |
+
add_menu_page( __( 'Stripe Gateway', 'woo-stripe-payment' ), __( 'Stripe Gateway', 'woo-stripe-payment' ), 'manage_woocommerce', 'wc_stripe', null, null, '7.458' );
|
20 |
+
}
|
21 |
+
|
22 |
+
public static function sub_menu() {
|
23 |
+
add_submenu_page( 'wc_stripe', __( 'Settings', 'woo-stripe-payment' ), __( 'Settings', 'woo-stripe-payment' ), 'manage_woocommerce', admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=stripe_api' ) );
|
24 |
+
add_submenu_page( 'wc_stripe', __( 'Logs', 'woo-stripe-payment' ), __( 'Logs', 'woo-stripe-payment' ), 'manage_woocommerce', admin_url( 'admin.php?page=wc-status&tab=logs' ) );
|
25 |
+
add_submenu_page( 'wc_stripe', __( 'Documentation', 'woo-stripe-payment' ), __( 'Documentation', 'woo-stripe-payment' ), 'manage_woocommerce', 'https://docs.paymentplugins.com/wc-stripe/config' );
|
26 |
+
}
|
27 |
+
|
28 |
+
public static function remove_submenu() {
|
29 |
+
global $submenu;
|
30 |
+
if ( isset( $submenu['wc_stripe'] ) ) {
|
31 |
+
unset( $submenu['wc_stripe'][0] );
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
public static function data_migration_page() {
|
36 |
+
include 'views/html-data-migration.php';
|
37 |
+
}
|
38 |
+
}
|
39 |
+
WC_Stripe_Admin_Menus::init();
|
|
|
|
|
|
|
|
|
|
|
|
includes/admin/class-wc-stripe-admin-notices.php
CHANGED
@@ -1,59 +1,67 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace PaymentPlugins;
|
4 |
-
|
5 |
-
defined
|
6 |
-
|
7 |
-
/**
|
8 |
-
*
|
9 |
-
* @since 3.1.0
|
10 |
-
* @author PaymentPlugins
|
11 |
-
*
|
12 |
-
*/
|
13 |
-
class WC_Stripe_Admin_Notices {
|
14 |
-
|
15 |
-
public static function init() {
|
16 |
-
add_action
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
}
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace PaymentPlugins;
|
4 |
+
|
5 |
+
defined( 'ABSPATH' ) || exit();
|
6 |
+
|
7 |
+
/**
|
8 |
+
*
|
9 |
+
* @since 3.1.0
|
10 |
+
* @author PaymentPlugins
|
11 |
+
*
|
12 |
+
*/
|
13 |
+
class WC_Stripe_Admin_Notices {
|
14 |
+
|
15 |
+
public static function init() {
|
16 |
+
add_action( 'admin_notices', array( __CLASS__, 'notices' ) );
|
17 |
+
}
|
18 |
+
|
19 |
+
public static function notices() {
|
20 |
+
$messages = array();
|
21 |
+
foreach ( static::get_notices() as $key => $notice ) {
|
22 |
+
if ( $notice['callback']() ) {
|
23 |
+
$screen = get_current_screen();
|
24 |
+
$screen_id = $screen ? $screen->id : '';
|
25 |
+
ob_start();
|
26 |
+
echo '<div class="notice notice-info woocommerce-message"><p>' . $notice['message']() . '</p></div>';
|
27 |
+
$message = ob_get_clean();
|
28 |
+
if ( strstr( $screen_id, 'wc-settings' ) ) {
|
29 |
+
$messages[] = $message;
|
30 |
+
} else {
|
31 |
+
echo $message;
|
32 |
+
}
|
33 |
+
}
|
34 |
+
}
|
35 |
+
// in WC 4.0 admin notices don't show on the WC Settings pages so adding this workaround.
|
36 |
+
if ( $messages ) {
|
37 |
+
wp_localize_script( 'wc-stripe-admin-settings', 'wc_stripe_admin_notices', $messages );
|
38 |
+
}
|
39 |
+
}
|
40 |
+
|
41 |
+
public static function get_notices() {
|
42 |
+
return array(
|
43 |
+
'connect_notice' => array(
|
44 |
+
'callback' => function () {
|
45 |
+
return ( ! isset( $_GET['_stripe_connect_nonce'] ) &&
|
46 |
+
( ! wc_stripe()->api_settings->get_option( 'account_id' ) && get_option( 'wc_stripe_connect_notice', 'no' ) == 'yes' ) );
|
47 |
+
},
|
48 |
+
'message' => function () {
|
49 |
+
wp_enqueue_style( 'wc-stripe-styles', wc_stripe()->assets_url( 'css/admin/admin.css' ), array(), wc_stripe()->version() );
|
50 |
+
return sprintf(
|
51 |
+
__(
|
52 |
+
'At Stripe\'s request we have updated how the Stripe for WooCommerce
|
53 |
+
plugin integrates with Stripe. This new integration offers even more security and
|
54 |
+
Stripe is requesting that all merchants switch. %1$sUpdate Integration%2$s',
|
55 |
+
'woo-stripe-payment'
|
56 |
+
),
|
57 |
+
' <a href = "' .
|
58 |
+
wc_stripe()->api_settings->get_connect_url() . '" class = "stripe-connect light-blue do-stripe-connect" > < span > ',
|
59 |
+
' < / span > < / a > '
|
60 |
+
);
|
61 |
+
},
|
62 |
+
),
|
63 |
+
);
|
64 |
+
}
|
65 |
+
}
|
66 |
+
\PaymentPlugins\WC_Stripe_Admin_Notices::init();
|
67 |
+
|
includes/admin/class-wc-stripe-admin-settings.php
CHANGED
@@ -1,104 +1,89 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
/**
|
5 |
-
*
|
6 |
-
* @package Stripe/Admin
|
7 |
-
* @author User
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
class WC_Stripe_Admin_Settings {
|
11 |
-
|
12 |
-
public static function init() {
|
13 |
-
add_action
|
14 |
-
|
15 |
-
) );
|
16 |
-
add_action
|
17 |
-
|
18 |
-
) );
|
19 |
-
add_action
|
20 |
-
|
21 |
-
) );
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
) );
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
}
|
46 |
-
|
47 |
-
public static function
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
}
|
64 |
-
|
65 |
-
public static function
|
66 |
-
global $current_section, $wc_stripe_subsection;
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
'title' => __ ( 'Stripe Email Options', 'woo-stripe-payment' )
|
91 |
-
];
|
92 |
-
$settings[] = [ 'type' => 'checkbox',
|
93 |
-
'title' => __ ( 'Email Receipt', 'woo-stripe-payment' ),
|
94 |
-
'id' => 'woocommerce_stripe_email_receipt',
|
95 |
-
'autoload' => false,
|
96 |
-
'desc' => __ ( 'If enabled, an email receipt will be sent to the customer by Stripe when the order is processed.', 'woo-stripe-payment' )
|
97 |
-
];
|
98 |
-
$settings[] = [ 'type' => 'sectionend',
|
99 |
-
'id' => 'stripe_email'
|
100 |
-
];
|
101 |
-
return $settings;
|
102 |
-
}
|
103 |
-
}
|
104 |
-
WC_Stripe_Admin_Settings::init ();
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
/**
|
5 |
+
*
|
6 |
+
* @package Stripe/Admin
|
7 |
+
* @author User
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
class WC_Stripe_Admin_Settings {
|
11 |
+
|
12 |
+
public static function init() {
|
13 |
+
add_action( 'woocommerce_settings_checkout', array( __CLASS__, 'output' ) );
|
14 |
+
add_action( 'woocommerce_settings_checkout_stripe_advanced', array( __CLASS__, 'output_advanced_settings' ) );
|
15 |
+
add_action( 'woocommerce_settings_checkout_stripe_local_gateways', array( __CLASS__, 'output_local_gateways' ) );
|
16 |
+
add_action( 'woocommerce_update_options_checkout_stripe_local_gateways', array( __CLASS__, 'save_local_gateway' ) );
|
17 |
+
add_filter( 'wc_stripe_settings_nav_tabs', array( __CLASS__, 'admin_settings_tabs' ), 20 );
|
18 |
+
add_action( 'wc_stripe_settings_before_options_stripe_advanced', array( __CLASS__, 'before_options' ) );
|
19 |
+
add_action( 'wc_stripe_settings_before_options_stripe_local_gateways', array( __CLASS__, 'before_options' ) );
|
20 |
+
add_action( 'woocommerce_update_options_checkout', array( __CLASS__, 'deprecated_save' ) );
|
21 |
+
add_filter( 'woocommerce_get_settings_email', array( __CLASS__, 'get_email_settings' ) );
|
22 |
+
}
|
23 |
+
|
24 |
+
public static function output() {
|
25 |
+
global $current_section;
|
26 |
+
do_action( 'woocommerce_settings_checkout_' . $current_section );
|
27 |
+
}
|
28 |
+
|
29 |
+
public static function output_advanced_settings() {
|
30 |
+
self::output_custom_section( '' );
|
31 |
+
}
|
32 |
+
|
33 |
+
public static function output_local_gateways() {
|
34 |
+
self::output_custom_section( 'stripe_ideal' );
|
35 |
+
}
|
36 |
+
|
37 |
+
public static function output_custom_section( $sub_section = '' ) {
|
38 |
+
global $current_section, $wc_stripe_subsection;
|
39 |
+
$wc_stripe_subsection = isset( $_GET['stripe_sub_section'] ) ? sanitize_title( $_GET['stripe_sub_section'] ) : $sub_section;
|
40 |
+
do_action( 'woocommerce_settings_checkout_' . $current_section . '_' . $wc_stripe_subsection );
|
41 |
+
}
|
42 |
+
|
43 |
+
public static function save_local_gateway() {
|
44 |
+
self::save_custom_section( 'stripe_ideal' );
|
45 |
+
}
|
46 |
+
|
47 |
+
public static function save_custom_section( $sub_section = '' ) {
|
48 |
+
global $current_section, $wc_stripe_subsection;
|
49 |
+
$wc_stripe_subsection = isset( $_GET['stripe_sub_section'] ) ? sanitize_title( $_GET['stripe_sub_section'] ) : $sub_section;
|
50 |
+
do_action( 'woocommerce_update_options_checkout_' . $current_section . '_' . $wc_stripe_subsection );
|
51 |
+
}
|
52 |
+
|
53 |
+
public static function deprecated_save() {
|
54 |
+
global $current_section;
|
55 |
+
if ( $current_section && ! did_action( 'woocommerce_update_options_checkout_' . $current_section ) ) {
|
56 |
+
do_action( 'woocommerce_update_options_checkout_' . $current_section );
|
57 |
+
}
|
58 |
+
}
|
59 |
+
|
60 |
+
public static function admin_settings_tabs( $tabs ) {
|
61 |
+
$tabs['stripe_local_gateways'] = __( 'Local Gateways', 'woo-stripe-payment' );
|
62 |
+
return $tabs;
|
63 |
+
}
|
64 |
+
|
65 |
+
public static function before_options() {
|
66 |
+
global $current_section, $wc_stripe_subsection;
|
67 |
+
do_action( 'wc_stripe_settings_before_options_' . $current_section . '_' . $wc_stripe_subsection );
|
68 |
+
}
|
69 |
+
|
70 |
+
public static function get_email_settings( $settings ) {
|
71 |
+
$settings[] = array(
|
72 |
+
'type' => 'title',
|
73 |
+
'title' => __( 'Stripe Email Options', 'woo-stripe-payment' ),
|
74 |
+
);
|
75 |
+
$settings[] = array(
|
76 |
+
'type' => 'checkbox',
|
77 |
+
'title' => __( 'Email Receipt', 'woo-stripe-payment' ),
|
78 |
+
'id' => 'woocommerce_stripe_email_receipt',
|
79 |
+
'autoload' => false,
|
80 |
+
'desc' => __( 'If enabled, an email receipt will be sent to the customer by Stripe when the order is processed.', 'woo-stripe-payment' ),
|
81 |
+
);
|
82 |
+
$settings[] = array(
|
83 |
+
'type' => 'sectionend',
|
84 |
+
'id' => 'stripe_email',
|
85 |
+
);
|
86 |
+
return $settings;
|
87 |
+
}
|
88 |
+
}
|
89 |
+
WC_Stripe_Admin_Settings::init();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/admin/class-wc-stripe-admin-user-edit.php
CHANGED
@@ -1,114 +1,109 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
/**
|
5 |
-
*
|
6 |
-
* @since 3.0.0
|
7 |
-
* @package Stripe/Admin
|
8 |
-
* @author PaymentPlugins
|
9 |
-
*
|
10 |
-
*/
|
11 |
-
class WC_Stripe_Admin_User_Edit {
|
12 |
-
|
13 |
-
public static function init() {
|
14 |
-
add_action
|
15 |
-
|
16 |
-
) );
|
17 |
-
add_action
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
);
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
}
|
111 |
-
}
|
112 |
-
}
|
113 |
-
}
|
114 |
-
WC_Stripe_Admin_User_Edit::init ();
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
/**
|
5 |
+
*
|
6 |
+
* @since 3.0.0
|
7 |
+
* @package Stripe/Admin
|
8 |
+
* @author PaymentPlugins
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
class WC_Stripe_Admin_User_Edit {
|
12 |
+
|
13 |
+
public static function init() {
|
14 |
+
add_action( 'edit_user_profile', array( __CLASS__, 'output' ) );
|
15 |
+
add_action( 'show_user_profile', array( __CLASS__, 'output' ) );
|
16 |
+
add_action( 'edit_user_profile_update', array( __CLASS__, 'save' ) );
|
17 |
+
add_action( 'personal_options_update', array( __CLASS__, 'save' ) );
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
*
|
22 |
+
* @param WP_User $user
|
23 |
+
*/
|
24 |
+
public static function output( $user ) {
|
25 |
+
// enquue scripts
|
26 |
+
wp_enqueue_style( 'wc-stripe-admin-style' );
|
27 |
+
|
28 |
+
remove_filter( 'woocommerce_get_customer_payment_tokens', 'wc_stripe_get_customer_payment_tokens' );
|
29 |
+
// get payment methods for all environments.
|
30 |
+
$tokens = WC_Payment_Tokens::get_customer_tokens( $user->ID );
|
31 |
+
$payment_methods = array(
|
32 |
+
'live' => array(),
|
33 |
+
'test' => array(),
|
34 |
+
);
|
35 |
+
foreach ( $tokens as $token ) {
|
36 |
+
if ( $token instanceof WC_Payment_Token_Stripe ) {
|
37 |
+
if ( 'live' === $token->get_environment() ) {
|
38 |
+
$payment_methods['live'][] = $token;
|
39 |
+
} else {
|
40 |
+
$payment_methods['test'][] = $token;
|
41 |
+
}
|
42 |
+
}
|
43 |
+
}
|
44 |
+
include wc_stripe()->plugin_path() . 'includes/admin/views/html-user-profile.php';
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
*
|
49 |
+
* @param int $user_id
|
50 |
+
*/
|
51 |
+
public static function save( $user_id ) {
|
52 |
+
$modes = array( 'test', 'live' );
|
53 |
+
if ( isset( $_POST['wc_stripe_live_id'] ) ) {
|
54 |
+
$old_live_id = wc_stripe_get_customer_id( $user_id, 'live' );
|
55 |
+
wc_stripe_save_customer( wc_clean( $_POST['wc_stripe_live_id'] ), $user_id, 'live' );
|
56 |
+
}
|
57 |
+
if ( isset( $_POST['wc_stripe_test_id'] ) ) {
|
58 |
+
$old_test_id = wc_stripe_get_customer_id( $user_id, 'test' );
|
59 |
+
wc_stripe_save_customer( wc_clean( $_POST['wc_stripe_test_id'] ), $user_id, 'test' );
|
60 |
+
}
|
61 |
+
|
62 |
+
// check if admin want's to delete any payment methods
|
63 |
+
foreach ( $modes as $mode ) {
|
64 |
+
if ( isset( $_POST[ $mode . '_payment_method_actions' ] ) ) {
|
65 |
+
switch ( wc_clean( $_POST[ $mode . '_payment_method_actions' ] ) ) {
|
66 |
+
case 'delete':
|
67 |
+
if ( isset( $_POST['payment_methods'], $_POST['payment_methods'][ $mode ] ) ) {
|
68 |
+
$tokens = $_POST['payment_methods'][ $mode ];
|
69 |
+
foreach ( $tokens as $token_id ) {
|
70 |
+
WC_Payment_Tokens::delete( absint( $token_id ) );
|
71 |
+
}
|
72 |
+
}
|
73 |
+
break;
|
74 |
+
}
|
75 |
+
}
|
76 |
+
}
|
77 |
+
|
78 |
+
$changes = array(
|
79 |
+
'live' => $old_live_id !== wc_stripe_get_customer_id( $user_id, 'live' ),
|
80 |
+
'test' => $old_test_id !== wc_stripe_get_customer_id( $user_id, 'test' ),
|
81 |
+
);
|
82 |
+
$gateway = WC_Stripe_Gateway::load();
|
83 |
+
|
84 |
+
// this will prevent the payment method from being deleted in Stripe. We only want to remove the tokens
|
85 |
+
// from the WC tables.
|
86 |
+
remove_action( 'woocommerce_payment_token_deleted', 'wc_stripe_woocommerce_payment_token_deleted', 10 );
|
87 |
+
|
88 |
+
// want results to return tokens for all modes
|
89 |
+
remove_action( 'woocommerce_get_customer_payment_tokens', 'wc_stripe_get_customer_payment_tokens' );
|
90 |
+
|
91 |
+
// if the value has changed, then remove old payment methods and import new ones.
|
92 |
+
foreach ( $changes as $mode => $change ) {
|
93 |
+
if ( $change ) {
|
94 |
+
// Delete all current payment methods in WC then save new ones.
|
95 |
+
$tokens = WC_Payment_Tokens::get_customer_tokens( $user_id );
|
96 |
+
foreach ( $tokens as $token ) {
|
97 |
+
if ( $token instanceof WC_Payment_Token_Stripe ) {
|
98 |
+
if ( $mode === $token->get_environment() ) {
|
99 |
+
WC_Payment_Tokens::delete( $token->get_id() );
|
100 |
+
}
|
101 |
+
}
|
102 |
+
}
|
103 |
+
// import payment methods from Stripe.
|
104 |
+
WC_Stripe_Customer_Manager::sync_payment_methods( wc_stripe_get_customer_id( $user_id, $mode ), $user_id, $mode );
|
105 |
+
}
|
106 |
+
}
|
107 |
+
}
|
108 |
+
}
|
109 |
+
WC_Stripe_Admin_User_Edit::init();
|
|
|
|
|
|
|
|
|
|
includes/admin/meta-boxes/class-wc-stripe-admin-meta-box-product-data.php
CHANGED
@@ -1,97 +1,92 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace PaymentPlugins;
|
4 |
-
|
5 |
-
class WC_Stripe_Admin_Meta_Box_Product_Data {
|
6 |
-
|
7 |
-
private static $_gateways =
|
8 |
-
|
9 |
-
private static $_options =
|
10 |
-
|
11 |
-
public static function init() {
|
12 |
-
add_filter
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
$tabs
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
$
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
$
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
}
|
94 |
-
$product->update_meta_data ( \WC_Stripe_Constants::PRODUCT_GATEWAY_ORDER, $order );
|
95 |
-
}
|
96 |
-
}
|
97 |
-
\PaymentPlugins\WC_Stripe_Admin_Meta_Box_Product_Data::init ();
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace PaymentPlugins;
|
4 |
+
|
5 |
+
class WC_Stripe_Admin_Meta_Box_Product_Data {
|
6 |
+
|
7 |
+
private static $_gateways = array();
|
8 |
+
|
9 |
+
private static $_options = array();
|
10 |
+
|
11 |
+
public static function init() {
|
12 |
+
add_filter( 'woocommerce_product_data_tabs', array( __CLASS__, 'product_data_tabs' ) );
|
13 |
+
add_action( 'woocommerce_product_data_panels', array( __CLASS__, 'output_panel' ) );
|
14 |
+
add_action( 'woocommerce_admin_process_product_object', array( __CLASS__, 'save' ) );
|
15 |
+
}
|
16 |
+
|
17 |
+
public static function product_data_tabs( $tabs ) {
|
18 |
+
$tabs['stripe'] = array(
|
19 |
+
'label' => __( 'Stripe Settings', 'woo-stripe-payment' ),
|
20 |
+
'target' => 'stripe_product_data',
|
21 |
+
'class' => array(),
|
22 |
+
'priority' => 100,
|
23 |
+
);
|
24 |
+
return $tabs;
|
25 |
+
}
|
26 |
+
|
27 |
+
public static function output_panel() {
|
28 |
+
global $product_object;
|
29 |
+
|
30 |
+
self::init_gateways( $product_object );
|
31 |
+
|
32 |
+
include 'views/html-product-data.php';
|
33 |
+
}
|
34 |
+
|
35 |
+
private static function init_gateways( $product ) {
|
36 |
+
$order = $product->get_meta( \WC_Stripe_Constants::PRODUCT_GATEWAY_ORDER );
|
37 |
+
$order = ! $order ? array() : $order;
|
38 |
+
foreach ( WC()->payment_gateways()->payment_gateways() as $gateway ) {
|
39 |
+
if ( $gateway->supports( 'wc_stripe_product_checkout' ) ) {
|
40 |
+
if ( isset( $order[ $gateway->id ] ) ) {
|
41 |
+
self::$_gateways[ $order[ $gateway->id ] ] = $gateway;
|
42 |
+
} else {
|
43 |
+
self::$_gateways[] = $gateway;
|
44 |
+
}
|
45 |
+
self::$_options[ $gateway->id ] = new \WC_Stripe_Product_Gateway_Option( $product, $gateway );
|
46 |
+
}
|
47 |
+
}
|
48 |
+
ksort( self::$_gateways );
|
49 |
+
}
|
50 |
+
|
51 |
+
private static function get_product_option( $gateway_id ) {
|
52 |
+
return self::$_options[ $gateway_id ];
|
53 |
+
}
|
54 |
+
|
55 |
+
private static function get_payment_gateways() {
|
56 |
+
foreach ( self::$_gateways as $gateway ) {
|
57 |
+
$gateways[ $gateway->id ] = $gateway;
|
58 |
+
}
|
59 |
+
return $gateways;
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
*
|
64 |
+
* @param \WC_Product $product
|
65 |
+
*/
|
66 |
+
public static function save( $product ) {
|
67 |
+
// only update the settings if something has been changed.
|
68 |
+
if ( empty( $_POST['wc_stripe_update_product'] ) ) {
|
69 |
+
return;
|
70 |
+
}
|
71 |
+
$loop = 0;
|
72 |
+
$order = array();
|
73 |
+
self::init_gateways( $product );
|
74 |
+
$payment_gateways = self::get_payment_gateways();
|
75 |
+
|
76 |
+
if ( isset( $_POST['stripe_gateway_order'] ) ) {
|
77 |
+
foreach ( $_POST['stripe_gateway_order'] as $i => $gateway ) {
|
78 |
+
$order[ $gateway ] = $loop;
|
79 |
+
if ( isset( $_POST['stripe_capture_type'] ) ) {
|
80 |
+
self::get_product_option( $gateway )->set_option( 'charge_type', $_POST['stripe_capture_type'][ $i ] );
|
81 |
+
self::get_product_option( $gateway )->save();
|
82 |
+
}
|
83 |
+
$loop++;
|
84 |
+
}
|
85 |
+
}
|
86 |
+
if ( isset( $_POST['_stripe_button_position'] ) ) {
|
87 |
+
$product->update_meta_data( '_stripe_button_position', wc_clean( $_POST['_stripe_button_position'] ) );
|
88 |
+
}
|
89 |
+
$product->update_meta_data( \WC_Stripe_Constants::PRODUCT_GATEWAY_ORDER, $order );
|
90 |
+
}
|
91 |
+
}
|
92 |
+
\PaymentPlugins\WC_Stripe_Admin_Meta_Box_Product_Data::init();
|
|
|
|
|
|
|
|
|
|
includes/admin/meta-boxes/class-wc-stripe-admin-order-metaboxes.php
CHANGED
@@ -1,105 +1,104 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
/**
|
5 |
-
*
|
6 |
-
* @package Stripe/Admin
|
7 |
-
* @author PaymentPlugins
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
class WC_Stripe_Admin_Order_Metaboxes {
|
11 |
-
|
12 |
-
public static function init() {
|
13 |
-
add_action
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
*
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
)
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
) );
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
WC_Stripe_Admin_Order_Metaboxes::init ();
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
/**
|
5 |
+
*
|
6 |
+
* @package Stripe/Admin
|
7 |
+
* @author PaymentPlugins
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
class WC_Stripe_Admin_Order_Metaboxes {
|
11 |
+
|
12 |
+
public static function init() {
|
13 |
+
add_action( 'add_meta_boxes', array( __CLASS__, 'add_meta_boxes' ), 10, 2 );
|
14 |
+
}
|
15 |
+
|
16 |
+
/**
|
17 |
+
*
|
18 |
+
* @param string $post_type
|
19 |
+
* @param WP_Post $post
|
20 |
+
*/
|
21 |
+
public static function add_meta_boxes( $post_type, $post ) {
|
22 |
+
// only add meta box if shop_order and Stripe gateway was used.
|
23 |
+
if ( $post_type !== 'shop_order' ) {
|
24 |
+
return;
|
25 |
+
}
|
26 |
+
|
27 |
+
add_action( 'woocommerce_admin_order_data_after_order_details', array( __CLASS__, 'pay_order_section' ) );
|
28 |
+
|
29 |
+
$order = wc_get_order( $post->ID );
|
30 |
+
$payment_method = $order->get_payment_method();
|
31 |
+
if ( $payment_method ) {
|
32 |
+
$gateways = WC()->payment_gateways()->payment_gateways();
|
33 |
+
if ( isset( $gateways[ $payment_method ] ) ) {
|
34 |
+
$gateway = WC()->payment_gateways()->payment_gateways()[ $payment_method ];
|
35 |
+
if ( $gateway instanceof WC_Payment_Gateway_Stripe ) {
|
36 |
+
add_action( 'woocommerce_admin_order_data_after_billing_address', array( __CLASS__, 'charge_data_view' ) );
|
37 |
+
}
|
38 |
+
}
|
39 |
+
}
|
40 |
+
self::enqueue_scripts();
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
*
|
45 |
+
* @param WC_Order $order
|
46 |
+
*/
|
47 |
+
public static function charge_data_view( $order ) {
|
48 |
+
if ( ( $transaction_id = $order->get_transaction_id() ) ) {
|
49 |
+
include 'views/html-order-charge-data.php';
|
50 |
+
}
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
*
|
55 |
+
* @param WC_Order $order
|
56 |
+
*/
|
57 |
+
public static function pay_order_section( $order ) {
|
58 |
+
if ( $order->get_type() === 'shop_order' && $order->has_status( array( 'pending', 'auto-draft' ) ) ) {
|
59 |
+
include 'views/html-order-pay.php';
|
60 |
+
$payment_methods = array();
|
61 |
+
foreach ( WC()->payment_gateways()->payment_gateways() as $gateway ) {
|
62 |
+
if ( $gateway instanceof WC_Payment_Gateway_Stripe ) {
|
63 |
+
$payment_methods = array_merge( $payment_methods, WC_Payment_Tokens::get_customer_tokens( $order->get_user_id(), $gateway->id ) );
|
64 |
+
}
|
65 |
+
}
|
66 |
+
wp_enqueue_script( 'wc-stripe-elements', 'https://js.stripe.com/v3/', array(), wc_stripe()->version, true );
|
67 |
+
wp_localize_script(
|
68 |
+
'wc-stripe-elements',
|
69 |
+
'wc_stripe_order_pay_params',
|
70 |
+
array(
|
71 |
+
'api_key' => wc_stripe_get_publishable_key(),
|
72 |
+
'payment_methods' => array_map(
|
73 |
+
function ( $payment_method ) {
|
74 |
+
return $payment_method->to_json();
|
75 |
+
},
|
76 |
+
$payment_methods
|
77 |
+
),
|
78 |
+
'order_status' => $order->get_status(),
|
79 |
+
)
|
80 |
+
);
|
81 |
+
wp_enqueue_script( 'wc-stripe-admin-modals', wc_stripe()->assets_url( 'js/admin/modals.js' ), array( 'wc-backbone-modal', 'jquery-blockui' ), wc_stripe()->version, true );
|
82 |
+
}
|
83 |
+
}
|
84 |
+
|
85 |
+
public static function enqueue_scripts() {
|
86 |
+
wp_enqueue_script( 'wc-stripe-order-metabox', wc_stripe()->assets_url( 'js/admin/meta-boxes-order.js' ), array( 'jquery', 'jquery-blockui' ), wc_stripe()->version(), true );
|
87 |
+
|
88 |
+
wp_localize_script(
|
89 |
+
'wc-stripe-order-metabox',
|
90 |
+
'wc_stripe_order_metabox_params',
|
91 |
+
array(
|
92 |
+
'_wpnonce' => wp_create_nonce( 'wp_rest' ),
|
93 |
+
'routes' => array(
|
94 |
+
'charge_view' => wc_stripe()->rest_api->order_actions->rest_url( 'charge-view' ),
|
95 |
+
'capture' => wc_stripe()->rest_api->order_actions->rest_url( 'capture' ),
|
96 |
+
'void' => wc_stripe()->rest_api->order_actions->rest_url( 'void' ),
|
97 |
+
'pay' => wc_stripe()->rest_api->order_actions->rest_url( 'pay' ),
|
98 |
+
'payment_methods' => wc_stripe()->rest_api->order_actions->rest_url( 'customer-payment-methods' ),
|
99 |
+
),
|
100 |
+
)
|
101 |
+
);
|
102 |
+
}
|
103 |
+
}
|
104 |
+
WC_Stripe_Admin_Order_Metaboxes::init();
|
|
includes/admin/meta-boxes/views/html-charge-data-subview.php
CHANGED
@@ -1,88 +1,90 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @var \Stripe\Charge $charge
|
4 |
-
*/
|
5 |
-
?>
|
6 |
-
<?php if(
|
7 |
-
<?php if(($charge->status === 'pending' &&
|
8 |
-
<div class="charge-actions">
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
</div>
|
18 |
-
<?php endif
|
19 |
-
<?php endif
|
20 |
-
<div class="data-container">
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
<?php $charge->livemode ? _e('Live', 'woo-stripe-payment') : _e('Test', 'wo0o-stripe')?>
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
<?php echo $charge->status
|
30 |
-
|
31 |
-
<?php if(($payment_intent_id = $order->get_meta('_payment_intent_id', true)))
|
32 |
-
|
33 |
-
|
34 |
-
<?php echo $payment_intent_id?>
|
35 |
-
|
36 |
-
<?php endif
|
37 |
-
<?php if(isset($charge->customer))
|
38 |
-
|
39 |
-
|
40 |
-
<?php echo $charge->customer?>
|
41 |
-
|
42 |
-
<?php endif
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
<?php echo $order->get_payment_method_title()?>
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
<?php echo $charge->payment_method_details->type
|
53 |
-
|
54 |
-
<?php if(isset($charge->payment_method_details->card))
|
55 |
-
|
56 |
-
|
57 |
-
<?php printf('%02d / %s', $charge->payment_method_details->card->exp_month, $charge->payment_method_details->card->exp_year)?>
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
<?php echo $charge->payment_method_details->card->fingerprint
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
<?php echo $charge->payment_method_details->card->checks->cvc_check
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
<?php echo $charge->payment_method_details->card->checks->address_postal_code_check
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
<?php echo $charge->payment_method_details->card->checks->address_line1_check
|
74 |
-
|
75 |
-
<?php endif
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
</div>
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @var \Stripe\Charge $charge
|
4 |
+
*/
|
5 |
+
?>
|
6 |
+
<?php if ( ! $order->has_status( 'cancelled' ) ) : ?>
|
7 |
+
<?php if ( ( $charge->status === 'pending' && ! $charge->captured ) || ( $charge->status === 'succeeded' && ! $charge->captured ) ) : ?>
|
8 |
+
<div class="charge-actions">
|
9 |
+
<h2><?php _e( 'Actions', 'woo-stripe-payment' ); ?></h2>
|
10 |
+
<div>
|
11 |
+
<input type="text" class="wc_input_price" name="capture_amount"
|
12 |
+
value="<?php echo $order->get_total(); ?>"
|
13 |
+
placeholder="<?php _e( 'capture amount', 'woo-stripe-payment' ); ?>"/>
|
14 |
+
<button class="button button-secondary do-api-capture"><?php _e( 'Capture', 'woo-stripe-payment' ); ?></button>
|
15 |
+
<button class="button button-secondary do-api-cancel"><?php _e( 'Void', 'woo-stripe-payment' ); ?></button>
|
16 |
+
</div>
|
17 |
+
</div>
|
18 |
+
<?php endif; ?>
|
19 |
+
<?php endif; ?>
|
20 |
+
<div class="data-container">
|
21 |
+
<div class="charge-data column-6">
|
22 |
+
<h3><?php _e( 'Charge Data', 'woo-stripe-payment' ); ?></h3>
|
23 |
+
<div class="metadata">
|
24 |
+
<label><?php _e( 'Mode', 'woo-stripe-payment' ); ?></label>:
|
25 |
+
<?php $charge->livemode ? _e( 'Live', 'woo-stripe-payment' ) : _e( 'Test', 'wo0o-stripe' ); ?>
|
26 |
+
</div>
|
27 |
+
<div class="metadata">
|
28 |
+
<label><?php _e( 'Status', 'woo-stripe-payment' ); ?></label>:
|
29 |
+
<?php echo $charge->status; ?>
|
30 |
+
</div>
|
31 |
+
<?php if ( ( $payment_intent_id = $order->get_meta( '_payment_intent_id', true ) ) ) : ?>
|
32 |
+
<div class="metadata">
|
33 |
+
<label><?php _e( 'Payment Intent', 'woo-stripe-payment' ); ?></label>:
|
34 |
+
<?php echo $payment_intent_id; ?>
|
35 |
+
</div>
|
36 |
+
<?php endif; ?>
|
37 |
+
<?php if ( isset( $charge->customer ) ) : ?>
|
38 |
+
<div class="metadata">
|
39 |
+
<label><?php _e( 'Customer', 'woo-stripe-payment' ); ?></label>:
|
40 |
+
<?php echo $charge->customer; ?>
|
41 |
+
</div>
|
42 |
+
<?php endif; ?>
|
43 |
+
</div>
|
44 |
+
<div class="payment-data column-6">
|
45 |
+
<h3><?php _e( 'Payment Method', 'woo-stripe-payment' ); ?></h3>
|
46 |
+
<div class="metadata">
|
47 |
+
<label><?php _e( 'Title', 'woo-stripe-payment' ); ?></label>:
|
48 |
+
<?php echo $order->get_payment_method_title(); ?>
|
49 |
+
</div>
|
50 |
+
<div class="metadata">
|
51 |
+
<label><?php _e( 'Type', 'woo-stripe-payment' ); ?></label>:
|
52 |
+
<?php echo $charge->payment_method_details->type; ?>
|
53 |
+
</div>
|
54 |
+
<?php if ( isset( $charge->payment_method_details->card ) ) : ?>
|
55 |
+
<div class="metadata">
|
56 |
+
<label><?php _e( 'Exp', 'woo-stripe-payment' ); ?>: </label>
|
57 |
+
<?php printf( '%02d / %s', $charge->payment_method_details->card->exp_month, $charge->payment_method_details->card->exp_year ); ?>
|
58 |
+
</div>
|
59 |
+
<div class="metadata">
|
60 |
+
<label><?php _e( 'Fingerprint', 'woo-stripe-payment' ); ?>: </label>
|
61 |
+
<?php echo $charge->payment_method_details->card->fingerprint; ?>
|
62 |
+
</div>
|
63 |
+
<div class="metadata">
|
64 |
+
<label><?php _e( 'CVC check', 'woo-stripe-payment' ); ?>: </label>
|
65 |
+
<?php echo $charge->payment_method_details->card->checks->cvc_check; ?>
|
66 |
+
</div>
|
67 |
+
<div class="metadata">
|
68 |
+
<label><?php _e( 'Postal check', 'woo-stripe-payment' ); ?>: </label>
|
69 |
+
<?php echo $charge->payment_method_details->card->checks->address_postal_code_check; ?>
|
70 |
+
</div>
|
71 |
+
<div class="metadata">
|
72 |
+
<label><?php _e( 'Street check', 'woo-stripe-payment' ); ?>: </label>
|
73 |
+
<?php echo $charge->payment_method_details->card->checks->address_line1_check; ?>
|
74 |
+
</div>
|
75 |
+
<?php endif; ?>
|
76 |
+
</div>
|
77 |
+
<div class="payment-data column-6">
|
78 |
+
<h3><?php _e( 'Riska Data', 'woo-stripe-payment' ); ?></h3>
|
79 |
+
<?php if ( isset( $charge->outcome->risk_score ) ) { ?>
|
80 |
+
<div class="metadata">
|
81 |
+
<label><?php _e( 'Score', 'woo-stripe-payment' ); ?></label>
|
82 |
+
<?php echo $charge->outcome->risk_score; ?>
|
83 |
+
</div>
|
84 |
+
<?php } ?>
|
85 |
+
<div class="metadata">
|
86 |
+
<label><?php _e( 'Level', 'woo-stripe-payment' ); ?></label>
|
87 |
+
<?php echo $charge->outcome->risk_level; ?>
|
88 |
+
</div>
|
89 |
+
</div>
|
90 |
+
</div>
|
includes/admin/meta-boxes/views/html-order-actions.php
CHANGED
@@ -1,47 +1,53 @@
|
|
1 |
-
<p
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
<?php
|
14 |
-
return;
|
15 |
-
}
|
16 |
-
$can_settle = $status === 'pending';
|
17 |
-
?>
|
18 |
-
<div id="wc-stripe-actions">
|
19 |
-
<div class="wc-stripe-buttons-container">
|
20 |
-
<?php if($can_settle)
|
21 |
-
<button type="button" class="button capture-charge"><?php esc_html_e('Capture Charge', 'woo-stripe-payment')?></button>
|
22 |
-
<?php endif
|
23 |
-
</div>
|
24 |
-
<div class="wc-order-data-row wc-order-capture-charge"
|
25 |
-
style="display: none;">
|
26 |
-
<div class="wc-order-capture-charge-container">
|
27 |
-
<table class="wc-order-capture-charge">
|
28 |
-
<tr>
|
29 |
-
<td class="label"><?php esc_html_e('Total available to capture', 'woo-stripe-payment')?>:</td>
|
30 |
-
<td class="total"><?php echo wc_price($order->get_total())?></td>
|
31 |
-
</tr>
|
32 |
-
<tr>
|
33 |
-
<td class="label"><?php esc_html_e('Amount To Capture', 'woo-stripe-payment')?>:</td>
|
34 |
-
<td class="total"><input type="text" id="worldpay_capture_amount"
|
35 |
-
name="capture_amount" class="wc_input_price" />
|
36 |
-
<div class="clear"></div></td>
|
37 |
-
</tr>
|
38 |
-
</table>
|
39 |
-
</div>
|
40 |
-
<div class="clear"></div>
|
41 |
-
<div class="capture-actions">
|
42 |
-
<button type="button" class="button button-primary do-api-capture"><?php esc_html_e( 'Capture', 'woo-stripe-payment' ); ?></button>
|
43 |
-
<button type="button" class="button cancel-action"><?php esc_html_e( 'Cancel', 'woo-stripe-payment' ); ?></button>
|
44 |
-
</div>
|
45 |
-
<div class="clear"></div>
|
46 |
-
</div>
|
47 |
-
</div>
|
1 |
+
<p>
|
2 |
+
<b><?php _e( 'Charge Status', 'woo-stripe-payment' ); ?>:</b> <?php echo ucfirst( str_replace( '_', ' ', $status ) ); ?></p>
|
3 |
+
<?php
|
4 |
+
|
5 |
+
if ( $status === 'pending' && $order->get_meta( '_authorization_exp_at' ) ) :
|
6 |
+
$date = new DateTime( '@' . $order->get_meta( '_authorization_exp_at' ) );
|
7 |
+
?>
|
8 |
+
<p>
|
9 |
+
<b><?php _e( 'Authorization Expires', 'woo-stripe-payment' ); ?>:</b> <?php echo date_format( $date, 'M d Y, h:i A e' ); ?>
|
10 |
+
<?php endif; ?>
|
11 |
+
<?php
|
12 |
+
|
13 |
+
switch ( $status ) {
|
14 |
+
case 'succeeded':
|
15 |
+
case 'faied':
|
16 |
+
?>
|
17 |
+
|
18 |
+
<p><?php _e( 'There are no actions available at this time.', 'woo-stripe-payment' ); ?></p>
|
19 |
<?php
|
20 |
+
return;
|
21 |
+
}
|
22 |
+
$can_settle = $status === 'pending';
|
23 |
+
?>
|
24 |
+
<div id="wc-stripe-actions">
|
25 |
+
<div class="wc-stripe-buttons-container">
|
26 |
+
<?php if ( $can_settle ) : ?>
|
27 |
+
<button type="button" class="button capture-charge"><?php esc_html_e( 'Capture Charge', 'woo-stripe-payment' ); ?></button>
|
28 |
+
<?php endif; ?>
|
29 |
+
</div>
|
30 |
+
<div class="wc-order-data-row wc-order-capture-charge"
|
31 |
+
style="display: none;">
|
32 |
+
<div class="wc-order-capture-charge-container">
|
33 |
+
<table class="wc-order-capture-charge">
|
34 |
+
<tr>
|
35 |
+
<td class="label"><?php esc_html_e( 'Total available to capture', 'woo-stripe-payment' ); ?>:</td>
|
36 |
+
<td class="total"><?php echo wc_price( $order->get_total() ); ?></td>
|
37 |
+
</tr>
|
38 |
+
<tr>
|
39 |
+
<td class="label"><?php esc_html_e( 'Amount To Capture', 'woo-stripe-payment' ); ?>:</td>
|
40 |
+
<td class="total"><input type="text" id="worldpay_capture_amount"
|
41 |
+
name="capture_amount" class="wc_input_price" />
|
42 |
+
<div class="clear"></div></td>
|
43 |
+
</tr>
|
44 |
+
</table>
|
45 |
+
</div>
|
46 |
+
<div class="clear"></div>
|
47 |
+
<div class="capture-actions">
|
48 |
+
<button type="button" class="button button-primary do-api-capture"><?php esc_html_e( 'Capture', 'woo-stripe-payment' ); ?></button>
|
49 |
+
<button type="button" class="button cancel-action"><?php esc_html_e( 'Cancel', 'woo-stripe-payment' ); ?></button>
|
50 |
+
</div>
|
51 |
+
<div class="clear"></div>
|
52 |
+
</div>
|
53 |
+
</div>
|
includes/admin/meta-boxes/views/html-order-charge-data.php
CHANGED
@@ -1,37 +1,37 @@
|
|
1 |
-
<div class="transaction-data">
|
2 |
-
<h3><?php _e('Transaction Data / Actions', 'woo-stripe-payment')?></h3>
|
3 |
-
<a href="#" class="do-transaction-view"
|
4 |
-
data-order="<?php echo $order->get_id()?>"></a>
|
5 |
-
</div>
|
6 |
-
<script type="text/template" id="tmpl-wc-stripe-view-transaction">
|
7 |
-
<div class="wc-backbone-modal">
|
8 |
-
<div class="wc-backbone-modal-content wc-transaction-data">
|
9 |
-
<section class="wc-backbone-modal-main" role="main">
|
10 |
-
<header class="wc-backbone-modal-header">
|
11 |
-
<h1>Transaction #{{ data.charge.id }}</h1>
|
12 |
-
<button
|
13 |
-
class="modal-close modal-close-link dashicons dashicons-no-alt">
|
14 |
-
<span class="screen-reader-text">Close modal panel</span>
|
15 |
-
</button>
|
16 |
-
</header>
|
17 |
-
<article class="wc-transaction-data-container">
|
18 |
-
{{{ data.html }}}
|
19 |
-
</article>
|
20 |
-
<footer>
|
21 |
-
<div class="inner">
|
22 |
-
|
23 |
-
</div>
|
24 |
-
</footer>
|
25 |
-
</section>
|
26 |
-
</div>
|
27 |
-
</div>
|
28 |
-
<div class="wc-backbone-modal-backdrop modal-close"></div>
|
29 |
-
</script>
|
30 |
-
<style>
|
31 |
-
#order_data .order_data_column .transaction-data a.disabled:before {
|
32 |
-
content: '';
|
33 |
-
background: url(<?php echo plugins_url('assets/images/wpspin.gif', WC_PLUGIN_FILE)?>)
|
34 |
-
no-repeat center top;
|
35 |
-
padding: 0px 10px;
|
36 |
-
}
|
37 |
-
</style>
|
1 |
+
<div class="transaction-data">
|
2 |
+
<h3><?php _e( 'Transaction Data / Actions', 'woo-stripe-payment' ); ?></h3>
|
3 |
+
<a href="#" class="do-transaction-view"
|
4 |
+
data-order="<?php echo $order->get_id(); ?>"></a>
|
5 |
+
</div>
|
6 |
+
<script type="text/template" id="tmpl-wc-stripe-view-transaction">
|
7 |
+
<div class="wc-backbone-modal">
|
8 |
+
<div class="wc-backbone-modal-content wc-transaction-data">
|
9 |
+
<section class="wc-backbone-modal-main" role="main">
|
10 |
+
<header class="wc-backbone-modal-header">
|
11 |
+
<h1>Transaction #{{ data.charge.id }}</h1>
|
12 |
+
<button
|
13 |
+
class="modal-close modal-close-link dashicons dashicons-no-alt">
|
14 |
+
<span class="screen-reader-text">Close modal panel</span>
|
15 |
+
</button>
|
16 |
+
</header>
|
17 |
+
<article class="wc-transaction-data-container">
|
18 |
+
{{{ data.html }}}
|
19 |
+
</article>
|
20 |
+
<footer>
|
21 |
+
<div class="inner">
|
22 |
+
|
23 |
+
</div>
|
24 |
+
</footer>
|
25 |
+
</section>
|
26 |
+
</div>
|
27 |
+
</div>
|
28 |
+
<div class="wc-backbone-modal-backdrop modal-close"></div>
|
29 |
+
</script>
|
30 |
+
<style>
|
31 |
+
#order_data .order_data_column .transaction-data a.disabled:before {
|
32 |
+
content: '';
|
33 |
+
background: url(<?php echo plugins_url('assets/images/wpspin.gif', WC_PLUGIN_FILE)?>)
|
34 |
+
no-repeat center top;
|
35 |
+
padding: 0px 10px;
|
36 |
+
}
|
37 |
+
</style>
|
includes/admin/meta-boxes/views/html-order-pay.php
CHANGED
@@ -1,59 +1,59 @@
|
|
1 |
-
<p class="form-field form-field-wide">
|
2 |
-
<button class="button button-secondary wc-stripe-pay-order"><?php _e('Pay for Order', 'woo-stripe-payment')?></button>
|
3 |
-
<?php echo wc_help_tip(__('Admins can process customer orders over the phone using this functionality.', 'woo-stripe-payment'))?>
|
4 |
-
</p>
|
5 |
-
<script type="text/template" id="tmpl-wc-stripe-modal-pay-order">
|
6 |
-
<div class="wc-backbone-modal">
|
7 |
-
<div class="wc-backbone-modal-content">
|
8 |
-
<section class="wc-backbone-modal-main" role="main">
|
9 |
-
<header class="wc-backbone-modal-header">
|
10 |
-
<h1><?php esc_html_e( 'Pay for Order', 'woocommerce' ); ?></h1>
|
11 |
-
<button
|
12 |
-
class="modal-close modal-close-link dashicons dashicons-no-alt">
|
13 |
-
<span class="screen-reader-text">Close modal panel</span>
|
14 |
-
</button>
|
15 |
-
</header>
|
16 |
-
<article>
|
17 |
-
<form id="wc-stripe-pay-order-form">
|
18 |
-
<input type="hidden" name="customer_id" value="{{{data.customer_id}}}"/>
|
19 |
-
<input type="hidden" name="order_id" value="{{{data.order_id}}}"/>
|
20 |
-
<div class="modal-wide option">
|
21 |
-
<label><?php _e('Charge Type', 'woo-stripe-payment')?></label>
|
22 |
-
<select name="wc_stripe_charge_type" class="wc-select2">
|
23 |
-
<option value="capture"><?php _e('Capture', 'woo-stripe-payment')?></value>
|
24 |
-
<option value="authorize"><?php _e('Authorize', 'woo-stripe-payment')?></value>
|
25 |
-
</select>
|
26 |
-
</div>
|
27 |
-
<#if(data.payment_methods.length){#>
|
28 |
-
<div class="modal-wide">
|
29 |
-
<input type="radio" value="token" name="payment_type" checked/>
|
30 |
-
<label class=""><?php _e('Saved Cards', 'woo-stripe-payment')?></label>
|
31 |
-
<div class="token-container show_if_token hide_if_nonce">
|
32 |
-
<select name="payment_token_id" class="wc-select2">
|
33 |
-
<#_.each(data.payment_methods, function(method){#>
|
34 |
-
<option value="{{{method.id}}}">{{{method.title}}}</option>
|
35 |
-
<#})#>
|
36 |
-
</select>
|
37 |
-
</div>
|
38 |
-
</div>
|
39 |
-
<#}#>
|
40 |
-
<div class="modal-wide">
|
41 |
-
<input type="radio" value="nonce" name="payment_type" class="" <#if(!data.payment_methods.length){#>checked<#}#>/>
|
42 |
-
<label class=""><?php _e('New Card', 'woo-stripe-payment')?></label>
|
43 |
-
<input type="hidden" name="payment_nonce"/>
|
44 |
-
<div id="wc-stripe-card-container" class="wc-stripe-card-container show_if_nonce hide_if_token">
|
45 |
-
<div id="card-element"></div>
|
46 |
-
</div>
|
47 |
-
<div>
|
48 |
-
</form>
|
49 |
-
</article>
|
50 |
-
<footer>
|
51 |
-
<div class="inner">
|
52 |
-
<button id="pay-order" class="button button-primary button-large"><?php esc_html_e( 'Pay', 'woo-stripe-payment' ); ?></button>
|
53 |
-
</div>
|
54 |
-
</footer>
|
55 |
-
</section>
|
56 |
-
</div>
|
57 |
-
</div>
|
58 |
-
<div class="wc-backbone-modal-backdrop modal-close"></div>
|
59 |
-
</script>
|
1 |
+
<p class="form-field form-field-wide">
|
2 |
+
<button class="button button-secondary wc-stripe-pay-order"><?php _e( 'Pay for Order', 'woo-stripe-payment' ); ?></button>
|
3 |
+
<?php echo wc_help_tip( __( 'Admins can process customer orders over the phone using this functionality.', 'woo-stripe-payment' ) ); ?>
|
4 |
+
</p>
|
5 |
+
<script type="text/template" id="tmpl-wc-stripe-modal-pay-order">
|
6 |
+
<div class="wc-backbone-modal">
|
7 |
+
<div class="wc-backbone-modal-content">
|
8 |
+
<section class="wc-backbone-modal-main" role="main">
|
9 |
+
<header class="wc-backbone-modal-header">
|
10 |
+
<h1><?php esc_html_e( 'Pay for Order', 'woocommerce' ); ?></h1>
|
11 |
+
<button
|
12 |
+
class="modal-close modal-close-link dashicons dashicons-no-alt">
|
13 |
+
<span class="screen-reader-text">Close modal panel</span>
|
14 |
+
</button>
|
15 |
+
</header>
|
16 |
+
<article>
|
17 |
+
<form id="wc-stripe-pay-order-form">
|
18 |
+
<input type="hidden" name="customer_id" value="{{{data.customer_id}}}"/>
|
19 |
+
<input type="hidden" name="order_id" value="{{{data.order_id}}}"/>
|
20 |
+
<div class="modal-wide option">
|
21 |
+
<label><?php _e( 'Charge Type', 'woo-stripe-payment' ); ?></label>
|
22 |
+
<select name="wc_stripe_charge_type" class="wc-select2">
|
23 |
+
<option value="capture"><?php _e( 'Capture', 'woo-stripe-payment' ); ?></value>
|
24 |
+
<option value="authorize"><?php _e( 'Authorize', 'woo-stripe-payment' ); ?></value>
|
25 |
+
</select>
|
26 |
+
</div>
|
27 |
+
<#if(data.payment_methods.length){#>
|
28 |
+
<div class="modal-wide">
|
29 |
+
<input type="radio" value="token" name="payment_type" checked/>
|
30 |
+
<label class=""><?php _e( 'Saved Cards', 'woo-stripe-payment' ); ?></label>
|
31 |
+
<div class="token-container show_if_token hide_if_nonce">
|
32 |
+
<select name="payment_token_id" class="wc-select2">
|
33 |
+
<#_.each(data.payment_methods, function(method){#>
|
34 |
+
<option value="{{{method.id}}}">{{{method.title}}}</option>
|
35 |
+
<#})#>
|
36 |
+
</select>
|
37 |
+
</div>
|
38 |
+
</div>
|
39 |
+
<#}#>
|
40 |
+
<div class="modal-wide">
|
41 |
+
<input type="radio" value="nonce" name="payment_type" class="" <#if(!data.payment_methods.length){#>checked<#}#>/>
|
42 |
+
<label class=""><?php _e( 'New Card', 'woo-stripe-payment' ); ?></label>
|
43 |
+
<input type="hidden" name="payment_nonce"/>
|
44 |
+
<div id="wc-stripe-card-container" class="wc-stripe-card-container show_if_nonce hide_if_token">
|
45 |
+
<div id="card-element"></div>
|
46 |
+
</div>
|
47 |
+
<div>
|
48 |
+
</form>
|
49 |
+
</article>
|
50 |
+
<footer>
|
51 |
+
<div class="inner">
|
52 |
+
<button id="pay-order" class="button button-primary button-large"><?php esc_html_e( 'Pay', 'woo-stripe-payment' ); ?></button>
|
53 |
+
</div>
|
54 |
+
</footer>
|
55 |
+
</section>
|
56 |
+
</div>
|
57 |
+
</div>
|
58 |
+
<div class="wc-backbone-modal-backdrop modal-close"></div>
|
59 |
+
</script>
|
includes/admin/meta-boxes/views/html-product-data.php
CHANGED
@@ -1,62 +1,82 @@
|
|
1 |
-
<div id="stripe_product_data"
|
2 |
-
class="panel woocommerce_stripe_panel woocommerce_options_panel hidden">
|
3 |
-
<p>
|
4 |
-
<?php _e('In this section you can control which gateways are displayed on the product page.', 'woo-stripe-payment')?>
|
5 |
-
</p>
|
6 |
-
<div class="options_group">
|
7 |
-
<input type="hidden" id="wc_stripe_update_product"
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
<th
|
13 |
-
<th><?php _e('
|
14 |
-
<th><?php _e(
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
<
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div id="stripe_product_data"
|
2 |
+
class="panel woocommerce_stripe_panel woocommerce_options_panel hidden">
|
3 |
+
<p>
|
4 |
+
<?php _e( 'In this section you can control which gateways are displayed on the product page.', 'woo-stripe-payment' ); ?>
|
5 |
+
</p>
|
6 |
+
<div class="options_group">
|
7 |
+
<input type="hidden" id="wc_stripe_update_product"
|
8 |
+
name="wc_stripe_update_product" />
|
9 |
+
<table class="wc-stripe-product-table wc_gateways">
|
10 |
+
<thead>
|
11 |
+
<tr>
|
12 |
+
<th></th>
|
13 |
+
<th><?php _e( 'Method', 'woo-stripe-payment' ); ?></th>
|
14 |
+
<th><?php _e( 'Enabled', 'woo-stripe-payment' ); ?></th>
|
15 |
+
<th><?php _e( 'Charge Type', 'woo-stripe-payment' ); ?>
|
16 |
+
|
17 |
+
|
18 |
+
</thead>
|
19 |
+
<tbody class="ui-sortable">
|
20 |
+
<?php foreach ( self::get_payment_gateways() as $gateway ) : ?>
|
21 |
+
<tr data-gateway_id="<?php echo $gateway->id; ?>">
|
22 |
+
<td class="sort">
|
23 |
+
<div class="wc-item-reorder-nav">
|
24 |
+
<button type="button" class="wc-move-up" tabindex="0"
|
25 |
+
aria-hidden="false"
|
26 |
+
aria-label="<?php /* Translators: %s Payment gateway name. */ echo esc_attr( sprintf( __( 'Move the "%s" payment method up', 'woocommerce' ), $gateway->get_method_title() ) ); ?>"><?php esc_html_e( 'Move up', 'woocommerce' ); ?></button>
|
27 |
+
<button type="button" class="wc-move-down" tabindex="0"
|
28 |
+
aria-hidden="false"
|
29 |
+
aria-label="<?php /* Translators: %s Payment gateway name. */ echo esc_attr( sprintf( __( 'Move the "%s" payment method down', 'woocommerce' ), $gateway->get_method_title() ) ); ?>"><?php esc_html_e( 'Move down', 'woocommerce' ); ?></button>
|
30 |
+
<input type="hidden" name="stripe_gateway_order[]"
|
31 |
+
value="<?php echo esc_attr( $gateway->id ); ?>" />
|
32 |
+
</div>
|
33 |
+
</td>
|
34 |
+
<td>
|
35 |
+
<?php echo $gateway->get_method_title(); ?>
|
36 |
+
</td>
|
37 |
+
<td><a class="wc-stripe-product-gateway-enabled" href="#"> <span
|
38 |
+
class="woocommerce-input-toggle woocommerce-input-toggle--
|
39 |
+
<?php
|
40 |
+
if ( ! self::get_product_option( $gateway->id )->enabled() ) {
|
41 |
+
?>
|
42 |
+
disabled
|
43 |
+
<?php
|
44 |
+
} else {
|
45 |
+
?>
|
46 |
+
enabled<?php } ?>"></span>
|
47 |
+
</a></td>
|
48 |
+
<td><select name="stripe_capture_type[]" class="wc-enhanced-select"
|
49 |
+
style="width: 100px">
|
50 |
+
<option value="capture"
|
51 |
+
<?php selected( 'capture', self::get_product_option( $gateway->id )->get_option( 'charge_type' ) ); ?>><?php _e( 'Capture', 'woo-stripe-payment' ); ?></option>
|
52 |
+
<option value="authorize"
|
53 |
+
<?php selected( 'authorize', self::get_product_option( $gateway->id )->get_option( 'charge_type' ) ); ?>><?php _e( 'Authorize', 'woo-stripe-payment' ); ?></option>
|
54 |
+
</select></td>
|
55 |
+
</tr>
|
56 |
+
<?php endforeach; ?>
|
57 |
+
</tbody>
|
58 |
+
</table>
|
59 |
+
<?php
|
60 |
+
woocommerce_wp_select(
|
61 |
+
array(
|
62 |
+
'id' => '_stripe_button_position',
|
63 |
+
'value' => ( ( $position = $product_object->get_meta( '_stripe_button_position' ) ) ? $position : 'bottom' ),
|
64 |
+
'label' => __( 'Button Position', 'woo-stripe-payment' ),
|
65 |
+
'options' => array(
|
66 |
+
'bottom' => __( 'Below add to cart', 'woo-stripe-payment' ),
|
67 |
+
'top' => __( 'Above add to cart', 'woo-stripe-payment' ),
|
68 |
+
),
|
69 |
+
'desc_tip' => true,
|
70 |
+
'description' => __(
|
71 |
+
'The location of the payment buttons in relation to the Add to Cart button.',
|
72 |
+
'woo-stripe-payment'
|
73 |
+
),
|
74 |
+
)
|
75 |
+
);
|
76 |
+
?>
|
77 |
+
</div>
|
78 |
+
<p>
|
79 |
+
<button class="button button-secondary wc-stripe-save-product-data"><?php _e( 'Save', 'woo-stripe-payment' ); ?></button>
|
80 |
+
<span class="spinner"></span>
|
81 |
+
</p>
|
82 |
+
</div>
|
includes/admin/settings/class-wc-stripe-api-settings.php
CHANGED
@@ -1,175 +1,188 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
/**
|
5 |
-
*
|
6 |
-
* @author Payment Plugins
|
7 |
-
* @since 3.0.0
|
8 |
-
* @package Stripe/Classes
|
9 |
-
*
|
10 |
-
*/
|
11 |
-
class WC_Stripe_API_Settings extends WC_Stripe_Settings_API {
|
12 |
-
|
13 |
-
public function __construct() {
|
14 |
-
$this->id
|
15 |
-
$this->tab_title = __
|
16 |
-
parent::__construct
|
17 |
-
}
|
18 |
-
|
19 |
-
public function hooks() {
|
20 |
-
parent::hooks
|
21 |
-
add_action
|
22 |
-
|
23 |
-
) );
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
'title'
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
),
|
47 |
-
'
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
'
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
'
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
'
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
'
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
),
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
$
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
$message = $error->message;
|
135 |
-
}
|
136 |
-
$message =
|
137 |
-
}
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
$
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
$this->settings[
|
148 |
-
|
149 |
-
|
150 |
-
$this->settings[
|
151 |
-
|
152 |
-
|
153 |
-
$this->
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
/**
|
5 |
+
*
|
6 |
+
* @author Payment Plugins
|
7 |
+
* @since 3.0.0
|
8 |
+
* @package Stripe/Classes
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
class WC_Stripe_API_Settings extends WC_Stripe_Settings_API {
|
12 |
+
|
13 |
+
public function __construct() {
|
14 |
+
$this->id = 'stripe_api';
|
15 |
+
$this->tab_title = __( 'API Settings', 'woo-stripe-payment' );
|
16 |
+
parent::__construct();
|
17 |
+
}
|
18 |
+
|
19 |
+
public function hooks() {
|
20 |
+
parent::hooks();
|
21 |
+
add_action( 'woocommerce_update_options_checkout_' . $this->id, array( $this, 'process_admin_options' ) );
|
22 |
+
add_filter( 'wc_stripe_settings_nav_tabs', array( $this, 'admin_nav_tab' ) );
|
23 |
+
add_action( 'woocommerce_settings_checkout_' . $this->id, array( $this, 'admin_options' ) );
|
24 |
+
}
|
25 |
+
|
26 |
+
public function init_form_fields() {
|
27 |
+
$this->form_fields = array(
|
28 |
+
'title' => array(
|
29 |
+
'type' => 'title',
|
30 |
+
'title' => __( 'API Settings', 'woo-stripe-payment' ),
|
31 |
+
),
|
32 |
+
'mode' => array(
|
33 |
+
'type' => 'select',
|
34 |
+
'title' => __( 'Mode', 'woo-stripe-payment' ),
|
35 |
+
'class' => 'wc-enhanced-select',
|
36 |
+
'options' => array(
|
37 |
+
'test' => __( 'Test', 'woo-stripe-payment' ),
|
38 |
+
'live' => __( 'Live', 'woo-stripe-payment' ),
|
39 |
+
),
|
40 |
+
'default' => 'test',
|
41 |
+
'desc_tip' => true,
|
42 |
+
'description' => __( 'The mode determines if you are processing test transactions or live transactions on your site. Test mode allows you to simulate payments so you can test your integration.', 'woo-stripe-payment' ),
|
43 |
+
),
|
44 |
+
'account_id' => array(
|
45 |
+
'type' => 'paragraph',
|
46 |
+
'title' => __( 'Account ID', 'woo-stripe-payment' ),
|
47 |
+
'text' => '',
|
48 |
+
'class' => '',
|
49 |
+
'default' => '',
|
50 |
+
'desc_tip' => true,
|
51 |
+
'description' => __( 'This is your Stripe Connect ID and serves as a unique identifier.', 'woo-stripe-payment' ),
|
52 |
+
),
|
53 |
+
'stripe_connect' => array(
|
54 |
+
'type' => 'stripe_connect',
|
55 |
+
'title' => __( 'Connect Stripe Account', 'woo-stripe-payment' ),
|
56 |
+
'label' => __( 'Click to Connect', 'woo-stripe-payment' ),
|
57 |
+
'class' => 'do-stripe-connect',
|
58 |
+
'description' => __( 'We make it easy to connect Stripe to your site. Click the Connect button to go through our connect flow.', 'woo-stripe-payment' ),
|
59 |
+
),
|
60 |
+
'connection_test' => array(
|
61 |
+
'type' => 'stripe_button',
|
62 |
+
'title' => __( 'Connection Test', 'woo-stripe-payment' ),
|
63 |
+
'label' => __( 'Connection Test', 'woo-stripe-payment' ),
|
64 |
+
'class' => 'wc-stripe-connection-test button-secondary',
|
65 |
+
'description' => __( 'Click this button to perform a connection test. If successful, your site is connected to Stripe.', 'woo-stripe-payment' ),
|
66 |
+
),
|
67 |
+
'webhook_url' => array(
|
68 |
+
'type' => 'paragraph',
|
69 |
+
'title' => __( 'Webhook url', 'woo-stripe-payment' ),
|
70 |
+
'class' => 'wc-stripe-webhook',
|
71 |
+
'text' => wc_stripe()->rest_api->webhook->rest_url( 'webhook' ),
|
72 |
+
'description' => sprintf( __( '<strong>Important:</strong> the webhook url is called by Stripe when events occur in your account, like a source becomes chargeable. You must add this webhook to your Stripe Dashboard if you are using any of the local gateways. %1$sWebhook guide%2$s', 'woo-stripe-payment' ), '<a target="_blank" href="https://docs.paymentplugins.com/wc-stripe/config/#/webhooks?id=configure-webhooks">', '</a>' ),
|
73 |
+
),
|
74 |
+
'webhook_secret_live' => array(
|
75 |
+
'type' => 'password',
|
76 |
+
'title' => __( 'Live Webhook Secret', 'woo-stripe-payment' ),
|
77 |
+
'description' => sprintf( __( 'The webhook secret is used to authenticate webhooks sent from Stripe. It ensures no 3rd party can send you events, pretending to be Stripe. %1$sWebhook guide%2$s', 'woo-stripe-payment' ), '<a target="_blank" href="https://docs.paymentplugins.com/wc-stripe/config/#/webhooks?id=configure-webhooks">', '</a>' ),
|
78 |
+
'custom_attributes' => array( 'data-show-if' => array( 'mode' => 'live' ) ),
|
79 |
+
),
|
80 |
+
'webhook_secret_test' => array(
|
81 |
+
'type' => 'password',
|
82 |
+
'title' => __( 'Test Webhook Secret', 'woo-stripe-payment' ),
|
83 |
+
'description' => sprintf( __( 'The webhook secret is used to authenticate webhooks sent from Stripe. It ensures no 3rd party can send you events, pretending to be Stripe. %1$sWebhook guide%2$s', 'woo-stripe-payment' ), '<a target="_blank" href="https://docs.paymentplugins.com/wc-stripe/config/#/webhooks?id=configure-webhooks">', '</a>' ),
|
84 |
+
'custom_attributes' => array( 'data-show-if' => array( 'mode' => 'test' ) ),
|
85 |
+
),
|
86 |
+
'debug_log' => array(
|
87 |
+
'title' => __( 'Debug Log', 'woo-stripe-payment' ),
|
88 |
+
'type' => 'checkbox',
|
89 |
+
'desc_tip' => true,
|
90 |
+
'default' => 'yes',
|
91 |
+
'description' => __( 'When enabled, the plugin logs important errors and info that can help you troubleshoot potential issues.', 'woo-stripe-payment' ),
|
92 |
+
),
|
93 |
+
);
|
94 |
+
if ( $this->get_option( 'account_id' ) ) {
|
95 |
+
$this->form_fields['account_id']['text'] = $this->get_option( 'account_id' );
|
96 |
+
$this->form_fields['stripe_connect']['description'] = sprintf( __( '%s Your Stripe account has been connected. You can now accept Live and Test payments. You can Re-Connect if you want to recycle your API keys for security.', 'woo-stripe-payment' ), '<span class="dashicons dashicons-yes stipe-connect-active"></span>' );
|
97 |
+
$this->form_fields['stripe_connect']['active'] = true;
|
98 |
+
} else {
|
99 |
+
unset( $this->form_fields['account_id'], $this->form_fields['connection_test'], $this->form_fields['mode'], $this->form_fields['webhook_url'] );
|
100 |
+
}
|
101 |
+
}
|
102 |
+
|
103 |
+
public function generate_stripe_connect_html( $key, $data ) {
|
104 |
+
$field_key = $this->get_field_key( $key );
|
105 |
+
$data = wp_parse_args(
|
106 |
+
$data,
|
107 |
+
array(
|
108 |
+
'class' => '',
|
109 |
+
'style' => '',
|
110 |
+
'description' => '',
|
111 |
+
'desc_tip' => false,
|
112 |
+
'css' => '',
|
113 |
+
'active' => false,
|
114 |
+
)
|
115 |
+
);
|
116 |
+
$data['connect_url'] = $this->get_connect_url();
|
117 |
+
if ( $data['active'] ) {
|
118 |
+
$data['label'] = __( 'Click To Re-Connect', 'woo-stripe-payment' );
|
119 |
+
}
|
120 |
+
ob_start();
|
121 |
+
include wc_stripe()->plugin_path() . 'includes/admin/views/html-stripe-connect.php';
|
122 |
+
|
123 |
+
return ob_get_clean();
|
124 |
+
}
|
125 |
+
|
126 |
+
public function admin_options() {
|
127 |
+
// Check if user is being returned from Stripe Connect
|
128 |
+
if ( isset( $_GET['_stripe_connect_nonce'] ) && wp_verify_nonce( $_GET['_stripe_connect_nonce'], 'stripe-connect' ) ) {
|
129 |
+
if ( isset( $_GET['error'] ) ) {
|
130 |
+
$error = json_decode( base64_decode( wc_clean( $_GET['error'] ) ) );
|
131 |
+
if ( property_exists( $error, 'message' ) ) {
|
132 |
+
$message = $error->message;
|
133 |
+
} elseif ( property_exists( $error, 'raw' ) ) {
|
134 |
+
$message = $error->raw->message;
|
135 |
+
} else {
|
136 |
+
$message = __( 'Please try again.', 'woo-stripe-payment' );
|
137 |
+
}
|
138 |
+
wc_stripe_log_error( sprintf( 'Error connecting to Stripe account. Reason: %s', $message ) );
|
139 |
+
$this->add_error( sprintf( __( 'We were not able to connect your Stripe account. Reason: %s', 'woo-stripe-payment' ), $message ) );
|
140 |
+
} elseif ( isset( $_GET['response'] ) ) {
|
141 |
+
$response = json_decode( base64_decode( $_GET['response'] ) );
|
142 |
+
|
143 |
+
// save the token to the api settings
|
144 |
+
$this->settings['account_id'] = $response->live->stripe_user_id;
|
145 |
+
$this->settings['refresh_token'] = $response->live->refresh_token;
|
146 |
+
|
147 |
+
$this->settings['secret_key_live'] = $response->live->access_token;
|
148 |
+
$this->settings['publishable_key_live'] = $response->live->stripe_publishable_key;
|
149 |
+
|
150 |
+
$this->settings['secret_key_test'] = $response->test->access_token;
|
151 |
+
$this->settings['publishable_key_test'] = $response->test->stripe_publishable_key;
|
152 |
+
|
153 |
+
update_option( $this->get_option_key(), $this->settings );
|
154 |
+
|
155 |
+
delete_option( 'wc_stripe_connect_notice' );
|
156 |
+
|
157 |
+
/**
|
158 |
+
* @param array $response
|
159 |
+
* @param WC_Stripe_API_Settings $this
|
160 |
+
*
|
161 |
+
* @since 3.1.6
|
162 |
+
*/
|
163 |
+
do_action( 'wc_stripe_connect_settings', $response, $this );
|
164 |
+
|
165 |
+
$this->init_form_fields();
|
166 |
+
|
167 |
+
echo '<div class="updated inline notice-success is-dismissible "><p>' .
|
168 |
+
__( 'Your Stripe account has been connected to your WooCommerce store. You may now accept payments in Live and Test mode.', 'woo-stripe-payment' ) .
|
169 |
+
'</p></div>';
|
170 |
+
}
|
171 |
+
}
|
172 |
+
parent::admin_options();
|
173 |
+
}
|
174 |
+
|
175 |
+
public function get_connect_url() {
|
176 |
+
return sprintf(
|
177 |
+
'https://connect.stripe.com/oauth/authorize?response_type=code&client_id=%s&stripe_landing=login&scope=read_write&state=%s',
|
178 |
+
wc_stripe()->client_id,
|
179 |
+
base64_encode(
|
180 |
+
wp_json_encode(
|
181 |
+
array(
|
182 |
+
'redirect' => add_query_arg( '_stripe_connect_nonce', wp_create_nonce( 'stripe-connect' ), admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=stripe_api' ) )
|
183 |
+
)
|
184 |
+
)
|
185 |
+
)
|
186 |
+
);
|
187 |
+
}
|
188 |
+
}
|
includes/admin/views/html-ach-fee.php
CHANGED
@@ -1,29 +1,33 @@
|
|
1 |
-
<tr valign="top">
|
2 |
-
<th scope="row" class="titledesc"
|
3 |
-
|
4 |
-
</th>
|
5 |
-
<td class="forminp">
|
6 |
-
<fieldset>
|
7 |
-
<legend class="screen-reader-text"
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
<?php
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
</
|
|
|
|
|
|
|
|
1 |
+
<tr valign="top">
|
2 |
+
<th scope="row" class="titledesc"><label
|
3 |
+
for="<?php echo esc_attr( $field_key ); ?>"><?php echo wp_kses_post( $data['title'] ); ?> <?php echo $this->get_tooltip_html( $data ); // WPCS: XSS ok. ?></label>
|
4 |
+
</th>
|
5 |
+
<td class="forminp">
|
6 |
+
<fieldset>
|
7 |
+
<legend class="screen-reader-text">
|
8 |
+
<span><?php echo wp_kses_post( $data['title'] ); ?></span>
|
9 |
+
</legend>
|
10 |
+
<div class="wc-stripe-fee-container">
|
11 |
+
<div class="wc-stripe-fee-col">
|
12 |
+
<label><?php _e( 'Type', 'woo-stripe-payment' ); ?></label> <select class="select wc-enhanced-select ach-fee" name="<?php echo esc_attr( $field_key ); ?>[type]" id="<?php echo esc_attr( $field_key ); ?>[type]" style="<?php echo esc_attr( $data['css'] ); ?>" <?php disabled( $data['disabled'], true ); ?> <?php echo $this->get_custom_attribute_html( $data ); // WPCS: XSS ok. ?>>
|
13 |
+
<?php foreach ( (array) $data['options'] as $option_key => $option_value ) : ?>
|
14 |
+
<option value="<?php echo esc_attr( $option_key ); ?>"
|
15 |
+
<?php selected( (string) $option_key, esc_attr( $this->get_option( $key )['type'] ) ); ?>><?php echo esc_attr( $option_value ); ?></option>
|
16 |
+
<?php endforeach; ?>
|
17 |
+
</select>
|
18 |
+
</div>
|
19 |
+
<div class="wc-stripe-fee-col">
|
20 |
+
<label><?php _e( 'Taxable', 'woo-stripe-payment' ); ?></label> <input
|
21 |
+
type="checkbox"
|
22 |
+
name="<?php echo esc_attr( $field_key ); ?>[taxable]"
|
23 |
+
id="<?php echo esc_attr( $field_key ); ?>[taxable]" value="yes"
|
24 |
+
<?php checked( $this->get_option( 'fee' )['taxable'], 'yes' ); ?> />
|
25 |
+
</div>
|
26 |
+
<div class="wc-stripe-fee-col">
|
27 |
+
<label><?php _e( 'Value', 'woo-stripe-payment' ); ?></label> <input class="input-text regular-input <?php echo esc_attr( $data['class'] ); ?>" type="text" name="<?php echo esc_attr( $field_key ); ?>[value]" id="<?php echo esc_attr( $field_key ); ?>[value]" style="<?php echo esc_attr( $data['css'] ); ?>" value="<?php echo esc_attr( $this->get_option( $key )['value'] ); ?>" placeholder="<?php echo esc_attr( $data['placeholder'] ); ?>" <?php disabled( $data['disabled'], true ); ?> <?php echo $this->get_custom_attribute_html( $data ); // WPCS: XSS ok. ?> />
|
28 |
+
</div>
|
29 |
+
</div>
|
30 |
+
<?php echo $this->get_description_html( $data ); // WPCS: XSS ok. ?>
|
31 |
+
</fieldset>
|
32 |
+
</td>
|
33 |
+
</tr>
|
includes/admin/views/html-button-demo.php
CHANGED
@@ -1,13 +1,17 @@
|
|
1 |
-
<tr valign="top">
|
2 |
-
<th scope="row" class="titledesc"
|
3 |
-
|
4 |
-
</th>
|
5 |
-
<td class="forminp">
|
6 |
-
<fieldset>
|
7 |
-
<legend class="screen-reader-text"
|
8 |
-
|
9 |
-
|
10 |
-
<?php echo
|
11 |
-
|
12 |
-
|
13 |
-
|
|
|
|
|
|
|
|
1 |
+
<tr valign="top">
|
2 |
+
<th scope="row" class="titledesc"><label
|
3 |
+
for="<?php echo esc_attr( $field_key ); ?>"><?php echo wp_kses_post( $data['title'] ); ?> <?php echo $this->get_tooltip_html( $data ); // WPCS: XSS ok. ?></label>
|
4 |
+
</th>
|
5 |
+
<td class="forminp">
|
6 |
+
<fieldset>
|
7 |
+
<legend class="screen-reader-text">
|
8 |
+
<span><?php echo wp_kses_post( $data['title'] ); ?></span>
|
9 |
+
</legend>
|
10 |
+
<label for="<?php echo esc_attr( $field_key ); ?>">
|
11 |
+
<div id="<?php echo $data['id']; ?>"></div>
|
12 |
+
<?php echo $this->get_description_html( $data ); // WPCS: XSS ok. ?>
|
13 |
+
|
14 |
+
|
15 |
+
</fieldset>
|
16 |
+
</td>
|
17 |
+
</tr>
|
includes/admin/views/html-button.php
CHANGED
@@ -1,13 +1,16 @@
|
|
1 |
-
<tr valign="top">
|
2 |
-
<th scope="row" class="titledesc"
|
3 |
-
|
4 |
-
</th>
|
5 |
-
<td class="forminp">
|
6 |
-
<fieldset>
|
7 |
-
<legend class="screen-reader-text"
|
8 |
-
|
9 |
-
|
10 |
-
<?php echo
|
11 |
-
|
12 |
-
|
13 |
-
|
|
|
|
|
|
1 |
+
<tr valign="top">
|
2 |
+
<th scope="row" class="titledesc"><label
|
3 |
+
for="<?php echo esc_attr( $field_key ); ?>"><?php echo wp_kses_post( $data['title'] ); ?> <?php echo $this->get_tooltip_html( $data ); // WPCS: XSS ok. ?></label>
|
4 |
+
</th>
|
5 |
+
<td class="forminp">
|
6 |
+
<fieldset>
|
7 |
+
<legend class="screen-reader-text">
|
8 |
+
<span><?php echo wp_kses_post( $data['title'] ); ?></span>
|
9 |
+
</legend>
|
10 |
+
<label for="<?php echo esc_attr( $field_key ); ?>">
|
11 |
+
<button type="submit" <?php disabled( $data['disabled'], true ); ?> class="<?php echo esc_attr( $data['class'] ); ?>" name="<?php echo esc_attr( $field_key ); ?>" id="<?php echo esc_attr( $field_key ); ?>" style="<?php echo esc_attr( $data['css'] ); ?>" value="<?php echo $field_key; ?>" <?php echo $this->get_custom_attribute_html( $data ); // WPCS: XSS ok. ?>><?php echo wp_kses_post( $data['label'] ); ?></button>
|
12 |
+
</label><br />
|
13 |
+
<?php echo $this->get_description_html( $data ); // WPCS: XSS ok. ?>
|
14 |
+
</fieldset>
|
15 |
+
</td>
|
16 |
+
</tr>
|
includes/admin/views/html-description.php
CHANGED
@@ -1 +1 @@
|
|
1 |
-
<p class="<?php echo $data['class']?>"><?php echo wp_kses_post( $data['description'] ); ?></p>
|
1 |
+
<p class="<?php echo $data['class']; ?>"><?php echo wp_kses_post( $data['description'] ); ?></p>
|
includes/admin/views/html-paragraph.php
CHANGED
@@ -1,14 +1,15 @@
|
|
1 |
-
<tr valign="top">
|
2 |
-
<th scope="row" class="titledesc"><label
|
3 |
-
for="<?php echo esc_attr( $field_key ); ?>"><?php echo wp_kses_post( $data['title'] ); ?> <?php echo $this->get_tooltip_html( $data ); // WPCS: XSS ok. ?></label>
|
4 |
-
</th>
|
5 |
-
<td class="forminp">
|
6 |
-
<fieldset>
|
7 |
-
<legend class="screen-reader-text">
|
8 |
-
<span><?php echo wp_kses_post( $data['title'] ); ?></span>
|
9 |
-
</legend>
|
10 |
-
<p class="<?php echo esc_attr( $data['class'] )
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
</
|
|
1 |
+
<tr valign="top">
|
2 |
+
<th scope="row" class="titledesc"><label
|
3 |
+
for="<?php echo esc_attr( $field_key ); ?>"><?php echo wp_kses_post( $data['title'] ); ?> <?php echo $this->get_tooltip_html( $data ); // WPCS: XSS ok. ?></label>
|
4 |
+
</th>
|
5 |
+
<td class="forminp">
|
6 |
+
<fieldset>
|
7 |
+
<legend class="screen-reader-text">
|
8 |
+
<span><?php echo wp_kses_post( $data['title'] ); ?></span>
|
9 |
+
</legend>
|
10 |
+
<p class="<?php echo esc_attr( $data['class'] ); ?>"
|
11 |
+
<?php echo $this->get_custom_attribute_html( $data ); ?>><?php echo $data['text']; ?></p>
|
12 |
+
<?php echo $this->get_description_html( $data ); // WPCS: XSS ok. ?>
|
13 |
+
</fieldset>
|
14 |
+
</td>
|
15 |
+
</tr>
|
includes/admin/views/html-settings-local-payments-nav.php
CHANGED
@@ -1,12 +1,17 @@
|
|
1 |
-
<?php
|
2 |
-
global $wc_stripe_subsection;
|
3 |
-
$tabs = apply_filters
|
4 |
-
?>
|
5 |
-
<div class="wc-stripe-advanced-settings-nav local-gateways">
|
6 |
-
<?php foreach($tabs as $id => $tab)
|
7 |
-
<a
|
8 |
-
class="nav-link
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
global $wc_stripe_subsection;
|
3 |
+
$tabs = apply_filters( 'wc_stripe_local_gateways_tab', array() );
|
4 |
+
?>
|
5 |
+
<div class="wc-stripe-advanced-settings-nav local-gateways">
|
6 |
+
<?php foreach ( $tabs as $id => $tab ) : ?>
|
7 |
+
<a
|
8 |
+
class="nav-link
|
9 |
+
<?php
|
10 |
+
if ( $wc_stripe_subsection === $id ) {
|
11 |
+
echo 'nav-link-active';}
|
12 |
+
?>
|
13 |
+
"
|
14 |
+
href="<?php echo admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=stripe_local_gateways&stripe_sub_section=' . $id ); ?>"><?php echo esc_attr( $tab ); ?></a>
|
15 |
+
<?php endforeach; ?>
|
16 |
+
</div>
|
17 |
+
<div class="clear"></div>
|
includes/admin/views/html-settings-nav.php
CHANGED
@@ -1,18 +1,25 @@
|
|
1 |
-
<?php
|
2 |
-
global $current_section;
|
3 |
-
$tabs = apply_filters('wc_stripe_settings_nav_tabs', array());
|
4 |
-
?>
|
5 |
-
<div class="wc-stripe-settings-logo">
|
6 |
-
<img
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
global $current_section;
|
3 |
+
$tabs = apply_filters( 'wc_stripe_settings_nav_tabs', array() );
|
4 |
+
?>
|
5 |
+
<div class="wc-stripe-settings-logo">
|
6 |
+
<img
|
7 |
+
src="<?php echo wc_stripe()->assets_url() . 'img/stripe_logo.svg'; ?>" />
|
8 |
+
</div>
|
9 |
+
<div class="stripe-settings-nav">
|
10 |
+
<?php foreach ( $tabs as $id => $tab ) : ?>
|
11 |
+
<a
|
12 |
+
class="nav-tab
|
13 |
+
<?php
|
14 |
+
if ( $current_section === $id ) {
|
15 |
+
echo 'nav-tab-active';}
|
16 |
+
?>
|
17 |
+
"
|
18 |
+
href="<?php echo admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=' . $id ); ?>"><?php echo esc_attr( $tab ); ?></a>
|
19 |
+
<?php endforeach; ?>
|
20 |
+
</div>
|
21 |
+
<div class="clear"></div>
|
22 |
+
<div class="wc-stripe-docs">
|
23 |
+
<a target="_blank" class="button button-secondary"
|
24 |
+
href="https://docs.paymentplugins.com/wc-stripe/config/#/<?php echo $current_section; ?>"><?php _e( 'Documentation', 'woo-stripe-payment' ); ?></a>
|
25 |
+
</div>
|
includes/admin/views/html-stripe-connect.php
CHANGED
@@ -1,14 +1,19 @@
|
|
1 |
-
<tr valign="top">
|
2 |
-
<th scope="row" class="titledesc"
|
3 |
-
|
4 |
-
</th>
|
5 |
-
<td class="forminp
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
|
1 |
+
<tr valign="top">
|
2 |
+
<th scope="row" class="titledesc"><label
|
3 |
+
for="<?php echo esc_attr( $field_key ); ?>"><?php echo wp_kses_post( $data['title'] ); ?> <?php echo $this->get_tooltip_html( $data ); // WPCS: XSS ok. ?></label>
|
4 |
+
</th>
|
5 |
+
<td class="forminp
|
6 |
+
<?php
|
7 |
+
if ( $data['active'] ) {
|
8 |
+
?>
|
9 |
+
active<?php } ?>">
|
10 |
+
<fieldset>
|
11 |
+
<legend class="screen-reader-text">
|
12 |
+
<span><?php echo wp_kses_post( $data['title'] ); ?></span>
|
13 |
+
</legend>
|
14 |
+
<label for="<?php echo esc_attr( $field_key ); ?>"> <a href="<?php echo $data['connect_url']; ?>" type="submit" class="stripe-connect light-blue <?php echo esc_attr( $data['class'] ); ?>" name="<?php echo esc_attr( $field_key ); ?>" id="<?php echo esc_attr( $field_key ); ?>" style="<?php echo esc_attr( $data['css'] ); ?>" value="<?php echo $field_key; ?>" <?php echo $this->get_custom_attribute_html( $data ); // WPCS: XSS ok. ?>><span><?php echo wp_kses_post( $data['label'] ); ?></span></a>
|
15 |
+
</label>
|
16 |
+
<?php echo $this->get_description_html( $data ); // WPCS: XSS ok. ?>
|
17 |
+
</fieldset>
|
18 |
+
</td>
|
19 |
+
</tr>
|
includes/admin/views/html-user-profile.php
CHANGED
@@ -1,95 +1,95 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @var WP_User $user
|
4 |
-
*/
|
5 |
-
?>
|
6 |
-
<div class="wc-stripe-user-info">
|
7 |
-
<h2><?php _e('Stripe Customer ID\'s', 'woo-stripe-payment')?></h2>
|
8 |
-
<p><?php _e('If you change a customer ID, the customer\'s payment methods will be imported from your Stripe account.')?></p>
|
9 |
-
<p><?php _e('If you remove a customer ID, the customer\'s payment methods will be removed from the WC payment methods table.')?></p>
|
10 |
-
<table class="form-table">
|
11 |
-
<tbody>
|
12 |
-
<tr>
|
13 |
-
<th><?php _e('Live ID', 'woo-stripe-payment')?></th>
|
14 |
-
<td
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
<
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
<
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
<th><?php _e('
|
34 |
-
<th><?php _e('
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
<th><?php _e('Payment
|
67 |
-
<th><?php _e('
|
68 |
-
<th><?php _e('
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
<option value="
|
86 |
-
|
87 |
-
</td>
|
88 |
-
</tr>
|
89 |
-
</tbody>
|
90 |
-
</table>
|
91 |
-
<?php else
|
92 |
-
<?php _e('No test payment methods saved', 'woo-stripe-payment')?>
|
93 |
-
<?php endif
|
94 |
-
<?php printf(__('%snote:%s payment methods will be deleted in Stripe if you use the delete action.', 'woo-stripe-payment'), '<strong>', '</strong>')?>
|
95 |
-
</div>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @var WP_User $user
|
4 |
+
*/
|
5 |
+
?>
|
6 |
+
<div class="wc-stripe-user-info">
|
7 |
+
<h2><?php _e( 'Stripe Customer ID\'s', 'woo-stripe-payment' ); ?></h2>
|
8 |
+
<p><?php _e( 'If you change a customer ID, the customer\'s payment methods will be imported from your Stripe account.' ); ?></p>
|
9 |
+
<p><?php _e( 'If you remove a customer ID, the customer\'s payment methods will be removed from the WC payment methods table.' ); ?></p>
|
10 |
+
<table class="form-table">
|
11 |
+
<tbody>
|
12 |
+
<tr>
|
13 |
+
<th><?php _e( 'Live ID', 'woo-stripe-payment' ); ?></th>
|
14 |
+
<td><input type="text" id="wc_stripe_live_id"
|
15 |
+
name="wc_stripe_live_id"
|
16 |
+
value="<?php echo wc_stripe_get_customer_id( $user->ID, 'live' ); ?>" />
|
17 |
+
</td>
|
18 |
+
</tr>
|
19 |
+
<tr>
|
20 |
+
<th><?php _e( 'Test ID', 'woo-stripe-payment' ); ?></th>
|
21 |
+
<td><input type="text" id="wc_stripe_test_id"
|
22 |
+
name="wc_stripe_test_id"
|
23 |
+
value="<?php echo wc_stripe_get_customer_id( $user->ID, 'test' ); ?>" />
|
24 |
+
</td>
|
25 |
+
</tr>
|
26 |
+
</tbody>
|
27 |
+
</table>
|
28 |
+
<h2><?php _e( 'Stripe Live Payment Methods', 'woo-stripe-payment' ); ?></h2>
|
29 |
+
<?php if ( $payment_methods['live'] ) : ?>
|
30 |
+
<table class="wc-stripe-payment-methods">
|
31 |
+
<thead>
|
32 |
+
<tr>
|
33 |
+
<th><?php _e( 'Payment Gateway', 'woo-stripe-payment' ); ?></th>
|
34 |
+
<th><?php _e( 'Payment Method', 'woo-stripe-payment' ); ?></th>
|
35 |
+
<th><?php _e( 'Token', 'woo-stripe-payment' ); ?></th>
|
36 |
+
<th><?php _e( 'Actions', 'woo-stripe-payment' ); ?></th>
|
37 |
+
</tr>
|
38 |
+
</thead>
|
39 |
+
<tbody>
|
40 |
+
<?php foreach ( $payment_methods['live'] as $token ) : ?>
|
41 |
+
<tr>
|
42 |
+
<td><?php echo $token->get_gateway_id(); ?></td>
|
43 |
+
<td><?php echo $token->get_payment_method_title(); ?></td>
|
44 |
+
<td><?php echo $token->get_token(); ?></td>
|
45 |
+
<td><input type="checkbox" name="payment_methods[live][]"
|
46 |
+
value="<?php echo $token->get_id(); ?>" /></td>
|
47 |
+
</tr>
|
48 |
+
<?php endforeach; ?>
|
49 |
+
<tr>
|
50 |
+
<th><?php _e( 'Action', 'delete' ); ?></th>
|
51 |
+
<td><select name="live_payment_method_actions">
|
52 |
+
<option value="none" selected><?php _e( 'No Action', 'woo-stripe-payment' ); ?></option>
|
53 |
+
<option value="delete"><?php _e( 'Delete', 'woo-stripe-payment' ); ?></option>
|
54 |
+
</select></td>
|
55 |
+
</tr>
|
56 |
+
</tbody>
|
57 |
+
</table>
|
58 |
+
<?php else : ?>
|
59 |
+
<?php _e( 'No live payment methods saved', 'woo-stripe-payment' ); ?>
|
60 |
+
<?php endif; ?>
|
61 |
+
<h2><?php _e( 'Stripe Test Payment Methods', 'woo-stripe-payment' ); ?></h2>
|
62 |
+
<?php if ( $payment_methods['test'] ) : ?>
|
63 |
+
<table class="wc-stripe-payment-methods">
|
64 |
+
<thead>
|
65 |
+
<tr>
|
66 |
+
<th><?php _e( 'Payment Gateway', 'woo-stripe-payment' ); ?></th>
|
67 |
+
<th><?php _e( 'Payment Method', 'woo-stripe-payment' ); ?></th>
|
68 |
+
<th><?php _e( 'Token', 'woo-stripe-payment' ); ?></th>
|
69 |
+
<th><?php _e( 'Actions', 'woo-stripe-payment' ); ?></th>
|
70 |
+
</tr>
|
71 |
+
</thead>
|
72 |
+
<tbody>
|
73 |
+
<?php foreach ( $payment_methods['test'] as $token ) : ?>
|
74 |
+
<tr>
|
75 |
+
<td><?php echo $token->get_gateway_id(); ?></td>
|
76 |
+
<td><?php echo $token->get_payment_method_title(); ?></td>
|
77 |
+
<td><?php echo $token->get_token(); ?></td>
|
78 |
+
<td><input type="checkbox" name="payment_methods[test][]"
|
79 |
+
value="<?php echo $token->get_id(); ?>" /></td>
|
80 |
+
</tr>
|
81 |
+
<?php endforeach; ?>
|
82 |
+
<tr>
|
83 |
+
<th><?php _e( 'Action', 'delete' ); ?></th>
|
84 |
+
<td><select name="test_payment_method_actions">
|
85 |
+
<option value="none" selected><?php _e( 'No Action', 'woo-stripe-payment' ); ?></option>
|
86 |
+
<option value="delete"><?php _e( 'Delete', 'woo-stripe-payment' ); ?></option>
|
87 |
+
</select></td>
|
88 |
+
</tr>
|
89 |
+
</tbody>
|
90 |
+
</table>
|
91 |
+
<?php else : ?>
|
92 |
+
<?php _e( 'No test payment methods saved', 'woo-stripe-payment' ); ?>
|
93 |
+
<?php endif; ?>
|
94 |
+
<?php printf( __( '%1$snote:%2$s payment methods will be deleted in Stripe if you use the delete action.', 'woo-stripe-payment' ), '<strong>', '</strong>' ); ?>
|
95 |
+
</div>
|
includes/class-stripe.php
CHANGED
@@ -1,295 +1,304 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Singleton class that handles plugin functionality like class loading.
|
6 |
-
*
|
7 |
-
* @since 3.0.0
|
8 |
-
* @author PaymentPlugins
|
9 |
-
* @package Stripe/Classes
|
10 |
-
*
|
11 |
-
*/
|
12 |
-
class WC_Stripe_Manager {
|
13 |
-
|
14 |
-
public static $_instance;
|
15 |
-
|
16 |
-
public static function instance() {
|
17 |
-
if (self::$_instance == null) {
|
18 |
-
self::$_instance = new self
|
19 |
-
}
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
*
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
*
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
*
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
*
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
*
|
50 |
-
*
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
*
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
*
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
add_action
|
71 |
-
) );
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/admin/class-wc-stripe-admin-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/wc-stripe-
|
145 |
-
|
146 |
-
//
|
147 |
-
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/
|
152 |
-
|
153 |
-
// load
|
154 |
-
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/
|
155 |
-
|
156 |
-
|
157 |
-
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/
|
158 |
-
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/
|
159 |
-
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/gateways/class-wc-payment-gateway-stripe-
|
160 |
-
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/gateways/class-wc-payment-gateway-stripe-
|
161 |
-
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/gateways/class-wc-payment-gateway-stripe-
|
162 |
-
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/gateways/class-wc-payment-gateway-stripe-
|
163 |
-
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/gateways/class-wc-payment-gateway-stripe-
|
164 |
-
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/gateways/class-wc-payment-gateway-stripe-
|
165 |
-
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/gateways/class-wc-payment-gateway-stripe-
|
166 |
-
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/gateways/class-wc-payment-gateway-stripe-
|
167 |
-
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/gateways/class-wc-payment-gateway-stripe-
|
168 |
-
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/gateways/class-wc-payment-gateway-stripe-
|
169 |
-
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/gateways/class-wc-payment-gateway-stripe-
|
170 |
-
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/gateways/class-wc-payment-gateway-stripe-
|
171 |
-
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/gateways/class-wc-payment-gateway-stripe-
|
172 |
-
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/gateways/class-wc-payment-gateway-stripe-
|
173 |
-
|
174 |
-
|
175 |
-
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/
|
176 |
-
|
177 |
-
|
178 |
-
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/
|
179 |
-
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/tokens/class-wc-payment-token-stripe-
|
180 |
-
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/tokens/class-wc-payment-token-stripe-
|
181 |
-
|
182 |
-
|
183 |
-
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/
|
184 |
-
|
185 |
-
|
186 |
-
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/class-wc-stripe-
|
187 |
-
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/class-wc-stripe-
|
188 |
-
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/class-wc-stripe-
|
189 |
-
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/class-wc-stripe-
|
190 |
-
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/class-wc-stripe-
|
191 |
-
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/class-wc-stripe-
|
192 |
-
|
193 |
-
|
194 |
-
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/
|
195 |
-
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/class-wc-stripe-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
'
|
208 |
-
'
|
209 |
-
'
|
210 |
-
'
|
211 |
-
'
|
212 |
-
'
|
213 |
-
'
|
214 |
-
'
|
215 |
-
'
|
216 |
-
'
|
217 |
-
'
|
218 |
-
'
|
219 |
-
'
|
220 |
-
'
|
221 |
-
'
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
$
|
227 |
-
$this->
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
$setting_classes
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Singleton class that handles plugin functionality like class loading.
|
6 |
+
*
|
7 |
+
* @since 3.0.0
|
8 |
+
* @author PaymentPlugins
|
9 |
+
* @package Stripe/Classes
|
10 |
+
*
|
11 |
+
*/
|
12 |
+
class WC_Stripe_Manager {
|
13 |
+
|
14 |
+
public static $_instance;
|
15 |
+
|
16 |
+
public static function instance() {
|
17 |
+
if ( self::$_instance == null ) {
|
18 |
+
self::$_instance = new self();
|
19 |
+
}
|
20 |
+
|
21 |
+
return self::$_instance;
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
*
|
26 |
+
* @var string
|
27 |
+
*/
|
28 |
+
public $version = '3.1.6';
|
29 |
+
|
30 |
+
/**
|
31 |
+
*
|
32 |
+
* @var WC_Stripe_Settings_API
|
33 |
+
*/
|
34 |
+
public $api_settings;
|
35 |
+
|
36 |
+
/**
|
37 |
+
*
|
38 |
+
* @var WC_Stripe_Rest_API
|
39 |
+
*/
|
40 |
+
public $rest_api;
|
41 |
+
|
42 |
+
/**
|
43 |
+
*
|
44 |
+
* @var string
|
45 |
+
*/
|
46 |
+
public $client_id = 'ca_Gp4vLOJiqHJLZGxakHW7JdbBlcgWK8Up';
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Test client id;
|
50 |
+
*
|
51 |
+
* @var string
|
52 |
+
*/
|
53 |
+
//public $client_id = 'ca_Gp4vL3V6FpTguYoZIehD5COPeI80rLpV';
|
54 |
+
|
55 |
+
/**
|
56 |
+
*
|
57 |
+
* @var WC_Stripe_Frontend_Scripts
|
58 |
+
*/
|
59 |
+
private $scripts;
|
60 |
+
|
61 |
+
/**
|
62 |
+
*
|
63 |
+
* @var array
|
64 |
+
*/
|
65 |
+
private $payment_gateways;
|
66 |
+
|
67 |
+
public function __construct() {
|
68 |
+
add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ), 10 );
|
69 |
+
add_action( 'init', array( $this, 'init' ) );
|
70 |
+
add_action( 'admin_init', array( $this, 'admin_init' ) );
|
71 |
+
add_action( 'woocommerce_init', array( $this, 'woocommerce_dependencies' ) );
|
72 |
+
$this->includes();
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Return the plugin version.
|
77 |
+
*
|
78 |
+
* @return string
|
79 |
+
*/
|
80 |
+
public function version() {
|
81 |
+
return $this->version;
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Return the url for the plugin assets.
|
86 |
+
*
|
87 |
+
* @return string
|
88 |
+
*/
|
89 |
+
public function assets_url( $uri = '' ) {
|
90 |
+
$url = WC_STRIPE_ASSETS . $uri;
|
91 |
+
if ( ! preg_match( '/(\.js)|(\.css)|(\.svg)|(\.png)/', $uri ) ) {
|
92 |
+
return trailingslashit( $url );
|
93 |
+
}
|
94 |
+
|
95 |
+
return $url;
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Return the dir path for the plugin.
|
100 |
+
*
|
101 |
+
* @return string
|
102 |
+
*/
|
103 |
+
public function plugin_path() {
|
104 |
+
return WC_STRIPE_PLUGIN_FILE_PATH;
|
105 |
+
}
|
106 |
+
|
107 |
+
public function plugins_loaded() {
|
108 |
+
load_plugin_textdomain( 'woo-stripe-payment', false, dirname( WC_STRIPE_PLUGIN_NAME ) . '/i18n/languages' );
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* Function that is hooked in to the WordPress init action.
|
113 |
+
*/
|
114 |
+
public function init() {
|
115 |
+
}
|
116 |
+
|
117 |
+
public function includes() {
|
118 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/class-wc-stripe-install.php';
|
119 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/class-wc-stripe-update.php';
|
120 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/class-wc-stripe-rest-api.php';
|
121 |
+
|
122 |
+
if ( is_admin() ) {
|
123 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/admin/class-wc-stripe-admin-menus.php';
|
124 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/admin/class-wc-stripe-admin-assets.php';
|
125 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/admin/class-wc-stripe-admin-settings.php';
|
126 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/admin/meta-boxes/class-wc-stripe-admin-order-metaboxes.php';
|
127 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/admin/meta-boxes/class-wc-stripe-admin-meta-box-product-data.php';
|
128 |
+
}
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Function that is hooked in to the WordPress admin_init action.
|
133 |
+
*/
|
134 |
+
public function admin_init() {
|
135 |
+
}
|
136 |
+
|
137 |
+
public function woocommerce_dependencies() {
|
138 |
+
// load functions
|
139 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/wc-stripe-functions.php';
|
140 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/wc-stripe-webhook-functions.php';
|
141 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/wc-stripe-hooks.php';
|
142 |
+
|
143 |
+
// constants
|
144 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/class-wc-stripe-constants.php';
|
145 |
+
|
146 |
+
// traits
|
147 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/traits/wc-stripe-settings-trait.php';
|
148 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/traits/wc-stripe-controller-cart-trait.php';
|
149 |
+
|
150 |
+
// load factories
|
151 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/class-wc-stripe-payment-factory.php';
|
152 |
+
|
153 |
+
// load gateways
|
154 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/abstract/abstract-wc-payment-gateway-stripe.php';
|
155 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php';
|
156 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/gateways/class-wc-payment-gateway-stripe-cc.php';
|
157 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/gateways/class-wc-payment-gateway-stripe-applepay.php';
|
158 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/gateways/class-wc-payment-gateway-stripe-googlepay.php';
|
159 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/gateways/class-wc-payment-gateway-stripe-ach.php';
|
160 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/gateways/class-wc-payment-gateway-stripe-payment-request.php';
|
161 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/gateways/class-wc-payment-gateway-stripe-ideal.php';
|
162 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/gateways/class-wc-payment-gateway-stripe-p24.php';
|
163 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/gateways/class-wc-payment-gateway-stripe-klarna.php';
|
164 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/gateways/class-wc-payment-gateway-stripe-giropay.php';
|
165 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/gateways/class-wc-payment-gateway-stripe-eps.php';
|
166 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/gateways/class-wc-payment-gateway-stripe-multibanco.php';
|
167 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/gateways/class-wc-payment-gateway-stripe-sepa.php';
|
168 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/gateways/class-wc-payment-gateway-stripe-sofort.php';
|
169 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/gateways/class-wc-payment-gateway-stripe-wechat.php';
|
170 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/gateways/class-wc-payment-gateway-stripe-bancontact.php';
|
171 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/gateways/class-wc-payment-gateway-stripe-fpx.php';
|
172 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/gateways/class-wc-payment-gateway-stripe-alipay.php';
|
173 |
+
|
174 |
+
// tokens
|
175 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/abstract/abstract-wc-payment-token-stripe.php';
|
176 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/tokens/class-wc-payment-token-stripe-cc.php';
|
177 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/tokens/class-wc-payment-token-stripe-applepay.php';
|
178 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/tokens/class-wc-payment-token-stripe-googlepay.php';
|
179 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/tokens/class-wc-payment-token-stripe-local-payment.php';
|
180 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/tokens/class-wc-payment-token-stripe-ach.php';
|
181 |
+
|
182 |
+
// main classes
|
183 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/class-wc-stripe-frontend-scripts.php';
|
184 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/class-wc-stripe-field-manager.php';
|
185 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/class-wc-stripe-rest-api.php';
|
186 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/class-wc-stripe-gateway.php';
|
187 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/class-wc-stripe-customer-manager.php';
|
188 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/class-wc-stripe-gateway-conversions.php';
|
189 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/class-wc-stripe-frontend-notices.php';
|
190 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/class-wc-stripe-redirect-handler.php';
|
191 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/class-wc-stripe-product-gateway-option.php';
|
192 |
+
|
193 |
+
// settings
|
194 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/abstract/abstract-wc-stripe-settings.php';
|
195 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/admin/settings/class-wc-stripe-api-settings.php';
|
196 |
+
|
197 |
+
if ( is_admin() ) {
|
198 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/admin/class-wc-stripe-admin-notices.php';
|
199 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/admin/class-wc-stripe-admin-user-edit.php';
|
200 |
+
}
|
201 |
+
|
202 |
+
$this->payment_gateways = apply_filters(
|
203 |
+
'wc_stripe_payment_gateways',
|
204 |
+
array(
|
205 |
+
'WC_Payment_Gateway_Stripe_CC',
|
206 |
+
'WC_Payment_Gateway_Stripe_ApplePay',
|
207 |
+
'WC_Payment_Gateway_Stripe_GooglePay',
|
208 |
+
'WC_Payment_Gateway_Stripe_Payment_Request',
|
209 |
+
'WC_Payment_Gateway_Stripe_ACH',
|
210 |
+
'WC_Payment_Gateway_Stripe_Ideal',
|
211 |
+
'WC_Payment_Gateway_Stripe_P24',
|
212 |
+
'WC_Payment_Gateway_Stripe_Klarna',
|
213 |
+
'WC_Payment_Gateway_Stripe_Bancontact',
|
214 |
+
'WC_Payment_Gateway_Stripe_Giropay',
|
215 |
+
'WC_Payment_Gateway_Stripe_EPS',
|
216 |
+
'WC_Payment_Gateway_Stripe_Multibanco',
|
217 |
+
'WC_Payment_Gateway_Stripe_Sepa',
|
218 |
+
'WC_Payment_Gateway_Stripe_Sofort',
|
219 |
+
'WC_Payment_Gateway_Stripe_WeChat',
|
220 |
+
'WC_Payment_Gateway_Stripe_FPX',
|
221 |
+
'WC_Payment_Gateway_Stripe_Alipay',
|
222 |
+
)
|
223 |
+
);
|
224 |
+
|
225 |
+
$api_class = apply_filters( 'wc_stripe_rest_api_class', 'WC_Stripe_Rest_API' );
|
226 |
+
$this->rest_api = new $api_class();
|
227 |
+
$this->scripts = new WC_Stripe_Frontend_Scripts();
|
228 |
+
|
229 |
+
// allow other plugins to provide their own settings classes.
|
230 |
+
$setting_classes = apply_filters( 'wc_stripe_setting_classes', array( 'api_settings' => 'WC_Stripe_API_Settings' ) );
|
231 |
+
foreach ( $setting_classes as $id => $class_name ) {
|
232 |
+
if ( class_exists( $class_name ) ) {
|
233 |
+
$this->{$id} = new $class_name();
|
234 |
+
}
|
235 |
+
}
|
236 |
+
}
|
237 |
+
|
238 |
+
/**
|
239 |
+
* Return the plugin template path.
|
240 |
+
*/
|
241 |
+
public function template_path() {
|
242 |
+
return 'woo-stripe-payment';
|
243 |
+
}
|
244 |
+
|
245 |
+
/**
|
246 |
+
* Return the plguins default directory path for template files.
|
247 |
+
*/
|
248 |
+
public function default_template_path() {
|
249 |
+
return WC_STRIPE_PLUGIN_FILE_PATH . 'templates/';
|
250 |
+
}
|
251 |
+
|
252 |
+
/**
|
253 |
+
*
|
254 |
+
* @return string
|
255 |
+
*/
|
256 |
+
public function rest_uri() {
|
257 |
+
return 'wc-stripe/v1/';
|
258 |
+
}
|
259 |
+
|
260 |
+
/**
|
261 |
+
*
|
262 |
+
* @return string
|
263 |
+
*/
|
264 |
+
public function rest_url() {
|
265 |
+
return get_rest_url( null, $this->rest_uri() );
|
266 |
+
}
|
267 |
+
|
268 |
+
/**
|
269 |
+
*
|
270 |
+
* @return WC_Stripe_Frontend_Scripts
|
271 |
+
*/
|
272 |
+
public function scripts() {
|
273 |
+
return $this->scripts;
|
274 |
+
}
|
275 |
+
|
276 |
+
public function payment_gateways() {
|
277 |
+
return $this->payment_gateways;
|
278 |
+
}
|
279 |
+
|
280 |
+
/**
|
281 |
+
* Schedule actions required by the plugin
|
282 |
+
* @since 3.1.6
|
283 |
+
*/
|
284 |
+
public function scheduled_actions() {
|
285 |
+
if ( function_exists( 'WC' ) ) {
|
286 |
+
if ( ! WC()->queue()->get_next( 'wc_stripe_remove_order_locks' ) ) {
|
287 |
+
WC()->queue()->schedule_recurring( strtotime( 'today midnight' ), DAY_IN_SECONDS, 'wc_stripe_remove_order_locks' );
|
288 |
+
}
|
289 |
+
}
|
290 |
+
}
|
291 |
+
}
|
292 |
+
|
293 |
+
/**
|
294 |
+
* Returns the global instance of the WC_Stripe_Manager.
|
295 |
+
*
|
296 |
+
* @return WC_Stripe_Manager
|
297 |
+
* @package Stripe/Functions
|
298 |
+
*/
|
299 |
+
function wc_stripe() {
|
300 |
+
return WC_Stripe_Manager::instance();
|
301 |
+
}
|
302 |
+
|
303 |
+
// load singleton
|
304 |
+
wc_stripe();
|
includes/class-wc-stripe-api-operation.php
ADDED
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Used as a wrapper for API requests to Stripe.
|
6 |
+
* Allows method chaining so things like mode can
|
7 |
+
* be set intuitively.
|
8 |
+
*
|
9 |
+
* @package Stripe/Classes
|
10 |
+
* @author PaymentPlugins
|
11 |
+
* @since 3.1.6
|
12 |
+
*/
|
13 |
+
class WC_Stripe_API_Operation {
|
14 |
+
|
15 |
+
/**
|
16 |
+
*
|
17 |
+
* @var \Stripe\StripeClient
|
18 |
+
*/
|
19 |
+
private $client;
|
20 |
+
|
21 |
+
/**
|
22 |
+
*
|
23 |
+
* @var string
|
24 |
+
*/
|
25 |
+
private $property;
|
26 |
+
|
27 |
+
/**
|
28 |
+
*
|
29 |
+
* @var \Stripe\Service\AbstractService
|
30 |
+
*/
|
31 |
+
private $service;
|
32 |
+
|
33 |
+
/**
|
34 |
+
*
|
35 |
+
* @var WC_Stripe_Gateway
|
36 |
+
*/
|
37 |
+
private $gateway;
|
38 |
+
|
39 |
+
/**
|
40 |
+
*
|
41 |
+
* @var string
|
42 |
+
*/
|
43 |
+
private $mode = '';
|
44 |
+
|
45 |
+
/**
|
46 |
+
*
|
47 |
+
* @param WC_Stripe_Gateway $gateway
|
48 |
+
* @param \Stripe\StripeClient $client
|
49 |
+
* @param string $property
|
50 |
+
*
|
51 |
+
* @throws InvalidArgumentException
|
52 |
+
*/
|
53 |
+
public function __construct( $gateway, $client, $property ) {
|
54 |
+
$this->client = $client;
|
55 |
+
$this->property = $property;
|
56 |
+
$this->gateway = $gateway;
|
57 |
+
|
58 |
+
$service = $this->client->__get( $property );
|
59 |
+
|
60 |
+
if ( ! $service ) {
|
61 |
+
throw new InvalidArgumentException( sprintf( 'Property %s is not a valid entry', $property ) );
|
62 |
+
}
|
63 |
+
|
64 |
+
$this->service = $service;
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Wrapper for Stripe API operations.
|
69 |
+
* This way, all exceptions can be caught gracefully.
|
70 |
+
*
|
71 |
+
* @param string $method
|
72 |
+
* @param array $args
|
73 |
+
*
|
74 |
+
* @throws InvalidArgumentException
|
75 |
+
*/
|
76 |
+
public function __call( $method, $args ) {
|
77 |
+
if ( ! method_exists( $this->service, $method ) ) {
|
78 |
+
throw new InvalidArgumentException( sprintf( 'Method %s does not exist for class %s.', $method, get_class( $this->service ) ) );
|
79 |
+
}
|
80 |
+
$args = $this->parse_args( $args, $method );
|
81 |
+
try {
|
82 |
+
/**
|
83 |
+
* Filters arguments before they are sent to the service for an API request.
|
84 |
+
*
|
85 |
+
* @param array $args The array of arguments that will be passed to the service method.
|
86 |
+
* @param string $property The name of the service being called.
|
87 |
+
* @param string $method The method of the service. Ex: create, delete, retrieve
|
88 |
+
*
|
89 |
+
* @since 3.1.6
|
90 |
+
*/
|
91 |
+
$args = apply_filters( 'wc_stripe_api_request_args', $args, $this->property, $method );
|
92 |
+
|
93 |
+
return $this->service->{$method}( ...$args );
|
94 |
+
} catch ( \Stripe\Exception\ApiErrorException $e ) {
|
95 |
+
return $this->gateway->get_wp_error( $e, $this->property . '-error' );
|
96 |
+
} catch ( \Stripe\Exception\UnexpectedValueException $e ) {
|
97 |
+
return new WP_Error( 'stripe-error', $e->getMessage(), $e );
|
98 |
+
}
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
*
|
103 |
+
* @param string $mode
|
104 |
+
*
|
105 |
+
* @return $this
|
106 |
+
*/
|
107 |
+
public function mode( $mode ) {
|
108 |
+
$this->mode = $mode;
|
109 |
+
|
110 |
+
return $this;
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Given an array of arguments, add method defaults to the array of args based on their existance.
|
115 |
+
*
|
116 |
+
* @param array $args
|
117 |
+
* @param string $method
|
118 |
+
*/
|
119 |
+
private function parse_args( $args, $method ) {
|
120 |
+
$reflection_method = new ReflectionMethod( get_class( $this->service ), $method );
|
121 |
+
$num_args = $reflection_method->getNumberOfParameters();
|
122 |
+
|
123 |
+
// loop through each
|
124 |
+
foreach ( $reflection_method->getParameters() as $parameter ) {
|
125 |
+
if ( ! isset( $args[ $parameter->getPosition() ] ) && $parameter->isOptional() ) {
|
126 |
+
$args[ $parameter->getPosition() ] = $parameter->getDefaultValue();
|
127 |
+
}
|
128 |
+
}
|
129 |
+
// merge options
|
130 |
+
$args[ $num_args - 1 ] = wp_parse_args( $args[ $num_args - 1 ], $this->gateway->get_api_options( $this->mode ) );
|
131 |
+
|
132 |
+
return $args;
|
133 |
+
}
|
134 |
+
}
|
includes/class-wc-stripe-constants.php
CHANGED
@@ -1,46 +1,46 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
/**
|
5 |
-
*
|
6 |
-
* @since 3.1.0
|
7 |
-
* @author Payment Plugins
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
class WC_Stripe_Constants {
|
11 |
-
|
12 |
-
const CUSTOMER_ID = '_wc_stripe_customer';
|
13 |
-
|
14 |
-
const PAYMENT_METHOD_TOKEN = '_payment_method_token';
|
15 |
-
|
16 |
-
const PAYMENT_INTENT_ID = '_payment_intent_id';
|
17 |
-
|
18 |
-
const PAYMENT_INTENT = '_payment_intent';
|
19 |
-
|
20 |
-
const MODE = '_wc_stripe_mode';
|
21 |
-
|
22 |
-
const CHARGE_STATUS = '_wc_stripe_charge_status';
|
23 |
-
|
24 |
-
const SOURCE_ID = '_stripe_source_id';
|
25 |
-
|
26 |
-
const STRIPE_INTENT_ID = '_stripe_intent_id';
|
27 |
-
|
28 |
-
const STRIPE_CUSTOMER_ID = '_stripe_customer_id';
|
29 |
-
|
30 |
-
const SUCCESS = 'success';
|
31 |
-
|
32 |
-
const FAILURE = 'failure';
|
33 |
-
|
34 |
-
const WOOCOMMERCE_STRIPE_ORDER_PAY = 'WOOCOMMERCE_STRIPE_ORDER_PAY';
|
35 |
-
|
36 |
-
const PRODUCT_GATEWAY_ORDER = '_stripe_gateway_order';
|
37 |
-
|
38 |
-
const BUTTON_POSITION = '_stripe_button_position';
|
39 |
-
|
40 |
-
/**
|
41 |
-
*
|
42 |
-
* @since 3.1.3
|
43 |
-
* @var unknown
|
44 |
-
*/
|
45 |
-
const REDIRECT_HANDLER = 'redirect_handler';
|
46 |
-
}
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
/**
|
5 |
+
*
|
6 |
+
* @since 3.1.0
|
7 |
+
* @author Payment Plugins
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
class WC_Stripe_Constants {
|
11 |
+
|
12 |
+
const CUSTOMER_ID = '_wc_stripe_customer';
|
13 |
+
|
14 |
+
const PAYMENT_METHOD_TOKEN = '_payment_method_token';
|
15 |
+
|
16 |
+
const PAYMENT_INTENT_ID = '_payment_intent_id';
|
17 |
+
|
18 |
+
const PAYMENT_INTENT = '_payment_intent';
|
19 |
+
|
20 |
+
const MODE = '_wc_stripe_mode';
|
21 |
+
|
22 |
+
const CHARGE_STATUS = '_wc_stripe_charge_status';
|
23 |
+
|
24 |
+
const SOURCE_ID = '_stripe_source_id';
|
25 |
+
|
26 |
+
const STRIPE_INTENT_ID = '_stripe_intent_id';
|
27 |
+
|
28 |
+
const STRIPE_CUSTOMER_ID = '_stripe_customer_id';
|
29 |
+
|
30 |
+
const SUCCESS = 'success';
|
31 |
+
|
32 |
+
const FAILURE = 'failure';
|
33 |
+
|
34 |
+
const WOOCOMMERCE_STRIPE_ORDER_PAY = 'WOOCOMMERCE_STRIPE_ORDER_PAY';
|
35 |
+
|
36 |
+
const PRODUCT_GATEWAY_ORDER = '_stripe_gateway_order';
|
37 |
+
|
38 |
+
const BUTTON_POSITION = '_stripe_button_position';
|
39 |
+
|
40 |
+
/**
|
41 |
+
*
|
42 |
+
* @since 3.1.3
|
43 |
+
* @var unknown
|
44 |
+
*/
|
45 |
+
const REDIRECT_HANDLER = 'redirect_handler';
|
46 |
+
}
|
includes/class-wc-stripe-customer-manager.php
CHANGED
@@ -1,182 +1,195 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Class that manages customer creation and custom updates.
|
6 |
-
*
|
7 |
-
* @since 3.0.0
|
8 |
-
* @package Stripe/Classes
|
9 |
-
* @author PaymentPlugins
|
10 |
-
*
|
11 |
-
*/
|
12 |
-
class WC_Stripe_Customer_Manager {
|
13 |
-
|
14 |
-
public function __construct() {
|
15 |
-
add_action
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
'
|
59 |
-
'
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
$
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
*
|
174 |
-
*
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Class that manages customer creation and custom updates.
|
6 |
+
*
|
7 |
+
* @since 3.0.0
|
8 |
+
* @package Stripe/Classes
|
9 |
+
* @author PaymentPlugins
|
10 |
+
*
|
11 |
+
*/
|
12 |
+
class WC_Stripe_Customer_Manager {
|
13 |
+
|
14 |
+
public function __construct() {
|
15 |
+
add_action( 'woocommerce_checkout_update_customer', array( $this, 'checkout_update_customer' ), 10, 2 );
|
16 |
+
add_action( 'wp_loaded', array( $this, 'wp_loaded' ) );
|
17 |
+
}
|
18 |
+
|
19 |
+
/**
|
20 |
+
*
|
21 |
+
* @param WC_Customer $customer
|
22 |
+
* @param array $data
|
23 |
+
*/
|
24 |
+
public function checkout_update_customer( $customer, $data ) {
|
25 |
+
if ( $this->user_has_id( $customer ) ) {
|
26 |
+
if ( $this->should_update_customer( $customer ) ) {
|
27 |
+
$result = $this->update_customer( $customer );
|
28 |
+
if ( is_wp_error( $result ) ) {
|
29 |
+
wc_add_notice( __( 'Error saving customer. Reason: %s', 'woo-stripe-payment' ), $result->get_error_message() );
|
30 |
+
}
|
31 |
+
}
|
32 |
+
} else {
|
33 |
+
// create the customer
|
34 |
+
$response = $this->create_customer( $customer );
|
35 |
+
if ( ! is_wp_error( $response ) ) {
|
36 |
+
wc_stripe_save_customer( $response->id, $customer->get_id() );
|
37 |
+
} else {
|
38 |
+
wc_add_notice( __( 'Error saving customer. Reason: %s', 'woo-stripe-payment' ), $response->get_error_message() );
|
39 |
+
}
|
40 |
+
}
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
*
|
45 |
+
* @param WC_Customer $customer
|
46 |
+
*
|
47 |
+
* @return \Stripe\Customer|WP_Error
|
48 |
+
*/
|
49 |
+
private function create_customer( $customer ) {
|
50 |
+
return WC_Stripe_Gateway::load()->customers->create(
|
51 |
+
apply_filters(
|
52 |
+
'wc_stripe_customer_args',
|
53 |
+
array(
|
54 |
+
'email' => $customer->get_email(),
|
55 |
+
'name' => sprintf( '%s %s', $customer->get_first_name(), $customer->get_last_name() ),
|
56 |
+
'phone' => $customer->get_billing_phone(),
|
57 |
+
'metadata' => array(
|
58 |
+
'user_id' => $customer->get_id(),
|
59 |
+
'username' => $customer->get_username(),
|
60 |
+
'website' => get_site_url(),
|
61 |
+
),
|
62 |
+
)
|
63 |
+
)
|
64 |
+
);
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
*
|
69 |
+
* @param WC_Customer $customer
|
70 |
+
*/
|
71 |
+
private function update_customer( $customer ) {
|
72 |
+
return WC_Stripe_Gateway::load()->customers->update(
|
73 |
+
wc_stripe_get_customer_id( $customer->get_id() ),
|
74 |
+
apply_filters( 'wc_stripe_update_customer_args', array(
|
75 |
+
'email' => $customer->get_billing_email(),
|
76 |
+
'name' => sprintf( '%s %s', $customer->get_billing_first_name(), $customer->get_billing_last_name() ),
|
77 |
+
'phone' => $customer->get_billing_phone(),
|
78 |
+
) )
|
79 |
+
);
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Check if the Stripe customer has been created for the WC user.
|
84 |
+
* If there is no Stripe customer then
|
85 |
+
* create one and save it to the WC user.
|
86 |
+
*/
|
87 |
+
public function wp_loaded() {
|
88 |
+
$customer = WC()->customer;
|
89 |
+
if ( $customer && $customer->get_id() ) {
|
90 |
+
if ( ! $this->user_has_id( $customer ) ) {
|
91 |
+
$response = $this->create_customer( $customer );
|
92 |
+
if ( ! is_wp_error( $response ) ) {
|
93 |
+
wc_stripe_save_customer( $response->id, $customer->get_id() );
|
94 |
+
}
|
95 |
+
}
|
96 |
+
}
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
*
|
101 |
+
* @param WC_Customer $customer
|
102 |
+
*/
|
103 |
+
private function user_has_id( $customer ) {
|
104 |
+
$id = wc_stripe_get_customer_id( $customer->get_id() );
|
105 |
+
|
106 |
+
// this customer may have an ID from another plugin. Check that too.
|
107 |
+
if ( empty( $id ) ) {
|
108 |
+
$id = get_user_option( '_stripe_customer_id', $customer->get_id() );
|
109 |
+
if ( ! empty( $id ) ) {
|
110 |
+
// validate that this customer exists in the Stripe gateway
|
111 |
+
$response = WC_Stripe_Gateway::load()->customers->retrieve( $id );
|
112 |
+
if ( ! is_wp_error( $response ) ) {
|
113 |
+
// id exists so save customer ID to this plugin's format.
|
114 |
+
wc_stripe_save_customer( $id, $customer->get_id() );
|
115 |
+
|
116 |
+
// load this customer's payment methods
|
117 |
+
$this->sync_payment_methods( $id, $customer->get_id() );
|
118 |
+
} else {
|
119 |
+
$id = '';
|
120 |
+
}
|
121 |
+
}
|
122 |
+
}
|
123 |
+
|
124 |
+
return ! empty( $id );
|
125 |
+
}
|
126 |
+
|
127 |
+
/**
|
128 |
+
* Syncs the WC database payment methods with the payment methods stored in Stripe.
|
129 |
+
*
|
130 |
+
* @param string $customer_id
|
131 |
+
* @param int $user_id
|
132 |
+
*
|
133 |
+
* @since 3.1.0
|
134 |
+
*/
|
135 |
+
public static function sync_payment_methods( $customer_id, $user_id, $mode = '' ) {
|
136 |
+
$payment_methods = WC_Stripe_Gateway::load()->paymentMethods->mode( $mode )->all( array(
|
137 |
+
'customer' => $customer_id,
|
138 |
+
'type' => 'card',
|
139 |
+
) );
|
140 |
+
|
141 |
+
if ( ! is_wp_error( $payment_methods ) ) {
|
142 |
+
foreach ( $payment_methods->data as $payment_method ) {
|
143 |
+
if ( ! WC_Payment_Token_Stripe::token_exists( $payment_method->id, $user_id ) ) {
|
144 |
+
$payment_gateways = WC()->payment_gateways()->payment_gateways();
|
145 |
+
$gateway_id = null;
|
146 |
+
|
147 |
+
if ( strstr( $payment_method->id, 'pm_' ) || strstr( $payment_method->id, 'src_' ) ) {
|
148 |
+
$gateway_id = 'stripe_cc';
|
149 |
+
} elseif ( strstr( $payment_method->id, 'card_' ) ) {
|
150 |
+
$gateway_id = 'stripe_googlepay';
|
151 |
+
}
|
152 |
+
/**
|
153 |
+
*
|
154 |
+
* @var WC_Payment_Gateway_Stripe_CC $payment_gateway
|
155 |
+
*/
|
156 |
+
$payment_gateway = $payment_gateways[ $gateway_id ];
|
157 |
+
$token = $payment_gateway->get_payment_token( $payment_method->id, $payment_method );
|
158 |
+
$token->set_environment( $payment_method->livemode ? 'live' : 'test' );
|
159 |
+
$token->set_user_id( $user_id );
|
160 |
+
$token->set_customer_id( $customer_id );
|
161 |
+
$token->save();
|
162 |
+
}
|
163 |
+
}
|
164 |
+
} else {
|
165 |
+
wc_stripe_log_info( sprintf( 'Payment methods for customer %s could not be synced. Reason: %s', $customer_id, $payment_methods->get_error_message() ) );
|
166 |
+
}
|
167 |
+
}
|
168 |
+
|
169 |
+
/**
|
170 |
+
* Returns true if the customer should be updated in Stripe.
|
171 |
+
*
|
172 |
+
* @param WC_Customer $customer
|
173 |
+
*
|
174 |
+
* @return bool
|
175 |
+
*/
|
176 |
+
private function should_update_customer( $customer ) {
|
177 |
+
$changes = $customer->get_changes();
|
178 |
+
if ( ! empty( $changes['billing'] ) ) {
|
179 |
+
return array_intersect_key( $changes['billing'], array_flip( $this->get_attribute_keys() ) );
|
180 |
+
}
|
181 |
+
|
182 |
+
return false;
|
183 |
+
}
|
184 |
+
|
185 |
+
/**
|
186 |
+
* Returns an array of user attributes.
|
187 |
+
*
|
188 |
+
* @return array
|
189 |
+
*/
|
190 |
+
private function get_attribute_keys() {
|
191 |
+
return array( 'first_name', 'last_name', 'email' );
|
192 |
+
}
|
193 |
+
}
|
194 |
+
|
195 |
+
new WC_Stripe_Customer_Manager();
|
includes/class-wc-stripe-field-manager.php
CHANGED
@@ -1,246 +1,256 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
/**
|
5 |
-
*
|
6 |
-
* @since 3.0.0
|
7 |
-
* @package Stripe/Classes
|
8 |
-
* @author Payment Plugins
|
9 |
-
*
|
10 |
-
*/
|
11 |
-
class WC_Stripe_Field_Manager {
|
12 |
-
|
13 |
-
private static $_cart_priority = 30;
|
14 |
-
|
15 |
-
private static $_product_button_position;
|
16 |
-
|
17 |
-
public static function init() {
|
18 |
-
add_action
|
19 |
-
|
20 |
-
) );
|
21 |
-
add_action
|
22 |
-
|
23 |
-
) );
|
24 |
-
add_action
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
}
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
self::
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
'
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
}
|
220 |
-
}
|
221 |
-
|
222 |
-
public static function
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
/**
|
5 |
+
*
|
6 |
+
* @since 3.0.0
|
7 |
+
* @package Stripe/Classes
|
8 |
+
* @author Payment Plugins
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
class WC_Stripe_Field_Manager {
|
12 |
+
|
13 |
+
private static $_cart_priority = 30;
|
14 |
+
|
15 |
+
private static $_product_button_position;
|
16 |
+
|
17 |
+
public static function init() {
|
18 |
+
add_action( 'woocommerce_checkout_before_customer_details', array( __CLASS__, 'output_banner_checkout_fields' ) );
|
19 |
+
add_action( 'woocommerce_before_add_to_cart_form', array( __CLASS__, 'before_add_to_cart' ) );
|
20 |
+
add_action( 'init', array( __CLASS__, 'init_action' ) );
|
21 |
+
add_action( 'woocommerce_review_order_after_order_total', array( __CLASS__, 'output_checkout_fields' ) );
|
22 |
+
add_action( 'before_woocommerce_add_payment_method', array( __CLASS__, 'add_payment_method_fields' ) );
|
23 |
+
add_action( 'before_woocommerce_pay', array( __CLASS__, 'change_payment_request' ) );
|
24 |
+
add_action( 'woocommerce_pay_order_after_submit', array( __CLASS__, 'pay_order_fields' ) );
|
25 |
+
}
|
26 |
+
|
27 |
+
public static function init_action() {
|
28 |
+
self::$_cart_priority = apply_filters( 'wc_stripe_cart_buttons_order', 30 );
|
29 |
+
add_action( 'woocommerce_proceed_to_checkout', array( __CLASS__, 'output_cart_fields' ), self::$_cart_priority );
|
30 |
+
}
|
31 |
+
|
32 |
+
public static function output_banner_checkout_fields() {
|
33 |
+
$gateways = array();
|
34 |
+
foreach ( WC()->payment_gateways()->get_available_payment_gateways() as $gateway ) {
|
35 |
+
if ( $gateway->supports( 'wc_stripe_banner_checkout' ) && $gateway->banner_checkout_enabled() ) {
|
36 |
+
$gateways[ $gateway->id ] = $gateway;
|
37 |
+
}
|
38 |
+
}
|
39 |
+
if ( $gateways ) {
|
40 |
+
wc_stripe_get_template( 'checkout/checkout-banner.php', array( 'gateways' => $gateways ) );
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
public static function output_checkout_fields() {
|
45 |
+
self::output_required_fields( 'checkout' );
|
46 |
+
|
47 |
+
wp_localize_script(
|
48 |
+
'wc-checkout',
|
49 |
+
'wc_stripe_checkout_fields',
|
50 |
+
array(
|
51 |
+
'billing' => WC()->checkout()->get_checkout_fields( 'billing' ),
|
52 |
+
'shipping' => WC()->checkout()->get_checkout_fields( 'shipping' ),
|
53 |
+
)
|
54 |
+
);
|
55 |
+
|
56 |
+
do_action( 'wc_stripe_output_checkout_fields' );
|
57 |
+
}
|
58 |
+
|
59 |
+
public static function before_add_to_cart() {
|
60 |
+
global $product;
|
61 |
+
self::$_product_button_position = $product->get_meta( WC_Stripe_Constants::BUTTON_POSITION );
|
62 |
+
if ( empty( self::$_product_button_position ) ) {
|
63 |
+
self::$_product_button_position = 'bottom';
|
64 |
+
}
|
65 |
+
|
66 |
+
if ( 'bottom' == self::$_product_button_position ) {
|
67 |
+
$action = 'woocommerce_after_add_to_cart_button';
|
68 |
+
} else {
|
69 |
+
$action = 'woocommerce_before_add_to_cart_button';
|
70 |
+
}
|
71 |
+
add_action( $action, array( __CLASS__, 'output_product_checkout_fields' ) );
|
72 |
+
}
|
73 |
+
|
74 |
+
public static function output_product_checkout_fields() {
|
75 |
+
global $product;
|
76 |
+
$gateways = array();
|
77 |
+
$ordering = $product->get_meta( WC_Stripe_Constants::PRODUCT_GATEWAY_ORDER );
|
78 |
+
$ordering = ! $ordering ? array() : $ordering;
|
79 |
+
|
80 |
+
foreach ( WC()->payment_gateways()->get_available_payment_gateways() as $id => $gateway ) {
|
81 |
+
/**
|
82 |
+
*
|
83 |
+
* @var WC_Payment_Gateway_Stripe $gateway
|
84 |
+
*/
|
85 |
+
if ( $gateway->supports( 'wc_stripe_product_checkout' ) ) {
|
86 |
+
$option = new WC_Stripe_Product_Gateway_Option( $product, $gateway );
|
87 |
+
if ( $option->enabled() ) {
|
88 |
+
if ( isset( $ordering[ $gateway->id ] ) ) {
|
89 |
+
$gateways[ $ordering[ $gateway->id ] ] = $gateway;
|
90 |
+
} else {
|
91 |
+
$gateways[] = $gateway;
|
92 |
+
}
|
93 |
+
}
|
94 |
+
}
|
95 |
+
}
|
96 |
+
ksort( $gateways );
|
97 |
+
|
98 |
+
if ( count( $gateways ) > 0 ) {
|
99 |
+
|
100 |
+
self::output_required_fields( 'product' );
|
101 |
+
|
102 |
+
wc_stripe_get_template(
|
103 |
+
'product/payment-methods.php',
|
104 |
+
array(
|
105 |
+
'position' => self::$_product_button_position,
|
106 |
+
'gateways' => $gateways,
|
107 |
+
)
|
108 |
+
);
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
+
public static function output_cart_fields() {
|
113 |
+
$gateways = array();
|
114 |
+
foreach ( WC()->payment_gateways()->get_available_payment_gateways() as $id => $gateway ) {
|
115 |
+
/**
|
116 |
+
*
|
117 |
+
* @var WC_Payment_Gateway_Stripe $gateway
|
118 |
+
*/
|
119 |
+
if ( $gateway->supports( 'wc_stripe_cart_checkout' ) && $gateway->cart_checkout_enabled() ) {
|
120 |
+
$gateways[ $gateway->id ] = $gateway;
|
121 |
+
}
|
122 |
+
}
|
123 |
+
if ( ! empty( $gateways ) ) {
|
124 |
+
echo '<form id="wc-stripe-cart-form">';
|
125 |
+
|
126 |
+
self::output_required_fields( 'cart' );
|
127 |
+
|
128 |
+
wc_stripe_get_template(
|
129 |
+
'cart/payment-methods.php',
|
130 |
+
array(
|
131 |
+
'gateways' => $gateways,
|
132 |
+
'after' => self::$_cart_priority > 20,
|
133 |
+
'cart_total' => WC()->cart->total,
|
134 |
+
)
|
135 |
+
);
|
136 |
+
echo '</form>';
|
137 |
+
}
|
138 |
+
}
|
139 |
+
|
140 |
+
public static function change_payment_request() {
|
141 |
+
if ( wcs_stripe_active() && WC_Subscriptions_Change_Payment_Gateway::$is_request_to_change_payment ) {
|
142 |
+
$subscription = wcs_get_subscription( absint( $_GET['change_payment_method'] ) );
|
143 |
+
self::output_required_fields( 'checkout', $subscription );
|
144 |
+
}
|
145 |
+
}
|
146 |
+
|
147 |
+
public static function add_payment_method_fields() {
|
148 |
+
wc_stripe_hidden_field( 'billing_first_name', '', WC()->customer->get_first_name() );
|
149 |
+
wc_stripe_hidden_field( 'billing_last_name', '', WC()->customer->get_last_name() );
|
150 |
+
}
|
151 |
+
|
152 |
+
public static function pay_order_fields() {
|
153 |
+
global $wp;
|
154 |
+
$order = wc_get_order( absint( $wp->query_vars['order-pay'] ) );
|
155 |
+
self::output_required_fields( 'checkout', $order );
|
156 |
+
}
|
157 |
+
|
158 |
+
/**
|
159 |
+
* @param string $page
|
160 |
+
* @param WC_Order $order
|
161 |
+
*/
|
162 |
+
public static function output_required_fields( $page, $order = null ) {
|
163 |
+
printf( '<input type="hidden" id="%1$s" value="%2$s"/>', 'wc_stripe_currency', $order ? $order->get_currency() : get_woocommerce_currency() );
|
164 |
+
printf( '<input type="hidden" id="%1$s" data-amount="%2$s"/>', 'wc_stripe_order_total', $order ? $order->get_total() : WC()->cart->total );
|
165 |
+
if ( in_array( $page, array( 'cart', 'checkout' ) ) ) {
|
166 |
+
printf( '<input type="hidden" id="wc_stripe_display_items" data-items="%s"/>', wc_stripe_get_display_items( true, $order ) );
|
167 |
+
printf( '<input type="hidden" id="wc_stripe_shipping_options" data-items="%s"/>', wc_stripe_get_shipping_options( true, $order ) );
|
168 |
+
printf( '<input type="hidden" id="wc_stripe_order_total_cents" data-amount="%s"/>', wc_stripe_add_number_precision( ( $order ? $order->get_total() : WC()->cart->total ), ( $order ? $order->get_currency() : '' ) ) );
|
169 |
+
|
170 |
+
if ( 'cart' === $page ) {
|
171 |
+
self::output_fields( 'billing' );
|
172 |
+
|
173 |
+
if ( WC()->cart->needs_shipping() ) {
|
174 |
+
self::output_needs_shipping( true );
|
175 |
+
self::output_fields( 'shipping' );
|
176 |
+
} else {
|
177 |
+
self::output_needs_shipping( false );
|
178 |
+
}
|
179 |
+
}
|
180 |
+
|
181 |
+
} elseif ( 'product' === $page ) {
|
182 |
+
global $product;
|
183 |
+
|
184 |
+
self::output_fields( 'billing' );
|
185 |
+
|
186 |
+
if ( $product->needs_shipping() ) {
|
187 |
+
self::output_fields( 'shipping' );
|
188 |
+
}
|
189 |
+
printf( '<input type="hidden" id="product_id" name="product_id", value="%s"/>', $product->get_id() );
|
190 |
+
printf(
|
191 |
+
'<input type="hidden" id="wc_stripe_product_data" data-product="%s"/>',
|
192 |
+
htmlspecialchars(
|
193 |
+
wp_json_encode(
|
194 |
+
array(
|
195 |
+
'product_id' => $product->get_id(),
|
196 |
+
'price' => $product->get_price(),
|
197 |
+
'needs_shipping' => $product->needs_shipping(),
|
198 |
+
)
|
199 |
+
)
|
200 |
+
)
|
201 |
+
);
|
202 |
+
printf(
|
203 |
+
'<input type="hidden" id="wc_stripe_display_items" data-items="%s"/>',
|
204 |
+
htmlspecialchars(
|
205 |
+
wp_json_encode(
|
206 |
+
array(
|
207 |
+
array(
|
208 |
+
'amount' => wc_stripe_add_number_precision( $product->get_price() ),
|
209 |
+
'label' => esc_attr( $product->get_name() ),
|
210 |
+
'pending' => true,
|
211 |
+
),
|
212 |
+
)
|
213 |
+
)
|
214 |
+
)
|
215 |
+
);
|
216 |
+
printf( '<input type="hidden" id="wc_stripe_shipping_options" data-items="%s"/>', htmlspecialchars( wp_json_encode( array() ) ) );
|
217 |
+
printf( '<input type="hidden" id="wc_stripe_order_total_cents" data-amount="%s"/>', wc_stripe_add_number_precision( $product->get_price() ) );
|
218 |
+
|
219 |
+
}
|
220 |
+
}
|
221 |
+
|
222 |
+
public static function output_fields( $prefix ) {
|
223 |
+
$fields = WC()->checkout()->get_checkout_fields( $prefix );
|
224 |
+
foreach ( $fields as $key => $field ) {
|
225 |
+
printf( '<input type="hidden" id="%1$s" name="%1$s" value="%2$s"/>', $key, WC()->checkout()->get_value( $key ) );
|
226 |
+
}
|
227 |
+
}
|
228 |
+
|
229 |
+
public static function output_needs_shipping( $needs_shipping ) {
|
230 |
+
printf( '<input type="hidden" id="wc_stripe_needs_shipping" data-value="%s" />', $needs_shipping );
|
231 |
+
}
|
232 |
+
|
233 |
+
/**
|
234 |
+
*
|
235 |
+
* @param array $args
|
236 |
+
*
|
237 |
+
* @deprecated
|
238 |
+
*
|
239 |
+
*/
|
240 |
+
public static function quantity_input_value( $args ) {
|
241 |
+
if ( is_product() ) {
|
242 |
+
foreach ( WC()->payment_gateways()->get_available_payment_gateways() as $id => $gateway ) {
|
243 |
+
if ( $gateway->supports( 'wc_stripe_product_checkout' ) ) {
|
244 |
+
$args['min_value'] = 0;
|
245 |
+
break;
|
246 |
+
}
|
247 |
+
}
|
248 |
+
}
|
249 |
+
|
250 |
+
return $args;
|
251 |
+
}
|
252 |
+
}
|
253 |
+
|
254 |
+
if ( ! is_admin() ) {
|
255 |
+
WC_Stripe_Field_Manager::init();
|
256 |
+
}
|
includes/class-wc-stripe-frontend-notices.php
CHANGED
@@ -1,58 +1,58 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
|
5 |
-
*
|
6 |
-
*
|
7 |
-
* @
|
8 |
-
* @
|
9 |
-
*
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
$
|
22 |
-
$
|
23 |
-
$
|
24 |
-
$
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
$scripts->
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
'
|
54 |
-
|
55 |
-
|
56 |
-
}
|
57 |
-
}
|
58 |
-
WC_Stripe_Frontend_Notices::init
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Class that manages frontend notices for customers.
|
6 |
+
*
|
7 |
+
* @author PaymentPlugins
|
8 |
+
* @package Stripe/Classes
|
9 |
+
* @since 3.0.0
|
10 |
+
*
|
11 |
+
*/
|
12 |
+
class WC_Stripe_Frontend_Notices {
|
13 |
+
|
14 |
+
public static function init() {
|
15 |
+
add_action( 'wp_enqueue_scripts', array( __CLASS__, 'enqueue_scripts' ) );
|
16 |
+
}
|
17 |
+
|
18 |
+
public static function enqueue_scripts() {
|
19 |
+
if ( isset( $wp->query_vars['order-received'] ) ) {
|
20 |
+
$scripts = wc_stripe()->scripts();
|
21 |
+
$order_id = absint( $wp->query_vars['order-received'] );
|
22 |
+
$order = wc_get_order( $order_id );
|
23 |
+
$notices = array();
|
24 |
+
if ( ( $message = $order->get_meta( '_wc_stripe_order_error', true ) ) ) {
|
25 |
+
$notices[] = wc_get_template_html( 'notices/notice.php', array( 'messages' => array( $message ) ) );
|
26 |
+
}
|
27 |
+
if ( $order->has_status( 'on-hold' ) ) {
|
28 |
+
$payment_method = $order->get_payment_method();
|
29 |
+
$gateway = WC()->payment_gateways()->payment_gateways()[ $payment_method ];
|
30 |
+
if ( $gateway instanceof WC_Payment_Gateway_Stripe_Local_Payment ) {
|
31 |
+
$notices[] = wc_get_template_html(
|
32 |
+
'notices/notice.php',
|
33 |
+
array(
|
34 |
+
'messages' => array(
|
35 |
+
__( 'Your payment is being processed and your order status will be updated once the funds are received.', 'woo-stripe-payment' ),
|
36 |
+
),
|
37 |
+
)
|
38 |
+
);
|
39 |
+
}
|
40 |
+
if ( $notices ) {
|
41 |
+
self::enqueue_notices( $notices );
|
42 |
+
}
|
43 |
+
}
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
public static function enqueue_notices( $notices ) {
|
48 |
+
$scripts->enqueue_script( 'notices', $scripts->assets_url( 'js/frontend/notices.js' ), array( 'jquery' ), wc_stripe()->version(), true );
|
49 |
+
$scripts->localize_script(
|
50 |
+
'notices',
|
51 |
+
array(
|
52 |
+
'container' => '.woocommerce-order',
|
53 |
+
'notices' => $notices,
|
54 |
+
)
|
55 |
+
);
|
56 |
+
}
|
57 |
+
}
|
58 |
+
WC_Stripe_Frontend_Notices::init();
|
includes/class-wc-stripe-frontend-scripts.php
CHANGED
@@ -1,148 +1,162 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Handles scrip enqueuement and output of params needed by the plugin.
|
6 |
-
*
|
7 |
-
* @package Stripe/Classes
|
8 |
-
* @author PaymentPlugins
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
add_action
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
$this->
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
'
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
$this->
|
96 |
-
|
97 |
-
}
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
$
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Handles scrip enqueuement and output of params needed by the plugin.
|
6 |
+
*
|
7 |
+
* @package Stripe/Classes
|
8 |
+
* @author PaymentPlugins
|
9 |
+
*/
|
10 |
+
class WC_Stripe_Frontend_Scripts {
|
11 |
+
|
12 |
+
public $prefix = 'wc-stripe-';
|
13 |
+
|
14 |
+
public $registered_scripts = array();
|
15 |
+
|
16 |
+
public $enqueued_scripts = array();
|
17 |
+
|
18 |
+
public $localized_scripts = array();
|
19 |
+
|
20 |
+
public $global_scripts = array(
|
21 |
+
'external' => 'https://js.stripe.com/v3/',
|
22 |
+
'gpay' => 'https://pay.google.com/gp/p/js/pay.js',
|
23 |
+
'plaid' => 'https://cdn.plaid.com/link/v2/stable/link-initialize.js',
|
24 |
+
);
|
25 |
+
|
26 |
+
public function __construct() {
|
27 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
|
28 |
+
add_action( 'woocommerce_review_order_before_payment', array( $this, 'enqueue_checkout_scripts' ) );
|
29 |
+
add_action( 'woocommerce_pay_order_after_submit', array( $this, 'enqueue_checkout_scripts' ) );
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Enqueue all frontend scripts needed by the plugin
|
34 |
+
*/
|
35 |
+
public function enqueue_scripts() {
|
36 |
+
// register global scripts
|
37 |
+
foreach ( $this->global_scripts as $handle => $src ) {
|
38 |
+
$this->register_script( $handle, $src );
|
39 |
+
}
|
40 |
+
|
41 |
+
// register scripts that aren't part of gateways
|
42 |
+
$this->register_script(
|
43 |
+
'wc-stripe',
|
44 |
+
$this->assets_url( 'js/frontend/wc-stripe' . $this->get_min() . '.js' ),
|
45 |
+
array(
|
46 |
+
'jquery',
|
47 |
+
$this->get_handle( 'external' ),
|
48 |
+
'woocommerce',
|
49 |
+
)
|
50 |
+
);
|
51 |
+
|
52 |
+
$this->register_script( 'form-handler', $this->assets_url( 'js/frontend/form-handler.js' ), array( 'selectWoo' ) );
|
53 |
+
|
54 |
+
$this->localize_script(
|
55 |
+
'wc-stripe',
|
56 |
+
array(
|
57 |
+
'api_key' => wc_stripe_get_publishable_key(),
|
58 |
+
'account' => wc_stripe_get_account_id(),
|
59 |
+
'page' => $this->get_page_id(),
|
60 |
+
),
|
61 |
+
'wc_stripe_params_v3'
|
62 |
+
);
|
63 |
+
|
64 |
+
$this->localize_script(
|
65 |
+
'form-handler',
|
66 |
+
array(
|
67 |
+
'no_results' => __(
|
68 |
+
'No matches found',
|
69 |
+
'woo-stripe-payment'
|
70 |
+
),
|
71 |
+
)
|
72 |
+
);
|
73 |
+
|
74 |
+
$this->localize_script( 'wc-stripe', wc_stripe_get_error_messages(), 'wc_stripe_messages' );
|
75 |
+
}
|
76 |
+
|
77 |
+
public function enqueue_checkout_scripts() {
|
78 |
+
$data = wc_stripe_get_local_payment_params();
|
79 |
+
// only enqueue local payment script if there are local payment gateways that have been enabled.
|
80 |
+
if ( ! empty( $data['gateways'] ) && ! in_array( $this->get_handle( 'local-payment' ), $this->enqueued_scripts ) ) {
|
81 |
+
$this->enqueue_script(
|
82 |
+
'local-payment',
|
83 |
+
$this->assets_url( 'js/frontend/local-payment.js' ),
|
84 |
+
array(
|
85 |
+
$this->get_handle( 'external' ),
|
86 |
+
$this->get_handle( 'wc-stripe' ),
|
87 |
+
)
|
88 |
+
);
|
89 |
+
$this->localize_script( 'local-payment', $data );
|
90 |
+
}
|
91 |
+
}
|
92 |
+
|
93 |
+
public function register_script( $handle, $src, $deps = array(), $version = '', $footer = true ) {
|
94 |
+
$version = empty( $version ) ? wc_stripe()->version() : $version;
|
95 |
+
$this->registered_scripts[] = $this->get_handle( $handle );
|
96 |
+
wp_register_script( $this->get_handle( $handle ), $src, $deps, $version, $footer );
|
97 |
+
}
|
98 |
+
|
99 |
+
public function enqueue_script( $handle, $src = '', $deps = array(), $version = '', $footer = true ) {
|
100 |
+
$handle = $this->get_handle( $handle );
|
101 |
+
$version = empty( $version ) ? wc_stripe()->version() : $version;
|
102 |
+
if ( ! in_array( $handle, $this->registered_scripts ) ) {
|
103 |
+
$this->register_script( $handle, $src, $deps, $version, $footer );
|
104 |
+
}
|
105 |
+
$this->enqueued_scripts[] = $handle;
|
106 |
+
wp_enqueue_script( $handle );
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
*
|
111 |
+
* @param string $handle
|
112 |
+
* @param array $data
|
113 |
+
* @param string $object_name
|
114 |
+
*/
|
115 |
+
public function localize_script( $handle, $data, $object_name = '' ) {
|
116 |
+
$handle = $this->get_handle( $handle );
|
117 |
+
if ( wp_script_is( $handle, 'registered' ) ) {
|
118 |
+
$name = str_replace( $this->prefix, '', $handle );
|
119 |
+
if ( ! $object_name ) {
|
120 |
+
$object_name = str_replace( '-', '_', $handle ) . '_params';
|
121 |
+
}
|
122 |
+
$data = apply_filters( 'wc_stripe_localize_script_' . $name, $data, $object_name );
|
123 |
+
if ( $data ) {
|
124 |
+
$this->localized_scripts[] = $handle;
|
125 |
+
wp_localize_script( $handle, $object_name, $data );
|
126 |
+
}
|
127 |
+
}
|
128 |
+
}
|
129 |
+
|
130 |
+
public function get_handle( $handle ) {
|
131 |
+
return strpos( $handle, $this->prefix ) === false ? $this->prefix . $handle : $handle;
|
132 |
+
}
|
133 |
+
|
134 |
+
/**
|
135 |
+
*
|
136 |
+
* @param string $uri
|
137 |
+
*/
|
138 |
+
public function assets_url( $uri = '' ) {
|
139 |
+
return untrailingslashit( wc_stripe()->assets_url( $uri ) );
|
140 |
+
}
|
141 |
+
|
142 |
+
public function get_min() {
|
143 |
+
return $suffix = SCRIPT_DEBUG ? '' : '.min';
|
144 |
+
}
|
145 |
+
|
146 |
+
private function get_page_id() {
|
147 |
+
if ( is_product() ) {
|
148 |
+
return 'product';
|
149 |
+
}
|
150 |
+
if ( is_cart() ) {
|
151 |
+
return 'cart';
|
152 |
+
}
|
153 |
+
if ( is_checkout() ) {
|
154 |
+
return 'checkout';
|
155 |
+
}
|
156 |
+
if ( is_add_payment_method_page() ) {
|
157 |
+
return 'add_payment_method';
|
158 |
+
}
|
159 |
+
|
160 |
+
return '';
|
161 |
+
}
|
162 |
+
}
|
includes/class-wc-stripe-gateway-ach.php
DELETED
@@ -1,99 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
defined ( 'ABSPATH' ) || exit ();
|
3 |
-
|
4 |
-
/**
|
5 |
-
*
|
6 |
-
* @since 3.1.0
|
7 |
-
* @author Payment Plugins
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
class WC_Stripe_Gateway_ACH extends WC_Stripe_Gateway {
|
11 |
-
|
12 |
-
private $public_token = '';
|
13 |
-
|
14 |
-
private $account_id = '';
|
15 |
-
|
16 |
-
private $environment = '';
|
17 |
-
|
18 |
-
public function set_public_token($public_token) {
|
19 |
-
$this->public_token = $public_token;
|
20 |
-
}
|
21 |
-
|
22 |
-
public function set_account_id($account_id) {
|
23 |
-
$this->account_id = $account_id;
|
24 |
-
}
|
25 |
-
|
26 |
-
public function set_plaid_environment($environment) {
|
27 |
-
$this->environment = $environment;
|
28 |
-
}
|
29 |
-
|
30 |
-
/**
|
31 |
-
*
|
32 |
-
* {@inheritDoc}
|
33 |
-
*
|
34 |
-
* @see WC_Stripe_Gateway::charge()
|
35 |
-
*/
|
36 |
-
public function charge($args, $mode = '') {
|
37 |
-
$mode = empty ( $mode ) ? wc_stripe_mode () : $mode;
|
38 |
-
$args = [ 'charge' => $args, 'mode' => $mode,
|
39 |
-
'account_id' => wc_stripe ()->api_settings->get_option ( 'account_id' ),
|
40 |
-
'plaid' => [
|
41 |
-
'public_token' => $this->public_token,
|
42 |
-
'account_id' => $this->account_id,
|
43 |
-
'environment' => $this->environment
|
44 |
-
]
|
45 |
-
];
|
46 |
-
try {
|
47 |
-
// validate env and mode to prevent conflicts
|
48 |
-
if ($mode == 'live' && in_array ( $this->environment, [
|
49 |
-
'sandbox', 'development'
|
50 |
-
] )) {
|
51 |
-
throw new Exception ( __ ( 'Please update your ACH environment to Production to match your Stripe API Mode.', 'woo-stripe-payment' ) );
|
52 |
-
}
|
53 |
-
$response = $this->do_request ( 'POST', '', $args, $mode );
|
54 |
-
return $response;
|
55 |
-
} catch ( Exception $e ) {
|
56 |
-
return new WP_Error ( 'charge-error', $e->getMessage () );
|
57 |
-
}
|
58 |
-
}
|
59 |
-
|
60 |
-
private function do_request($method, $uri, $args, $mode) {
|
61 |
-
$response = wp_safe_remote_post ( $this->base_url ( $uri, $mode ), [
|
62 |
-
'headers' => [
|
63 |
-
'Content-Type' => 'application/json'
|
64 |
-
], /**
|
65 |
-
* 20 second timeout
|
66 |
-
*/
|
67 |
-
'timeout' => 20,
|
68 |
-
'body' => wp_json_encode ( $args )
|
69 |
-
] );
|
70 |
-
if (is_wp_error ( $response )) {
|
71 |
-
throw new Exception ( $response->get_error_message () );
|
72 |
-
} else {
|
73 |
-
$body = json_decode ( $response[ 'body' ], true );
|
74 |
-
if ($response[ 'response' ][ 'code' ] > 299) {
|
75 |
-
throw new Exception ( $body[ 'message' ] );
|
76 |
-
} else {
|
77 |
-
$obj = \Stripe\Util\Util::convertToStripeObject ( $body, null );
|
78 |
-
$obj->setLastResponse ( $response );
|
79 |
-
return $obj;
|
80 |
-
}
|
81 |
-
}
|
82 |
-
}
|
83 |
-
|
84 |
-
/**
|
85 |
-
*
|
86 |
-
* @param string $uri
|
87 |
-
*/
|
88 |
-
private function base_url($uri, $mode) {
|
89 |
-
$url = '';
|
90 |
-
switch ($mode) {
|
91 |
-
case 'live' :
|
92 |
-
case 'test' :
|
93 |
-
$url = 'https://api.plaid.paymentplugins.com/v1/stripe/';
|
94 |
-
// $url = 'http://localhost:8080/v1/stripe/';
|
95 |
-
break;
|
96 |
-
}
|
97 |
-
return $url . $uri;
|
98 |
-
}
|
99 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/class-wc-stripe-gateway-conversions.php
CHANGED
@@ -1,40 +1,36 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
/**
|
5 |
-
*
|
6 |
-
* @since 3.1.0
|
7 |
-
* @author Payment Plugins
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
class WC_Stripe_Gateway_Conversion {
|
11 |
-
|
12 |
-
public static function init() {
|
13 |
-
add_filter
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
return $payment_method;
|
38 |
-
}
|
39 |
-
}
|
40 |
-
WC_Stripe_Gateway_Conversion::init ();
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
/**
|
5 |
+
*
|
6 |
+
* @since 3.1.0
|
7 |
+
* @author Payment Plugins
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
class WC_Stripe_Gateway_Conversion {
|
11 |
+
|
12 |
+
public static function init() {
|
13 |
+
add_filter( 'woocommerce_order_get_payment_method', array( __CLASS__, 'convert_payment_method' ), 10, 2 );
|
14 |
+
add_filter( 'woocommerce_subscription_get_payment_method', array( __CLASS__, 'convert_payment_method' ), 10, 2 );
|
15 |
+
}
|
16 |
+
|
17 |
+
/**
|
18 |
+
*
|
19 |
+
* @param string $payment_method
|
20 |
+
* @param WC_Order $order
|
21 |
+
*/
|
22 |
+
public static function convert_payment_method( $payment_method, $order ) {
|
23 |
+
$old_payment_method = $payment_method;
|
24 |
+
|
25 |
+
switch ( $payment_method ) {
|
26 |
+
case 'stripe':
|
27 |
+
$payment_method = 'stripe_cc';
|
28 |
+
break;
|
29 |
+
}
|
30 |
+
if ( $payment_method != $old_payment_method && ! empty( $payment_method ) ) {
|
31 |
+
update_post_meta( $order->get_id(), '_payment_method', $payment_method );
|
32 |
+
}
|
33 |
+
return $payment_method;
|
34 |
+
}
|
35 |
+
}
|
36 |
+
WC_Stripe_Gateway_Conversion::init();
|
|
|
|
|
|
|
|
includes/class-wc-stripe-gateway.php
CHANGED
@@ -1,495 +1,444 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
*
|
11 |
-
*
|
12 |
-
* @
|
13 |
-
* @
|
14 |
-
*
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
*
|
65 |
-
* @
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
*
|
74 |
-
* @
|
75 |
-
* @
|
76 |
-
*/
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
}
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
*
|
105 |
-
* @param string $mode
|
106 |
-
* @
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
*
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
public function
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
*
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
}
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
*
|
223 |
-
* @param string $
|
224 |
-
* @
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
}
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
*
|
275 |
-
* @param
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
*
|
287 |
-
* @param string $
|
288 |
-
*
|
289 |
-
* @
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
*
|
301 |
-
*
|
302 |
-
* @
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
public function
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
*
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
}
|
373 |
-
|
374 |
-
public function
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
}
|
391 |
-
|
392 |
-
public function
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
} catch ( \Stripe\Error\Base $e ) {
|
446 |
-
return $this->get_wp_error ( $e, 'webhook-error' );
|
447 |
-
}
|
448 |
-
}
|
449 |
-
|
450 |
-
private function get_api_options($mode = '') {
|
451 |
-
if (empty ( $mode ) && $this->mode != null) {
|
452 |
-
$mode = $this->mode;
|
453 |
-
}
|
454 |
-
$args = [
|
455 |
-
'api_key' => $this->secret_key ? $this->secret_key : wc_stripe_get_secret_key ( $mode )
|
456 |
-
];
|
457 |
-
return apply_filters ( 'wc_stripe_api_options', $args );
|
458 |
-
}
|
459 |
-
|
460 |
-
/**
|
461 |
-
*
|
462 |
-
* @param mixed $err
|
463 |
-
*/
|
464 |
-
private function get_error_message($err) {
|
465 |
-
if (is_a ( $err, '\Stripe\Error\Base' )) {
|
466 |
-
$err = $err->getJsonBody ()[ 'error' ];
|
467 |
-
}
|
468 |
-
if (is_array ( $err )) {
|
469 |
-
if (isset ( $err[ 'decline_code' ] ) && isset ( $this->messages[ $err[ 'decline_code' ] ] )) {
|
470 |
-
return $this->messages[ $err[ 'decline_code' ] ];
|
471 |
-
}
|
472 |
-
if (isset ( $err[ 'code' ] ) && isset ( $this->messages[ $err[ 'code' ] ] )) {
|
473 |
-
return $this->messages[ $err[ 'code' ] ];
|
474 |
-
}
|
475 |
-
if (isset ( $err[ 'message' ] )) {
|
476 |
-
return $err[ 'message' ];
|
477 |
-
}
|
478 |
-
}
|
479 |
-
if (is_string ( $err )) {
|
480 |
-
return $err;
|
481 |
-
}
|
482 |
-
}
|
483 |
-
|
484 |
-
/**
|
485 |
-
*
|
486 |
-
* @todo use in future version to replace manual returns of WP_Error in each method
|
487 |
-
* @since 3.1.1
|
488 |
-
* @param \Stripe\Error\Base $e
|
489 |
-
*/
|
490 |
-
private function get_wp_error($e, $code = 'stripe-error') {
|
491 |
-
$err = $e->getJsonBody ()[ 'error' ];
|
492 |
-
return new WP_Error ( $code, $this->get_error_message ( $err ), $err );
|
493 |
-
}
|
494 |
-
}
|
495 |
-
WC_Stripe_Gateway::init ();
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
require_once( WC_STRIPE_PLUGIN_FILE_PATH . 'includes/class-wc-stripe-api-operation.php' );
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Gateway class that abstracts all API calls to Stripe.
|
8 |
+
*
|
9 |
+
* @author Payment Plugins
|
10 |
+
* @package Stripe/Classes
|
11 |
+
*
|
12 |
+
* @property \Stripe\Service\AccountLinkService $accountLinks
|
13 |
+
* @property \Stripe\Service\AccountService $accounts
|
14 |
+
* @property \Stripe\Service\ApplePayDomainService $applePayDomains
|
15 |
+
* @property \Stripe\Service\ApplicationFeeService $applicationFees
|
16 |
+
* @property \Stripe\Service\BalanceService $balance
|
17 |
+
* @property \Stripe\Service\BalanceTransactionService $balanceTransactions
|
18 |
+
* @property \Stripe\Service\BillingPortal\BillingPortalServiceFactory $billingPortal
|
19 |
+
* @property \Stripe\Service\ChargeService $charges
|
20 |
+
* @property \Stripe\Service\Checkout\CheckoutServiceFactory $checkout
|
21 |
+
* @property \Stripe\Service\CountrySpecService $countrySpecs
|
22 |
+
* @property \Stripe\Service\CouponService $coupons
|
23 |
+
* @property \Stripe\Service\CreditNoteService $creditNotes
|
24 |
+
* @property \Stripe\Service\CustomerService $customers
|
25 |
+
* @property \Stripe\Service\DisputeService $disputes
|
26 |
+
* @property \Stripe\Service\EphemeralKeyService $ephemeralKeys
|
27 |
+
* @property \Stripe\Service\EventService $events
|
28 |
+
* @property \Stripe\Service\ExchangeRateService $exchangeRates
|
29 |
+
* @property \Stripe\Service\FileLinkService $fileLinks
|
30 |
+
* @property \Stripe\Service\FileService $files
|
31 |
+
* @property \Stripe\Service\InvoiceItemService $invoiceItems
|
32 |
+
* @property \Stripe\Service\InvoiceService $invoices
|
33 |
+
* @property \Stripe\Service\Issuing\IssuingServiceFactory $issuing
|
34 |
+
* @property \Stripe\Service\MandateService $mandates
|
35 |
+
* @property \Stripe\Service\OrderReturnService $orderReturns
|
36 |
+
* @property \Stripe\Service\OrderService $orders
|
37 |
+
* @property \Stripe\Service\PaymentIntentService $paymentIntents
|
38 |
+
* @property \Stripe\Service\PaymentMethodService $paymentMethods
|
39 |
+
* @property \Stripe\Service\PayoutService $payouts
|
40 |
+
* @property \Stripe\Service\PlanService $plans
|
41 |
+
* @property \Stripe\Service\PriceService $prices
|
42 |
+
* @property \Stripe\Service\ProductService $products
|
43 |
+
* @property \Stripe\Service\Radar\RadarServiceFactory $radar
|
44 |
+
* @property \Stripe\Service\RefundService $refunds
|
45 |
+
* @property \Stripe\Service\Reporting\ReportingServiceFactory $reporting
|
46 |
+
* @property \Stripe\Service\ReviewService $reviews
|
47 |
+
* @property \Stripe\Service\SetupIntentService $setupIntents
|
48 |
+
* @property \Stripe\Service\Sigma\SigmaServiceFactory $sigma
|
49 |
+
* @property \Stripe\Service\SkuService $skus
|
50 |
+
* @property \Stripe\Service\SourceService $sources
|
51 |
+
* @property \Stripe\Service\SubscriptionItemService $subscriptionItems
|
52 |
+
* @property \Stripe\Service\SubscriptionScheduleService $subscriptionSchedules
|
53 |
+
* @property \Stripe\Service\SubscriptionService $subscriptions
|
54 |
+
* @property \Stripe\Service\TaxRateService $taxRates
|
55 |
+
* @property \Stripe\Service\Terminal\TerminalServiceFactory $terminal
|
56 |
+
* @property \Stripe\Service\TokenService $tokens
|
57 |
+
* @property \Stripe\Service\TopupService $topups
|
58 |
+
* @property \Stripe\Service\TransferService $transfers
|
59 |
+
* @property \Stripe\Service\WebhookEndpointService $webhookEndpoints
|
60 |
+
*/
|
61 |
+
class WC_Stripe_Gateway {
|
62 |
+
|
63 |
+
/**
|
64 |
+
*
|
65 |
+
* @since 3.0.5
|
66 |
+
* @var Stripe mode (test, live)
|
67 |
+
*/
|
68 |
+
private $mode = null;
|
69 |
+
|
70 |
+
private $messages = array();
|
71 |
+
|
72 |
+
/**
|
73 |
+
*
|
74 |
+
* @since 3.0.8
|
75 |
+
* @var string
|
76 |
+
*/
|
77 |
+
private $secret_key = null;
|
78 |
+
|
79 |
+
/**
|
80 |
+
*
|
81 |
+
* @var \Stripe\StripeClient
|
82 |
+
*/
|
83 |
+
private $client = null;
|
84 |
+
|
85 |
+
public function __construct( $mode = null, $secret_key = null ) {
|
86 |
+
if ( null != $mode ) {
|
87 |
+
$this->mode = $mode;
|
88 |
+
}
|
89 |
+
if ( null != $secret_key ) {
|
90 |
+
$this->secret_key = $secret_key;
|
91 |
+
}
|
92 |
+
$this->client = new \Stripe\StripeClient( array( 'stripe_version' => '2020-03-02' ) );
|
93 |
+
}
|
94 |
+
|
95 |
+
public static function init() {
|
96 |
+
\Stripe\Stripe::setAppInfo( 'WordPress woo-stripe-payment', wc_stripe()->version(), 'https://wordpress.org/plugins/woo-stripe-payment/', 'pp_partner_FdPtriN2Q7JLOe' );
|
97 |
+
}
|
98 |
+
|
99 |
+
public function __get( $key ) {
|
100 |
+
return new WC_Stripe_API_Operation( $this, $this->client, $key );
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
*
|
105 |
+
* @param string $mode
|
106 |
+
* @param string $secret_key
|
107 |
+
*
|
108 |
+
* @return WC_Stripe_Gateway
|
109 |
+
* @since 3.1.0
|
110 |
+
*/
|
111 |
+
public static function load( $mode = null, $secret_key = null ) {
|
112 |
+
$class = apply_filters( 'wc_stripe_gateway_class', 'WC_Stripe_Gateway' );
|
113 |
+
|
114 |
+
return new $class( $mode, $secret_key );
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
*
|
119 |
+
* @param string $mode
|
120 |
+
*
|
121 |
+
* @since 3.1.0
|
122 |
+
*/
|
123 |
+
public function set_mode( $mode ) {
|
124 |
+
$this->mode = $mode;
|
125 |
+
}
|
126 |
+
|
127 |
+
/**
|
128 |
+
* Create a customer within Stripe.
|
129 |
+
*
|
130 |
+
* @param array $args
|
131 |
+
*
|
132 |
+
* @return WP_Error|string
|
133 |
+
*/
|
134 |
+
public function create_customer( $args, $mode = '' ) {
|
135 |
+
return $this->customers->create( apply_filters( 'wc_stripe_create_customer_args', $args ), $this->get_api_options( $mode ) );
|
136 |
+
|
137 |
+
}
|
138 |
+
|
139 |
+
public function update_customer( $id, $args, $mode = '' ) {
|
140 |
+
return $this->customers->update( $id, $args, $this->get_api_options( $mode ) );
|
141 |
+
}
|
142 |
+
|
143 |
+
public function charge( $args, $mode = '' ) {
|
144 |
+
return $this->charges->create( $args, $this->get_api_options( $mode ) );
|
145 |
+
}
|
146 |
+
|
147 |
+
/**
|
148 |
+
*
|
149 |
+
* @param array $args
|
150 |
+
* @param string $mode
|
151 |
+
*
|
152 |
+
* @return WP_Error|\Stripe\PaymentIntent
|
153 |
+
*/
|
154 |
+
public function create_payment_intent( $args, $mode = '' ) {
|
155 |
+
return $this->paymentIntents->create( $args, $this->get_api_options( $mode ) );
|
156 |
+
}
|
157 |
+
|
158 |
+
public function create_setup_intent( $args, $mode = '' ) {
|
159 |
+
return $this->setupIntents->create( $args, $this->get_api_options( $mode ) );
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
*
|
164 |
+
* @param \Stripe\PaymentIntent $intent
|
165 |
+
* @param array $args
|
166 |
+
* @param string $mode
|
167 |
+
*/
|
168 |
+
public function update_payment_intent( $id, $args, $mode = '' ) {
|
169 |
+
return $this->paymentIntents->update( $id, $args, $this->get_api_options( $mode ) );
|
170 |
+
}
|
171 |
+
|
172 |
+
/**
|
173 |
+
*
|
174 |
+
* @param \Stripe\PaymentIntent $intent
|
175 |
+
* @param array $args
|
176 |
+
* @param string $mode
|
177 |
+
*/
|
178 |
+
public function confirm_payment_intent( $id, $args = array(), $mode = '' ) {
|
179 |
+
return $this->paymentIntents->confirm( $id, $args, $this->get_api_options( $mode ) );
|
180 |
+
}
|
181 |
+
|
182 |
+
/**
|
183 |
+
*
|
184 |
+
* @param string $id
|
185 |
+
* @param string $mode
|
186 |
+
*
|
187 |
+
* @return WP_Error|\Stripe\PaymentIntent
|
188 |
+
*/
|
189 |
+
public function fetch_payment_intent( $id, $mode = '' ) {
|
190 |
+
return $this->paymentIntents->retrieve( $id, array(), $this->get_api_options( $mode ) );
|
191 |
+
}
|
192 |
+
|
193 |
+
public function capture_payment_intent( $id, $args = array(), $mode = '' ) {
|
194 |
+
return $this->paymentIntents->capture( $id, $args, $this->get_api_options( $mode ) );
|
195 |
+
}
|
196 |
+
|
197 |
+
/**
|
198 |
+
*
|
199 |
+
* @param \Stripe\PaymentIntent|string $id
|
200 |
+
* @param string $mode
|
201 |
+
*/
|
202 |
+
public function cancel_payment_intent( $id, $mode = '' ) {
|
203 |
+
return $this->paymentIntents->cancel( $id, array(), $this->get_api_options( $mode ) );
|
204 |
+
}
|
205 |
+
|
206 |
+
/**
|
207 |
+
*
|
208 |
+
* @param string $id
|
209 |
+
* @param string $mode
|
210 |
+
*
|
211 |
+
* @return WP_Error|\Stripe\SetupIntent
|
212 |
+
*/
|
213 |
+
public function fetch_setup_intent( $id, $mode = '' ) {
|
214 |
+
return $this->setupIntents->retrieve( $id, array(), $this->get_api_options( $mode ) );
|
215 |
+
}
|
216 |
+
|
217 |
+
public function capture( $id, $args, $mode = '' ) {
|
218 |
+
return $this->charges->capture( $id, $args, $this->get_api_options( $mode ) );
|
219 |
+
}
|
220 |
+
|
221 |
+
/**
|
222 |
+
*
|
223 |
+
* @param string $charge_id
|
224 |
+
* @param string $mode
|
225 |
+
*
|
226 |
+
* @return \Stripe\Charge|WP_Error
|
227 |
+
*/
|
228 |
+
public function get_charge( $charge_id, $mode = '' ) {
|
229 |
+
return $this->charges->retrieve( $charge_id, array(), $this->get_api_options( $mode ) );
|
230 |
+
}
|
231 |
+
|
232 |
+
public function refund( $args, $mode = '' ) {
|
233 |
+
return $this->refunds->create( $args, $this->get_api_options( $mode ) );
|
234 |
+
}
|
235 |
+
|
236 |
+
public function get_payment_method( $id, $mode = '' ) {
|
237 |
+
return \Stripe\PaymentMethod::retrieve( $id, $this->get_api_options( $mode ) );
|
238 |
+
}
|
239 |
+
|
240 |
+
/**
|
241 |
+
*
|
242 |
+
* @param \Stripe\PaymentMethod $payment_method
|
243 |
+
* @param array $args
|
244 |
+
* @param string $mode
|
245 |
+
*/
|
246 |
+
public function attach_payment_method( $id, $args = array(), $mode = '' ) {
|
247 |
+
return $this->paymentMethods->attach( $id, $args, $this->get_api_options( $mode ) );
|
248 |
+
}
|
249 |
+
|
250 |
+
public function fetch_payment_method( $id, $mode = '' ) {
|
251 |
+
return $this->paymentMethods->retrieve( $id, null, $this->get_api_options( $mode ) );
|
252 |
+
}
|
253 |
+
|
254 |
+
/**
|
255 |
+
*
|
256 |
+
* @param \Stripe\PaymentMethod $payment_method
|
257 |
+
* @param string $mode
|
258 |
+
*/
|
259 |
+
public function delete_payment_method( $id, $mode = '' ) {
|
260 |
+
return $this->paymentMethods->detach( $id, array(), $this->get_api_options( $mode ) );
|
261 |
+
}
|
262 |
+
|
263 |
+
/**
|
264 |
+
*
|
265 |
+
* @param string $id
|
266 |
+
* @param string $customer
|
267 |
+
* @param string $mode
|
268 |
+
*/
|
269 |
+
public function delete_card( $id, $customer, $mode = '' ) {
|
270 |
+
return $this->sources->detach( $customer, $id, null, $this->get_api_options( $mode ) );
|
271 |
+
}
|
272 |
+
|
273 |
+
/**
|
274 |
+
*
|
275 |
+
* @param array $args
|
276 |
+
* @param string $mode
|
277 |
+
*
|
278 |
+
* @return WP_Error|\Stripe\PaymentMethod
|
279 |
+
*/
|
280 |
+
public function create_payment_method( $args, $mode = '' ) {
|
281 |
+
return $this->paymentMethods->create( $args, $this->get_api_options( $mode ) );
|
282 |
+
}
|
283 |
+
|
284 |
+
/**
|
285 |
+
*
|
286 |
+
* @param string $id
|
287 |
+
* @param string $mode
|
288 |
+
*
|
289 |
+
* @return WP_Error|\Stripe\Source
|
290 |
+
*
|
291 |
+
*/
|
292 |
+
public function fetch_payment_source( $id, $mode = '' ) {
|
293 |
+
return $this->sources->retrieve( $id, null, $this->get_api_options( $mode ) );
|
294 |
+
}
|
295 |
+
|
296 |
+
/**
|
297 |
+
*
|
298 |
+
* @param string $customer_id
|
299 |
+
* @param string $id
|
300 |
+
* @param string $mode
|
301 |
+
*
|
302 |
+
* @return WP_Error|\Stripe\Source
|
303 |
+
*/
|
304 |
+
public function create_customer_source( $customer_id, $id, $mode = '' ) {
|
305 |
+
return $this->customers->createSource( $customer_id, array( 'source' => $id ), $this->get_api_options( $mode ) );
|
306 |
+
}
|
307 |
+
|
308 |
+
/**
|
309 |
+
*
|
310 |
+
* @param array $args
|
311 |
+
* @param string $mode
|
312 |
+
*
|
313 |
+
* @return WP_Error|\Stripe\Source
|
314 |
+
*/
|
315 |
+
public function create_source( $args, $mode = '' ) {
|
316 |
+
return $this->sources->create( $args, $this->get_api_options( $mode ) );
|
317 |
+
}
|
318 |
+
|
319 |
+
/**
|
320 |
+
*
|
321 |
+
* @param string $source_id
|
322 |
+
* @param array $args
|
323 |
+
* @param string $mode
|
324 |
+
*
|
325 |
+
* @since 3.0.2
|
326 |
+
*/
|
327 |
+
public function update_source( $source_id, $args, $mode = '' ) {
|
328 |
+
return $this->sources->update( $source_id, $args, $this->get_api_options( $mode ) );
|
329 |
+
}
|
330 |
+
|
331 |
+
public function fetch_customer( $customer_id, $mode = '' ) {
|
332 |
+
return $this->customers->retrieve( $customer_id, null, $this->get_api_options( $mode ) );
|
333 |
+
}
|
334 |
+
|
335 |
+
public function fetch_customers( $mode = '' ) {
|
336 |
+
return $this->customers->all( array( 'limit' => 1 ), $this->get_api_options( $mode ) );
|
337 |
+
}
|
338 |
+
|
339 |
+
public function fetch_payment_methods( $customer_id, $mode = '', $type = 'card' ) {
|
340 |
+
return $this->paymentMethods->all(
|
341 |
+
array(
|
342 |
+
'customer' => $customer_id,
|
343 |
+
'type' => $type,
|
344 |
+
),
|
345 |
+
$this->get_api_options( $mode )
|
346 |
+
);
|
347 |
+
}
|
348 |
+
|
349 |
+
public function register_domain( $domain, $mode = '' ) {
|
350 |
+
return $this->applePayDomains->create( array( 'domain_name' => $domain ), $this->get_api_options( $mode ) );
|
351 |
+
}
|
352 |
+
|
353 |
+
/**
|
354 |
+
*
|
355 |
+
* @param string $mode
|
356 |
+
*
|
357 |
+
* @since 3.1.6
|
358 |
+
*/
|
359 |
+
public function fetch_domains( $mode = '' ) {
|
360 |
+
return $this->applePayDomains->all( array( 'limit' => 50 ), $this->get_api_options( $mode ) );
|
361 |
+
}
|
362 |
+
|
363 |
+
/**
|
364 |
+
*
|
365 |
+
* @param \Stripe\ApplePayDomain $domain
|
366 |
+
* @param string $mode
|
367 |
+
*
|
368 |
+
* @since 3.1.6
|
369 |
+
*/
|
370 |
+
public function delete_domain( $id, $mode = '' ) {
|
371 |
+
return $this->applePayDomains->delete( $id, array(), $this->get_api_options( $mode ) );
|
372 |
+
}
|
373 |
+
|
374 |
+
public function webhooks( $mode = '' ) {
|
375 |
+
return $this->webhookEndpoints->all( array( 'limit' => 100 ), $this->get_api_options( $mode ) );
|
376 |
+
}
|
377 |
+
|
378 |
+
public function create_webhook( $url, $events, $mode = '' ) {
|
379 |
+
return $this->webhookEndpoints->create(
|
380 |
+
array(
|
381 |
+
'url' => $url,
|
382 |
+
'enabled_events' => $events,
|
383 |
+
),
|
384 |
+
$this->get_api_options( $mode )
|
385 |
+
);
|
386 |
+
}
|
387 |
+
|
388 |
+
public function update_webhook( $id, $params, $mode = '' ) {
|
389 |
+
return $this->webhookEndpoints->update( $id, $params, $this->get_api_options( $mode ) );
|
390 |
+
}
|
391 |
+
|
392 |
+
public function fetch_webhook( $id, $mode = '' ) {
|
393 |
+
return $this->webhookEndpoints->retrieve( $id, null, $this->get_api_options( $mode ) );
|
394 |
+
}
|
395 |
+
|
396 |
+
public function get_api_options( $mode = '' ) {
|
397 |
+
if ( empty( $mode ) && $this->mode != null ) {
|
398 |
+
$mode = $this->mode;
|
399 |
+
}
|
400 |
+
$args = array( 'api_key' => $this->secret_key ? $this->secret_key : wc_stripe_get_secret_key( $mode ) );
|
401 |
+
|
402 |
+
return apply_filters( 'wc_stripe_api_options', $args );
|
403 |
+
}
|
404 |
+
|
405 |
+
/**
|
406 |
+
*
|
407 |
+
* @param mixed $err
|
408 |
+
*/
|
409 |
+
private function get_error_message( $err ) {
|
410 |
+
if ( is_a( $err, '\Stripe\Exception\ApiErrorException' ) ) {
|
411 |
+
$err = $err->getError();
|
412 |
+
}
|
413 |
+
if ( is_array( $err ) || $err instanceof \Stripe\ErrorObject ) {
|
414 |
+
$this->messages = ! $this->messages ? wc_stripe_get_error_messages() : $this->messages;
|
415 |
+
if ( isset( $err['decline_code'] ) && isset( $this->messages[ $err['decline_code'] ] ) ) {
|
416 |
+
return $this->messages[ $err['decline_code'] ];
|
417 |
+
}
|
418 |
+
if ( isset( $err['code'] ) && isset( $this->messages[ $err['code'] ] ) ) {
|
419 |
+
return $this->messages[ $err['code'] ];
|
420 |
+
}
|
421 |
+
if ( isset( $err['message'] ) ) {
|
422 |
+
return $err['message'];
|
423 |
+
}
|
424 |
+
}
|
425 |
+
if ( is_string( $err ) ) {
|
426 |
+
return $err;
|
427 |
+
}
|
428 |
+
}
|
429 |
+
|
430 |
+
/**
|
431 |
+
*
|
432 |
+
* @param \Stripe\Exception\ApiErrorException $e
|
433 |
+
*
|
434 |
+
* @since 3.1.1
|
435 |
+
* @todo use in future version to replace manual returns of WP_Error in each method
|
436 |
+
*/
|
437 |
+
public function get_wp_error( $e, $code = 'stripe-error' ) {
|
438 |
+
$err = $e->getJsonBody()['error'];
|
439 |
+
|
440 |
+
return new WP_Error( $code, $this->get_error_message( $err ), $err );
|
441 |
+
}
|
442 |
+
}
|
443 |
+
|
444 |
+
WC_Stripe_Gateway::init();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/class-wc-stripe-install.php
CHANGED
@@ -1,36 +1,40 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
/**
|
5 |
-
*
|
6 |
-
* @package Stripe/Classes
|
7 |
-
*
|
8 |
-
*/
|
9 |
-
class WC_Stripe_Install {
|
10 |
-
|
11 |
-
public static function init() {
|
12 |
-
add_filter
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
) );
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
/**
|
5 |
+
*
|
6 |
+
* @package Stripe/Classes
|
7 |
+
*
|
8 |
+
*/
|
9 |
+
class WC_Stripe_Install {
|
10 |
+
|
11 |
+
public static function init() {
|
12 |
+
add_filter( 'plugin_action_links_' . WC_STRIPE_PLUGIN_NAME, array( __CLASS__, 'plugin_action_links' ) );
|
13 |
+
register_activation_hook( WC_STRIPE_PLUGIN_NAME, array( __CLASS__, 'install' ) );
|
14 |
+
}
|
15 |
+
|
16 |
+
public static function install() {
|
17 |
+
update_option( 'stripe_wc_version', wc_stripe()->version() );
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Schedule required actions. Actions are scheduled during install as they only need to be setup
|
21 |
+
* once.
|
22 |
+
*/
|
23 |
+
wc_stripe()->scheduled_actions();
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
*
|
28 |
+
* @param array $links
|
29 |
+
*/
|
30 |
+
public static function plugin_action_links( $links ) {
|
31 |
+
$action_links = array(
|
32 |
+
'settings' => sprintf( '<a href="%1$s">%2$s</a>', admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=stripe_api' ), esc_html__( 'Settings', 'woo-stripe-payment' ) ),
|
33 |
+
'docs' => sprintf( '<a target="_blank" href="https://docs.paymentplugins.com/wc-stripe/config">%s</a>', __( 'Documentation', 'woo-stripe-payment' ) ),
|
34 |
+
);
|
35 |
+
|
36 |
+
return array_merge( $action_links, $links );
|
37 |
+
}
|
38 |
+
}
|
39 |
+
|
40 |
+
WC_Stripe_Install::init();
|
includes/class-wc-stripe-payment-charge-local.php
CHANGED
@@ -1,71 +1,74 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
/**
|
5 |
-
*
|
6 |
-
* @author PaymentPlugins
|
7 |
-
* @since 3.1.1
|
8 |
-
* @package Stripe/Classes
|
9 |
-
*
|
10 |
-
*/
|
11 |
-
class WC_Stripe_Payment_Charge_Local extends WC_Stripe_Payment_Charge {
|
12 |
-
|
13 |
-
/**
|
14 |
-
*
|
15 |
-
* @param WC_Order $order
|
16 |
-
*/
|
17 |
-
public function process_payment($order) {
|
18 |
-
|
19 |
-
/**
|
20 |
-
* If there is no order lock, then this is not being processed via a webhook
|
21 |
-
*/
|
22 |
-
if (! $this->payment_method->has_order_lock
|
23 |
-
try {
|
24 |
-
$source_id = $this->payment_method->get_new_source_token
|
25 |
-
if (! empty
|
26 |
-
// source was created client side.
|
27 |
-
$source = $this->gateway->
|
28 |
-
|
29 |
-
if (is_wp_error
|
30 |
-
|
31 |
-
}
|
32 |
-
|
33 |
-
// update the source's metadata with the order id
|
34 |
-
$this->gateway->
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
$
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
$order->
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
/**
|
5 |
+
*
|
6 |
+
* @author PaymentPlugins
|
7 |
+
* @since 3.1.1
|
8 |
+
* @package Stripe/Classes
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
class WC_Stripe_Payment_Charge_Local extends WC_Stripe_Payment_Charge {
|
12 |
+
|
13 |
+
/**
|
14 |
+
*
|
15 |
+
* @param WC_Order $order
|
16 |
+
*/
|
17 |
+
public function process_payment( $order ) {
|
18 |
+
|
19 |
+
/**
|
20 |
+
* If there is no order lock, then this is not being processed via a webhook
|
21 |
+
*/
|
22 |
+
if ( ! $this->payment_method->has_order_lock( $order ) ) {
|
23 |
+
try {
|
24 |
+
$source_id = $this->payment_method->get_new_source_token();
|
25 |
+
if ( ! empty( $source_id ) ) {
|
26 |
+
// source was created client side.
|
27 |
+
$source = $this->gateway->sources->mode( wc_stripe_order_mode( $order ) )->retrieve( $source_id );
|
28 |
+
|
29 |
+
if ( is_wp_error( $source ) ) {
|
30 |
+
return $source;
|
31 |
+
}
|
32 |
+
|
33 |
+
// update the source's metadata with the order id
|
34 |
+
$this->gateway->sources->mode( wc_stripe_order_mode( $order ) )->update(
|
35 |
+
$source_id,
|
36 |
+
array(
|
37 |
+
'metadata' => array(
|
38 |
+
'order_id' => $order->get_id(),
|
39 |
+
'created' => time(),
|
40 |
+
),
|
41 |
+
)
|
42 |
+
);
|
43 |
+
} else {
|
44 |
+
// create the source
|
45 |
+
$args = $this->payment_method->get_source_args( $order );
|
46 |
+
$args['metadata']['order_id'] = $order->get_id();
|
47 |
+
$args['metadata']['created'] = time();
|
48 |
+
$source = $this->gateway->sources->mode( wc_stripe_order_mode( $order ) )->create( $args );
|
49 |
+
}
|
50 |
+
|
51 |
+
if ( is_wp_error( $source ) ) {
|
52 |
+
throw new Exception( $source->get_error_message() );
|
53 |
+
}
|
54 |
+
|
55 |
+
$order->update_meta_data( WC_Stripe_Constants::SOURCE_ID, $source->id );
|
56 |
+
$order->update_meta_data( WC_Stripe_Constants::MODE, wc_stripe_mode() );
|
57 |
+
|
58 |
+
$order->save();
|
59 |
+
|
60 |
+
return (object) array(
|
61 |
+
'complete_payment' => false,
|
62 |
+
'redirect' => $this->payment_method->get_source_redirect_url( $source, $order ),
|
63 |
+
);
|
64 |
+
} catch ( Exception $e ) {
|
65 |
+
return new WP_Error( 'source-error', $e->getMessage() );
|
66 |
+
}
|
67 |
+
} else {
|
68 |
+
/**
|
69 |
+
* There is an order lock so this order is ready to be processed.
|
70 |
+
*/
|
71 |
+
return parent::process_payment( $order );
|
72 |
+
}
|
73 |
+
}
|
74 |
+
}
|
includes/class-wc-stripe-payment-charge.php
CHANGED
@@ -1,173 +1,179 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
require_once
|
5 |
-
|
6 |
-
/**
|
7 |
-
*
|
8 |
-
* @
|
9 |
-
* @
|
10 |
-
*
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
*
|
17 |
-
*
|
18 |
-
*
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
*
|
47 |
-
* @
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
$
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
$
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
}
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
$
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
}
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
require_once( WC_STRIPE_PLUGIN_FILE_PATH . 'includes/abstract/abstract-wc-stripe-payment.php' );
|
5 |
+
|
6 |
+
/**
|
7 |
+
*
|
8 |
+
* @package Stripe/Classes
|
9 |
+
* @author Payment Plugins
|
10 |
+
* @since 3.1.0
|
11 |
+
*
|
12 |
+
*/
|
13 |
+
class WC_Stripe_Payment_Charge extends WC_Stripe_Payment {
|
14 |
+
|
15 |
+
/**
|
16 |
+
*
|
17 |
+
* {@inheritDoc}
|
18 |
+
*
|
19 |
+
* @see WC_Stripe_Payment::process_payment()
|
20 |
+
*/
|
21 |
+
public function process_payment( $order ) {
|
22 |
+
if ( $this->payment_method->should_save_payment_method( $order ) ) {
|
23 |
+
$result = $this->payment_method->save_payment_method( $this->payment_method->get_new_source_token(), $order );
|
24 |
+
if ( is_wp_error( $result ) ) {
|
25 |
+
return $result;
|
26 |
+
}
|
27 |
+
}
|
28 |
+
|
29 |
+
$args = $this->get_order_charge_args( $args, $order );
|
30 |
+
|
31 |
+
$charge = $this->gateway->charges->mode( wc_stripe_order_mode( $order ) )->create( $args );
|
32 |
+
|
33 |
+
wc_stripe_log_info( 'Stripe charge: ' . print_r( $charge, true ) );
|
34 |
+
|
35 |
+
if ( is_wp_error( $charge ) ) {
|
36 |
+
return $charge;
|
37 |
+
}
|
38 |
+
|
39 |
+
return (object) array(
|
40 |
+
'complete_payment' => true,
|
41 |
+
'charge' => $charge,
|
42 |
+
);
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
*
|
47 |
+
* {@inheritDoc}
|
48 |
+
*
|
49 |
+
* @see WC_Stripe_Payment::capture_charge()
|
50 |
+
*/
|
51 |
+
public function capture_charge( $amount, $order ) {
|
52 |
+
return $this->gateway->charges->mode( wc_stripe_order_mode( $order ) )->capture(
|
53 |
+
$order->get_transaction_id(),
|
54 |
+
array(
|
55 |
+
'amount' => wc_stripe_add_number_precision(
|
56 |
+
$amount,
|
57 |
+
$order->get_currency()
|
58 |
+
),
|
59 |
+
)
|
60 |
+
);
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
*
|
65 |
+
* {@inheritDoc}
|
66 |
+
*
|
67 |
+
* @see WC_Stripe_Payment::void_charge()
|
68 |
+
*/
|
69 |
+
public function void_charge( $order ) {
|
70 |
+
return $this->gateway->refunds->mode( wc_stripe_order_mode( $order ) )->create( array( 'charge' => $order->get_transaction_id() ) );
|
71 |
+
}
|
72 |
+
|
73 |
+
public function scheduled_subscription_payment( $amount, $order ) {
|
74 |
+
$this->get_order_charge_args( $args, $order );
|
75 |
+
|
76 |
+
$args['source'] = $order->get_meta( WC_Stripe_Constants::PAYMENT_METHOD_TOKEN );
|
77 |
+
|
78 |
+
if ( ( $customer_id = $order->get_meta( WC_Stripe_Constants::CUSTOMER_ID ) ) ) {
|
79 |
+
$args['customer'] = $customer_id;
|
80 |
+
} elseif ( ( $customer_id = wc_stripe_get_customer_id( $order->get_customer_id(), wc_stripe_order_mode( $order ) ) ) ) {
|
81 |
+
$args['customer'] = $customer_id;
|
82 |
+
}
|
83 |
+
|
84 |
+
$charge = $this->gateway->charges->mode( wc_stripe_order_mode( $order ) )->create( $args );
|
85 |
+
|
86 |
+
if ( is_wp_error( $charge ) ) {
|
87 |
+
return $charge;
|
88 |
+
} else {
|
89 |
+
return (object) array(
|
90 |
+
'complete_payment' => true,
|
91 |
+
'charge' => $charge,
|
92 |
+
);
|
93 |
+
}
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
*
|
98 |
+
* {@inheritDoc}
|
99 |
+
*
|
100 |
+
* @see WC_Stripe_Payment::process_pre_order_payment()
|
101 |
+
*/
|
102 |
+
public function process_pre_order_payment( $order ) {
|
103 |
+
$this->get_order_charge_args( $args, $order );
|
104 |
+
|
105 |
+
$args['source'] = $order->get_meta( WC_Stripe_Constants::PAYMENT_METHOD_TOKEN );
|
106 |
+
|
107 |
+
if ( ( $customer_id = $order->get_meta( WC_Stripe_Constants::CUSTOMER_ID ) ) ) {
|
108 |
+
$args['customer'] = $customer_id;
|
109 |
+
} elseif ( ( $customer_id = wc_stripe_get_customer_id( $order->get_customer_id(), wc_stripe_order_mode( $order ) ) ) ) {
|
110 |
+
$args['customer'] = $customer_id;
|
111 |
+
}
|
112 |
+
|
113 |
+
$charge = $this->gateway->charges->mode( wc_stripe_order_mode( $order ) )->create( $args );
|
114 |
+
|
115 |
+
if ( is_wp_error( $charge ) ) {
|
116 |
+
return $charge;
|
117 |
+
} else {
|
118 |
+
return (object) array(
|
119 |
+
'complete_payment' => true,
|
120 |
+
'charge' => $charge,
|
121 |
+
);
|
122 |
+
}
|
123 |
+
}
|
124 |
+
|
125 |
+
/**
|
126 |
+
*
|
127 |
+
* @param array $args
|
128 |
+
* @param WC_Order $order
|
129 |
+
*/
|
130 |
+
public function get_order_charge_args( &$args, $order ) {
|
131 |
+
$this->add_general_order_args( $args, $order );
|
132 |
+
|
133 |
+
if ( get_option( 'woocommerce_stripe_email_receipt', 'no' ) === 'yes' && ( $email = $order->get_billing_email() ) ) {
|
134 |
+
$args['receipt_email'] = $email;
|
135 |
+
}
|
136 |
+
$args['capture'] = $this->payment_method->get_option( 'charge_type' ) === 'capture';
|
137 |
+
|
138 |
+
$customer_id = wc_stripe_get_customer_id( $order->get_user_id() );
|
139 |
+
|
140 |
+
// only add customer ID if user is paying with a saved payment method
|
141 |
+
if ( $customer_id && $this->payment_method->use_saved_source() ) {
|
142 |
+
$args['customer'] = $customer_id;
|
143 |
+
}
|
144 |
+
|
145 |
+
$this->payment_method->add_stripe_order_args( $args, $order );
|
146 |
+
|
147 |
+
return apply_filters( 'wc_stripe_charge_order_args', $args, $order, $this->payment_method->id );
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
*
|
152 |
+
* {@inheritDoc}
|
153 |
+
*
|
154 |
+
* @see WC_Stripe_Payment::get_payment_method_from_charge()
|
155 |
+
*/
|
156 |
+
public function get_payment_method_from_charge( $charge ) {
|
157 |
+
return $charge->source->id;
|
158 |
+
}
|
159 |
+
|
160 |
+
/**
|
161 |
+
*
|
162 |
+
* {@inheritDoc}
|
163 |
+
*
|
164 |
+
* @see WC_Stripe_Payment::add_order_payment_method()
|
165 |
+
*/
|
166 |
+
public function add_order_payment_method( &$args, $order ) {
|
167 |
+
$args['source'] = $this->payment_method->get_payment_method_from_request();
|
168 |
+
}
|
169 |
+
|
170 |
+
/**
|
171 |
+
*
|
172 |
+
* {@inheritDoc}
|
173 |
+
*
|
174 |
+
* @see WC_Stripe_Payment::can_void_charge()
|
175 |
+
*/
|
176 |
+
public function can_void_order( $order ) {
|
177 |
+
return $order->get_transaction_id();
|
178 |
+
}
|
179 |
+
}
|
includes/class-wc-stripe-payment-factory.php
CHANGED
@@ -1,42 +1,42 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
/**
|
5 |
-
*
|
6 |
-
* @author PaymentPlugins
|
7 |
-
* @since 3.1.1
|
8 |
-
* @package Stripe/Classes
|
9 |
-
*
|
10 |
-
*/
|
11 |
-
class WC_Stripe_Payment_Factory {
|
12 |
-
|
13 |
-
private static $classes =
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
/**
|
20 |
-
*
|
21 |
-
* @param string $type
|
22 |
-
* @param WC_Payment_Gateway_Stripe $payment_method
|
23 |
-
* @param WC_Stripe_Gateway $gateway
|
24 |
-
*/
|
25 |
-
public static function load($type, $payment_method, $gateway) {
|
26 |
-
$classes = apply_filters
|
27 |
-
if (! isset
|
28 |
-
throw Exception
|
29 |
-
}
|
30 |
-
$classname = $classes[ $type ];
|
31 |
-
|
32 |
-
$args = func_get_args
|
33 |
-
|
34 |
-
if (count
|
35 |
-
$args
|
36 |
-
$instance = new $classname
|
37 |
-
} else {
|
38 |
-
$instance = new $classname
|
39 |
-
}
|
40 |
-
return $instance;
|
41 |
-
}
|
42 |
-
}
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
/**
|
5 |
+
*
|
6 |
+
* @author PaymentPlugins
|
7 |
+
* @since 3.1.1
|
8 |
+
* @package Stripe/Classes
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
class WC_Stripe_Payment_Factory {
|
12 |
+
|
13 |
+
private static $classes = array(
|
14 |
+
'charge' => 'WC_Stripe_Payment_Charge',
|
15 |
+
'payment_intent' => 'WC_Stripe_Payment_Intent',
|
16 |
+
'local_charge' => 'WC_Stripe_Payment_Charge_Local',
|
17 |
+
);
|
18 |
+
|
19 |
+
/**
|
20 |
+
*
|
21 |
+
* @param string $type
|
22 |
+
* @param WC_Payment_Gateway_Stripe $payment_method
|
23 |
+
* @param WC_Stripe_Gateway $gateway
|
24 |
+
*/
|
25 |
+
public static function load( $type, $payment_method, $gateway ) {
|
26 |
+
$classes = apply_filters( 'wc_stripe_payment_classes', self::$classes );
|
27 |
+
if ( ! isset( $classes[ $type ] ) ) {
|
28 |
+
throw Exception( 'No class defined for type ' . $type );
|
29 |
+
}
|
30 |
+
$classname = $classes[ $type ];
|
31 |
+
|
32 |
+
$args = func_get_args();
|
33 |
+
|
34 |
+
if ( count( $args ) > 3 ) {
|
35 |
+
$args = array_slice( $args, 3 );
|
36 |
+
$instance = new $classname( $payment_method, $gateway, ...$args );
|
37 |
+
} else {
|
38 |
+
$instance = new $classname( $payment_method, $gateway );
|
39 |
+
}
|
40 |
+
return $instance;
|
41 |
+
}
|
42 |
+
}
|
includes/class-wc-stripe-payment-intent.php
CHANGED
@@ -1,321 +1,337 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
require_once
|
5 |
-
|
6 |
-
/**
|
7 |
-
*
|
8 |
-
* @
|
9 |
-
* @
|
10 |
-
*
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
*
|
17 |
-
*
|
18 |
-
*
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
$order->update_meta_data
|
40 |
-
$order->update_meta_data
|
41 |
-
|
42 |
-
//
|
43 |
-
|
44 |
-
$order->
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
$args
|
91 |
-
|
92 |
-
$args[
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
$
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
*
|
126 |
-
* @
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
$args
|
132 |
-
|
133 |
-
$args[
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
$
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
*
|
166 |
-
*
|
167 |
-
*
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
$
|
183 |
-
$
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
if (
|
210 |
-
$args[
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
*
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
require_once( WC_STRIPE_PLUGIN_FILE_PATH . 'includes/abstract/abstract-wc-stripe-payment.php' );
|
5 |
+
|
6 |
+
/**
|
7 |
+
*
|
8 |
+
* @package Stripe/Classes
|
9 |
+
* @author Payment Plugins
|
10 |
+
* @since 3.1.0
|
11 |
+
*
|
12 |
+
*/
|
13 |
+
class WC_Stripe_Payment_Intent extends WC_Stripe_Payment {
|
14 |
+
|
15 |
+
/**
|
16 |
+
*
|
17 |
+
* {@inheritDoc}
|
18 |
+
*
|
19 |
+
* @see WC_Stripe_Payment::process_payment()
|
20 |
+
*/
|
21 |
+
public function process_payment( $order ) {
|
22 |
+
// first check to see if a payment intent can be used
|
23 |
+
if ( ( $intent = $this->can_use_payment_intent( $order ) ) ) {
|
24 |
+
$intent_id = $intent['id'];
|
25 |
+
if ( $this->can_update_payment_intent( $order ) ) {
|
26 |
+
$intent = $this->gateway->paymentIntents->update( $intent_id, $this->get_payment_intent_args( $order, false ) );
|
27 |
+
} else {
|
28 |
+
$intent = $this->gateway->paymentIntents->retrieve( $intent_id );
|
29 |
+
}
|
30 |
+
} else {
|
31 |
+
$intent = $this->gateway->paymentIntents->create( $this->get_payment_intent_args( $order ) );
|
32 |
+
}
|
33 |
+
|
34 |
+
if ( is_wp_error( $intent ) ) {
|
35 |
+
return $intent;
|
36 |
+
}
|
37 |
+
|
38 |
+
// always update the order with the payment intent.
|
39 |
+
$order->update_meta_data( WC_Stripe_Constants::PAYMENT_INTENT_ID, $intent->id );
|
40 |
+
$order->update_meta_data( WC_Stripe_Constants::PAYMENT_METHOD_TOKEN, $intent->payment_method );
|
41 |
+
$order->update_meta_data( WC_Stripe_Constants::MODE, wc_stripe_mode() );
|
42 |
+
// serialize the the intent and save to the order. The intent will be used to analyze if anything
|
43 |
+
// has changed.
|
44 |
+
$order->update_meta_data( WC_Stripe_Constants::PAYMENT_INTENT, $intent->jsonSerialize() );
|
45 |
+
$order->save();
|
46 |
+
|
47 |
+
if ( $intent->status === 'requires_confirmation' ) {
|
48 |
+
$intent = $this->gateway->paymentIntents->confirm( $intent->id );
|
49 |
+
if ( is_wp_error( $intent ) ) {
|
50 |
+
return $intent;
|
51 |
+
}
|
52 |
+
}
|
53 |
+
|
54 |
+
// the intent was processed.
|
55 |
+
if ( $intent->status === 'succeeded' || $intent->status === 'requires_capture' ) {
|
56 |
+
|
57 |
+
if ( isset( $intent['setup_future_usage'] ) && 'off_session' === $intent['setup_future_usage'] ) {
|
58 |
+
$result = $this->payment_method->save_payment_method( $this->payment_method->get_new_source_token(), $order );
|
59 |
+
if ( is_wp_error( $result ) ) {
|
60 |
+
$this->payment_method->set_payment_save_error( $order, $result );
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
+
// payment has been processed.
|
65 |
+
$charges = $intent->charges;
|
66 |
+
if ( count( $charges->data ) > 0 ) {
|
67 |
+
$charge = $charges->data[0];
|
68 |
+
|
69 |
+
return (object) array(
|
70 |
+
'complete_payment' => true,
|
71 |
+
'charge' => $charge,
|
72 |
+
);
|
73 |
+
}
|
74 |
+
}
|
75 |
+
if ( $intent->status === 'requires_source_action' || $intent->status === 'requires_action' ) {
|
76 |
+
return (object) array(
|
77 |
+
'complete_payment' => false,
|
78 |
+
'redirect' => $this->payment_method->get_payment_intent_checkout_url( $intent, $order ),
|
79 |
+
);
|
80 |
+
}
|
81 |
+
if ( $intent->status === 'requires_source' || $intent->status === 'requires_payment_method' ) {
|
82 |
+
return (object) array(
|
83 |
+
'complete_payment' => false,
|
84 |
+
'redirect' => $this->payment_method->get_payment_intent_checkout_url( $intent, $order ),
|
85 |
+
);
|
86 |
+
}
|
87 |
+
}
|
88 |
+
|
89 |
+
public function scheduled_subscription_payment( $amount, $order ) {
|
90 |
+
$args = $this->get_payment_intent_args( $order );
|
91 |
+
|
92 |
+
$args['confirm'] = true;
|
93 |
+
$args['off_session'] = true;
|
94 |
+
$args['payment_method'] = $this->payment_method->get_order_meta_data( WC_Stripe_Constants::PAYMENT_METHOD_TOKEN, $order );
|
95 |
+
|
96 |
+
if ( ( $customer = $this->payment_method->get_order_meta_data( WC_Stripe_Constants::CUSTOMER_ID, $order ) ) ) {
|
97 |
+
$args['customer'] = $customer;
|
98 |
+
}
|
99 |
+
|
100 |
+
$intent = $this->gateway->paymentIntents->mode( wc_stripe_order_mode( $order ) )->create( $args );
|
101 |
+
|
102 |
+
if ( is_wp_error( $intent ) ) {
|
103 |
+
return $intent;
|
104 |
+
} else {
|
105 |
+
$order->update_meta_data( WC_Stripe_Constants::PAYMENT_INTENT_ID, $intent->id );
|
106 |
+
|
107 |
+
$charge = $intent->charges->data[0];
|
108 |
+
|
109 |
+
if ( $intent->status === 'succeeded' || $intent->status === 'requires_capture' ) {
|
110 |
+
|
111 |
+
return (object) array(
|
112 |
+
'complete_payment' => true,
|
113 |
+
'charge' => $charge,
|
114 |
+
);
|
115 |
+
} else {
|
116 |
+
return (object) array(
|
117 |
+
'complete_payment' => false,
|
118 |
+
'charge' => $charge,
|
119 |
+
);
|
120 |
+
}
|
121 |
+
}
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
*
|
126 |
+
* {@inheritDoc}
|
127 |
+
*
|
128 |
+
* @see WC_Stripe_Payment::process_pre_order_payment()
|
129 |
+
*/
|
130 |
+
public function process_pre_order_payment( $order ) {
|
131 |
+
$args = $this->get_payment_intent_args( $order );
|
132 |
+
|
133 |
+
$args['confirm'] = true;
|
134 |
+
$args['off_session'] = true;
|
135 |
+
$args['payment_method'] = $this->payment_method->get_order_meta_data( WC_Stripe_Constants::PAYMENT_METHOD_TOKEN, $order );
|
136 |
+
|
137 |
+
if ( ( $customer = $this->payment_method->get_order_meta_data( WC_Stripe_Constants::CUSTOMER_ID, $order ) ) ) {
|
138 |
+
$args['customer'] = $customer;
|
139 |
+
}
|
140 |
+
|
141 |
+
$intent = $this->gateway->paymentIntents->mode( wc_stripe_order_mode( $order ) )->create( $args );
|
142 |
+
|
143 |
+
if ( is_wp_error( $intent ) ) {
|
144 |
+
return $intent;
|
145 |
+
} else {
|
146 |
+
$order->update_meta_data( WC_Stripe_Constants::PAYMENT_INTENT_ID, $intent->id );
|
147 |
+
|
148 |
+
$charge = $intent->charges->data[0];
|
149 |
+
|
150 |
+
if ( $intent->status === 'succeeded' || $intent->status === 'requires_capture' ) {
|
151 |
+
return (object) array(
|
152 |
+
'complete_payment' => true,
|
153 |
+
'charge' => $charge,
|
154 |
+
);
|
155 |
+
} else {
|
156 |
+
return (object) array(
|
157 |
+
'complete_payment' => false,
|
158 |
+
'charge' => $charge,
|
159 |
+
);
|
160 |
+
}
|
161 |
+
}
|
162 |
+
}
|
163 |
+
|
164 |
+
/**
|
165 |
+
* Compares the order's saved intent to the order's attributes.
|
166 |
+
* If there is a delta, then the payment intent can be updated. The intent should
|
167 |
+
* only be updated if this is the checkout page.
|
168 |
+
*
|
169 |
+
* @param WC_Order $order
|
170 |
+
*/
|
171 |
+
public function can_update_payment_intent( $order ) {
|
172 |
+
if ( ! is_checkout() || defined( WC_Stripe_Constants::REDIRECT_HANDLER ) ) {
|
173 |
+
return false;
|
174 |
+
}
|
175 |
+
$intent = $order->get_meta( WC_Stripe_Constants::PAYMENT_INTENT );
|
176 |
+
if ( $intent ) {
|
177 |
+
$order_hash = implode(
|
178 |
+
'_',
|
179 |
+
array(
|
180 |
+
wc_stripe_add_number_precision( $order->get_total(), $order->get_currency() ),
|
181 |
+
wc_stripe_get_customer_id( $order->get_user_id() ),
|
182 |
+
$this->payment_method->get_payment_method_from_request(),
|
183 |
+
$this->payment_method->get_payment_method_type(),
|
184 |
+
)
|
185 |
+
);
|
186 |
+
$intent_hash = implode(
|
187 |
+
'_',
|
188 |
+
array(
|
189 |
+
$intent['amount'],
|
190 |
+
$intent['customer'],
|
191 |
+
$intent['payment_method'],
|
192 |
+
isset( $intent['payment_method_types'] ) ? $intent['payment_method_types'][0] : '',
|
193 |
+
)
|
194 |
+
);
|
195 |
+
|
196 |
+
return $order_hash !== $intent_hash;
|
197 |
+
}
|
198 |
+
|
199 |
+
return false;
|
200 |
+
}
|
201 |
+
|
202 |
+
/**
|
203 |
+
*
|
204 |
+
* @param WC_Order $order
|
205 |
+
*/
|
206 |
+
public function get_payment_intent_args( $order, $new = true ) {
|
207 |
+
$this->add_general_order_args( $args, $order );
|
208 |
+
|
209 |
+
if ( $new ) {
|
210 |
+
$args['confirmation_method'] = $this->payment_method->get_confirmation_method( $order );
|
211 |
+
$args['capture_method'] = $this->payment_method->get_option( 'charge_type' ) === 'capture' ? 'automatic' : 'manual';
|
212 |
+
$args['confirm'] = false;
|
213 |
+
}
|
214 |
+
|
215 |
+
if ( get_option( 'woocommerce_stripe_email_receipt', 'no' ) === 'yes' && ( $email = $order->get_billing_email() ) ) {
|
216 |
+
$args['receipt_email'] = $email;
|
217 |
+
}
|
218 |
+
|
219 |
+
if ( ( $customer_id = wc_stripe_get_customer_id( $order->get_customer_id() ) ) ) {
|
220 |
+
$args['customer'] = $customer_id;
|
221 |
+
}
|
222 |
+
|
223 |
+
if ( $this->payment_method->should_save_payment_method( $order ) ) {
|
224 |
+
$args['setup_future_usage'] = 'off_session';
|
225 |
+
}
|
226 |
+
|
227 |
+
$args['payment_method_types'][] = $this->payment_method->get_payment_method_type();
|
228 |
+
|
229 |
+
$this->payment_method->add_stripe_order_args( $args, $order );
|
230 |
+
|
231 |
+
return apply_filters( 'wc_stripe_payment_intent_args', $args, $order, $this );
|
232 |
+
}
|
233 |
+
|
234 |
+
/**
|
235 |
+
*
|
236 |
+
* {@inheritDoc}
|
237 |
+
*
|
238 |
+
* @see WC_Stripe_Payment::capture_charge()
|
239 |
+
*/
|
240 |
+
public function capture_charge( $amount, $order ) {
|
241 |
+
$payment_intent = $this->payment_method->get_order_meta_data( WC_Stripe_Constants::PAYMENT_INTENT_ID, $order );
|
242 |
+
if ( empty( $payment_intent ) ) {
|
243 |
+
$charge = $this->gateway->charges->mode( wc_stripe_order_mode( $order ) )->retrieve( $order->get_transaction_id() );
|
244 |
+
$payment_intent = $charge->payment_intent;
|
245 |
+
$order->update_meta_data( WC_Stripe_Constants::PAYMENT_INTENT_ID, $payment_intent );
|
246 |
+
$order->save();
|
247 |
+
}
|
248 |
+
|
249 |
+
return $this->gateway->paymentIntents->mode( wc_stripe_order_mode( $order ) )->capture(
|
250 |
+
$payment_intent,
|
251 |
+
array(
|
252 |
+
'amount_to_capture' => wc_stripe_add_number_precision(
|
253 |
+
$amount,
|
254 |
+
$order->get_currency()
|
255 |
+
),
|
256 |
+
)
|
257 |
+
);
|
258 |
+
}
|
259 |
+
|
260 |
+
/**
|
261 |
+
*
|
262 |
+
* {@inheritDoc}
|
263 |
+
*
|
264 |
+
* @see WC_Stripe_Payment::void_charge()
|
265 |
+
*/
|
266 |
+
public function void_charge( $order ) {
|
267 |
+
// fetch the intent and check its status
|
268 |
+
$payment_intent = $this->gateway->paymentIntents->mode( wc_stripe_order_mode( $order ) )->retrieve( $order->get_meta( WC_Stripe_Constants::PAYMENT_INTENT_ID ) );
|
269 |
+
if ( is_wp_error( $payment_intent ) ) {
|
270 |
+
return $payment_intent;
|
271 |
+
}
|
272 |
+
$statuses = array( 'requires_payment_method', 'requires_capture', 'requires_confirmation', 'requires_action' );
|
273 |
+
if ( 'canceled' !== $payment_intent->status ) {
|
274 |
+
if ( in_array( $payment_intent->status, $statuses ) ) {
|
275 |
+
return $this->gateway->paymentIntents->mode( wc_stripe_order_mode( $order ) )->cancel( $payment_intent->id );
|
276 |
+
} elseif ( 'succeeded' === $payment_intent->status ) {
|
277 |
+
return $this->process_refund( $order, $order->get_total() );
|
278 |
+
}
|
279 |
+
}
|
280 |
+
}
|
281 |
+
|
282 |
+
/**
|
283 |
+
*
|
284 |
+
* {@inheritDoc}
|
285 |
+
*
|
286 |
+
* @see WC_Stripe_Payment::get_payment_method_from_charge()
|
287 |
+
*/
|
288 |
+
public function get_payment_method_from_charge( $charge ) {
|
289 |
+
return $charge->payment_method;
|
290 |
+
}
|
291 |
+
|
292 |
+
/**
|
293 |
+
*
|
294 |
+
* {@inheritDoc}
|
295 |
+
*
|
296 |
+
* @see WC_Stripe_Payment::add_order_payment_method()
|
297 |
+
*/
|
298 |
+
public function add_order_payment_method( &$args, $order ) {
|
299 |
+
$args['payment_method'] = $this->payment_method->get_payment_method_from_request();
|
300 |
+
if ( empty( $args['payment_method'] ) ) {
|
301 |
+
unset( $args['payment_method'] );
|
302 |
+
}
|
303 |
+
}
|
304 |
+
|
305 |
+
/**
|
306 |
+
*
|
307 |
+
* @param WC_Order $order
|
308 |
+
*/
|
309 |
+
public function can_use_payment_intent( $order ) {
|
310 |
+
$intent = $order->get_meta( WC_Stripe_Constants::PAYMENT_INTENT );
|
311 |
+
|
312 |
+
if ( $intent ) {
|
313 |
+
if ( $intent['confirmation_method'] != $this->payment_method->get_confirmation_method( $order ) ) {
|
314 |
+
return false;
|
315 |
+
}
|
316 |
+
|
317 |
+
// compare the active environment to the order's environment
|
318 |
+
if ( wc_stripe_order_mode( $order ) != wc_stripe_mode() ) {
|
319 |
+
return false;
|
320 |
+
}
|
321 |
+
|
322 |
+
return $intent;
|
323 |
+
}
|
324 |
+
|
325 |
+
return false;
|
326 |
+
}
|
327 |
+
|
328 |
+
/**
|
329 |
+
*
|
330 |
+
* {@inheritDoc}
|
331 |
+
*
|
332 |
+
* @see WC_Stripe_Payment::can_void_charge()
|
333 |
+
*/
|
334 |
+
public function can_void_order( $order ) {
|
335 |
+
return $order->get_meta( WC_Stripe_Constants::PAYMENT_INTENT_ID );
|
336 |
+
}
|
337 |
+
}
|
includes/class-wc-stripe-product-gateway-option.php
CHANGED
@@ -1,102 +1,109 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
* @
|
6 |
-
*
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
*
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
$this->product = $product;
|
44 |
-
}
|
45 |
-
|
46 |
-
|
47 |
-
$this->
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
$this->settings =
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
/**
|
5 |
+
* @since 3.1.2
|
6 |
+
* @package Stripe/Classes
|
7 |
+
* @author PaymentPlugins
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
class WC_Stripe_Product_Gateway_Option {
|
11 |
+
|
12 |
+
/**
|
13 |
+
*
|
14 |
+
* @var string
|
15 |
+
*/
|
16 |
+
private $id;
|
17 |
+
|
18 |
+
/**
|
19 |
+
*
|
20 |
+
* @var array
|
21 |
+
*/
|
22 |
+
private $settings = array();
|
23 |
+
|
24 |
+
/**
|
25 |
+
*
|
26 |
+
* @var WC_Product
|
27 |
+
*/
|
28 |
+
private $product;
|
29 |
+
|
30 |
+
/**
|
31 |
+
*
|
32 |
+
* @var WC_Payment_Gateway_Stripe
|
33 |
+
*/
|
34 |
+
private $payment_method;
|
35 |
+
|
36 |
+
/**
|
37 |
+
*
|
38 |
+
* @param int|WC_Product $product
|
39 |
+
* @param WC_Payment_Gateway_Stripe $payment_method
|
40 |
+
*/
|
41 |
+
public function __construct( $product, $payment_method ) {
|
42 |
+
if ( ! is_object( $product ) ) {
|
43 |
+
$this->product = wc_get_product( $product );
|
44 |
+
} else {
|
45 |
+
$this->product = $product;
|
46 |
+
}
|
47 |
+
$this->payment_method = $payment_method;
|
48 |
+
|
49 |
+
$this->init_settings();
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Return the ID of this product option.
|
54 |
+
*/
|
55 |
+
public function get_id() {
|
56 |
+
return '_' . $this->payment_method->id . '_options';
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Save the settings
|
61 |
+
*/
|
62 |
+
public function save() {
|
63 |
+
$this->product->update_meta_data( $this->get_id(), $this->settings );
|
64 |
+
$this->product->save();
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Initialzie the settings.
|
69 |
+
*/
|
70 |
+
public function init_settings() {
|
71 |
+
if ( ! $this->settings ) {
|
72 |
+
$this->settings = $this->product->get_meta( $this->get_id() );
|
73 |
+
$this->settings = is_array( $this->settings ) ? $this->settings : array();
|
74 |
+
$this->settings = wp_parse_args( $this->settings, $this->get_default_values() );
|
75 |
+
}
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Return default options build from the payment gateway's options.
|
80 |
+
* @return array
|
81 |
+
*/
|
82 |
+
public function get_default_values() {
|
83 |
+
return array(
|
84 |
+
'enabled' => $this->payment_method->product_checkout_enabled(),
|
85 |
+
'charge_type' => $this->payment_method->get_option( 'charge_type' ),
|
86 |
+
);
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
*
|
91 |
+
* @param string $key
|
92 |
+
* @param mixed $default
|
93 |
+
*/
|
94 |
+
public function get_option( $key, $default = null ) {
|
95 |
+
if ( ! isset( $this->settings[ $key ] ) && null != $default ) {
|
96 |
+
$this->settings[ $key ] = $default;
|
97 |
+
}
|
98 |
+
|
99 |
+
return $this->settings[ $key ];
|
100 |
+
}
|
101 |
+
|
102 |
+
public function set_option( $key, $value ) {
|
103 |
+
$this->settings[ $key ] = $value;
|
104 |
+
}
|
105 |
+
|
106 |
+
public function enabled() {
|
107 |
+
return $this->get_option( 'enabled', false );
|
108 |
+
}
|
109 |
+
}
|
includes/class-wc-stripe-product-option.php
CHANGED
@@ -1,102 +1,103 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
* @
|
5 |
-
* @
|
6 |
-
*
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
*
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
*
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
*
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
*
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
*
|
37 |
-
* @param
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
$this->product->
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
$this->settings =
|
72 |
-
$this->settings =
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
*
|
86 |
-
* @param
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
}
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @since 3.1.2
|
5 |
+
* @package Stripe/Classes
|
6 |
+
* @author PaymentPlugins
|
7 |
+
*
|
8 |
+
*/
|
9 |
+
class WC_Stripe_Product_Option {
|
10 |
+
|
11 |
+
/**
|
12 |
+
*
|
13 |
+
* @var string
|
14 |
+
*/
|
15 |
+
private $id;
|
16 |
+
|
17 |
+
/**
|
18 |
+
*
|
19 |
+
* @var array
|
20 |
+
*/
|
21 |
+
private $settings = array();
|
22 |
+
|
23 |
+
/**
|
24 |
+
*
|
25 |
+
* @var WC_Product
|
26 |
+
*/
|
27 |
+
private $product;
|
28 |
+
|
29 |
+
/**
|
30 |
+
*
|
31 |
+
* @var WC_Payment_Gateway_Stripe
|
32 |
+
*/
|
33 |
+
private $payment_method;
|
34 |
+
|
35 |
+
/**
|
36 |
+
*
|
37 |
+
* @param int|WC_Product $product
|
38 |
+
* @param WC_Payment_Gateway_Stripe $payment_method
|
39 |
+
*/
|
40 |
+
public function __construct( $product, $payment_method ) {
|
41 |
+
if ( ! is_object( $product ) ) {
|
42 |
+
$this->product = wc_get_product( $product );
|
43 |
+
} else {
|
44 |
+
$this->product = $product;
|
45 |
+
}
|
46 |
+
$this->payment_method = $payment_method;
|
47 |
+
|
48 |
+
$this->init_settings();
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Return the ID of this product option.
|
53 |
+
*/
|
54 |
+
public function get_id() {
|
55 |
+
return '_' . $this->payment_method->id . '_options';
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Save the settings
|
60 |
+
*/
|
61 |
+
public function save() {
|
62 |
+
$this->product->update_meta_data( $this->get_id(), $this->settings );
|
63 |
+
$this->product->save();
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Initialzie the settings.
|
68 |
+
*/
|
69 |
+
public function init_settings() {
|
70 |
+
if ( ! $this->settings ) {
|
71 |
+
$this->settings = $this->product->get_meta( $this->get_id() );
|
72 |
+
$this->settings = is_array( $this->settings ) ? $this->settings : array();
|
73 |
+
$this->settings = wp_parse_args( $this->settings, $this->get_default_values() );
|
74 |
+
}
|
75 |
+
}
|
76 |
+
|
77 |
+
public function get_default_values() {
|
78 |
+
return array(
|
79 |
+
'enabled' => $this->payment_method->product_checkout_enabled(),
|
80 |
+
'charge_type' => $this->payment_method->get_option( 'charge_type' ),
|
81 |
+
);
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
*
|
86 |
+
* @param string $key
|
87 |
+
* @param mixed $default
|
88 |
+
*/
|
89 |
+
public function get_option( $key, $default = null ) {
|
90 |
+
if ( ! isset( $this->settings[ $key ] ) && null != $default ) {
|
91 |
+
$this->settings[ $key ] = $default;
|
92 |
+
}
|
93 |
+
return $this->settings[ $key ];
|
94 |
+
}
|
95 |
+
|
96 |
+
public function set_option( $key, $value ) {
|
97 |
+
$this->settings[ $key ] = $value;
|
98 |
+
}
|
99 |
+
|
100 |
+
public function enabled() {
|
101 |
+
return $this->get_option( 'enabled', false );
|
102 |
+
}
|
103 |
+
}
|
includes/class-wc-stripe-redirect-handler.php
CHANGED
@@ -1,92 +1,91 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
/**
|
5 |
-
*
|
6 |
-
* @author PaymentPlugins
|
7 |
-
* @package Stripe/Classes
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
class WC_Stripe_Redirect_Handler {
|
11 |
-
|
12 |
-
public static function init() {
|
13 |
-
add_action
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
$payment_method->
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
WC_Stripe_Redirect_Handler::init ();
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
/**
|
5 |
+
*
|
6 |
+
* @author PaymentPlugins
|
7 |
+
* @package Stripe/Classes
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
class WC_Stripe_Redirect_Handler {
|
11 |
+
|
12 |
+
public static function init() {
|
13 |
+
add_action( 'template_redirect', array( __CLASS__, 'local_payment_redirect' ) );
|
14 |
+
add_action( 'get_header', array( __CLASS__, 'maybe_restore_cart' ), 100 );
|
15 |
+
}
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Check if this request is for a local payment redirect.
|
19 |
+
*/
|
20 |
+
public static function local_payment_redirect() {
|
21 |
+
if ( isset( $_GET['wc-stripe-local-gateway'], $_GET['_payment_nonce'] ) && wp_verify_nonce( $_GET['_payment_nonce'], 'local-payment' ) ) {
|
22 |
+
self::process_redirect();
|
23 |
+
}
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
*/
|
28 |
+
public static function process_redirect() {
|
29 |
+
if ( isset( $_GET['source'] ) ) {
|
30 |
+
$result = WC_Stripe_Gateway::load()->sources->retrieve( wc_clean( $_GET['source'] ) );
|
31 |
+
} else {
|
32 |
+
$result = WC_Stripe_Gateway::load()->paymentIntents->retrieve( wc_clean( $_GET['payment_intent'] ) );
|
33 |
+
}
|
34 |
+
if ( is_wp_error( $result ) ) {
|
35 |
+
wc_add_notice( sprintf( __( 'Error retrieving payment source. Reason: %s', 'woo-stripe-payment' ), $result->get_error_message() ), 'error' );
|
36 |
+
|
37 |
+
return;
|
38 |
+
} else {
|
39 |
+
define( WC_Stripe_Constants::REDIRECT_HANDLER, true );
|
40 |
+
$order_id = $result->metadata['order_id'];
|
41 |
+
$order = wc_get_order( wc_stripe_filter_order_id( $order_id, $result ) );
|
42 |
+
|
43 |
+
/**
|
44 |
+
*
|
45 |
+
* @var WC_Payment_Gateway_Stripe_Local_Payment $payment_method
|
46 |
+
*/
|
47 |
+
$payment_method = WC()->payment_gateways()->payment_gateways()[ $order->get_payment_method() ];
|
48 |
+
$redirect = $order->get_checkout_order_received_url();
|
49 |
+
|
50 |
+
if ( 'failed' === $result->status || 'requires_payment_method' === $result->status ) {
|
51 |
+
wc_add_notice( __( 'Payment authorization failed. Please select another payment method.', 'woo-stripe-payment' ), 'error' );
|
52 |
+
$order->update_status( 'failed', __( 'Payment authorization failed.', 'woo-stripe-payment' ) );
|
53 |
+
if ( $result instanceof \Stripe\PaymentIntent ) {
|
54 |
+
$order->update_meta_data( WC_Stripe_Constants::PAYMENT_INTENT, $result->jsonSerialize() );
|
55 |
+
}
|
56 |
+
|
57 |
+
return;
|
58 |
+
} elseif ( 'chargeable' === $result->status ) {
|
59 |
+
if ( ! $payment_method->has_order_lock( $order ) && ! $order->get_transaction_id() ) {
|
60 |
+
$payment_method->set_order_lock( $order );
|
61 |
+
$payment_method->set_new_source_token( $result->id );
|
62 |
+
wc_stripe_log_info( 'processing from redirect handler.' );
|
63 |
+
$result = $payment_method->process_payment( $order_id );
|
64 |
+
// we don't release the order lock so there aren't conflicts with the source.chargeable webhook
|
65 |
+
if ( $result['result'] === 'success' ) {
|
66 |
+
$redirect = $result['redirect'];
|
67 |
+
}
|
68 |
+
}
|
69 |
+
} elseif ( 'succeeded' == $result->status ) {
|
70 |
+
if ( ! $payment_method->has_order_lock( $order ) ) {
|
71 |
+
$payment_method->set_order_lock( $order );
|
72 |
+
$result = $payment_method->process_payment( $order_id );
|
73 |
+
if ( $result['result'] === 'success' ) {
|
74 |
+
$redirect = $result['redirect'];
|
75 |
+
}
|
76 |
+
}
|
77 |
+
}
|
78 |
+
wp_safe_redirect( $redirect );
|
79 |
+
exit();
|
80 |
+
}
|
81 |
+
}
|
82 |
+
|
83 |
+
public static function maybe_restore_cart() {
|
84 |
+
global $wp;
|
85 |
+
if ( isset( $wp->query_vars['order-received'] ) && isset( $_GET['wc_stripe_product_checkout'] ) ) {
|
86 |
+
add_action( 'woocommerce_cart_emptied', 'wc_stripe_restore_cart_after_product_checkout' );
|
87 |
+
}
|
88 |
+
}
|
89 |
+
}
|
90 |
+
|
91 |
+
WC_Stripe_Redirect_Handler::init();
|
|
includes/class-wc-stripe-rest-api.php
CHANGED
@@ -1,119 +1,113 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
/**
|
5 |
-
*
|
6 |
-
* @author PaymentPlugins
|
7 |
-
* @package Stripe/Classes
|
8 |
-
* @property WC_Stripe_Rest_Controller $order_actions
|
9 |
-
* @property WC_Stripe_Rest_Controller $cart
|
10 |
-
* @property WC_Stripe_Rest_Controller $checkout
|
11 |
-
* @property WC_Stripe_Rest_Controller $payment_intent
|
12 |
-
* @property WC_Stripe_Rest_Controller $googlepay
|
13 |
-
* @property WC_Stripe_Rest_Controller $settings
|
14 |
-
* @property WC_Stripe_Rest_Controller $webhook
|
15 |
-
* @property WC_Stripe_Rest_Controller $product_data
|
16 |
-
*/
|
17 |
-
class WC_Stripe_Rest_API {
|
18 |
-
|
19 |
-
/**
|
20 |
-
*
|
21 |
-
* @var array
|
22 |
-
*/
|
23 |
-
private $controllers = array();
|
24 |
-
|
25 |
-
public function __construct() {
|
26 |
-
$this->include_classes
|
27 |
-
add_action
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
$controller
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
}
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/
|
56 |
-
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/controllers/class-wc-stripe-controller-
|
57 |
-
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/controllers/class-wc-stripe-controller-payment-
|
58 |
-
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/controllers/class-wc-stripe-controller-
|
59 |
-
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/controllers/class-wc-stripe-controller-
|
60 |
-
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/controllers/class-wc-stripe-controller-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
$bool = false;
|
115 |
-
}
|
116 |
-
return $bool;
|
117 |
-
}
|
118 |
-
}
|
119 |
-
WC_Stripe_Rest_API::init ();
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
/**
|
5 |
+
*
|
6 |
+
* @author PaymentPlugins
|
7 |
+
* @package Stripe/Classes
|
8 |
+
* @property WC_Stripe_Rest_Controller $order_actions
|
9 |
+
* @property WC_Stripe_Rest_Controller $cart
|
10 |
+
* @property WC_Stripe_Rest_Controller $checkout
|
11 |
+
* @property WC_Stripe_Rest_Controller $payment_intent
|
12 |
+
* @property WC_Stripe_Rest_Controller $googlepay
|
13 |
+
* @property WC_Stripe_Rest_Controller $settings
|
14 |
+
* @property WC_Stripe_Rest_Controller $webhook
|
15 |
+
* @property WC_Stripe_Rest_Controller $product_data
|
16 |
+
*/
|
17 |
+
class WC_Stripe_Rest_API {
|
18 |
+
|
19 |
+
/**
|
20 |
+
*
|
21 |
+
* @var array
|
22 |
+
*/
|
23 |
+
private $controllers = array();
|
24 |
+
|
25 |
+
public function __construct() {
|
26 |
+
$this->include_classes();
|
27 |
+
add_action( 'rest_api_init', array( $this, 'register_routes' ) );
|
28 |
+
}
|
29 |
+
|
30 |
+
public static function init() {
|
31 |
+
add_filter( 'woocommerce_is_rest_api_request', array( __CLASS__, 'is_rest_api_request' ) );
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
*
|
36 |
+
* @param WC_Stripe_Rest_Controller $key
|
37 |
+
*/
|
38 |
+
public function __get( $key ) {
|
39 |
+
$controller = isset( $this->controllers[ $key ] ) ? $this->controllers[ $key ] : '';
|
40 |
+
if ( empty( $controller ) ) {
|
41 |
+
wc_doing_it_wrong( __FUNCTION__, sprintf( __( '%1$s is an invalid controller name.', 'woo-stripe-payment' ), $key ), wc_stripe()->version );
|
42 |
+
}
|
43 |
+
return $controller;
|
44 |
+
}
|
45 |
+
|
46 |
+
public function __set( $key, $value ) {
|
47 |
+
$this->controllers[ $key ] = $value;
|
48 |
+
}
|
49 |
+
|
50 |
+
private function include_classes() {
|
51 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/abstract/abstract-wc-stripe-rest-controller.php';
|
52 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/controllers/class-wc-stripe-controller-order-actions.php';
|
53 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/controllers/class-wc-stripe-controller-payment-intent.php';
|
54 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/controllers/class-wc-stripe-controller-cart.php';
|
55 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/controllers/class-wc-stripe-controller-checkout.php';
|
56 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/controllers/class-wc-stripe-controller-googlepay.php';
|
57 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/controllers/class-wc-stripe-controller-payment-method.php';
|
58 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/controllers/class-wc-stripe-controller-gateway-settings.php';
|
59 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/controllers/class-wc-stripe-controller-webhook.php';
|
60 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/controllers/class-wc-stripe-controller-product-data.php';
|
61 |
+
|
62 |
+
foreach ( $this->get_controllers() as $key => $class_name ) {
|
63 |
+
if ( class_exists( $class_name ) ) {
|
64 |
+
$this->{$key} = new $class_name();
|
65 |
+
}
|
66 |
+
}
|
67 |
+
}
|
68 |
+
|
69 |
+
public function register_routes() {
|
70 |
+
WC()->payment_gateways();
|
71 |
+
foreach ( $this->controllers as $key => $controller ) {
|
72 |
+
if ( is_callable( array( $controller, 'register_routes' ) ) ) {
|
73 |
+
$controller->{ 'register_routes' }();
|
74 |
+
}
|
75 |
+
}
|
76 |
+
}
|
77 |
+
|
78 |
+
public function get_controllers() {
|
79 |
+
$controllers = array(
|
80 |
+
'order_actions' => 'WC_Stripe_Controller_Order_Actions',
|
81 |
+
'checkout' => 'WC_Stripe_Controller_Checkout',
|
82 |
+
'cart' => 'WC_Stripe_Controller_Cart',
|
83 |
+
'payment_intent' => 'WC_Stripe_Controller_Payment_Intent',
|
84 |
+
'googlepay' => 'WC_Stripe_Controller_GooglePay',
|
85 |
+
'payment_method' => 'WC_Stripe_Controller_Payment_Method',
|
86 |
+
'settings' => 'WC_Stripe_Controller_Gateway_Settings',
|
87 |
+
'webhook' => 'WC_Stripe_Controller_Webhook',
|
88 |
+
'product_data' => 'WC_Stripe_Controller_Product_Data',
|
89 |
+
);
|
90 |
+
return apply_filters( 'wc_stripe_api_controllers', $controllers );
|
91 |
+
}
|
92 |
+
|
93 |
+
public function rest_url() {
|
94 |
+
return wc_stripe()->rest_url();
|
95 |
+
}
|
96 |
+
|
97 |
+
public function rest_uri() {
|
98 |
+
return wc_stripe()->rest_uri();
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Added after WC 3.6 so WC_STRIPE_PLUGIN_FILE_PATH, and Session are loaded for Stripe rest requests.
|
103 |
+
*
|
104 |
+
* @param bool $bool
|
105 |
+
*/
|
106 |
+
public static function is_rest_api_request( $bool ) {
|
107 |
+
if ( ! empty( $_SERVER['REQUEST_URI'] ) && strpos( $_SERVER['REQUEST_URI'], wc_stripe()->rest_uri() ) !== false ) {
|
108 |
+
$bool = false;
|
109 |
+
}
|
110 |
+
return $bool;
|
111 |
+
}
|
112 |
+
}
|
113 |
+
WC_Stripe_Rest_API::init();
|
|
|
|
|
|
|
|
|
|
|
|
includes/class-wc-stripe-update.php
CHANGED
@@ -1,62 +1,67 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
/**
|
5 |
-
*
|
6 |
-
* @author PaymentPlugins
|
7 |
-
* @package Stripe/Classes
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
class WC_Stripe_Update {
|
11 |
-
|
12 |
-
private static $updates =
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
}
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Performs an update on the plugin if required.
|
25 |
-
*/
|
26 |
-
public static function update() {
|
27 |
-
// if option is not set, make the default version 3.0.6.
|
28 |
-
$current_version = get_option
|
29 |
-
|
30 |
-
// if database version is less than plugin version, an update might be required.
|
31 |
-
if (version_compare
|
32 |
-
foreach ( self::$updates as $version => $path ) {
|
33 |
-
/*
|
34 |
-
* If the current version is less than the version in the loop, then perform upgrade.
|
35 |
-
*/
|
36 |
-
if (version_compare
|
37 |
-
$file = wc_stripe
|
38 |
-
if (file_exists
|
39 |
-
include $file;
|
40 |
-
}
|
41 |
-
$current_version = $version;
|
42 |
-
update_option
|
43 |
-
add_action
|
44 |
-
|
45 |
-
|
46 |
-
$message
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
/**
|
5 |
+
*
|
6 |
+
* @author PaymentPlugins
|
7 |
+
* @package Stripe/Classes
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
class WC_Stripe_Update {
|
11 |
+
|
12 |
+
private static $updates = array(
|
13 |
+
'3.0.7' => 'update-3.0.7.php',
|
14 |
+
'3.1.0' => 'update-3.1.0.php',
|
15 |
+
'3.1.1' => 'update-3.1.1.php',
|
16 |
+
'3.1.6' => 'update-3.1.6.php'
|
17 |
+
);
|
18 |
+
|
19 |
+
public static function init() {
|
20 |
+
add_action( 'init', array( __CLASS__, 'update' ) );
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Performs an update on the plugin if required.
|
25 |
+
*/
|
26 |
+
public static function update() {
|
27 |
+
// if option is not set, make the default version 3.0.6.
|
28 |
+
$current_version = get_option( 'stripe_wc_version', '3.0.6' );
|
29 |
+
|
30 |
+
// if database version is less than plugin version, an update might be required.
|
31 |
+
if ( version_compare( $current_version, wc_stripe()->version(), '<' ) ) {
|
32 |
+
foreach ( self::$updates as $version => $path ) {
|
33 |
+
/*
|
34 |
+
* If the current version is less than the version in the loop, then perform upgrade.
|
35 |
+
*/
|
36 |
+
if ( version_compare( $current_version, $version, '<' ) ) {
|
37 |
+
$file = wc_stripe()->plugin_path() . 'includes/updates/' . $path;
|
38 |
+
if ( file_exists( $file ) ) {
|
39 |
+
include $file;
|
40 |
+
}
|
41 |
+
$current_version = $version;
|
42 |
+
update_option( 'stripe_wc_version', $current_version );
|
43 |
+
add_action(
|
44 |
+
'admin_notices',
|
45 |
+
function () use ( $current_version ) {
|
46 |
+
$message = sprintf( __( 'Thank you for updating Stripe for WooCommerce to version %1$s.', 'woo-stripe-payment' ), $current_version );
|
47 |
+
if ( ( $text = self::get_messages( $current_version ) ) ) {
|
48 |
+
$message .= ' ' . $text;
|
49 |
+
}
|
50 |
+
printf( '<div class="notice notice-success is-dismissible"><p>%1$s</p></div>', $message );
|
51 |
+
}
|
52 |
+
);
|
53 |
+
}
|
54 |
+
}
|
55 |
+
// save latest version.
|
56 |
+
update_option( 'stripe_wc_version', wc_stripe()->version() );
|
57 |
+
}
|
58 |
+
}
|
59 |
+
|
60 |
+
public static function get_messages( $version ) {
|
61 |
+
$messages = array();
|
62 |
+
|
63 |
+
return isset( $messages[ $version ] ) ? $messages[ $version ] : false;
|
64 |
+
}
|
65 |
+
}
|
66 |
+
|
67 |
+
WC_Stripe_Update::init();
|
includes/controllers/class-wc-stripe-controller-cart.php
CHANGED
@@ -1,335 +1,358 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Controller class that perfors cart operations for client side requests.
|
6 |
-
*
|
7 |
-
* @author PaymentPlugins
|
8 |
-
* @package Stripe/Controllers
|
9 |
-
*
|
10 |
-
*/
|
11 |
-
class WC_Stripe_Controller_Cart extends WC_Stripe_Rest_Controller {
|
12 |
-
|
13 |
-
use WC_Stripe_Controller_Cart_Trait;
|
14 |
-
|
15 |
-
protected $namespace = 'cart';
|
16 |
-
|
17 |
-
public function register_routes() {
|
18 |
-
register_rest_route
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
'
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
'
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
'
|
48 |
-
'
|
49 |
-
|
50 |
-
|
51 |
-
'
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
'
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
*
|
94 |
-
*
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
'
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
*
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
$
|
157 |
-
|
158 |
-
|
159 |
-
*
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
'
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
$
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
$
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
*
|
324 |
-
*
|
325 |
-
* @
|
326 |
-
*/
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Controller class that perfors cart operations for client side requests.
|
6 |
+
*
|
7 |
+
* @author PaymentPlugins
|
8 |
+
* @package Stripe/Controllers
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
class WC_Stripe_Controller_Cart extends WC_Stripe_Rest_Controller {
|
12 |
+
|
13 |
+
use WC_Stripe_Controller_Cart_Trait;
|
14 |
+
|
15 |
+
protected $namespace = 'cart';
|
16 |
+
|
17 |
+
public function register_routes() {
|
18 |
+
register_rest_route(
|
19 |
+
$this->rest_uri(),
|
20 |
+
'shipping-method',
|
21 |
+
array(
|
22 |
+
'methods' => WP_REST_Server::CREATABLE,
|
23 |
+
'callback' => array( $this, 'update_shipping_method' ),
|
24 |
+
'args' => array(
|
25 |
+
'shipping_methods' => array( 'required' => true ),
|
26 |
+
'payment_method' => array( 'required' => true ),
|
27 |
+
),
|
28 |
+
)
|
29 |
+
);
|
30 |
+
register_rest_route(
|
31 |
+
$this->rest_uri(),
|
32 |
+
'shipping-address',
|
33 |
+
array(
|
34 |
+
'methods' => WP_REST_Server::CREATABLE,
|
35 |
+
'callback' => array( $this, 'update_shipping_address' ),
|
36 |
+
'args' => array(
|
37 |
+
'address' => array( 'required' => true ),
|
38 |
+
'payment_method' => array( 'required' => true ),
|
39 |
+
),
|
40 |
+
)
|
41 |
+
);
|
42 |
+
register_rest_route(
|
43 |
+
$this->rest_uri(),
|
44 |
+
'add-to-cart',
|
45 |
+
array(
|
46 |
+
'methods' => WP_REST_Server::CREATABLE,
|
47 |
+
'callback' => array( $this, 'add_to_cart' ),
|
48 |
+
'args' => array(
|
49 |
+
'product_id' => array( 'required' => true ),
|
50 |
+
'qty' => array(
|
51 |
+
'required' => true,
|
52 |
+
'validate_callback' => array( $this, 'validate_quantity' ),
|
53 |
+
),
|
54 |
+
'payment_method' => array( 'required' => true ),
|
55 |
+
),
|
56 |
+
)
|
57 |
+
);
|
58 |
+
/**
|
59 |
+
*
|
60 |
+
* @since 3.0.6
|
61 |
+
*/
|
62 |
+
register_rest_route(
|
63 |
+
$this->rest_uri(),
|
64 |
+
'cart-calculation',
|
65 |
+
array(
|
66 |
+
'methods' => WP_REST_Server::CREATABLE,
|
67 |
+
'callback' => array( $this, 'cart_calculation' ),
|
68 |
+
'args' => array(
|
69 |
+
'product_id' => array( 'required' => true ),
|
70 |
+
'qty' => array(
|
71 |
+
'required' => true,
|
72 |
+
'validate_callback' => array( $this, 'validate_quantity' ),
|
73 |
+
),
|
74 |
+
'payment_method' => array( 'required' => true ),
|
75 |
+
),
|
76 |
+
)
|
77 |
+
);
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
*
|
82 |
+
* @param int $qty
|
83 |
+
* @param WP_REST_Request $request
|
84 |
+
*/
|
85 |
+
public function validate_quantity( $qty, $request ) {
|
86 |
+
if ( $qty == 0 ) {
|
87 |
+
return $this->add_validation_error( new WP_Error( 'cart-error', __( 'Quantity must be greater than zero.', 'woo-stripe-payment' ) ) );
|
88 |
+
}
|
89 |
+
return true;
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Update the shipping method chosen by the customer.
|
94 |
+
*
|
95 |
+
* @param WP_REST_Request $request
|
96 |
+
*/
|
97 |
+
public function update_shipping_method( $request ) {
|
98 |
+
wc_maybe_define_constant( 'WOOCOMMERCE_CART', true );
|
99 |
+
$shipping_methods = $request->get_param( 'shipping_methods' );
|
100 |
+
$payment_method = $request->get_param( 'payment_method' );
|
101 |
+
/**
|
102 |
+
*
|
103 |
+
* @var WC_Payment_Gateway_Stripe $gateway
|
104 |
+
*/
|
105 |
+
$gateway = WC()->payment_gateways()->payment_gateways()[ $payment_method ];
|
106 |
+
|
107 |
+
wc_stripe_update_shipping_methods( $shipping_methods );
|
108 |
+
|
109 |
+
$this->add_ready_to_calc_shipping();
|
110 |
+
|
111 |
+
// if this request is coming from product page, stash cart and use product cart
|
112 |
+
if ( 'product' == $request->get_param( 'page_id' ) ) {
|
113 |
+
wc_stripe_stash_cart( WC()->cart );
|
114 |
+
} else {
|
115 |
+
WC()->cart->calculate_totals();
|
116 |
+
}
|
117 |
+
|
118 |
+
$response = rest_ensure_response(
|
119 |
+
apply_filters(
|
120 |
+
'wc_stripe_update_shipping_method_response',
|
121 |
+
array(
|
122 |
+
'data' => $gateway->get_update_shipping_method_response(
|
123 |
+
array(
|
124 |
+
'newData' => array(
|
125 |
+
'status' => 'success',
|
126 |
+
'total' => array(
|
127 |
+
'amount' => wc_stripe_add_number_precision( WC()->cart->total ),
|
128 |
+
'label' => __( 'Total', 'woo-stripe-payment' ),
|
129 |
+
'pending' => false,
|
130 |
+
),
|
131 |
+
'displayItems' => wc_stripe_get_display_items(),
|
132 |
+
'shippingOptions' => wc_stripe_get_shipping_options(),
|
133 |
+
),
|
134 |
+
'shipping_methods' => WC()->session->get(
|
135 |
+
'chosen_shipping_methods',
|
136 |
+
array()
|
137 |
+
),
|
138 |
+
)
|
139 |
+
),
|
140 |
+
)
|
141 |
+
)
|
142 |
+
);
|
143 |
+
if ( 'product' == $request->get_param( 'page_id' ) ) {
|
144 |
+
wc_stripe_restore_cart( WC()->cart );
|
145 |
+
}
|
146 |
+
return $response;
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
*
|
151 |
+
* @param WP_REST_Request $request
|
152 |
+
*/
|
153 |
+
public function update_shipping_address( $request ) {
|
154 |
+
wc_maybe_define_constant( 'WOOCOMMERCE_CART', true );
|
155 |
+
$address = $request->get_param( 'address' );
|
156 |
+
$payment_method = $request->get_param( 'payment_method' );
|
157 |
+
/**
|
158 |
+
*
|
159 |
+
* @var WC_Payment_Gateway_Stripe $gateway
|
160 |
+
*/
|
161 |
+
$gateway = WC()->payment_gateways()->payment_gateways()[ $payment_method ];
|
162 |
+
try {
|
163 |
+
wc_stripe_update_customer_location( $address );
|
164 |
+
|
165 |
+
$this->add_ready_to_calc_shipping();
|
166 |
+
|
167 |
+
if ( 'product' == $request->get_param( 'page_id' ) ) {
|
168 |
+
wc_stripe_stash_cart( WC()->cart );
|
169 |
+
} else {
|
170 |
+
WC()->cart->calculate_totals();
|
171 |
+
}
|
172 |
+
|
173 |
+
if ( ! $this->has_shipping_methods( WC()->shipping()->get_packages() ) ) {
|
174 |
+
throw new Exception( 'No valid shipping methods.' );
|
175 |
+
}
|
176 |
+
|
177 |
+
$response = rest_ensure_response(
|
178 |
+
apply_filters(
|
179 |
+
'wc_stripe_update_shipping_method_response',
|
180 |
+
array(
|
181 |
+
'data' => $gateway->get_update_shipping_address_response(
|
182 |
+
array(
|
183 |
+
'newData' => array(
|
184 |
+
'status' => 'success',
|
185 |
+
'total' => array(
|
186 |
+
'amount' => wc_stripe_add_number_precision( WC()->cart->total ),
|
187 |
+
'label' => __( 'Total', 'woo-stripe-payment' ),
|
188 |
+
'pending' => false,
|
189 |
+
),
|
190 |
+
'displayItems' => wc_stripe_get_display_items(),
|
191 |
+
'shippingOptions' => wc_stripe_get_shipping_options(),
|
192 |
+
),
|
193 |
+
)
|
194 |
+
),
|
195 |
+
)
|
196 |
+
)
|
197 |
+
);
|
198 |
+
} catch ( Exception $e ) {
|
199 |
+
$response = new WP_Error(
|
200 |
+
'address-error',
|
201 |
+
$e->getMessage(),
|
202 |
+
array(
|
203 |
+
'status' => 200,
|
204 |
+
'newData' => array( 'status' => 'invalid_shipping_address' ),
|
205 |
+
)
|
206 |
+
);
|
207 |
+
}
|
208 |
+
if ( 'product' == $request->get_param( 'page_id' ) ) {
|
209 |
+
wc_stripe_restore_cart( WC()->cart );
|
210 |
+
}
|
211 |
+
return $response;
|
212 |
+
}
|
213 |
+
|
214 |
+
/**
|
215 |
+
*
|
216 |
+
* @param WP_REST_Request $request
|
217 |
+
*/
|
218 |
+
public function add_to_cart( $request ) {
|
219 |
+
// WC 3.0.0 requires WOOCOMMERCE_CART to be defined.
|
220 |
+
wc_maybe_define_constant( 'WOOCOMMERCE_CART', true );
|
221 |
+
$payment_method = $request->get_param( 'payment_method' );
|
222 |
+
/**
|
223 |
+
*
|
224 |
+
* @var WC_Payment_Gateway_Stripe $gateway
|
225 |
+
*/
|
226 |
+
$gateway = WC()->payment_gateways()->payment_gateways()[ $payment_method ];
|
227 |
+
|
228 |
+
$product_id = $request->get_param( 'product_id' );
|
229 |
+
$qty = $request->get_param( 'qty' );
|
230 |
+
$variation_id = $request->get_param( 'variation_id' );
|
231 |
+
|
232 |
+
// stash cart so clean calculation can be performed.
|
233 |
+
wc_stripe_stash_cart( WC()->cart, false );
|
234 |
+
|
235 |
+
if ( WC()->cart->add_to_cart( $product_id, $qty, $variation_id ) == false ) {
|
236 |
+
return new WP_Error( 'cart-error', $this->get_error_messages(), array( 'status' => 200 ) );
|
237 |
+
} else {
|
238 |
+
// add to cart was successful. Send a new X-WP-Nonce since it will be different now that a WC session
|
239 |
+
// exists.
|
240 |
+
rest_get_server()->send_header( 'X-WP-Nonce', wp_create_nonce( 'wp_rest' ) );
|
241 |
+
$response = rest_ensure_response(
|
242 |
+
apply_filters(
|
243 |
+
'wc_stripe_add_to_cart_response',
|
244 |
+
array(
|
245 |
+
'data' => $gateway->add_to_cart_response(
|
246 |
+
array(
|
247 |
+
'total' => WC()->cart->total,
|
248 |
+
'subtotal' => WC()->cart->subtotal,
|
249 |
+
'totalCents' => wc_stripe_add_number_precision( WC()->cart->total ),
|
250 |
+
'displayItems' => wc_stripe_get_display_items(),
|
251 |
+
'shippingOptions' => wc_stripe_get_shipping_options(),
|
252 |
+
)
|
253 |
+
),
|
254 |
+
),
|
255 |
+
$gateway,
|
256 |
+
$request
|
257 |
+
)
|
258 |
+
);
|
259 |
+
// save the product cart so it can be used for shipping calculations etc.
|
260 |
+
wc_stripe_stash_product_cart( WC()->cart );
|
261 |
+
// put cart contents back to how they were before.
|
262 |
+
wc_stripe_restore_cart( WC()->cart );
|
263 |
+
return $response;
|
264 |
+
}
|
265 |
+
}
|
266 |
+
|
267 |
+
/**
|
268 |
+
* Performs a cart calculation
|
269 |
+
*
|
270 |
+
* @param WP_REST_Request $request
|
271 |
+
*/
|
272 |
+
public function cart_calculation( $request ) {
|
273 |
+
// WC 3.0.0 requires WOOCOMMERCE_CART to be defined.
|
274 |
+
wc_maybe_define_constant( 'WOOCOMMERCE_CART', true );
|
275 |
+
$product_id = $request->get_param( 'product_id' );
|
276 |
+
$qty = $request->get_param( 'qty' );
|
277 |
+
$variation_id = $request->get_param( 'variation_id' ) == null ? 0 : $request->get_param( 'variation_id' );
|
278 |
+
|
279 |
+
wc_stripe_stash_cart( WC()->cart, false );
|
280 |
+
|
281 |
+
if ( WC()->cart->add_to_cart( $product_id, $qty, $variation_id ) ) {
|
282 |
+
$payment_method = $request->get_param( 'payment_method' );
|
283 |
+
/**
|
284 |
+
*
|
285 |
+
* @var WC_Payment_Gateway_Stripe $gateway
|
286 |
+
*/
|
287 |
+
$gateway = WC()->payment_gateways()->payment_gateways()[ $payment_method ];
|
288 |
+
$response = rest_ensure_response(
|
289 |
+
apply_filters(
|
290 |
+
'wc_stripe_add_to_cart_response',
|
291 |
+
array(
|
292 |
+
'data' => $gateway->add_to_cart_response(
|
293 |
+
array(
|
294 |
+
'total' => WC()->cart->total,
|
295 |
+
'subtotal' => WC()->cart->subtotal,
|
296 |
+
'totalCents' => wc_stripe_add_number_precision( WC()->cart->total ),
|
297 |
+
'displayItems' => wc_stripe_get_display_items(),
|
298 |
+
'shippingOptions' => wc_stripe_get_shipping_options(),
|
299 |
+
)
|
300 |
+
),
|
301 |
+
),
|
302 |
+
$gateway,
|
303 |
+
$request
|
304 |
+
)
|
305 |
+
);
|
306 |
+
} else {
|
307 |
+
$response = new WP_Error( 'cart-error', $this->get_error_messages(), array( 'status' => 200 ) );
|
308 |
+
}
|
309 |
+
wc_stripe_stash_product_cart( WC()->cart );
|
310 |
+
wc_stripe_restore_cart( WC()->cart );
|
311 |
+
wc_clear_notices();
|
312 |
+
// add to cart was successful. Send a new X-WP-Nonce since it will be different now that a WC session exists.
|
313 |
+
rest_get_server()->send_header( 'X-WP-Nonce', wp_create_nonce( 'wp_rest' ) );
|
314 |
+
return $response;
|
315 |
+
}
|
316 |
+
|
317 |
+
protected function get_error_messages() {
|
318 |
+
return $this->get_messages( 'error' );
|
319 |
+
}
|
320 |
+
|
321 |
+
/**
|
322 |
+
*
|
323 |
+
* {@inheritDoc}
|
324 |
+
*
|
325 |
+
* @see WC_Stripe_Rest_Controller::get_messages()
|
326 |
+
*/
|
327 |
+
protected function get_messages( $types = 'all' ) {
|
328 |
+
$notices = wc_get_notices();
|
329 |
+
$message = '';
|
330 |
+
if ( $types !== 'all' ) {
|
331 |
+
$types = (array) $types;
|
332 |
+
foreach ( $notices as $type => $notice ) {
|
333 |
+
if ( ! in_array( $type, $types ) ) {
|
334 |
+
unset( $notices[ $type ] );
|
335 |
+
}
|
336 |
+
}
|
337 |
+
}
|
338 |
+
foreach ( $notices as $notice ) {
|
339 |
+
$message .= sprintf( ' %s', $notice );
|
340 |
+
}
|
341 |
+
|
342 |
+
return trim( $message );
|
343 |
+
}
|
344 |
+
|
345 |
+
/**
|
346 |
+
* Return true if the provided packages have shipping methods.
|
347 |
+
*
|
348 |
+
* @param array $packages
|
349 |
+
*/
|
350 |
+
private function has_shipping_methods( $packages ) {
|
351 |
+
foreach ( $packages as $i => $package ) {
|
352 |
+
if ( ! empty( $package['rates'] ) ) {
|
353 |
+
return true;
|
354 |
+
}
|
355 |
+
}
|
356 |
+
return false;
|
357 |
+
}
|
358 |
+
}
|
includes/controllers/class-wc-stripe-controller-checkout.php
CHANGED
@@ -1,229 +1,265 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
if (! class_exists
|
5 |
-
return;
|
6 |
-
}
|
7 |
-
|
8 |
-
|
9 |
-
*
|
10 |
-
* @
|
11 |
-
* @
|
12 |
-
*
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
*
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
$this->
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
}
|
157 |
-
|
158 |
-
private function
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
)
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
if ( ! class_exists( 'WC_Stripe_Rest_Controller' ) ) {
|
5 |
+
return;
|
6 |
+
}
|
7 |
+
|
8 |
+
/**
|
9 |
+
*
|
10 |
+
* @author PaymentPlugins
|
11 |
+
* @since 3.0.0
|
12 |
+
* @package Stripe/Controllers
|
13 |
+
*
|
14 |
+
*/
|
15 |
+
class WC_Stripe_Controller_Checkout extends WC_Stripe_Rest_Controller {
|
16 |
+
|
17 |
+
protected $namespace = '';
|
18 |
+
|
19 |
+
private $order_review = false;
|
20 |
+
|
21 |
+
/**
|
22 |
+
*
|
23 |
+
* @var WC_Payment_Gateway_Stripe
|
24 |
+
*/
|
25 |
+
private $gateway = null;
|
26 |
+
|
27 |
+
public function register_routes() {
|
28 |
+
register_rest_route(
|
29 |
+
$this->rest_uri(),
|
30 |
+
'checkout',
|
31 |
+
array(
|
32 |
+
'methods' => WP_REST_Server::CREATABLE,
|
33 |
+
'callback' => array(
|
34 |
+
$this,
|
35 |
+
'process_checkout',
|
36 |
+
),
|
37 |
+
)
|
38 |
+
);
|
39 |
+
register_rest_route(
|
40 |
+
$this->rest_uri(),
|
41 |
+
'order-pay',
|
42 |
+
array(
|
43 |
+
'methods' => WP_REST_Server::CREATABLE,
|
44 |
+
'callback' => array(
|
45 |
+
$this,
|
46 |
+
'process_order_pay',
|
47 |
+
),
|
48 |
+
)
|
49 |
+
);
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Process the WC Order
|
54 |
+
*
|
55 |
+
* @param WP_REST_Request $request
|
56 |
+
*/
|
57 |
+
public function process_checkout( $request ) {
|
58 |
+
wc_maybe_define_constant( 'DOING_AJAX', true );
|
59 |
+
$this->actions();
|
60 |
+
$checkout = WC()->checkout();
|
61 |
+
$payment_method = $request->get_param( 'payment_method' );
|
62 |
+
/**
|
63 |
+
*
|
64 |
+
* @var WC_Payment_Gateway_Stripe $gateway
|
65 |
+
*/
|
66 |
+
$this->gateway = $gateway = WC()->payment_gateways()->payment_gateways()[ $payment_method ];
|
67 |
+
|
68 |
+
$this->required_post_data();
|
69 |
+
|
70 |
+
$this->order_review = ! is_null( $request->get_param( 'order_review' ) ) && 'true' === $request->get_param( 'order_review' );
|
71 |
+
|
72 |
+
try {
|
73 |
+
do_action( 'wc_stripe_rest_process_checkout', $request, $gateway );
|
74 |
+
if ( ! is_user_logged_in() ) {
|
75 |
+
$this->create_customer( $request );
|
76 |
+
}
|
77 |
+
// set the checkout nonce so no exceptions are thrown.
|
78 |
+
$_REQUEST['_wpnonce'] = $_POST['_wpnonce'] = wp_create_nonce( 'woocommerce-process_checkout' );
|
79 |
+
|
80 |
+
if ( 'product' == $request->get_param( 'page_id' ) ) {
|
81 |
+
wc_stripe_stash_cart( WC()->cart );
|
82 |
+
$gateway->set_post_payment_process( array( $this, 'post_payment_processes' ) );
|
83 |
+
add_filter(
|
84 |
+
'woocommerce_get_checkout_order_received_url',
|
85 |
+
function ( $url, $order ) {
|
86 |
+
return add_query_arg( 'wc_stripe_product_checkout', $order->get_payment_method(), $url );
|
87 |
+
},
|
88 |
+
10,
|
89 |
+
2
|
90 |
+
);
|
91 |
+
|
92 |
+
$option = new WC_Stripe_Product_Gateway_Option( current( WC()->cart->get_cart() )['data'], $gateway );
|
93 |
+
$gateway->settings['charge_type'] = $option->get_option( 'charge_type' );
|
94 |
+
}
|
95 |
+
$checkout->process_checkout();
|
96 |
+
} catch ( Exception $e ) {
|
97 |
+
wc_add_notice( $e->getMessage(), 'error' );
|
98 |
+
}
|
99 |
+
if ( wc_notice_count( 'error' ) > 0 ) {
|
100 |
+
return $this->send_response( false );
|
101 |
+
}
|
102 |
+
return $this->send_response( true );
|
103 |
+
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
*
|
107 |
+
* @since 3.1.8
|
108 |
+
* @param WP_REST_Request $request
|
109 |
+
*/
|
110 |
+
public function process_order_pay( $request ) {
|
111 |
+
global $wp;
|
112 |
+
|
113 |
+
$wp->query_vars['order-pay'] = $request->get_param( 'order_id' );
|
114 |
+
|
115 |
+
wc_maybe_define_constant( WC_Stripe_Constants::WOOCOMMERCE_STRIPE_ORDER_PAY, true );
|
116 |
+
|
117 |
+
WC_Form_Handler::pay_action();
|
118 |
+
|
119 |
+
if ( wc_notice_count( 'error' ) > 0 ) {
|
120 |
+
return rest_ensure_response(
|
121 |
+
array(
|
122 |
+
'success' => false,
|
123 |
+
'message' => $this->get_messages( 'error' ),
|
124 |
+
)
|
125 |
+
);
|
126 |
+
}
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
*
|
131 |
+
* @param WP_REST_Request $request
|
132 |
+
*/
|
133 |
+
private function create_customer( $request ) {
|
134 |
+
$create = WC()->checkout()->is_registration_required();
|
135 |
+
// create an account for the user if it's required for things like subscriptions.
|
136 |
+
if ( wcs_stripe_active() && WC_Subscriptions_Cart::cart_contains_subscription() ) {
|
137 |
+
$create = true;
|
138 |
+
}
|
139 |
+
if ( $create ) {
|
140 |
+
$password = wp_generate_password();
|
141 |
+
$username = $email = $request->get_param( 'billing_email' );
|
142 |
+
$result = wc_create_new_customer( $email, $username, $password );
|
143 |
+
if ( $result instanceof WP_Error ) {
|
144 |
+
// for email exists errors you want customer to either login or use a different email address.
|
145 |
+
throw new Exception( $result->get_error_message() );
|
146 |
+
}
|
147 |
+
$this->customer_id = $result;
|
148 |
+
|
149 |
+
// log the customer in
|
150 |
+
wp_set_current_user( $this->customer_id );
|
151 |
+
wc_set_customer_auth_cookie( $this->customer_id );
|
152 |
+
|
153 |
+
// As we are now logged in, cart will need to refresh to receive updated nonces
|
154 |
+
WC()->session->set( 'reload_checkout', true );
|
155 |
+
}
|
156 |
+
}
|
157 |
+
|
158 |
+
private function send_response( $success ) {
|
159 |
+
$reload = WC()->session->get( 'reload_checkout', false );
|
160 |
+
$data = array(
|
161 |
+
'result' => $success ? 'success' : 'failure',
|
162 |
+
'messages' => $reload ? null : $this->get_error_messages(),
|
163 |
+
'reload' => $reload,
|
164 |
+
);
|
165 |
+
unset( WC()->session->reload_checkout );
|
166 |
+
return rest_ensure_response( $data );
|
167 |
+
}
|
168 |
+
|
169 |
+
public function validate_payment_method( $payment_method ) {
|
170 |
+
$gateways = WC()->payment_gateways()->payment_gateways();
|
171 |
+
return isset( $gateways[ $payment_method ] ) ? true : new WP_Error( 'validation-error', 'Please choose a valid payment method.' );
|
172 |
+
}
|
173 |
+
|
174 |
+
private function actions() {
|
175 |
+
add_action( 'woocommerce_after_checkout_validation', array( $this, 'after_checkout_validation' ), 10, 2 );
|
176 |
+
add_action( 'woocommerce_checkout_order_processed', array( $this, 'checkout_order_processed' ), 10, 3 );
|
177 |
+
}
|
178 |
+
|
179 |
+
/**
|
180 |
+
*
|
181 |
+
* @param WC_Order $order
|
182 |
+
* @param WC_Payment_Gateway_Stripe $gateway
|
183 |
+
*/
|
184 |
+
public function set_stashed_cart( $order, $gateway ) {
|
185 |
+
wc_stripe_restore_cart( WC()->cart );
|
186 |
+
}
|
187 |
+
|
188 |
+
/**
|
189 |
+
*
|
190 |
+
* @param array $data
|
191 |
+
* @param WP_Error $errors
|
192 |
+
*/
|
193 |
+
public function after_checkout_validation( $data, $errors ) {
|
194 |
+
if ( $errors->get_error_message( 'required-field' ) ) {
|
195 |
+
wc_add_notice(
|
196 |
+
apply_filters(
|
197 |
+
'wc_stripe_after_checkout_validation_notice',
|
198 |
+
sprintf(
|
199 |
+
__( 'Some required fields were missing. Please click %1$shere%2$s to complete your payment.', 'woo-stripe-payment' ),
|
200 |
+
'<a href="' .
|
201 |
+
$this->get_order_review_url() . '">',
|
202 |
+
'</a>'
|
203 |
+
),
|
204 |
+
$data,
|
205 |
+
$errors
|
206 |
+
),
|
207 |
+
'notice'
|
208 |
+
);
|
209 |
+
wp_send_json(
|
210 |
+
array(
|
211 |
+
'result' => 'failure',
|
212 |
+
'messages' => $this->get_messages( 'notice' ),
|
213 |
+
'reload' => false,
|
214 |
+
),
|
215 |
+
200
|
216 |
+
);
|
217 |
+
}
|
218 |
+
}
|
219 |
+
|
220 |
+
private function required_post_data() {
|
221 |
+
if ( WC()->cart->needs_shipping() ) {
|
222 |
+
$_POST['ship_to_different_address'] = true;
|
223 |
+
}
|
224 |
+
if ( wc_get_page_id( 'terms' ) > 0 ) {
|
225 |
+
$_POST['terms'] = 1;
|
226 |
+
}
|
227 |
+
}
|
228 |
+
|
229 |
+
private function get_order_review_url() {
|
230 |
+
return add_query_arg(
|
231 |
+
array(
|
232 |
+
'order_review' => 'true',
|
233 |
+
'payment_method' => $this->gateway->id,
|
234 |
+
'payment_nonce' => $this->gateway->get_payment_source(),
|
235 |
+
),
|
236 |
+
wc_get_checkout_url()
|
237 |
+
);
|
238 |
+
}
|
239 |
+
|
240 |
+
/**
|
241 |
+
*
|
242 |
+
* @param int $order_id
|
243 |
+
* @param array $posted_data
|
244 |
+
* @param WC_Order $order
|
245 |
+
*/
|
246 |
+
public function checkout_order_processed( $order_id, $posted_data, $order ) {
|
247 |
+
if ( $this->order_review ) {
|
248 |
+
wc_add_notice( __( 'Please review your order details then click Place Order.', 'woo-stripe-payment' ), 'notice' );
|
249 |
+
wp_send_json(
|
250 |
+
array(
|
251 |
+
'result' => 'success',
|
252 |
+
'redirect' => $this->get_order_review_url(),
|
253 |
+
),
|
254 |
+
200
|
255 |
+
);
|
256 |
+
}
|
257 |
+
}
|
258 |
+
|
259 |
+
public function post_payment_processes( $order, $gateway ) {
|
260 |
+
wc_stripe_restore_cart( WC()->cart );
|
261 |
+
$data = WC()->session->get( 'wc_stripe_cart', array() );
|
262 |
+
unset( $data['product_cart'] );
|
263 |
+
WC()->session->set( 'wc_stripe_cart', $data );
|
264 |
+
}
|
265 |
+
}
|
includes/controllers/class-wc-stripe-controller-gateway-settings.php
CHANGED
@@ -1,194 +1,237 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
/**
|
5 |
-
*
|
6 |
-
* @package Stripe/Controllers
|
7 |
-
* @author PaymentPlugins
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
class WC_Stripe_Controller_Gateway_Settings extends WC_Stripe_Rest_Controller {
|
11 |
-
|
12 |
-
protected $namespace = 'gateway-settings';
|
13 |
-
|
14 |
-
public function register_routes() {
|
15 |
-
register_rest_route
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
'
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
'
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
}
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
}
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
/**
|
5 |
+
*
|
6 |
+
* @package Stripe/Controllers
|
7 |
+
* @author PaymentPlugins
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
class WC_Stripe_Controller_Gateway_Settings extends WC_Stripe_Rest_Controller {
|
11 |
+
|
12 |
+
protected $namespace = 'gateway-settings';
|
13 |
+
|
14 |
+
public function register_routes() {
|
15 |
+
register_rest_route(
|
16 |
+
$this->rest_uri(),
|
17 |
+
'apple-domain',
|
18 |
+
array(
|
19 |
+
'methods' => WP_REST_Server::CREATABLE,
|
20 |
+
'callback' => array( $this, 'register_apple_domain' ),
|
21 |
+
'permission_callback' => array(
|
22 |
+
$this,
|
23 |
+
'admin_permission_check',
|
24 |
+
),
|
25 |
+
)
|
26 |
+
);
|
27 |
+
register_rest_route(
|
28 |
+
$this->rest_uri(),
|
29 |
+
'create-webook',
|
30 |
+
array(
|
31 |
+
'methods' => WP_REST_Server::CREATABLE,
|
32 |
+
'callback' => array( $this, 'create_webhook' ),
|
33 |
+
'permission_callback' => array(
|
34 |
+
$this,
|
35 |
+
'admin_permission_check',
|
36 |
+
),
|
37 |
+
)
|
38 |
+
);
|
39 |
+
register_rest_route(
|
40 |
+
$this->rest_uri(),
|
41 |
+
'connection-test',
|
42 |
+
array(
|
43 |
+
'methods' => WP_REST_Server::CREATABLE,
|
44 |
+
'callback' => array( $this, 'connection_test' ),
|
45 |
+
'permission_callback' => array(
|
46 |
+
$this,
|
47 |
+
'admin_permission_check',
|
48 |
+
),
|
49 |
+
)
|
50 |
+
);
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Register the site domain with Stripe for Apple Pay.
|
55 |
+
*
|
56 |
+
* @param WP_REST_Request $request
|
57 |
+
*/
|
58 |
+
public function register_apple_domain( $request ) {
|
59 |
+
$gateway = WC_Stripe_Gateway::load();
|
60 |
+
|
61 |
+
// try to add domain association file.
|
62 |
+
if ( isset( $_SERVER['DOCUMENT_ROOT'] ) ) {
|
63 |
+
$path = $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '.well-known';
|
64 |
+
$file = $path . DIRECTORY_SEPARATOR . 'apple-developer-merchantid-domain-association';
|
65 |
+
if ( ! file_exists( $file ) ) {
|
66 |
+
require_once( ABSPATH . '/wp-admin/includes/file.php' );
|
67 |
+
if ( function_exists( 'WP_Filesystem' ) && ( WP_Filesystem() ) ) {
|
68 |
+
/**
|
69 |
+
*
|
70 |
+
* @var WP_Filesystem_Base $wp_filesystem
|
71 |
+
*/
|
72 |
+
global $wp_filesystem;
|
73 |
+
if ( ! $wp_filesystem->is_dir( $path ) ) {
|
74 |
+
$wp_filesystem->mkdir( $path );
|
75 |
+
}
|
76 |
+
$contents = $wp_filesystem->get_contents( WC_STRIPE_PLUGIN_FILE_PATH . 'apple-developer-merchantid-domain-association' );
|
77 |
+
$wp_filesystem->put_contents( $file, $contents, 0755 );
|
78 |
+
}
|
79 |
+
}
|
80 |
+
}
|
81 |
+
$server_name = $_SERVER['SERVER_NAME'];
|
82 |
+
if ( strstr( $server_name, 'www.' ) ) {
|
83 |
+
$server_name_2 = str_replace( 'www.', '', $server_name );
|
84 |
+
} else {
|
85 |
+
$server_name_2 = 'www.' . $server_name;
|
86 |
+
}
|
87 |
+
$domains = array( $server_name, $server_name_2 );
|
88 |
+
try {
|
89 |
+
$api_key = wc_stripe_get_secret_key( 'live' );
|
90 |
+
if ( empty( $api_key ) ) {
|
91 |
+
throw new Exception( __( 'You cannot register your domain until you have configured your Live API keys.', 'woo-stripe-payment' ) );
|
92 |
+
}
|
93 |
+
// fetch the Apple domains
|
94 |
+
$registered_domains = $gateway->applePayDomains->mode( 'live' )->all( array( 'limit' => 50 ) );
|
95 |
+
if ( ! is_wp_error( $registered_domains ) && $registered_domains ) {
|
96 |
+
// loop through domains and delete if they match domain of site.
|
97 |
+
foreach ( $registered_domains->data as $domain ) {
|
98 |
+
if ( in_array( $domain->domain_name, $domains ) ) {
|
99 |
+
$gateway->applePayDomains->mode( 'live' )->delete( $domain->id );
|
100 |
+
}
|
101 |
+
}
|
102 |
+
}
|
103 |
+
$failures = 0;
|
104 |
+
foreach ( $domains as $domain ) {
|
105 |
+
$result = $gateway->applePayDomains->mode( 'live' )->create( array( 'domain_name' => $domain ) );
|
106 |
+
if ( is_wp_error( $result ) ) {
|
107 |
+
$failures ++;
|
108 |
+
if ( $failures > 1 ) {
|
109 |
+
throw new Exception( $result->get_error_message() );
|
110 |
+
}
|
111 |
+
}
|
112 |
+
}
|
113 |
+
} catch ( Exception $e ) {
|
114 |
+
return new WP_Error( 'domain-error', $e->getMessage(), array( 'status' => 200 ) );
|
115 |
+
}
|
116 |
+
|
117 |
+
return rest_ensure_response(
|
118 |
+
array(
|
119 |
+
'message' => sprintf(
|
120 |
+
__(
|
121 |
+
'Domain registered successfully. You can confirm in your Stripe Dashboard at https://dashboard.stripe.com/account/apple_pay.',
|
122 |
+
'woo-stripe-payment'
|
123 |
+
)
|
124 |
+
),
|
125 |
+
)
|
126 |
+
);
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* Create a Stripe webhook for the site.
|
131 |
+
*
|
132 |
+
* @param WP_REST_Request $request
|
133 |
+
*/
|
134 |
+
public function create_webhook( $request ) {
|
135 |
+
$url = wc_stripe()->rest_api->webhook->rest_url( 'webhook' );
|
136 |
+
$api_settings = wc_stripe()->api_settings;
|
137 |
+
$env = $request->get_param( 'environment' );
|
138 |
+
$gateway = new WC_Stripe_Gateway( $env );
|
139 |
+
// first fetch all webhooks
|
140 |
+
$private_key = wc_stripe_get_secret_key( $env );
|
141 |
+
if ( empty( $private_key ) ) {
|
142 |
+
return new WP_Error(
|
143 |
+
'webhook-error',
|
144 |
+
__( 'You must configure your secret key before creating webhooks.', 'woo-stripe-payment' ),
|
145 |
+
array(
|
146 |
+
'status' => 200,
|
147 |
+
)
|
148 |
+
);
|
149 |
+
}
|
150 |
+
$webhooks = $gateway->webhookEndpoints->all( array( 'limit' => 100 ) );
|
151 |
+
if ( ! is_wp_error( $webhooks ) ) {
|
152 |
+
// validate that the webhook hasn't already been created.
|
153 |
+
foreach ( $webhooks->data as $webhook ) {
|
154 |
+
if ( $webhook['url'] === $url ) {
|
155 |
+
return new WP_Error(
|
156 |
+
'webhook-error',
|
157 |
+
__( 'There is already a webhook configured for this site. If you want to delete the webhook, login to your Stripe Dashboard.', 'woo-stripe-payment' ),
|
158 |
+
array(
|
159 |
+
'status' => 200,
|
160 |
+
)
|
161 |
+
);
|
162 |
+
}
|
163 |
+
}
|
164 |
+
}
|
165 |
+
|
166 |
+
// create the webhooks and save it to the api settings.
|
167 |
+
$webhook = $gateway->webhookEndpoints->create(
|
168 |
+
array(
|
169 |
+
'url' => $url,
|
170 |
+
'enabled_events' => apply_filters(
|
171 |
+
'wc_stripe_webhook_events',
|
172 |
+
array(
|
173 |
+
'charge.failed',
|
174 |
+
'charge.succeeded',
|
175 |
+
'source.chargeable',
|
176 |
+
'payment_intent.succeeded',
|
177 |
+
)
|
178 |
+
),
|
179 |
+
)
|
180 |
+
);
|
181 |
+
if ( is_wp_error( $webhook ) ) {
|
182 |
+
return new WP_Error( $webhook->get_error_code(), $webhook->get_error_message(), array( 'status' => 200 ) );
|
183 |
+
} else {
|
184 |
+
$api_settings->update_option( "webhook_url_{$env}", $webhook['url'] );
|
185 |
+
$api_settings->update_option( "webhook_secret_{$env}", $webhook['secret'] );
|
186 |
+
$api_settings->update_option( "webhook_id_{$env}", $webhook['id'] );
|
187 |
+
|
188 |
+
return rest_ensure_response(
|
189 |
+
array(
|
190 |
+
'message' => sprintf(
|
191 |
+
__( 'Webhook created in Stripe for %s environment. You can test your webhook by logging in to the Stripe dashboard', 'woo-stripe-payment' ),
|
192 |
+
'live' ==
|
193 |
+
$env ? __( 'Live', 'woo-stripe-payment' ) : __( 'Test', 'woo-stripe-payment' )
|
194 |
+
),
|
195 |
+
'secret' => $webhook['secret'],
|
196 |
+
)
|
197 |
+
);
|
198 |
+
}
|
199 |
+
}
|
200 |
+
|
201 |
+
/**
|
202 |
+
* Perform a connection test
|
203 |
+
*
|
204 |
+
* @param WP_REST_Request $request
|
205 |
+
*/
|
206 |
+
public function connection_test( $request ) {
|
207 |
+
$mode = $request->get_param( 'mode' );
|
208 |
+
|
209 |
+
try {
|
210 |
+
// test the secret key
|
211 |
+
$response = WC_Stripe_Gateway::load()->customers->mode( $mode )->all( array( 'limit' => 1 ) );
|
212 |
+
|
213 |
+
if ( is_wp_error( $response ) ) {
|
214 |
+
throw new Exception( sprintf( __( 'Mode: %s. Invalid secret key. Please check your entry.', 'woo-stripe-payment' ), $mode ) );
|
215 |
+
}
|
216 |
+
|
217 |
+
// test the publishable key
|
218 |
+
$response = wp_remote_post(
|
219 |
+
'https://api.stripe.com/v1/payment_methods',
|
220 |
+
array(
|
221 |
+
'headers' => array( 'Content-Type' => 'application/x-www-form-urlencoded' ),
|
222 |
+
'body' => array( 'key' => wc_stripe_get_publishable_key( $mode ) ),
|
223 |
+
)
|
224 |
+
);
|
225 |
+
if ( is_wp_error( $response ) ) {
|
226 |
+
throw new Exception( sprintf( __( 'Mode: %s. Invalid publishable key. Please check your entry.', 'woo-stripe-payment' ), $mode ) );
|
227 |
+
}
|
228 |
+
if ( $response['response']['code'] == 401 ) {
|
229 |
+
throw new Exception( sprintf( __( 'Mode: %s. Invalid publishable key. Please check your entry.', 'woo-stripe-payment' ), $mode ) );
|
230 |
+
}
|
231 |
+
} catch ( Exception $e ) {
|
232 |
+
return new WP_Error( 'connection-failure', $e->getMessage(), array( 'status' => 200 ) );
|
233 |
+
}
|
234 |
+
|
235 |
+
return rest_ensure_response( array( 'message' => sprintf( __( 'Connection test to Stripe was successful. Mode: %s.', 'woo-stripe-payment' ), $mode ) ) );
|
236 |
+
}
|
237 |
+
}
|
includes/controllers/class-wc-stripe-controller-googlepay.php
CHANGED
@@ -1,154 +1,160 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
if (! class_exists
|
5 |
-
return;
|
6 |
-
}
|
7 |
-
|
8 |
-
|
9 |
-
*
|
10 |
-
* @
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
*
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
*
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
*
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
*
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
'
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
$
|
70 |
-
|
71 |
-
$this->
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
//
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
'shipping_methods'
|
98 |
-
'paymentRequestUpdate' => $this->get_payment_response_data
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
return
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
'
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
if ( ! class_exists( 'WC_Stripe_Rest_Controller' ) ) {
|
5 |
+
return;
|
6 |
+
}
|
7 |
+
|
8 |
+
/**
|
9 |
+
*
|
10 |
+
* @author PaymentPlugins
|
11 |
+
* @package Stripe/Controllers
|
12 |
+
*/
|
13 |
+
class WC_Stripe_Controller_GooglePay extends WC_Stripe_Rest_Controller {
|
14 |
+
|
15 |
+
use WC_Stripe_Controller_Cart_Trait;
|
16 |
+
|
17 |
+
protected $namespace = 'googlepay';
|
18 |
+
|
19 |
+
/**
|
20 |
+
*
|
21 |
+
* @var WC_Payment_Gateway_Stripe
|
22 |
+
*/
|
23 |
+
private $gateway;
|
24 |
+
|
25 |
+
/**
|
26 |
+
*
|
27 |
+
* @var string
|
28 |
+
*/
|
29 |
+
private $shipping_method_id;
|
30 |
+
|
31 |
+
/**
|
32 |
+
*
|
33 |
+
* @var array
|
34 |
+
*/
|
35 |
+
private $shipping_methods = array();
|
36 |
+
|
37 |
+
/**
|
38 |
+
*
|
39 |
+
* @var string
|
40 |
+
*/
|
41 |
+
private $reason_code;
|
42 |
+
|
43 |
+
public function register_routes() {
|
44 |
+
register_rest_route(
|
45 |
+
$this->rest_uri(),
|
46 |
+
'shipping-data',
|
47 |
+
array(
|
48 |
+
'methods' => WP_REST_Server::CREATABLE,
|
49 |
+
'callback' => array( $this, 'update_shipping_data' ),
|
50 |
+
'args' => array(
|
51 |
+
'shipping_address' => array( 'required' => true ),
|
52 |
+
'shipping_methods' => array( 'required' => false ),
|
53 |
+
'shipping_method_id' => array( 'required' => true ),
|
54 |
+
),
|
55 |
+
)
|
56 |
+
);
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Update the WC shipping data from the Google payment sheet.
|
61 |
+
*
|
62 |
+
* @param WP_REST_Request $request
|
63 |
+
*/
|
64 |
+
public function update_shipping_data( $request ) {
|
65 |
+
wc_maybe_define_constant( 'WOOCOMMERCE_CART', true );
|
66 |
+
$address = $request->get_param( 'shipping_address' );
|
67 |
+
$this->shipping_methods = $request->get_param( 'shipping_methods' );
|
68 |
+
$this->shipping_methods = null == $this->shipping_methods ? array() : $this->shipping_methods;
|
69 |
+
$this->shipping_method_id = $request->get_param( 'shipping_method_id' );
|
70 |
+
|
71 |
+
$this->gateway = WC()->payment_gateways()->payment_gateways()['stripe_googlepay'];
|
72 |
+
|
73 |
+
$this->add_ready_to_calc_shipping();
|
74 |
+
|
75 |
+
try {
|
76 |
+
if ( 'product' == $request->get_param( 'page_id' ) ) {
|
77 |
+
wc_stripe_stash_cart( WC()->cart );
|
78 |
+
}
|
79 |
+
wc_stripe_update_customer_location( $address );
|
80 |
+
|
81 |
+
wc_stripe_update_shipping_methods( $this->shipping_methods );
|
82 |
+
|
83 |
+
// update the WC cart with the new shipping options
|
84 |
+
WC()->cart->calculate_totals();
|
85 |
+
|
86 |
+
// if shipping address is not serviceable, throw an error.
|
87 |
+
if ( ! wc_stripe_shipping_address_serviceable() ) {
|
88 |
+
$this->reason_code = 'SHIPPING_ADDRESS_UNSERVICEABLE';
|
89 |
+
throw new Exception( __( 'Your shipping address is not serviceable.', 'woo-stripe-payment' ) );
|
90 |
+
}
|
91 |
+
|
92 |
+
$response = rest_ensure_response(
|
93 |
+
apply_filters(
|
94 |
+
'wc_stripe_googlepay_paymentdata_response',
|
95 |
+
array(
|
96 |
+
'data' => array(
|
97 |
+
'shipping_methods' => $this->get_shipping_methods(),
|
98 |
+
'paymentRequestUpdate' => $this->get_payment_response_data(),
|
99 |
+
),
|
100 |
+
)
|
101 |
+
)
|
102 |
+
);
|
103 |
+
if ( 'product' == $request->get_param( 'page_id' ) ) {
|
104 |
+
wc_stripe_restore_cart( WC()->cart );
|
105 |
+
}
|
106 |
+
return $response;
|
107 |
+
} catch ( Exception $e ) {
|
108 |
+
return new WP_Error(
|
109 |
+
'payment-data-error',
|
110 |
+
$e->getMessage(),
|
111 |
+
array(
|
112 |
+
'status' => 200,
|
113 |
+
'data' => array(
|
114 |
+
'error' => array(
|
115 |
+
'reason' => $this->reason_code,
|
116 |
+
'message' => $e->getMessage(),
|
117 |
+
'intent' => 'SHIPPING_ADDRESS',
|
118 |
+
),
|
119 |
+
),
|
120 |
+
)
|
121 |
+
);
|
122 |
+
}
|
123 |
+
}
|
124 |
+
|
125 |
+
/**
|
126 |
+
* Return a formatted array of response data required by the Google payment sheet.
|
127 |
+
*/
|
128 |
+
public function get_payment_response_data() {
|
129 |
+
return array(
|
130 |
+
'newTransactionInfo' => array(
|
131 |
+
'currencyCode' => get_woocommerce_currency(),
|
132 |
+
'totalPriceStatus' => 'FINAL',
|
133 |
+
'totalPrice' => strval( WC()->cart->total ),
|
134 |
+
'displayItems' => $this->gateway->get_display_items(),
|
135 |
+
'totalPriceLabel' => __( 'Total', 'woo-stripe-payment' ),
|
136 |
+
),
|
137 |
+
'newShippingOptionParameters' => array(
|
138 |
+
'shippingOptions' => $this->gateway->get_shipping_methods(),
|
139 |
+
'defaultSelectedOptionId' => $this->get_default_shipping_method(),
|
140 |
+
),
|
141 |
+
);
|
142 |
+
}
|
143 |
+
|
144 |
+
private function get_shipping_methods() {
|
145 |
+
return WC()->session->get( 'chosen_shipping_methods', array() );
|
146 |
+
}
|
147 |
+
|
148 |
+
/**
|
149 |
+
* Returns a default shipping method based on the chosen shipping methods.
|
150 |
+
*
|
151 |
+
* @return string
|
152 |
+
*/
|
153 |
+
private function get_default_shipping_method() {
|
154 |
+
$chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods', array() );
|
155 |
+
if ( ! empty( $chosen_shipping_methods ) ) {
|
156 |
+
return sprintf( '%s:%s', 0, current( $chosen_shipping_methods ) );
|
157 |
+
}
|
158 |
+
return $this->shipping_method_id;
|
159 |
+
}
|
160 |
+
}
|
includes/controllers/class-wc-stripe-controller-order-actions.php
CHANGED
@@ -1,300 +1,318 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
/**
|
5 |
-
*
|
6 |
-
* @author PaymentPlugins
|
7 |
-
* @package Stripe/Controllers
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
class WC_Stripe_Controller_Order_Actions extends WC_Stripe_Rest_Controller {
|
11 |
-
|
12 |
-
protected $namespace = 'order~action';
|
13 |
-
|
14 |
-
public function register_routes() {
|
15 |
-
register_rest_route
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
'
|
20 |
-
|
21 |
-
),
|
22 |
-
'args'
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
'
|
40 |
-
),
|
41 |
-
'permission_callback' => array( $this,
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
'
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
),
|
60 |
-
'permission_callback' => array( $this,
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
'
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
),
|
79 |
-
'permission_callback' => array( $this,
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
'
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
'
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
'
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
)
|
103 |
-
}
|
104 |
-
|
105 |
-
/**
|
106 |
-
* Return true if the order_id is a valid post.
|
107 |
-
*
|
108 |
-
* @param int $order_id
|
109 |
-
*/
|
110 |
-
public function validate_order_id($order_id) {
|
111 |
-
return null !== get_post
|
112 |
-
}
|
113 |
-
|
114 |
-
/**
|
115 |
-
*
|
116 |
-
* @param WP_REST_Request $request
|
117 |
-
*/
|
118 |
-
public function capture($request) {
|
119 |
-
$order_id = $request->get_param
|
120 |
-
$order
|
121 |
-
$amount
|
122 |
-
if (! is_numeric
|
123 |
-
return new WP_Error
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
$
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
$
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
$
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
}
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
) );
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
/**
|
5 |
+
*
|
6 |
+
* @author PaymentPlugins
|
7 |
+
* @package Stripe/Controllers
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
class WC_Stripe_Controller_Order_Actions extends WC_Stripe_Rest_Controller {
|
11 |
+
|
12 |
+
protected $namespace = 'order~action';
|
13 |
+
|
14 |
+
public function register_routes() {
|
15 |
+
register_rest_route(
|
16 |
+
$this->rest_uri(),
|
17 |
+
'capture',
|
18 |
+
array(
|
19 |
+
'methods' => WP_REST_Server::CREATABLE,
|
20 |
+
'callback' => array( $this, 'capture' ),
|
21 |
+
'permission_callback' => array( $this, 'admin_permission_check' ),
|
22 |
+
'args' => array(
|
23 |
+
'order_id' => array(
|
24 |
+
'required' => true,
|
25 |
+
'type' => 'int',
|
26 |
+
'validate_callback' => array( $this, 'validate_order_id' ),
|
27 |
+
),
|
28 |
+
'amount' => array(
|
29 |
+
'required' => true,
|
30 |
+
'type' => 'float',
|
31 |
+
),
|
32 |
+
),
|
33 |
+
)
|
34 |
+
);
|
35 |
+
register_rest_route(
|
36 |
+
$this->rest_uri(),
|
37 |
+
'void',
|
38 |
+
array(
|
39 |
+
'methods' => WP_REST_Server::CREATABLE,
|
40 |
+
'callback' => array( $this, 'void' ),
|
41 |
+
'permission_callback' => array( $this, 'admin_permission_check' ),
|
42 |
+
'args' => array(
|
43 |
+
'order_id' => array(
|
44 |
+
'required' => true,
|
45 |
+
'type' => 'number',
|
46 |
+
'validate_callback' => array(
|
47 |
+
$this,
|
48 |
+
'validate_order_id',
|
49 |
+
),
|
50 |
+
),
|
51 |
+
),
|
52 |
+
)
|
53 |
+
);
|
54 |
+
register_rest_route(
|
55 |
+
$this->rest_uri(),
|
56 |
+
'pay',
|
57 |
+
array(
|
58 |
+
'methods' => WP_REST_Server::CREATABLE,
|
59 |
+
'callback' => array( $this, 'process_payment' ),
|
60 |
+
'permission_callback' => array( $this, 'admin_permission_check' ),
|
61 |
+
'args' => array(
|
62 |
+
'order_id' => array(
|
63 |
+
'required' => true,
|
64 |
+
'type' => 'number',
|
65 |
+
'validate_callback' => array(
|
66 |
+
$this,
|
67 |
+
'validate_order_id',
|
68 |
+
),
|
69 |
+
),
|
70 |
+
),
|
71 |
+
)
|
72 |
+
);
|
73 |
+
register_rest_route(
|
74 |
+
$this->rest_uri(),
|
75 |
+
'customer-payment-methods',
|
76 |
+
array(
|
77 |
+
'methods' => WP_REST_Server::READABLE,
|
78 |
+
'callback' => array( $this, 'customer_payment_methods' ),
|
79 |
+
'permission_callback' => array( $this, 'admin_permission_check' ),
|
80 |
+
'args' => array(
|
81 |
+
'customer_id' => array(
|
82 |
+
'required' => true,
|
83 |
+
'type' => 'number',
|
84 |
+
),
|
85 |
+
),
|
86 |
+
)
|
87 |
+
);
|
88 |
+
register_rest_route(
|
89 |
+
$this->rest_uri(),
|
90 |
+
'charge-view',
|
91 |
+
array(
|
92 |
+
'methods' => WP_REST_Server::READABLE,
|
93 |
+
'callback' => array( $this, 'charge_view' ),
|
94 |
+
'permission_callback' => array( $this, 'admin_permission_check' ),
|
95 |
+
'args' => array(
|
96 |
+
'order_id' => array(
|
97 |
+
'required' => true,
|
98 |
+
'type' => 'number',
|
99 |
+
),
|
100 |
+
),
|
101 |
+
)
|
102 |
+
);
|
103 |
+
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Return true if the order_id is a valid post.
|
107 |
+
*
|
108 |
+
* @param int $order_id
|
109 |
+
*/
|
110 |
+
public function validate_order_id( $order_id ) {
|
111 |
+
return null !== get_post( $order_id );
|
112 |
+
}
|
113 |
+
|
114 |
+
/**
|
115 |
+
*
|
116 |
+
* @param WP_REST_Request $request
|
117 |
+
*/
|
118 |
+
public function capture( $request ) {
|
119 |
+
$order_id = $request->get_param( 'order_id' );
|
120 |
+
$order = wc_get_order( $order_id );
|
121 |
+
$amount = $request->get_param( 'amount' );
|
122 |
+
if ( ! is_numeric( $amount ) ) {
|
123 |
+
return new WP_Error(
|
124 |
+
'invalid_data',
|
125 |
+
__( 'Invalid amount entered.', 'woo-stripe-payment' ),
|
126 |
+
array(
|
127 |
+
'success' => false,
|
128 |
+
'status' => 200,
|
129 |
+
)
|
130 |
+
);
|
131 |
+
}
|
132 |
+
try {
|
133 |
+
/**
|
134 |
+
*
|
135 |
+
* @var WC_Payment_Gateway_Stripe $gateway
|
136 |
+
*/
|
137 |
+
$gateway = WC()->payment_gateways()->payment_gateways()[ $order->get_payment_method() ];
|
138 |
+
$result = $gateway->capture_charge( $amount, $order );
|
139 |
+
if ( is_wp_error( $result ) ) {
|
140 |
+
throw new Exception( $result->get_error_message() );
|
141 |
+
}
|
142 |
+
|
143 |
+
return rest_ensure_response( array() );
|
144 |
+
} catch ( Exception $e ) {
|
145 |
+
return new WP_Error( 'capture-error', $e->getMessage(), array( 'status' => 200 ) );
|
146 |
+
}
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
*
|
151 |
+
* @param WP_REST_Request $request
|
152 |
+
*/
|
153 |
+
public function void( $request ) {
|
154 |
+
$order_id = $request->get_param( 'order_id' );
|
155 |
+
$order = wc_get_order( $order_id );
|
156 |
+
/**
|
157 |
+
* When the order's status is set to cancelled, the wc_stripe_order_cancelled
|
158 |
+
* function is called, which voids the charge.
|
159 |
+
*/
|
160 |
+
$order->update_status( 'cancelled' );
|
161 |
+
|
162 |
+
return rest_ensure_response( array() );
|
163 |
+
}
|
164 |
+
|
165 |
+
/**
|
166 |
+
* Process a payment as an admin.
|
167 |
+
*
|
168 |
+
* @param WP_REST_Request $request
|
169 |
+
*/
|
170 |
+
public function process_payment( $request ) {
|
171 |
+
$order_id = $request->get_param( 'order_id' );
|
172 |
+
$payment_type = $request->get_param( 'payment_type' );
|
173 |
+
$order = wc_get_order( $order_id );
|
174 |
+
$use_token = $payment_type === 'token';
|
175 |
+
try {
|
176 |
+
// perform some validations
|
177 |
+
if ( $order->get_total() == 0 ) {
|
178 |
+
if ( ! wcs_stripe_active() ) {
|
179 |
+
throw new Exception( __( 'Order total must be greater than zero.', 'woo-stripe-payment' ) );
|
180 |
+
} else {
|
181 |
+
if ( ! wcs_order_contains_subscription( $order ) ) {
|
182 |
+
throw new Exception( __( 'Order total must be greater than zero.', 'woo-stripe-payment' ) );
|
183 |
+
}
|
184 |
+
}
|
185 |
+
}
|
186 |
+
// update the order's customer ID if it has changed.
|
187 |
+
if ( $order->get_customer_id() != $request->get_param( 'customer_id' ) ) {
|
188 |
+
$order->set_customer_id( $request->get_param( 'customer_id' ) );
|
189 |
+
}
|
190 |
+
|
191 |
+
if ( $order->get_transaction_id() ) {
|
192 |
+
throw new Exception( sprintf( __( 'This order has already been processed. Transaction ID: %1$s. Payment method: %2$s', 'woo-stripe-payment' ), $order->get_transaction_id(), $order->get_payment_method_title() ) );
|
193 |
+
}
|
194 |
+
if ( ! $use_token ) {
|
195 |
+
// only credit card payments are allowed for one off payments as an admin.
|
196 |
+
$payment_method = 'stripe_cc';
|
197 |
+
} elseif ( $payment_type === 'token' ) {
|
198 |
+
$token_id = intval( $request->get_param( 'payment_token_id' ) );
|
199 |
+
$token = WC_Payment_Tokens::get( $token_id );
|
200 |
+
if ( $token->get_user_id() !== $order->get_customer_id() ) {
|
201 |
+
throw new Exception( __( 'Order customer Id and payment method customer Id do not match.', 'woo-stripe-payment' ) );
|
202 |
+
}
|
203 |
+
$payment_method = $token->get_gateway_id();
|
204 |
+
}
|
205 |
+
/**
|
206 |
+
*
|
207 |
+
* @var WC_Payment_Gateway_Stripe $gateway
|
208 |
+
*/
|
209 |
+
$gateway = WC()->payment_gateways()->payment_gateways()[ $payment_method ];
|
210 |
+
// temporarily set the charge type of the gateway to whatever the admin has selected.
|
211 |
+
$gateway->settings['charge_type'] = $request->get_param( 'wc_stripe_charge_type' );
|
212 |
+
// set the payment gateway to the order.
|
213 |
+
$order->set_payment_method( $gateway->id );
|
214 |
+
$order->save();
|
215 |
+
if ( ! $use_token ) {
|
216 |
+
$_POST[ $gateway->token_key ] = $request->get_param( 'payment_nonce' );
|
217 |
+
} else {
|
218 |
+
$gateway->set_payment_method_token( $token->get_token() );
|
219 |
+
}
|
220 |
+
|
221 |
+
// set intent attribute off_session. Stripe requires confirm to be true to use off session.
|
222 |
+
add_filter(
|
223 |
+
'wc_stripe_payment_intent_args',
|
224 |
+
function ( $args ) {
|
225 |
+
$args['confirm'] = true;
|
226 |
+
$args['off_session'] = true;
|
227 |
+
|
228 |
+
return $args;
|
229 |
+
}
|
230 |
+
);
|
231 |
+
|
232 |
+
$result = $gateway->process_payment( $order_id );
|
233 |
+
|
234 |
+
if ( isset( $result['result'] ) && $result['result'] === 'success' ) {
|
235 |
+
return rest_ensure_response( array( 'success' => true ) );
|
236 |
+
} else {
|
237 |
+
// create a new order since updates to the order were made during the process_payment call.
|
238 |
+
$order = wc_get_order( $order_id );
|
239 |
+
$order->update_status( 'pending' );
|
240 |
+
|
241 |
+
return new WP_Error(
|
242 |
+
'order-error',
|
243 |
+
$this->get_error_messages(),
|
244 |
+
array(
|
245 |
+
'status' => 200,
|
246 |
+
'success' => false,
|
247 |
+
)
|
248 |
+
);
|
249 |
+
}
|
250 |
+
} catch ( Exception $e ) {
|
251 |
+
return new WP_Error( 'order-error', '<div class="woocommerce-error">' . $e->getMessage() . '</div>', array( 'status' => 200 ) );
|
252 |
+
}
|
253 |
+
}
|
254 |
+
|
255 |
+
/**
|
256 |
+
*
|
257 |
+
* @param WP_REST_Request $request
|
258 |
+
*/
|
259 |
+
public function customer_payment_methods( $request ) {
|
260 |
+
$customer_id = $request->get_param( 'customer_id' );
|
261 |
+
$tokens = array();
|
262 |
+
foreach ( WC()->payment_gateways()->payment_gateways() as $gateway ) {
|
263 |
+
if ( $gateway instanceof WC_Payment_Gateway_Stripe ) {
|
264 |
+
$tokens = array_merge( $tokens, WC_Payment_Tokens::get_customer_tokens( $customer_id, $gateway->id ) );
|
265 |
+
}
|
266 |
+
}
|
267 |
+
|
268 |
+
return rest_ensure_response(
|
269 |
+
array(
|
270 |
+
'payment_methods' => array_map(
|
271 |
+
function ( $payment_method ) {
|
272 |
+
return $payment_method->to_json();
|
273 |
+
},
|
274 |
+
$tokens
|
275 |
+
),
|
276 |
+
)
|
277 |
+
);
|
278 |
+
}
|
279 |
+
|
280 |
+
/**
|
281 |
+
*
|
282 |
+
* @param WP_REST_Request $request
|
283 |
+
*/
|
284 |
+
public function charge_view( $request ) {
|
285 |
+
$order = wc_get_order( absint( $request->get_param( 'order_id' ) ) );
|
286 |
+
/**
|
287 |
+
*
|
288 |
+
* @var WC_Payment_Gateway_Stripe $payment_method
|
289 |
+
*/
|
290 |
+
$payment_method = WC()->payment_gateways()->payment_gateways()[ $order->get_payment_method() ];
|
291 |
+
try {
|
292 |
+
// fetch the charge so data is up to date.
|
293 |
+
$charge = WC_Stripe_Gateway::load( wc_stripe_order_mode( $order ) )->charges->retrieve( $order->get_transaction_id() );
|
294 |
+
|
295 |
+
if ( is_wp_error( $charge ) ) {
|
296 |
+
throw new Exception( $charge->get_error_message() );
|
297 |
+
}
|
298 |
+
$order->update_meta_data( WC_Stripe_Constants::CHARGE_STATUS, $charge->status );
|
299 |
+
$order->save();
|
300 |
+
ob_start();
|
301 |
+
include wc_stripe()->plugin_path() . 'includes/admin/meta-boxes/views/html-charge-data-subview.php';
|
302 |
+
$html = ob_get_clean();
|
303 |
+
|
304 |
+
return rest_ensure_response(
|
305 |
+
array(
|
306 |
+
'data' => array(
|
307 |
+
'order_id' => $order->get_id(),
|
308 |
+
'order_number' => $order->get_order_number(),
|
309 |
+
'charge' => $charge->jsonSerialize(),
|
310 |
+
'html' => $html,
|
311 |
+
),
|
312 |
+
)
|
313 |
+
);
|
314 |
+
} catch ( Exception $e ) {
|
315 |
+
return new WP_Error( 'charge-error', $e->getMessage(), array( 'status' => 200 ) );
|
316 |
+
}
|
317 |
+
}
|
318 |
+
}
|
includes/controllers/class-wc-stripe-controller-payment-intent.php
CHANGED
@@ -1,88 +1,89 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Controller which handles Payment Intent related actions such as creation.
|
6 |
-
*
|
7 |
-
* @author PaymentPlugins
|
8 |
-
* @package Stripe/Controllers
|
9 |
-
*
|
10 |
-
*/
|
11 |
-
class WC_Stripe_Controller_Payment_Intent extends WC_Stripe_Rest_Controller {
|
12 |
-
|
13 |
-
protected $namespace = '';
|
14 |
-
|
15 |
-
public function register_routes() {
|
16 |
-
register_rest_route
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
}
|
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Controller which handles Payment Intent related actions such as creation.
|
6 |
+
*
|
7 |
+
* @author PaymentPlugins
|
8 |
+
* @package Stripe/Controllers
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
class WC_Stripe_Controller_Payment_Intent extends WC_Stripe_Rest_Controller {
|
12 |
+
|
13 |
+
protected $namespace = '';
|
14 |
+
|
15 |
+
public function register_routes() {
|
16 |
+
register_rest_route(
|
17 |
+
$this->rest_uri(),
|
18 |
+
'setup-intent',
|
19 |
+
array(
|
20 |
+
'methods' => WP_REST_Server::READABLE,
|
21 |
+
'callback' => array(
|
22 |
+
$this,
|
23 |
+
'create_setup_intent',
|
24 |
+
),
|
25 |
+
)
|
26 |
+
);
|
27 |
+
register_rest_route(
|
28 |
+
$this->rest_uri(),
|
29 |
+
'sync-payment-intent',
|
30 |
+
array(
|
31 |
+
'methods' => WP_REST_Server::CREATABLE,
|
32 |
+
'callback' => array( $this, 'sync_payment_intent' ),
|
33 |
+
'args' => array(
|
34 |
+
'order_id' => array( 'required' => true ),
|
35 |
+
'client_secret' => array( 'required' => true ),
|
36 |
+
),
|
37 |
+
)
|
38 |
+
);
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
*
|
43 |
+
* @param WP_REST_Request $request
|
44 |
+
*/
|
45 |
+
public function create_setup_intent( $request ) {
|
46 |
+
$intent = WC_Stripe_Gateway::load()->setupIntents->create( array( 'usage' => 'off_session' ) );
|
47 |
+
try {
|
48 |
+
if ( is_wp_error( $intent ) ) {
|
49 |
+
throw new Exception( $result->get_error_message() );
|
50 |
+
}
|
51 |
+
|
52 |
+
return rest_ensure_response( array( 'intent' => array( 'client_secret' => $intent->client_secret ) ) );
|
53 |
+
} catch ( Exception $e ) {
|
54 |
+
return new WP_Error(
|
55 |
+
'payment-intent-error',
|
56 |
+
sprintf( __( 'Error creating payment intent. Reason: %s', 'woo-stripe-payment' ), $e->getMessage() ),
|
57 |
+
array(
|
58 |
+
'status' => 200,
|
59 |
+
)
|
60 |
+
);
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
*
|
66 |
+
* @param WP_REST_Request $request
|
67 |
+
*/
|
68 |
+
public function sync_payment_intent( $request ) {
|
69 |
+
try {
|
70 |
+
$order = wc_get_order( absint( $request->get_param( 'order_id' ) ) );
|
71 |
+
if ( ! $order ) {
|
72 |
+
throw new Exception( __( 'Invalid order id provided', 'woo-stripe-payment' ) );
|
73 |
+
}
|
74 |
+
|
75 |
+
$intent = WC_Stripe_Gateway::load()->paymentIntents->retrieve( $order->get_meta( WC_Stripe_Constants::PAYMENT_INTENT_ID ) );
|
76 |
+
|
77 |
+
if ( ! hash_equals( $intent->client_secret, $request->get_param( 'client_secret' ) ) ) {
|
78 |
+
throw new Exception( __( 'You are not authorized to update this order.', 'woo-stripe-payment' ) );
|
79 |
+
}
|
80 |
+
|
81 |
+
$order->update_meta_data( WC_Stripe_Constants::PAYMENT_INTENT, $intent->jsonSerialize() );
|
82 |
+
$order->save();
|
83 |
+
|
84 |
+
return rest_ensure_response( array() );
|
85 |
+
} catch ( Exception $e ) {
|
86 |
+
return new WP_Error( 'payment-intent-error', $e->getMessage(), array( 'status' => 200 ) );
|
87 |
+
}
|
88 |
+
}
|
89 |
+
}
|
includes/controllers/class-wc-stripe-controller-payment-method.php
CHANGED
@@ -1,49 +1,52 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
/**
|
5 |
-
*
|
6 |
-
* @package Stripe/Controllers
|
7 |
-
* @author PaymentPlugins
|
8 |
-
* @since 3.0.0
|
9 |
-
*
|
10 |
-
*/
|
11 |
-
class WC_Stripe_Controller_Payment_Method extends WC_Stripe_Rest_Controller {
|
12 |
-
|
13 |
-
protected $namespace = 'payment-method';
|
14 |
-
|
15 |
-
public function register_routes() {
|
16 |
-
register_rest_route
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
*
|
31 |
-
*
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
/**
|
5 |
+
*
|
6 |
+
* @package Stripe/Controllers
|
7 |
+
* @author PaymentPlugins
|
8 |
+
* @since 3.0.0
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
class WC_Stripe_Controller_Payment_Method extends WC_Stripe_Rest_Controller {
|
12 |
+
|
13 |
+
protected $namespace = 'payment-method';
|
14 |
+
|
15 |
+
public function register_routes() {
|
16 |
+
register_rest_route(
|
17 |
+
$this->rest_uri(),
|
18 |
+
'token',
|
19 |
+
array(
|
20 |
+
'methods' => WP_REST_Server::CREATABLE,
|
21 |
+
'callback' => array(
|
22 |
+
$this,
|
23 |
+
'payment_method_from_token',
|
24 |
+
),
|
25 |
+
)
|
26 |
+
);
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Creates a PaymentMethod from a Token.
|
31 |
+
* Use case for this controller would be if a token
|
32 |
+
* is provided on the client side, but PaymentIntent is desired instead of a Charge. The token must be converted to
|
33 |
+
* a PaymentMethod for use in a PaymentIntent.
|
34 |
+
*
|
35 |
+
* @param WP_REST_Request $request
|
36 |
+
*
|
37 |
+
* @return WP_Error|WP_REST_Response|mixed
|
38 |
+
*/
|
39 |
+
public function payment_method_from_token( $request ) {
|
40 |
+
$result = WC_Stripe_Gateway::load()->paymentMethods->create(
|
41 |
+
array(
|
42 |
+
'type' => 'card',
|
43 |
+
'card' => array( 'token' => $request->get_param( 'token' ) ),
|
44 |
+
)
|
45 |
+
);
|
46 |
+
if ( is_wp_error( $result ) ) {
|
47 |
+
return new WP_Error( 'payment-method', $result->get_error_message(), array( 'status' => 200 ) );
|
48 |
+
}
|
49 |
+
|
50 |
+
return rest_ensure_response( array( 'payment_method' => $result->jsonSerialize() ) );
|
51 |
+
}
|
52 |
+
}
|
includes/controllers/class-wc-stripe-controller-product-data.php
CHANGED
@@ -1,79 +1,83 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
/**
|
5 |
-
*
|
6 |
-
* @since 3.1.2
|
7 |
-
* @author PaymentPlugins
|
8 |
-
* @package Stripe/Controllers
|
9 |
-
*
|
10 |
-
*/
|
11 |
-
class WC_Stripe_Controller_Product_Data extends WC_Stripe_Rest_Controller {
|
12 |
-
|
13 |
-
protected $namespace = 'product';
|
14 |
-
|
15 |
-
public function register_routes() {
|
16 |
-
register_rest_route
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
'
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
$
|
66 |
-
|
67 |
-
foreach ( $
|
68 |
-
$
|
69 |
-
$
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
/**
|
5 |
+
*
|
6 |
+
* @since 3.1.2
|
7 |
+
* @author PaymentPlugins
|
8 |
+
* @package Stripe/Controllers
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
class WC_Stripe_Controller_Product_Data extends WC_Stripe_Rest_Controller {
|
12 |
+
|
13 |
+
protected $namespace = 'product';
|
14 |
+
|
15 |
+
public function register_routes() {
|
16 |
+
register_rest_route(
|
17 |
+
$this->rest_uri(),
|
18 |
+
'gateway',
|
19 |
+
array(
|
20 |
+
'methods' => WP_REST_Server::CREATABLE,
|
21 |
+
'callback' => array( $this, 'toggle_gateway' ),
|
22 |
+
'permission_callback' => array(
|
23 |
+
$this,
|
24 |
+
'admin_permission_check',
|
25 |
+
),
|
26 |
+
)
|
27 |
+
);
|
28 |
+
register_rest_route(
|
29 |
+
$this->rest_uri(),
|
30 |
+
'save',
|
31 |
+
array(
|
32 |
+
'methods' => WP_REST_Server::CREATABLE,
|
33 |
+
'callback' => array( $this, 'save' ),
|
34 |
+
'permission_callback' => array(
|
35 |
+
$this,
|
36 |
+
'admin_permission_check',
|
37 |
+
),
|
38 |
+
)
|
39 |
+
);
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
*
|
44 |
+
* @param WP_REST_Request $request
|
45 |
+
*/
|
46 |
+
public function toggle_gateway( $request ) {
|
47 |
+
$product = wc_get_product( $request->get_param( 'product_id' ) );
|
48 |
+
$payment_method = WC()->payment_gateways()->payment_gateways()[ $request->get_param( 'gateway_id' ) ];
|
49 |
+
|
50 |
+
$option = new WC_Stripe_Product_Gateway_Option( $product, $payment_method );
|
51 |
+
$option->set_option( 'enabled', ! $option->enabled() );
|
52 |
+
$option->save();
|
53 |
+
return rest_ensure_response( array( 'enabled' => $option->enabled() ) );
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
*
|
58 |
+
* @param WP_REST_Request $request
|
59 |
+
*/
|
60 |
+
public function save( $request ) {
|
61 |
+
$gateways = $request->get_param( 'gateways' );
|
62 |
+
$charge_types = $request->get_param( 'charge_types' );
|
63 |
+
$payment_gateways = WC()->payment_gateways()->payment_gateways();
|
64 |
+
$product = wc_get_product( $request->get_param( 'product_id' ) );
|
65 |
+
$order = array();
|
66 |
+
$loop = 0;
|
67 |
+
foreach ( $gateways as $gateway ) {
|
68 |
+
$order[ $gateway ] = $loop;
|
69 |
+
$loop++;
|
70 |
+
}
|
71 |
+
$product->update_meta_data( WC_Stripe_Constants::PRODUCT_GATEWAY_ORDER, $order );
|
72 |
+
|
73 |
+
foreach ( $charge_types as $type ) {
|
74 |
+
$option = new WC_Stripe_Product_Gateway_Option( $product, $payment_gateways[ $type['gateway'] ] );
|
75 |
+
$option->set_option( 'charge_type', $type['value'] );
|
76 |
+
$option->save();
|
77 |
+
}
|
78 |
+
$product->update_meta_data( '_stripe_button_position', $request->get_param( 'position' ) );
|
79 |
+
|
80 |
+
$product->save();
|
81 |
+
return rest_ensure_response( array( 'order' => $order ) );
|
82 |
+
}
|
83 |
+
}
|
includes/controllers/class-wc-stripe-controller-webhook.php
CHANGED
@@ -1,58 +1,62 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
/**
|
5 |
-
*
|
6 |
-
* @author PaymentPlugins
|
7 |
-
* @package Stripe/Controllers
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
class WC_Stripe_Controller_Webhook extends WC_Stripe_Rest_Controller {
|
11 |
-
|
12 |
-
protected $namespace = '';
|
13 |
-
|
14 |
-
private $secret;
|
15 |
-
|
16 |
-
public function register_routes() {
|
17 |
-
register_rest_route
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
}
|
58 |
-
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
/**
|
5 |
+
*
|
6 |
+
* @author PaymentPlugins
|
7 |
+
* @package Stripe/Controllers
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
class WC_Stripe_Controller_Webhook extends WC_Stripe_Rest_Controller {
|
11 |
+
|
12 |
+
protected $namespace = '';
|
13 |
+
|
14 |
+
private $secret;
|
15 |
+
|
16 |
+
public function register_routes() {
|
17 |
+
register_rest_route(
|
18 |
+
$this->rest_uri(),
|
19 |
+
'webhook',
|
20 |
+
array(
|
21 |
+
'methods' => WP_REST_Server::CREATABLE,
|
22 |
+
'callback' => array(
|
23 |
+
$this,
|
24 |
+
'webhook',
|
25 |
+
),
|
26 |
+
)
|
27 |
+
);
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
*
|
32 |
+
* @param WP_REST_Request $request
|
33 |
+
*/
|
34 |
+
public function webhook( $request ) {
|
35 |
+
$payload = $request->get_body();
|
36 |
+
$json_payload = json_decode( $payload, true );
|
37 |
+
$mode = $json_payload['livemode'] == true ? 'live' : 'test';
|
38 |
+
$this->secret = wc_stripe()->api_settings->get_option( 'webhook_secret_' . $mode );
|
39 |
+
$header = isset( $_SERVER['HTTP_STRIPE_SIGNATURE'] ) ? $_SERVER['HTTP_STRIPE_SIGNATURE'] : '';
|
40 |
+
try {
|
41 |
+
$event = \Stripe\Webhook::constructEvent( $payload, $header, $this->secret );
|
42 |
+
// $event = \Stripe\StripeObject::constructFrom(json_decode($payload, true));
|
43 |
+
wc_stripe_log_info( sprintf( 'Webhook notification received: Event: %s. Payload: %s', $event->type, print_r( $payload, true ) ) );
|
44 |
+
$type = $event->type;
|
45 |
+
$type = str_replace( '.', '_', $type );
|
46 |
+
|
47 |
+
// allow functionality to hook in to the event action
|
48 |
+
do_action( 'wc_stripe_webhook_' . $type, $event->data->object, $request, $event );
|
49 |
+
|
50 |
+
return rest_ensure_response( apply_filters( 'wc_stripe_webhook_response', array(), $event, $request ) );
|
51 |
+
} catch ( \Stripe\Error\SignatureVerification $e ) {
|
52 |
+
wc_stripe_log_info( __( 'Invalid signature received. Verify that your webhook secret is correct.', 'woo-stripe-payment' ) );
|
53 |
+
return $this->send_error_response( __( 'Invalid signature received. Verify that your webhook secret is correct.', 'woo-stripe-payment' ), 401 );
|
54 |
+
} catch ( Exception $e ) {
|
55 |
+
return $this->send_error_response( $e->getMessage() );
|
56 |
+
}
|
57 |
+
}
|
58 |
+
|
59 |
+
private function send_error_response( $message, $code = 400 ) {
|
60 |
+
return new WP_Error( 'webhook-error', $message, array( 'status' => $code ) );
|
61 |
+
}
|
62 |
+
}
|
includes/gateways/class-wc-payment-gateway-stripe-ach-v2.php
DELETED
@@ -1,233 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
defined ( 'ABSPATH' ) || exit ();
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Gateway that processes ACH payments.
|
6 |
-
* Only available for U.S. based merchants at this time.
|
7 |
-
*
|
8 |
-
* @since 3.0.5
|
9 |
-
* @author Payment Plugins
|
10 |
-
* @package Stripe/Gateways
|
11 |
-
*
|
12 |
-
*/
|
13 |
-
class WC_Payment_Gateway_Stripe_ACH_V2 extends WC_Payment_Gateway_Stripe {
|
14 |
-
|
15 |
-
use WC_Stripe_Payment_Charge_Trait;
|
16 |
-
|
17 |
-
/**
|
18 |
-
*
|
19 |
-
* @var object
|
20 |
-
*/
|
21 |
-
public $metadata_key = '';
|
22 |
-
|
23 |
-
public function __construct() {
|
24 |
-
$this->synchronous = false;
|
25 |
-
$this->id = 'stripe_ach';
|
26 |
-
$this->tab_title = __ ( 'ACH', 'woo-stripe-payment' );
|
27 |
-
$this->template_name = 'ach.php';
|
28 |
-
$this->token_type = 'Stripe_ACH';
|
29 |
-
$this->method_title = __ ( 'Stripe ACH', 'woo-stripe-payment' );
|
30 |
-
$this->method_description = __ ( 'ACH gateway that integrates with your Stripe account.', 'woo-stripe-payment' );
|
31 |
-
$this->icon = wc_stripe ()->assets_url ( 'img/ach.svg' );
|
32 |
-
$this->order_button_text = __ ( 'Bank Payment', 'woo-stripe-payment' );
|
33 |
-
$this->metadata_key = $this->id . '_metadata';
|
34 |
-
parent::__construct ();
|
35 |
-
$this->settings[ 'charge_type' ] = 'capture';
|
36 |
-
}
|
37 |
-
|
38 |
-
public function get_payment_object() {
|
39 |
-
return new WC_Stripe_Payment_Charge ( $this, new WC_Stripe_Gateway_ACH () );
|
40 |
-
}
|
41 |
-
|
42 |
-
public static function init() {
|
43 |
-
add_action ( 'woocommerce_checkout_update_order_review', [
|
44 |
-
__CLASS__, 'update_order_review'
|
45 |
-
] );
|
46 |
-
}
|
47 |
-
|
48 |
-
/**
|
49 |
-
*
|
50 |
-
* {@inheritDoc}
|
51 |
-
*
|
52 |
-
* @see WC_Payment_Gateway::is_available()
|
53 |
-
*/
|
54 |
-
public function is_available() {
|
55 |
-
$is_available = parent::is_available ();
|
56 |
-
return $is_available && get_woocommerce_currency () == 'USD';
|
57 |
-
}
|
58 |
-
|
59 |
-
/**
|
60 |
-
*
|
61 |
-
* {@inheritDoc}
|
62 |
-
*
|
63 |
-
* @see WC_Payment_Gateway_Stripe::init_supports()
|
64 |
-
*/
|
65 |
-
public function init_supports() {
|
66 |
-
/*
|
67 |
-
* $this->supports = [ 'tokenization', 'products',
|
68 |
-
* 'refunds'
|
69 |
-
* ];
|
70 |
-
*/
|
71 |
-
parent::init_supports ();
|
72 |
-
unset ( $this->supports[ 'add_payment_method' ] );
|
73 |
-
}
|
74 |
-
|
75 |
-
/**
|
76 |
-
*
|
77 |
-
* {@inheritDoc}
|
78 |
-
*
|
79 |
-
* @see WC_Payment_Gateway_Stripe::enqueue_checkout_scripts()
|
80 |
-
*/
|
81 |
-
public function enqueue_checkout_scripts($scripts) {
|
82 |
-
$scripts->enqueue_script ( 'ach', $scripts->assets_url ( 'js/frontend/ach-payments.js' ), array(
|
83 |
-
$scripts->get_handle ( 'external' ),
|
84 |
-
$scripts->get_handle ( 'plaid' )
|
85 |
-
) );
|
86 |
-
$scripts->localize_script ( 'ach', $this->get_localized_params () );
|
87 |
-
}
|
88 |
-
|
89 |
-
public function get_localized_params() {
|
90 |
-
return array_merge_recursive ( parent::get_localized_params (), array(
|
91 |
-
'env' => $this->get_plaid_environment (),
|
92 |
-
'client_name' => $this->get_option ( 'client_name' ),
|
93 |
-
'public_key' => '3a5433ed5ff7229aef78bb4d87a63a',
|
94 |
-
'metadata_key' => '[name="' . $this->metadata_key . '"]',
|
95 |
-
'fees_enabled' => $this->fees_enabled ()
|
96 |
-
) );
|
97 |
-
}
|
98 |
-
|
99 |
-
/**
|
100 |
-
*
|
101 |
-
* {@inheritDoc}
|
102 |
-
*
|
103 |
-
* @see WC_Payment_Gateway_Stripe_Charge::process_payment()
|
104 |
-
*/
|
105 |
-
public function process_payment($order_id) {
|
106 |
-
$this->payment_object->get_gateway ()->set_plaid_environment ( $this->get_option ( 'environment' ) );
|
107 |
-
$this->payment_object->get_gateway ()->set_public_token ( $this->get_public_token () );
|
108 |
-
$this->payment_object->get_gateway ()->set_account_id ( $this->get_metadata ()[ 'account_id' ] );
|
109 |
-
|
110 |
-
return parent::process_payment ( $order_id );
|
111 |
-
}
|
112 |
-
|
113 |
-
public function get_plaid_environment() {
|
114 |
-
return $this->get_option ( 'environment' );
|
115 |
-
}
|
116 |
-
|
117 |
-
private function get_metadata() {
|
118 |
-
return isset ( $_POST[ $this->metadata_key ] ) ? json_decode ( stripslashes ( $_POST[ $this->metadata_key ] ), true ) : null;
|
119 |
-
}
|
120 |
-
|
121 |
-
private function get_public_token() {
|
122 |
-
return $this->get_new_source_token ();
|
123 |
-
}
|
124 |
-
|
125 |
-
public function get_saved_methods_label() {
|
126 |
-
return __ ( 'Saved Banks', 'woo-stripe-payment' );
|
127 |
-
}
|
128 |
-
|
129 |
-
public function get_new_method_label() {
|
130 |
-
return __ ( 'New Bank', 'woo-stripe-payment' );
|
131 |
-
}
|
132 |
-
|
133 |
-
public function generate_ach_fee_html($key, $data) {
|
134 |
-
$field_key = $this->get_field_key ( $key );
|
135 |
-
$defaults = array( 'title' => '',
|
136 |
-
'disabled' => false, 'class' => '',
|
137 |
-
'css' => 'max-width: 150px; min-width: 150px;',
|
138 |
-
'placeholder' => '', 'type' => 'text',
|
139 |
-
'desc_tip' => false, 'description' => '',
|
140 |
-
'custom_attributes' => array(),
|
141 |
-
'options' => array()
|
142 |
-
);
|
143 |
-
$data = wp_parse_args ( $data, $defaults );
|
144 |
-
ob_start ();
|
145 |
-
include wc_stripe ()->plugin_path () . 'includes/admin/views/html-ach-fee.php';
|
146 |
-
return ob_get_clean ();
|
147 |
-
}
|
148 |
-
|
149 |
-
/**
|
150 |
-
*
|
151 |
-
* @param string $key
|
152 |
-
* @param array $value
|
153 |
-
*/
|
154 |
-
public function validate_ach_fee_field($key, $value) {
|
155 |
-
$value = empty ( $value ) ? [ 'type' => 'none',
|
156 |
-
'taxable' => 'no', 'value' => '0'
|
157 |
-
] : $value;
|
158 |
-
if (! isset ( $value[ 'taxable' ] )) {
|
159 |
-
$value[ 'taxable' ] = 'no';
|
160 |
-
}
|
161 |
-
return $value;
|
162 |
-
}
|
163 |
-
|
164 |
-
/**
|
165 |
-
*
|
166 |
-
* @param string $key
|
167 |
-
* @param string $value
|
168 |
-
*/
|
169 |
-
public function validate_environment_field($key, $value) {
|
170 |
-
if ('test' == wc_stripe_mode () && 'development' == $value) {
|
171 |
-
WC_Admin_Settings::add_error ( __ ( 'You must set the API mode to live in order to enable the Plaid development environment.', 'woo-stripe-payment' ) );
|
172 |
-
}
|
173 |
-
return $value;
|
174 |
-
}
|
175 |
-
|
176 |
-
public function fees_enabled() {
|
177 |
-
$fee = $this->get_option ( 'fee', [
|
178 |
-
'type' => 'none', 'value' => '0'
|
179 |
-
] );
|
180 |
-
return ! empty ( $fee ) && $fee[ 'type' ] != 'none';
|
181 |
-
}
|
182 |
-
|
183 |
-
/**
|
184 |
-
*
|
185 |
-
* @param WC_Cart $cart
|
186 |
-
*/
|
187 |
-
public function after_calculate_totals($cart) {
|
188 |
-
remove_action ( 'woocommerce_after_calculate_totals', [
|
189 |
-
$this, 'after_calculate_totals'
|
190 |
-
] );
|
191 |
-
|
192 |
-
add_action ( 'woocommerce_cart_calculate_fees', array(
|
193 |
-
$this, 'calculate_fees'
|
194 |
-
) );
|
195 |
-
|
196 |
-
WC ()->session->set ( 'wc_stripe_cart_total', $cart->total );
|
197 |
-
$cart->calculate_totals ();
|
198 |
-
}
|
199 |
-
|
200 |
-
/**
|
201 |
-
*
|
202 |
-
* @param WC_Cart $cart
|
203 |
-
*/
|
204 |
-
public function calculate_fees($cart) {
|
205 |
-
remove_action ( 'woocommerce_cart_calculate_fees', array(
|
206 |
-
$this, 'calculate_fees'
|
207 |
-
) );
|
208 |
-
$fee = $this->get_option ( 'fee' );
|
209 |
-
$taxable = $fee[ 'taxable' ] == 'yes';
|
210 |
-
switch ($fee[ 'type' ]) {
|
211 |
-
case 'amount' :
|
212 |
-
$cart->add_fee ( __ ( 'ACH Fee' ), $fee[ 'value' ], $taxable );
|
213 |
-
break;
|
214 |
-
case 'percent' :
|
215 |
-
$cart->add_fee ( __ ( 'ACH Fee' ), $fee[ 'value' ] * WC ()->session->get ( 'wc_stripe_cart_total', 0 ), $taxable );
|
216 |
-
break;
|
217 |
-
}
|
218 |
-
unset ( WC ()->session->wc_stripe_cart_total );
|
219 |
-
}
|
220 |
-
|
221 |
-
public static function update_order_review() {
|
222 |
-
if (! empty ( $_POST[ 'payment_method' ] ) && $_POST[ 'payment_method' ] == 'stripe_ach') {
|
223 |
-
$payment_method = new WC_Payment_Gateway_Stripe_ACH ();
|
224 |
-
if ($payment_method->fees_enabled ()) {
|
225 |
-
add_action ( 'woocommerce_after_calculate_totals', [
|
226 |
-
$payment_method,
|
227 |
-
'after_calculate_totals'
|
228 |
-
] );
|
229 |
-
}
|
230 |
-
}
|
231 |
-
}
|
232 |
-
}
|
233 |
-
WC_Payment_Gateway_Stripe_ACH::init ();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/gateways/class-wc-payment-gateway-stripe-ach.php
CHANGED
@@ -1,331 +1,352 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Gateway that processes ACH payments.
|
6 |
-
* Only available for U.S. based merchants at this time.
|
7 |
-
*
|
8 |
-
* @since 3.0.5
|
9 |
-
* @author Payment Plugins
|
10 |
-
* @package Stripe/Gateways
|
11 |
-
*
|
12 |
-
*/
|
13 |
-
class WC_Payment_Gateway_Stripe_ACH extends WC_Payment_Gateway_Stripe {
|
14 |
-
|
15 |
-
use WC_Stripe_Payment_Charge_Trait;
|
16 |
-
|
17 |
-
/**
|
18 |
-
*
|
19 |
-
* @var object
|
20 |
-
*/
|
21 |
-
public $metadata_key = '';
|
22 |
-
|
23 |
-
public function __construct() {
|
24 |
-
$this->synchronous
|
25 |
-
$this->id
|
26 |
-
$this->tab_title
|
27 |
-
$this->template_name
|
28 |
-
$this->token_type
|
29 |
-
$this->method_title
|
30 |
-
$this->method_description = __
|
31 |
-
$this->icon
|
32 |
-
$this->order_button_text
|
33 |
-
$this->metadata_key
|
34 |
-
parent::__construct
|
35 |
-
$this->settings[
|
36 |
-
}
|
37 |
-
|
38 |
-
public static function init() {
|
39 |
-
add_action
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
*
|
46 |
-
*
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
$is_available
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
*
|
57 |
-
*
|
58 |
-
*
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
'env'
|
89 |
-
'client_name'
|
90 |
-
'public_key'
|
91 |
-
'metadata_key' => '[name="' . $this->metadata_key . '"]',
|
92 |
-
'fees_enabled' => $this->fees_enabled
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
*
|
99 |
-
*
|
100 |
-
*
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
'
|
159 |
-
'
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
] )
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
$fee
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Gateway that processes ACH payments.
|
6 |
+
* Only available for U.S. based merchants at this time.
|
7 |
+
*
|
8 |
+
* @since 3.0.5
|
9 |
+
* @author Payment Plugins
|
10 |
+
* @package Stripe/Gateways
|
11 |
+
*
|
12 |
+
*/
|
13 |
+
class WC_Payment_Gateway_Stripe_ACH extends WC_Payment_Gateway_Stripe {
|
14 |
+
|
15 |
+
use WC_Stripe_Payment_Charge_Trait;
|
16 |
+
|
17 |
+
/**
|
18 |
+
*
|
19 |
+
* @var object
|
20 |
+
*/
|
21 |
+
public $metadata_key = '';
|
22 |
+
|
23 |
+
public function __construct() {
|
24 |
+
$this->synchronous = false;
|
25 |
+
$this->id = 'stripe_ach';
|
26 |
+
$this->tab_title = __( 'ACH', 'woo-stripe-payment' );
|
27 |
+
$this->template_name = 'ach.php';
|
28 |
+
$this->token_type = 'Stripe_ACH';
|
29 |
+
$this->method_title = __( 'Stripe ACH', 'woo-stripe-payment' );
|
30 |
+
$this->method_description = __( 'ACH gateway that integrates with your Stripe account.', 'woo-stripe-payment' );
|
31 |
+
$this->icon = wc_stripe()->assets_url( 'img/ach.svg' );
|
32 |
+
$this->order_button_text = __( 'Bank Payment', 'woo-stripe-payment' );
|
33 |
+
$this->metadata_key = $this->id . '_metadata';
|
34 |
+
parent::__construct();
|
35 |
+
$this->settings['charge_type'] = 'capture';
|
36 |
+
}
|
37 |
+
|
38 |
+
public static function init() {
|
39 |
+
add_action( 'woocommerce_checkout_update_order_review', array( __CLASS__, 'update_order_review' ) );
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
*
|
44 |
+
* {@inheritDoc}
|
45 |
+
*
|
46 |
+
* @see WC_Payment_Gateway::is_available()
|
47 |
+
*/
|
48 |
+
public function is_available() {
|
49 |
+
$is_available = parent::is_available();
|
50 |
+
|
51 |
+
return $is_available && get_woocommerce_currency() == 'USD';
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
*
|
56 |
+
* {@inheritDoc}
|
57 |
+
*
|
58 |
+
* @see WC_Payment_Gateway_Stripe::init_supports()
|
59 |
+
*/
|
60 |
+
public function init_supports() {
|
61 |
+
parent::init_supports();
|
62 |
+
unset( $this->supports['add_payment_method'] );
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
*
|
67 |
+
* {@inheritDoc}
|
68 |
+
*
|
69 |
+
* @see WC_Payment_Gateway_Stripe::enqueue_checkout_scripts()
|
70 |
+
*/
|
71 |
+
public function enqueue_checkout_scripts( $scripts ) {
|
72 |
+
$scripts->enqueue_script(
|
73 |
+
'ach',
|
74 |
+
$scripts->assets_url( 'js/frontend/ach-payments.js' ),
|
75 |
+
array(
|
76 |
+
$scripts->get_handle( 'external' ),
|
77 |
+
$scripts->get_handle( 'wc-stripe' ),
|
78 |
+
$scripts->get_handle( 'plaid' ),
|
79 |
+
)
|
80 |
+
);
|
81 |
+
$scripts->localize_script( 'ach', $this->get_localized_params() );
|
82 |
+
}
|
83 |
+
|
84 |
+
public function get_localized_params() {
|
85 |
+
return array_merge_recursive(
|
86 |
+
parent::get_localized_params(),
|
87 |
+
array(
|
88 |
+
'env' => $this->get_plaid_environment(),
|
89 |
+
'client_name' => $this->get_option( 'client_name' ),
|
90 |
+
'public_key' => $this->get_option( 'public_key' ),
|
91 |
+
'metadata_key' => '[name="' . $this->metadata_key . '"]',
|
92 |
+
'fees_enabled' => $this->fees_enabled(),
|
93 |
+
)
|
94 |
+
);
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
*
|
99 |
+
* {@inheritDoc}
|
100 |
+
*
|
101 |
+
* @see WC_Payment_Gateway_Stripe_Charge::process_payment()
|
102 |
+
*/
|
103 |
+
public function process_payment( $order_id ) {
|
104 |
+
$order = wc_get_order( $order_id );
|
105 |
+
|
106 |
+
// generate the access token first.
|
107 |
+
if ( ! $this->use_saved_source() ) {
|
108 |
+
try {
|
109 |
+
$result = $this->fetch_access_token( $this->get_public_token() );
|
110 |
+
|
111 |
+
$result = $this->fetch_bank_token( $result->access_token );
|
112 |
+
|
113 |
+
$this->set_new_source_token( $result->stripe_bank_account_token );
|
114 |
+
} catch ( Exception $e ) {
|
115 |
+
wc_add_notice( sprintf( __( 'Error processing payment. Reason: %s', 'woo-stripe-payment' ), $e->getMessage() ), 'error' );
|
116 |
+
}
|
117 |
+
}
|
118 |
+
add_filter(
|
119 |
+
'wc_stripe_order_meta_data',
|
120 |
+
function ( $metadata ) {
|
121 |
+
$metadata['plaid_id'] = $this->get_option( 'client_id' );
|
122 |
+
|
123 |
+
return $metadata;
|
124 |
+
}
|
125 |
+
);
|
126 |
+
|
127 |
+
return parent::process_payment( $order_id );
|
128 |
+
}
|
129 |
+
|
130 |
+
private function do_api_request( $uri, $body, $method = 'POST' ) {
|
131 |
+
$response = wp_safe_remote_post(
|
132 |
+
$this->get_plaid_url( $uri ),
|
133 |
+
array(
|
134 |
+
'headers' => array( 'Content-Type' => 'application/json' ),
|
135 |
+
'body' => wp_json_encode( $body ),
|
136 |
+
'data_format' => 'body',
|
137 |
+
)
|
138 |
+
);
|
139 |
+
if ( is_wp_error( $response ) ) {
|
140 |
+
throw new Exception( $response->get_error_message() );
|
141 |
+
} else {
|
142 |
+
$body = json_decode( $response['body'] );
|
143 |
+
if ( $response['response']['code'] > 299 ) {
|
144 |
+
throw new Exception( $body->error_message );
|
145 |
+
} else {
|
146 |
+
return $body;
|
147 |
+
}
|
148 |
+
}
|
149 |
+
}
|
150 |
+
|
151 |
+
private function fetch_access_token( $public_token ) {
|
152 |
+
$env = $this->get_plaid_environment();
|
153 |
+
|
154 |
+
return $this->do_api_request(
|
155 |
+
'item/public_token/exchange',
|
156 |
+
array(
|
157 |
+
'client_id' => $this->get_option( 'client_id' ),
|
158 |
+
'secret' => $this->get_option( "{$env}_secret" ),
|
159 |
+
'public_token' => $public_token,
|
160 |
+
)
|
161 |
+
);
|
162 |
+
}
|
163 |
+
|
164 |
+
private function fetch_bank_token( $access_token ) {
|
165 |
+
$env = $this->get_plaid_environment();
|
166 |
+
|
167 |
+
return $this->do_api_request(
|
168 |
+
'processor/stripe/bank_account_token/create',
|
169 |
+
array(
|
170 |
+
'client_id' => $this->get_option( 'client_id' ),
|
171 |
+
'secret' => $this->get_option( "{$env}_secret" ),
|
172 |
+
'access_token' => $access_token,
|
173 |
+
'account_id' => $this->get_metadata()['account_id'],
|
174 |
+
)
|
175 |
+
);
|
176 |
+
}
|
177 |
+
|
178 |
+
/**
|
179 |
+
* Return the base plaid api url.
|
180 |
+
*
|
181 |
+
* @return string
|
182 |
+
*/
|
183 |
+
private function get_base_url() {
|
184 |
+
$url = '';
|
185 |
+
switch ( $this->get_plaid_environment() ) {
|
186 |
+
case 'production':
|
187 |
+
$url = 'https://production.plaid.com/';
|
188 |
+
break;
|
189 |
+
case 'sandbox':
|
190 |
+
$url = 'https://sandbox.plaid.com/';
|
191 |
+
break;
|
192 |
+
case 'development':
|
193 |
+
$url = 'https://development.plaid.com/';
|
194 |
+
break;
|
195 |
+
}
|
196 |
+
|
197 |
+
return $url;
|
198 |
+
}
|
199 |
+
|
200 |
+
private function get_plaid_url( $uri ) {
|
201 |
+
return sprintf( '%s%s', $this->get_base_url(), $uri );
|
202 |
+
}
|
203 |
+
|
204 |
+
public function get_plaid_environment() {
|
205 |
+
return $this->get_option( 'environment' );
|
206 |
+
}
|
207 |
+
|
208 |
+
private function get_metadata() {
|
209 |
+
return isset( $_POST[ $this->metadata_key ] ) ? json_decode( stripslashes( $_POST[ $this->metadata_key ] ), true ) : null;
|
210 |
+
}
|
211 |
+
|
212 |
+
private function get_public_token() {
|
213 |
+
return $this->get_new_source_token();
|
214 |
+
}
|
215 |
+
|
216 |
+
public function get_saved_methods_label() {
|
217 |
+
return __( 'Saved Banks', 'woo-stripe-payment' );
|
218 |
+
}
|
219 |
+
|
220 |
+
public function get_new_method_label() {
|
221 |
+
return __( 'New Bank', 'woo-stripe-payment' );
|
222 |
+
}
|
223 |
+
|
224 |
+
public function generate_ach_fee_html( $key, $data ) {
|
225 |
+
$field_key = $this->get_field_key( $key );
|
226 |
+
$defaults = array(
|
227 |
+
'title' => '',
|
228 |
+
'disabled' => false,
|
229 |
+
'class' => '',
|
230 |
+
'css' => 'max-width: 150px; min-width: 150px;',
|
231 |
+
'placeholder' => '',
|
232 |
+
'type' => 'text',
|
233 |
+
'desc_tip' => false,
|
234 |
+
'description' => '',
|
235 |
+
'custom_attributes' => array(),
|
236 |
+
'options' => array(),
|
237 |
+
);
|
238 |
+
$data = wp_parse_args( $data, $defaults );
|
239 |
+
ob_start();
|
240 |
+
include wc_stripe()->plugin_path() . 'includes/admin/views/html-ach-fee.php';
|
241 |
+
|
242 |
+
return ob_get_clean();
|
243 |
+
}
|
244 |
+
|
245 |
+
public function validate_ach_fee_field( $key, $value ) {
|
246 |
+
$value = empty( $value ) ? array(
|
247 |
+
'type' => 'none',
|
248 |
+
'taxable' => 'no',
|
249 |
+
'value' => '0',
|
250 |
+
) : $value;
|
251 |
+
if ( ! isset( $value['taxable'] ) ) {
|
252 |
+
$value['taxable'] = 'no';
|
253 |
+
}
|
254 |
+
|
255 |
+
return $value;
|
256 |
+
}
|
257 |
+
|
258 |
+
/**
|
259 |
+
*
|
260 |
+
* @param string $key
|
261 |
+
* @param string $value
|
262 |
+
*/
|
263 |
+
public function validate_environment_field( $key, $value ) {
|
264 |
+
if ( 'test' == wc_stripe_mode() && 'development' == $value ) {
|
265 |
+
WC_Admin_Settings::add_error( __( 'You must set the API mode to live in order to enable the Plaid development environment.', 'woo-stripe-payment' ) );
|
266 |
+
}
|
267 |
+
|
268 |
+
return $value;
|
269 |
+
}
|
270 |
+
|
271 |
+
public function fees_enabled() {
|
272 |
+
$fee = $this->get_option(
|
273 |
+
'fee',
|
274 |
+
array(
|
275 |
+
'type' => 'none',
|
276 |
+
'value' => '0',
|
277 |
+
)
|
278 |
+
);
|
279 |
+
|
280 |
+
return ! empty( $fee ) && $fee['type'] != 'none';
|
281 |
+
}
|
282 |
+
|
283 |
+
/**
|
284 |
+
*
|
285 |
+
* @param WC_Cart $cart
|
286 |
+
*/
|
287 |
+
public function after_calculate_totals( $cart ) {
|
288 |
+
remove_action( 'woocommerce_after_calculate_totals', array( $this, 'after_calculate_totals' ) );
|
289 |
+
|
290 |
+
add_action( 'woocommerce_cart_calculate_fees', array( $this, 'calculate_fees' ) );
|
291 |
+
|
292 |
+
WC()->session->set( 'wc_stripe_cart_total', $cart->total );
|
293 |
+
$cart->calculate_totals();
|
294 |
+
}
|
295 |
+
|
296 |
+
/**
|
297 |
+
*
|
298 |
+
* @param WC_Cart $cart
|
299 |
+
*/
|
300 |
+
public function calculate_fees( $cart ) {
|
301 |
+
remove_action( 'woocommerce_cart_calculate_fees', array( $this, 'calculate_fees' ) );
|
302 |
+
$fee = $this->get_option( 'fee' );
|
303 |
+
$taxable = $fee['taxable'] == 'yes';
|
304 |
+
switch ( $fee['type'] ) {
|
305 |
+
case 'amount':
|
306 |
+
$cart->add_fee( __( 'ACH Fee' ), $fee['value'], $taxable );
|
307 |
+
break;
|
308 |
+
case 'percent':
|
309 |
+
$cart->add_fee( __( 'ACH Fee' ), $fee['value'] * WC()->session->get( 'wc_stripe_cart_total', 0 ), $taxable );
|
310 |
+
break;
|
311 |
+
}
|
312 |
+
unset( WC()->session->wc_stripe_cart_total );
|
313 |
+
}
|
314 |
+
|
315 |
+
public static function update_order_review() {
|
316 |
+
if ( ! empty( $_POST['payment_method'] ) && $_POST['payment_method'] == 'stripe_ach' ) {
|
317 |
+
$payment_method = new WC_Payment_Gateway_Stripe_ACH();
|
318 |
+
if ( $payment_method->fees_enabled() ) {
|
319 |
+
add_action( 'woocommerce_after_calculate_totals', array( $payment_method, 'after_calculate_totals' ) );
|
320 |
+
}
|
321 |
+
}
|
322 |
+
}
|
323 |
+
|
324 |
+
/**
|
325 |
+
* Override so Plaid token can be converted to a Stripe bank token.
|
326 |
+
*
|
327 |
+
* {@inheritDoc}
|
328 |
+
*
|
329 |
+
* @see WC_Payment_Gateway_Stripe::create_payment_method()
|
330 |
+
*/
|
331 |
+
public function create_payment_method( $id, $customer_id ) {
|
332 |
+
if ( $this->is_change_payment_method_request() ) {
|
333 |
+
$result = $this->fetch_access_token( $this->get_public_token() );
|
334 |
+
|
335 |
+
if ( is_wp_error( $result ) ) {
|
336 |
+
return $result;
|
337 |
+
}
|
338 |
+
|
339 |
+
$result = $this->fetch_bank_token( $result->access_token );
|
340 |
+
|
341 |
+
if ( is_wp_error( $result ) ) {
|
342 |
+
return $result;
|
343 |
+
}
|
344 |
+
|
345 |
+
$id = $result->stripe_bank_account_token;
|
346 |
+
}
|
347 |
+
|
348 |
+
return parent::create_payment_method( $id, $customer_id );
|
349 |
+
}
|
350 |
+
}
|
351 |
+
|
352 |
+
WC_Payment_Gateway_Stripe_ACH::init();
|
includes/gateways/class-wc-payment-gateway-stripe-alipay.php
CHANGED
@@ -1,34 +1,33 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
if (! class_exists
|
5 |
-
return;
|
6 |
-
}
|
7 |
-
|
8 |
-
|
9 |
-
*
|
10 |
-
* @
|
11 |
-
*
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
$this->
|
20 |
-
|
21 |
-
|
22 |
-
//
|
23 |
-
|
24 |
-
$this->
|
25 |
-
$this->
|
26 |
-
$this->
|
27 |
-
$this->
|
28 |
-
$this->
|
29 |
-
$this->
|
30 |
-
$this->
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
}
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
if ( ! class_exists( 'WC_Payment_Gateway_Stripe_Local_Payment' ) ) {
|
5 |
+
return;
|
6 |
+
}
|
7 |
+
|
8 |
+
/**
|
9 |
+
*
|
10 |
+
* @package Stripe/Gateways
|
11 |
+
* @author PaymentPlugins
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
class WC_Payment_Gateway_Stripe_Alipay extends WC_Payment_Gateway_Stripe_Local_Payment {
|
15 |
+
|
16 |
+
use WC_Stripe_Local_Payment_Charge_Trait;
|
17 |
+
|
18 |
+
public function __construct() {
|
19 |
+
$this->local_payment_type = 'alipay';
|
20 |
+
$this->currencies = array( 'AUD', 'CAD', 'EUR', 'GBP', 'HKD', 'JPY', 'SGD', 'USD' );
|
21 |
+
// $this->countries = [ 'CN'
|
22 |
+
// ];
|
23 |
+
$this->id = 'stripe_alipay';
|
24 |
+
$this->tab_title = __( 'Alipay', 'woo-stripe-payment' );
|
25 |
+
$this->template_name = 'local-payment.php';
|
26 |
+
$this->token_type = 'Stripe_Local';
|
27 |
+
$this->method_title = __( 'Alipay', 'woo-stripe-payment' );
|
28 |
+
$this->method_description = __( 'Alipay gateway that integrates with your Stripe account.', 'woo-stripe-payment' );
|
29 |
+
$this->icon = wc_stripe()->assets_url( 'img/alipay.svg' );
|
30 |
+
$this->order_button_text = $this->get_order_button_text( __( 'Alipay', 'woo-stripe-payment' ) );
|
31 |
+
parent::__construct();
|
32 |
+
}
|
33 |
+
}
|
|
includes/gateways/class-wc-payment-gateway-stripe-applepay.php
CHANGED
@@ -1,90 +1,115 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
if (! class_exists
|
5 |
-
return;
|
6 |
-
}
|
7 |
-
|
8 |
-
|
9 |
-
*
|
10 |
-
* @
|
11 |
-
*
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
$this->
|
22 |
-
$this->
|
23 |
-
$this->
|
24 |
-
$this->
|
25 |
-
$this->
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
$this->supports[] = '
|
34 |
-
$this->supports[] = '
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
if ( ! class_exists( 'WC_Payment_Gateway_Stripe' ) ) {
|
5 |
+
return;
|
6 |
+
}
|
7 |
+
|
8 |
+
/**
|
9 |
+
*
|
10 |
+
* @package Stripe/Gateways
|
11 |
+
* @author PaymentPlugins
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
class WC_Payment_Gateway_Stripe_ApplePay extends WC_Payment_Gateway_Stripe {
|
15 |
+
|
16 |
+
use WC_Stripe_Payment_Intent_Trait;
|
17 |
+
|
18 |
+
protected $payment_method_type = 'card';
|
19 |
+
|
20 |
+
public function __construct() {
|
21 |
+
$this->id = 'stripe_applepay';
|
22 |
+
$this->tab_title = __( 'Apple Pay', 'woo-stripe-payment' );
|
23 |
+
$this->template_name = 'applepay.php';
|
24 |
+
$this->token_type = 'Stripe_ApplePay';
|
25 |
+
$this->method_title = __( 'Stripe Apple Pay', 'woo-stripe-payment' );
|
26 |
+
$this->method_description = __( 'Apple Pay gateway that integrates with your Stripe account.', 'woo-stripe-payment' );
|
27 |
+
parent::__construct();
|
28 |
+
$this->icon = wc_stripe()->assets_url( 'img/applepay.svg' );
|
29 |
+
}
|
30 |
+
|
31 |
+
public function init_supports() {
|
32 |
+
parent::init_supports();
|
33 |
+
$this->supports[] = 'wc_stripe_cart_checkout';
|
34 |
+
$this->supports[] = 'wc_stripe_product_checkout';
|
35 |
+
$this->supports[] = 'wc_stripe_banner_checkout';
|
36 |
+
}
|
37 |
+
|
38 |
+
public function enqueue_product_scripts( $scripts ) {
|
39 |
+
$scripts->enqueue_script(
|
40 |
+
'applepay-product',
|
41 |
+
$scripts->assets_url( 'js/frontend/applepay-product.js' ),
|
42 |
+
array(
|
43 |
+
$scripts->get_handle( 'wc-stripe' ),
|
44 |
+
$scripts->get_handle( 'external' ),
|
45 |
+
),
|
46 |
+
wc_stripe()->version(),
|
47 |
+
true
|
48 |
+
);
|
49 |
+
$scripts->localize_script( 'applepay-product', $this->get_localized_params() );
|
50 |
+
}
|
51 |
+
|
52 |
+
public function enqueue_cart_scripts( $scripts ) {
|
53 |
+
$scripts->enqueue_script(
|
54 |
+
'applepay-cart',
|
55 |
+
$scripts->assets_url( 'js/frontend/applepay-cart.js' ),
|
56 |
+
array(
|
57 |
+
$scripts->get_handle( 'wc-stripe' ),
|
58 |
+
$scripts->get_handle( 'external' ),
|
59 |
+
),
|
60 |
+
wc_stripe()->version(),
|
61 |
+
true
|
62 |
+
);
|
63 |
+
$scripts->localize_script( 'applepay-cart', $this->get_localized_params() );
|
64 |
+
}
|
65 |
+
|
66 |
+
public function enqueue_checkout_scripts( $scripts ) {
|
67 |
+
$scripts->enqueue_script(
|
68 |
+
'applepay-checkout',
|
69 |
+
$scripts->assets_url( 'js/frontend/applepay-checkout.js' ),
|
70 |
+
array(
|
71 |
+
$scripts->get_handle( 'wc-stripe' ),
|
72 |
+
$scripts->get_handle( 'external' ),
|
73 |
+
),
|
74 |
+
wc_stripe()->version(),
|
75 |
+
true
|
76 |
+
);
|
77 |
+
$scripts->localize_script( 'applepay-checkout', $this->get_localized_params() );
|
78 |
+
}
|
79 |
+
|
80 |
+
public function get_localized_params() {
|
81 |
+
return array_merge_recursive(
|
82 |
+
parent::get_localized_params(),
|
83 |
+
array(
|
84 |
+
'messages' => array(
|
85 |
+
'invalid_amount' => __( 'Please update you product quantity before using Apple Pay.', 'woo-stripe-payment' ),
|
86 |
+
'choose_product' => __( 'Please select a product option before updating quantity.', 'woo-stripe-payment' ),
|
87 |
+
),
|
88 |
+
'button' => wc_stripe_get_template_html(
|
89 |
+
'applepay-button.php',
|
90 |
+
array(
|
91 |
+
'style' => $this->get_option( 'button_style' ),
|
92 |
+
'type' => $this->get_button_type(),
|
93 |
+
)
|
94 |
+
),
|
95 |
+
)
|
96 |
+
);
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Returns the Apple Pay button type based on the current page.
|
101 |
+
*
|
102 |
+
* @return string
|
103 |
+
*/
|
104 |
+
protected function get_button_type() {
|
105 |
+
if ( is_checkout() ) {
|
106 |
+
return $this->get_option( 'button_type_checkout' );
|
107 |
+
}
|
108 |
+
if ( is_cart() ) {
|
109 |
+
return $this->get_option( 'button_type_cart' );
|
110 |
+
}
|
111 |
+
if ( is_product() ) {
|
112 |
+
return $this->get_option( 'button_type_product' );
|
113 |
+
}
|
114 |
+
}
|
115 |
+
}
|
includes/gateways/class-wc-payment-gateway-stripe-bancontact.php
CHANGED
@@ -1,34 +1,33 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
if (! class_exists
|
5 |
-
return;
|
6 |
-
}
|
7 |
-
|
8 |
-
|
9 |
-
*
|
10 |
-
* @
|
11 |
-
*
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
$this->
|
20 |
-
$this->
|
21 |
-
|
22 |
-
$this->countries
|
23 |
-
|
24 |
-
$this->
|
25 |
-
$this->
|
26 |
-
$this->
|
27 |
-
$this->
|
28 |
-
$this->
|
29 |
-
$this->
|
30 |
-
$this->
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
}
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
if ( ! class_exists( 'WC_Payment_Gateway_Stripe_Local_Payment' ) ) {
|
5 |
+
return;
|
6 |
+
}
|
7 |
+
|
8 |
+
/**
|
9 |
+
*
|
10 |
+
* @package Stripe/Gateways
|
11 |
+
* @author PaymentPlugins
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
class WC_Payment_Gateway_Stripe_Bancontact extends WC_Payment_Gateway_Stripe_Local_Payment {
|
15 |
+
|
16 |
+
use WC_Stripe_Local_Payment_Charge_Trait;
|
17 |
+
|
18 |
+
public function __construct() {
|
19 |
+
$this->synchronous = false;
|
20 |
+
$this->local_payment_type = 'bancontact';
|
21 |
+
$this->currencies = array( 'EUR' );
|
22 |
+
$this->countries = array( 'BE' );
|
23 |
+
$this->id = 'stripe_bancontact';
|
24 |
+
$this->tab_title = __( 'Bancontact', 'woo-stripe-payment' );
|
25 |
+
$this->template_name = 'local-payment.php';
|
26 |
+
$this->token_type = 'Stripe_Local';
|
27 |
+
$this->method_title = __( 'Bancontact', 'woo-stripe-payment' );
|
28 |
+
$this->method_description = __( 'Bancontact gateway that integrates with your Stripe account.', 'woo-stripe-payment' );
|
29 |
+
$this->icon = wc_stripe()->assets_url( 'img/bancontact.svg' );
|
30 |
+
$this->order_button_text = $this->get_order_button_text( __( 'Bancontact', 'woo-stripe-payment' ) );
|
31 |
+
parent::__construct();
|
32 |
+
}
|
33 |
+
}
|
|
includes/gateways/class-wc-payment-gateway-stripe-cc.php
CHANGED
@@ -1,164 +1,173 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
/**
|
5 |
-
*
|
6 |
-
* @since 3.0.0
|
7 |
-
* @package Stripe/Gateways
|
8 |
-
* @author User
|
9 |
-
*
|
10 |
-
*/
|
11 |
-
class WC_Payment_Gateway_Stripe_CC extends WC_Payment_Gateway_Stripe {
|
12 |
-
|
13 |
-
use WC_Stripe_Payment_Intent_Trait;
|
14 |
-
|
15 |
-
protected $payment_method_type = 'card';
|
16 |
-
|
17 |
-
public function __construct() {
|
18 |
-
$this->id
|
19 |
-
$this->tab_title
|
20 |
-
$this->template_name
|
21 |
-
$this->token_type
|
22 |
-
$this->method_title
|
23 |
-
$this->method_description = __
|
24 |
-
parent::__construct
|
25 |
-
}
|
26 |
-
|
27 |
-
public function get_icon() {
|
28 |
-
return wc_stripe_get_template
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
return
|
93 |
-
}
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
/**
|
5 |
+
*
|
6 |
+
* @since 3.0.0
|
7 |
+
* @package Stripe/Gateways
|
8 |
+
* @author User
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
class WC_Payment_Gateway_Stripe_CC extends WC_Payment_Gateway_Stripe {
|
12 |
+
|
13 |
+
use WC_Stripe_Payment_Intent_Trait;
|
14 |
+
|
15 |
+
protected $payment_method_type = 'card';
|
16 |
+
|
17 |
+
public function __construct() {
|
18 |
+
$this->id = 'stripe_cc';
|
19 |
+
$this->tab_title = __( 'Credit Cards', 'woo-stripe-payment' );
|
20 |
+
$this->template_name = 'credit-card.php';
|
21 |
+
$this->token_type = 'Stripe_CC';
|
22 |
+
$this->method_title = __( 'Stripe Credit Cards', 'woo-stripe-payment' );
|
23 |
+
$this->method_description = __( 'Credit card gateway that integrates with your Stripe account.', 'woo-stripe-payment' );
|
24 |
+
parent::__construct();
|
25 |
+
}
|
26 |
+
|
27 |
+
public function get_icon() {
|
28 |
+
return wc_stripe_get_template(
|
29 |
+
'card-icons.php',
|
30 |
+
array(
|
31 |
+
'cards' => $this->get_option( 'cards' ),
|
32 |
+
'style' => $this->get_option( 'icon_style' ),
|
33 |
+
)
|
34 |
+
);
|
35 |
+
}
|
36 |
+
|
37 |
+
public function enqueue_checkout_scripts( $scripts ) {
|
38 |
+
$scripts->enqueue_script(
|
39 |
+
'credit-card',
|
40 |
+
$scripts->assets_url( 'js/frontend/credit-card.js' ),
|
41 |
+
array(
|
42 |
+
$scripts->prefix . 'external',
|
43 |
+
$scripts->prefix . 'wc-stripe',
|
44 |
+
)
|
45 |
+
);
|
46 |
+
$scripts->localize_script( 'credit-card', $this->get_localized_params() );
|
47 |
+
}
|
48 |
+
|
49 |
+
public function get_localized_params() {
|
50 |
+
$data = parent::get_localized_params();
|
51 |
+
return array_merge(
|
52 |
+
$data,
|
53 |
+
array(
|
54 |
+
'style' => $this->get_form_style(),
|
55 |
+
'elementOptions' => $this->get_element_options(),
|
56 |
+
'custom_form' => $this->is_custom_form_active(),
|
57 |
+
'html' => array( 'card_brand' => sprintf( '<img id="wc-stripe-card" src="%s" />', $this->get_custom_form()['cardBrand'] ) ),
|
58 |
+
'cards' => array(
|
59 |
+
'visa' => wc_stripe()->assets_url( 'img/cards/visa.svg' ),
|
60 |
+
'amex' => wc_stripe()->assets_url( 'img/cards/amex.svg' ),
|
61 |
+
'mastercard' => wc_stripe()->assets_url( 'img/cards/mastercard.svg' ),
|
62 |
+
'discover' => wc_stripe()->assets_url( 'img/cards/discover.svg' ),
|
63 |
+
'diners' => wc_stripe()->assets_url( 'img/cards/diners.svg' ),
|
64 |
+
'jcb' => wc_stripe()->assets_url( 'img/cards/jcb.svg' ),
|
65 |
+
'unionpay' => wc_stripe()->assets_url( 'img/cards/china_union_pay.svg' ),
|
66 |
+
'unknown' => $this->get_custom_form()['cardBrand'],
|
67 |
+
),
|
68 |
+
'postal_regex' => $this->get_postal_code_regex(),
|
69 |
+
)
|
70 |
+
);
|
71 |
+
}
|
72 |
+
|
73 |
+
private function get_form_style() {
|
74 |
+
if ( $this->is_custom_form_active() ) {
|
75 |
+
$style = $this->get_custom_form()['elementStyles'];
|
76 |
+
} else {
|
77 |
+
$style = array(
|
78 |
+
'base' => array(
|
79 |
+
'color' => '#32325d',
|
80 |
+
'fontFamily' => '"Helvetica Neue", Helvetica, sans-serif',
|
81 |
+
'fontSmoothing' => 'antialiased',
|
82 |
+
'fontSize' => '18px',
|
83 |
+
'::placeholder' => array( 'color' => '#aab7c4' ),
|
84 |
+
':focus' => array(),
|
85 |
+
),
|
86 |
+
'invalid' => array(
|
87 |
+
'color' => '#fa755a',
|
88 |
+
'iconColor' => '#fa755a',
|
89 |
+
),
|
90 |
+
);
|
91 |
+
}
|
92 |
+
return apply_filters( 'wc_stripe_cc_element_style', $style );
|
93 |
+
}
|
94 |
+
|
95 |
+
private function get_custom_form() {
|
96 |
+
return wc_stripe_get_custom_forms()[ $this->get_option( 'custom_form' ) ];
|
97 |
+
}
|
98 |
+
|
99 |
+
private function get_element_options() {
|
100 |
+
return $this->get_custom_form()['elementOptions'];
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Returns true if custom forms are enabled.
|
105 |
+
*
|
106 |
+
* @return bool
|
107 |
+
*/
|
108 |
+
public function is_custom_form_active() {
|
109 |
+
return $this->get_option( 'form_type' ) === 'custom';
|
110 |
+
}
|
111 |
+
|
112 |
+
public function get_custom_form_template() {
|
113 |
+
$form = $this->get_option( 'custom_form' );
|
114 |
+
return wc_stripe_get_custom_forms()[ $form ]['template'];
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Returns true if the postal code field is enabled.
|
119 |
+
*
|
120 |
+
* @return bool
|
121 |
+
*/
|
122 |
+
public function postal_enabled() {
|
123 |
+
if ( is_checkout() ) {
|
124 |
+
return $this->is_active( 'postal_enabled' );
|
125 |
+
}
|
126 |
+
if ( is_add_payment_method_page() ) {
|
127 |
+
return true;
|
128 |
+
}
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Returns true if the cvv field is enabled.
|
133 |
+
*
|
134 |
+
* @return bool
|
135 |
+
*/
|
136 |
+
public function cvv_enabled() {
|
137 |
+
return $this->is_active( 'cvv_enabled' );
|
138 |
+
}
|
139 |
+
|
140 |
+
public function get_postal_code_regex() {
|
141 |
+
return array(
|
142 |
+
'AT' => '^([0-9]{4})$',
|
143 |
+
'BR' => '^([0-9]{5})([-])?([0-9]{3})$',
|
144 |
+
'CH' => '^([0-9]{4})$',
|
145 |
+
'DE' => '^([0]{1}[1-9]{1}|[1-9]{1}[0-9]{1})[0-9]{3}$',
|
146 |
+
'ES' => '^([0-9]{5})$',
|
147 |
+
'FR' => '^([0-9]{5})$',
|
148 |
+
'IT' => '^([0-9]{5})$/i',
|
149 |
+
'IE' => '([AC-FHKNPRTV-Y]\d{2}|D6W)[0-9AC-FHKNPRTV-Y]{4}',
|
150 |
+
'JP' => '^([0-9]{3})([-])([0-9]{4})$',
|
151 |
+
'PT' => '^([0-9]{4})([-])([0-9]{3})$',
|
152 |
+
'US' => '^([0-9]{5})(-[0-9]{4})?$',
|
153 |
+
'CA' => '^([ABCEGHJKLMNPRSTVXY]\d[ABCEGHJKLMNPRSTVWXYZ])([\ ])?(\d[ABCEGHJKLMNPRSTVWXYZ]\d)$',
|
154 |
+
'PL' => '^([0-9]{2})([-])([0-9]{3})',
|
155 |
+
'CZ' => '^([0-9]{3})(\s?)([0-9]{2})$',
|
156 |
+
'SK' => '^([0-9]{3})(\s?)([0-9]{2})$',
|
157 |
+
'NL' => '^([1-9][0-9]{3})(\s?)(?!SA|SD|SS)[A-Z]{2}$',
|
158 |
+
);
|
159 |
+
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
*
|
163 |
+
* {@inheritDoc}
|
164 |
+
*
|
165 |
+
* @see WC_Payment_Gateway_Stripe::add_stripe_order_args()
|
166 |
+
*/
|
167 |
+
public function add_stripe_order_args( &$args, $order ) {
|
168 |
+
// if the merchant is forcing 3D secure for all intents then add the required args.
|
169 |
+
if ( $this->is_active( 'force_3d_secure' ) && is_checkout() && ! doing_action( 'woocommerce_scheduled_subscription_payment_' . $this->id ) ) {
|
170 |
+
$args['payment_method_options']['card']['request_three_d_secure'] = 'any';
|
171 |
+
}
|
172 |
+
}
|
173 |
+
}
|
includes/gateways/class-wc-payment-gateway-stripe-eps.php
CHANGED
@@ -1,33 +1,32 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
if (! class_exists
|
5 |
-
return;
|
6 |
-
}
|
7 |
-
|
8 |
-
|
9 |
-
*
|
10 |
-
* @
|
11 |
-
*
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
$this->
|
20 |
-
|
21 |
-
$this->countries
|
22 |
-
|
23 |
-
$this->
|
24 |
-
$this->
|
25 |
-
$this->
|
26 |
-
$this->
|
27 |
-
$this->
|
28 |
-
$this->
|
29 |
-
$this->
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
}
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
if ( ! class_exists( 'WC_Payment_Gateway_Stripe_Local_Payment' ) ) {
|
5 |
+
return;
|
6 |
+
}
|
7 |
+
|
8 |
+
/**
|
9 |
+
*
|
10 |
+
* @package Stripe/Gateways
|
11 |
+
* @author PaymentPlugins
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
class WC_Payment_Gateway_Stripe_EPS extends WC_Payment_Gateway_Stripe_Local_Payment {
|
15 |
+
|
16 |
+
use WC_Stripe_Local_Payment_Charge_Trait;
|
17 |
+
|
18 |
+
public function __construct() {
|
19 |
+
$this->local_payment_type = 'eps';
|
20 |
+
$this->currencies = array( 'EUR' );
|
21 |
+
$this->countries = array( 'AT' );
|
22 |
+
$this->id = 'stripe_eps';
|
23 |
+
$this->tab_title = __( 'EPS', 'woo-stripe-payment' );
|
24 |
+
$this->template_name = 'local-payment.php';
|
25 |
+
$this->token_type = 'Stripe_Local';
|
26 |
+
$this->method_title = __( 'EPS', 'woo-stripe-payment' );
|
27 |
+
$this->method_description = __( 'EPS gateway that integrates with your Stripe account.', 'woo-stripe-payment' );
|
28 |
+
$this->icon = wc_stripe()->assets_url( 'img/eps.svg' );
|
29 |
+
$this->order_button_text = $this->get_order_button_text( __( 'EPS', 'woo-stripe-payment' ) );
|
30 |
+
parent::__construct();
|
31 |
+
}
|
32 |
+
}
|
|
includes/gateways/class-wc-payment-gateway-stripe-fpx.php
CHANGED
@@ -1,39 +1,38 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
if (! class_exists
|
5 |
-
return;
|
6 |
-
}
|
7 |
-
|
8 |
-
|
9 |
-
*
|
10 |
-
* @
|
11 |
-
*
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
$this->
|
22 |
-
|
23 |
-
$this->countries
|
24 |
-
|
25 |
-
$this->
|
26 |
-
$this->
|
27 |
-
$this->
|
28 |
-
$this->
|
29 |
-
$this->
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
$params =
|
36 |
-
$params
|
37 |
-
|
38 |
-
|
39 |
-
}
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
if ( ! class_exists( 'WC_Payment_Gateway_Stripe_Local_Payment' ) ) {
|
5 |
+
return;
|
6 |
+
}
|
7 |
+
|
8 |
+
/**
|
9 |
+
*
|
10 |
+
* @package Stripe/Gateways
|
11 |
+
* @author PaymentPlugins
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
class WC_Payment_Gateway_Stripe_FPX extends WC_Payment_Gateway_Stripe_Local_Payment {
|
15 |
+
|
16 |
+
use WC_Stripe_Local_Payment_Intent_Trait;
|
17 |
+
|
18 |
+
protected $payment_method_type = 'fpx';
|
19 |
+
|
20 |
+
public function __construct() {
|
21 |
+
$this->local_payment_type = 'fpx';
|
22 |
+
$this->currencies = array( 'MYR' );
|
23 |
+
$this->countries = array( 'MY' );
|
24 |
+
$this->id = 'stripe_fpx';
|
25 |
+
$this->tab_title = __( 'FPX', 'woo-stripe-payment' );
|
26 |
+
$this->method_title = __( 'FPX', 'woo-stripe-payment' );
|
27 |
+
$this->method_description = __( 'FPX gateway that integrates with your Stripe account.', 'woo-stripe-payment' );
|
28 |
+
$this->icon = wc_stripe()->assets_url( 'img/fpx.svg' );
|
29 |
+
$this->order_button_text = $this->get_order_button_text( __( 'FPX', 'woo-stripe-payment' ) );
|
30 |
+
parent::__construct();
|
31 |
+
}
|
32 |
+
|
33 |
+
public function get_element_params() {
|
34 |
+
$params = parent::get_element_params();
|
35 |
+
$params['accountHolderType'] = 'individual';
|
36 |
+
return $params;
|
37 |
+
}
|
38 |
+
}
|
|
includes/gateways/class-wc-payment-gateway-stripe-giropay.php
CHANGED
@@ -1,33 +1,32 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
if (! class_exists
|
5 |
-
return;
|
6 |
-
}
|
7 |
-
|
8 |
-
|
9 |
-
*
|
10 |
-
* @
|
11 |
-
*
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
$this->
|
20 |
-
|
21 |
-
$this->countries
|
22 |
-
|
23 |
-
$this->
|
24 |
-
$this->
|
25 |
-
$this->
|
26 |
-
$this->
|
27 |
-
$this->
|
28 |
-
$this->
|
29 |
-
$this->
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
}
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
if ( ! class_exists( 'WC_Payment_Gateway_Stripe_Local_Payment' ) ) {
|
5 |
+
return;
|
6 |
+
}
|
7 |
+
|
8 |
+
/**
|
9 |
+
*
|
10 |
+
* @package Stripe/Gateways
|
11 |
+
* @author PaymentPlugins
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
class WC_Payment_Gateway_Stripe_Giropay extends WC_Payment_Gateway_Stripe_Local_Payment {
|
15 |
+
|
16 |
+
use WC_Stripe_Local_Payment_Charge_Trait;
|
17 |
+
|
18 |
+
public function __construct() {
|
19 |
+
$this->local_payment_type = 'giropay';
|
20 |
+
$this->currencies = array( 'EUR' );
|
21 |
+
$this->countries = array( 'DE' );
|
22 |
+
$this->id = 'stripe_giropay';
|
23 |
+
$this->tab_title = __( 'Giropay', 'woo-stripe-payment' );
|
24 |
+
$this->template_name = 'local-payment.php';
|
25 |
+
$this->token_type = 'Stripe_Local';
|
26 |
+
$this->method_title = __( 'Giropay', 'woo-stripe-payment' );
|
27 |
+
$this->method_description = __( 'Giropay gateway that integrates with your Stripe account.', 'woo-stripe-payment' );
|
28 |
+
$this->icon = wc_stripe()->assets_url( 'img/giropay.svg' );
|
29 |
+
$this->order_button_text = $this->get_order_button_text( __( 'Giropay', 'woo-stripe-payment' ) );
|
30 |
+
parent::__construct();
|
31 |
+
}
|
32 |
+
}
|
|
includes/gateways/class-wc-payment-gateway-stripe-googlepay.php
CHANGED
@@ -1,278 +1,329 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
if (! class_exists
|
5 |
-
return;
|
6 |
-
}
|
7 |
-
|
8 |
-
|
9 |
-
*
|
10 |
-
* @
|
11 |
-
* @
|
12 |
-
*
|
13 |
-
*/
|
14 |
-
class WC_Payment_Gateway_Stripe_GooglePay extends WC_Payment_Gateway_Stripe {
|
15 |
-
|
16 |
-
use WC_Stripe_Payment_Charge_Trait;
|
17 |
-
|
18 |
-
public function __construct() {
|
19 |
-
$this->id
|
20 |
-
$this->tab_title
|
21 |
-
$this->template_name
|
22 |
-
$this->token_type
|
23 |
-
$this->method_title
|
24 |
-
$this->method_description = __
|
25 |
-
parent::__construct
|
26 |
-
$this->icon = wc_stripe
|
27 |
-
}
|
28 |
-
|
29 |
-
public function init_supports() {
|
30 |
-
parent::init_supports
|
31 |
-
$this->supports[] = 'wc_stripe_cart_checkout';
|
32 |
-
$this->supports[] = 'wc_stripe_product_checkout';
|
33 |
-
$this->supports[] = 'wc_stripe_banner_checkout';
|
34 |
-
}
|
35 |
-
|
36 |
-
public function enqueue_checkout_scripts($scripts) {
|
37 |
-
$scripts->enqueue_script
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
$scripts->get_handle
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
$
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
$
|
163 |
-
|
164 |
-
|
165 |
-
]
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
if (
|
173 |
-
$items[] =
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
}
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
*
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
}
|
231 |
-
|
232 |
-
|
233 |
-
$
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
$
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
}
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
if ( ! class_exists( 'WC_Payment_Gateway_Stripe' ) ) {
|
5 |
+
return;
|
6 |
+
}
|
7 |
+
|
8 |
+
/**
|
9 |
+
*
|
10 |
+
* @author PaymentPlugins
|
11 |
+
* @since 3.0.0
|
12 |
+
* @package Stripe/Gateways
|
13 |
+
*/
|
14 |
+
class WC_Payment_Gateway_Stripe_GooglePay extends WC_Payment_Gateway_Stripe {
|
15 |
+
|
16 |
+
use WC_Stripe_Payment_Charge_Trait;
|
17 |
+
|
18 |
+
public function __construct() {
|
19 |
+
$this->id = 'stripe_googlepay';
|
20 |
+
$this->tab_title = __( 'Google Pay', 'woo-stripe-payment' );
|
21 |
+
$this->template_name = 'googlepay.php';
|
22 |
+
$this->token_type = 'Stripe_GooglePay';
|
23 |
+
$this->method_title = __( 'Stripe Google Pay', 'woo-stripe-payment' );
|
24 |
+
$this->method_description = __( 'Google Pay gateway that integrates with your Stripe account.', 'woo-stripe-payment' );
|
25 |
+
parent::__construct();
|
26 |
+
$this->icon = wc_stripe()->assets_url( 'img/' . $this->get_option( 'icon' ) . '.svg' );
|
27 |
+
}
|
28 |
+
|
29 |
+
public function init_supports() {
|
30 |
+
parent::init_supports();
|
31 |
+
$this->supports[] = 'wc_stripe_cart_checkout';
|
32 |
+
$this->supports[] = 'wc_stripe_product_checkout';
|
33 |
+
$this->supports[] = 'wc_stripe_banner_checkout';
|
34 |
+
}
|
35 |
+
|
36 |
+
public function enqueue_checkout_scripts( $scripts ) {
|
37 |
+
$scripts->enqueue_script(
|
38 |
+
'googlepay-checkout',
|
39 |
+
$scripts->assets_url( 'js/frontend/googlepay-checkout.js' ),
|
40 |
+
array(
|
41 |
+
$scripts->get_handle( 'wc-stripe' ),
|
42 |
+
$scripts->get_handle( 'gpay' ),
|
43 |
+
),
|
44 |
+
wc_stripe()->version(),
|
45 |
+
true
|
46 |
+
);
|
47 |
+
$scripts->localize_script( 'googlepay-checkout', $this->get_localized_params() );
|
48 |
+
}
|
49 |
+
|
50 |
+
public function enqueue_product_scripts( $scripts ) {
|
51 |
+
$scripts->enqueue_script(
|
52 |
+
'googlepay-product',
|
53 |
+
$scripts->assets_url( 'js/frontend/googlepay-product.js' ),
|
54 |
+
array(
|
55 |
+
$scripts->get_handle( 'wc-stripe' ),
|
56 |
+
$scripts->get_handle( 'gpay' ),
|
57 |
+
),
|
58 |
+
wc_stripe()->version(),
|
59 |
+
true
|
60 |
+
);
|
61 |
+
$scripts->localize_script( 'googlepay-product', $this->get_localized_params() );
|
62 |
+
}
|
63 |
+
|
64 |
+
public function enqueue_cart_scripts( $scripts ) {
|
65 |
+
$scripts->enqueue_script(
|
66 |
+
'googlepay-cart',
|
67 |
+
$scripts->assets_url( 'js/frontend/googlepay-cart.js' ),
|
68 |
+
array(
|
69 |
+
$scripts->get_handle( 'wc-stripe' ),
|
70 |
+
$scripts->get_handle( 'gpay' ),
|
71 |
+
),
|
72 |
+
wc_stripe()->version(),
|
73 |
+
true
|
74 |
+
);
|
75 |
+
$scripts->localize_script( 'googlepay-cart', $this->get_localized_params() );
|
76 |
+
}
|
77 |
+
|
78 |
+
public function enqueue_admin_scripts() {
|
79 |
+
wp_register_script( 'gpay-external', wc_stripe()->scripts()->global_scripts['gpay'], array(), wc_stripe()->version(), true );
|
80 |
+
wp_enqueue_script(
|
81 |
+
'wc-stripe-gpay-admin',
|
82 |
+
wc_stripe()->assets_url( 'js/admin/googlepay.js' ),
|
83 |
+
array(
|
84 |
+
'gpay-external',
|
85 |
+
'wc-stripe-admin-settings',
|
86 |
+
),
|
87 |
+
wc_stripe()->version(),
|
88 |
+
true
|
89 |
+
);
|
90 |
+
}
|
91 |
+
|
92 |
+
public function get_localized_params() {
|
93 |
+
$data = array_merge_recursive(
|
94 |
+
parent::get_localized_params(),
|
95 |
+
array(
|
96 |
+
'environment' => wc_stripe_mode() === 'test' ? 'TEST' : 'PRODUCTION',
|
97 |
+
'merchant_id' => wc_stripe_mode() === 'test' ? '' : $this->get_option( 'merchant_id' ),
|
98 |
+
'merchant_name' => $this->get_option( 'merchant_name' ),
|
99 |
+
'button_color' => $this->get_option( 'button_color' ),
|
100 |
+
'button_style' => $this->get_option( 'button_style' ),
|
101 |
+
'total_price_label' => __( 'Total', 'woo-stripe-payment' ),
|
102 |
+
'routes' => array( 'payment_data' => wc_stripe()->rest_api->googlepay->rest_url( 'shipping-data' ) ),
|
103 |
+
'messages' => array( 'invalid_amount' => __( 'Please update you product quantity before using Google Pay.', 'woo-stripe-payment' ) ),
|
104 |
+
'dynamic_price' => $this->is_active( 'dynamic_price' ),
|
105 |
+
)
|
106 |
+
);
|
107 |
+
|
108 |
+
return $data;
|
109 |
+
}
|
110 |
+
|
111 |
+
public function get_display_items( $encode = false ) {
|
112 |
+
$items = array();
|
113 |
+
global $wp;
|
114 |
+
if ( wcs_stripe_active() && WC_Subscriptions_Change_Payment_Gateway::$is_request_to_change_payment ) {
|
115 |
+
$subscription = wcs_get_subscription( absint( $_GET['change_payment_method'] ) );
|
116 |
+
$items[] = array(
|
117 |
+
'label' => __( 'Subscription', 'woo-stripe-payment' ),
|
118 |
+
'type' => 'SUBTOTAL',
|
119 |
+
'price' => strval( $subscription->get_total() ),
|
120 |
+
);
|
121 |
+
} elseif ( is_product() ) {
|
122 |
+
global $product;
|
123 |
+
$items[] = array(
|
124 |
+
'label' => esc_attr( $product->get_name() ),
|
125 |
+
'type' => 'LINE_ITEM',
|
126 |
+
'price' => strval( $product->get_price() ),
|
127 |
+
);
|
128 |
+
} elseif ( is_checkout() && isset( $wp->query_vars['order-pay'] ) ) {
|
129 |
+
$order = wc_get_order( absint( $wp->query_vars['order-pay'] ) );
|
130 |
+
// add all order items
|
131 |
+
foreach ( $order->get_items() as $item ) {
|
132 |
+
/**
|
133 |
+
*
|
134 |
+
* @var WC_Order_Item_Product $item
|
135 |
+
*/
|
136 |
+
$qty = $item->get_quantity();
|
137 |
+
|
138 |
+
$items[] = array(
|
139 |
+
'label' => $qty > 1 ? sprintf( '%s X %s', $item->get_name(), $qty ) : $item->get_name(),
|
140 |
+
'type' => 'LINE_ITEM',
|
141 |
+
'price' => strval( $item->get_subtotal() ),
|
142 |
+
);
|
143 |
+
}
|
144 |
+
// shipping total
|
145 |
+
if ( $order->get_shipping_total() ) {
|
146 |
+
$items[] = array(
|
147 |
+
'label' => __( 'Shipping', 'woo-stripe-payment' ),
|
148 |
+
'type' => 'LINE_ITEM',
|
149 |
+
'price' => strval( $order->get_shipping_total() ),
|
150 |
+
);
|
151 |
+
}
|
152 |
+
// discount total
|
153 |
+
if ( $order->get_total_discount() ) {
|
154 |
+
$items[] = array(
|
155 |
+
'label' => __( 'Discount', 'woo-stripe-payment' ),
|
156 |
+
'type' => 'LINE_ITEM',
|
157 |
+
'price' => strval( $order->get_total_discount() ),
|
158 |
+
);
|
159 |
+
}
|
160 |
+
if ( $order->get_fees() ) {
|
161 |
+
$fee_total = 0;
|
162 |
+
foreach ( $order->get_fees() as $fee ) {
|
163 |
+
$fee_total += $fee->get_total();
|
164 |
+
}
|
165 |
+
$items[] = array(
|
166 |
+
'label' => __( 'Fees', 'woo-stripe-payment' ),
|
167 |
+
'type' => 'LINE_ITEM',
|
168 |
+
'price' => strval( $fee_total ),
|
169 |
+
);
|
170 |
+
}
|
171 |
+
// tax total
|
172 |
+
if ( $order->get_total_tax() ) {
|
173 |
+
$items[] = array(
|
174 |
+
'label' => __( 'Tax', 'woocommerce' ),
|
175 |
+
'type' => 'TAX',
|
176 |
+
'price' => strval( $order->get_total_tax() ),
|
177 |
+
);
|
178 |
+
}
|
179 |
+
} else {
|
180 |
+
$incl_tax = wc_stripe_display_prices_including_tax();
|
181 |
+
$decimals = ( ( $decimals = wc_get_price_decimals() ) < 2 ? $decimals : 2 );
|
182 |
+
foreach ( WC()->cart->get_cart() as $cart_item ) {
|
183 |
+
/**
|
184 |
+
*
|
185 |
+
* @var WC_Product $product
|
186 |
+
*/
|
187 |
+
$product = $cart_item['data'];
|
188 |
+
$qty = $cart_item['quantity'];
|
189 |
+
$args = array( 'qty' => $qty );
|
190 |
+
$items[] = array(
|
191 |
+
'label' => $qty > 1 ? sprintf( '%s X %s', $product->get_name(), $qty ) : $product->get_name(),
|
192 |
+
'type' => 'LINE_ITEM',
|
193 |
+
'price' => strval( round( $incl_tax ? wc_get_price_including_tax( $product, $args ) : wc_get_price_excluding_tax( $product, $args ), $decimals ) ),
|
194 |
+
);
|
195 |
+
}
|
196 |
+
if ( WC()->cart->needs_shipping() ) {
|
197 |
+
$items[] = array(
|
198 |
+
'label' => __( 'Shipping', 'woo-stripe-payment' ),
|
199 |
+
'type' => 'LINE_ITEM',
|
200 |
+
'price' => strval( round( $incl_tax ? WC()->cart->shipping_total + WC()->cart->shipping_tax_total : WC()->cart->shipping_total, $decimals ) ),
|
201 |
+
);
|
202 |
+
}
|
203 |
+
|
204 |
+
// fees
|
205 |
+
foreach ( WC()->cart->get_fees() as $fee_item ) {
|
206 |
+
/**
|
207 |
+
*
|
208 |
+
* @var WC_Order_I
|
209 |
+
*/
|
210 |
+
$items[] = array(
|
211 |
+
'label' => $fee_item->name,
|
212 |
+
'type' => 'LINE_ITEM',
|
213 |
+
'price' => strval( round( $incl_tax ? $fee_item->total + $fee_item->tax : $fee_item->total, $decimals ) ),
|
214 |
+
);
|
215 |
+
}
|
216 |
+
|
217 |
+
// coupons
|
218 |
+
if ( WC()->cart->discount_cart != 0 ) {
|
219 |
+
$items[] = array(
|
220 |
+
'label' => __( 'Discount', 'woo-stripe-payment' ),
|
221 |
+
'type' => 'LINE_ITEM',
|
222 |
+
'price' => strval(
|
223 |
+
round(
|
224 |
+
- 1 *
|
225 |
+
abs( $incl_tax ? WC()->cart->discount_cart + WC()->cart->discount_cart_tax : WC()->cart->discount_cart ),
|
226 |
+
$decimals
|
227 |
+
)
|
228 |
+
),
|
229 |
+
);
|
230 |
+
}
|
231 |
+
|
232 |
+
if ( ! $incl_tax && wc_tax_enabled() ) {
|
233 |
+
$item = array(
|
234 |
+
'label' => __( 'Tax', 'woo-stripe-payment' ),
|
235 |
+
'type' => 'TAX',
|
236 |
+
'price' => strval( round( WC()->cart->get_taxes_total(), $decimals ) ),
|
237 |
+
);
|
238 |
+
if ( 'itemized' === get_option( 'woocommerce_tax_total_display' ) ) {
|
239 |
+
if ( 0 < WC()->cart->get_taxes_total() ) {
|
240 |
+
$items[] = $item;
|
241 |
+
}
|
242 |
+
} else {
|
243 |
+
$items[] = $item;
|
244 |
+
}
|
245 |
+
}
|
246 |
+
}
|
247 |
+
|
248 |
+
return $encode ? htmlspecialchars( json_encode( $items ) ) : $items;
|
249 |
+
}
|
250 |
+
|
251 |
+
public function get_shipping_methods( $encode = false ) {
|
252 |
+
if ( wcs_stripe_active() && WC_Subscriptions_Change_Payment_Gateway::$is_request_to_change_payment ) {
|
253 |
+
$methods = array();
|
254 |
+
} else {
|
255 |
+
$methods = array();
|
256 |
+
$packages = WC()->shipping()->get_packages();
|
257 |
+
foreach ( $packages as $i => $package ) {
|
258 |
+
foreach ( $package['rates'] as $rate ) {
|
259 |
+
/**
|
260 |
+
*
|
261 |
+
* @var WC_Shipping_Rate $rate
|
262 |
+
*/
|
263 |
+
$methods[] = array(
|
264 |
+
'id' => sprintf( '%s:%s', $i, $rate->id ),
|
265 |
+
'label' => $this->get_shipping_method_label( $rate ),
|
266 |
+
'description' => '',
|
267 |
+
);
|
268 |
+
}
|
269 |
+
}
|
270 |
+
if ( empty( $methods ) ) {
|
271 |
+
// GPay does not like empty shipping methods. Make a temporary one;
|
272 |
+
$methods[] = array(
|
273 |
+
'id' => 'default',
|
274 |
+
'label' => __( 'Waiting...', 'woo-stripe-payment' ),
|
275 |
+
'description' => __( 'loading shipping methods...', 'woo-stripe-payment' ),
|
276 |
+
);
|
277 |
+
}
|
278 |
+
}
|
279 |
+
|
280 |
+
return $encode ? htmlspecialchars( json_encode( $methods ) ) : $methods;
|
281 |
+
}
|
282 |
+
|
283 |
+
/**
|
284 |
+
* Return a formatted shipping method label.
|
285 |
+
* <strong>Example</strong> 5 Day shipping: 5 USD
|
286 |
+
*
|
287 |
+
* @param WC_Shipping_Rate $rate
|
288 |
+
*
|
289 |
+
* @return
|
290 |
+
*/
|
291 |
+
public function get_shipping_method_label( $rate ) {
|
292 |
+
$incl_tax = wc_stripe_display_prices_including_tax();
|
293 |
+
|
294 |
+
if ( $incl_tax ) {
|
295 |
+
$total = $rate->cost + $rate->get_shipping_tax();
|
296 |
+
} else {
|
297 |
+
$total = $rate->cost;
|
298 |
+
}
|
299 |
+
$decimals = ( ( $decimals = wc_get_price_decimals() ) < 2 ? $decimals : 2 );
|
300 |
+
$total = number_format( $total, $decimals );
|
301 |
+
$label = sprintf( '%s: %s %s', $rate->get_label(), $total, get_woocommerce_currency() );
|
302 |
+
|
303 |
+
if ( $incl_tax ) {
|
304 |
+
if ( $rate->get_shipping_tax() > 0 && ! wc_prices_include_tax() ) {
|
305 |
+
$label .= ' ' . WC()->countries->inc_tax_or_vat();
|
306 |
+
}
|
307 |
+
} else {
|
308 |
+
if ( $rate->get_shipping_tax() > 0 && wc_prices_include_tax() ) {
|
309 |
+
$label .= ' ' . WC()->countries->ex_tax_or_vat();
|
310 |
+
}
|
311 |
+
}
|
312 |
+
|
313 |
+
return $label;
|
314 |
+
}
|
315 |
+
|
316 |
+
public function add_to_cart_response( $data ) {
|
317 |
+
$data['googlepay']['displayItems'] = $this->get_display_items();
|
318 |
+
|
319 |
+
return $data;
|
320 |
+
}
|
321 |
+
|
322 |
+
/**
|
323 |
+
* Outputs fields required by Google Pay to render the payment wallet.
|
324 |
+
*/
|
325 |
+
public function output_display_items() {
|
326 |
+
printf( '<input type="hidden" id="%1$s" data-items="%2$s"/>', 'googlepay_display_items', $this->get_display_items( true ) );
|
327 |
+
printf( '<input type="hidden" id="%1$s" data-items="%2$s"/>', 'googlepay_shipping_options', $this->get_shipping_methods( true ) );
|
328 |
+
}
|
329 |
+
}
|
includes/gateways/class-wc-payment-gateway-stripe-ideal.php
CHANGED
@@ -1,35 +1,34 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
if (! class_exists
|
5 |
-
return;
|
6 |
-
}
|
7 |
-
|
8 |
-
|
9 |
-
*
|
10 |
-
* @
|
11 |
-
*
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
$this->
|
24 |
-
|
25 |
-
$this->countries
|
26 |
-
|
27 |
-
$this->
|
28 |
-
$this->
|
29 |
-
$this->
|
30 |
-
$this->
|
31 |
-
$this->
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
}
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
if ( ! class_exists( 'WC_Payment_Gateway_Stripe_Local_Payment' ) ) {
|
5 |
+
return;
|
6 |
+
}
|
7 |
+
|
8 |
+
/**
|
9 |
+
*
|
10 |
+
* @package Stripe/Gateways
|
11 |
+
* @author PaymentPlugins
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
class WC_Payment_Gateway_Stripe_Ideal extends WC_Payment_Gateway_Stripe_Local_Payment {
|
15 |
+
|
16 |
+
protected $payment_method_type = 'ideal';
|
17 |
+
|
18 |
+
// use WC_Stripe_Local_Payment_Charge_Trait;
|
19 |
+
|
20 |
+
use WC_Stripe_Local_Payment_Intent_Trait;
|
21 |
+
|
22 |
+
public function __construct() {
|
23 |
+
$this->local_payment_type = 'ideal';
|
24 |
+
$this->currencies = array( 'EUR' );
|
25 |
+
$this->countries = array( 'NL' );
|
26 |
+
$this->id = 'stripe_ideal';
|
27 |
+
$this->tab_title = __( 'iDEAL', 'woo-stripe-payment' );
|
28 |
+
$this->method_title = __( 'iDEAL', 'woo-stripe-payment' );
|
29 |
+
$this->method_description = __( 'Ideal gateway that integrates with your Stripe account.', 'woo-stripe-payment' );
|
30 |
+
$this->icon = wc_stripe()->assets_url( 'img/ideal.svg' );
|
31 |
+
$this->order_button_text = $this->get_order_button_text( __( 'iDEAL', 'woo-stripe-payment' ) );
|
32 |
+
parent::__construct();
|
33 |
+
}
|
34 |
+
}
|
|
includes/gateways/class-wc-payment-gateway-stripe-klarna.php
CHANGED
@@ -1,277 +1,298 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
if (! class_exists
|
5 |
-
return;
|
6 |
-
}
|
7 |
-
|
8 |
-
|
9 |
-
*
|
10 |
-
* @
|
11 |
-
*
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
$this->
|
20 |
-
|
21 |
-
|
22 |
-
$this->
|
23 |
-
$this->
|
24 |
-
$this->
|
25 |
-
$this->
|
26 |
-
$this->
|
27 |
-
$this->
|
28 |
-
$this->
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
add_action
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
]
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
$
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
}
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
*
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
'
|
110 |
-
'
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
];
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
}
|
261 |
-
|
262 |
-
/**
|
263 |
-
*
|
264 |
-
*
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
if ( ! class_exists( 'WC_Payment_Gateway_Stripe_Local_Payment' ) ) {
|
5 |
+
return;
|
6 |
+
}
|
7 |
+
|
8 |
+
/**
|
9 |
+
*
|
10 |
+
* @package Stripe/Gateways
|
11 |
+
* @author PaymentPlugins
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
class WC_Payment_Gateway_Stripe_Klarna extends WC_Payment_Gateway_Stripe_Local_Payment {
|
15 |
+
|
16 |
+
use WC_Stripe_Local_Payment_Charge_Trait;
|
17 |
+
|
18 |
+
public function __construct() {
|
19 |
+
$this->local_payment_type = 'klarna';
|
20 |
+
$this->currencies = array( 'EUR', 'SEK', 'NOK', 'DKK', 'GBP', 'USD' );
|
21 |
+
$this->id = 'stripe_klarna';
|
22 |
+
$this->tab_title = __( 'Klarna', 'woo-stripe-payment' );
|
23 |
+
$this->template_name = 'local-payment.php';
|
24 |
+
$this->token_type = 'Stripe_Local';
|
25 |
+
$this->method_title = __( 'Klarna', 'woo-stripe-payment' );
|
26 |
+
$this->method_description = __( 'Klarna gateway that integrates with your Stripe account.', 'woo-stripe-payment' );
|
27 |
+
$this->icon = wc_stripe()->assets_url( 'img/klarna.svg' );
|
28 |
+
$this->order_button_text = $this->get_order_button_text( __( 'Klarna', 'woo-stripe-payment' ) );
|
29 |
+
parent::__construct();
|
30 |
+
$this->template_name = 'klarna.php';
|
31 |
+
}
|
32 |
+
|
33 |
+
public function hooks() {
|
34 |
+
parent::hooks();
|
35 |
+
add_action( 'woocommerce_review_order_before_payment', array( $this, 'enqueue_klarna' ) );
|
36 |
+
add_action( 'woocommerce_pay_order_after_submit', array( $this, 'enqueue_klarna' ) );
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Enqueue Klarna based on whether it's available or not.
|
41 |
+
*/
|
42 |
+
public function enqueue_klarna() {
|
43 |
+
if ( $this->is_available() ) {
|
44 |
+
wc_stripe()->scripts()->enqueue_script( 'klarna', 'https://x.klarnacdn.net/kp/lib/v1/api.js', array(), wc_stripe()->version(), true );
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
public function get_required_parameters() {
|
49 |
+
return array(
|
50 |
+
'USD' => array( 'US' ),
|
51 |
+
'EUR' => array( 'AT', 'FI', 'DE', 'NL' ),
|
52 |
+
'DKK' => array( 'DK' ),
|
53 |
+
'NOK' => array( 'NO' ),
|
54 |
+
'SEK' => array( 'SE' ),
|
55 |
+
'GBP' => array( 'GB' ),
|
56 |
+
);
|
57 |
+
}
|
58 |
+
|
59 |
+
public function is_local_payment_available() {
|
60 |
+
global $wp;
|
61 |
+
if ( isset( $wp->query_vars['order-pay'] ) ) {
|
62 |
+
$order = wc_get_order( absint( $wp->query_vars['order-pay'] ) );
|
63 |
+
$currency = $order->get_currency();
|
64 |
+
$country = $order->get_billing_country();
|
65 |
+
} else {
|
66 |
+
$currency = get_woocommerce_currency();
|
67 |
+
$country = WC()->customer ? WC()->customer->get_billing_country() : null;
|
68 |
+
if ( ! $country ) {
|
69 |
+
$country = WC()->countries->get_base_country();
|
70 |
+
}
|
71 |
+
}
|
72 |
+
if ( $country ) {
|
73 |
+
$params = $this->get_required_parameters();
|
74 |
+
|
75 |
+
return isset( $params[ $currency ] ) && array_search( $country, $params[ $currency ] ) !== false;
|
76 |
+
}
|
77 |
+
|
78 |
+
return false;
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
*
|
83 |
+
* {@inheritDoc}
|
84 |
+
*
|
85 |
+
* @see WC_Payment_Gateway_Stripe::payment_fields()
|
86 |
+
*/
|
87 |
+
public function payment_fields() {
|
88 |
+
// this might be an update checkout request. If so, update the source if it exists
|
89 |
+
if ( is_ajax() && ( $order_id = absint( WC()->session->get( 'order_awaiting_payment' ) ) ) ) {
|
90 |
+
$order = wc_get_order( $order_id );
|
91 |
+
if ( $order->get_payment_method() === $this->id && ( $source_id = $order->get_meta( WC_Stripe_Constants::SOURCE_ID, true ) ) ) {
|
92 |
+
$this->payment_object->get_gateway()->sources->mode( wc_stripe_order_mode( $order ) )->update( $source_id, $this->get_update_source_args( $order ) );
|
93 |
+
}
|
94 |
+
}
|
95 |
+
parent::payment_fields();
|
96 |
+
}
|
97 |
+
|
98 |
+
public function get_local_payment_settings() {
|
99 |
+
return wp_parse_args(
|
100 |
+
array(
|
101 |
+
'payment_categories' => array(
|
102 |
+
'title' => __( 'Payment Categories', 'woo-stripe-payment' ),
|
103 |
+
'type' => 'multiselect',
|
104 |
+
'class' => 'wc-enhanced-select',
|
105 |
+
'options' => $this->get_payment_categories(),
|
106 |
+
'default' => array_keys( $this->get_payment_categories() ),
|
107 |
+
'desc_tip' => true,
|
108 |
+
'description' => __(
|
109 |
+
'These are the payment categories that will be displayed on the checkout page if they are supported. Note, depending on the customer\'s billing country, not all enabled options may show.',
|
110 |
+
'woo-stripe-payment'
|
111 |
+
),
|
112 |
+
),
|
113 |
+
),
|
114 |
+
parent::get_local_payment_settings()
|
115 |
+
);
|
116 |
+
}
|
117 |
+
|
118 |
+
private function get_update_source_args( $order ) {
|
119 |
+
$args = $this->get_source_args( $order, true );
|
120 |
+
unset( $args['type'], $args['currency'], $args['statement_descriptor'], $args['redirect'], $args['klarna']['product'], $args['klarna']['locale'] );
|
121 |
+
|
122 |
+
return $args;
|
123 |
+
}
|
124 |
+
|
125 |
+
/**
|
126 |
+
*
|
127 |
+
* {@inheritDoc}
|
128 |
+
*
|
129 |
+
* @see WC_Payment_Gateway_Stripe_Local_Payment::get_source_args()
|
130 |
+
*/
|
131 |
+
public function get_source_args( $order, $update = false ) {
|
132 |
+
if ( $update ) {
|
133 |
+
/*
|
134 |
+
* Use customer if this is an update since customer object has been updated
|
135 |
+
* with all checkout form data in the update_order_review process.
|
136 |
+
*/
|
137 |
+
$object = WC()->customer;
|
138 |
+
} else {
|
139 |
+
$object = $order;
|
140 |
+
}
|
141 |
+
|
142 |
+
$args = array_merge_recursive(
|
143 |
+
parent::get_source_args( $order ),
|
144 |
+
array(
|
145 |
+
'klarna' => array(
|
146 |
+
'product' => 'payment',
|
147 |
+
'purchase_country' => $object->get_billing_country(),
|
148 |
+
'first_name' => $object->get_billing_first_name(),
|
149 |
+
'last_name' => $object->get_billing_last_name(),
|
150 |
+
),
|
151 |
+
'owner' => array(
|
152 |
+
'address' => array(
|
153 |
+
'city' => $object->get_billing_city(),
|
154 |
+
'country' => $object->get_billing_country(),
|
155 |
+
'line1' => $object->get_billing_address_1(),
|
156 |
+
'line2' => $object->get_billing_address_2(),
|
157 |
+
'postal_code' => $object->get_billing_postcode(),
|
158 |
+
'state' => $object->get_billing_state(),
|
159 |
+
),
|
160 |
+
),
|
161 |
+
)
|
162 |
+
);
|
163 |
+
$args['source_order'] = array();
|
164 |
+
|
165 |
+
if ( ( $locale = get_locale() ) ) {
|
166 |
+
$args['klarna']['locale'] = str_replace( '_', '-', $locale );
|
167 |
+
}
|
168 |
+
|
169 |
+
if ( $order->get_shipping_address_1() ) {
|
170 |
+
$args['klarna']['shipping_first_name'] = $object->get_shipping_first_name();
|
171 |
+
$args['klarna']['shipping_last_name'] = $object->get_shipping_last_name();
|
172 |
+
$args['source_order']['shipping']['address'] = array(
|
173 |
+
'city' => $object->get_billing_city(),
|
174 |
+
'country' => $object->get_shipping_country(),
|
175 |
+
'line1' => $object->get_shipping_address_1(),
|
176 |
+
'line2' => $object->get_shipping_address_2(),
|
177 |
+
'postal_code' => $object->get_shipping_postcode(),
|
178 |
+
'state' => $object->get_shipping_state(),
|
179 |
+
);
|
180 |
+
}
|
181 |
+
|
182 |
+
foreach ( $order->get_items( 'line_item' ) as $item ) {
|
183 |
+
/**
|
184 |
+
*
|
185 |
+
* @var WC_Order_Item_Product $item
|
186 |
+
*/
|
187 |
+
$args['source_order']['items'][] = array(
|
188 |
+
'type' => 'sku',
|
189 |
+
'amount' => wc_stripe_add_number_precision( $item->get_subtotal(), $order->get_currency() ),
|
190 |
+
'currency' => $order->get_currency(),
|
191 |
+
'quantity' => $item->get_quantity(),
|
192 |
+
'description' => $item->get_name(),
|
193 |
+
);
|
194 |
+
}
|
195 |
+
// shipping
|
196 |
+
if ( $order->get_shipping_total() ) {
|
197 |
+
$args['source_order']['items'][] = array(
|
198 |
+
'type' => 'shipping',
|
199 |
+
'amount' => wc_stripe_add_number_precision( $order->get_shipping_total(), $order->get_currency() ),
|
200 |
+
'currency' => $order->get_currency(),
|
201 |
+
'quantity' => 1,
|
202 |
+
'description' => __( 'Shipping', 'woo-stripe-payment' ),
|
203 |
+
);
|
204 |
+
}
|
205 |
+
// discount
|
206 |
+
if ( $order->get_discount_total() ) {
|
207 |
+
$args['source_order']['items'][] = array(
|
208 |
+
'type' => 'discount',
|
209 |
+
'amount' => - 1 * wc_stripe_add_number_precision( $order->get_discount_total(), $order->get_currency() ),
|
210 |
+
'currency' => $order->get_currency(),
|
211 |
+
'quantity' => 1,
|
212 |
+
'description' => __( 'Discount', 'woo-stripe-payment' ),
|
213 |
+
);
|
214 |
+
}
|
215 |
+
// fees
|
216 |
+
if ( $order->get_fees() ) {
|
217 |
+
$fee_total = 0;
|
218 |
+
foreach ( $order->get_fees() as $fee ) {
|
219 |
+
$fee_total += wc_stripe_add_number_precision( $fee->get_total(), $order->get_currency() );
|
220 |
+
}
|
221 |
+
$args['source_order']['items'][] = array(
|
222 |
+
'type' => 'sku',
|
223 |
+
'amount' => $fee_total,
|
224 |
+
'currency' => $order->get_currency(),
|
225 |
+
'quantity' => 1,
|
226 |
+
'description' => __( 'Fee', 'woo-stripe-payment' ),
|
227 |
+
);
|
228 |
+
}
|
229 |
+
// tax
|
230 |
+
if ( $order->get_total_tax() ) {
|
231 |
+
$args['source_order']['items'][] = array(
|
232 |
+
'type' => 'tax',
|
233 |
+
'amount' => wc_stripe_add_number_precision( $order->get_total_tax() ),
|
234 |
+
'description' => __( 'Tax', 'woo-stripe-payment' ),
|
235 |
+
'quantity' => 1,
|
236 |
+
'currency' => $order->get_currency(),
|
237 |
+
);
|
238 |
+
}
|
239 |
+
|
240 |
+
return $args;
|
241 |
+
}
|
242 |
+
|
243 |
+
/**
|
244 |
+
*
|
245 |
+
* {@inheritDoc}
|
246 |
+
*
|
247 |
+
* @see WC_Payment_Gateway_Stripe_Local_Payment::get_source_redirect_url()
|
248 |
+
*/
|
249 |
+
public function get_source_redirect_url( $source, $order ) {
|
250 |
+
$klarna_categories = explode( ',', $source['klarna']['payment_method_categories'] );
|
251 |
+
$klarna_categories = array_intersect( $klarna_categories, $this->get_option( 'payment_categories' ) );
|
252 |
+
$source['klarna']['payment_method_categories'] = implode( $klarna_categories, ',' );
|
253 |
+
|
254 |
+
return '#local_payment=klarna&redirect=' . $this->get_local_payment_return_url( $order ) . '&encoded_source=' .
|
255 |
+
base64_encode( wp_json_encode( $source ) );
|
256 |
+
}
|
257 |
+
|
258 |
+
protected function get_local_payment_return_url( $order ) {
|
259 |
+
return add_query_arg( 'source', $order->get_meta( '_stripe_source_id', true ), parent::get_local_payment_return_url( $order ) );
|
260 |
+
}
|
261 |
+
|
262 |
+
/**
|
263 |
+
*
|
264 |
+
* @return mixed
|
265 |
+
*/
|
266 |
+
public function get_payment_categories() {
|
267 |
+
return apply_filters(
|
268 |
+
'wc_stripe_klarna_payment_categries',
|
269 |
+
array(
|
270 |
+
'pay_now' => __( 'Pay Now', 'woo-stripe-payment' ),
|
271 |
+
'pay_later' => __( 'Pay Later', 'woo-stripe-payment' ),
|
272 |
+
'pay_over_time' => __(
|
273 |
+
'Pay Over Time',
|
274 |
+
'woo-stripe-payment'
|
275 |
+
),
|
276 |
+
)
|
277 |
+
);
|
278 |
+
}
|
279 |
+
|
280 |
+
/**
|
281 |
+
*
|
282 |
+
* {@inheritDoc}
|
283 |
+
*
|
284 |
+
* @see WC_Payment_Gateway_Stripe_Local_Payment::get_payment_description()
|
285 |
+
*/
|
286 |
+
public function get_payment_description() {
|
287 |
+
return '<p>' .
|
288 |
+
sprintf( __( 'Click %1$shere%2$s for Klarna test payment methods.', 'woo-stripe-payment' ), '<a target="_blank" href="https://stripe.com/docs/sources/klarna#testing-klarna-payments">', '</a>' ) .
|
289 |
+
'</p>' . parent::get_payment_description();
|
290 |
+
}
|
291 |
+
|
292 |
+
public function get_localized_params() {
|
293 |
+
$params = parent::get_localized_params();
|
294 |
+
$params['messages']['klarna_error'] = __( 'Your purchase is not approved.', 'woo-stripe-payment' );
|
295 |
+
|
296 |
+
return $params;
|
297 |
+
}
|
298 |
+
}
|
includes/gateways/class-wc-payment-gateway-stripe-multibanco.php
CHANGED
@@ -1,33 +1,32 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
if (! class_exists
|
5 |
-
return;
|
6 |
-
}
|
7 |
-
|
8 |
-
|
9 |
-
*
|
10 |
-
* @
|
11 |
-
*
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
$this->
|
20 |
-
|
21 |
-
$this->countries
|
22 |
-
|
23 |
-
$this->
|
24 |
-
$this->
|
25 |
-
$this->
|
26 |
-
$this->
|
27 |
-
$this->
|
28 |
-
$this->
|
29 |
-
$this->
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
}
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
if ( ! class_exists( 'WC_Payment_Gateway_Stripe_Local_Payment' ) ) {
|
5 |
+
return;
|
6 |
+
}
|
7 |
+
|
8 |
+
/**
|
9 |
+
*
|
10 |
+
* @package Stripe/Gateways
|
11 |
+
* @author PaymentPlugins
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
class WC_Payment_Gateway_Stripe_Multibanco extends WC_Payment_Gateway_Stripe_Local_Payment {
|
15 |
+
|
16 |
+
use WC_Stripe_Local_Payment_Charge_Trait;
|
17 |
+
|
18 |
+
public function __construct() {
|
19 |
+
$this->local_payment_type = 'multibanco';
|
20 |
+
$this->currencies = array( 'EUR' );
|
21 |
+
$this->countries = array( 'PT' );
|
22 |
+
$this->id = 'stripe_multibanco';
|
23 |
+
$this->tab_title = __( 'Multibanco', 'woo-stripe-payment' );
|
24 |
+
$this->template_name = 'local-payment.php';
|
25 |
+
$this->token_type = 'Stripe_Local';
|
26 |
+
$this->method_title = __( 'Multibanco', 'woo-stripe-payment' );
|
27 |
+
$this->method_description = __( 'Multibanco gateway that integrates with your Stripe account.', 'woo-stripe-payment' );
|
28 |
+
$this->icon = wc_stripe()->assets_url( 'img/multibanco.svg' );
|
29 |
+
$this->order_button_text = $this->get_order_button_text( __( 'Multibanco', 'woo-stripe-payment' ) );
|
30 |
+
parent::__construct();
|
31 |
+
}
|
32 |
+
}
|
|
includes/gateways/class-wc-payment-gateway-stripe-p24.php
CHANGED
@@ -1,33 +1,32 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
if (! class_exists
|
5 |
-
return;
|
6 |
-
}
|
7 |
-
|
8 |
-
|
9 |
-
*
|
10 |
-
* @
|
11 |
-
*
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
$this->
|
20 |
-
|
21 |
-
$this->countries
|
22 |
-
|
23 |
-
$this->
|
24 |
-
$this->
|
25 |
-
$this->
|
26 |
-
$this->
|
27 |
-
$this->
|
28 |
-
$this->
|
29 |
-
$this->
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
}
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
if ( ! class_exists( 'WC_Payment_Gateway_Stripe_Local_Payment' ) ) {
|
5 |
+
return;
|
6 |
+
}
|
7 |
+
|
8 |
+
/**
|
9 |
+
*
|
10 |
+
* @package Stripe/Gateways
|
11 |
+
* @author PaymentPlugins
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
class WC_Payment_Gateway_Stripe_P24 extends WC_Payment_Gateway_Stripe_Local_Payment {
|
15 |
+
|
16 |
+
use WC_Stripe_Local_Payment_Charge_Trait;
|
17 |
+
|
18 |
+
public function __construct() {
|
19 |
+
$this->local_payment_type = 'p24';
|
20 |
+
$this->currencies = array( 'EUR', 'PLN' );
|
21 |
+
$this->countries = array( 'PL' );
|
22 |
+
$this->id = 'stripe_p24';
|
23 |
+
$this->tab_title = __( 'Przelewy24', 'woo-stripe-payment' );
|
24 |
+
$this->template_name = 'local-payment.php';
|
25 |
+
$this->token_type = 'Stripe_Local';
|
26 |
+
$this->method_title = __( 'Przelewy24', 'woo-stripe-payment' );
|
27 |
+
$this->method_description = __( 'P24 gateway that integrates with your Stripe account.', 'woo-stripe-payment' );
|
28 |
+
$this->icon = wc_stripe()->assets_url( 'img/p24.svg' );
|
29 |
+
$this->order_button_text = $this->get_order_button_text( __( 'P24', 'woo-stripe-payment' ) );
|
30 |
+
parent::__construct();
|
31 |
+
}
|
32 |
+
}
|
|
includes/gateways/class-wc-payment-gateway-stripe-payment-request.php
CHANGED
@@ -1,87 +1,98 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
if (! class_exists
|
5 |
-
return;
|
6 |
-
}
|
7 |
-
|
8 |
-
|
9 |
-
*
|
10 |
-
*
|
11 |
-
* @
|
12 |
-
*
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
$this->
|
23 |
-
$this->
|
24 |
-
$this->
|
25 |
-
$this->
|
26 |
-
$this->
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
$this->supports[] = '
|
34 |
-
$this->supports[] = '
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
if ( ! class_exists( 'WC_Payment_Gateway_Stripe' ) ) {
|
5 |
+
return;
|
6 |
+
}
|
7 |
+
|
8 |
+
/**
|
9 |
+
* This gateway is provided so merchants can accept Chrome Payments, Microsoft Pay, etc.
|
10 |
+
*
|
11 |
+
* @author PaymentPlugins
|
12 |
+
* @package Stripe/Gateways
|
13 |
+
*
|
14 |
+
*/
|
15 |
+
class WC_Payment_Gateway_Stripe_Payment_Request extends WC_Payment_Gateway_Stripe {
|
16 |
+
|
17 |
+
use WC_Stripe_Payment_Intent_Trait;
|
18 |
+
|
19 |
+
protected $payment_method_type = 'card';
|
20 |
+
|
21 |
+
public function __construct() {
|
22 |
+
$this->id = 'stripe_payment_request';
|
23 |
+
$this->tab_title = __( 'PaymentRequest Gateway', 'woo-stripe-payment' );
|
24 |
+
$this->template_name = 'payment-request.php';
|
25 |
+
$this->token_type = 'Stripe_CC';
|
26 |
+
$this->method_title = __( 'Stripe Payment Request', 'woo-stripe-payment' );
|
27 |
+
$this->method_description = __( 'Gateway that renders based on the user\'s browser. Chrome payment methods, Microsoft pay, etc.', 'woo-stripe-payment' );
|
28 |
+
parent::__construct();
|
29 |
+
}
|
30 |
+
|
31 |
+
public function init_supports() {
|
32 |
+
parent::init_supports();
|
33 |
+
$this->supports[] = 'wc_stripe_cart_checkout';
|
34 |
+
$this->supports[] = 'wc_stripe_product_checkout';
|
35 |
+
$this->supports[] = 'wc_stripe_banner_checkout';
|
36 |
+
}
|
37 |
+
|
38 |
+
public function get_icon() {
|
39 |
+
return wc_stripe_get_template( 'payment-request-icons.php' );
|
40 |
+
}
|
41 |
+
|
42 |
+
public function enqueue_product_scripts( $scripts ) {
|
43 |
+
$this->enqueue_checkout_scripts( $scripts );
|
44 |
+
}
|
45 |
+
|
46 |
+
public function enqueue_cart_scripts( $scripts ) {
|
47 |
+
$this->enqueue_checkout_scripts( $scripts );
|
48 |
+
}
|
49 |
+
|
50 |
+
public function enqueue_checkout_scripts( $scripts ) {
|
51 |
+
$scripts->enqueue_script(
|
52 |
+
'payment-request',
|
53 |
+
$scripts->assets_url( 'js/frontend/payment-request.js' ),
|
54 |
+
array(
|
55 |
+
$scripts->get_handle( 'wc-stripe' ),
|
56 |
+
$scripts->get_handle( 'external' ),
|
57 |
+
),
|
58 |
+
wc_stripe()->version(),
|
59 |
+
true
|
60 |
+
);
|
61 |
+
|
62 |
+
$scripts->localize_script( 'payment-request', $this->get_localized_params() );
|
63 |
+
}
|
64 |
+
|
65 |
+
public function get_localized_params() {
|
66 |
+
return array_merge_recursive(
|
67 |
+
parent::get_localized_params(),
|
68 |
+
array(
|
69 |
+
'button' => array(
|
70 |
+
'type' => $this->get_option( 'button_type' ),
|
71 |
+
'theme' => $this->get_option( 'button_theme' ),
|
72 |
+
'height' => $this->get_button_height(),
|
73 |
+
),
|
74 |
+
'icons' => array( 'chrome' => wc_stripe()->assets_url( 'img/chrome.svg' ) ),
|
75 |
+
'messages' => array(
|
76 |
+
'invalid_amount' => __( 'Please update you product quantity before paying.', 'woo-stripe-payment' ),
|
77 |
+
'add_to_cart' => __( 'Adding to cart...', 'woo-stripe-payment' ),
|
78 |
+
'choose_product' => __(
|
79 |
+
'Please select a product option before updating quantity.',
|
80 |
+
'woo-stripe-payment'
|
81 |
+
),
|
82 |
+
),
|
83 |
+
)
|
84 |
+
);
|
85 |
+
}
|
86 |
+
|
87 |
+
private function get_button_height() {
|
88 |
+
$value = $this->get_option( 'button_height' );
|
89 |
+
$value .= strpos( $value, 'px' ) === false ? 'px' : '';
|
90 |
+
return $value;
|
91 |
+
}
|
92 |
+
|
93 |
+
private function get_icon_for_payment_request() {
|
94 |
+
$user_agent = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : '';
|
95 |
+
if ( ! empty( $user_agent ) ) {
|
96 |
+
}
|
97 |
+
}
|
98 |
+
}
|
includes/gateways/class-wc-payment-gateway-stripe-sepa.php
CHANGED
@@ -1,60 +1,64 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
if (! class_exists
|
5 |
-
return;
|
6 |
-
}
|
7 |
-
|
8 |
-
|
9 |
-
*
|
10 |
-
* @
|
11 |
-
*
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
$this->
|
20 |
-
$this->
|
21 |
-
|
22 |
-
$this->id
|
23 |
-
$this->tab_title
|
24 |
-
$this->template_name
|
25 |
-
$this->token_type
|
26 |
-
$this->method_title
|
27 |
-
$this->method_description = __
|
28 |
-
$this->icon
|
29 |
-
$this->order_button_text
|
30 |
-
parent::__construct
|
31 |
-
|
32 |
-
$this->local_payment_description = sprintf
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
)
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
if ( ! class_exists( 'WC_Payment_Gateway_Stripe_Local_Payment' ) ) {
|
5 |
+
return;
|
6 |
+
}
|
7 |
+
|
8 |
+
/**
|
9 |
+
*
|
10 |
+
* @package Stripe/Gateways
|
11 |
+
* @author PaymentPlugins
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
class WC_Payment_Gateway_Stripe_Sepa extends WC_Payment_Gateway_Stripe_Local_Payment {
|
15 |
+
|
16 |
+
use WC_Stripe_Local_Payment_Charge_Trait;
|
17 |
+
|
18 |
+
public function __construct() {
|
19 |
+
$this->synchronous = false;
|
20 |
+
$this->local_payment_type = 'sepa_debit';
|
21 |
+
$this->currencies = array( 'EUR' );
|
22 |
+
$this->id = 'stripe_sepa';
|
23 |
+
$this->tab_title = __( 'SEPA', 'woo-stripe-payment' );
|
24 |
+
$this->template_name = 'local-payment.php';
|
25 |
+
$this->token_type = 'Stripe_Local';
|
26 |
+
$this->method_title = __( 'Sepa', 'woo-stripe-payment' );
|
27 |
+
$this->method_description = __( 'Sepa gateway that integrates with your Stripe account.', 'woo-stripe-payment' );
|
28 |
+
$this->icon = wc_stripe()->assets_url( 'img/sepa.svg' );
|
29 |
+
$this->order_button_text = $this->get_order_button_text( __( 'SEPA', 'woo-stripe-payment' ) );
|
30 |
+
parent::__construct();
|
31 |
+
|
32 |
+
$this->local_payment_description = sprintf(
|
33 |
+
__(
|
34 |
+
'By providing your IBAN and confirming this payment, you are
|
35 |
+
authorizing %s and Stripe, our payment service provider, to send instructions to your bank to debit your account
|
36 |
+
and your bank to debit your account in accordance with those instructions. You are entitled to a refund from your bank under the
|
37 |
+
terms and conditions of your agreement with your bank. A refund must be claimed within 8 weeks starting from the date on which your account was debited.',
|
38 |
+
'woo-stripe-payment'
|
39 |
+
),
|
40 |
+
$this->get_option( 'company_name' )
|
41 |
+
);
|
42 |
+
}
|
43 |
+
|
44 |
+
public function get_element_params() {
|
45 |
+
return array_merge( parent::get_element_params(), array( 'supportedCountries' => array( 'SEPA' ) ) );
|
46 |
+
}
|
47 |
+
|
48 |
+
public function get_local_payment_settings() {
|
49 |
+
return parent::get_local_payment_settings() + array(
|
50 |
+
'company_name' => array(
|
51 |
+
'title' => __( 'Company Name', 'woo-stripe-payment' ),
|
52 |
+
'type' => 'text',
|
53 |
+
'default' => get_bloginfo( 'name' ),
|
54 |
+
'desc_tip' => true,
|
55 |
+
'description' => __( 'The name of your company that will appear in the SEPA mandate.', 'woo-stripe-payment' ),
|
56 |
+
),
|
57 |
+
);
|
58 |
+
}
|
59 |
+
|
60 |
+
public function get_payment_description() {
|
61 |
+
return parent::get_payment_description() .
|
62 |
+
sprintf( '<p><a target="_blank" href="https://stripe.com/docs/sources/sepa-debit#testing">%s</a></p>', __( 'SEPA Test Accounts', 'woo-stripe-payment' ) );
|
63 |
+
}
|
64 |
+
}
|
includes/gateways/class-wc-payment-gateway-stripe-sofort.php
CHANGED
@@ -1,43 +1,37 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
if (! class_exists
|
5 |
-
return;
|
6 |
-
}
|
7 |
-
|
8 |
-
|
9 |
-
*
|
10 |
-
* @
|
11 |
-
*
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
$this->
|
20 |
-
$this->
|
21 |
-
|
22 |
-
$this->countries
|
23 |
-
|
24 |
-
|
25 |
-
$this->
|
26 |
-
$this->
|
27 |
-
$this->
|
28 |
-
$this->
|
29 |
-
$this->
|
30 |
-
$this->
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
'sofort' => [
|
39 |
-
'country' => $order->get_billing_country ()
|
40 |
-
]
|
41 |
-
] );
|
42 |
-
}
|
43 |
-
}
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
if ( ! class_exists( 'WC_Payment_Gateway_Stripe_Local_Payment' ) ) {
|
5 |
+
return;
|
6 |
+
}
|
7 |
+
|
8 |
+
/**
|
9 |
+
*
|
10 |
+
* @package Stripe/Gateways
|
11 |
+
* @author PaymentPlugins
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
class WC_Payment_Gateway_Stripe_Sofort extends WC_Payment_Gateway_Stripe_Local_Payment {
|
15 |
+
|
16 |
+
use WC_Stripe_Local_Payment_Charge_Trait;
|
17 |
+
|
18 |
+
public function __construct() {
|
19 |
+
$this->synchronous = false;
|
20 |
+
$this->local_payment_type = 'sofort';
|
21 |
+
$this->currencies = array( 'EUR' );
|
22 |
+
$this->countries = array( 'AT', 'BE', 'DE', 'ES', 'IT', 'NL' );
|
23 |
+
$this->id = 'stripe_sofort';
|
24 |
+
$this->tab_title = __( 'Sofort', 'woo-stripe-payment' );
|
25 |
+
$this->template_name = 'local-payment.php';
|
26 |
+
$this->token_type = 'Stripe_Local';
|
27 |
+
$this->method_title = __( 'Sofort', 'woo-stripe-payment' );
|
28 |
+
$this->method_description = __( 'Sofort gateway that integrates with your Stripe account.', 'woo-stripe-payment' );
|
29 |
+
$this->icon = wc_stripe()->assets_url( 'img/sofort.svg' );
|
30 |
+
$this->order_button_text = $this->get_order_button_text( __( 'SOFORT', 'woo-stripe-payment' ) );
|
31 |
+
parent::__construct();
|
32 |
+
}
|
33 |
+
|
34 |
+
public function get_source_args( $order ) {
|
35 |
+
return array_merge( parent::get_source_args( $order ), array( 'sofort' => array( 'country' => $order->get_billing_country() ) ) );
|
36 |
+
}
|
37 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
includes/gateways/class-wc-payment-gateway-stripe-wechat.php
CHANGED
@@ -1,67 +1,73 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
if (! class_exists
|
5 |
-
return;
|
6 |
-
}
|
7 |
-
|
8 |
-
|
9 |
-
*
|
10 |
-
* @
|
11 |
-
*
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
$this->
|
20 |
-
|
21 |
-
|
22 |
-
//
|
23 |
-
|
24 |
-
$this->
|
25 |
-
$this->
|
26 |
-
$this->
|
27 |
-
$this->
|
28 |
-
$this->
|
29 |
-
$this->
|
30 |
-
$this->
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
*
|
37 |
-
*
|
38 |
-
*
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
if ( ! class_exists( 'WC_Payment_Gateway_Stripe_Local_Payment' ) ) {
|
5 |
+
return;
|
6 |
+
}
|
7 |
+
|
8 |
+
/**
|
9 |
+
*
|
10 |
+
* @package Stripe/Gateways
|
11 |
+
* @author PaymentPlugins
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
class WC_Payment_Gateway_Stripe_WeChat extends WC_Payment_Gateway_Stripe_Local_Payment {
|
15 |
+
|
16 |
+
use WC_Stripe_Local_Payment_Charge_Trait;
|
17 |
+
|
18 |
+
public function __construct() {
|
19 |
+
$this->local_payment_type = 'wechat';
|
20 |
+
$this->currencies = array( 'AUD', 'CAD', 'EUR', 'GBP', 'HKD', 'JPY', 'SGD', 'USD' );
|
21 |
+
// $this->countries = [ 'CN'
|
22 |
+
// ];
|
23 |
+
$this->id = 'stripe_wechat';
|
24 |
+
$this->tab_title = __( 'WeChat', 'woo-stripe-payment' );
|
25 |
+
$this->template_name = 'local-payment.php';
|
26 |
+
$this->token_type = 'Stripe_Local';
|
27 |
+
$this->method_title = __( 'WeChat', 'woo-stripe-payment' );
|
28 |
+
$this->method_description = __( 'WeChat gateway that integrates with your Stripe account.', 'woo-stripe-payment' );
|
29 |
+
$this->icon = wc_stripe()->assets_url( 'img/wechat.svg' );
|
30 |
+
$this->order_button_text = $this->get_order_button_text( __( 'WeChat', 'woo-stripe-payment' ) );
|
31 |
+
parent::__construct();
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
*
|
36 |
+
* {@inheritDoc}
|
37 |
+
*
|
38 |
+
* @see WC_Payment_Gateway_Stripe_Local_Payment::get_source_redirect_url()
|
39 |
+
*/
|
40 |
+
public function get_source_redirect_url( $source, $order ) {
|
41 |
+
if ( wc_stripe_mode() == 'live' ) {
|
42 |
+
return sprintf(
|
43 |
+
'#qrcode=%s',
|
44 |
+
base64_encode(
|
45 |
+
wp_json_encode(
|
46 |
+
array(
|
47 |
+
'code' => $source->wechat->qr_code_url,
|
48 |
+
'redirect' => $order->get_checkout_order_received_url(),
|
49 |
+
)
|
50 |
+
)
|
51 |
+
)
|
52 |
+
);
|
53 |
+
}
|
54 |
+
// test code
|
55 |
+
// 'code' => 'weixin:\/\/wxpay\/bizpayurl?pr=tMih4Jo'
|
56 |
+
|
57 |
+
// in test mode just return the redirect url
|
58 |
+
return $source->wechat->qr_code_url;
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
*
|
63 |
+
* {@inheritDoc}
|
64 |
+
*
|
65 |
+
* @see WC_Payment_Gateway_Stripe_Local_Payment::get_localized_params()
|
66 |
+
*/
|
67 |
+
public function get_localized_params() {
|
68 |
+
$data = parent::get_localized_params();
|
69 |
+
$data['qr_script'] = sprintf( wc_stripe()->scripts()->assets_url( 'js/frontend/qrcode.js?ver=%s' ), wc_stripe()->version );
|
70 |
+
$data['qr_message'] = __( 'Scan the QR code using your WeChat app. Once scanned click the Place Order button.', 'woo-stripe-payment' );
|
71 |
+
return $data;
|
72 |
+
}
|
73 |
+
}
|
includes/gateways/settings/ach-settings-v2.php
CHANGED
@@ -1,101 +1,115 @@
|
|
1 |
-
<?php
|
2 |
-
return array(
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
'
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
),
|
24 |
-
'
|
25 |
-
|
26 |
-
|
27 |
-
'
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
'
|
32 |
-
'
|
33 |
-
'
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
'
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
'
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
'
|
47 |
-
'
|
48 |
-
'
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
'
|
53 |
-
'
|
54 |
-
'
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
'
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
),
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
),
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
),
|
78 |
-
'
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
return array(
|
3 |
+
'desc' => array(
|
4 |
+
'type' => 'description',
|
5 |
+
'description' => sprintf( '<div>%s</div>', __( 'For US customers only.', 'woo-stripe-payment' ) ) .
|
6 |
+
sprintf( '<p>%s</p>', sprintf( __( 'Read through our %1$sdocumentation%2$s to configure ACH payments', 'woo-stripe-payment' ), '<a target="_blank" href="https://docs.paymentplugins.com/wc-stripe/config/#/stripe_ach">', '</a>' ) ),
|
7 |
+
),
|
8 |
+
'enabled' => array(
|
9 |
+
'title' => __( 'Enabled', 'woo-stripe-payment' ),
|
10 |
+
'type' => 'checkbox',
|
11 |
+
'default' => 'no',
|
12 |
+
'value' => 'yes',
|
13 |
+
'desc_tip' => true,
|
14 |
+
'description' => __( 'If enabled, your site can accept ACH payments through Stripe.', 'woo-stripe-payment' ),
|
15 |
+
),
|
16 |
+
'environment' => array(
|
17 |
+
'type' => 'select',
|
18 |
+
'title' => __( 'Plaid Environment', 'woo-stripe-payment' ),
|
19 |
+
'options' => array(
|
20 |
+
'sandbox' => __( 'Sandbox', 'woo-stripe-payment' ),
|
21 |
+
'development' => __( 'Development', 'woo-stripe-payment' ),
|
22 |
+
'production' => __( 'Production', 'woo-stripe-payment' ),
|
23 |
+
),
|
24 |
+
'description' => __( 'This setting determines the Plaid environment you are connecting with. When you are ready to accept live transactions, switch this option to Production.<br><strong>Production</strong> - accept live ACH payments <br><strong>Development</strong> - use real bank login details with test transactions <br><strong>Sandbox</strong> - test integration using test credentials', 'woo-stripe-payment' ),
|
25 |
+
),
|
26 |
+
/* 'plaid_keys' => array( 'type' => 'title',
|
27 |
+
'title' => __ ( 'Plaid Keys', 'wo-stripe-paymento' )
|
28 |
+
),
|
29 |
+
'client_id' => array( 'type' => 'text',
|
30 |
+
'title' => __ ( 'Client ID' ),
|
31 |
+
'default' => '',
|
32 |
+
'description' => __ ( 'ID that identifies your Plaid account.', 'woo-stripe-payment' ),
|
33 |
+
'desc_tip' => true
|
34 |
+
),
|
35 |
+
'public_key' => array( 'type' => 'text',
|
36 |
+
'title' => __ ( 'Public Key' ),
|
37 |
+
'default' => '',
|
38 |
+
'description' => __ ( 'Used to identify ACH payments initiated from your site.', 'woo-stripe-payment' ),
|
39 |
+
'desc_tip' => true
|
40 |
+
),
|
41 |
+
'plaid_secrets' => array( 'type' => 'title',
|
42 |
+
'title' => __ ( 'Plaid Secrets', 'wo-stripe-paymento' )
|
43 |
+
),
|
44 |
+
'sandbox_secret' => array(
|
45 |
+
'title' => __ ( 'Sandbox Secret', 'woo-stripe-payment' ),
|
46 |
+
'type' => 'password', 'default' => '',
|
47 |
+
'description' => __ ( 'Key that acts as a password when connecting to Plaid\'s sandbox environment.', 'woo-stripe-payment' ),
|
48 |
+
'desc_tip' => true
|
49 |
+
),
|
50 |
+
'development_secret' => array(
|
51 |
+
'title' => __ ( 'Development Secret', 'woo-stripe-payment' ),
|
52 |
+
'type' => 'password', 'default' => '',
|
53 |
+
'description' => __ ( '', 'woo-stripe-payment' ),
|
54 |
+
'desc_tip' => true
|
55 |
+
),
|
56 |
+
'production_secret' => array(
|
57 |
+
'title' => __ ( 'Production Secret', 'woo-stripe-payment' ),
|
58 |
+
'type' => 'password', 'default' => '',
|
59 |
+
'description' => __ ( 'Key that acts as a password when connecting to Plaid\'s production environment.', 'woo-stripe-payment' ),
|
60 |
+
'desc_tip' => true
|
61 |
+
), */
|
62 |
+
'general_settings' => array(
|
63 |
+
'type' => 'title',
|
64 |
+
'title' => __( 'General Settings', 'woo-stripe-payment' ),
|
65 |
+
),
|
66 |
+
'title_text' => array(
|
67 |
+
'type' => 'text',
|
68 |
+
'title' => __( 'Title', 'woo-stripe-payment' ),
|
69 |
+
'default' => __( 'ACH Payment', 'woo-stripe-payment' ),
|
70 |
+
'desc_tip' => true,
|
71 |
+
'description' => __( 'Title of the ACH gateway' ),
|
72 |
+
),
|
73 |
+
'description' => array(
|
74 |
+
'title' => __( 'Description', 'woo-stripe-payment' ),
|
75 |
+
'type' => 'text',
|
76 |
+
'default' => '',
|
77 |
+
'description' => __( 'Leave blank if you don\'t want a description to show for the gateway.', 'woo-stripe-payment' ),
|
78 |
+
'desc_tip' => true,
|
79 |
+
),
|
80 |
+
'client_name' => array(
|
81 |
+
'type' => 'text',
|
82 |
+
'title' => __( 'Client Name', 'woo-stripe-payment' ),
|
83 |
+
'default' => get_bloginfo( 'name' ),
|
84 |
+
'description' => __( 'The name that appears on the ACH payment screen.', 'woo-stripe-payment' ),
|
85 |
+
'desc_tip' => true,
|
86 |
+
),
|
87 |
+
'method_format' => array(
|
88 |
+
'title' => __( 'ACH Display', 'woo-stripe-payment' ),
|
89 |
+
'type' => 'select',
|
90 |
+
'class' => 'wc-enhanced-select',
|
91 |
+
'options' => wp_list_pluck( $this->get_method_formats(), 'example' ),
|
92 |
+
'value' => '',
|
93 |
+
'default' => 'type_ending_in',
|
94 |
+
'desc_tip' => true,
|
95 |
+
'description' => __( 'This option allows you to customize how the credit card will display for your customers on orders, subscriptions, etc.' ),
|
96 |
+
),
|
97 |
+
'fee' => array(
|
98 |
+
'title' => __( 'ACH Fee', 'woo-stripe-payment' ),
|
99 |
+
'type' => 'ach_fee',
|
100 |
+
'class' => '',
|
101 |
+
'value' => '',
|
102 |
+
'default' => array(
|
103 |
+
'type' => 'none',
|
104 |
+
'taxable' => 'no',
|
105 |
+
'value' => '0',
|
106 |
+
),
|
107 |
+
'options' => array(
|
108 |
+
'none' => __( 'None', 'woo-stripe-payment' ),
|
109 |
+
'amount' => __( 'Amount', 'woo-stripe-payment' ),
|
110 |
+
'percent' => __( 'Percentage', 'woo-stripe-payment' ),
|
111 |
+
),
|
112 |
+
'desc_tip' => true,
|
113 |
+
'description' => __( 'You can assign a fee to the order for ACH payments. Amount is a static amount and percentage is a percentage of the cart amount.', 'woo-stripe-payment' ),
|
114 |
+
),
|
115 |
+
);
|
includes/gateways/settings/ach-settings.php
CHANGED
@@ -1,102 +1,124 @@
|
|
1 |
-
<?php
|
2 |
-
return array(
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
'
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
),
|
25 |
-
'
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
),
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
),
|
37 |
-
'
|
38 |
-
|
39 |
-
|
40 |
-
'
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
),
|
52 |
-
'
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
'
|
59 |
-
|
60 |
-
|
61 |
-
'
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
'
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
'
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
),
|
79 |
-
'
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
return array(
|
3 |
+
'desc' => array(
|
4 |
+
'type' => 'description',
|
5 |
+
'description' => sprintf( '<div>%s</div>', __( 'For US customers only.', 'woo-stripe-payment' ) ) .
|
6 |
+
sprintf( '<p>%s</p>', sprintf( __( 'Read through our %1$sdocumentation%2$s to configure ACH payments', 'woo-stripe-payment' ), '<a target="_blank" href="https://docs.paymentplugins.com/wc-stripe/config/#/stripe_ach">', '</a>' ) ),
|
7 |
+
),
|
8 |
+
'enabled' => array(
|
9 |
+
'title' => __( 'Enabled', 'woo-stripe-payment' ),
|
10 |
+
'type' => 'checkbox',
|
11 |
+
'default' => 'no',
|
12 |
+
'value' => 'yes',
|
13 |
+
'desc_tip' => true,
|
14 |
+
'description' => __( 'If enabled, your site can accept ACH payments through Stripe.', 'woo-stripe-payment' ),
|
15 |
+
),
|
16 |
+
'environment' => array(
|
17 |
+
'type' => 'select',
|
18 |
+
'title' => __( 'Plaid Environment', 'woo-stripe-payment' ),
|
19 |
+
'default' => 'production',
|
20 |
+
'options' => array(
|
21 |
+
'sandbox' => __( 'Sandbox', 'woo-stripe-payment' ),
|
22 |
+
'development' => __( 'Development', 'woo-stripe-payment' ),
|
23 |
+
'production' => __( 'Production', 'woo-stripe-payment' ),
|
24 |
+
),
|
25 |
+
'desc_tip' => true,
|
26 |
+
'description' => __( 'The active Plaid environment. You must set API mode to live to use Plaid\'s development environment.', 'woo-stripe-payment' ),
|
27 |
+
),
|
28 |
+
'plaid_keys' => array(
|
29 |
+
'type' => 'title',
|
30 |
+
'title' => __( 'Plaid Keys', 'wo-stripe-paymento' ),
|
31 |
+
),
|
32 |
+
'client_id' => array(
|
33 |
+
'type' => 'text',
|
34 |
+
'title' => __( 'Client ID' ),
|
35 |
+
'default' => '',
|
36 |
+
'description' => __( 'ID that identifies your Plaid account.', 'woo-stripe-payment' ),
|
37 |
+
'desc_tip' => true,
|
38 |
+
),
|
39 |
+
'public_key' => array(
|
40 |
+
'type' => 'text',
|
41 |
+
'title' => __( 'Public Key' ),
|
42 |
+
'default' => '',
|
43 |
+
'description' => __( 'Used to identify ACH payments initiated from your site.', 'woo-stripe-payment' ),
|
44 |
+
'desc_tip' => true,
|
45 |
+
),
|
46 |
+
'plaid_secrets' => array(
|
47 |
+
'type' => 'title',
|
48 |
+
'title' => __( 'Plaid Secrets', 'wo-stripe-paymento' ),
|
49 |
+
),
|
50 |
+
'sandbox_secret' => array(
|
51 |
+
'title' => __( 'Sandbox Secret', 'woo-stripe-payment' ),
|
52 |
+
'type' => 'password',
|
53 |
+
'default' => '',
|
54 |
+
'description' => __( 'Key that acts as a password when connecting to Plaid\'s sandbox environment.', 'woo-stripe-payment' ),
|
55 |
+
'desc_tip' => true,
|
56 |
+
),
|
57 |
+
'development_secret' => array(
|
58 |
+
'title' => __( 'Development Secret', 'woo-stripe-payment' ),
|
59 |
+
'type' => 'password',
|
60 |
+
'default' => '',
|
61 |
+
'description' => __( 'Development allows you to test real bank credentials with test transactions.', 'woo-stripe-payment' ),
|
62 |
+
'desc_tip' => true,
|
63 |
+
),
|
64 |
+
'production_secret' => array(
|
65 |
+
'title' => __( 'Production Secret', 'woo-stripe-payment' ),
|
66 |
+
'type' => 'password',
|
67 |
+
'default' => '',
|
68 |
+
'description' => __( 'Key that acts as a password when connecting to Plaid\'s production environment.', 'woo-stripe-payment' ),
|
69 |
+
'desc_tip' => true,
|
70 |
+
),
|
71 |
+
'general_settings' => array(
|
72 |
+
'type' => 'title',
|
73 |
+
'title' => __( 'General Settings', 'woo-stripe-payment' ),
|
74 |
+
),
|
75 |
+
'title_text' => array(
|
76 |
+
'type' => 'text',
|
77 |
+
'title' => __( 'Title', 'woo-stripe-payment' ),
|
78 |
+
'default' => __( 'ACH Payment', 'woo-stripe-payment' ),
|
79 |
+
'desc_tip' => true,
|
80 |
+
'description' => __( 'Title of the ACH gateway' ),
|
81 |
+
),
|
82 |
+
'description' => array(
|
83 |
+
'title' => __( 'Description', 'woo-stripe-payment' ),
|
84 |
+
'type' => 'text',
|
85 |
+
'default' => '',
|
86 |
+
'description' => __( 'Leave blank if you don\'t want a description to show for the gateway.', 'woo-stripe-payment' ),
|
87 |
+
'desc_tip' => true,
|
88 |
+
),
|
89 |
+
'client_name' => array(
|
90 |
+
'type' => 'text',
|
91 |
+
'title' => __( 'Client Name', 'woo-stripe-payment' ),
|
92 |
+
'default' => get_bloginfo( 'name' ),
|
93 |
+
'description' => __( 'The name that appears on the ACH payment screen.', 'woo-stripe-payment' ),
|
94 |
+
'desc_tip' => true,
|
95 |
+
),
|
96 |
+
'method_format' => array(
|
97 |
+
'title' => __( 'ACH Display', 'woo-stripe-payment' ),
|
98 |
+
'type' => 'select',
|
99 |
+
'class' => 'wc-enhanced-select',
|
100 |
+
'options' => wp_list_pluck( $this->get_method_formats(), 'example' ),
|
101 |
+
'value' => '',
|
102 |
+
'default' => 'type_ending_in',
|
103 |
+
'desc_tip' => true,
|
104 |
+
'description' => __( 'This option allows you to customize how the credit card will display for your customers on orders, subscriptions, etc.' ),
|
105 |
+
),
|
106 |
+
'fee' => array(
|
107 |
+
'title' => __( 'ACH Fee', 'woo-stripe-payment' ),
|
108 |
+
'type' => 'ach_fee',
|
109 |
+
'class' => '',
|
110 |
+
'value' => '',
|
111 |
+
'default' => array(
|
112 |
+
'type' => 'none',
|
113 |
+
'taxable' => 'no',
|
114 |
+
'value' => '0',
|
115 |
+
),
|
116 |
+
'options' => array(
|
117 |
+
'none' => __( 'None', 'woo-stripe-payment' ),
|
118 |
+
'amount' => __( 'Amount', 'woo-stripe-payment' ),
|
119 |
+
'percent' => __( 'Percentage', 'woo-stripe-payment' ),
|
120 |
+
),
|
121 |
+
'desc_tip' => true,
|
122 |
+
'description' => __( 'You can assign a fee to the order for ACH payments. Amount is a static amount and percentage is a percentage of the cart amount.', 'woo-stripe-payment' ),
|
123 |
+
),
|
124 |
+
);
|
includes/gateways/settings/applepay-settings.php
CHANGED
@@ -1,112 +1,125 @@
|
|
1 |
-
<?php
|
2 |
-
return array(
|
3 |
-
|
4 |
-
|
5 |
-
),
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
),
|
12 |
-
'
|
13 |
-
|
14 |
-
|
15 |
-
'
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
),
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
'
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
),
|
68 |
-
'
|
69 |
-
|
70 |
-
|
71 |
-
'
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
),
|
102 |
-
'
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
)
|
112 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
return array(
|
3 |
+
'desc' => array(
|
4 |
+
'type' => 'description',
|
5 |
+
'description' => sprintf( '<div class="wc-stripe-register-domain"><button class="button button-secondary api-register-domain">%s</button></div><p>%s</p>', __( 'Register Domain', 'woo-stripe-payment' ), sprintf( __( 'This plugin attemps to add the domain association file to your server automatically when you click the Register Domain button. If that fails due to file permssions, you must add the <strong>%1$s.well-known/apple-developer-merchantid-domain-association%2$s</strong> file to your domain and register your domain within the Stripe Dashboard.', 'woo-stripe-payment' ), '<a href="https://stripe.com/files/apple-pay/apple-developer-merchantid-domain-association">', '</a>' ) ) .
|
6 |
+
'<p>' .
|
7 |
+
__( 'In order for Apple Pay to display, you must test with an iOS device and have a payment method saved in the Apple Wallet.', 'woo-stripe-payment' ) .
|
8 |
+
'</p>',
|
9 |
+
),
|
10 |
+
'enabled' => array(
|
11 |
+
'title' => __( 'Enabled', 'woo-stripe-payment' ),
|
12 |
+
'type' => 'checkbox',
|
13 |
+
'default' => 'no',
|
14 |
+
'value' => 'yes',
|
15 |
+
'desc_tip' => true,
|
16 |
+
'description' => __( 'If enabled, your site can accept Apple Pay payments through Stripe.', 'woo-stripe-payment' ),
|
17 |
+
),
|
18 |
+
'general_settings' => array(
|
19 |
+
'type' => 'title',
|
20 |
+
'title' => __( 'General Settings', 'woo-stripe-payment' ),
|
21 |
+
),
|
22 |
+
'title_text' => array(
|
23 |
+
'type' => 'text',
|
24 |
+
'title' => __( 'Title', 'woo-stripe-payment' ),
|
25 |
+
'default' => __( 'Apple Pay', 'woo-stripe-payment' ),
|
26 |
+
'desc_tip' => true,
|
27 |
+
'description' => __( 'Title of the Apple Pay gateway' ),
|
28 |
+
),
|
29 |
+
'description' => array(
|
30 |
+
'title' => __( 'Description', 'woo-stripe-payment' ),
|
31 |
+
'type' => 'text',
|
32 |
+
'default' => '',
|
33 |
+
'description' => __( 'Leave blank if you don\'t want a description to show for the gateway.', 'woo-stripe-payment' ),
|
34 |
+
'desc_tip' => true,
|
35 |
+
),
|
36 |
+
'method_format' => array(
|
37 |
+
'title' => __( 'Credit Card Display', 'woo-stripe-payment' ),
|
38 |
+
'type' => 'select',
|
39 |
+
'class' => 'wc-enhanced-select',
|
40 |
+
'options' => wp_list_pluck( $this->get_method_formats(), 'example' ),
|
41 |
+
'value' => '',
|
42 |
+
'default' => 'type_ending_in',
|
43 |
+
'desc_tip' => true,
|
44 |
+
'description' => __( 'This option allows you to customize how the credit card will display for your customers on orders, subscriptions, etc.' ),
|
45 |
+
),
|
46 |
+
'charge_type' => array(
|
47 |
+
'type' => 'select',
|
48 |
+
'title' => __( 'Charge Type', 'woo-stripe-payment' ),
|
49 |
+
'default' => 'capture',
|
50 |
+
'class' => 'wc-enhanced-select',
|
51 |
+
'options' => array(
|
52 |
+
'capture' => __( 'Capture', 'woo-stripe-payment' ),
|
53 |
+
'authorize' => __( 'Authorize', 'woo-stripe-payment' ),
|
54 |
+
),
|
55 |
+
'desc_tip' => true,
|
56 |
+
'description' => __( 'This option determines whether the customer\'s funds are captured immediately or authorized and can be captured at a later date.', 'woo-stripe-payment' ),
|
57 |
+
),
|
58 |
+
'payment_sections' => array(
|
59 |
+
'type' => 'multiselect',
|
60 |
+
'title' => __( 'Payment Sections', 'woo-stripe-payment' ),
|
61 |
+
'class' => 'wc-enhanced-select',
|
62 |
+
'options' => array(
|
63 |
+
'product' => __( 'Product Page', 'woo-stripe-payment' ),
|
64 |
+
'cart' => __( 'Cart Page', 'woo-stripe-payment' ),
|
65 |
+
'checkout_banner' => __( 'Top of Checkout', 'woo-stripe-payment' ),
|
66 |
+
),
|
67 |
+
'default' => array( 'product', 'cart' ),
|
68 |
+
'description' => $this->get_payment_section_description(),
|
69 |
+
),
|
70 |
+
'order_status' => array(
|
71 |
+
'type' => 'select',
|
72 |
+
'title' => __( 'Order Status', 'woo-stripe-payment' ),
|
73 |
+
'default' => 'default',
|
74 |
+
'class' => 'wc-enhanced-select',
|
75 |
+
'options' => array_merge( array( 'default' => __( 'Default', 'woo-stripe-payment' ) ), wc_get_order_statuses() ),
|
76 |
+
'tool_tip' => true,
|
77 |
+
'description' => __( 'This is the status of the order once payment is complete. If <b>Default</b> is selected, then WooCommerce will set the order status automatically based on internal logic which states if a product is virtual and downloadable then status is set to complete. Products that require shipping are set to Processing. Default is the recommended setting as it allows standard WooCommerce code to process the order status.', 'woo-stripe-payment' ),
|
78 |
+
),
|
79 |
+
'button_section' => array(
|
80 |
+
'type' => 'title',
|
81 |
+
'title' => __( 'Button Settings', 'woo-stripe-payment' ),
|
82 |
+
),
|
83 |
+
'button_style' => array(
|
84 |
+
'type' => 'select',
|
85 |
+
'title' => __( 'Button Design', 'woo-stripe-payment' ),
|
86 |
+
'class' => 'wc-enhanced-select',
|
87 |
+
'default' => 'apple-pay-button-black',
|
88 |
+
'options' => array(
|
89 |
+
'apple-pay-button-black' => __( 'Black Button', 'woo-stripe-payment' ),
|
90 |
+
'apple-pay-button-white-with-line' => __( 'White With Black Line', 'woo-stripe-payment' ),
|
91 |
+
'apple-pay-button-white' => __( 'White Button', 'woo-stripe-payment' ),
|
92 |
+
),
|
93 |
+
'description' => __( 'This is the style for all Apple Pay buttons presented on your store.', 'woo-stripe-payment' ),
|
94 |
+
),
|
95 |
+
'button_type_checkout' => array(
|
96 |
+
'title' => __( 'Checkout button type', 'woo-stripe-payment' ),
|
97 |
+
'type' => 'select',
|
98 |
+
'options' => array(
|
99 |
+
'plain' => __( 'Standard Button', 'woo-stripe-payment' ),
|
100 |
+
'buy' => __( 'Buy with Apple Pay', 'woo-stripe-payment' ),
|
101 |
+
),
|
102 |
+
// 'check-out' => __ ( 'Checkout with Apple Pay', 'woo-stripe-payment' )
|
103 |
+
'default' => 'plain',
|
104 |
+
),
|
105 |
+
'button_type_cart' => array(
|
106 |
+
'title' => __( 'Cart button type', 'woo-stripe-payment' ),
|
107 |
+
'type' => 'select',
|
108 |
+
'options' => array(
|
109 |
+
'plain' => __( 'Standard Button', 'woo-stripe-payment' ),
|
110 |
+
'buy' => __( 'Buy with Apple Pay', 'woo-stripe-payment' ),
|
111 |
+
),
|
112 |
+
// 'check-out' => __ ( 'Checkout with Apple Pay', 'woo-stripe-payment' )
|
113 |
+
'default' => 'plain',
|
114 |
+
),
|
115 |
+
'button_type_product' => array(
|
116 |
+
'title' => __( 'Product button type', 'woo-stripe-payment' ),
|
117 |
+
'type' => 'select',
|
118 |
+
'options' => array(
|
119 |
+
'plain' => __( 'Standard Button', 'woo-stripe-payment' ),
|
120 |
+
'buy' => __( 'Buy with Apple Pay', 'woo-stripe-payment' ),
|
121 |
+
),
|
122 |
+
// 'check-out' => __ ( 'Checkout with Apple Pay', 'woo-stripe-payment' )
|
123 |
+
'default' => 'buy',
|
124 |
+
),
|
125 |
+
);
|
includes/gateways/settings/cc-settings.php
CHANGED
@@ -1,139 +1,148 @@
|
|
1 |
-
<?php
|
2 |
-
return array(
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
'
|
10 |
-
|
11 |
-
|
12 |
-
'
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
'
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
'
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
'
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
),
|
46 |
-
'
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
'
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
'
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
'
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
),
|
74 |
-
'
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
'
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
'
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
),
|
117 |
-
'
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
),
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
return array(
|
3 |
+
'enabled' => array(
|
4 |
+
'title' => __( 'Enabled', 'woo-stripe-payment' ),
|
5 |
+
'type' => 'checkbox',
|
6 |
+
'default' => 'yes',
|
7 |
+
'value' => 'yes',
|
8 |
+
'desc_tip' => true,
|
9 |
+
'description' => __( 'If enabled, your site can accept credit card payments through Stripe.', 'woo-stripe-payment' ),
|
10 |
+
),
|
11 |
+
'desc1' => array(
|
12 |
+
'type' => 'description',
|
13 |
+
'description' => sprintf( __( '%1$sTest cards%2$s', 'woo-stripe-payment' ), '<a target="_blank" href="https://stripe.com/docs/testing#cards">', '</a>' ),
|
14 |
+
),
|
15 |
+
'general_settings' => array(
|
16 |
+
'type' => 'title',
|
17 |
+
'title' => __( 'General Settings', 'woo-stripe-payment' ),
|
18 |
+
),
|
19 |
+
'title_text' => array(
|
20 |
+
'type' => 'text',
|
21 |
+
'title' => __( 'Title', 'woo-stripe-payment' ),
|
22 |
+
'default' => __( 'Credit Cards', 'woo-stripe-payment' ),
|
23 |
+
'desc_tip' => true,
|
24 |
+
'description' => __( 'Title of the credit card gateway' ),
|
25 |
+
),
|
26 |
+
'description' => array(
|
27 |
+
'title' => __( 'Description', 'woo-stripe-payment' ),
|
28 |
+
'type' => 'text',
|
29 |
+
'default' => '',
|
30 |
+
'description' => __( 'Leave blank if you don\'t want a description to show for the gateway.', 'woo-stripe-payment' ),
|
31 |
+
'desc_tip' => true,
|
32 |
+
),
|
33 |
+
'method_format' => array(
|
34 |
+
'title' => __( 'Credit Card Display', 'woo-stripe-payment' ),
|
35 |
+
'type' => 'select',
|
36 |
+
'class' => 'wc-enhanced-select',
|
37 |
+
'options' => wp_list_pluck( $this->get_method_formats(), 'example' ),
|
38 |
+
'value' => '',
|
39 |
+
'default' => 'type_ending_in',
|
40 |
+
'desc_tip' => true,
|
41 |
+
'description' => __( 'This option allows you to customize how the credit card will display for your customers on orders, subscriptions, etc.' ),
|
42 |
+
),
|
43 |
+
'charge_type' => array(
|
44 |
+
'type' => 'select',
|
45 |
+
'title' => __( 'Charge Type', 'woo-stripe-payment' ),
|
46 |
+
'default' => 'capture',
|
47 |
+
'class' => 'wc-enhanced-select',
|
48 |
+
'options' => array(
|
49 |
+
'capture' => __( 'Capture', 'woo-stripe-payment' ),
|
50 |
+
'authorize' => __( 'Authorize', 'woo-stripe-payment' ),
|
51 |
+
),
|
52 |
+
'desc_tip' => true,
|
53 |
+
'description' => __( 'This option determines whether the customer\'s funds are captured immediately or authorized and can be captured at a later date.', 'woo-stripe-payment' ),
|
54 |
+
),
|
55 |
+
'order_status' => array(
|
56 |
+
'type' => 'select',
|
57 |
+
'title' => __( 'Order Status', 'woo-stripe-payment' ),
|
58 |
+
'default' => 'default',
|
59 |
+
'class' => 'wc-enhanced-select',
|
60 |
+
'options' => array_merge( array( 'default' => __( 'Default', 'woo-stripe-payment' ) ), wc_get_order_statuses() ),
|
61 |
+
'tool_tip' => true,
|
62 |
+
'description' => __( 'This is the status of the order once payment is complete. If <b>Default</b> is selected, then WooCommerce will set the order status automatically based on internal logic which states if a product is virtual and downloadable then status is set to complete. Products that require shipping are set to Processing. Default is the recommended setting as it allows standard WooCommerce code to process the order status.', 'woo-stripe-payment' ),
|
63 |
+
),
|
64 |
+
'save_card_enabled' => array(
|
65 |
+
'type' => 'checkbox',
|
66 |
+
'value' => 'yes',
|
67 |
+
'default' => 'yes',
|
68 |
+
'title' => __( 'Allow Credit Card Save', 'woo-stripe-payment' ),
|
69 |
+
'desc_tip' => false,
|
70 |
+
'description' => __( 'If enabled, a checkbox will be available on the checkout page allowing your customers to save their credit card. The payment methods are stored securely in Stripe\'s vault and never touch your server. Note: if the cart contains a subscription, there will be no checkbox because the payment method will be saved automatically. There will also be no checkbox for guest checkout as a user must be logged in to save a payment method.', 'woo-stripe-payment' ),
|
71 |
+
),
|
72 |
+
'force_3d_secure' => array(
|
73 |
+
'title' => __( 'Force 3D Secure', 'woo-stripe-payment' ),
|
74 |
+
'type' => 'checkbox',
|
75 |
+
'value' => 'yes',
|
76 |
+
'default' => 'no',
|
77 |
+
'desc_tip' => false,
|
78 |
+
'description' => sprintf( __( 'Stripe internally determines when 3D secure should be presented based on their SCA engine. If <strong>Force 3D Secure</strong> is enabled, 3D Secure will be forced for ALL credit card transactions. In test mode 3D secure only shows for %1$s3DS Test Cards%2$s regardless of this setting.', 'woo-stripe-payment' ), '<a target="_blank" href="https://stripe.com/docs/testing#regulatory-cards">', '</a>' ),
|
79 |
+
),
|
80 |
+
'generic_error' => array(
|
81 |
+
'title' => __( 'Generic Errors', 'woo-stripe-payment' ),
|
82 |
+
'type' => 'checkbox',
|
83 |
+
'default' => 'no',
|
84 |
+
'value' => 'yes',
|
85 |
+
'desc_tip' => true,
|
86 |
+
'description' => __( 'If enabled, credit card errors will be generic when presented to the customer. Merchants may prefer to not provide details on why a card was not accepted for security purposes.', 'woo-stripe-payment' ),
|
87 |
+
),
|
88 |
+
'cards' => array(
|
89 |
+
'type' => 'multiselect',
|
90 |
+
'title' => __( 'Accepted Payment Methods', 'wwoo-stripe' ),
|
91 |
+
'class' => 'wc-enhanced-select stripe-accepted-cards',
|
92 |
+
'default' => array( 'amex', 'discover', 'visa', 'mastercard' ),
|
93 |
+
'options' => array(
|
94 |
+
'visa' => __( 'Visa', 'wwoo-stripe' ),
|
95 |
+
'amex' => __( 'Amex', 'wwoo-stripe' ),
|
96 |
+
'discover' => __( 'Discover', 'wwoo-stripe' ),
|
97 |
+
'mastercard' => __( 'MasterCard', 'wwoo-stripe' ),
|
98 |
+
'jcb' => __( 'JCB', 'wwoo-stripe' ),
|
99 |
+
'maestro' => __( 'Maestro', 'wwoo-stripe' ),
|
100 |
+
'diners' => __( 'Diners Club', 'wwoo-stripe' ),
|
101 |
+
'china_union_pay' => __( 'Union Pay', 'wwoo-stripe' ),
|
102 |
+
),
|
103 |
+
'desc_tip' => true,
|
104 |
+
'description' => __( 'The selected icons will show customers which credit card brands you accept.', 'wwoo-stripe' ),
|
105 |
+
),
|
106 |
+
'form_title' => array(
|
107 |
+
'type' => 'title',
|
108 |
+
'title' => __( 'Credit Card Form', 'woo-stripe-payment' ),
|
109 |
+
),
|
110 |
+
'form_type' => array(
|
111 |
+
'title' => __( 'Card Form', 'woo-stripe-payment' ),
|
112 |
+
'type' => 'select',
|
113 |
+
'options' => array(
|
114 |
+
'inline' => __( 'Stripe form', 'woo-stripe-payment' ),
|
115 |
+
'custom' => __( 'Custom form', 'woo-stripe-payment' ),
|
116 |
+
),
|
117 |
+
'default' => 'inline',
|
118 |
+
'description' => __( 'The Stripe form option displays a CC form rendered by Stripe. It works well with most themes. The custom card forms are offered if you want more options on the CC form design.', 'woo-stripe-payment' ),
|
119 |
+
),
|
120 |
+
'custom_form' => array(
|
121 |
+
'title' => __( 'Custom Form', 'woo-stripe-payment' ),
|
122 |
+
'type' => 'select',
|
123 |
+
'options' => wp_list_pluck( wc_stripe_get_custom_forms(), 'label' ),
|
124 |
+
'default' => 'bootstrap',
|
125 |
+
'description' => __( 'The design of the credit card form.', 'woo-stripe-payment' ),
|
126 |
+
'desc_tip' => true,
|
127 |
+
'custom_attributes' => array( 'data-show-if' => array( 'form_type' => 'custom' ) ),
|
128 |
+
),
|
129 |
+
'postal_enabled' => array(
|
130 |
+
'title' => __( 'Postal Code', 'woo-stripe-payment' ),
|
131 |
+
'type' => 'checkbox',
|
132 |
+
'default' => 'no',
|
133 |
+
'description' => __( 'If enabled, the CC form will show the postal code on the checkout page. If disabled, the billing field\'s postal code will be used. The postal code will show on the Add Payment Method page for security reasons.', 'woo-stripe-payment' ),
|
134 |
+
'desc_tip' => true,
|
135 |
+
'custom_attributes' => array( 'data-show-if' => array( 'form_type' => 'custom' ) ),
|
136 |
+
),
|
137 |
+
/* 'cvv_enabled' => array(
|
138 |
+
'title' => __ ( 'CVV Code', 'woo-stripe-payment' ),
|
139 |
+
'type' => 'checkbox', 'default' => 'yes',
|
140 |
+
'description' => __ ( 'If enabled, the CC form will show the cvv field.', 'woo-stripe-payment' ),
|
141 |
+
'desc_tip' => true,
|
142 |
+
'custom_attributes' => array(
|
143 |
+
'data-show-if' => array(
|
144 |
+
'form_type' => 'custom'
|
145 |
+
)
|
146 |
+
)
|
147 |
+
) */
|
148 |
+
);
|
includes/gateways/settings/googlepay-settings.php
CHANGED
@@ -1,126 +1,153 @@
|
|
1 |
-
<?php
|
2 |
-
return array(
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
'
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
'
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
),
|
35 |
-
'
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
'
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
),
|
50 |
-
'
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
'
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
'
|
99 |
-
|
100 |
-
|
101 |
-
'
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
'
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
return array(
|
3 |
+
'desc1' => array(
|
4 |
+
'type' => 'description',
|
5 |
+
'description' => '<p><a target="_blank" href="https://pay.google.com/business/console">' . __( 'GPay Business Console', 'woo-stripe-payment' ) .
|
6 |
+
'</a></p>' .
|
7 |
+
__( 'When test mode is enabled, Google Pay will work without a merchant ID, allowing you to capture the necessary screenshots the Google API team needs to approve your integration request.', 'woo-stripe-payment' ),
|
8 |
+
),
|
9 |
+
'desc2' => array(
|
10 |
+
'type' => 'description',
|
11 |
+
'description' => sprintf(
|
12 |
+
'<p>%s</p>',
|
13 |
+
sprintf(
|
14 |
+
__( 'If you don\'t want to request a Google Merchant ID, you can use the %1$sPayment Request Gateway%2$s which has a Google Pay integration through Stripe via the Chrome browser.', 'woo-stripe-payment' ),
|
15 |
+
'<a target="_blank" href="' .
|
16 |
+
admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=stripe_payment_request' ) . '">',
|
17 |
+
'</a>'
|
18 |
+
)
|
19 |
+
),
|
20 |
+
),
|
21 |
+
'enabled' => array(
|
22 |
+
'title' => __( 'Enabled', 'woo-stripe-payment' ),
|
23 |
+
'type' => 'checkbox',
|
24 |
+
'default' => 'no',
|
25 |
+
'value' => 'yes',
|
26 |
+
'desc_tip' => true,
|
27 |
+
'description' => __( 'If enabled, your site can accept Google Pay payments through Stripe.', 'woo-stripe-payment' ),
|
28 |
+
),
|
29 |
+
'general_settings' => array(
|
30 |
+
'type' => 'title',
|
31 |
+
'title' => __( 'General Settings', 'woo-stripe-payment' ),
|
32 |
+
),
|
33 |
+
'dynamic_price' => array(
|
34 |
+
'title' => __( 'Dynamic Price', 'woo-stripe-payment' ),
|
35 |
+
'type' => 'checkbox',
|
36 |
+
'default' => 'yes',
|
37 |
+
'desc_tip' => true,
|
38 |
+
'description' => __( 'If enabled, the Google Payment sheet will show the order line items. You must have Google whitelist you for callback intents.', 'woo-stripe-payment' ),
|
39 |
+
),
|
40 |
+
'merchant_id' => array(
|
41 |
+
'type' => 'text',
|
42 |
+
'title' => __( 'Merchant ID', 'woo-stripe-payment' ),
|
43 |
+
'default' => '',
|
44 |
+
'description' => __( 'Your Google Merchant ID is given to you by the Google API team once you register for Google Pay. While testing in TEST mode you can leave this value blank and Google Pay will work.', 'woo-stripe-payment' ),
|
45 |
+
),
|
46 |
+
'title_text' => array(
|
47 |
+
'type' => 'text',
|
48 |
+
'title' => __( 'Title', 'woo-stripe-payment' ),
|
49 |
+
'default' => __( 'Google Pay', 'woo-stripe-payment' ),
|
50 |
+
'desc_tip' => true,
|
51 |
+
'description' => __( 'Title of the credit card gateway' ),
|
52 |
+
),
|
53 |
+
'description' => array(
|
54 |
+
'title' => __( 'Description', 'woo-stripe-payment' ),
|
55 |
+
'type' => 'text',
|
56 |
+
'default' => '',
|
57 |
+
'description' => __( 'Leave blank if you don\'t want a description to show for the gateway.', 'woo-stripe-payment' ),
|
58 |
+
'desc_tip' => true,
|
59 |
+
),
|
60 |
+
'method_format' => array(
|
61 |
+
'title' => __( 'Credit Card Display', 'woo-stripe-payment' ),
|
62 |
+
'type' => 'select',
|
63 |
+
'class' => 'wc-enhanced-select',
|
64 |
+
'options' => wp_list_pluck( $this->get_method_formats(), 'example' ),
|
65 |
+
'value' => '',
|
66 |
+
'default' => 'type_ending_in',
|
67 |
+
'desc_tip' => true,
|
68 |
+
'description' => __( 'This option allows you to customize how the credit card will display for your customers on orders, subscriptions, etc.' ),
|
69 |
+
),
|
70 |
+
'charge_type' => array(
|
71 |
+
'type' => 'select',
|
72 |
+
'title' => __( 'Charge Type', 'woo-stripe-payment' ),
|
73 |
+
'default' => 'capture',
|
74 |
+
'class' => 'wc-enhanced-select',
|
75 |
+
'options' => array(
|
76 |
+
'capture' => __( 'Capture', 'woo-stripe-payment' ),
|
77 |
+
'authorize' => __( 'Authorize', 'woo-stripe-payment' ),
|
78 |
+
),
|
79 |
+
'desc_tip' => true,
|
80 |
+
'description' => __( 'This option determines whether the customer\'s funds are capture immediately or authorized and can be captured at a later date.', 'woo-stripe-payment' ),
|
81 |
+
),
|
82 |
+
'payment_sections' => array(
|
83 |
+
'type' => 'multiselect',
|
84 |
+
'title' => __( 'Payment Sections', 'woo-stripe-payment' ),
|
85 |
+
'class' => 'wc-enhanced-select',
|
86 |
+
'options' => array(
|
87 |
+
'product' => __( 'Product Page', 'woo-stripe-payment' ),
|
88 |
+
'cart' => __( 'Cart Page', 'woo-stripe-payment' ),
|
89 |
+
'checkout_banner' => __( 'Top of Checkout', 'woo-stripe-payment' ),
|
90 |
+
),
|
91 |
+
'default' => array( 'product', 'cart' ),
|
92 |
+
'description' => $this->get_payment_section_description(),
|
93 |
+
),
|
94 |
+
'order_status' => array(
|
95 |
+
'type' => 'select',
|
96 |
+
'title' => __( 'Order Status', 'woo-stripe-payment' ),
|
97 |
+
'default' => 'default',
|
98 |
+
'class' => 'wc-enhanced-select',
|
99 |
+
'options' => array_merge( array( 'default' => __( 'Default', 'woo-stripe-payment' ) ), wc_get_order_statuses() ),
|
100 |
+
'tool_tip' => true,
|
101 |
+
'description' => __( 'This is the status of the order once payment is complete. If <b>Default</b> is selected, then WooCommerce will set the order status automatically based on internal logic which states if a product is virtual and downloadable then status is set to complete. Products that require shipping are set to Processing. Default is the recommended setting as it allows standard WooCommerce code to process the order status.', 'woo-stripe-payment' ),
|
102 |
+
),
|
103 |
+
'merchant_name' => array(
|
104 |
+
'type' => 'text',
|
105 |
+
'title' => __( 'Merchant Name', 'woo-stripe-payment' ),
|
106 |
+
'default' => get_bloginfo( 'name' ),
|
107 |
+
'description' => __( 'The name of your business as it appears on the Google Pay payment sheet.', 'woo-stripe-payment' ),
|
108 |
+
'desc_tip' => true,
|
109 |
+
),
|
110 |
+
'icon' => array(
|
111 |
+
'title' => __( 'Icon', 'woo-stripe-payment' ),
|
112 |
+
'type' => 'select',
|
113 |
+
'options' => array(
|
114 |
+
'googlepay_outline' => __( 'With Outline', 'woo-stripe-payment' ),
|
115 |
+
'googlepay_standard' => __( 'Standard', 'woo-stripe-payment' ),
|
116 |
+
),
|
117 |
+
'default' => 'googlepay_outline',
|
118 |
+
'desc_tip' => true,
|
119 |
+
'description' => __( 'This is the icon style that appears next to the gateway on the checkout page. Google\'s API team typically requires the With Outline option on the checkout page for branding purposes.', 'woo-stripe-payment' ),
|
120 |
+
),
|
121 |
+
'button_section' => array(
|
122 |
+
'type' => 'title',
|
123 |
+
'title' => __( 'Button Options', 'woo-stripe-payment' ),
|
124 |
+
),
|
125 |
+
'button_color' => array(
|
126 |
+
'title' => __( 'Button Color', 'woo-stripe-payment' ),
|
127 |
+
'type' => 'select',
|
128 |
+
'class' => 'gpay-button-option button-color',
|
129 |
+
'options' => array(
|
130 |
+
'black' => __( 'Black', 'woo-stripe-payment' ),
|
131 |
+
'white' => __( 'White', 'woo-stripe-payment' ),
|
132 |
+
),
|
133 |
+
'default' => 'black',
|
134 |
+
'description' => __( 'The button color of the GPay button.', 'woo-stripe-payment' ),
|
135 |
+
),
|
136 |
+
'button_style' => array(
|
137 |
+
'title' => __( 'Button Style', 'woo-stripe-payment' ),
|
138 |
+
'type' => 'select',
|
139 |
+
'class' => 'gpay-button-option button-style',
|
140 |
+
'options' => array(
|
141 |
+
'long' => __( 'Long', 'woo-stripe-payment' ),
|
142 |
+
'short' => __( 'Short', 'woo-stripe-payment' ),
|
143 |
+
),
|
144 |
+
'default' => 'long',
|
145 |
+
'description' => __( 'The button style of the GPay button.', 'woo-stripe-payment' ),
|
146 |
+
),
|
147 |
+
'button_render' => array(
|
148 |
+
'type' => 'button_demo',
|
149 |
+
'title' => __( 'Button Design', 'woo-stripe-payment' ),
|
150 |
+
'id' => 'gpay-button',
|
151 |
+
'description' => __( 'If you can\'t see the Google Pay button, try switching to a Chrome browser.', 'woo-stripe-payment' ),
|
152 |
+
),
|
153 |
+
);
|
includes/gateways/settings/payment-request-settings.php
CHANGED
@@ -1,95 +1,115 @@
|
|
1 |
-
<?php
|
2 |
-
return array(
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
),
|
13 |
-
'
|
14 |
-
|
15 |
-
|
16 |
-
'
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
),
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
'
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
),
|
69 |
-
'
|
70 |
-
|
71 |
-
|
72 |
-
'
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
'
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
return array(
|
3 |
+
'desc' => array(
|
4 |
+
'type' => 'description',
|
5 |
+
'description' => __(
|
6 |
+
'The PaymentRequest gateway uses your customer\'s browser to render payment options like Google Pay and Microsoft Pay. You can either use the Google Pay gateway for example, or this gateway.
|
7 |
+
The difference is this gateway uses Stripe\'s PaymentRequest Button rather than render a Google Pay specific button.',
|
8 |
+
'woo-stripe-payment'
|
9 |
+
),
|
10 |
+
),
|
11 |
+
'enabled' => array(
|
12 |
+
'title' => __( 'Enabled', 'woo-stripe-payment' ),
|
13 |
+
'type' => 'checkbox',
|
14 |
+
'default' => 'no',
|
15 |
+
'value' => 'yes',
|
16 |
+
'desc_tip' => true,
|
17 |
+
'description' => __( 'If enabled, your site can accept Apple Pay payments through Stripe.', 'woo-stripe-payment' ),
|
18 |
+
),
|
19 |
+
'general_settings' => array(
|
20 |
+
'type' => 'title',
|
21 |
+
'title' => __( 'General Settings', 'woo-stripe-payment' ),
|
22 |
+
),
|
23 |
+
'title_text' => array(
|
24 |
+
'type' => 'text',
|
25 |
+
'title' => __( 'Title', 'woo-stripe-payment' ),
|
26 |
+
'default' => __( 'Browser Payments', 'woo-stripe-payment' ),
|
27 |
+
'desc_tip' => true,
|
28 |
+
'description' => __( 'Title of the credit card gateway' ),
|
29 |
+
),
|
30 |
+
'description' => array(
|
31 |
+
'title' => __( 'Description', 'woo-stripe-payment' ),
|
32 |
+
'type' => 'text',
|
33 |
+
'default' => '',
|
34 |
+
'description' => __( 'Leave blank if you don\'t want a description to show for the gateway.', 'woo-stripe-payment' ),
|
35 |
+
'desc_tip' => true,
|
36 |
+
),
|
37 |
+
'method_format' => array(
|
38 |
+
'title' => __( 'Credit Card Display', 'woo-stripe-payment' ),
|
39 |
+
'type' => 'select',
|
40 |
+
'class' => 'wc-enhanced-select',
|
41 |
+
'options' => wp_list_pluck( $this->get_method_formats(), 'example' ),
|
42 |
+
'value' => '',
|
43 |
+
'default' => 'type_ending_in',
|
44 |
+
'desc_tip' => true,
|
45 |
+
'description' => __( 'This option allows you to customize how the credit card will display for your customers on orders, subscriptions, etc.' ),
|
46 |
+
),
|
47 |
+
'charge_type' => array(
|
48 |
+
'type' => 'select',
|
49 |
+
'title' => __( 'Charge Type', 'woo-stripe-payment' ),
|
50 |
+
'default' => 'capture',
|
51 |
+
'class' => 'wc-enhanced-select',
|
52 |
+
'options' => array(
|
53 |
+
'capture' => __( 'Capture', 'woo-stripe-payment' ),
|
54 |
+
'authorize' => __( 'Authorize', 'woo-stripe-payment' ),
|
55 |
+
),
|
56 |
+
'desc_tip' => true,
|
57 |
+
'description' => __( 'This option determines whether the customer\'s funds are captured immediately or authorized and can be captured at a later date.', 'woo-stripe-payment' ),
|
58 |
+
),
|
59 |
+
'payment_sections' => array(
|
60 |
+
'type' => 'multiselect',
|
61 |
+
'title' => __( 'Payment Sections', 'woo-stripe-payment' ),
|
62 |
+
'class' => 'wc-enhanced-select',
|
63 |
+
'options' => array(
|
64 |
+
'product' => __( 'Product Page', 'woo-stripe-payment' ),
|
65 |
+
'cart' => __( 'Cart Page', 'woo-stripe-payment' ),
|
66 |
+
'checkout_banner' => __( 'Top of Checkout', 'woo-stripe-payment' ),
|
67 |
+
),
|
68 |
+
'default' => array( 'product', 'cart' ),
|
69 |
+
'description' => $this->get_payment_section_description(),
|
70 |
+
),
|
71 |
+
'order_status' => array(
|
72 |
+
'type' => 'select',
|
73 |
+
'title' => __( 'Order Status', 'woo-stripe-payment' ),
|
74 |
+
'default' => 'default',
|
75 |
+
'class' => 'wc-enhanced-select',
|
76 |
+
'options' => array_merge( array( 'default' => __( 'Default', 'woo-stripe-payment' ) ), wc_get_order_statuses() ),
|
77 |
+
'tool_tip' => true,
|
78 |
+
'description' => __( 'This is the status of the order once payment is complete. If <b>Default</b> is selected, then WooCommerce will set the order status automatically based on internal logic which states if a product is virtual and downloadable then status is set to complete. Products that require shipping are set to Processing. Default is the recommended setting as it allows standard WooCommerce code to process the order status.', 'woo-stripe-payment' ),
|
79 |
+
),
|
80 |
+
'button_section' => array(
|
81 |
+
'type' => 'title',
|
82 |
+
'title' => __( 'Button Settings', 'woo-stripe-payment' ),
|
83 |
+
),
|
84 |
+
'button_type' => array(
|
85 |
+
'type' => 'select',
|
86 |
+
'title' => __( 'Type', 'woo-stripe-payment' ),
|
87 |
+
'options' => array(
|
88 |
+
'default' => __( 'default', 'woo-stripe-payment' ),
|
89 |
+
// 'donate' => __ ( 'donate', 'woo-stripe-payment' ),
|
90 |
+
'buy' => __( 'buy', 'woo-stripe-payment' ),
|
91 |
+
),
|
92 |
+
'default' => 'buy',
|
93 |
+
'desc_tip' => true,
|
94 |
+
'description' => __( 'This defines the type of button that will display.', 'woo-stripe-payment' ),
|
95 |
+
),
|
96 |
+
'button_theme' => array(
|
97 |
+
'type' => 'select',
|
98 |
+
'title' => __( 'Theme', 'woo-stripe-payment' ),
|
99 |
+
'options' => array(
|
100 |
+
'dark' => __( 'dark', 'woo-stripe-payment' ),
|
101 |
+
'light' => __( 'light', 'woo-stripe-payment' ),
|
102 |
+
'light-outline' => __( 'light-outline', 'woo-stripe-payment' ),
|
103 |
+
),
|
104 |
+
'default' => 'dark',
|
105 |
+
'desc_tip' => true,
|
106 |
+
'description' => __( 'This defines the color scheme for the button.', 'woo-stripe-payment' ),
|
107 |
+
),
|
108 |
+
'button_height' => array(
|
109 |
+
'type' => 'text',
|
110 |
+
'title' => __( 'Height', 'woo-stripe-payment' ),
|
111 |
+
'default' => '40',
|
112 |
+
'desc_tip' => true,
|
113 |
+
'description' => __( 'The height of the button. Max height is 64', 'woo-stripe-payment' ),
|
114 |
+
),
|
115 |
+
);
|
includes/tokens/class-wc-payment-token-stripe-ach.php
CHANGED
@@ -1,83 +1,85 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
/**
|
5 |
-
*
|
6 |
-
* @since 3.0.5
|
7 |
-
* @package Stripe/Tokens
|
8 |
-
* @author Payment Plugins
|
9 |
-
*
|
10 |
-
*/
|
11 |
-
class WC_Payment_Token_Stripe_ACH extends WC_Payment_Token_Stripe {
|
12 |
-
|
13 |
-
use WC_Payment_Token_Source_Trait;
|
14 |
-
|
15 |
-
protected $type = 'Stripe_ACH';
|
16 |
-
|
17 |
-
protected $stripe_payment_type = 'source';
|
18 |
-
|
19 |
-
protected $stripe_data = array(
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
*
|
27 |
-
* @
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
$bank = $details;
|
34 |
-
}
|
35 |
-
|
36 |
-
|
37 |
-
$this->
|
38 |
-
$this->
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
'
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
|
|
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
/**
|
5 |
+
*
|
6 |
+
* @since 3.0.5
|
7 |
+
* @package Stripe/Tokens
|
8 |
+
* @author Payment Plugins
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
class WC_Payment_Token_Stripe_ACH extends WC_Payment_Token_Stripe {
|
12 |
+
|
13 |
+
use WC_Payment_Token_Source_Trait;
|
14 |
+
|
15 |
+
protected $type = 'Stripe_ACH';
|
16 |
+
|
17 |
+
protected $stripe_payment_type = 'source';
|
18 |
+
|
19 |
+
protected $stripe_data = array(
|
20 |
+
'bank_name' => '',
|
21 |
+
'routing_number' => '',
|
22 |
+
'last4' => '',
|
23 |
+
);
|
24 |
+
|
25 |
+
/**
|
26 |
+
*
|
27 |
+
* {@inheritDoc}
|
28 |
+
*
|
29 |
+
* @see WC_Payment_Token_Stripe::details_to_props()
|
30 |
+
*/
|
31 |
+
public function details_to_props( $details ) {
|
32 |
+
if ( isset( $details['ach_debit'] ) ) {
|
33 |
+
$bank = $details['ach_debit'];
|
34 |
+
} elseif ( $details instanceof \Stripe\BankAccount ) {
|
35 |
+
$bank = $details;
|
36 |
+
}
|
37 |
+
$this->set_brand( $bank['bank_name'] );
|
38 |
+
$this->set_bank_name( $bank['bank_name'] );
|
39 |
+
$this->set_last4( $bank['last4'] );
|
40 |
+
$this->set_routing_number( $bank['routing_number'] );
|
41 |
+
}
|
42 |
+
|
43 |
+
public function get_bank_name( $context = 'view' ) {
|
44 |
+
return $this->get_prop( 'bank_name', $context );
|
45 |
+
}
|
46 |
+
|
47 |
+
public function get_routing_number( $context = 'view' ) {
|
48 |
+
return $this->get_prop( 'routing_number', $context );
|
49 |
+
}
|
50 |
+
|
51 |
+
public function get_last4( $context = 'view' ) {
|
52 |
+
return $this->get_prop( 'last4', $context );
|
53 |
+
}
|
54 |
+
|
55 |
+
public function set_bank_name( $value ) {
|
56 |
+
$this->set_prop( 'bank_name', $value );
|
57 |
+
}
|
58 |
+
|
59 |
+
public function set_routing_number( $value ) {
|
60 |
+
$this->set_prop( 'routing_number', $value );
|
61 |
+
}
|
62 |
+
|
63 |
+
public function set_last4( $value ) {
|
64 |
+
$this->set_prop( 'last4', $value );
|
65 |
+
}
|
66 |
+
|
67 |
+
public function get_formats() {
|
68 |
+
return array(
|
69 |
+
'type_ending_in' => array(
|
70 |
+
'label' => __( 'Type Ending In', 'woo-stripe-payment' ),
|
71 |
+
'example' => 'Chase ending in 3434',
|
72 |
+
'format' => __( '{bank_name} ending in {last4}', 'woo-stripe-payment' ),
|
73 |
+
),
|
74 |
+
'name_masked_last4' => array(
|
75 |
+
'label' => __( 'Type Ending In', 'woo-stripe-payment' ),
|
76 |
+
'example' => 'Chase **** 3434',
|
77 |
+
'format' => __( '{bank_name} **** {last4}', 'woo-stripe-payment' ),
|
78 |
+
),
|
79 |
+
);
|
80 |
+
}
|
81 |
+
|
82 |
+
public function get_html_classes() {
|
83 |
+
return 'wc-stripe-ach';
|
84 |
+
}
|
85 |
+
}
|
includes/tokens/class-wc-payment-token-stripe-applepay.php
CHANGED
@@ -1,16 +1,17 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
if (! class_exists
|
5 |
-
return;
|
6 |
-
}
|
7 |
-
|
8 |
-
|
9 |
-
*
|
10 |
-
* @
|
11 |
-
*
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
if ( ! class_exists( 'WC_Payment_Token_Stripe_CC' ) ) {
|
5 |
+
return;
|
6 |
+
}
|
7 |
+
|
8 |
+
/**
|
9 |
+
*
|
10 |
+
* @author PaymentPlugins
|
11 |
+
* @package Stripe/Tokens
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
class WC_Payment_Token_Stripe_ApplePay extends WC_Payment_Token_Stripe_CC {
|
15 |
+
|
16 |
+
protected $type = 'Stripe_ApplePay';
|
17 |
+
}
|
includes/tokens/class-wc-payment-token-stripe-cc.php
CHANGED
@@ -1,122 +1,126 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
if (! class_exists
|
5 |
-
return;
|
6 |
-
}
|
7 |
-
|
8 |
-
|
9 |
-
*
|
10 |
-
*
|
11 |
-
* @
|
12 |
-
*
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
$this->
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
}
|
46 |
-
|
47 |
-
public function
|
48 |
-
return $this->get_prop
|
49 |
-
}
|
50 |
-
|
51 |
-
public function
|
52 |
-
$this->
|
53 |
-
}
|
54 |
-
|
55 |
-
public function
|
56 |
-
$this->set_prop
|
57 |
-
}
|
58 |
-
|
59 |
-
public function
|
60 |
-
|
61 |
-
}
|
62 |
-
|
63 |
-
public function
|
64 |
-
$this->
|
65 |
-
}
|
66 |
-
|
67 |
-
public function
|
68 |
-
|
69 |
-
}
|
70 |
-
|
71 |
-
public function
|
72 |
-
$this->
|
73 |
-
}
|
74 |
-
|
75 |
-
public function
|
76 |
-
|
77 |
-
}
|
78 |
-
|
79 |
-
public function
|
80 |
-
return $this->
|
81 |
-
}
|
82 |
-
|
83 |
-
public function
|
84 |
-
return
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
'
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
'
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
'
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
'
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
'
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
'
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
}
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
if ( ! class_exists( 'WC_Payment_Token_Stripe' ) ) {
|
5 |
+
return;
|
6 |
+
}
|
7 |
+
|
8 |
+
/**
|
9 |
+
* @sin 3.0.0
|
10 |
+
*
|
11 |
+
* @author PaymentPlugins
|
12 |
+
* @package Stripe/Tokens
|
13 |
+
*
|
14 |
+
*/
|
15 |
+
class WC_Payment_Token_Stripe_CC extends WC_Payment_Token_Stripe {
|
16 |
+
|
17 |
+
use WC_Payment_Token_Payment_Method_Trait;
|
18 |
+
|
19 |
+
protected $has_expiration = true;
|
20 |
+
|
21 |
+
protected $type = 'Stripe_CC';
|
22 |
+
|
23 |
+
protected $stripe_payment_type = 'payment_method';
|
24 |
+
|
25 |
+
protected $stripe_data = array(
|
26 |
+
'brand' => '',
|
27 |
+
'exp_month' => '',
|
28 |
+
'exp_year' => '',
|
29 |
+
'last4' => '',
|
30 |
+
'masked_number' => '',
|
31 |
+
);
|
32 |
+
|
33 |
+
public function details_to_props( $details ) {
|
34 |
+
if ( isset( $details['card'] ) ) {
|
35 |
+
$card = $details['card'];
|
36 |
+
}
|
37 |
+
if ( $details instanceof \Stripe\Card ) {
|
38 |
+
$card = $details;
|
39 |
+
}
|
40 |
+
$this->set_brand( $card['brand'] );
|
41 |
+
$this->set_last4( $card['last4'] );
|
42 |
+
$this->set_exp_month( $card['exp_month'] );
|
43 |
+
$this->set_exp_year( $card['exp_year'] );
|
44 |
+
$this->set_masked_number( sprintf( '********%s', $card['last4'] ) );
|
45 |
+
}
|
46 |
+
|
47 |
+
public function get_last4( $context = 'view' ) {
|
48 |
+
return $this->get_prop( 'last4', $context );
|
49 |
+
}
|
50 |
+
|
51 |
+
public function get_masked_number( $context = 'view' ) {
|
52 |
+
return $this->get_prop( 'masked_number', $context );
|
53 |
+
}
|
54 |
+
|
55 |
+
public function set_last4( $last4 ) {
|
56 |
+
$this->set_prop( 'last4', $last4 );
|
57 |
+
}
|
58 |
+
|
59 |
+
public function set_masked_number( $value ) {
|
60 |
+
$this->set_prop( 'masked_number', $value );
|
61 |
+
}
|
62 |
+
|
63 |
+
public function get_exp_year( $context = 'view' ) {
|
64 |
+
return $this->get_prop( 'exp_year', $context );
|
65 |
+
}
|
66 |
+
|
67 |
+
public function set_exp_year( $year ) {
|
68 |
+
$this->set_prop( 'exp_year', $year );
|
69 |
+
}
|
70 |
+
|
71 |
+
public function get_exp_month( $context = 'view' ) {
|
72 |
+
return $this->get_prop( 'exp_month', $context );
|
73 |
+
}
|
74 |
+
|
75 |
+
public function set_exp_month( $month ) {
|
76 |
+
$this->set_prop( 'exp_month', str_pad( $month, 2, '0', STR_PAD_LEFT ) );
|
77 |
+
}
|
78 |
+
|
79 |
+
public function get_html_classes() {
|
80 |
+
return sprintf( '%s', str_replace( ' ', '', strtolower( $this->get_prop( 'brand' ) ) ) );
|
81 |
+
}
|
82 |
+
|
83 |
+
public function get_card_type( $context = 'view' ) {
|
84 |
+
return $this->get_brand( $context );
|
85 |
+
}
|
86 |
+
|
87 |
+
public function get_formats() {
|
88 |
+
return array(
|
89 |
+
'type_ending_in' => array(
|
90 |
+
'label' => __( 'Type Ending In', 'woo-stripe-payment' ),
|
91 |
+
'example' => 'Visa ending in 1111',
|
92 |
+
'format' => __( '{brand} ending in {last4}', 'woo-stripe-payment' ),
|
93 |
+
),
|
94 |
+
'type_masked_number' => array(
|
95 |
+
'label' => __( 'Type Masked Number', 'woo-stripe-payment' ),
|
96 |
+
'example' => 'Visa ********1111',
|
97 |
+
'format' => '{brand} {masked_number}',
|
98 |
+
),
|
99 |
+
'type_dash_masked_number' => array(
|
100 |
+
'label' => __( 'Type Dash Masked Number', 'woo-stripe-payment' ),
|
101 |
+
'example' => 'Visa - ********1111',
|
102 |
+
'format' => '{brand} - {masked_number}',
|
103 |
+
),
|
104 |
+
'type_last4' => array(
|
105 |
+
'label' => __( 'Type Last 4', 'woo-stripe-payment' ),
|
106 |
+
'example' => 'Visa 1111',
|
107 |
+
'format' => '{brand} {last4}',
|
108 |
+
),
|
109 |
+
'type_dash_last4' => array(
|
110 |
+
'label' => __( 'Type Dash & Last 4', 'woo-stripe-payment' ),
|
111 |
+
'example' => 'Visa - 1111',
|
112 |
+
'format' => '{brand} - {last4}',
|
113 |
+
),
|
114 |
+
'last4' => array(
|
115 |
+
'label' => __( 'Last Four', 'woo-stripe-payment' ),
|
116 |
+
'example' => '1111',
|
117 |
+
'format' => '{last4}',
|
118 |
+
),
|
119 |
+
'card_type' => array(
|
120 |
+
'label' => __( 'Card Type', 'woo-stripe-payment' ),
|
121 |
+
'example' => 'Visa',
|
122 |
+
'format' => '{brand}',
|
123 |
+
),
|
124 |
+
);
|
125 |
+
}
|
126 |
+
}
|
includes/tokens/class-wc-payment-token-stripe-googlepay.php
CHANGED
@@ -1,21 +1,21 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
if (! class_exists
|
5 |
-
return;
|
6 |
-
}
|
7 |
-
|
8 |
-
|
9 |
-
*
|
10 |
-
* @
|
11 |
-
*
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
}
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
if ( ! class_exists( 'WC_Payment_Token_Stripe_CC' ) ) {
|
5 |
+
return;
|
6 |
+
}
|
7 |
+
|
8 |
+
/**
|
9 |
+
*
|
10 |
+
* @author PaymentPlugins
|
11 |
+
* @package Stripe/Tokens
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
class WC_Payment_Token_Stripe_GooglePay extends WC_Payment_Token_Stripe_CC {
|
15 |
+
|
16 |
+
use WC_Payment_Token_Source_Trait;
|
17 |
+
|
18 |
+
protected $type = 'Stripe_GooglePay';
|
19 |
+
|
20 |
+
protected $stripe_payment_type = 'source';
|
21 |
+
}
|
includes/tokens/class-wc-payment-token-stripe-local-payment.php
CHANGED
@@ -1,41 +1,40 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
/**
|
5 |
-
*
|
6 |
-
* @since 3.0.0
|
7 |
-
* @package Stripe/Tokens
|
8 |
-
* @author PaymentPlugins
|
9 |
-
*
|
10 |
-
*/
|
11 |
-
class WC_Payment_Token_Stripe_Local extends WC_Payment_Token_Stripe {
|
12 |
-
|
13 |
-
protected $type = 'Stripe_Local';
|
14 |
-
|
15 |
-
protected $stripe_data =
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
'
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
}
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
/**
|
5 |
+
*
|
6 |
+
* @since 3.0.0
|
7 |
+
* @package Stripe/Tokens
|
8 |
+
* @author PaymentPlugins
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
class WC_Payment_Token_Stripe_Local extends WC_Payment_Token_Stripe {
|
12 |
+
|
13 |
+
protected $type = 'Stripe_Local';
|
14 |
+
|
15 |
+
protected $stripe_data = array( 'gateway_title' => '' );
|
16 |
+
|
17 |
+
public function details_to_props( $details ) {}
|
18 |
+
|
19 |
+
public function set_gateway_title( $value ) {
|
20 |
+
$this->set_prop( 'gateway_title', $value );
|
21 |
+
}
|
22 |
+
|
23 |
+
public function get_gateway_title( $context = 'view' ) {
|
24 |
+
return $this->get_prop( 'gateway_title', $context );
|
25 |
+
}
|
26 |
+
|
27 |
+
public function get_formats() {
|
28 |
+
return array(
|
29 |
+
'gateway_title' => array(
|
30 |
+
'label' => __( 'Gateway Title', 'woo-stripe-payment' ),
|
31 |
+
'example' => 'P24',
|
32 |
+
'format' => '{gateway_title}',
|
33 |
+
),
|
34 |
+
);
|
35 |
+
}
|
36 |
+
|
37 |
+
public function save_payment_method() {}
|
38 |
+
|
39 |
+
public function delete_from_stripe() {}
|
40 |
+
}
|
|
includes/traits/wc-stripe-controller-cart-trait.php
CHANGED
@@ -1,25 +1,28 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
/**
|
5 |
-
*
|
6 |
-
* @since 3.1.0
|
7 |
-
* @author Payment Plugins
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
*
|
14 |
-
*
|
15 |
-
*
|
16 |
-
*
|
17 |
-
*
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
/**
|
5 |
+
*
|
6 |
+
* @since 3.1.0
|
7 |
+
* @author Payment Plugins
|
8 |
+
*/
|
9 |
+
trait WC_Stripe_Controller_Cart_Trait {
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Method that hooks in to the woocommerce_cart_ready_to_calc_shipping filter.
|
13 |
+
* Purpose is to ensure
|
14 |
+
* true is returned so shipping packages are calculated. Some 3rd party plugins and themes return false
|
15 |
+
* if the current page is the cart because they don't want to display the shipping calculator.
|
16 |
+
*
|
17 |
+
* @since 3.1.0
|
18 |
+
*/
|
19 |
+
public function add_ready_to_calc_shipping() {
|
20 |
+
add_filter(
|
21 |
+
'woocommerce_cart_ready_to_calc_shipping',
|
22 |
+
function ( $show_shipping ) {
|
23 |
+
return true;
|
24 |
+
},
|
25 |
+
1000
|
26 |
+
);
|
27 |
+
}
|
28 |
+
}
|
includes/traits/wc-stripe-payment-token-traits.php
CHANGED
@@ -1,65 +1,38 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
/**
|
5 |
-
*
|
6 |
-
* @author PaymentPlugins
|
7 |
-
* @since 3.1.5
|
8 |
-
* @package Stripe/Trait
|
9 |
-
*
|
10 |
-
*/
|
11 |
-
trait WC_Payment_Token_Source_Trait{
|
12 |
-
|
13 |
-
public function save_payment_method() {
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
public function save_payment_method() {
|
40 |
-
$gateway = WC_Stripe_Gateway::load ();
|
41 |
-
|
42 |
-
$payment_method = $gateway->fetch_payment_method ( $this->get_token () );
|
43 |
-
|
44 |
-
if (is_wp_error ( $payment_method )) {
|
45 |
-
return $payment_method;
|
46 |
-
}
|
47 |
-
|
48 |
-
return $gateway->attach_payment_method ( $payment_method, [
|
49 |
-
'customer' => $this->get_customer_id ()
|
50 |
-
] );
|
51 |
-
}
|
52 |
-
|
53 |
-
public function delete_from_stripe() {
|
54 |
-
$customer_id = wc_stripe_get_customer_id ( $this->get_user_id (), $this->get_environment () );
|
55 |
-
$gateway = WC_Stripe_Gateway::load ();
|
56 |
-
|
57 |
-
$payment_method = $gateway->fetch_payment_method ( $this->get_token () );
|
58 |
-
|
59 |
-
if (is_wp_error ( $payment_method )) {
|
60 |
-
return $payment_method;
|
61 |
-
}
|
62 |
-
|
63 |
-
return $gateway->delete_payment_method ( $payment_method );
|
64 |
-
}
|
65 |
-
}
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
/**
|
5 |
+
*
|
6 |
+
* @author PaymentPlugins
|
7 |
+
* @since 3.1.5
|
8 |
+
* @package Stripe/Trait
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
trait WC_Payment_Token_Source_Trait {
|
12 |
+
|
13 |
+
public function save_payment_method() {
|
14 |
+
return WC_Stripe_Gateway::load()->customers->createSource( $this->get_customer_id(), array( 'source' => $this->get_token() ) );
|
15 |
+
}
|
16 |
+
|
17 |
+
public function delete_from_stripe() {
|
18 |
+
return WC_Stripe_Gateway::load()->sources->mode( $this->get_environment() )->detach( $this->get_customer_id(), $this->get_token() );
|
19 |
+
}
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
*
|
24 |
+
* @author PaymentPlugins
|
25 |
+
* @since 3.1.5
|
26 |
+
* @package Stripe/Trait
|
27 |
+
*
|
28 |
+
*/
|
29 |
+
trait WC_Payment_Token_Payment_Method_Trait {
|
30 |
+
|
31 |
+
public function save_payment_method() {
|
32 |
+
return WC_Stripe_Gateway::load()->paymentMethods->attach( $this->get_token(), array( 'customer' => $this->get_customer_id() ) );
|
33 |
+
}
|
34 |
+
|
35 |
+
public function delete_from_stripe() {
|
36 |
+
return WC_Stripe_Gateway::load()->paymentMethods->mode( $this->get_environment() )->detach( $this->get_token() );
|
37 |
+
}
|
38 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/traits/wc-stripe-payment-traits.php
CHANGED
@@ -1,101 +1,122 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
/**
|
5 |
-
*
|
6 |
-
* @author Payment Plugins
|
7 |
-
* @since 3.1.0
|
8 |
-
* @package Stripe/Trait
|
9 |
-
*/
|
10 |
-
trait WC_Stripe_Payment_Intent_Trait{
|
11 |
-
|
12 |
-
public function get_payment_object() {
|
13 |
-
return WC_Stripe_Payment_Factory::load
|
14 |
-
}
|
15 |
-
|
16 |
-
public function get_payment_method_type() {
|
17 |
-
return $this->payment_method_type;
|
18 |
-
}
|
19 |
-
|
20 |
-
/**
|
21 |
-
*
|
22 |
-
* @param WC_Order $order
|
23 |
-
*/
|
24 |
-
public function get_confirmation_method($order) {
|
25 |
-
return 'manual';
|
26 |
-
}
|
27 |
-
|
28 |
-
/**
|
29 |
-
*
|
30 |
-
* @param \Stripe\PaymentIntent $secret
|
31 |
-
* @param WC_Order $order
|
32 |
-
*/
|
33 |
-
public function get_payment_intent_checkout_url($intent, $order) {
|
34 |
-
// rand is used to generate some random entropy so that window hash events are triggered.
|
35 |
-
return sprintf
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
*
|
57 |
-
* @
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
*
|
70 |
-
* @
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
/**
|
5 |
+
*
|
6 |
+
* @author Payment Plugins
|
7 |
+
* @since 3.1.0
|
8 |
+
* @package Stripe/Trait
|
9 |
+
*/
|
10 |
+
trait WC_Stripe_Payment_Intent_Trait {
|
11 |
+
|
12 |
+
public function get_payment_object() {
|
13 |
+
return WC_Stripe_Payment_Factory::load( 'payment_intent', $this, WC_Stripe_Gateway::load() );
|
14 |
+
}
|
15 |
+
|
16 |
+
public function get_payment_method_type() {
|
17 |
+
return $this->payment_method_type;
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
*
|
22 |
+
* @param WC_Order $order
|
23 |
+
*/
|
24 |
+
public function get_confirmation_method( $order ) {
|
25 |
+
return 'manual';
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
*
|
30 |
+
* @param \Stripe\PaymentIntent $secret
|
31 |
+
* @param WC_Order $order
|
32 |
+
*/
|
33 |
+
public function get_payment_intent_checkout_url( $intent, $order ) {
|
34 |
+
// rand is used to generate some random entropy so that window hash events are triggered.
|
35 |
+
return sprintf(
|
36 |
+
'#response=%s',
|
37 |
+
base64_encode(
|
38 |
+
wp_json_encode(
|
39 |
+
array(
|
40 |
+
'client_secret' => $intent->client_secret,
|
41 |
+
'order_id' => $order->get_id(),
|
42 |
+
'time' => rand(
|
43 |
+
0,
|
44 |
+
999999
|
45 |
+
),
|
46 |
+
)
|
47 |
+
)
|
48 |
+
)
|
49 |
+
);
|
50 |
+
}
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
*
|
55 |
+
* @author Payment Plugins
|
56 |
+
* @since 3.1.0
|
57 |
+
* @package Stripe/Trait
|
58 |
+
*/
|
59 |
+
trait WC_Stripe_Payment_Charge_Trait {
|
60 |
+
|
61 |
+
public function get_payment_object() {
|
62 |
+
return WC_Stripe_Payment_Factory::load( 'charge', $this, WC_Stripe_Gateway::load() );
|
63 |
+
}
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
*
|
68 |
+
* @author Payment Plugins
|
69 |
+
* @since 3.1.0
|
70 |
+
* @package Stripe/Trait
|
71 |
+
*/
|
72 |
+
trait WC_Stripe_Local_Payment_Charge_Trait {
|
73 |
+
|
74 |
+
public function get_payment_object() {
|
75 |
+
return WC_Stripe_Payment_Factory::load( 'local_charge', $this, WC_Stripe_Gateway::load() );
|
76 |
+
}
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
*
|
81 |
+
* @author Payment Plugins
|
82 |
+
* @since 3.1.0
|
83 |
+
* @package Stripe/Trait
|
84 |
+
*
|
85 |
+
*/
|
86 |
+
trait WC_Stripe_Local_Payment_Intent_Trait {
|
87 |
+
|
88 |
+
use WC_Stripe_Payment_Intent_Trait;
|
89 |
+
|
90 |
+
/**
|
91 |
+
*
|
92 |
+
* @param \Stripe\PaymentIntent $secret
|
93 |
+
* @param WC_Order $order
|
94 |
+
*/
|
95 |
+
public function get_payment_intent_checkout_url( $intent, $order ) {
|
96 |
+
// rand is used to generate some random entropy so that window hash events are triggered.
|
97 |
+
return sprintf(
|
98 |
+
'#response=%s',
|
99 |
+
base64_encode(
|
100 |
+
wp_json_encode(
|
101 |
+
array(
|
102 |
+
'client_secret' => $intent->client_secret,
|
103 |
+
'gateway_id' => $this->id,
|
104 |
+
'return_url' => $this->get_local_payment_return_url( $order ),
|
105 |
+
'time' => rand(
|
106 |
+
0,
|
107 |
+
999999
|
108 |
+
),
|
109 |
+
)
|
110 |
+
)
|
111 |
+
)
|
112 |
+
);
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
*
|
117 |
+
* @param WC_Order $order
|
118 |
+
*/
|
119 |
+
public function get_confirmation_method( $order ) {
|
120 |
+
return 'automatic';
|
121 |
+
}
|
122 |
+
}
|
includes/traits/wc-stripe-settings-trait.php
CHANGED
@@ -1,160 +1,178 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
/**
|
5 |
-
*
|
6 |
-
* @author Payment Plugins
|
7 |
-
* @since 3.1.0
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
trait WC_Stripe_Settings_Trait{
|
11 |
-
|
12 |
-
protected $tab_title;
|
13 |
-
|
14 |
-
private $admin_output = false;
|
15 |
-
|
16 |
-
public function admin_nav_tab($tabs) {
|
17 |
-
$tabs[ $this->id ] = $this->tab_title;
|
18 |
-
return $tabs;
|
19 |
-
}
|
20 |
-
|
21 |
-
public function is_active($key) {
|
22 |
-
return $this->get_option
|
23 |
-
}
|
24 |
-
|
25 |
-
public function admin_options() {
|
26 |
-
if ($this->admin_output) {
|
27 |
-
return;
|
28 |
-
}
|
29 |
-
$this->display_errors
|
30 |
-
$this->output_settings_nav
|
31 |
-
printf
|
32 |
-
echo '<div class="wc-stripe-settings-container ' . $this->id . '">';
|
33 |
-
parent::admin_options
|
34 |
-
echo '</div>';
|
35 |
-
$this->admin_output = true;
|
36 |
-
}
|
37 |
-
|
38 |
-
public function output_settings_nav() {
|
39 |
-
include wc_stripe
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Display admin error messages.
|
44 |
-
*/
|
45 |
-
public function display_errors() {
|
46 |
-
if ($this->get_errors
|
47 |
-
echo '<div id="woocommerce_errors" class="error notice inline is-dismissible">';
|
48 |
-
foreach ( $this->get_errors
|
49 |
-
echo '<p>' . wp_kses_post
|
50 |
-
}
|
51 |
-
echo '</div>';
|
52 |
-
}
|
53 |
-
}
|
54 |
-
|
55 |
-
public function get_prefix() {
|
56 |
-
return $this->plugin_id . $this->id . '_';
|
57 |
-
}
|
58 |
-
|
59 |
-
public function generate_multiselect_html($key, $data) {
|
60 |
-
$value
|
61 |
-
$data[
|
62 |
-
return parent::generate_multiselect_html
|
63 |
-
}
|
64 |
-
|
65 |
-
public function get_custom_attribute_html($attribs) {
|
66 |
-
if (! empty
|
67 |
-
foreach ( $attribs[
|
68 |
-
if (is_array
|
69 |
-
$attribs[
|
70 |
-
}
|
71 |
-
}
|
72 |
-
}
|
73 |
-
return parent::get_custom_attribute_html
|
74 |
-
}
|
75 |
-
|
76 |
-
public function generate_description_html($key, $data) {
|
77 |
-
$field_key = $this->get_field_key
|
78 |
-
$data
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
'
|
120 |
-
'
|
121 |
-
'id'
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
/**
|
5 |
+
*
|
6 |
+
* @author Payment Plugins
|
7 |
+
* @since 3.1.0
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
trait WC_Stripe_Settings_Trait {
|
11 |
+
|
12 |
+
protected $tab_title;
|
13 |
+
|
14 |
+
private $admin_output = false;
|
15 |
+
|
16 |
+
public function admin_nav_tab( $tabs ) {
|
17 |
+
$tabs[ $this->id ] = $this->tab_title;
|
18 |
+
return $tabs;
|
19 |
+
}
|
20 |
+
|
21 |
+
public function is_active( $key ) {
|
22 |
+
return $this->get_option( $key ) === 'yes';
|
23 |
+
}
|
24 |
+
|
25 |
+
public function admin_options() {
|
26 |
+
if ( $this->admin_output ) {
|
27 |
+
return;
|
28 |
+
}
|
29 |
+
$this->display_errors();
|
30 |
+
$this->output_settings_nav();
|
31 |
+
printf( '<input type="hidden" id="wc_stripe_prefix" name="wc_stripe_prefix" value="%1$s"/>', $this->get_prefix() );
|
32 |
+
echo '<div class="wc-stripe-settings-container ' . $this->id . '">';
|
33 |
+
parent::admin_options();
|
34 |
+
echo '</div>';
|
35 |
+
$this->admin_output = true;
|
36 |
+
}
|
37 |
+
|
38 |
+
public function output_settings_nav() {
|
39 |
+
include wc_stripe()->plugin_path() . 'includes/admin/views/html-settings-nav.php';
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Display admin error messages.
|
44 |
+
*/
|
45 |
+
public function display_errors() {
|
46 |
+
if ( $this->get_errors() ) {
|
47 |
+
echo '<div id="woocommerce_errors" class="error notice inline is-dismissible">';
|
48 |
+
foreach ( $this->get_errors() as $error ) {
|
49 |
+
echo '<p>' . wp_kses_post( $error ) . '</p>';
|
50 |
+
}
|
51 |
+
echo '</div>';
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
public function get_prefix() {
|
56 |
+
return $this->plugin_id . $this->id . '_';
|
57 |
+
}
|
58 |
+
|
59 |
+
public function generate_multiselect_html( $key, $data ) {
|
60 |
+
$value = (array) $this->get_option( $key, array() );
|
61 |
+
$data['options'] = array_merge( array_flip( $value ), $data['options'] );
|
62 |
+
return parent::generate_multiselect_html( $key, $data );
|
63 |
+
}
|
64 |
+
|
65 |
+
public function get_custom_attribute_html( $attribs ) {
|
66 |
+
if ( ! empty( $attribs['custom_attributes'] ) && is_array( $attribs['custom_attributes'] ) ) {
|
67 |
+
foreach ( $attribs['custom_attributes'] as $k => $v ) {
|
68 |
+
if ( is_array( $v ) ) {
|
69 |
+
$attribs['custom_attributes'][ $k ] = htmlspecialchars( wp_json_encode( $v ) );
|
70 |
+
}
|
71 |
+
}
|
72 |
+
}
|
73 |
+
return parent::get_custom_attribute_html( $attribs );
|
74 |
+
}
|
75 |
+
|
76 |
+
public function generate_description_html( $key, $data ) {
|
77 |
+
$field_key = $this->get_field_key( $key );
|
78 |
+
$data = wp_parse_args(
|
79 |
+
$data,
|
80 |
+
array(
|
81 |
+
'class' => '',
|
82 |
+
'style' => '',
|
83 |
+
'description' => '',
|
84 |
+
)
|
85 |
+
);
|
86 |
+
ob_start();
|
87 |
+
include wc_stripe()->plugin_path() . 'includes/admin/views/html-description.php';
|
88 |
+
return ob_get_clean();
|
89 |
+
}
|
90 |
+
|
91 |
+
public function generate_paragraph_html( $key, $data ) {
|
92 |
+
$field_key = $this->get_field_key( $key );
|
93 |
+
$defaults = array(
|
94 |
+
'title' => '',
|
95 |
+
'label' => '',
|
96 |
+
'class' => '',
|
97 |
+
'css' => '',
|
98 |
+
'desc_tip' => false,
|
99 |
+
'description' => '',
|
100 |
+
'custom_attributes' => array(),
|
101 |
+
);
|
102 |
+
$data = wp_parse_args( $data, $defaults );
|
103 |
+
if ( ! $data['label'] ) {
|
104 |
+
$data['label'] = $data['title'];
|
105 |
+
}
|
106 |
+
ob_start();
|
107 |
+
include wc_stripe()->plugin_path() . 'includes/admin/views/html-paragraph.php';
|
108 |
+
return ob_get_clean();
|
109 |
+
}
|
110 |
+
|
111 |
+
public function generate_stripe_button_html( $key, $data ) {
|
112 |
+
$field_key = $this->get_field_key( $key );
|
113 |
+
$data = wp_parse_args(
|
114 |
+
$data,
|
115 |
+
array(
|
116 |
+
'title' => '',
|
117 |
+
'class' => '',
|
118 |
+
'style' => '',
|
119 |
+
'description' => '',
|
120 |
+
'desc_tip' => false,
|
121 |
+
'id' => 'wc-stripe-button_' . $key,
|
122 |
+
'disabled' => false,
|
123 |
+
'css' => '',
|
124 |
+
)
|
125 |
+
);
|
126 |
+
ob_start();
|
127 |
+
include wc_stripe()->plugin_path() . 'includes/admin/views/html-button.php';
|
128 |
+
return ob_get_clean();
|
129 |
+
}
|
130 |
+
|
131 |
+
public function generate_button_demo_html( $key, $data ) {
|
132 |
+
$field_key = $this->get_field_key( $key );
|
133 |
+
$data = wp_parse_args(
|
134 |
+
$data,
|
135 |
+
array(
|
136 |
+
'title' => '',
|
137 |
+
'class' => '',
|
138 |
+
'style' => '',
|
139 |
+
'description' => '',
|
140 |
+
'desc_tip' => false,
|
141 |
+
'id' => 'wc-stripe-button-demo',
|
142 |
+
)
|
143 |
+
);
|
144 |
+
ob_start();
|
145 |
+
include wc_stripe()->plugin_path() . 'includes/admin/views/html-button-demo.php';
|
146 |
+
return ob_get_clean();
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* Added override to provide more control on which fields are saved and which are skipped.
|
151 |
+
* This plugin
|
152 |
+
* has custom setting fields like "paragraph" that are for info display only and not for saving.
|
153 |
+
*
|
154 |
+
* {@inheritDoc}
|
155 |
+
*
|
156 |
+
* @see WC_Settings_API::process_admin_options()
|
157 |
+
*/
|
158 |
+
public function process_admin_options() {
|
159 |
+
$this->init_settings();
|
160 |
+
|
161 |
+
$post_data = $this->get_post_data();
|
162 |
+
|
163 |
+
$skip_types = array( 'title', 'paragraph', 'button', 'description', 'button_demo', 'stripe_button' );
|
164 |
+
|
165 |
+
foreach ( $this->get_form_fields() as $key => $field ) {
|
166 |
+
$skip = isset( $field['skip'] ) && $field['skip'] == true;
|
167 |
+
if ( ! in_array( $this->get_field_type( $field ), $skip_types ) && ! $skip ) {
|
168 |
+
try {
|
169 |
+
$this->settings[ $key ] = $this->get_field_value( $key, $field, $post_data );
|
170 |
+
} catch ( Exception $e ) {
|
171 |
+
$this->add_error( $e->getMessage() );
|
172 |
+
}
|
173 |
+
}
|
174 |
+
}
|
175 |
+
|
176 |
+
return update_option( $this->get_option_key(), apply_filters( 'woocommerce_settings_api_sanitized_fields_' . $this->id, $this->settings ), 'yes' );
|
177 |
+
}
|
178 |
+
}
|
includes/updates/update-3.0.7.php
CHANGED
@@ -1,42 +1,38 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
use Stripe\Webhook;
|
5 |
-
use Stripe\WebhookEndpoint;
|
6 |
-
use Stripe\ApiOperations\Delete;
|
7 |
-
|
8 |
-
/**
|
9 |
-
* This update reconfigured the webhooks for each environment.
|
10 |
-
*/
|
11 |
-
$environments =
|
12 |
-
|
13 |
-
$
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
$
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
*
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
$api_settings->update_option ( "webhook_secret_{$env}", $webhook[ 'secret' ] );
|
40 |
-
$api_settings->update_option ( "webhook_id_{$env}", $webhook[ 'id' ] );
|
41 |
-
}
|
42 |
-
}
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
use Stripe\Webhook;
|
5 |
+
use Stripe\WebhookEndpoint;
|
6 |
+
use Stripe\ApiOperations\Delete;
|
7 |
+
|
8 |
+
/**
|
9 |
+
* This update reconfigured the webhooks for each environment.
|
10 |
+
*/
|
11 |
+
$environments = array( 'live', 'test' );
|
12 |
+
$api_settings = wc_stripe()->api_settings;
|
13 |
+
$url = wc_stripe()->rest_api->webhook->rest_url( 'webhook' );
|
14 |
+
|
15 |
+
foreach ( $environments as $env ) {
|
16 |
+
$gateway = new WC_Stripe_Gateway();
|
17 |
+
$webhooks = $gateway->webhooks( $env );
|
18 |
+
|
19 |
+
if ( ! is_wp_error( $webhooks ) ) {
|
20 |
+
// first delete the webhook if it matches the wp-json webhook. Then re-create it.
|
21 |
+
foreach ( $webhooks->data as $webhook ) {
|
22 |
+
/**
|
23 |
+
*
|
24 |
+
* @var Stripe\WebhookEndpoint $webhook
|
25 |
+
*/
|
26 |
+
if ( $webhook['url'] == $url ) {
|
27 |
+
$webhook->delete();
|
28 |
+
}
|
29 |
+
}
|
30 |
+
}
|
31 |
+
// now that endpoint is deleted, re-create it and store details.
|
32 |
+
$webhook = $gateway->create_webhook( $url, array( 'charge.failed', 'charge.succeeded', 'source.chargeable' ), $env );
|
33 |
+
if ( ! is_wp_error( $webhook ) ) {
|
34 |
+
$api_settings->update_option( "webhook_url_{$env}", $webhook['url'] );
|
35 |
+
$api_settings->update_option( "webhook_secret_{$env}", $webhook['secret'] );
|
36 |
+
$api_settings->update_option( "webhook_id_{$env}", $webhook['id'] );
|
37 |
+
}
|
38 |
+
}
|
|
|
|
|
|
|
|
includes/updates/update-3.1.0.php
CHANGED
@@ -1,60 +1,55 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
// update webhooks to include payment_intent.succeeded
|
5 |
-
$environments =
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
$webhook_id
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
$events =
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
?>
|
33 |
-
|
34 |
-
|
35 |
-
<p><?php
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
});
|
57 |
-
add_filter('woocommerce_email_from_name', function($name){
|
58 |
-
return 'Payment Plugins';
|
59 |
-
});
|
60 |
-
$email->send ( $settings[ 'recipient' ], __ ( 'Stripe For WooCommerce Update', 'woo-stripe-payment' ), $content, $email->get_headers (), []);
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
// update webhooks to include payment_intent.succeeded
|
5 |
+
$environments = array( 'live', 'test' );
|
6 |
+
|
7 |
+
foreach ( $environments as $env ) {
|
8 |
+
$webhook_id = wc_stripe()->api_settings->get_option( "webhook_id_{$env}" );
|
9 |
+
if ( $webhook_id ) {
|
10 |
+
$gateway = WC_Stripe_Gateway::load( $env );
|
11 |
+
|
12 |
+
// fetch webhook so we can merge existing events with the new payment_intent.succeeded event
|
13 |
+
$webhook = $gateway->webhookEndpoints->retrieve( $webhook_id );
|
14 |
+
if ( ! is_wp_error( $webhook ) ) {
|
15 |
+
$events = $webhook['enabled_events'];
|
16 |
+
$events[] = 'payment_intent.succeeded';
|
17 |
+
|
18 |
+
$result = $gateway->webhookEndpoints->update( $webhook_id, array( 'enabled_events' => $events ) );
|
19 |
+
wc_stripe_log_info( "Webhook {$webhook_id} updated." );
|
20 |
+
}
|
21 |
+
}
|
22 |
+
}
|
23 |
+
|
24 |
+
update_option( 'wc_stripe_connect_notice', 'yes' );
|
25 |
+
|
26 |
+
// send email
|
27 |
+
ob_start();
|
28 |
+
WC_Emails::instance()->email_header( __( 'Stripe For WooCommerce Update', 'woo-stripe-payment' ) );
|
29 |
+
?>
|
30 |
+
<p><?php _e( 'Greetings from Payment Plugins,', 'woo-stripe-payment' ); ?></p>
|
31 |
+
<p><?php _e( 'At Stripe\'s request, we have updated Stripe for WooCommerce to use the new Stripe Connect integration. This new integration offers even more security. Stripe is requesting that all merchants switch.', 'woo-stripe-payment' ); ?></p>
|
32 |
+
<p><?php printf( __( 'Click %1$shere%2$s to be redirected to your Stripe API settings page then click the <strong>Click to Connect</strong> button.', 'woo-stripe-payment' ), '<a href="' . admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=stripe_api' ) . '" target="_blank">', '</a>' ); ?>
|
33 |
+
|
34 |
+
|
35 |
+
<p><?php _e( 'Kind Regards,', 'woo-stripe-payment' ); ?></p>
|
36 |
+
<p><?php _e( 'Payment Plugins' ); ?></p>
|
37 |
+
<?php
|
38 |
+
WC_Emails::instance()->email_footer();
|
39 |
+
$content = ob_get_clean();
|
40 |
+
$settings = get_option( 'woocommerce_new_order_settings', array( 'recipient' => get_option( 'admin_email', '' ) ) );
|
41 |
+
$email = new WC_Email();
|
42 |
+
$email->email_type = 'html';
|
43 |
+
add_filter(
|
44 |
+
'woocommerce_email_from_address',
|
45 |
+
function ( $from ) {
|
46 |
+
return 'support@paymentplugins.com';
|
47 |
+
}
|
48 |
+
);
|
49 |
+
add_filter(
|
50 |
+
'woocommerce_email_from_name',
|
51 |
+
function ( $name ) {
|
52 |
+
return 'Payment Plugins';
|
53 |
+
}
|
54 |
+
);
|
55 |
+
$email->send( $settings['recipient'], __( 'Stripe For WooCommerce Update', 'woo-stripe-payment' ), $content, $email->get_headers(), array() );
|
|
|
|
|
|
|
|
|
|
includes/updates/update-3.1.1.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
global $wpdb;
|
5 |
-
|
6 |
-
// delete transients that have incorrect timeouts
|
7 |
-
$wpdb->query
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
global $wpdb;
|
5 |
+
|
6 |
+
// delete transients that have incorrect timeouts
|
7 |
+
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->options} WHERE option_name LIKE %s OR option_name LIKE %s", '%_transient_timeout__stripe_lock_order_%', '%_transient__stripe_lock_order_%' ) );
|
includes/updates/update-3.1.6.php
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Schedule actions required by the plugin.
|
4 |
+
*/
|
5 |
+
wc_stripe()->scheduled_actions();
|
includes/wc-stripe-functions.php
CHANGED
@@ -1,1175 +1,1243 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
/**
|
5 |
-
*
|
6 |
-
* @
|
7 |
-
* @
|
8 |
-
*
|
9 |
-
* @
|
10 |
-
* @
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
*
|
19 |
-
*
|
20 |
-
*
|
21 |
-
*
|
22 |
-
* @
|
23 |
-
* @param
|
24 |
-
*
|
25 |
-
* @return string
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
*
|
35 |
-
*
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
*
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
*
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
*
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
*
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
*
|
119 |
-
*
|
120 |
-
* @package Stripe/Functions
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
*
|
151 |
-
* @
|
152 |
-
*
|
153 |
-
* @
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
*
|
165 |
-
*
|
166 |
-
* @since 3.0.0
|
167 |
-
* @package Stripe/Functions
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
*
|
182 |
-
* @since 3.0.0
|
183 |
-
* @package Stripe/Functions
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
*
|
194 |
-
* @param string $message
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
*
|
205 |
-
* @
|
206 |
-
*
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
*
|
217 |
-
*
|
218 |
-
* @
|
219 |
-
*
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
*
|
247 |
-
*
|
248 |
-
* @package Stripe/Functions
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
*
|
267 |
-
*
|
268 |
-
* @
|
269 |
-
* @
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
}
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
}
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
*
|
347 |
-
*
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
foreach ( $
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
];
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
]
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
$items[] =
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
}
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
}
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
*
|
569 |
-
*
|
570 |
-
* @package Stripe/Functions
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
}
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
*
|
593 |
-
*
|
594 |
-
*
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
*
|
615 |
-
* @
|
616 |
-
*
|
617 |
-
* @
|
618 |
-
*/
|
619 |
-
function
|
620 |
-
|
621 |
-
$
|
622 |
-
$gateways
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
}
|
634 |
-
|
635 |
-
/**
|
636 |
-
*
|
637 |
-
*
|
638 |
-
*
|
639 |
-
*
|
640 |
-
* @
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
*
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
'
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
*
|
966 |
-
* @
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
*
|
977 |
-
* @since 3.0.5
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
*
|
989 |
-
*
|
990 |
-
*
|
991 |
-
*
|
992 |
-
* @
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
*
|
1012 |
-
* @since 3.0.6
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
$
|
1019 |
-
$data[
|
1020 |
-
|
1021 |
-
|
1022 |
-
}
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
*
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
*
|
1057 |
-
* @
|
1058 |
-
* @
|
1059 |
-
*/
|
1060 |
-
function
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
*
|
1074 |
-
* @
|
1075 |
-
* @param
|
1076 |
-
*
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
return
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
'
|
1121 |
-
'
|
1122 |
-
'
|
1123 |
-
'
|
1124 |
-
'
|
1125 |
-
'
|
1126 |
-
'
|
1127 |
-
'
|
1128 |
-
'
|
1129 |
-
'
|
1130 |
-
'
|
1131 |
-
'
|
1132 |
-
'
|
1133 |
-
'
|
1134 |
-
'
|
1135 |
-
'
|
1136 |
-
'
|
1137 |
-
'
|
1138 |
-
'
|
1139 |
-
'
|
1140 |
-
'
|
1141 |
-
'
|
1142 |
-
'
|
1143 |
-
|
1144 |
-
|
1145 |
-
|
1146 |
-
|
1147 |
-
|
1148 |
-
|
1149 |
-
|
1150 |
-
|
1151 |
-
|
1152 |
-
|
1153 |
-
|
1154 |
-
|
1155 |
-
|
1156 |
-
'
|
1157 |
-
'
|
1158 |
-
'
|
1159 |
-
'
|
1160 |
-
|
1161 |
-
|
1162 |
-
|
1163 |
-
|
1164 |
-
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
/**
|
5 |
+
*
|
6 |
+
* @param string $template_name
|
7 |
+
* @param array $args
|
8 |
+
*
|
9 |
+
* @since 3.0.0
|
10 |
+
* @package Stripe/Functions
|
11 |
+
* Wrapper for wc_get_template that returns Stripe specfic templates.
|
12 |
+
*/
|
13 |
+
function wc_stripe_get_template( $template_name, $args = array() ) {
|
14 |
+
wc_get_template( $template_name, $args, wc_stripe()->template_path(), wc_stripe()->default_template_path() );
|
15 |
+
}
|
16 |
+
|
17 |
+
/**
|
18 |
+
*
|
19 |
+
*
|
20 |
+
* Wrapper for wc_get_template_html that returns Stripe specififc templates in an html string.
|
21 |
+
*
|
22 |
+
* @param string $template_name
|
23 |
+
* @param array $args
|
24 |
+
*
|
25 |
+
* @return string
|
26 |
+
* @since 3.0.0
|
27 |
+
* @package Stripe/Functions
|
28 |
+
*/
|
29 |
+
function wc_stripe_get_template_html( $template_name, $args = array() ) {
|
30 |
+
return wc_get_template_html( $template_name, $args, wc_stripe()->template_path(), wc_stripe()->default_template_path() );
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Return true if WCS is active.
|
35 |
+
*
|
36 |
+
* @return boolean
|
37 |
+
* @package Stripe/Functions
|
38 |
+
*/
|
39 |
+
function wcs_stripe_active() {
|
40 |
+
return function_exists( 'wcs_is_subscription' );
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
*
|
45 |
+
* @param WC_Payment_Gateway_Stripe $gateway
|
46 |
+
*
|
47 |
+
* @package Stripe/Functions
|
48 |
+
*/
|
49 |
+
function wc_stripe_token_field( $gateway ) {
|
50 |
+
wc_stripe_hidden_field( $gateway->token_key, 'wc-stripe-token-field' );
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
*
|
55 |
+
* @param WC_Payment_Gateway_Stripe $gateway
|
56 |
+
*
|
57 |
+
* @package Stripe/Functions
|
58 |
+
*/
|
59 |
+
function wc_stripe_payment_intent_field( $gateway ) {
|
60 |
+
wc_stripe_hidden_field( $gateway->payment_intent_key, 'wc-stripe-payment-intent-field' );
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
*
|
65 |
+
* @param string $id
|
66 |
+
* @param string $class
|
67 |
+
* @param string $value
|
68 |
+
*
|
69 |
+
* @package Stripe/Functions
|
70 |
+
*/
|
71 |
+
function wc_stripe_hidden_field( $id, $class = '', $value = '' ) {
|
72 |
+
printf( '<input type="hidden" class="%1$s" id="%2$s" name="%2$s" value="%3$s"/>', $class, $id, $value );
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Return the mode for the plugin.
|
77 |
+
*
|
78 |
+
* @return string
|
79 |
+
* @package Stripe/Functions
|
80 |
+
*/
|
81 |
+
function wc_stripe_mode() {
|
82 |
+
return apply_filters( 'wc_stripe_mode', wc_stripe()->api_settings->get_option( 'mode' ) );
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Return the secret key for the provided mode.
|
87 |
+
* If no mode given, the key for the active mode is returned.
|
88 |
+
*
|
89 |
+
* @param string $mode
|
90 |
+
*
|
91 |
+
* @since 3.0.0
|
92 |
+
* @package Stripe/Functions
|
93 |
+
*/
|
94 |
+
function wc_stripe_get_secret_key( $mode = '' ) {
|
95 |
+
$mode = empty( $mode ) ? wc_stripe_mode() : $mode;
|
96 |
+
|
97 |
+
return apply_filters( 'wc_stripe_get_secret_key', wc_stripe()->api_settings->get_option( "secret_key_{$mode}" ), $mode );
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Return the publishable key for the provided mode.
|
102 |
+
* If no mode given, the key for the active mode is returned.
|
103 |
+
*
|
104 |
+
* @param string $mode
|
105 |
+
*
|
106 |
+
* @since 3.0.0
|
107 |
+
* @package Stripe/Functions
|
108 |
+
*/
|
109 |
+
function wc_stripe_get_publishable_key( $mode = '' ) {
|
110 |
+
$mode = empty( $mode ) ? wc_stripe_mode() : $mode;
|
111 |
+
|
112 |
+
return apply_filters( 'wc_stripe_get_publishable_key', wc_stripe()->api_settings->get_option( "publishable_key_{$mode}" ), $mode );
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* Return the merchant's Stripe account.
|
117 |
+
*
|
118 |
+
* @return string
|
119 |
+
* @since 3.1.4
|
120 |
+
* @package Stripe/Functions
|
121 |
+
*/
|
122 |
+
function wc_stripe_get_account_id() {
|
123 |
+
return apply_filters( 'wc_stripe_get_account_id', wc_stripe()->api_settings->get_option( 'account_id' ) );
|
124 |
+
}
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Return the stripe customer ID
|
128 |
+
*
|
129 |
+
* @param int $user_id
|
130 |
+
* @param string $mode
|
131 |
+
*
|
132 |
+
* @package Stripe/Functions
|
133 |
+
* @since 3.0.0
|
134 |
+
*/
|
135 |
+
function wc_stripe_get_customer_id( $user_id = '', $mode = '' ) {
|
136 |
+
$mode = empty( $mode ) ? wc_stripe_mode() : $mode;
|
137 |
+
if ( $user_id === 0 ) {
|
138 |
+
return '';
|
139 |
+
}
|
140 |
+
if ( empty( $user_id ) ) {
|
141 |
+
$user_id = get_current_user_id();
|
142 |
+
}
|
143 |
+
|
144 |
+
return get_user_meta( $user_id, "wc_stripe_customer_{$mode}", true );
|
145 |
+
}
|
146 |
+
|
147 |
+
/**
|
148 |
+
*
|
149 |
+
* @param string $customer_id
|
150 |
+
* @param int $user_id
|
151 |
+
* @param string $mode
|
152 |
+
*
|
153 |
+
* @package Stripe/Functions
|
154 |
+
*/
|
155 |
+
function wc_stripe_save_customer( $customer_id, $user_id, $mode = '' ) {
|
156 |
+
$mode = empty( $mode ) ? wc_stripe_mode() : $mode;
|
157 |
+
$key = "wc_stripe_customer_{$mode}";
|
158 |
+
update_user_meta( $user_id, $key, $customer_id );
|
159 |
+
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
*
|
163 |
+
* @param int $token_id
|
164 |
+
* @param WC_Payment_Token $token
|
165 |
+
*
|
166 |
+
* @since 3.0.0
|
167 |
+
* @package Stripe/Functions
|
168 |
+
*/
|
169 |
+
function wc_stripe_woocommerce_payment_token_deleted( $token_id, $token ) {
|
170 |
+
if ( ! did_action( 'woocommerce_payment_gateways' ) ) {
|
171 |
+
WC_Payment_Gateways::instance();
|
172 |
+
}
|
173 |
+
do_action( 'wc_stripe_payment_token_deleted_' . $token->get_gateway_id(), $token_id, $token );
|
174 |
+
}
|
175 |
+
|
176 |
+
/**
|
177 |
+
* Log the provided message in the WC logs directory.
|
178 |
+
*
|
179 |
+
* @param int $level
|
180 |
+
* @param string $message
|
181 |
+
*
|
182 |
+
* @since 3.0.0
|
183 |
+
* @package Stripe/Functions
|
184 |
+
*/
|
185 |
+
function wc_stripe_log( $level, $message ) {
|
186 |
+
if ( wc_stripe()->api_settings->is_active( 'debug_log' ) ) {
|
187 |
+
$log = wc_get_logger();
|
188 |
+
$log->log( $level, $message, array( 'source' => 'wc-stripe' ) );
|
189 |
+
}
|
190 |
+
}
|
191 |
+
|
192 |
+
/**
|
193 |
+
*
|
194 |
+
* @param string $message
|
195 |
+
*
|
196 |
+
* @package Stripe/Functions
|
197 |
+
* @since 3.0.0
|
198 |
+
*/
|
199 |
+
function wc_stripe_log_error( $message ) {
|
200 |
+
wc_stripe_log( WC_Log_Levels::ERROR, $message );
|
201 |
+
}
|
202 |
+
|
203 |
+
/**
|
204 |
+
*
|
205 |
+
* @param string $message
|
206 |
+
*
|
207 |
+
* @package Stripe/Functions
|
208 |
+
* @since 3.0.0
|
209 |
+
*/
|
210 |
+
function wc_stripe_log_info( $message ) {
|
211 |
+
wc_stripe_log( WC_Log_Levels::INFO, $message );
|
212 |
+
}
|
213 |
+
|
214 |
+
/**
|
215 |
+
* Return the mode that the order was created in.
|
216 |
+
* Values can be <strong>live</strong> or <strong>test</strong>
|
217 |
+
*
|
218 |
+
* @param WC_Order|int $order
|
219 |
+
*
|
220 |
+
* @package Stripe/Functions
|
221 |
+
* @since 3.0.0
|
222 |
+
*/
|
223 |
+
function wc_stripe_order_mode( $order ) {
|
224 |
+
if ( is_object( $order ) ) {
|
225 |
+
return $order->get_meta( WC_Stripe_Constants::MODE, true );
|
226 |
+
}
|
227 |
+
|
228 |
+
return get_post_meta( $order, WC_Stripe_Constants::MODE, true );
|
229 |
+
}
|
230 |
+
|
231 |
+
/**
|
232 |
+
*
|
233 |
+
* @param array $gateways
|
234 |
+
*
|
235 |
+
* @package Stripe\Functions
|
236 |
+
* @since 3.0.0
|
237 |
+
*/
|
238 |
+
function wc_stripe_payment_gateways( $gateways ) {
|
239 |
+
return array_merge( $gateways, wc_stripe()->payment_gateways() );
|
240 |
+
}
|
241 |
+
|
242 |
+
/**
|
243 |
+
* Cancel the Stripe charge
|
244 |
+
*
|
245 |
+
* @param int $order_id
|
246 |
+
* @param WC_Order $order
|
247 |
+
*
|
248 |
+
* @package Stripe/Functions
|
249 |
+
*/
|
250 |
+
function wc_stripe_order_cancelled( $order_id, $order ) {
|
251 |
+
$gateways = WC()->payment_gateways()->payment_gateways();
|
252 |
+
/**
|
253 |
+
*
|
254 |
+
* @var WC_Payment_Gateway_Stripe $gateway
|
255 |
+
*/
|
256 |
+
$gateway = isset( $gateways[ $order->get_payment_method() ] ) ? $gateways[ $order->get_payment_method() ] : null;
|
257 |
+
|
258 |
+
if ( $gateway && $gateway instanceof WC_Payment_Gateway_Stripe ) {
|
259 |
+
$gateway->void_charge( $order );
|
260 |
+
}
|
261 |
+
}
|
262 |
+
|
263 |
+
/**
|
264 |
+
*
|
265 |
+
* @param int $order_id
|
266 |
+
* @param WC_Order $order
|
267 |
+
*
|
268 |
+
* @since 3.0.0
|
269 |
+
* @package Stripe/Functions
|
270 |
+
*/
|
271 |
+
function wc_stripe_order_status_completed( $order_id, $order ) {
|
272 |
+
$gateways = WC()->payment_gateways()->payment_gateways();
|
273 |
+
/**
|
274 |
+
*
|
275 |
+
* @var WC_Payment_Gateway_Stripe $gateway
|
276 |
+
*/
|
277 |
+
$gateway = isset( $gateways[ $order->get_payment_method() ] ) ? $gateways[ $order->get_payment_method() ] : null;
|
278 |
+
// @since 3.0.3 check added to ensure this is a Stripe gateway.
|
279 |
+
if ( $gateway && $gateway instanceof WC_Payment_Gateway_Stripe && ! $gateway->processing_payment ) {
|
280 |
+
$gateway->capture_charge( $order->get_total(), $order );
|
281 |
+
}
|
282 |
+
}
|
283 |
+
|
284 |
+
/**
|
285 |
+
*
|
286 |
+
* @param [] $address
|
287 |
+
*
|
288 |
+
* @throws Exception
|
289 |
+
* @since 3.0.0
|
290 |
+
* @package Stripe/Functions
|
291 |
+
*/
|
292 |
+
function wc_stripe_update_customer_location( $address ) {
|
293 |
+
// address validation for countries other than US is problematic when using responses from payment sources like
|
294 |
+
// Apple Pay.
|
295 |
+
if ( $address['postcode'] && $address['country'] === 'US' && ! WC_Validation::is_postcode( $address['postcode'], $address['country'] ) ) {
|
296 |
+
throw new Exception( __( 'Please enter a valid postcode / ZIP.', 'woocommerce' ) );
|
297 |
+
} elseif ( $address['postcode'] ) {
|
298 |
+
$address['postcode'] = wc_format_postcode( $address['postcode'], $address['country'] );
|
299 |
+
}
|
300 |
+
|
301 |
+
if ( $address['country'] ) {
|
302 |
+
WC()->customer->set_billing_location( $address['country'], $address['state'], $address['postcode'], $address['city'] );
|
303 |
+
WC()->customer->set_shipping_location( $address['country'], $address['state'], $address['postcode'], $address['city'] );
|
304 |
+
// set the customer's address if it's in the $address array
|
305 |
+
if ( ! empty( $address['address_1'] ) ) {
|
306 |
+
WC()->customer->set_shipping_address_1( wc_clean( $address['address_1'] ) );
|
307 |
+
}
|
308 |
+
if ( ! empty( $address['address_2'] ) ) {
|
309 |
+
WC()->customer->set_shipping_address_2( wc_clean( $address['address_2'] ) );
|
310 |
+
}
|
311 |
+
if ( ! empty( $address['first_name'] ) ) {
|
312 |
+
WC()->customer->set_shipping_first_name( $address['first_name'] );
|
313 |
+
}
|
314 |
+
if ( ! empty( $address['last_name'] ) ) {
|
315 |
+
WC()->customer->set_shipping_last_name( $address['last_name'] );
|
316 |
+
}
|
317 |
+
} else {
|
318 |
+
WC()->customer->set_billing_address_to_base();
|
319 |
+
WC()->customer->set_shipping_address_to_base();
|
320 |
+
}
|
321 |
+
|
322 |
+
WC()->customer->set_calculated_shipping( true );
|
323 |
+
WC()->customer->save();
|
324 |
+
|
325 |
+
do_action( 'woocommerce_calculated_shipping' );
|
326 |
+
}
|
327 |
+
|
328 |
+
/**
|
329 |
+
*
|
330 |
+
* @param [] $methods
|
331 |
+
*
|
332 |
+
* @package Stripe/Functions
|
333 |
+
* @since 3.0.0
|
334 |
+
*/
|
335 |
+
function wc_stripe_update_shipping_methods( $methods ) {
|
336 |
+
$chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods', array() );
|
337 |
+
|
338 |
+
foreach ( $methods as $i => $method ) {
|
339 |
+
$chosen_shipping_methods[ $i ] = $method;
|
340 |
+
}
|
341 |
+
|
342 |
+
WC()->session->set( 'chosen_shipping_methods', $chosen_shipping_methods );
|
343 |
+
}
|
344 |
+
|
345 |
+
/**
|
346 |
+
* Return true if there are shipping packages that contain rates.
|
347 |
+
*
|
348 |
+
* @return boolean
|
349 |
+
* @package Stripe/Functions
|
350 |
+
* @since 3.0.0
|
351 |
+
*/
|
352 |
+
function wc_stripe_shipping_address_serviceable() {
|
353 |
+
$packages = WC()->shipping()->get_packages();
|
354 |
+
if ( $packages ) {
|
355 |
+
foreach ( $packages as $package ) {
|
356 |
+
if ( count( $package['rates'] ) > 0 ) {
|
357 |
+
return true;
|
358 |
+
}
|
359 |
+
}
|
360 |
+
}
|
361 |
+
|
362 |
+
return false;
|
363 |
+
}
|
364 |
+
|
365 |
+
/**
|
366 |
+
*
|
367 |
+
* @param bool $encode
|
368 |
+
* @param WC_Order $order
|
369 |
+
*
|
370 |
+
* @package Stripe/Functions
|
371 |
+
* @since 3.0.0
|
372 |
+
*/
|
373 |
+
function wc_stripe_get_display_items( $encode = false, $order = null ) {
|
374 |
+
$items = array();
|
375 |
+
if ( ! $order ) {
|
376 |
+
$cart = WC()->cart;
|
377 |
+
$incl_tax = wc_stripe_display_prices_including_tax();
|
378 |
+
|
379 |
+
foreach ( $cart->get_cart() as $cart_item ) {
|
380 |
+
/**
|
381 |
+
*
|
382 |
+
* @var WC_Product $product
|
383 |
+
*/
|
384 |
+
$product = $cart_item['data'];
|
385 |
+
$qty = $cart_item['quantity'];
|
386 |
+
$items[] = array(
|
387 |
+
'label' => $qty > 1 ? sprintf( '%s X %s', $product->get_name(), $qty ) : $product->get_name(),
|
388 |
+
'pending' => false,
|
389 |
+
'amount' => wc_stripe_add_number_precision(
|
390 |
+
$incl_tax ? wc_get_price_including_tax( $product, array( 'qty' => $qty ) ) : wc_get_price_excluding_tax(
|
391 |
+
$product,
|
392 |
+
array(
|
393 |
+
'qty' => $qty,
|
394 |
+
)
|
395 |
+
)
|
396 |
+
),
|
397 |
+
);
|
398 |
+
}
|
399 |
+
if ( $cart->needs_shipping() ) {
|
400 |
+
$items[] = array(
|
401 |
+
'label' => __( 'Shipping', 'woo-stripe-payment' ),
|
402 |
+
'pending' => false,
|
403 |
+
'amount' => wc_stripe_add_number_precision( $incl_tax ? $cart->shipping_total + $cart->shipping_tax_total : $cart->shipping_total ),
|
404 |
+
);
|
405 |
+
}
|
406 |
+
|
407 |
+
// fees
|
408 |
+
foreach ( $cart->get_fees() as $fee ) {
|
409 |
+
$items[] = array(
|
410 |
+
'label' => $fee->name,
|
411 |
+
'pending' => false,
|
412 |
+
'amount' => wc_stripe_add_number_precision( $incl_tax ? $fee->total + $fee->tax : $fee->total ),
|
413 |
+
);
|
414 |
+
}
|
415 |
+
// coupons
|
416 |
+
if ( $cart->discount_cart != 0 ) {
|
417 |
+
$items[] = array(
|
418 |
+
'label' => __( 'Discount', 'woo-stripe-payment' ),
|
419 |
+
'pending' => false,
|
420 |
+
'amount' => wc_stripe_add_number_precision( - 1 * abs( $incl_tax ? $cart->discount_cart + $cart->discount_cart_tax : $cart->discount_cart ) ),
|
421 |
+
);
|
422 |
+
}
|
423 |
+
|
424 |
+
if ( ! $incl_tax && wc_tax_enabled() ) {
|
425 |
+
$item = array(
|
426 |
+
'label' => __( 'Tax', 'woo-stripe-payment' ),
|
427 |
+
'pending' => false,
|
428 |
+
'amount' => wc_stripe_add_number_precision( $cart->get_taxes_total() ),
|
429 |
+
);
|
430 |
+
if ( 'itemized' === get_option( 'woocommerce_tax_total_display' ) ) {
|
431 |
+
if ( 0 < WC()->cart->get_taxes_total() ) {
|
432 |
+
$items[] = $item;
|
433 |
+
}
|
434 |
+
} else {
|
435 |
+
$items[] = $item;
|
436 |
+
}
|
437 |
+
}
|
438 |
+
} else {
|
439 |
+
$currency = $order->get_currency();
|
440 |
+
// add all order items
|
441 |
+
foreach ( $order->get_items() as $item ) {
|
442 |
+
/**
|
443 |
+
*
|
444 |
+
* @var WC_Order_Item_Product $item
|
445 |
+
*/
|
446 |
+
$qty = $item->get_quantity();
|
447 |
+
|
448 |
+
$items[] = array(
|
449 |
+
'label' => $qty > 1 ? sprintf( '%s X %s', $item->get_name(), $qty ) : $item->get_name(),
|
450 |
+
'pending' => false,
|
451 |
+
'amount' => wc_stripe_add_number_precision( $item->get_subtotal(), $currency ),
|
452 |
+
);
|
453 |
+
}
|
454 |
+
// shipping total
|
455 |
+
if ( $order->get_shipping_total() ) {
|
456 |
+
$items[] = array(
|
457 |
+
'label' => __( 'Shipping', 'woo-stripe-payment' ),
|
458 |
+
'pending' => false,
|
459 |
+
'amount' => wc_stripe_add_number_precision( $order->get_shipping_total(), $currency ),
|
460 |
+
);
|
461 |
+
}
|
462 |
+
// discount total
|
463 |
+
if ( $order->get_total_discount() ) {
|
464 |
+
$items[] = array(
|
465 |
+
'label' => __( 'Discount', 'woo-stripe-payment' ),
|
466 |
+
'pending' => false,
|
467 |
+
'amount' => wc_stripe_add_number_precision( $order->get_total_discount(), $currency ),
|
468 |
+
);
|
469 |
+
}
|
470 |
+
if ( $order->get_fees() ) {
|
471 |
+
$fee_total = 0;
|
472 |
+
foreach ( $order->get_fees() as $fee ) {
|
473 |
+
$fee_total += $fee->get_total();
|
474 |
+
}
|
475 |
+
$items[] = array(
|
476 |
+
'label' => __( 'Fees', 'woo-stripe-payment' ),
|
477 |
+
'pending' => false,
|
478 |
+
'amount' => wc_stripe_add_number_precision( $fee_total, $currency ),
|
479 |
+
);
|
480 |
+
}
|
481 |
+
// tax total
|
482 |
+
if ( $order->get_total_tax() ) {
|
483 |
+
$items[] = array(
|
484 |
+
'label' => __( 'Tax', 'woocommerce' ),
|
485 |
+
'pending' => false,
|
486 |
+
'amount' => wc_stripe_add_number_precision( $order->get_total_tax(), $currency ),
|
487 |
+
);
|
488 |
+
}
|
489 |
+
}
|
490 |
+
$items = apply_filters( 'wc_stripe_get_display_items', $items, $order );
|
491 |
+
|
492 |
+
return $encode ? htmlspecialchars( wp_json_encode( $items ) ) : $items;
|
493 |
+
}
|
494 |
+
|
495 |
+
/**
|
496 |
+
*
|
497 |
+
* @param bool $encode
|
498 |
+
* @param WC_Order $order
|
499 |
+
*
|
500 |
+
* @return mixed
|
501 |
+
* @package Stripe/Functions
|
502 |
+
* @since 3.0.0
|
503 |
+
*/
|
504 |
+
function wc_stripe_get_shipping_options( $encode = false, $order = null ) {
|
505 |
+
$methods = array();
|
506 |
+
$incl_tax = wc_stripe_display_prices_including_tax();
|
507 |
+
if ( ! $order ) {
|
508 |
+
$ids = array();
|
509 |
+
$chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods', array() );
|
510 |
+
$packages = WC()->shipping()->get_packages();
|
511 |
+
foreach ( $packages as $i => $package ) {
|
512 |
+
foreach ( $package['rates'] as $rate ) {
|
513 |
+
/**
|
514 |
+
*
|
515 |
+
* @var WC_Shipping_Rate $rate
|
516 |
+
*/
|
517 |
+
$method = array(
|
518 |
+
'id' => sprintf( '%s:%s', $i, $rate->id ),
|
519 |
+
'label' => sprintf( '%s', esc_attr( $rate->get_label() ) ),
|
520 |
+
'detail' => '',
|
521 |
+
'amount' => wc_stripe_add_number_precision( $incl_tax ? $rate->cost + $rate->get_shipping_tax() : $rate->cost ),
|
522 |
+
);
|
523 |
+
if ( $incl_tax ) {
|
524 |
+
if ( $rate->get_shipping_tax() > 0 && ! wc_prices_include_tax() ) {
|
525 |
+
$method['detail'] = WC()->countries->inc_tax_or_vat();
|
526 |
+
}
|
527 |
+
} else {
|
528 |
+
if ( $rate->get_shipping_tax() > 0 && wc_prices_include_tax() ) {
|
529 |
+
$method['detail'] = WC()->countries->ex_tax_or_vat();
|
530 |
+
}
|
531 |
+
}
|
532 |
+
$methods[] = $method;
|
533 |
+
$ids[] = $rate->id;
|
534 |
+
}
|
535 |
+
// Stripe always shows the first shipping option as selected. Make sure the chosen method
|
536 |
+
// is first in the array.
|
537 |
+
if ( isset( $chosen_shipping_methods[ $i ] ) ) {
|
538 |
+
$index = array_search( $chosen_shipping_methods[ $i ], $ids );
|
539 |
+
if ( $index != 0 ) {
|
540 |
+
$temp = $methods[0];
|
541 |
+
$methods[0] = $methods[ $index ];
|
542 |
+
$methods[ $index ] = $temp;
|
543 |
+
}
|
544 |
+
}
|
545 |
+
}
|
546 |
+
/*
|
547 |
+
* if (empty ( $methods )) {
|
548 |
+
* // GPay does not like empty shipping methods. Make a temporary one;
|
549 |
+
* $methods[] = [ 'id' => 'default',
|
550 |
+
* 'label' => __ ( 'Waiting...', 'woo-stripe-payment' ),
|
551 |
+
* 'detail' => __ ( 'loading shipping methods...', 'woo-stripe-payment' ),
|
552 |
+
* 'amount' => 0
|
553 |
+
* ];
|
554 |
+
* }
|
555 |
+
*/
|
556 |
+
}
|
557 |
+
/**
|
558 |
+
*
|
559 |
+
* @param array $methods
|
560 |
+
* @param WC_Order $orer
|
561 |
+
*/
|
562 |
+
$methods = apply_filters( 'wc_stripe_get_shipping_options', $methods, $order );
|
563 |
+
|
564 |
+
return $encode ? htmlspecialchars( wp_json_encode( $methods ) ) : $methods;
|
565 |
+
}
|
566 |
+
|
567 |
+
/**
|
568 |
+
*
|
569 |
+
* @since 3.0.0
|
570 |
+
* @package Stripe/Functions
|
571 |
+
*/
|
572 |
+
function wc_stripe_set_checkout_error() {
|
573 |
+
add_action( 'woocommerce_after_template_part', 'wc_stripe_output_checkout_error' );
|
574 |
+
}
|
575 |
+
|
576 |
+
/**
|
577 |
+
*
|
578 |
+
* @param string $template_name
|
579 |
+
*
|
580 |
+
* @package Stripe/Functions
|
581 |
+
* @since 3.0.0
|
582 |
+
*/
|
583 |
+
function wc_stripe_output_checkout_error( $template_name ) {
|
584 |
+
if ( $template_name === 'notices/error.php' && is_ajax() ) {
|
585 |
+
echo '<input type="hidden" id="wc_stripe_checkout_error" value="true"/>';
|
586 |
+
remove_action( 'woocommerce_after_template_part', 'wc_stripe_output_checkout_error' );
|
587 |
+
add_filter( 'wp_kses_allowed_html', 'wc_stripe_add_allowed_html', 10, 2 );
|
588 |
+
}
|
589 |
+
}
|
590 |
+
|
591 |
+
/**
|
592 |
+
*
|
593 |
+
* @since 3.0.0
|
594 |
+
* @package Stripe/Functions
|
595 |
+
*/
|
596 |
+
function wc_stripe_add_allowed_html( $tags, $context ) {
|
597 |
+
if ( $context === 'post' ) {
|
598 |
+
$tags['input'] = array(
|
599 |
+
'id' => true,
|
600 |
+
'type' => true,
|
601 |
+
'value' => true,
|
602 |
+
);
|
603 |
+
}
|
604 |
+
|
605 |
+
return $tags;
|
606 |
+
}
|
607 |
+
|
608 |
+
/**
|
609 |
+
* Save WCS meta data when it's changed in the admin section.
|
610 |
+
* By default WCS saves the
|
611 |
+
* payment method title as the gateway title. This method saves the payment method title in
|
612 |
+
* a human readable format suitable for the frontend.
|
613 |
+
*
|
614 |
+
* @param int $post_id
|
615 |
+
* @param WP_Post $post
|
616 |
+
*
|
617 |
+
* @package Stripe/Functions
|
618 |
+
*/
|
619 |
+
function wc_stripe_process_shop_subscription_meta( $post_id, $post ) {
|
620 |
+
$subscription = wcs_get_subscription( $post_id );
|
621 |
+
$gateway_id = $subscription->get_payment_method();
|
622 |
+
$gateways = WC()->payment_gateways()->payment_gateways();
|
623 |
+
if ( isset( $gateways[ $gateway_id ] ) ) {
|
624 |
+
$gateway = $gateways[ $gateway_id ];
|
625 |
+
if ( $gateway instanceof WC_Payment_Gateway_Stripe ) {
|
626 |
+
$token = $gateway->get_token( $subscription->get_meta( WC_Stripe_Constants::PAYMENT_METHOD_TOKEN ), $subscription->get_customer_id() );
|
627 |
+
if ( $token ) {
|
628 |
+
$subscription->set_payment_method_title( $token->get_payment_method_title() );
|
629 |
+
$subscription->save();
|
630 |
+
}
|
631 |
+
}
|
632 |
+
}
|
633 |
+
}
|
634 |
+
|
635 |
+
/**
|
636 |
+
* Filter the WC payment gateways based on criteria specific to Stripe functionality.
|
637 |
+
*
|
638 |
+
* <strong>Example:</strong> on add payment method page, only show the CC gateway for Stripe.
|
639 |
+
*
|
640 |
+
* @param WC_Payment_Gateway[] $gateways
|
641 |
+
*
|
642 |
+
* @package Stripe/Functions
|
643 |
+
* @since 3.0.0
|
644 |
+
*/
|
645 |
+
function wc_stripe_available_payment_gateways( $gateways ) {
|
646 |
+
global $wp;
|
647 |
+
if ( is_add_payment_method_page() && ! isset( $wp->query_vars['payment-methods'] ) ) {
|
648 |
+
foreach ( $gateways as $gateway ) {
|
649 |
+
if ( $gateway instanceof WC_Payment_Gateway_Stripe ) {
|
650 |
+
if ( 'stripe_cc' !== $gateway->id ) {
|
651 |
+
unset( $gateways[ $gateway->id ] );
|
652 |
+
}
|
653 |
+
}
|
654 |
+
}
|
655 |
+
}
|
656 |
+
|
657 |
+
return $gateways;
|
658 |
+
}
|
659 |
+
|
660 |
+
/**
|
661 |
+
*
|
662 |
+
* @return array
|
663 |
+
* @package Stripe/Functions
|
664 |
+
* @since 3.0.0
|
665 |
+
*/
|
666 |
+
function wc_stripe_get_local_payment_params() {
|
667 |
+
global $wp;
|
668 |
+
$data = array();
|
669 |
+
$gateways = WC()->payment_gateways()->payment_gateways();
|
670 |
+
foreach ( $gateways as $gateway ) {
|
671 |
+
if ( $gateway instanceof WC_Payment_Gateway_Stripe_Local_Payment && $gateway->is_available() ) {
|
672 |
+
$data['gateways'][ $gateway->id ] = $gateway->get_localized_params();
|
673 |
+
if ( isset( $wp->query_vars['order-pay'] ) ) {
|
674 |
+
$data['gateways'][ $gateway->id ]['order_id'] = $wp->query_vars['order-pay'];
|
675 |
+
}
|
676 |
+
}
|
677 |
+
}
|
678 |
+
$data['api_key'] = wc_stripe_get_publishable_key();
|
679 |
+
|
680 |
+
return $data;
|
681 |
+
}
|
682 |
+
|
683 |
+
/**
|
684 |
+
*
|
685 |
+
* @param array $gateways
|
686 |
+
*
|
687 |
+
* @return WC_Payment_Gateway[]
|
688 |
+
* @package Stripe/Functions
|
689 |
+
* @since 3.0.0
|
690 |
+
*/
|
691 |
+
function wc_stripe_get_available_local_gateways( $gateways ) {
|
692 |
+
foreach ( $gateways as $gateway ) {
|
693 |
+
if ( $gateway instanceof WC_Payment_Gateway_Stripe_Local_Payment ) {
|
694 |
+
if ( ! $gateway->is_local_payment_available() ) {
|
695 |
+
unset( $gateways[ $gateway->id ] );
|
696 |
+
}
|
697 |
+
}
|
698 |
+
}
|
699 |
+
|
700 |
+
return $gateways;
|
701 |
+
}
|
702 |
+
|
703 |
+
/**
|
704 |
+
*
|
705 |
+
* @param string|int $key
|
706 |
+
*
|
707 |
+
* @package Stripe/Functions
|
708 |
+
* @since 3.0.0
|
709 |
+
*/
|
710 |
+
function wc_stripe_set_idempotency_key( $key ) {
|
711 |
+
global $wc_stripe_idempotency_key;
|
712 |
+
$wc_stripe_idempotency_key = $key;
|
713 |
+
}
|
714 |
+
|
715 |
+
/**
|
716 |
+
*
|
717 |
+
* @return mixed
|
718 |
+
* @package Stripe/Functions
|
719 |
+
* @since 3.0.0
|
720 |
+
*/
|
721 |
+
function wc_stripe_get_idempotency_key() {
|
722 |
+
global $wc_stripe_idempotency_key;
|
723 |
+
|
724 |
+
return $wc_stripe_idempotency_key;
|
725 |
+
}
|
726 |
+
|
727 |
+
/**
|
728 |
+
*
|
729 |
+
* @param array $options
|
730 |
+
*
|
731 |
+
* @return array
|
732 |
+
* @since 3.0.0
|
733 |
+
* @package Stripe/Functions
|
734 |
+
*/
|
735 |
+
function wc_stripe_api_options( $options ) {
|
736 |
+
$key = wc_stripe_get_idempotency_key();
|
737 |
+
if ( $key ) {
|
738 |
+
$options['idempotency_key'] = $key;
|
739 |
+
}
|
740 |
+
|
741 |
+
return $options;
|
742 |
+
}
|
743 |
+
|
744 |
+
/**
|
745 |
+
*
|
746 |
+
* @param string $order_status
|
747 |
+
* @param int $order_id
|
748 |
+
* @param WC_Order $order
|
749 |
+
*
|
750 |
+
* @package Stripe/Functions
|
751 |
+
* @since 3.0.0
|
752 |
+
*/
|
753 |
+
function wc_stripe_payment_complete_order_status( $order_status, $order_id, $order ) {
|
754 |
+
if ( is_checkout() && $order->get_payment_method() ) {
|
755 |
+
$gateway = WC()->payment_gateways()->payment_gateways()[ $order->get_payment_method() ];
|
756 |
+
if ( $gateway instanceof WC_Payment_Gateway_Stripe && 'default' !== $gateway->get_option( 'order_status' ) ) {
|
757 |
+
$order_status = $gateway->get_option( 'order_status' );
|
758 |
+
}
|
759 |
+
}
|
760 |
+
|
761 |
+
return $order_status;
|
762 |
+
}
|
763 |
+
|
764 |
+
/**
|
765 |
+
* Converts the amount to cents.
|
766 |
+
* Stripe processes all requests in cents.
|
767 |
+
*
|
768 |
+
* @param float $value
|
769 |
+
* @param string $currency
|
770 |
+
* @param string $round
|
771 |
+
*
|
772 |
+
* @return number
|
773 |
+
* @package Stripe/Functions
|
774 |
+
* @since 3.0.0
|
775 |
+
*/
|
776 |
+
function wc_stripe_add_number_precision( $value, $currency = '', $round = true ) {
|
777 |
+
if ( ! is_numeric( $value ) ) {
|
778 |
+
$value = 0;
|
779 |
+
}
|
780 |
+
$currency = empty( $currency ) ? get_woocommerce_currency() : $currency;
|
781 |
+
$currencies = wc_stripe_get_currencies();
|
782 |
+
$exp = isset( $currencies[ $currency ] ) ? $currencies[ $currency ] : 2;
|
783 |
+
$cent_precision = pow( 10, $exp );
|
784 |
+
$value = $value * $cent_precision;
|
785 |
+
$value = $round ? round( $value, wc_get_rounding_precision() - wc_get_price_decimals() ) : $value;
|
786 |
+
|
787 |
+
if ( is_numeric( $value ) && floor( $value ) != $value ) {
|
788 |
+
// there are some decimal points that need to be removed.
|
789 |
+
$value = round( $value );
|
790 |
+
}
|
791 |
+
|
792 |
+
return $value;
|
793 |
+
}
|
794 |
+
|
795 |
+
/**
|
796 |
+
* Return an array of credit card forms.
|
797 |
+
*
|
798 |
+
* @return mixed
|
799 |
+
* @package Stripe/Functions
|
800 |
+
* @since 3.0.0
|
801 |
+
*/
|
802 |
+
function wc_stripe_get_custom_forms() {
|
803 |
+
return apply_filters(
|
804 |
+
'wc_stripe_get_custom_forms',
|
805 |
+
array(
|
806 |
+
'bootstrap' => array(
|
807 |
+
'template' => 'cc-forms/bootstrap.php',
|
808 |
+
'label' => __( 'Bootstrap form', 'woo-stripe-payment' ),
|
809 |
+
'cardBrand' => wc_stripe()->assets_url( 'img/card_brand2.svg' ),
|
810 |
+
'elementStyles' => array(
|
811 |
+
'base' => array(
|
812 |
+
'color' => '#495057',
|
813 |
+
'fontWeight' => 300,
|
814 |
+
'fontFamily' => 'Roboto, sans-serif, Source Code Pro, Consolas, Menlo, monospace',
|
815 |
+
'fontSize' => '16px',
|
816 |
+
'fontSmoothing' => 'antialiased',
|
817 |
+
'::placeholder' => array(
|
818 |
+
'color' => '#fff',
|
819 |
+
'fontSize' => '0px',
|
820 |
+
),
|
821 |
+
':-webkit-autofill' => array( 'color' => '#495057' ),
|
822 |
+
),
|
823 |
+
'invalid' => array(
|
824 |
+
'color' => '#E25950',
|
825 |
+
'::placeholder' => array( 'color' => '#757575' ),
|
826 |
+
),
|
827 |
+
),
|
828 |
+
'elementOptions' => array(
|
829 |
+
'fonts' => array( array( 'cssSrc' => 'https://fonts.googleapis.com/css?family=Source+Code+Pro' ) ),
|
830 |
+
),
|
831 |
+
),
|
832 |
+
'simple' => array(
|
833 |
+
'template' => 'cc-forms/simple.php',
|
834 |
+
'label' => __( 'Simple form', 'woo-stripe-payment' ),
|
835 |
+
'cardBrand' => wc_stripe()->assets_url( 'img/card_brand2.svg' ),
|
836 |
+
'elementStyles' => array(
|
837 |
+
'base' => array(
|
838 |
+
'color' => '#32325D',
|
839 |
+
'fontWeight' => 500,
|
840 |
+
'fontFamily' => 'Source Code Pro, Consolas, Menlo, monospace',
|
841 |
+
'fontSize' => '16px',
|
842 |
+
'fontSmoothing' => 'antialiased',
|
843 |
+
'::placeholder' => array( 'color' => '#CFD7DF' ),
|
844 |
+
':-webkit-autofill' => array( 'color' => '#32325D' ),
|
845 |
+
),
|
846 |
+
'invalid' => array(
|
847 |
+
'color' => '#E25950',
|
848 |
+
'::placeholder' => array( 'color' => '#FFCCA5' ),
|
849 |
+
),
|
850 |
+
),
|
851 |
+
'elementOptions' => array(
|
852 |
+
'fonts' => array( array( 'cssSrc' => 'https://fonts.googleapis.com/css?family=Source+Code+Pro' ) ),
|
853 |
+
),
|
854 |
+
),
|
855 |
+
'minimalist' => array(
|
856 |
+
'template' => 'cc-forms/minimalist.php',
|
857 |
+
'label' => __( 'Minimalist form', 'woo-stripe-payment' ),
|
858 |
+
'cardBrand' => wc_stripe()->assets_url( 'img/card_brand2.svg' ),
|
859 |
+
'elementStyles' => array(
|
860 |
+
'base' => array(
|
861 |
+
'color' => '#495057',
|
862 |
+
'fontWeight' => 300,
|
863 |
+
'fontFamily' => 'Roboto, sans-serif, Source Code Pro, Consolas, Menlo, monospace',
|
864 |
+
'fontSize' => '30px',
|
865 |
+
'fontSmoothing' => 'antialiased',
|
866 |
+
'::placeholder' => array(
|
867 |
+
'color' => '#fff',
|
868 |
+
'fontSize' => '0px',
|
869 |
+
),
|
870 |
+
':-webkit-autofill' => array( 'color' => '#495057' ),
|
871 |
+
),
|
872 |
+
'invalid' => array(
|
873 |
+
'color' => '#495057',
|
874 |
+
'::placeholder' => array( 'color' => '#495057' ),
|
875 |
+
),
|
876 |
+
),
|
877 |
+
'elementOptions' => array(
|
878 |
+
'fonts' => array( array( 'cssSrc' => 'https://fonts.googleapis.com/css?family=Source+Code+Pro' ) ),
|
879 |
+
),
|
880 |
+
),
|
881 |
+
'inline' => array(
|
882 |
+
'template' => 'cc-forms/inline.php',
|
883 |
+
'label' => __( 'Inline Form', 'woo-stripe-payment' ),
|
884 |
+
'cardBrand' => wc_stripe()->assets_url( 'img/card_brand.svg' ),
|
885 |
+
'elementStyles' => array(
|
886 |
+
'base' => array(
|
887 |
+
'color' => '#819efc',
|
888 |
+
'fontWeight' => 600,
|
889 |
+
'fontFamily' => 'Roboto, Open Sans, Segoe UI, sans-serif',
|
890 |
+
'fontSize' => '16px',
|
891 |
+
'fontSmoothing' => 'antialiased',
|
892 |
+
':focus' => array( 'color' => '#819efc' ),
|
893 |
+
'::placeholder' => array( 'color' => '#87BBFD' ),
|
894 |
+
':focus::placeholder' => array( 'color' => '#CFD7DF' ),
|
895 |
+
':-webkit-autofill' => array( 'color' => '#819efc' ),
|
896 |
+
),
|
897 |
+
'invalid' => array( 'color' => '#f99393' ),
|
898 |
+
),
|
899 |
+
'elementOptions' => array(
|
900 |
+
'fonts' => array( array( 'cssSrc' => 'https://fonts.googleapis.com/css?family=Roboto' ) ),
|
901 |
+
),
|
902 |
+
),
|
903 |
+
'rounded' => array(
|
904 |
+
'template' => 'cc-forms/round.php',
|
905 |
+
'label' => __( 'Rounded Form', 'woo-stripe-payment' ),
|
906 |
+
'cardBrand' => wc_stripe()->assets_url( 'img/card_brand.svg' ),
|
907 |
+
'elementStyles' => array(
|
908 |
+
'base' => array(
|
909 |
+
'color' => '#fff',
|
910 |
+
'fontWeight' => 600,
|
911 |
+
'fontFamily' => 'Quicksand, Open Sans, Segoe UI, sans-serif',
|
912 |
+
'fontSize' => '16px',
|
913 |
+
'fontSmoothing' => 'antialiased',
|
914 |
+
':focus' => array( 'color' => '#424770' ),
|
915 |
+
'::placeholder' => array( 'color' => '#9BACC8' ),
|
916 |
+
':focus::placeholder' => array( 'color' => '#CFD7DF' ),
|
917 |
+
':-webkit-autofill' => array( 'color' => '#fff' ),
|
918 |
+
),
|
919 |
+
'invalid' => array(
|
920 |
+
'color' => '#fff',
|
921 |
+
':focus' => array( 'color' => '#FA755A' ),
|
922 |
+
'::placeholder' => array( 'color' => '#FFCCA5' ),
|
923 |
+
),
|
924 |
+
),
|
925 |
+
'elementOptions' => array(
|
926 |
+
'fonts' => array( array( 'cssSrc' => 'https://fonts.googleapis.com/css?family=Quicksand' ) ),
|
927 |
+
),
|
928 |
+
),
|
929 |
+
)
|
930 |
+
);
|
931 |
+
}
|
932 |
+
|
933 |
+
/**
|
934 |
+
*
|
935 |
+
* @param WC_Order $order
|
936 |
+
*
|
937 |
+
* @since 3.0.0
|
938 |
+
* @package Stripe/Functions
|
939 |
+
*/
|
940 |
+
function wc_stripe_order_has_shipping_address( $order ) {
|
941 |
+
if ( method_exists( $order, 'has_shipping_address' ) ) {
|
942 |
+
return $order->has_shipping_address();
|
943 |
+
} else {
|
944 |
+
return $order->get_shipping_address_1() || $order->get_shipping_address_2();
|
945 |
+
}
|
946 |
+
}
|
947 |
+
|
948 |
+
/**
|
949 |
+
*
|
950 |
+
* @since 3.0.0
|
951 |
+
* @package Stripe/Functions
|
952 |
+
*/
|
953 |
+
function wc_stripe_display_prices_including_tax() {
|
954 |
+
$cart = WC()->cart;
|
955 |
+
if ( method_exists( $cart, 'display_prices_including_tax' ) ) {
|
956 |
+
return $cart->display_prices_including_tax();
|
957 |
+
}
|
958 |
+
|
959 |
+
return 'incl' == $cart->tax_display_cart && ( WC()->customer && ! WC()->customer->is_vat_exempt() );
|
960 |
+
}
|
961 |
+
|
962 |
+
/**
|
963 |
+
* Return true if the WC pre-orders plugin is active
|
964 |
+
*
|
965 |
+
* @since 3.0.1
|
966 |
+
* @package Stripe/Functions
|
967 |
+
*/
|
968 |
+
function wc_stripe_pre_orders_active() {
|
969 |
+
return class_exists( 'WC_Pre_Orders' );
|
970 |
+
}
|
971 |
+
|
972 |
+
/**
|
973 |
+
*
|
974 |
+
* @param string $source_id
|
975 |
+
*
|
976 |
+
* @package Stripe/Functions
|
977 |
+
* @since 3.0.5
|
978 |
+
*/
|
979 |
+
function wc_stripe_get_order_from_source_id( $source_id ) {
|
980 |
+
global $wpdb;
|
981 |
+
$order_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} AS posts LEFT JOIN {$wpdb->postmeta} AS meta ON posts.ID = meta.post_id WHERE meta.meta_key = %s AND meta.meta_value = %s LIMIT 1", '_stripe_source_id', $source_id ) );
|
982 |
+
|
983 |
+
return wc_get_order( $order_id );
|
984 |
+
}
|
985 |
+
|
986 |
+
/**
|
987 |
+
*
|
988 |
+
* @param string $transaction_id
|
989 |
+
*
|
990 |
+
* @return WC_Order|WC_Refund|boolean|WC_Order_Refund
|
991 |
+
* @since 3.0.5
|
992 |
+
* @package Stripe/Functions
|
993 |
+
*/
|
994 |
+
function wc_stripe_get_order_from_transaction( $transaction_id ) {
|
995 |
+
global $wpdb;
|
996 |
+
$order_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} AS posts LEFT JOIN {$wpdb->postmeta} AS meta ON posts.ID = meta.post_id WHERE meta.meta_key = %s AND meta.meta_value = %s LIMIT 1", '_transaction_id', $transaction_id ) );
|
997 |
+
|
998 |
+
return wc_get_order( $order_id );
|
999 |
+
}
|
1000 |
+
|
1001 |
+
/**
|
1002 |
+
* Stash the WC cart contents in the session and empty it's contents.
|
1003 |
+
* If $product_cart is true, add the stashed product(s)
|
1004 |
+
* to the cart.
|
1005 |
+
*
|
1006 |
+
* @param WC_Cart $cart
|
1007 |
+
*
|
1008 |
+
* @package Stripe/Functions
|
1009 |
+
* @todo Maybe empty cart silently so actions are not triggered that cause session data to be removed
|
1010 |
+
* from 3rd party plugins.
|
1011 |
+
*
|
1012 |
+
* @since 3.0.6
|
1013 |
+
*/
|
1014 |
+
function wc_stripe_stash_cart( $cart, $product_cart = true ) {
|
1015 |
+
$data = WC()->session->get( 'wc_stripe_cart', array() );
|
1016 |
+
$data['cart'] = $cart->get_cart_for_session();
|
1017 |
+
WC()->session->set( 'wc_stripe_cart', $data );
|
1018 |
+
$cart->empty_cart( false );
|
1019 |
+
if ( $product_cart && isset( $data['product_cart'] ) ) {
|
1020 |
+
foreach ( $data['product_cart'] as $cart_item ) {
|
1021 |
+
$cart->add_to_cart( $cart_item['product_id'], $cart_item['quantity'], $cart_item['variation_id'] );
|
1022 |
+
}
|
1023 |
+
}
|
1024 |
+
}
|
1025 |
+
|
1026 |
+
/**
|
1027 |
+
*
|
1028 |
+
* @param number $product_id
|
1029 |
+
* @param number $qty
|
1030 |
+
* @param number $variation_id
|
1031 |
+
*
|
1032 |
+
* @package Stripe/Functions
|
1033 |
+
* @since 3.0.6
|
1034 |
+
*/
|
1035 |
+
function wc_stripe_stash_product_cart( $cart ) {
|
1036 |
+
$data = WC()->session->get( 'wc_stripe_cart', array() );
|
1037 |
+
$data['product_cart'] = $cart->get_cart_for_session();
|
1038 |
+
WC()->session->set( 'wc_stripe_cart', $data );
|
1039 |
+
WC()->cart->set_session();
|
1040 |
+
}
|
1041 |
+
|
1042 |
+
/**
|
1043 |
+
*
|
1044 |
+
* @param WC_Cart $cart
|
1045 |
+
*
|
1046 |
+
* @package Stripe/Functions
|
1047 |
+
* @since 3.0.6
|
1048 |
+
*/
|
1049 |
+
function wc_stripe_restore_cart( $cart ) {
|
1050 |
+
$data = WC()->session->get( 'wc_stripe_cart', array( 'cart' => array() ) );
|
1051 |
+
$cart->cart_contents = $data['cart'];
|
1052 |
+
$cart->set_session();
|
1053 |
+
}
|
1054 |
+
|
1055 |
+
/**
|
1056 |
+
*
|
1057 |
+
* @since 3.0.6
|
1058 |
+
* @package Stripe/Functions
|
1059 |
+
*/
|
1060 |
+
function wc_stripe_restore_cart_after_product_checkout() {
|
1061 |
+
wc_stripe_restore_cart( WC()->cart );
|
1062 |
+
$cart_contents = array();
|
1063 |
+
foreach ( WC()->cart->get_cart() as $key => $cart_item ) {
|
1064 |
+
$cart_item['data'] = wc_get_product( $cart_item['variation_id'] ? $cart_item['variation_id'] : $cart_item['product_id'] );
|
1065 |
+
$cart_contents[ $key ] = $cart_item;
|
1066 |
+
}
|
1067 |
+
WC()->cart->cart_contents = $cart_contents;
|
1068 |
+
WC()->cart->calculate_totals();
|
1069 |
+
}
|
1070 |
+
|
1071 |
+
/**
|
1072 |
+
*
|
1073 |
+
* @param WC_Payment_Token[] $tokens
|
1074 |
+
* @param int $user_id
|
1075 |
+
* @param string $gateway_id
|
1076 |
+
*
|
1077 |
+
* @return WC_Payment_Token[]
|
1078 |
+
* @since 3.1.0
|
1079 |
+
* @package Stripe/Functions
|
1080 |
+
*/
|
1081 |
+
function wc_stripe_get_customer_payment_tokens( $tokens, $user_id, $gateway_id ) {
|
1082 |
+
foreach ( $tokens as $idx => $token ) {
|
1083 |
+
if ( $token instanceof WC_Payment_Token_Stripe ) {
|
1084 |
+
$mode = wc_stripe_mode();
|
1085 |
+
if ( $token->get_environment() != $mode ) {
|
1086 |
+
unset( $tokens[ $idx ] );
|
1087 |
+
}
|
1088 |
+
}
|
1089 |
+
}
|
1090 |
+
|
1091 |
+
return $tokens;
|
1092 |
+
}
|
1093 |
+
|
1094 |
+
/**
|
1095 |
+
*
|
1096 |
+
* @param array $labels
|
1097 |
+
*
|
1098 |
+
* @return string
|
1099 |
+
* @since 3.1.0
|
1100 |
+
* @package Stripe/Functions
|
1101 |
+
*/
|
1102 |
+
function wc_stripe_credit_card_labels( $labels ) {
|
1103 |
+
if ( ! isset( $labels['amex'] ) ) {
|
1104 |
+
$labels['amex'] = __( 'Amex', 'woocommerce' );
|
1105 |
+
}
|
1106 |
+
|
1107 |
+
return $labels;
|
1108 |
+
}
|
1109 |
+
|
1110 |
+
/**
|
1111 |
+
* Return an array of Stripe error messages.
|
1112 |
+
*
|
1113 |
+
* @since 3.1.1
|
1114 |
+
* @package Stripe/Functions
|
1115 |
+
*/
|
1116 |
+
function wc_stripe_get_error_messages() {
|
1117 |
+
return apply_filters(
|
1118 |
+
'wc_stripe_get_error_messages',
|
1119 |
+
array(
|
1120 |
+
'stripe_cc_generic' => __( 'There was an error processing your credit card.', 'woo-stripe-payment' ),
|
1121 |
+
'incomplete_number' => __( 'Your card number is incomplete.', 'woo-stripe-payment' ),
|
1122 |
+
'incorrect_number' => __( 'The card number is incorrect. Check the card\'s number or use a different card.', 'woo-stripe-payment' ),
|
1123 |
+
'incorrect_cvc' => __( 'The card\'s security code is incorrect. Check the card\'s security code or use a different card.', 'woo-stripe-payment' ),
|
1124 |
+
'incorrect_zip' => __( 'The card\'s ZIP code is incorrect. Check the card\'s ZIP code or use a different card.', 'woo-stripe-payment' ),
|
1125 |
+
'invalid_number' => __( 'The card number is invalid. Check the card details or use a different card.', 'woo-stripe-payment' ),
|
1126 |
+
'invalid_characters' => __( 'This value provided to the field contains characters that are unsupported by the field.', 'woo-stripe-payment' ),
|
1127 |
+
'invalid_cvc' => __( 'The card\'s security code is invalid. Check the card\'s security code or use a different card.', 'woo-stripe-payment' ),
|
1128 |
+
'invalid_expiry_month' => __( 'The card\'s expiration month is incorrect. Check the expiration date or use a different card.', 'woo-stripe-payment' ),
|
1129 |
+
'invalid_expiry_year' => __( 'The card\'s expiration year is incorrect. Check the expiration date or use a different card.', 'woo-stripe-payment' ),
|
1130 |
+
'invalid_number' => __( 'The card number is invalid. Check the card details or use a different card.', 'woo-stripe-payment' ),
|
1131 |
+
'incorrect_address' => __( 'The card\'s address is incorrect. Check the card\'s address or use a different card.', 'woo-stripe-payment' ),
|
1132 |
+
'expired_card' => __( 'The card has expired. Check the expiration date or use a different card.', 'woo-stripe-payment' ),
|
1133 |
+
'card_declined' => __( 'The card has been declined.', 'woo-stripe-payment' ),
|
1134 |
+
'invalid_expiry_year_past' => __( 'Your card\'s expiration year is in the past.', 'woo-stripe-payment' ),
|
1135 |
+
'account_number_invalid' => __( 'The bank account number provided is invalid (e.g., missing digits). Bank account information varies from country to country. We recommend creating validations in your entry forms based on the bank account formats we provide.', 'woo-stripe-payment' ),
|
1136 |
+
'amount_too_large' => __( 'The specified amount is greater than the maximum amount allowed. Use a lower amount and try again.', 'woo-stripe-payment' ),
|
1137 |
+
'amount_too_small' => __( 'The specified amount is less than the minimum amount allowed. Use a higher amount and try again.', 'woo-stripe-payment' ),
|
1138 |
+
'authentication_required' => __( 'The payment requires authentication to proceed. If your customer is off session, notify your customer to return to your application and complete the payment. If you provided the error_on_requires_action parameter, then your customer should try another card that does not require authentication.', 'woo-stripe-payment' ),
|
1139 |
+
'balance_insufficient' => __( 'The transfer or payout could not be completed because the associated account does not have a sufficient balance available. Create a new transfer or payout using an amount less than or equal to the account\'s available balance.', 'woo-stripe-payment' ),
|
1140 |
+
'bank_account_declined' => __( 'The bank account provided can not be used to charge, either because it is not verified yet or it is not supported.', 'woo-stripe-payment' ),
|
1141 |
+
'bank_account_exists' => __( 'The bank account provided already exists on the specified Customer object. If the bank account should also be attached to a different customer, include the correct customer ID when making the request again.', 'woo-stripe-payment' ),
|
1142 |
+
'bank_account_unusable' => __( 'The bank account provided cannot be used for payouts. A different bank account must be used.', 'woo-stripe-payment' ),
|
1143 |
+
'bank_account_unverified' => __( 'Your Connect platform is attempting to share an unverified bank account with a connected account.', 'woo-stripe-payment' ),
|
1144 |
+
'bank_account_verification_failed' => __( 'The bank account cannot be verified, either because the microdeposit amounts provided do not match the actual amounts, or because verification has failed too many times.', 'woo-stripe-payment' ),
|
1145 |
+
'card_decline_rate_limit_exceeded' => __( 'This card has been declined too many times. You can try to charge this card again after 24 hours. We suggest reaching out to your customer to make sure they have entered all of their information correctly and that there are no issues with their card.', 'woo-stripe-payment' ),
|
1146 |
+
'charge_already_captured' => __( 'The charge you\'re attempting to capture has already been captured. Update the request with an uncaptured charge ID.', 'woo-stripe-payment' ),
|
1147 |
+
'charge_already_refunded' => __( 'The charge you\'re attempting to refund has already been refunded. Update the request to use the ID of a charge that has not been refunded.', 'woo-stripe-payment' ),
|
1148 |
+
'charge_disputed' => __( 'The charge you\'re attempting to refund has been charged back. Check the disputes documentation to learn how to respond to the dispute.', 'woo-stripe-payment' ),
|
1149 |
+
'charge_exceeds_source_limit' => __( 'This charge would cause you to exceed your rolling-window processing limit for this source type. Please retry the charge later, or contact us to request a higher processing limit.', 'woo-stripe-payment' ),
|
1150 |
+
'charge_expired_for_capture' => __( 'The charge cannot be captured as the authorization has expired. Auth and capture charges must be captured within seven days.', 'woo-stripe-payment' ),
|
1151 |
+
'charge_invalid_parameter' => __( 'One or more provided parameters was not allowed for the given operation on the Charge. Check our API reference or the returned error message to see which values were not correct for that Charge.', 'woo-stripe-payment' ),
|
1152 |
+
'email_invalid' => __( 'The email address is invalid (e.g., not properly formatted). Check that the email address is properly formatted and only includes allowed characters.', 'woo-stripe-payment' ),
|
1153 |
+
'idempotency_key_in_use' => __( 'The idempotency key provided is currently being used in another request. This occurs if your integration is making duplicate requests simultaneously.', 'woo-stripe-payment' ),
|
1154 |
+
'invalid_charge_amount' => __( 'The specified amount is invalid. The charge amount must be a positive integer in the smallest currency unit, and not exceed the minimum or maximum amount.', 'woo-stripe-payment' ),
|
1155 |
+
'invalid_source_usage' => __( 'The source cannot be used because it is not in the correct state (e.g., a charge request is trying to use a source with a pending, failed, or consumed source). Check the status of the source you are attempting to use.', 'woo-stripe-payment' ),
|
1156 |
+
'missing' => __( 'Both a customer and source ID have been provided, but the source has not been saved to the customer. To create a charge for a customer with a specified source, you must first save the card details.', 'woo-stripe-payment' ),
|
1157 |
+
'postal_code_invalid' => __( 'The ZIP code provided was incorrect.', 'woo-stripe-payment' ),
|
1158 |
+
'processing_error' => __( 'An error occurred while processing the card. Try again later or with a different payment method.', 'woo-stripe-payment' ),
|
1159 |
+
'card_not_supported' => __( 'The card does not support this type of purchase.', 'woo-stripe-payment' ),
|
1160 |
+
'call_issuer' => __( 'The card has been declined for an unknown reason.', 'woo-stripe-payment' ),
|
1161 |
+
'card_velocity_exceeded' => __( 'The customer has exceeded the balance or credit limit available on their card.', 'woo-stripe-payment' ),
|
1162 |
+
'currency_not_supported' => __( 'The card does not support the specified currency.', 'woo-stripe-payment' ),
|
1163 |
+
'do_not_honor' => __( 'The card has been declined for an unknown reason.', 'woo-stripe-payment' ),
|
1164 |
+
'fraudulent' => __( 'The payment has been declined as Stripe suspects it is fraudulent.', 'woo-stripe-payment' ),
|
1165 |
+
'generic_decline' => __( 'The card has been declined for an unknown reason.', 'woo-stripe-payment' ),
|
1166 |
+
'incorrect_pin' => __( 'The PIN entered is incorrect. ', 'woo-stripe-payment' ),
|
1167 |
+
'insufficient_funds' => __( 'The card has insufficient funds to complete the purchase.', 'woo-stripe-payment' ),
|
1168 |
+
'empty_element' => __( 'Please select a payment method before proceeding.', 'woo-stripe-payment' ),
|
1169 |
+
'empty_element_sepa_debit' => __( 'Please enter your IBAN before proceeding.', 'woo-stripe-payment' ),
|
1170 |
+
'empty_element_ideal' => __(
|
1171 |
+
'Please select a bank before proceeding',
|
1172 |
+
'woo-stripe-payment'
|
1173 |
+
),
|
1174 |
+
)
|
1175 |
+
);
|
1176 |
+
}
|
1177 |
+
|
1178 |
+
/**
|
1179 |
+
* Return an array of Stripe currencies where the value of each
|
1180 |
+
* currency is the curency multiplier.
|
1181 |
+
*
|
1182 |
+
* @return mixed
|
1183 |
+
* @package Stripe/Functions
|
1184 |
+
* @since 3.1.2
|
1185 |
+
*/
|
1186 |
+
function wc_stripe_get_currencies() {
|
1187 |
+
return apply_filters(
|
1188 |
+
'wc_stripe_get_currencies',
|
1189 |
+
array(
|
1190 |
+
'BIF' => 0,
|
1191 |
+
'CLP' => 0,
|
1192 |
+
'DJF' => 0,
|
1193 |
+
'GNF' => 0,
|
1194 |
+
'JPY' => 0,
|
1195 |
+
'KMF' => 0,
|
1196 |
+
'KRW' => 0,
|
1197 |
+
'MGA' => 0,
|
1198 |
+
'PYG' => 0,
|
1199 |
+
'RWF' => 0,
|
1200 |
+
'UGX' => 0,
|
1201 |
+
'VND' => 0,
|
1202 |
+
'VUV' => 0,
|
1203 |
+
'XAF' => 0,
|
1204 |
+
'XOF' => 0,
|
1205 |
+
'XPF' => 0,
|
1206 |
+
)
|
1207 |
+
);
|
1208 |
+
}
|
1209 |
+
|
1210 |
+
/**
|
1211 |
+
* Function that triggers a filter on the order id.
|
1212 |
+
* Allows 3rd parties to
|
1213 |
+
* convert the order_id from the metadata of the Stripe object.
|
1214 |
+
*
|
1215 |
+
* @param int $order_id
|
1216 |
+
* @param \Stripe\ApiResource $object
|
1217 |
+
*
|
1218 |
+
* @since 3.1.3
|
1219 |
+
* @package Stripe/Functions
|
1220 |
+
*/
|
1221 |
+
function wc_stripe_filter_order_id( $order_id, $object ) {
|
1222 |
+
return apply_filters( 'wc_stripe_filter_order_id', $order_id, $object );
|
1223 |
+
}
|
1224 |
+
|
1225 |
+
/**
|
1226 |
+
* Removes order locks that have expired so the options table does not get cluttered with transients.
|
1227 |
+
* @since 3.1.6
|
1228 |
+
* @package Stripe/Functions
|
1229 |
+
*/
|
1230 |
+
function wc_stripe_remove_order_locks() {
|
1231 |
+
global $wpdb;
|
1232 |
+
|
1233 |
+
// this operation could take some time, ensure it completes.
|
1234 |
+
wc_set_time_limit();
|
1235 |
+
|
1236 |
+
$results = $wpdb->get_results( $wpdb->prepare( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE %s AND option_value < %d", '_transient_timeout_stripe_lock_order_%', time() ) );
|
1237 |
+
if ( $results ) {
|
1238 |
+
foreach ( $results as $result ) {
|
1239 |
+
// call delete_transient so Wordpress can fire all it's transient actions.
|
1240 |
+
delete_transient( substr( $result->option_name, strlen( '_transient_timeout_' ) ) );
|
1241 |
+
}
|
1242 |
+
}
|
1243 |
+
}
|
includes/wc-stripe-hooks.php
CHANGED
@@ -1,28 +1,29 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Actions
|
6 |
-
*/
|
7 |
-
add_action
|
8 |
-
add_action
|
9 |
-
add_action
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
add_action
|
15 |
-
add_action
|
16 |
-
add_action
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
add_filter
|
23 |
-
add_filter
|
24 |
-
|
25 |
-
|
26 |
-
add_filter
|
27 |
-
add_filter
|
28 |
-
add_filter
|
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Actions
|
6 |
+
*/
|
7 |
+
add_action( 'woocommerce_payment_token_deleted', 'wc_stripe_woocommerce_payment_token_deleted', 10, 2 );
|
8 |
+
add_action( 'woocommerce_order_status_cancelled', 'wc_stripe_order_cancelled', 10, 2 );
|
9 |
+
add_action( 'woocommerce_order_status_completed', 'wc_stripe_order_status_completed', 10, 2 );
|
10 |
+
add_action( 'wc_stripe_remove_order_locks', 'wc_stripe_remove_order_locks' );
|
11 |
+
/**
|
12 |
+
* * Webhook Actions ***
|
13 |
+
*/
|
14 |
+
add_action( 'wc_stripe_webhook_source_chargeable', 'wc_stripe_process_source_chargeable', 10, 2 );
|
15 |
+
add_action( 'wc_stripe_webhook_charge_succeeded', 'wc_stripe_process_charge_succeeded', 10, 2 );
|
16 |
+
add_action( 'wc_stripe_webhook_charge_failed', 'wc_stripe_process_charge_failed', 10, 2 );
|
17 |
+
add_action( 'wc_stripe_webhook_payment_intent_succeeded', 'wc_stripe_process_payment_intent_succeeded', 10, 2 );
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Filters
|
21 |
+
*/
|
22 |
+
add_filter( 'wc_stripe_api_options', 'wc_stripe_api_options' );
|
23 |
+
add_filter( 'woocommerce_payment_gateways', 'wc_stripe_payment_gateways' );
|
24 |
+
add_filter( 'woocommerce_available_payment_gateways', 'wc_stripe_available_payment_gateways' );
|
25 |
+
add_action( 'woocommerce_process_shop_subscription_meta', 'wc_stripe_process_shop_subscription_meta', 10, 2 );
|
26 |
+
add_filter( 'woocommerce_available_payment_gateways', 'wc_stripe_get_available_local_gateways' );
|
27 |
+
add_filter( 'woocommerce_payment_complete_order_status', 'wc_stripe_payment_complete_order_status', 10, 3 );
|
28 |
+
add_filter( 'woocommerce_get_customer_payment_tokens', 'wc_stripe_get_customer_payment_tokens', 10, 3 );
|
29 |
+
add_filter( 'woocommerce_credit_card_type_labels', 'wc_stripe_credit_card_labels' );
|
includes/wc-stripe-webhook-functions.php
CHANGED
@@ -1,149 +1,150 @@
|
|
1 |
-
<?php
|
2 |
-
defined
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Processes the charge via webhooks for local payment methods like
|
6 |
-
*
|
7 |
-
* @
|
8 |
-
* @
|
9 |
-
*
|
10 |
-
* @
|
11 |
-
* @
|
12 |
-
*/
|
13 |
-
function wc_stripe_process_source_chargeable($source, $request) {
|
14 |
-
$order = wc_get_order
|
15 |
-
if (! $order) {
|
16 |
-
wc_stripe_log_error
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
*
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
return;
|
32 |
-
}
|
33 |
-
$
|
34 |
-
$
|
35 |
-
$
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
*
|
42 |
-
*
|
43 |
-
*
|
44 |
-
* @
|
45 |
-
*
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
$
|
80 |
-
$order->
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
}
|
86 |
-
|
87 |
-
/**
|
88 |
-
*
|
89 |
-
* @
|
90 |
-
* @
|
91 |
-
*
|
92 |
-
* @
|
93 |
-
* @
|
94 |
-
*/
|
95 |
-
function wc_stripe_process_payment_intent_succeeded($intent, $request) {
|
96 |
-
$order = wc_get_order ( $intent->metadata[
|
97 |
-
if (! $order) {
|
98 |
-
wc_stripe_log_error
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
$
|
118 |
-
|
119 |
-
$
|
120 |
-
}
|
121 |
-
}
|
122 |
-
|
123 |
-
/**
|
124 |
-
*
|
125 |
-
* @
|
126 |
-
* @
|
127 |
-
*
|
128 |
-
* @
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
*
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
//
|
143 |
-
//
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
}
|
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Processes the charge via webhooks for local payment methods like P24, EPS, etc.
|
6 |
+
*
|
7 |
+
* @param \Stripe\Source $source
|
8 |
+
* @param WP_REST_Request $request
|
9 |
+
*
|
10 |
+
* @since 3.0.0
|
11 |
+
* @package Stripe/Functions
|
12 |
+
*/
|
13 |
+
function wc_stripe_process_source_chargeable( $source, $request ) {
|
14 |
+
$order = wc_get_order( wc_stripe_filter_order_id( $source->metadata['order_id'], $source ) );
|
15 |
+
if ( ! $order ) {
|
16 |
+
wc_stripe_log_error( sprintf( 'Could not create a charge for source %s. No order ID was found in your WordPress database.', $source->id ) );
|
17 |
+
|
18 |
+
return;
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
*
|
23 |
+
* @var WC_Payment_Gateway_Stripe $payment_method
|
24 |
+
*/
|
25 |
+
$payment_method = WC()->payment_gateways()->payment_gateways()[ $order->get_payment_method() ];
|
26 |
+
|
27 |
+
// if the order has a transaction ID, then a charge has already been created.
|
28 |
+
if ( $payment_method->has_order_lock( $order ) || ( $transaction_id = $order->get_transaction_id() ) ) {
|
29 |
+
wc_stripe_log_info( sprintf( 'source.chargeable event received. Charge has already been created for order %s. Event exited.', $order->get_id() ) );
|
30 |
+
|
31 |
+
return;
|
32 |
+
}
|
33 |
+
$payment_method->set_order_lock( $order );
|
34 |
+
$payment_method->set_new_source_token( $source->id );
|
35 |
+
$payment_method->process_payment( $order->get_id() );
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* When the charge has succeeded, the order should be completed.
|
40 |
+
*
|
41 |
+
* @param \Stripe\Charge $charge
|
42 |
+
* @param WP_REST_Request $request
|
43 |
+
*
|
44 |
+
* @since 3.0.5
|
45 |
+
* @package Stripe/Functions
|
46 |
+
*/
|
47 |
+
function wc_stripe_process_charge_succeeded( $charge, $request ) {
|
48 |
+
// charges that belong to a payment intent can be skipped
|
49 |
+
// because the payment_intent.succeeded event will be called.
|
50 |
+
if ( $charge->payment_intent ) {
|
51 |
+
return;
|
52 |
+
}
|
53 |
+
$order = wc_get_order( wc_stripe_filter_order_id( $charge->metadata['order_id'], $charge ) );
|
54 |
+
if ( ! $order ) {
|
55 |
+
wc_stripe_log_error( sprintf( 'Could not complete payment for charge %s. No order ID %s was found in your WordPress database.', $charge->id, $charge->metadata['order_id'] ) );
|
56 |
+
|
57 |
+
return;
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
*
|
62 |
+
* @var WC_Payment_Gateway_Stripe $payment_method
|
63 |
+
*/
|
64 |
+
$payment_method = WC()->payment_gateways()->payment_gateways()[ $order->get_payment_method() ];
|
65 |
+
/**
|
66 |
+
* Only process for local payment methods. We make sure the payment method is asynchronous
|
67 |
+
* because synchronous payments are handled via the source.chargeable event which processes the payment.
|
68 |
+
* This event is relevant for payment methods that receive a charge.succeeded event at some arbitrary amount of time
|
69 |
+
* after the source is chargeable.
|
70 |
+
*/
|
71 |
+
if ( $payment_method instanceof WC_Payment_Gateway_Stripe_Local_Payment && ! $payment_method->synchronous ) {
|
72 |
+
|
73 |
+
// If the order's charge status is not equal to charge status from Stripe, then complete_payment.
|
74 |
+
if ( $order->get_meta( WC_Stripe_Constants::CHARGE_STATUS ) != $charge->status ) {
|
75 |
+
// want to prevent plugin from processing capture_charge since charge has already been captured.
|
76 |
+
remove_action( 'woocommerce_order_status_completed', 'wc_stripe_order_status_completed' );
|
77 |
+
|
78 |
+
// call payment complete so shipping, emails, etc are triggered.
|
79 |
+
$payment_method->save_order_meta( $order, $charge );
|
80 |
+
$order->payment_complete();
|
81 |
+
$order->add_order_note( __( 'Charge.succeeded webhook received. Payment has been completed.', 'woo-stripe-payment' ) );
|
82 |
+
$payment_method->release_order_lock( $order );
|
83 |
+
}
|
84 |
+
}
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
*
|
89 |
+
* @param \Stripe\PaymentIntent $intent
|
90 |
+
* @param WP_REST_Request $request
|
91 |
+
*
|
92 |
+
* @since 3.1.0
|
93 |
+
* @package Stripe/Functions
|
94 |
+
*/
|
95 |
+
function wc_stripe_process_payment_intent_succeeded( $intent, $request ) {
|
96 |
+
$order = wc_get_order( wc_stripe_filter_order_id( $intent->metadata['order_id'], $intent ) );
|
97 |
+
if ( ! $order ) {
|
98 |
+
wc_stripe_log_error( sprintf( 'Could not complete payment for payment_intent %s. No order ID was found in your WordPress database.', $intent->id ) );
|
99 |
+
|
100 |
+
return;
|
101 |
+
}
|
102 |
+
$payment_method = WC()->payment_gateways()->payment_gateways()[ $order->get_payment_method() ];
|
103 |
+
|
104 |
+
if ( $payment_method instanceof WC_Payment_Gateway_Stripe_Local_Payment ) {
|
105 |
+
/**
|
106 |
+
* Delay the event by one second to allow the redirect handler to process
|
107 |
+
* the payment.
|
108 |
+
*/
|
109 |
+
sleep( 1 );
|
110 |
+
|
111 |
+
if ( $payment_method->has_order_lock( $order ) || ( $transaction_id = $order->get_transaction_id() ) ) {
|
112 |
+
wc_stripe_log_info( sprintf( 'payment_intent.succeeded event received. Intent has been completed and been created for order %s. Event exited.', $order->get_id() ) );
|
113 |
+
|
114 |
+
return;
|
115 |
+
}
|
116 |
+
|
117 |
+
$payment_method->set_order_lock( $order );
|
118 |
+
$payment_method->process_payment( $order->get_id() );
|
119 |
+
$order->add_order_note( __( 'payment_intent.succeeded webhook received. Payment has been completed.', 'woo-stripe-payment' ) );
|
120 |
+
}
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
*
|
125 |
+
* @param \Stripe\Charge $charge
|
126 |
+
* @param WP_REST_Request $request
|
127 |
+
*
|
128 |
+
* @since 3.1.1
|
129 |
+
* @package Stripe/Functions
|
130 |
+
*/
|
131 |
+
function wc_stripe_process_charge_failed( $charge, $request ) {
|
132 |
+
$order = wc_get_order( wc_stripe_filter_order_id( $charge->metadata['order_id'], $charge ) );
|
133 |
+
|
134 |
+
if ( $order ) {
|
135 |
+
$payment_methods = WC()->payment_gateways()->payment_gateways();
|
136 |
+
if ( isset( $payment_methods[ $order->get_payment_method() ] ) ) {
|
137 |
+
/**
|
138 |
+
*
|
139 |
+
* @var WC_Payment_Gateway_Stripe $payment_method
|
140 |
+
*/
|
141 |
+
$payment_method = $payment_methods[ $order->get_payment_method() ];
|
142 |
+
// only update order status if this is an asynchronous payment method,
|
143 |
+
// and there is no completed date on the order. If there is a complete date it
|
144 |
+
// means payment_complete was called on the order at some point
|
145 |
+
if ( ! $payment_method->synchronous && ! $order->get_date_completed() ) {
|
146 |
+
$order->update_status( 'failed', $charge->failure_message );
|
147 |
+
}
|
148 |
+
}
|
149 |
+
}
|
150 |
+
}
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: mr.clayton
|
|
3 |
Tags: stripe, ach, klarna, credit card, apple pay, google pay, ideal, sepa, sofort
|
4 |
Requires at least: 3.0.1
|
5 |
Tested up to: 5.4
|
6 |
-
Requires PHP: 5.
|
7 |
-
Stable tag: 3.1.
|
8 |
Copyright: Payment Plugins
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
@@ -57,6 +57,14 @@ If you're site is not loading over https, then Stripe won't render the Payment R
|
|
57 |
8. Edit payment gateways on the product page
|
58 |
|
59 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
= 3.1.5 =
|
61 |
* Fixed - Capture type on product page checkout
|
62 |
* Fixed - WP 5.4.2 deprecation message for namespaces
|
3 |
Tags: stripe, ach, klarna, credit card, apple pay, google pay, ideal, sepa, sofort
|
4 |
Requires at least: 3.0.1
|
5 |
Tested up to: 5.4
|
6 |
+
Requires PHP: 5.6
|
7 |
+
Stable tag: 3.1.6
|
8 |
Copyright: Payment Plugins
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
57 |
8. Edit payment gateways on the product page
|
58 |
|
59 |
== Changelog ==
|
60 |
+
= 3.1.6 =
|
61 |
+
* Updated - WC tested to 4.3.0
|
62 |
+
* Updated - Bumped PHP min version to 5.6
|
63 |
+
* Updated - Stripe php lib version 7.39.0
|
64 |
+
* Updated - Apple domain registration check for existing domain
|
65 |
+
* Fixed - Notice on cart page when payment request button active and cart emptied
|
66 |
+
* Fixed - Google Pay fee line item in wallet
|
67 |
+
* Added - New filters for API requests
|
68 |
= 3.1.5 =
|
69 |
* Fixed - Capture type on product page checkout
|
70 |
* Fixed - WP 5.4.2 deprecation message for namespaces
|
stripe-payments.php
CHANGED
@@ -3,22 +3,22 @@
|
|
3 |
* Plugin Name: Stripe For WooCommerce
|
4 |
* Plugin URI: https://docs.paymentplugins.com/wc-stripe/config/
|
5 |
* Description: Accept credit cards, Google Pay, Apple Pay, ACH, Klarna and more using Stripe.
|
6 |
-
* Version: 3.1.
|
7 |
* Author: Payment Plugins, support@paymentplugins.com
|
8 |
* Text Domain: woo-stripe-payment
|
9 |
* Domain Path: /i18n/languages/
|
10 |
* Tested up to: 5.4
|
11 |
* WC requires at least: 3.0.0
|
12 |
-
* WC tested up to: 4.
|
13 |
*/
|
14 |
defined ( 'ABSPATH' ) || exit ();
|
15 |
|
16 |
function wc_stripe_php_version_notice() {
|
17 |
-
$message = sprintf ( __ ( 'Your PHP version is %s but Stripe requires version 5.
|
18 |
echo '<div class="notice notice-error"><p style="font-size: 16px">' . $message . '</p></div>';
|
19 |
}
|
20 |
|
21 |
-
if (version_compare ( PHP_VERSION, '5.
|
22 |
add_action ( 'admin_init', 'wc_stripe_php_version_notice' );
|
23 |
return;
|
24 |
}
|
@@ -29,5 +29,4 @@ define ( 'WC_STRIPE_PLUGIN_NAME', plugin_basename ( __FILE__ ) );
|
|
29 |
define ( 'WC_STRIPE_CLASS_VERSION', '6.40.0' );
|
30 |
// include main plugin file.
|
31 |
require_once ( WC_STRIPE_PLUGIN_FILE_PATH . 'includes/class-stripe.php' );
|
32 |
-
|
33 |
-
require_once ( WC_STRIPE_PLUGIN_FILE_PATH . 'stripe-php-' . WC_STRIPE_CLASS_VERSION . '/init.php' );
|
3 |
* Plugin Name: Stripe For WooCommerce
|
4 |
* Plugin URI: https://docs.paymentplugins.com/wc-stripe/config/
|
5 |
* Description: Accept credit cards, Google Pay, Apple Pay, ACH, Klarna and more using Stripe.
|
6 |
+
* Version: 3.1.6
|
7 |
* Author: Payment Plugins, support@paymentplugins.com
|
8 |
* Text Domain: woo-stripe-payment
|
9 |
* Domain Path: /i18n/languages/
|
10 |
* Tested up to: 5.4
|
11 |
* WC requires at least: 3.0.0
|
12 |
+
* WC tested up to: 4.3.0
|
13 |
*/
|
14 |
defined ( 'ABSPATH' ) || exit ();
|
15 |
|
16 |
function wc_stripe_php_version_notice() {
|
17 |
+
$message = sprintf ( __ ( 'Your PHP version is %s but Stripe requires version 5.6+.', 'woo-stripe-payment' ), PHP_VERSION );
|
18 |
echo '<div class="notice notice-error"><p style="font-size: 16px">' . $message . '</p></div>';
|
19 |
}
|
20 |
|
21 |
+
if (version_compare ( PHP_VERSION, '5.6', '<' )) {
|
22 |
add_action ( 'admin_init', 'wc_stripe_php_version_notice' );
|
23 |
return;
|
24 |
}
|
29 |
define ( 'WC_STRIPE_CLASS_VERSION', '6.40.0' );
|
30 |
// include main plugin file.
|
31 |
require_once ( WC_STRIPE_PLUGIN_FILE_PATH . 'includes/class-stripe.php' );
|
32 |
+
require_once ( WC_STRIPE_PLUGIN_FILE_PATH . 'vendor/autoload.php' );
|
|
stripe-php-6.40.0/CHANGELOG.md
DELETED
@@ -1,715 +0,0 @@
|
|
1 |
-
# Changelog
|
2 |
-
|
3 |
-
## 6.40.0 - 2019-06-27
|
4 |
-
* [#675](https://github.com/stripe/stripe-php/pull/675) Add support for `SetupIntent` resource and APIs
|
5 |
-
|
6 |
-
## 6.39.2 - 2019-06-26
|
7 |
-
* [#676](https://github.com/stripe/stripe-php/pull/676) Fix exception message in `CustomerBalanceTransaction::update()`
|
8 |
-
|
9 |
-
## 6.39.1 - 2019-06-25
|
10 |
-
* [#674](https://github.com/stripe/stripe-php/pull/674) Add new constants for `collection_method` on `Invoice`
|
11 |
-
|
12 |
-
## 6.39.0 - 2019-06-24
|
13 |
-
* [#673](https://github.com/stripe/stripe-php/pull/673) Enable request latency telemetry by default
|
14 |
-
|
15 |
-
## 6.38.0 - 2019-06-17
|
16 |
-
* [#649](https://github.com/stripe/stripe-php/pull/649) Add support for `CustomerBalanceTransaction` resource and APIs
|
17 |
-
|
18 |
-
## 6.37.2 - 2019-06-17
|
19 |
-
* [#671](https://github.com/stripe/stripe-php/pull/671) Add new PHPDoc
|
20 |
-
* [#672](https://github.com/stripe/stripe-php/pull/672) Add constants for `submit_type` on Checkout `Session`
|
21 |
-
|
22 |
-
## 6.37.1 - 2019-06-14
|
23 |
-
* [#670](https://github.com/stripe/stripe-php/pull/670) Add new PHPDoc
|
24 |
-
|
25 |
-
## 6.37.0 - 2019-05-23
|
26 |
-
* [#663](https://github.com/stripe/stripe-php/pull/663) Add support for `radar.early_fraud_warning` resource
|
27 |
-
|
28 |
-
## 6.36.0 - 2019-05-22
|
29 |
-
* [#661](https://github.com/stripe/stripe-php/pull/661) Add constants for new TaxId types
|
30 |
-
* [#662](https://github.com/stripe/stripe-php/pull/662) Add constants for BalanceTransaction types
|
31 |
-
|
32 |
-
## 6.35.2 - 2019-05-20
|
33 |
-
* [#655](https://github.com/stripe/stripe-php/pull/655) Add constants for payment intent statuses
|
34 |
-
* [#659](https://github.com/stripe/stripe-php/pull/659) Fix PHPDoc for various nested Account actions
|
35 |
-
* [#660](https://github.com/stripe/stripe-php/pull/660) Fix various PHPDoc
|
36 |
-
|
37 |
-
## 6.35.1 - 2019-05-20
|
38 |
-
* [#658](https://github.com/stripe/stripe-php/pull/658) Use absolute value when checking timestamp tolerance
|
39 |
-
|
40 |
-
## 6.35.0 - 2019-05-14
|
41 |
-
* [#651](https://github.com/stripe/stripe-php/pull/651) Add support for the Capability resource and APIs
|
42 |
-
|
43 |
-
## 6.34.6 - 2019-05-13
|
44 |
-
* [#654](https://github.com/stripe/stripe-php/pull/654) Fix typo in definition of `Event::PAYMENT_METHOD_ATTACHED` constant
|
45 |
-
|
46 |
-
## 6.34.5 - 2019-05-06
|
47 |
-
* [#647](https://github.com/stripe/stripe-php/pull/647) Set the return type to static for more operations
|
48 |
-
|
49 |
-
## 6.34.4 - 2019-05-06
|
50 |
-
* [#650](https://github.com/stripe/stripe-php/pull/650) Add missing constants for Event types
|
51 |
-
|
52 |
-
## 6.34.3 - 2019-05-01
|
53 |
-
* [#644](https://github.com/stripe/stripe-php/pull/644) Update return type to `static` to improve static analysis
|
54 |
-
* [#645](https://github.com/stripe/stripe-php/pull/645) Fix constant for `payment_intent.payment_failed`
|
55 |
-
|
56 |
-
## 6.34.2 - 2019-04-26
|
57 |
-
* [#642](https://github.com/stripe/stripe-php/pull/642) Fix an issue where existing idempotency keys would be overwritten when using automatic retries
|
58 |
-
|
59 |
-
## 6.34.1 - 2019-04-25
|
60 |
-
* [#640](https://github.com/stripe/stripe-php/pull/640) Add missing phpdocs
|
61 |
-
|
62 |
-
## 6.34.0 - 2019-04-24
|
63 |
-
* [#626](https://github.com/stripe/stripe-php/pull/626) Add support for the `TaxRate` resource and APIs
|
64 |
-
* [#639](https://github.com/stripe/stripe-php/pull/639) Fix multiple phpdoc issues
|
65 |
-
|
66 |
-
## 6.33.0 - 2019-04-22
|
67 |
-
* [#630](https://github.com/stripe/stripe-php/pull/630) Add support for the `TaxId` resource and APIs
|
68 |
-
|
69 |
-
## 6.32.1 - 2019-04-19
|
70 |
-
* [#636](https://github.com/stripe/stripe-php/pull/636) Correct type of `$personId` in PHPDoc
|
71 |
-
|
72 |
-
## 6.32.0 - 2019-04-18
|
73 |
-
* [#621](https://github.com/stripe/stripe-php/pull/621) Add support for `CreditNote`
|
74 |
-
|
75 |
-
## 6.31.5 - 2019-04-12
|
76 |
-
* [#628](https://github.com/stripe/stripe-php/pull/628) Add constants for `person.*` event types
|
77 |
-
* [#628](https://github.com/stripe/stripe-php/pull/628) Add missing constants for `Account` and `Person`
|
78 |
-
|
79 |
-
## 6.31.4 - 2019-04-05
|
80 |
-
* [#624](https://github.com/stripe/stripe-php/pull/624) Fix encoding of nested parameters in multipart requests
|
81 |
-
|
82 |
-
## 6.31.3 - 2019-04-02
|
83 |
-
* [#623](https://github.com/stripe/stripe-php/pull/623) Only use HTTP/2 with curl >= 7.60.0
|
84 |
-
|
85 |
-
## 6.31.2 - 2019-03-25
|
86 |
-
* [#619](https://github.com/stripe/stripe-php/pull/619) Fix PHPDoc return types for list methods for nested resources
|
87 |
-
|
88 |
-
## 6.31.1 - 2019-03-22
|
89 |
-
* [#612](https://github.com/stripe/stripe-php/pull/612) Add a lot of constants
|
90 |
-
* [#614](https://github.com/stripe/stripe-php/pull/614) Add missing subscription status constants
|
91 |
-
|
92 |
-
## 6.31.0 - 2019-03-18
|
93 |
-
* [#600](https://github.com/stripe/stripe-php/pull/600) Add support for the `PaymentMethod` resource and APIs
|
94 |
-
* [#606](https://github.com/stripe/stripe-php/pull/606) Add support for retrieving a Checkout `Session`
|
95 |
-
* [#611](https://github.com/stripe/stripe-php/pull/611) Add support for deleting a Terminal `Location` and `Reader`
|
96 |
-
|
97 |
-
## 6.30.5 - 2019-03-11
|
98 |
-
* [#607](https://github.com/stripe/stripe-php/pull/607) Correctly handle case where a metadata key is called `metadata`
|
99 |
-
|
100 |
-
## 6.30.4 - 2019-02-27
|
101 |
-
* [#602](https://github.com/stripe/stripe-php/pull/602) Add `subscription_schedule` to `Subscription` for PHPDoc.
|
102 |
-
|
103 |
-
## 6.30.3 - 2019-02-26
|
104 |
-
* [#603](https://github.com/stripe/stripe-php/pull/603) Improve PHPDoc on the `Source` object to cover all types of Sources currently supported.
|
105 |
-
|
106 |
-
## 6.30.2 - 2019-02-25
|
107 |
-
* [#601](https://github.com/stripe/stripe-php/pull/601) Fix PHPDoc across multiple resources and add support for new events.
|
108 |
-
|
109 |
-
## 6.30.1 - 2019-02-16
|
110 |
-
* [#599](https://github.com/stripe/stripe-php/pull/599) Fix PHPDoc for `SubscriptionSchedule` and `SubscriptionScheduleRevision`
|
111 |
-
|
112 |
-
## 6.30.0 - 2019-02-12
|
113 |
-
* [#590](https://github.com/stripe/stripe-php/pull/590) Add support for `SubscriptionSchedule` and `SubscriptionScheduleRevision`
|
114 |
-
|
115 |
-
## 6.29.3 - 2019-01-31
|
116 |
-
* [#592](https://github.com/stripe/stripe-php/pull/592) Some more PHPDoc fixes
|
117 |
-
|
118 |
-
## 6.29.2 - 2019-01-31
|
119 |
-
* [#591](https://github.com/stripe/stripe-php/pull/591) Fix PHPDoc for nested resources
|
120 |
-
|
121 |
-
## 6.29.1 - 2019-01-25
|
122 |
-
* [#566](https://github.com/stripe/stripe-php/pull/566) Fix dangling message contents
|
123 |
-
* [#586](https://github.com/stripe/stripe-php/pull/586) Don't overwrite `CURLOPT_HTTP_VERSION` option
|
124 |
-
|
125 |
-
## 6.29.0 - 2019-01-23
|
126 |
-
* [#579](https://github.com/stripe/stripe-php/pull/579) Rename `CheckoutSession` to `Session` and move it under the `Checkout` namespace. This is a breaking change, but we've reached out to affected merchants and all new merchants would use the new approach.
|
127 |
-
|
128 |
-
## 6.28.1 - 2019-01-21
|
129 |
-
* [#580](https://github.com/stripe/stripe-php/pull/580) Properly serialize `individual` on `Account` objects
|
130 |
-
|
131 |
-
## 6.28.0 - 2019-01-03
|
132 |
-
* [#576](https://github.com/stripe/stripe-php/pull/576) Add support for iterating directly over `Collection` instances
|
133 |
-
|
134 |
-
## 6.27.0 - 2018-12-21
|
135 |
-
* [#571](https://github.com/stripe/stripe-php/pull/571) Add support for the `CheckoutSession` resource
|
136 |
-
|
137 |
-
## 6.26.0 - 2018-12-11
|
138 |
-
* [#568](https://github.com/stripe/stripe-php/pull/568) Enable persistent connections
|
139 |
-
|
140 |
-
## 6.25.0 - 2018-12-10
|
141 |
-
* [#567](https://github.com/stripe/stripe-php/pull/567) Add support for account links
|
142 |
-
|
143 |
-
## 6.24.0 - 2018-11-28
|
144 |
-
* [#562](https://github.com/stripe/stripe-php/pull/562) Add support for the Review resource
|
145 |
-
* [#564](https://github.com/stripe/stripe-php/pull/564) Add event name constants for subscription schedule aborted/expiring
|
146 |
-
|
147 |
-
## 6.23.0 - 2018-11-27
|
148 |
-
* [#542](https://github.com/stripe/stripe-php/pull/542) Add support for `ValueList` and `ValueListItem` for Radar
|
149 |
-
|
150 |
-
## 6.22.1 - 2018-11-20
|
151 |
-
* [#561](https://github.com/stripe/stripe-php/pull/561) Add cast and some docs to telemetry introduced in 6.22.0/#549
|
152 |
-
|
153 |
-
## 6.22.0 - 2018-11-15
|
154 |
-
* [#549](https://github.com/stripe/stripe-php/pull/549) Add support for client telemetry
|
155 |
-
|
156 |
-
## 6.21.1 - 2018-11-12
|
157 |
-
* [#548](https://github.com/stripe/stripe-php/pull/548) Don't mutate `Exception` class properties from `OAuthBase` error
|
158 |
-
|
159 |
-
## 6.21.0 - 2018-11-08
|
160 |
-
* [#537](https://github.com/stripe/stripe-php/pull/537) Add new API endpoints for the `Invoice` resource.
|
161 |
-
|
162 |
-
## 6.20.1 - 2018-11-07
|
163 |
-
* [#546](https://github.com/stripe/stripe-php/pull/546) Drop files from the Composer package that aren't needed in the release
|
164 |
-
|
165 |
-
## 6.20.0 - 2018-10-30
|
166 |
-
* [#536](https://github.com/stripe/stripe-php/pull/536) Add support for the `Person` resource
|
167 |
-
* [#541](https://github.com/stripe/stripe-php/pull/541) Add support for the `WebhookEndpoint` resource
|
168 |
-
|
169 |
-
## 6.19.5 - 2018-10-17
|
170 |
-
* [#539](https://github.com/stripe/stripe-php/pull/539) Fix methods on `\Stripe\PaymentIntent` to properly pass arguments to the API.
|
171 |
-
|
172 |
-
## 6.19.4 - 2018-10-11
|
173 |
-
* [#534](https://github.com/stripe/stripe-php/pull/534) Fix PSR-4 autoloading for `\Stripe\FileUpload` class alias
|
174 |
-
|
175 |
-
## 6.19.3 - 2018-10-09
|
176 |
-
* [#530](https://github.com/stripe/stripe-php/pull/530) Add constants for `flow` (`FLOW_*`), `status` (`STATUS_*`) and `usage` (`USAGE_*`) on `\Stripe\Source`
|
177 |
-
|
178 |
-
## 6.19.2 - 2018-10-08
|
179 |
-
* [#531](https://github.com/stripe/stripe-php/pull/531) Store HTTP response headers in case-insensitive array
|
180 |
-
|
181 |
-
## 6.19.1 - 2018-09-25
|
182 |
-
* [#526](https://github.com/stripe/stripe-php/pull/526) Ignore null values in request parameters
|
183 |
-
|
184 |
-
## 6.19.0 - 2018-09-24
|
185 |
-
* [#523](https://github.com/stripe/stripe-php/pull/523) Add support for Stripe Terminal
|
186 |
-
|
187 |
-
## 6.18.0 - 2018-09-24
|
188 |
-
* [#520](https://github.com/stripe/stripe-php/pull/520) Rename `\Stripe\FileUpload` to `\Stripe\File`
|
189 |
-
|
190 |
-
## 6.17.2 - 2018-09-18
|
191 |
-
* [#522](https://github.com/stripe/stripe-php/pull/522) Fix warning when adding a new additional owner to an existing array
|
192 |
-
|
193 |
-
## 6.17.1 - 2018-09-14
|
194 |
-
* [#517](https://github.com/stripe/stripe-php/pull/517) Integer-index encode all sequential arrays
|
195 |
-
|
196 |
-
## 6.17.0 - 2018-09-05
|
197 |
-
* [#514](https://github.com/stripe/stripe-php/pull/514) Add support for reporting resources
|
198 |
-
|
199 |
-
## 6.16.0 - 2018-08-23
|
200 |
-
* [#509](https://github.com/stripe/stripe-php/pull/509) Add support for usage record summaries
|
201 |
-
|
202 |
-
## 6.15.0 - 2018-08-03
|
203 |
-
* [#504](https://github.com/stripe/stripe-php/pull/504) Add cancel support for topups
|
204 |
-
|
205 |
-
## 6.14.0 - 2018-08-02
|
206 |
-
* [#505](https://github.com/stripe/stripe-php/pull/505) Add support for file links
|
207 |
-
|
208 |
-
## 6.13.0 - 2018-07-31
|
209 |
-
* [#502](https://github.com/stripe/stripe-php/pull/502) Add `isDeleted()` method to `\Stripe\StripeObject`
|
210 |
-
|
211 |
-
## 6.12.0 - 2018-07-28
|
212 |
-
* [#501](https://github.com/stripe/stripe-php/pull/501) Add support for scheduled query runs (`\Stripe\Sigma\ScheduledQueryRun`) for Sigma
|
213 |
-
|
214 |
-
## 6.11.0 - 2018-07-26
|
215 |
-
* [#500](https://github.com/stripe/stripe-php/pull/500) Add support for Stripe Issuing
|
216 |
-
|
217 |
-
## 6.10.4 - 2018-07-19
|
218 |
-
* [#498](https://github.com/stripe/stripe-php/pull/498) Internal improvements to the `\Stripe\ApiResource.classUrl()` method
|
219 |
-
|
220 |
-
## 6.10.3 - 2018-07-16
|
221 |
-
* [#497](https://github.com/stripe/stripe-php/pull/497) Use HTTP/2 only for HTTPS requests
|
222 |
-
|
223 |
-
## 6.10.2 - 2018-07-11
|
224 |
-
* [#494](https://github.com/stripe/stripe-php/pull/494) Enable HTTP/2 support
|
225 |
-
|
226 |
-
## 6.10.1 - 2018-07-10
|
227 |
-
* [#493](https://github.com/stripe/stripe-php/pull/493) Add PHPDoc for `auto_advance` on `\Stripe\Invoice`
|
228 |
-
|
229 |
-
## 6.10.0 - 2018-06-28
|
230 |
-
* [#488](https://github.com/stripe/stripe-php/pull/488) Add support for `$appPartnerId` to `Stripe::setAppInfo()`
|
231 |
-
|
232 |
-
## 6.9.0 - 2018-06-28
|
233 |
-
* [#487](https://github.com/stripe/stripe-php/pull/487) Add support for payment intents
|
234 |
-
|
235 |
-
## 6.8.2 - 2018-06-24
|
236 |
-
* [#486](https://github.com/stripe/stripe-php/pull/486) Make `Account.deauthorize()` return the `StripeObject` from the API
|
237 |
-
|
238 |
-
## 6.8.1 - 2018-06-13
|
239 |
-
* [#472](https://github.com/stripe/stripe-php/pull/472) Added phpDoc for `ApiRequestor` and others, especially regarding thrown errors
|
240 |
-
|
241 |
-
## 6.8.0 - 2018-06-13
|
242 |
-
* [#481](https://github.com/stripe/stripe-php/pull/481) Add new `\Stripe\Discount` and `\Stripe\OrderItem` classes, add more PHPDoc describing object attributes
|
243 |
-
|
244 |
-
## 6.7.4 - 2018-05-29
|
245 |
-
* [#480](https://github.com/stripe/stripe-php/pull/480) PHPDoc changes for API version 2018-05-21 and the addition of the new `CHARGE_EXPIRED` event type
|
246 |
-
|
247 |
-
## 6.7.3 - 2018-05-28
|
248 |
-
* [#479](https://github.com/stripe/stripe-php/pull/479) Fix unnecessary traits on `\Stripe\InvoiceLineItem`
|
249 |
-
|
250 |
-
## 6.7.2 - 2018-05-28
|
251 |
-
* [#471](https://github.com/stripe/stripe-php/pull/471) Add `OBJECT_NAME` constant to all API resource classes, add `\Stripe\InvoiceLineItem` class
|
252 |
-
|
253 |
-
## 6.7.1 - 2018-05-13
|
254 |
-
* [#468](https://github.com/stripe/stripe-php/pull/468) Update fields in PHP docs for accuracy
|
255 |
-
|
256 |
-
## 6.7.0 - 2018-05-09
|
257 |
-
* [#466](https://github.com/stripe/stripe-php/pull/466) Add support for issuer fraud records
|
258 |
-
|
259 |
-
## 6.6.0 - 2018-04-11
|
260 |
-
* [#460](https://github.com/stripe/stripe-php/pull/460) Add support for flexible billing primitives
|
261 |
-
|
262 |
-
## 6.5.0 - 2018-04-05
|
263 |
-
* [#461](https://github.com/stripe/stripe-php/pull/461) Don't zero keys on non-`metadata` subobjects
|
264 |
-
|
265 |
-
## 6.4.2 - 2018-03-17
|
266 |
-
* [#458](https://github.com/stripe/stripe-php/pull/458) Add PHPDoc for `account` on `\Stripe\Event`
|
267 |
-
|
268 |
-
## 6.4.1 - 2018-03-02
|
269 |
-
* [#455](https://github.com/stripe/stripe-php/pull/455) Fix namespaces in PHPDoc
|
270 |
-
* [#456](https://github.com/stripe/stripe-php/pull/456) Fix namespaces for some exceptions
|
271 |
-
|
272 |
-
## 6.4.0 - 2018-02-28
|
273 |
-
* [#453](https://github.com/stripe/stripe-php/pull/453) Add constants for `reason` (`REASON_*`) and `status` (`STATUS_*`) on `\Stripe\Dispute`
|
274 |
-
|
275 |
-
## 6.3.2 - 2018-02-27
|
276 |
-
* [#452](https://github.com/stripe/stripe-php/pull/452) Add PHPDoc for `amount_paid` and `amount_remaining` on `\Stripe\Invoice`
|
277 |
-
|
278 |
-
## 6.3.1 - 2018-02-26
|
279 |
-
* [#443](https://github.com/stripe/stripe-php/pull/443) Add event types as constants to `\Stripe\Event` class
|
280 |
-
|
281 |
-
## 6.3.0 - 2018-02-23
|
282 |
-
* [#450](https://github.com/stripe/stripe-php/pull/450) Add support for `code` attribute on all Stripe exceptions
|
283 |
-
|
284 |
-
## 6.2.0 - 2018-02-21
|
285 |
-
* [#440](https://github.com/stripe/stripe-php/pull/440) Add support for topups
|
286 |
-
* [#442](https://github.com/stripe/stripe-php/pull/442) Fix PHPDoc for `\Stripe\Error\SignatureVerification`
|
287 |
-
|
288 |
-
## 6.1.0 - 2018-02-12
|
289 |
-
* [#435](https://github.com/stripe/stripe-php/pull/435) Fix header persistence on `Collection` objects
|
290 |
-
* [#436](https://github.com/stripe/stripe-php/pull/436) Introduce new `Idempotency` error class
|
291 |
-
|
292 |
-
## 6.0.0 - 2018-02-07
|
293 |
-
Major version release. List of backwards incompatible changes to watch out for:
|
294 |
-
+ The minimum PHP version is now 5.4.0. If you're using PHP 5.3 or older, consider upgrading to a more recent version.
|
295 |
-
* `\Stripe\AttachedObject` no longer exists. Attributes that used to be instances of `\Stripe\AttachedObject` (such as `metadata`) are now instances of `\Stripe\StripeObject`.
|
296 |
-
+ Attributes that used to be PHP arrays (such as `legal_entity->additional_owners` on `\Stripe\Account` instances) are now instances of `\Stripe\StripeObject`, except when they are empty. `\Stripe\StripeObject` has array semantics so this should not be an issue unless you are actively checking types.
|
297 |
-
* `\Stripe\Collection` now derives from `\Stripe\StripeObject` rather than from `\Stripe\ApiResource`.
|
298 |
-
|
299 |
-
Pull requests included in this release:
|
300 |
-
* [#410](https://github.com/stripe/stripe-php/pull/410) Drop support for PHP 5.3
|
301 |
-
* [#411](https://github.com/stripe/stripe-php/pull/411) Use traits for common API operations
|
302 |
-
* [#414](https://github.com/stripe/stripe-php/pull/414) Use short array syntax
|
303 |
-
* [#404](https://github.com/stripe/stripe-php/pull/404) Fix serialization logic
|
304 |
-
* [#417](https://github.com/stripe/stripe-php/pull/417) Remove `ExternalAccount` class
|
305 |
-
* [#418](https://github.com/stripe/stripe-php/pull/418) Increase test coverage
|
306 |
-
* [#421](https://github.com/stripe/stripe-php/pull/421) Update CA bundle and add script for future updates
|
307 |
-
* [#422](https://github.com/stripe/stripe-php/pull/422) Use vendored CA bundle for all requests
|
308 |
-
* [#428](https://github.com/stripe/stripe-php/pull/428) Support for automatic request retries
|
309 |
-
|
310 |
-
## 5.9.2 - 2018-02-07
|
311 |
-
* [#431](https://github.com/stripe/stripe-php/pull/431) Update PHPDoc @property tags for latest API version
|
312 |
-
|
313 |
-
## 5.9.1 - 2018-02-06
|
314 |
-
* [#427](https://github.com/stripe/stripe-php/pull/427) Add and update PHPDoc @property tags on all API resources
|
315 |
-
|
316 |
-
## 5.9.0 - 2018-01-17
|
317 |
-
* [#421](https://github.com/stripe/stripe-php/pull/421) Updated bundled CA certificates
|
318 |
-
* [#423](https://github.com/stripe/stripe-php/pull/423) Escape unsanitized input in OAuth example
|
319 |
-
|
320 |
-
## 5.8.0 - 2017-12-20
|
321 |
-
* [#403](https://github.com/stripe/stripe-php/pull/403) Add `__debugInfo()` magic method to `StripeObject`
|
322 |
-
|
323 |
-
## 5.7.0 - 2017-11-28
|
324 |
-
* [#390](https://github.com/stripe/stripe-php/pull/390) Remove some unsupported API methods
|
325 |
-
* [#391](https://github.com/stripe/stripe-php/pull/391) Alphabetize the list of API resources in `Util::convertToStripeObject()` and add missing resources
|
326 |
-
* [#393](https://github.com/stripe/stripe-php/pull/393) Fix expiry date update for card sources
|
327 |
-
|
328 |
-
## 5.6.0 - 2017-10-31
|
329 |
-
* [#386](https://github.com/stripe/stripe-php/pull/386) Support for exchange rates APIs
|
330 |
-
|
331 |
-
## 5.5.1 - 2017-10-30
|
332 |
-
* [#387](https://github.com/stripe/stripe-php/pull/387) Allow `personal_address_kana` and `personal_address_kanji` to be updated on an account
|
333 |
-
|
334 |
-
## 5.5.0 - 2017-10-27
|
335 |
-
* [#385](https://github.com/stripe/stripe-php/pull/385) Support for listing source transactions
|
336 |
-
|
337 |
-
## 5.4.0 - 2017-10-24
|
338 |
-
* [#383](https://github.com/stripe/stripe-php/pull/383) Add static methods to manipulate resources from parent
|
339 |
-
* `Account` gains methods for external accounts and login links (e.g. `createExternalAccount`, `createLoginLink`)
|
340 |
-
* `ApplicationFee` gains methods for refunds
|
341 |
-
* `Customer` gains methods for sources
|
342 |
-
* `Transfer` gains methods for reversals
|
343 |
-
|
344 |
-
## 5.3.0 - 2017-10-11
|
345 |
-
* [#378](https://github.com/stripe/stripe-php/pull/378) Rename source `delete` to `detach` (and deprecate the former)
|
346 |
-
|
347 |
-
## 5.2.3 - 2017-09-27
|
348 |
-
* Add PHPDoc for `Card`
|
349 |
-
|
350 |
-
## 5.2.2 - 2017-09-20
|
351 |
-
* Fix deserialization mapping of `FileUpload` objects
|
352 |
-
|
353 |
-
## 5.2.1 - 2017-09-14
|
354 |
-
* Serialized `shipping` nested attribute
|
355 |
-
|
356 |
-
## 5.2.0 - 2017-08-29
|
357 |
-
* Add support for `InvalidClient` OAuth error
|
358 |
-
|
359 |
-
## 5.1.3 - 2017-08-14
|
360 |
-
* Allow `address_kana` and `address_kanji` to be updated for custom accounts
|
361 |
-
|
362 |
-
## 5.1.2 - 2017-08-01
|
363 |
-
* Fix documented return type of `autoPagingIterator()` (was missing namespace)
|
364 |
-
|
365 |
-
## 5.1.1 - 2017-07-03
|
366 |
-
* Fix order returns to use the right URL `/v1/order_returns`
|
367 |
-
|
368 |
-
## 5.1.0 - 2017-06-30
|
369 |
-
* Add support for OAuth
|
370 |
-
|
371 |
-
## 5.0.0 - 2017-06-27
|
372 |
-
* `pay` on invoice now takes params as well as opts
|
373 |
-
|
374 |
-
## 4.13.0 - 2017-06-19
|
375 |
-
* Add support for ephemeral keys
|
376 |
-
|
377 |
-
## 4.12.0 - 2017-06-05
|
378 |
-
* Clients can implement `getUserAgentInfo()` to add additional user agent information
|
379 |
-
|
380 |
-
## 4.11.0 - 2017-06-05
|
381 |
-
* Implement `Countable` for `AttachedObject` (`metadata` and `additional_owners`)
|
382 |
-
|
383 |
-
## 4.10.0 - 2017-05-25
|
384 |
-
* Add support for login links
|
385 |
-
|
386 |
-
## 4.9.1 - 2017-05-10
|
387 |
-
* Fix docs to include arrays on `$id` parameter for retrieve methods
|
388 |
-
|
389 |
-
## 4.9.0 - 2017-04-28
|
390 |
-
* Support for checking webhook signatures
|
391 |
-
|
392 |
-
## 4.8.1 - 2017-04-24
|
393 |
-
* Allow nested field `payout_schedule` to be updated
|
394 |
-
|
395 |
-
## 4.8.0 - 2017-04-20
|
396 |
-
* Add `\Stripe\Stripe::setLogger()` to support an external PSR-3 compatible logger
|
397 |
-
|
398 |
-
## 4.7.0 - 2017-04-10
|
399 |
-
* Add support for payouts and recipient transfers
|
400 |
-
|
401 |
-
## 4.6.0 - 2017-04-06
|
402 |
-
* Please see 4.7.0 instead (no-op release)
|
403 |
-
|
404 |
-
## 4.5.1 - 2017-03-22
|
405 |
-
* Remove hard dependency on cURL
|
406 |
-
|
407 |
-
## 4.5.0 - 2017-03-20
|
408 |
-
* Support for detaching sources from customers
|
409 |
-
|
410 |
-
## 4.4.2 - 2017-02-27
|
411 |
-
* Correct handling of `owner` parameter when updating sources
|
412 |
-
|
413 |
-
## 4.4.1 - 2017-02-24
|
414 |
-
* Correct the error check on a bad JSON decoding
|
415 |
-
|
416 |
-
## 4.4.0 - 2017-01-18
|
417 |
-
* Add support for updating sources
|
418 |
-
|
419 |
-
## 4.3.0 - 2016-11-30
|
420 |
-
* Add support for verifying sources
|
421 |
-
|
422 |
-
## 4.2.0 - 2016-11-21
|
423 |
-
* Add retrieve method for 3-D Secure resources
|
424 |
-
|
425 |
-
## 4.1.1 - 2016-10-21
|
426 |
-
* Add docblock with model properties for `Plan`
|
427 |
-
|
428 |
-
## 4.1.0 - 2016-10-18
|
429 |
-
* Support for 403 status codes (permission denied)
|
430 |
-
|
431 |
-
## 4.0.1 - 2016-10-17
|
432 |
-
* Fix transfer reversal materialization
|
433 |
-
* Fixes for some property definitions in docblocks
|
434 |
-
|
435 |
-
## 4.0.0 - 2016-09-28
|
436 |
-
* Support for subscription items
|
437 |
-
* Drop attempt to force TLS 1.2: please note that this could be breaking if you're using old OS distributions or packages and upgraded recently (so please make sure to test your integration!)
|
438 |
-
|
439 |
-
## 3.23.0 - 2016-09-15
|
440 |
-
* Add support for Apple Pay domains
|
441 |
-
|
442 |
-
## 3.22.0 - 2016-09-13
|
443 |
-
* Add `Stripe::setAppInfo` to allow plugins to register user agent information
|
444 |
-
|
445 |
-
## 3.21.0 - 2016-08-25
|
446 |
-
* Add `Source` model for generic payment sources
|
447 |
-
|
448 |
-
## 3.20.0 - 2016-08-08
|
449 |
-
* Add `getDeclineCode` to card errors
|
450 |
-
|
451 |
-
## 3.19.0 - 2016-07-29
|
452 |
-
* Opt requests directly into TLS 1.2 where OpenSSL >= 1.0.1 (see #277 for context)
|
453 |
-
|
454 |
-
## 3.18.0 - 2016-07-28
|
455 |
-
* Add new `STATUS_` constants for subscriptions
|
456 |
-
|
457 |
-
## 3.17.1 - 2016-07-28
|
458 |
-
* Fix auto-paging iterator so that it plays nicely with `iterator_to_array`
|
459 |
-
|
460 |
-
## 3.17.0 - 2016-07-14
|
461 |
-
* Add field annotations to model classes for better editor hinting
|
462 |
-
|
463 |
-
## 3.16.0 - 2016-07-12
|
464 |
-
* Add `ThreeDSecure` model for 3-D secure payments
|
465 |
-
|
466 |
-
## 3.15.0 - 2016-06-29
|
467 |
-
* Add static `update` method to all resources that can be changed.
|
468 |
-
|
469 |
-
## 3.14.3 - 2016-06-20
|
470 |
-
* Make sure that cURL never sends `Expects: 100-continue`, even on large request bodies
|
471 |
-
|
472 |
-
## 3.14.2 - 2016-06-03
|
473 |
-
* Add `inventory` under `SKU` to list of keys that have nested data and can be updated
|
474 |
-
|
475 |
-
## 3.14.1 - 2016-05-27
|
476 |
-
* Fix some inconsistencies in PHPDoc
|
477 |
-
|
478 |
-
## 3.14.0 - 2016-05-25
|
479 |
-
* Add support for returning Relay orders
|
480 |
-
|
481 |
-
## 3.13.0 - 2016-05-04
|
482 |
-
* Add `list`, `create`, `update`, `retrieve`, and `delete` methods to the Subscription class
|
483 |
-
|
484 |
-
## 3.12.1 - 2016-04-07
|
485 |
-
* Additional check on value arrays for some extra safety
|
486 |
-
|
487 |
-
## 3.12.0 - 2016-03-31
|
488 |
-
* Fix bug `refreshFrom` on `StripeObject` would not take an `$opts` array
|
489 |
-
* Fix bug where `$opts` not passed to parent `save` method in `Account`
|
490 |
-
* Fix bug where non-existent variable was referenced in `reverse` in `Transfer`
|
491 |
-
* Update CA cert bundle for compatibility with OpenSSL versions below 1.0.1
|
492 |
-
|
493 |
-
## 3.11.0 - 2016-03-22
|
494 |
-
* Allow `CurlClient` to be initialized with default `CURLOPT_*` options
|
495 |
-
|
496 |
-
## 3.10.1 - 2016-03-22
|
497 |
-
* Fix bug where request params and options were ignored in `ApplicationFee`'s `refund.`
|
498 |
-
|
499 |
-
## 3.10.0 - 2016-03-15
|
500 |
-
* Add `reject` on `Account` to support the new API feature
|
501 |
-
|
502 |
-
## 3.9.2 - 2016-03-04
|
503 |
-
* Fix error when an object's metadata is set more than once
|
504 |
-
|
505 |
-
## 3.9.1 - 2016-02-24
|
506 |
-
* Fix encoding behavior of nested arrays for requests (see #227)
|
507 |
-
|
508 |
-
## 3.9.0 - 2016-02-09
|
509 |
-
* Add automatic pagination mechanism with `autoPagingIterator()`
|
510 |
-
* Allow global account ID to be set with `Stripe::setAccountId()`
|
511 |
-
|
512 |
-
## 3.8.0 - 2016-02-08
|
513 |
-
* Add `CountrySpec` model for looking up country payment information
|
514 |
-
|
515 |
-
## 3.7.1 - 2016-02-01
|
516 |
-
* Update bundled CA certs
|
517 |
-
|
518 |
-
## 3.7.0 - 2016-01-27
|
519 |
-
* Support deleting Relay products and SKUs
|
520 |
-
|
521 |
-
## 3.6.0 - 2016-01-05
|
522 |
-
* Allow configuration of HTTP client timeouts
|
523 |
-
|
524 |
-
## 3.5.0 - 2015-12-01
|
525 |
-
* Add a verification routine for external accounts
|
526 |
-
|
527 |
-
## 3.4.0 - 2015-09-14
|
528 |
-
* Products, SKUs, and Orders -- https://stripe.com/relay
|
529 |
-
|
530 |
-
## 3.3.0 - 2015-09-11
|
531 |
-
* Add support for 429 Rate Limit response
|
532 |
-
|
533 |
-
## 3.2.0 - 2015-08-17
|
534 |
-
* Add refund listing and retrieval without an associated charge
|
535 |
-
|
536 |
-
## 3.1.0 - 2015-08-03
|
537 |
-
* Add dispute listing and retrieval
|
538 |
-
* Add support for manage account deletion
|
539 |
-
|
540 |
-
## 3.0.0 - 2015-07-28
|
541 |
-
* Rename `\Stripe\Object` to `\Stripe\StripeObject` (PHP 7 compatibility)
|
542 |
-
* Rename `getCode` and `getParam` in exceptions to `getStripeCode` and `getStripeParam`
|
543 |
-
* Add support for calling `json_encode` on Stripe objects in PHP 5.4+
|
544 |
-
* Start supporting/testing PHP 7
|
545 |
-
|
546 |
-
## 2.3.0 - 2015-07-06
|
547 |
-
* Add request ID to all Stripe exceptions
|
548 |
-
|
549 |
-
## 2.2.0 - 2015-06-01
|
550 |
-
* Add support for Alipay accounts as sources
|
551 |
-
* Add support for bank accounts as sources (private beta)
|
552 |
-
* Add support for bank accounts and cards as external_accounts on Account objects
|
553 |
-
|
554 |
-
## 2.1.4 - 2015-05-13
|
555 |
-
* Fix CA certificate file path (thanks @lphilps & @matthewarkin)
|
556 |
-
|
557 |
-
## 2.1.3 - 2015-05-12
|
558 |
-
* Fix to account updating to permit `tos_acceptance` and `personal_address` to be set properly
|
559 |
-
* Fix to Transfer reversal creation (thanks @neatness!)
|
560 |
-
* Network requests are now done through a swappable class for easier mocking
|
561 |
-
|
562 |
-
## 2.1.2 - 2015-04-10
|
563 |
-
* Remove SSL cert revokation checking (all pre-Heartbleed certs have expired)
|
564 |
-
* Bug fixes to account updating
|
565 |
-
|
566 |
-
## 2.1.1 - 2015-02-27
|
567 |
-
* Support transfer reversals
|
568 |
-
|
569 |
-
## 2.1.0 - 2015-02-19
|
570 |
-
* Support new API version (2015-02-18)
|
571 |
-
* Added Bitcoin Receiever update and delete actions
|
572 |
-
* Edited tests to prefer "source" over "card" as per new API version
|
573 |
-
|
574 |
-
## 2.0.1 - 2015-02-16
|
575 |
-
* Fix to fetching endpoints that use a non-default baseUrl (`FileUpload`)
|
576 |
-
|
577 |
-
## 2.0.0 - 2015-02-14
|
578 |
-
* Bumped minimum version to 5.3.3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|