Version Description
- 2021-07-21 =
- Fix - Disable Payment Request Buttons when order has to be split into multiple packages because Payment Requests do not support that use case.
- Tweak - Payment request button should guide users to login when necessary.
See changelog for all versions.
Download this release
Release Info
Developer | woothemes |
Plugin | WooCommerce Stripe Payment Gateway |
Version | 5.3.0 |
Comparing to | |
See all releases |
Code changes from version 5.2.3 to 5.3.0
- assets/js/stripe-payment-request.js +59 -8
- assets/js/stripe-payment-request.min.js +1 -1
- build/index.asset.php +1 -1
- build/index.js +1 -1
- changelog.txt +4 -0
- includes/class-wc-stripe-blocks-support.php +56 -7
- includes/payment-methods/class-wc-stripe-payment-request.php +214 -75
- languages/woocommerce-gateway-stripe.pot +39 -27
- readme.txt +4 -4
- woocommerce-gateway-stripe.php +2 -2
assets/js/stripe-payment-request.js
CHANGED
@@ -376,7 +376,14 @@ jQuery( function( $ ) {
|
|
376 |
if ( ! result ) {
|
377 |
return;
|
378 |
}
|
379 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
380 |
wc_stripe_payment_request.attachPaymentRequestButtonEventListeners( prButton, paymentRequest );
|
381 |
wc_stripe_payment_request.showPaymentRequestButton( prButton );
|
382 |
} );
|
@@ -588,6 +595,13 @@ jQuery( function( $ ) {
|
|
588 |
var addToCartButton = $( '.single_add_to_cart_button' );
|
589 |
|
590 |
prButton.on( 'click', function ( evt ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
591 |
// First check if product can be added to cart.
|
592 |
if ( addToCartButton.is( '.disabled' ) ) {
|
593 |
evt.preventDefault(); // Prevent showing payment request modal.
|
@@ -669,14 +683,25 @@ jQuery( function( $ ) {
|
|
669 |
},
|
670 |
|
671 |
attachCartPageEventListeners: function ( prButton, paymentRequest ) {
|
672 |
-
if ( ( ! wc_stripe_payment_request_params.button.is_custom || ! wc_stripe_payment_request.isCustomPaymentRequestButton( prButton ) ) &&
|
673 |
-
( ! wc_stripe_payment_request_params.button.is_branded || ! wc_stripe_payment_request.isBrandedPaymentRequestButton( prButton ) ) ) {
|
674 |
-
return;
|
675 |
-
}
|
676 |
-
|
677 |
prButton.on( 'click', function ( evt ) {
|
678 |
-
|
679 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
680 |
} );
|
681 |
},
|
682 |
|
@@ -748,4 +773,30 @@ jQuery( function( $ ) {
|
|
748 |
}
|
749 |
testImg.src = background;
|
750 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
751 |
} );
|
376 |
if ( ! result ) {
|
377 |
return;
|
378 |
}
|
379 |
+
if ( result.applePay ) {
|
380 |
+
paymentRequestType = 'apple_pay';
|
381 |
+
} else if ( result.googlePay ) {
|
382 |
+
paymentRequestType = 'google_pay';
|
383 |
+
} else {
|
384 |
+
paymentRequestType = 'payment_request_api';
|
385 |
+
}
|
386 |
+
|
387 |
wc_stripe_payment_request.attachPaymentRequestButtonEventListeners( prButton, paymentRequest );
|
388 |
wc_stripe_payment_request.showPaymentRequestButton( prButton );
|
389 |
} );
|
595 |
var addToCartButton = $( '.single_add_to_cart_button' );
|
596 |
|
597 |
prButton.on( 'click', function ( evt ) {
|
598 |
+
// If login is required for checkout, display redirect confirmation dialog.
|
599 |
+
if ( wc_stripe_payment_request_params.login_confirmation ) {
|
600 |
+
evt.preventDefault();
|
601 |
+
displayLoginConfirmation( paymentRequestType );
|
602 |
+
return;
|
603 |
+
}
|
604 |
+
|
605 |
// First check if product can be added to cart.
|
606 |
if ( addToCartButton.is( '.disabled' ) ) {
|
607 |
evt.preventDefault(); // Prevent showing payment request modal.
|
683 |
},
|
684 |
|
685 |
attachCartPageEventListeners: function ( prButton, paymentRequest ) {
|
|
|
|
|
|
|
|
|
|
|
686 |
prButton.on( 'click', function ( evt ) {
|
687 |
+
// If login is required for checkout, display redirect confirmation dialog.
|
688 |
+
if ( wc_stripe_payment_request_params.login_confirmation ) {
|
689 |
+
evt.preventDefault();
|
690 |
+
displayLoginConfirmation( paymentRequestType );
|
691 |
+
return;
|
692 |
+
}
|
693 |
+
|
694 |
+
if (
|
695 |
+
wc_stripe_payment_request.isCustomPaymentRequestButton(
|
696 |
+
prButton
|
697 |
+
) ||
|
698 |
+
wc_stripe_payment_request.isBrandedPaymentRequestButton(
|
699 |
+
prButton
|
700 |
+
)
|
701 |
+
) {
|
702 |
+
evt.preventDefault();
|
703 |
+
paymentRequest.show();
|
704 |
+
}
|
705 |
} );
|
706 |
},
|
707 |
|
773 |
}
|
774 |
testImg.src = background;
|
775 |
}
|
776 |
+
|
777 |
+
// TODO: Replace this by `client/blocks/payment-request/login-confirmation.js`
|
778 |
+
// when we start using webpack to build this file.
|
779 |
+
function displayLoginConfirmation( paymentRequestType ) {
|
780 |
+
if ( ! wc_stripe_payment_request_params.login_confirmation ) {
|
781 |
+
return;
|
782 |
+
}
|
783 |
+
|
784 |
+
var message = wc_stripe_payment_request_params.login_confirmation.message;
|
785 |
+
|
786 |
+
// Replace dialog text with specific payment request type "Apple Pay" or "Google Pay".
|
787 |
+
if ( 'payment_request_api' !== paymentRequestType ) {
|
788 |
+
message = message.replace(
|
789 |
+
/\*\*.*?\*\*/,
|
790 |
+
'apple_pay' === paymentRequestType ? 'Apple Pay' : 'Google Pay'
|
791 |
+
);
|
792 |
+
}
|
793 |
+
|
794 |
+
// Remove asterisks from string.
|
795 |
+
message = message.replace( /\*\*/g, '' );
|
796 |
+
|
797 |
+
if ( confirm( message ) ) {
|
798 |
+
// Redirect to my account page.
|
799 |
+
window.location.href = wc_stripe_payment_request_params.login_confirmation.redirect_url;
|
800 |
+
}
|
801 |
+
}
|
802 |
} );
|
assets/js/stripe-payment-request.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
jQuery(function(i){"use strict";var o,u=Stripe(wc_stripe_payment_request_params.stripe.key,{locale:"undefined"!=typeof wc_stripe_params?wc_stripe_params.stripe_locale:"auto"}),p={getAjaxURL:function(t){return wc_stripe_payment_request_params.ajax_url.toString().replace("%%endpoint%%","wc_stripe_"+t)},getCartDetails:function(){var t={security:wc_stripe_payment_request_params.nonce.payment};i.ajax({type:"POST",data:t,url:p.getAjaxURL("get_cart_details"),success:function(t){p.startPaymentRequest(t)}})},getAttributes:function(){var t=i(".variations_form").find(".variations select"),a={},n=0,r=0;return t.each(function(){var t=i(this).data("attribute_name")||i(this).attr("name"),e=i(this).val()||"";0<e.length&&r++,n++,a[t]=e}),{count:n,chosenCount:r,data:a}},processSource:function(t,e){e=p.getOrderData(t,e);return i.ajax({type:"POST",data:e,dataType:"json",url:p.getAjaxURL("create_order")})},getOrderData:function(t,e){var a=t.source,n=a.owner.email,r=a.owner.phone,s=a.owner.address,i=a.owner.name,o=t.shippingAddress,e={_wpnonce:wc_stripe_payment_request_params.nonce.checkout,billing_first_name:null!==i?i.split(" ").slice(0,1).join(" "):"",billing_last_name:null!==i?i.split(" ").slice(1).join(" "):"",billing_company:"",billing_email:null!==n?n:t.payerEmail,billing_phone:null!==r?r:t.payerPhone&&t.payerPhone.replace("/[() -]/g",""),billing_country:null!==s?s.country:"",billing_address_1:null!==s?s.line1:"",billing_address_2:null!==s?s.line2:"",billing_city:null!==s?s.city:"",billing_state:null!==s?s.state:"",billing_postcode:null!==s?s.postal_code:"",shipping_first_name:"",shipping_last_name:"",shipping_company:"",shipping_country:"",shipping_address_1:"",shipping_address_2:"",shipping_city:"",shipping_state:"",shipping_postcode:"",shipping_method:[null===t.shippingOption?null:t.shippingOption.id],order_comments:"",payment_method:"stripe",ship_to_different_address:1,terms:1,stripe_source:a.id,payment_request_type:e};return o&&(e.shipping_first_name=o.recipient.split(" ").slice(0,1).join(" "),e.shipping_last_name=o.recipient.split(" ").slice(1).join(" "),e.shipping_company=o.organization,e.shipping_country=o.country,e.shipping_address_1=void 0===o.addressLine[0]?"":o.addressLine[0],e.shipping_address_2=void 0===o.addressLine[1]?"":o.addressLine[1],e.shipping_city=o.city,e.shipping_state=o.region,e.shipping_postcode=o.postalCode),e},getErrorMessageHTML:function(t){return i('<div class="woocommerce-error" />').text(t)},displayErrorMessage:function(t){var e;i(".woocommerce-error").remove(),wc_stripe_payment_request_params.is_product_page?((e=i(".product").first()).before(t),i("html, body").animate({scrollTop:e.prev(".woocommerce-error").offset().top},600)):((e=i(".shop_table.cart").closest("form")).before(t),i("html, body").animate({scrollTop:e.prev(".woocommerce-error").offset().top},600))},abortPayment:function(t,e){t.complete("fail"),p.displayErrorMessage(e)},completePayment:function(t,e){p.block(),t.complete("success"),window.location=e},block:function(){i.blockUI({message:null,overlayCSS:{background:"#fff",opacity:.6}})},updateShippingOptions:function(t,e){e={security:wc_stripe_payment_request_params.nonce.shipping,country:e.country,state:e.region,postcode:e.postalCode,city:e.city,address:void 0===e.addressLine[0]?"":e.addressLine[0],address_2:void 0===e.addressLine[1]?"":e.addressLine[1],payment_request_type:o,is_product_page:wc_stripe_payment_request_params.is_product_page};return i.ajax({type:"POST",data:e,url:p.getAjaxURL("get_shipping_options")})},updateShippingDetails:function(t,e){e={security:wc_stripe_payment_request_params.nonce.update_shipping,shipping_method:[e.id],payment_request_type:o,is_product_page:wc_stripe_payment_request_params.is_product_page};return i.ajax({type:"POST",data:e,url:p.getAjaxURL("update_shipping_method")})},addToCart:function(){var t=i(".single_add_to_cart_button").val();i(".single_variation_wrap").length&&(t=i(".single_variation_wrap").find('input[name="product_id"]').val());var n={security:wc_stripe_payment_request_params.nonce.add_to_cart,product_id:t,qty:i(".quantity .qty").val(),attributes:i(".variations_form").length?p.getAttributes().data:[]},t=i("form.cart").serializeArray();return i.each(t,function(t,e){var a;/^addon-/.test(e.name)&&(/\[\]$/.test(e.name)?(a=e.name.substring(0,e.name.length-2),n[a]?n[a].push(e.value):n[a]=[e.value]):n[e.name]=e.value)}),i.ajax({type:"POST",data:n,url:p.getAjaxURL("add_to_cart")})},clearCart:function(){var t={security:wc_stripe_payment_request_params.nonce.clear_cart};return i.ajax({type:"POST",data:t,url:p.getAjaxURL("clear_cart"),success:function(t){}})},getRequestOptionsFromLocal:function(){return{total:wc_stripe_payment_request_params.product.total,currency:wc_stripe_payment_request_params.checkout.currency_code,country:wc_stripe_payment_request_params.checkout.country_code,requestPayerName:!0,requestPayerEmail:!0,requestPayerPhone:wc_stripe_payment_request_params.checkout.needs_payer_phone,requestShipping:wc_stripe_payment_request_params.product.requestShipping,displayItems:wc_stripe_payment_request_params.product.displayItems}},startPaymentRequest:function(t){var e,a=wc_stripe_payment_request_params.is_product_page?e=p.getRequestOptionsFromLocal():(e={total:t.order_data.total,currency:t.order_data.currency,country:t.order_data.country_code,requestPayerName:!0,requestPayerEmail:!0,requestPayerPhone:wc_stripe_payment_request_params.checkout.needs_payer_phone,requestShipping:!!t.shipping_required,displayItems:t.order_data.displayItems},t.order_data);"PR"===e.country&&(e.country="US");try{var n=u.paymentRequest(e),r=u.elements({locale:wc_stripe_payment_request_params.button.locale}),s=p.createPaymentRequestButton(r,n);n.canMakePayment().then(function(t){t&&(o=t.applePay?"apple_pay":"payment_request_api",p.attachPaymentRequestButtonEventListeners(s,n),p.showPaymentRequestButton(s))}),n.on("shippingaddresschange",function(e){i.when(p.updateShippingOptions(a,e.shippingAddress)).then(function(t){e.updateWith({status:t.result,shippingOptions:t.shipping_options,total:t.total,displayItems:t.displayItems})})}),n.on("shippingoptionchange",function(e){i.when(p.updateShippingDetails(a,e.shippingOption)).then(function(t){"success"===t.result&&e.updateWith({status:"success",total:t.total,displayItems:t.displayItems}),"fail"===t.result&&e.updateWith({status:"fail"})})}),n.on("source",function(e){"no"===wc_stripe_payment_request_params.stripe.allow_prepaid_card&&"prepaid"===e.source.card.funding?p.abortPayment(e,p.getErrorMessageHTML(wc_stripe_payment_request_params.i18n.no_prepaid_card)):i.when(p.processSource(e,o)).then(function(t){"success"===t.result?p.completePayment(e,t.redirect):p.abortPayment(e,t.messages)})})}catch(t){console.error(t)}},getSelectedProductData:function(){var t=i(".single_add_to_cart_button").val();i(".single_variation_wrap").length&&(t=i(".single_variation_wrap").find('input[name="product_id"]').val());var e=(i("#product-addons-total").data("price_data")||[]).reduce(function(t,e){return t+e.cost},0),e={security:wc_stripe_payment_request_params.nonce.get_selected_product_data,product_id:t,qty:i(".quantity .qty").val(),attributes:i(".variations_form").length?p.getAttributes().data:[],addon_value:e};return i.ajax({type:"POST",data:e,url:p.getAjaxURL("get_selected_product_data")})},debounce:function(n,r,s){var i;return function(){var t=this,e=arguments,a=s&&!i;clearTimeout(i),i=setTimeout(function(){i=null,s||r.apply(t,e)},n),a&&r.apply(t,e)}},createPaymentRequestButton:function(t,e){var a;if(wc_stripe_payment_request_params.button.is_custom&&(a=i(wc_stripe_payment_request_params.button.css_selector)).length)return a.data("isCustom",!0),a;if(wc_stripe_payment_request_params.button.is_branded){if(p.shouldUseGooglePayBrand())return(a=p.createGooglePayButton()).data("isBranded",!0),a;wc_stripe_payment_request_params.button.type="long"===wc_stripe_payment_request_params.button.branded_type?"buy":"default"}return t.create("paymentRequestButton",{paymentRequest:e,style:{paymentRequestButton:{type:wc_stripe_payment_request_params.button.type,theme:wc_stripe_payment_request_params.button.theme,height:wc_stripe_payment_request_params.button.height+"px"}}})},isCustomPaymentRequestButton:function(t){return t&&"function"==typeof t.data&&t.data("isCustom")},isBrandedPaymentRequestButton:function(t){return t&&"function"==typeof t.data&&t.data("isBranded")},shouldUseGooglePayBrand:function(){var t=window.navigator.userAgent.toLowerCase(),e=/chrome/.test(t)&&!/edge|edg|opr|brave\//.test(t)&&"Google Inc."===window.navigator.vendor,t=e&&window.navigator.brave;return e&&!t},createGooglePayButton:function(){var t=wc_stripe_payment_request_params.button.theme,e=wc_stripe_payment_request_params.button.branded_type,a=wc_stripe_payment_request_params.button.locale,n=wc_stripe_payment_request_params.button.height,r="dark"===(t=["dark","light","light-outline"].includes(t)?t:"light")?"dark":"light",e=["short","long"].includes(e)?e:"long",s=i('<button type="button" id="wc-stripe-branded-button" aria-label="Google Pay" class="gpay-button"></button>');return s.css("height",n+"px"),s.addClass(t+" "+e),"long"===e&&function(t,e,a){t.css("background-image","url("+e+")");var n=document.createElement("img");n.onerror=function(){t.css("background-image","url("+a+")")},n.src=e}(s,"https://www.gstatic.com/instantbuy/svg/"+r+"/"+a+".svg","https://www.gstatic.com/instantbuy/svg/"+r+"/en.svg"),s},attachPaymentRequestButtonEventListeners:function(t,e){t.on("click",function(t){i("body").addClass("woocommerce-stripe-prb-clicked")}),wc_stripe_payment_request_params.is_product_page?p.attachProductPageEventListeners(t,e):p.attachCartPageEventListeners(t,e)},attachProductPageEventListeners:function(e,a){var n=[],r=i(".single_add_to_cart_button");e.on("click",function(t){return r.is(".disabled")?(t.preventDefault(),void(r.is(".wc-variation-is-unavailable")?window.alert(wc_add_to_cart_variation_params.i18n_unavailable_text):r.is(".wc-variation-selection-needed")&&window.alert(wc_add_to_cart_variation_params.i18n_make_a_selection_text))):0<n.length?(t.preventDefault(),void window.alert(n)):(p.addToCart(),void((p.isCustomPaymentRequestButton(e)||p.isBrandedPaymentRequestButton(e))&&(t.preventDefault(),a.show())))}),i(document.body).on("wc_stripe_unblock_payment_request_button wc_stripe_enable_payment_request_button",function(){p.unblockPaymentRequestButton()}),i(document.body).on("wc_stripe_block_payment_request_button",function(){p.blockPaymentRequestButton("wc_request_button_is_blocked")}),i(document.body).on("wc_stripe_disable_payment_request_button",function(){p.blockPaymentRequestButton("wc_request_button_is_disabled")}),i(document.body).on("woocommerce_variation_has_changed",function(){i(document.body).trigger("wc_stripe_block_payment_request_button"),i.when(p.getSelectedProductData()).then(function(t){i.when(a.update({total:t.total,displayItems:t.displayItems})).then(function(){i(document.body).trigger("wc_stripe_unblock_payment_request_button")})})}),i(".quantity").on("input",".qty",function(){i(document.body).trigger("wc_stripe_block_payment_request_button")}),i(".quantity").on("input",".qty",p.debounce(250,function(){i(document.body).trigger("wc_stripe_block_payment_request_button"),n=[],i.when(p.getSelectedProductData()).then(function(t){t.error?(n=[t.error],i(document.body).trigger("wc_stripe_unblock_payment_request_button")):i.when(a.update({total:t.total,displayItems:t.displayItems})).then(function(){i(document.body).trigger("wc_stripe_unblock_payment_request_button")})})}))},attachCartPageEventListeners:function(t,e){(wc_stripe_payment_request_params.button.is_custom&&p.isCustomPaymentRequestButton(t)||wc_stripe_payment_request_params.button.is_branded&&p.isBrandedPaymentRequestButton(t))&&t.on("click",function(t){t.preventDefault(),e.show()})},showPaymentRequestButton:function(t){p.isCustomPaymentRequestButton(t)?(t.addClass("is-active"),i("#wc-stripe-payment-request-wrapper, #wc-stripe-payment-request-button-separator").show()):p.isBrandedPaymentRequestButton(t)?(i("#wc-stripe-payment-request-wrapper, #wc-stripe-payment-request-button-separator").show(),i("#wc-stripe-payment-request-button").html(t)):i("#wc-stripe-payment-request-button").length&&(i("#wc-stripe-payment-request-wrapper, #wc-stripe-payment-request-button-separator").show(),t.mount("#wc-stripe-payment-request-button"))},blockPaymentRequestButton:function(t){i("#wc-stripe-payment-request-button").data("blockUI.isBlocked")||i("#wc-stripe-payment-request-button").addClass(t).block({message:null})},unblockPaymentRequestButton:function(){i("#wc-stripe-payment-request-button").removeClass(["wc_request_button_is_blocked","wc_request_button_is_disabled"]).unblock()},init:function(){wc_stripe_payment_request_params.is_product_page?p.startPaymentRequest(""):p.getCartDetails()}};p.init(),i(document.body).on("updated_cart_totals",function(){p.init()}),i(document.body).on("updated_checkout",function(){p.init()})});
|
1 |
+
jQuery(function(i){"use strict";var o,p=Stripe(wc_stripe_payment_request_params.stripe.key,{locale:"undefined"!=typeof wc_stripe_params?wc_stripe_params.stripe_locale:"auto"}),u={getAjaxURL:function(t){return wc_stripe_payment_request_params.ajax_url.toString().replace("%%endpoint%%","wc_stripe_"+t)},getCartDetails:function(){var t={security:wc_stripe_payment_request_params.nonce.payment};i.ajax({type:"POST",data:t,url:u.getAjaxURL("get_cart_details"),success:function(t){u.startPaymentRequest(t)}})},getAttributes:function(){var t=i(".variations_form").find(".variations select"),a={},n=0,r=0;return t.each(function(){var t=i(this).data("attribute_name")||i(this).attr("name"),e=i(this).val()||"";0<e.length&&r++,n++,a[t]=e}),{count:n,chosenCount:r,data:a}},processSource:function(t,e){e=u.getOrderData(t,e);return i.ajax({type:"POST",data:e,dataType:"json",url:u.getAjaxURL("create_order")})},getOrderData:function(t,e){var a=t.source,n=a.owner.email,r=a.owner.phone,s=a.owner.address,i=a.owner.name,o=t.shippingAddress,e={_wpnonce:wc_stripe_payment_request_params.nonce.checkout,billing_first_name:null!==i?i.split(" ").slice(0,1).join(" "):"",billing_last_name:null!==i?i.split(" ").slice(1).join(" "):"",billing_company:"",billing_email:null!==n?n:t.payerEmail,billing_phone:null!==r?r:t.payerPhone&&t.payerPhone.replace("/[() -]/g",""),billing_country:null!==s?s.country:"",billing_address_1:null!==s?s.line1:"",billing_address_2:null!==s?s.line2:"",billing_city:null!==s?s.city:"",billing_state:null!==s?s.state:"",billing_postcode:null!==s?s.postal_code:"",shipping_first_name:"",shipping_last_name:"",shipping_company:"",shipping_country:"",shipping_address_1:"",shipping_address_2:"",shipping_city:"",shipping_state:"",shipping_postcode:"",shipping_method:[null===t.shippingOption?null:t.shippingOption.id],order_comments:"",payment_method:"stripe",ship_to_different_address:1,terms:1,stripe_source:a.id,payment_request_type:e};return o&&(e.shipping_first_name=o.recipient.split(" ").slice(0,1).join(" "),e.shipping_last_name=o.recipient.split(" ").slice(1).join(" "),e.shipping_company=o.organization,e.shipping_country=o.country,e.shipping_address_1=void 0===o.addressLine[0]?"":o.addressLine[0],e.shipping_address_2=void 0===o.addressLine[1]?"":o.addressLine[1],e.shipping_city=o.city,e.shipping_state=o.region,e.shipping_postcode=o.postalCode),e},getErrorMessageHTML:function(t){return i('<div class="woocommerce-error" />').text(t)},displayErrorMessage:function(t){var e;i(".woocommerce-error").remove(),wc_stripe_payment_request_params.is_product_page?((e=i(".product").first()).before(t),i("html, body").animate({scrollTop:e.prev(".woocommerce-error").offset().top},600)):((e=i(".shop_table.cart").closest("form")).before(t),i("html, body").animate({scrollTop:e.prev(".woocommerce-error").offset().top},600))},abortPayment:function(t,e){t.complete("fail"),u.displayErrorMessage(e)},completePayment:function(t,e){u.block(),t.complete("success"),window.location=e},block:function(){i.blockUI({message:null,overlayCSS:{background:"#fff",opacity:.6}})},updateShippingOptions:function(t,e){e={security:wc_stripe_payment_request_params.nonce.shipping,country:e.country,state:e.region,postcode:e.postalCode,city:e.city,address:void 0===e.addressLine[0]?"":e.addressLine[0],address_2:void 0===e.addressLine[1]?"":e.addressLine[1],payment_request_type:o,is_product_page:wc_stripe_payment_request_params.is_product_page};return i.ajax({type:"POST",data:e,url:u.getAjaxURL("get_shipping_options")})},updateShippingDetails:function(t,e){e={security:wc_stripe_payment_request_params.nonce.update_shipping,shipping_method:[e.id],payment_request_type:o,is_product_page:wc_stripe_payment_request_params.is_product_page};return i.ajax({type:"POST",data:e,url:u.getAjaxURL("update_shipping_method")})},addToCart:function(){var t=i(".single_add_to_cart_button").val();i(".single_variation_wrap").length&&(t=i(".single_variation_wrap").find('input[name="product_id"]').val());var n={security:wc_stripe_payment_request_params.nonce.add_to_cart,product_id:t,qty:i(".quantity .qty").val(),attributes:i(".variations_form").length?u.getAttributes().data:[]},t=i("form.cart").serializeArray();return i.each(t,function(t,e){var a;/^addon-/.test(e.name)&&(/\[\]$/.test(e.name)?(a=e.name.substring(0,e.name.length-2),n[a]?n[a].push(e.value):n[a]=[e.value]):n[e.name]=e.value)}),i.ajax({type:"POST",data:n,url:u.getAjaxURL("add_to_cart")})},clearCart:function(){var t={security:wc_stripe_payment_request_params.nonce.clear_cart};return i.ajax({type:"POST",data:t,url:u.getAjaxURL("clear_cart"),success:function(t){}})},getRequestOptionsFromLocal:function(){return{total:wc_stripe_payment_request_params.product.total,currency:wc_stripe_payment_request_params.checkout.currency_code,country:wc_stripe_payment_request_params.checkout.country_code,requestPayerName:!0,requestPayerEmail:!0,requestPayerPhone:wc_stripe_payment_request_params.checkout.needs_payer_phone,requestShipping:wc_stripe_payment_request_params.product.requestShipping,displayItems:wc_stripe_payment_request_params.product.displayItems}},startPaymentRequest:function(t){var e,a=wc_stripe_payment_request_params.is_product_page?e=u.getRequestOptionsFromLocal():(e={total:t.order_data.total,currency:t.order_data.currency,country:t.order_data.country_code,requestPayerName:!0,requestPayerEmail:!0,requestPayerPhone:wc_stripe_payment_request_params.checkout.needs_payer_phone,requestShipping:!!t.shipping_required,displayItems:t.order_data.displayItems},t.order_data);"PR"===e.country&&(e.country="US");try{var n=p.paymentRequest(e),r=p.elements({locale:wc_stripe_payment_request_params.button.locale}),s=u.createPaymentRequestButton(r,n);n.canMakePayment().then(function(t){t&&(o=t.applePay?"apple_pay":t.googlePay?"google_pay":"payment_request_api",u.attachPaymentRequestButtonEventListeners(s,n),u.showPaymentRequestButton(s))}),n.on("shippingaddresschange",function(e){i.when(u.updateShippingOptions(a,e.shippingAddress)).then(function(t){e.updateWith({status:t.result,shippingOptions:t.shipping_options,total:t.total,displayItems:t.displayItems})})}),n.on("shippingoptionchange",function(e){i.when(u.updateShippingDetails(a,e.shippingOption)).then(function(t){"success"===t.result&&e.updateWith({status:"success",total:t.total,displayItems:t.displayItems}),"fail"===t.result&&e.updateWith({status:"fail"})})}),n.on("source",function(e){"no"===wc_stripe_payment_request_params.stripe.allow_prepaid_card&&"prepaid"===e.source.card.funding?u.abortPayment(e,u.getErrorMessageHTML(wc_stripe_payment_request_params.i18n.no_prepaid_card)):i.when(u.processSource(e,o)).then(function(t){"success"===t.result?u.completePayment(e,t.redirect):u.abortPayment(e,t.messages)})})}catch(t){console.error(t)}},getSelectedProductData:function(){var t=i(".single_add_to_cart_button").val();i(".single_variation_wrap").length&&(t=i(".single_variation_wrap").find('input[name="product_id"]').val());var e=(i("#product-addons-total").data("price_data")||[]).reduce(function(t,e){return t+e.cost},0),e={security:wc_stripe_payment_request_params.nonce.get_selected_product_data,product_id:t,qty:i(".quantity .qty").val(),attributes:i(".variations_form").length?u.getAttributes().data:[],addon_value:e};return i.ajax({type:"POST",data:e,url:u.getAjaxURL("get_selected_product_data")})},debounce:function(n,r,s){var i;return function(){var t=this,e=arguments,a=s&&!i;clearTimeout(i),i=setTimeout(function(){i=null,s||r.apply(t,e)},n),a&&r.apply(t,e)}},createPaymentRequestButton:function(t,e){var a;if(wc_stripe_payment_request_params.button.is_custom&&(a=i(wc_stripe_payment_request_params.button.css_selector)).length)return a.data("isCustom",!0),a;if(wc_stripe_payment_request_params.button.is_branded){if(u.shouldUseGooglePayBrand())return(a=u.createGooglePayButton()).data("isBranded",!0),a;wc_stripe_payment_request_params.button.type="long"===wc_stripe_payment_request_params.button.branded_type?"buy":"default"}return t.create("paymentRequestButton",{paymentRequest:e,style:{paymentRequestButton:{type:wc_stripe_payment_request_params.button.type,theme:wc_stripe_payment_request_params.button.theme,height:wc_stripe_payment_request_params.button.height+"px"}}})},isCustomPaymentRequestButton:function(t){return t&&"function"==typeof t.data&&t.data("isCustom")},isBrandedPaymentRequestButton:function(t){return t&&"function"==typeof t.data&&t.data("isBranded")},shouldUseGooglePayBrand:function(){var t=window.navigator.userAgent.toLowerCase(),e=/chrome/.test(t)&&!/edge|edg|opr|brave\//.test(t)&&"Google Inc."===window.navigator.vendor,t=e&&window.navigator.brave;return e&&!t},createGooglePayButton:function(){var t=wc_stripe_payment_request_params.button.theme,e=wc_stripe_payment_request_params.button.branded_type,a=wc_stripe_payment_request_params.button.locale,n=wc_stripe_payment_request_params.button.height,r="dark"===(t=["dark","light","light-outline"].includes(t)?t:"light")?"dark":"light",e=["short","long"].includes(e)?e:"long",s=i('<button type="button" id="wc-stripe-branded-button" aria-label="Google Pay" class="gpay-button"></button>');return s.css("height",n+"px"),s.addClass(t+" "+e),"long"===e&&function(t,e,a){t.css("background-image","url("+e+")");var n=document.createElement("img");n.onerror=function(){t.css("background-image","url("+a+")")},n.src=e}(s,"https://www.gstatic.com/instantbuy/svg/"+r+"/"+a+".svg","https://www.gstatic.com/instantbuy/svg/"+r+"/en.svg"),s},attachPaymentRequestButtonEventListeners:function(t,e){t.on("click",function(t){i("body").addClass("woocommerce-stripe-prb-clicked")}),wc_stripe_payment_request_params.is_product_page?u.attachProductPageEventListeners(t,e):u.attachCartPageEventListeners(t,e)},attachProductPageEventListeners:function(e,a){var n=[],r=i(".single_add_to_cart_button");e.on("click",function(t){return wc_stripe_payment_request_params.login_confirmation?(t.preventDefault(),void s(o)):r.is(".disabled")?(t.preventDefault(),void(r.is(".wc-variation-is-unavailable")?window.alert(wc_add_to_cart_variation_params.i18n_unavailable_text):r.is(".wc-variation-selection-needed")&&window.alert(wc_add_to_cart_variation_params.i18n_make_a_selection_text))):0<n.length?(t.preventDefault(),void window.alert(n)):(u.addToCart(),void((u.isCustomPaymentRequestButton(e)||u.isBrandedPaymentRequestButton(e))&&(t.preventDefault(),a.show())))}),i(document.body).on("wc_stripe_unblock_payment_request_button wc_stripe_enable_payment_request_button",function(){u.unblockPaymentRequestButton()}),i(document.body).on("wc_stripe_block_payment_request_button",function(){u.blockPaymentRequestButton("wc_request_button_is_blocked")}),i(document.body).on("wc_stripe_disable_payment_request_button",function(){u.blockPaymentRequestButton("wc_request_button_is_disabled")}),i(document.body).on("woocommerce_variation_has_changed",function(){i(document.body).trigger("wc_stripe_block_payment_request_button"),i.when(u.getSelectedProductData()).then(function(t){i.when(a.update({total:t.total,displayItems:t.displayItems})).then(function(){i(document.body).trigger("wc_stripe_unblock_payment_request_button")})})}),i(".quantity").on("input",".qty",function(){i(document.body).trigger("wc_stripe_block_payment_request_button")}),i(".quantity").on("input",".qty",u.debounce(250,function(){i(document.body).trigger("wc_stripe_block_payment_request_button"),n=[],i.when(u.getSelectedProductData()).then(function(t){t.error?(n=[t.error],i(document.body).trigger("wc_stripe_unblock_payment_request_button")):i.when(a.update({total:t.total,displayItems:t.displayItems})).then(function(){i(document.body).trigger("wc_stripe_unblock_payment_request_button")})})}))},attachCartPageEventListeners:function(e,a){e.on("click",function(t){return wc_stripe_payment_request_params.login_confirmation?(t.preventDefault(),void s(o)):void((u.isCustomPaymentRequestButton(e)||u.isBrandedPaymentRequestButton(e))&&(t.preventDefault(),a.show()))})},showPaymentRequestButton:function(t){u.isCustomPaymentRequestButton(t)?(t.addClass("is-active"),i("#wc-stripe-payment-request-wrapper, #wc-stripe-payment-request-button-separator").show()):u.isBrandedPaymentRequestButton(t)?(i("#wc-stripe-payment-request-wrapper, #wc-stripe-payment-request-button-separator").show(),i("#wc-stripe-payment-request-button").html(t)):i("#wc-stripe-payment-request-button").length&&(i("#wc-stripe-payment-request-wrapper, #wc-stripe-payment-request-button-separator").show(),t.mount("#wc-stripe-payment-request-button"))},blockPaymentRequestButton:function(t){i("#wc-stripe-payment-request-button").data("blockUI.isBlocked")||i("#wc-stripe-payment-request-button").addClass(t).block({message:null})},unblockPaymentRequestButton:function(){i("#wc-stripe-payment-request-button").removeClass(["wc_request_button_is_blocked","wc_request_button_is_disabled"]).unblock()},init:function(){wc_stripe_payment_request_params.is_product_page?u.startPaymentRequest(""):u.getCartDetails()}};function s(t){var e;wc_stripe_payment_request_params.login_confirmation&&(e=wc_stripe_payment_request_params.login_confirmation.message,e=(e="payment_request_api"!==t?e.replace(/\*\*.*?\*\*/,"apple_pay"===t?"Apple Pay":"Google Pay"):e).replace(/\*\*/g,""),confirm(e)&&(window.location.href=wc_stripe_payment_request_params.login_confirmation.redirect_url))}u.init(),i(document.body).on("updated_cart_totals",function(){u.init()}),i(document.body).on("updated_checkout",function(){u.init()})});
|
build/index.asset.php
CHANGED
@@ -1 +1 @@
|
|
1 |
-
<?php return array('dependencies' => array('jquery', 'react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => '
|
1 |
+
<?php return array('dependencies' => array('jquery', 'react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => 'c889ba6aebe35154550efe0912fbb67c');
|
build/index.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=20)}([function(e,t){e.exports=window.wp.element},function(e,t){e.exports=window.wp.i18n},function(e,t){e.exports=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,n){var r=n(13),o=n(14),i=n(15),c=n(17);e.exports=function(e,t){return r(e)||o(e,t)||i(e,t)||c()},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,n){!function(e,t){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function o(){}function i(){}t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t,i.resetWarningCache=o;var c=function(e,t){return function(e){e.exports=function(){function e(e,t,n,r,o,i){if("SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"!==i){var c=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw c.name="Invariant Violation",c}}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:o};return n.PropTypes=n,n}()}(t={exports:{}}),t.exports}(),a=function(e){return null!==e&&"object"===n(e)},u=function e(t,n){if(!a(t)||!a(n))return t===n;var r=Array.isArray(t);if(r!==Array.isArray(n))return!1;var o="[object Object]"===Object.prototype.toString.call(t);if(o!==("[object Object]"===Object.prototype.toString.call(n)))return!1;if(!o&&!r)return!1;var i=Object.keys(t),c=Object.keys(n);if(i.length!==c.length)return!1;for(var u={},s=0;s<i.length;s+=1)u[i[s]]=!0;for(var l=0;l<c.length;l+=1)u[c[l]]=!0;var p=Object.keys(u);if(p.length!==i.length)return!1;var d=t,f=n;return p.every((function(t){return e(d[t],f[t])}))},s=function(e){var n=t.useRef(e);return t.useEffect((function(){n.current=e}),[e]),n.current},l=function(e){if(null===e||a(t=e)&&"function"==typeof t.elements&&"function"==typeof t.createToken&&"function"==typeof t.createPaymentMethod&&"function"==typeof t.confirmCardPayment)return e;var t;throw new Error("Invalid prop `stripe` supplied to `Elements`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.")},p=t.createContext(null);p.displayName="ElementsContext";var d=function(e){var n,o,i=e.stripe,c=e.options,d=e.children,f=t.useRef(!1),m=t.useRef(!0),v=t.useMemo((function(){return function(e){if(function(e){return a(e)&&"function"==typeof e.then}(e))return{tag:"async",stripePromise:Promise.resolve(e).then(l)};var t=l(e);return null===t?{tag:"empty"}:{tag:"sync",stripe:t}}(i)}),[i]),y=(n=t.useState((function(){return{stripe:null,elements:null}})),o=2,function(e){if(Array.isArray(e))return e}(n)||function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var n=[],_n=!0,r=!1,o=void 0;try{for(var i,c=e[Symbol.iterator]();!(_n=(i=c.next()).done)&&(n.push(i.value),!t||n.length!==t);_n=!0);}catch(e){r=!0,o=e}finally{try{_n||null==c.return||c.return()}finally{if(r)throw o}}return n}}(n,o)||function(e,t){if(e){if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}}(n,o)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),b=y[0],g=y[1],h=s(i),_=s(c);return null!==h&&(h!==i&&console.warn("Unsupported prop change on Elements: You cannot change the `stripe` prop after setting it."),u(c,_)||console.warn("Unsupported prop change on Elements: You cannot change the `options` prop after setting the `stripe` prop.")),f.current||("sync"===v.tag&&(f.current=!0,g({stripe:v.stripe,elements:v.stripe.elements(c)})),"async"===v.tag&&(f.current=!0,v.stripePromise.then((function(e){e&&m.current&&g({stripe:e,elements:e.elements(c)})})))),t.useEffect((function(){return function(){m.current=!1}}),[]),t.useEffect((function(){var e=b.stripe;e&&e._registerWrapper&&e._registerWrapper({name:"react-stripe-js",version:"1.2.2"})}),[b.stripe]),t.createElement(p.Provider,{value:b},d)};d.propTypes={stripe:c.any,options:c.object};var f=function(e){return function(e,t){if(!e)throw new Error("Could not find Elements context; You need to wrap the part of your app that ".concat(t," in an <Elements> provider."));return e}(t.useContext(p),e)},m=function(e){return(0,e.children)(f("mounts <ElementsConsumer>"))};m.propTypes={children:c.func.isRequired};var v=function(e){var n=t.useRef(e);return t.useEffect((function(){n.current=e}),[e]),function(){n.current&&n.current.apply(n,arguments)}},y=function(e){return a(e)?(e.paymentRequest,function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,["paymentRequest"])):{}},b=function(){},g=function(e,n){var r,o="".concat((r=e).charAt(0).toUpperCase()+r.slice(1),"Element"),i=n?function(e){f("mounts <".concat(o,">"));var n=e.id,r=e.className;return t.createElement("div",{id:n,className:r})}:function(n){var r=n.id,i=n.className,c=n.options,a=void 0===c?{}:c,s=n.onBlur,l=void 0===s?b:s,p=n.onFocus,d=void 0===p?b:p,m=n.onReady,g=void 0===m?b:m,h=n.onChange,_=void 0===h?b:h,w=n.onEscape,O=void 0===w?b:w,E=n.onClick,j=void 0===E?b:E,C=f("mounts <".concat(o,">")).elements,x=t.useRef(null),S=t.useRef(null),R=v(g),P=v(l),T=v(d),k=v(j),I=v(_),A=v(O);t.useLayoutEffect((function(){if(null==x.current&&C&&null!=S.current){var t=C.create(e,a);x.current=t,t.mount(S.current),t.on("ready",(function(){return R(t)})),t.on("change",I),t.on("blur",P),t.on("focus",T),t.on("escape",A),t.on("click",k)}}));var M=t.useRef(a);return t.useEffect((function(){M.current&&M.current.paymentRequest!==a.paymentRequest&&console.warn("Unsupported prop change: options.paymentRequest is not a customizable property.");var e=y(a);0===Object.keys(e).length||u(e,y(M.current))||x.current&&(x.current.update(e),M.current=a)}),[a]),t.useLayoutEffect((function(){return function(){x.current&&x.current.destroy()}}),[]),t.createElement("div",{id:r,className:i,ref:S})};return i.propTypes={id:c.string,className:c.string,onChange:c.func,onBlur:c.func,onFocus:c.func,onReady:c.func,onClick:c.func,options:c.object},i.displayName=o,i.__elementType=e,i},h="undefined"==typeof window,_=g("auBankAccount",h),w=g("card",h),O=g("cardNumber",h),E=g("cardExpiry",h),j=g("cardCvc",h),C=g("fpxBank",h),x=g("iban",h),S=g("idealBank",h),R=g("paymentRequestButton",h);e.AuBankAccountElement=_,e.CardCvcElement=j,e.CardElement=w,e.CardExpiryElement=E,e.CardNumberElement=O,e.Elements=d,e.ElementsConsumer=m,e.FpxBankElement=C,e.IbanElement=x,e.IdealBankElement=S,e.PaymentRequestButtonElement=R,e.useElements=function(){return f("calls useElements()").elements},e.useStripe=function(){return f("calls useStripe()").stripe},Object.defineProperty(e,"__esModule",{value:!0})}(t,n(19))},function(e,t){e.exports=window.regeneratorRuntime},function(e,t){e.exports=window.jQuery},function(e,t){function n(e,t,n,r,o,i,c){try{var a=e[i](c),u=a.value}catch(e){return void n(e)}a.done?t(u):Promise.resolve(u).then(r,o)}e.exports=function(e){return function(){var t=this,r=arguments;return new Promise((function(o,i){var c=e.apply(t,r);function a(e){n(c,o,i,a,u,"next",e)}function u(e){n(c,o,i,a,u,"throw",e)}a(void 0)}))}},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,n){var r=n(18);e.exports=function(e,t){if(null==e)return{};var n,o,i=r(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(o=0;o<c.length;o++)n=c[o],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=window.wc.wcSettings},function(e,t){e.exports=window.wc.wcBlocksRegistry},function(e,t){function n(){return e.exports=n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},e.exports.default=e.exports,e.exports.__esModule=!0,n.apply(this,arguments)}e.exports=n,e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){function n(t){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?(e.exports=n=function(e){return typeof e},e.exports.default=e.exports,e.exports.__esModule=!0):(e.exports=n=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.default=e.exports,e.exports.__esModule=!0),n(t)}e.exports=n,e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(e){if(Array.isArray(e))return e},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var n=[],_n=!0,r=!1,o=void 0;try{for(var i,c=e[Symbol.iterator]();!(_n=(i=c.next()).done)&&(n.push(i.value),!t||n.length!==t);_n=!0);}catch(e){r=!0,o=e}finally{try{_n||null==c.return||c.return()}finally{if(r)throw o}}return n}},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,n){var r=n(16);e.exports=function(e,t){if(e){if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(o[n]=e[n]);return o},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=window.React},function(e,t,n){"use strict";n.r(t);var r=n(10),o=n(11),i=n.n(o),c=n(3),a=n.n(c),u=n(8),s=n.n(u),l=n(0),p=n(1),d=n(2),f=n.n(d),m=n(9),v={INVALID_EMAIL:"email_invalid",INVALID_REQUEST:"invalid_request_error",API_CONNECTION:"api_connection_error",API_ERROR:"api_error",AUTHENTICATION_ERROR:"authentication_error",RATE_LIMIT_ERROR:"rate_limit_error",CARD_ERROR:"card_error",VALIDATION_ERROR:"validation_error"},y=function(){var e=Object(m.getSetting)("stripe_data",null);if(!e)throw new Error("Stripe initialization data is not available");return e},b=function(e,t){var n,r,o={total:t.order_data.total,currency:t.order_data.currency,country:t.order_data.country_code,requestPayerName:!0,requestPayerEmail:!0,requestPayerPhone:null===(n=y())||void 0===n||null===(r=n.checkout)||void 0===r?void 0:r.needs_payer_phone,requestShipping:!!t.shipping_required,displayItems:t.order_data.displayItems};return"PR"===o.country&&(o.country="US"),e.paymentRequest(o)},g=function(e){return[v.INVALID_REQUEST,v.API_CONNECTION,v.API_ERROR,v.AUTHENTICATION_ERROR,v.RATE_LIMIT_ERROR].includes(e)},h=function(e){var t;return(t={},f()(t,"invalid_number",Object(p.__)("The card number is not a valid credit card number.","woocommerce-gateway-stripe")),f()(t,"invalid_expiry_month",Object(p.__)("The card expiration month is invalid.","woocommerce-gateway-stripe")),f()(t,"invalid_expiry_year",Object(p.__)("The card expiration year is invalid.","woocommerce-gateway-stripe")),f()(t,"invalid_cvc",Object(p.__)("The card security code is invalid.","woocommerce-gateway-stripe")),f()(t,"incorrect_number",Object(p.__)("The card number is incorrect.","woocommerce-gateway-stripe")),f()(t,"incomplete_number",Object(p.__)("The card number is incomplete.","woocommerce-gateway-stripe")),f()(t,"incomplete_cvc",Object(p.__)("The card security code is incomplete.","woocommerce-gateway-stripe")),f()(t,"incomplete_expiry",Object(p.__)("The card expiration date is incomplete.","woocommerce-gateway-stripe")),f()(t,"expired_card",Object(p.__)("The card has expired.","woocommerce-gateway-stripe")),f()(t,"incorrect_cvc",Object(p.__)("The card security code is incorrect.","woocommerce-gateway-stripe")),f()(t,"incorrect_zip",Object(p.__)("The card zip code failed validation.","woocommerce-gateway-stripe")),f()(t,"invalid_expiry_year_past",Object(p.__)("The card expiration year is in the past","woocommerce-gateway-stripe")),f()(t,"card_declined",Object(p.__)("The card was declined.","woocommerce-gateway-stripe")),f()(t,"missing",Object(p.__)("There is no card on a customer that is being charged.","woocommerce-gateway-stripe")),f()(t,"processing_error",Object(p.__)("An error occurred while processing the card.","woocommerce-gateway-stripe")),t)[e]||null},_=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";switch(e){case v.INVALID_EMAIL:return Object(p.__)("Invalid email address, please correct and try again.","woocommerce-gateway-stripe");case g(e):return Object(p.__)("Unable to process this payment, please try again or use alternative method.","woocommerce-gateway-stripe");case v.CARD_ERROR:return h(t);case v.VALIDATION_ERROR:return""}return null},w="https://js.stripe.com/v3",O=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,E="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used",j=null,C=function(e,t,n){if(null===e)return null;var r=e.apply(void 0,t);return function(e,t){e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",version:"1.11.0",startTime:t})}(r,n),r},x=Promise.resolve().then((function(){return e=null,null!==j?j:j=new Promise((function(t,n){if("undefined"!=typeof window)if(window.Stripe&&e&&console.warn(E),window.Stripe)t(window.Stripe);else try{var r=function(){for(var e=document.querySelectorAll('script[src^="'.concat(w,'"]')),t=0;t<e.length;t++){var n=e[t];if(O.test(n.src))return n}return null}();r&&e?console.warn(E):r||(r=function(e){var t=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",n=document.createElement("script");n.src="".concat(w).concat(t);var r=document.head||document.body;if(!r)throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");return r.appendChild(n),n}(e)),r.addEventListener("load",(function(){window.Stripe?t(window.Stripe):n(new Error("Stripe.js not available"))})),r.addEventListener("error",(function(){n(new Error("Failed to load Stripe.js"))}))}catch(e){return void n(e)}else t(null)}));var e})),S=!1;x.catch((function(e){S||console.warn(e)}));var R=function(){return new Promise((function(e){try{var t,n,r=null!==(t=null===(n=y())||void 0===n?void 0:n.stripe_locale)&&void 0!==t?t:"auto";e(function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];S=!0;var r=Date.now();return x.then((function(e){return C(e,t,r)}))}(function(){var e,t=null===(e=y())||void 0===e?void 0:e.key;if(!t)throw new Error("There is no api key available for stripe. Make sure it is available on the wc.stripe_data.stripe.key property.");return t}(),{locale:r}))}catch(t){e({error:t})}}))},P=n(4),T=n(7),k=n.n(T),I=n(5),A=n.n(I),M=function(e){var t=e.stripe,n=e.paymentDetails,r=e.errorContext,o=e.errorType,i={type:e.successType};if(!n.setup_intent&&!n.payment_intent_secret)return!0;var c=!!n.setupIntent,a=n.verification_endpoint,u=c?n.setup_intent:n.payment_intent_secret;return t[c?"confirmCardSetup":"confirmCardPayment"](u).then((function(e){if(e.error)throw e.error;var t=e[c?"setupIntent":"paymentIntent"];return"requires_capture"!==t.status&&"succeeded"!==t.status||(i.redirectUrl=a),i})).catch((function(e){return i.type=o,i.message=e.message,i.retry=!0,i.messageContext=r,window.fetch(a+"&is_ajax"),i}))},N=function(e,t,n,r){Object(l.useEffect)((function(){var o=t(function(){var t=k()(A.a.mark((function t(o){var i,c,a;return A.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=o.processingResponse,c=i.paymentDetails||{},t.next=4,M({stripe:e,paymentDetails:c,errorContext:r.noticeContexts.PAYMENTS,errorType:r.responseTypes.ERROR,successType:r.responseTypes.SUCCESS});case 4:return(a=t.sent).type===r.responseTypes.ERROR&&a.retry&&n(""),t.abrupt("return",a);case 7:case"end":return t.stop()}}),t)})));return function(_x){return t.apply(this,arguments)}}());return function(){return o()}}),[t,r.noticeContexts.PAYMENTS,r.responseTypes.ERROR,r.responseTypes.SUCCESS,n,e])},L=function(){},D=function(e){var t=e.eventRegistration,n=e.emitResponse,r=Object(P.useStripe)(),o=t.onCheckoutAfterProcessingWithSuccess;return N(r,o,L,n),null},q=n(12),B=n.n(q);function U(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function F(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?U(Object(n),!0).forEach((function(t){f()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):U(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var V={style:{base:{iconColor:"#666EE8",color:"#31325F",fontSize:function(e,t,n){var r={};if("object"===("undefined"==typeof document?"undefined":B()(document))&&"function"==typeof document.querySelector&&"function"==typeof window.getComputedStyle){var o=document.querySelector(".wc-block-checkout");o&&(r=window.getComputedStyle(o))}return r.fontSize||"16px"}(),lineHeight:1.375,"::placeholder":{color:"#fff"}}},classes:{focus:"focused",empty:"empty",invalid:"has-error"}},H=function(e){var t=Object(l.useState)(!1),n=a()(t,2),r=n[0],o=n[1],i=Object(l.useState)(F(F({},V),e)),c=a()(i,2),u=c[0],s=c[1],p=Object(l.useState)(""),d=a()(p,2),f=d[0],m=d[1];return Object(l.useEffect)((function(){var e=r?"#CFD7E0":"#fff";s((function(t){var n=void 0!==t.showIcon?{showIcon:r}:{};return F(F({},t),{},{style:F(F({},t.style),{},{base:F(F({},t.style.base),{},{"::placeholder":{color:e}})})},n)}))}),[r]),{options:u,onActive:Object(l.useCallback)((function(e){o(!e||function(e){return!e})}),[o]),error:f,setError:m}};function W(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Y(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?W(Object(n),!0).forEach((function(t){f()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):W(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var z,Z,$,Q,G,J,K=function(e){var t=e.inputErrorComponent,n=e.onChange,r=Object(l.useState)(!0),o=a()(r,2),i=o[0],c=o[1],u=H({hidePostalCode:!0}),s=u.options,d=u.onActive,f=u.error,m=u.setError;return Object(l.createElement)(l.Fragment,null,Object(l.createElement)("div",{className:"wc-block-gateway-container wc-inline-card-element"},Object(l.createElement)(P.CardElement,{id:"wc-stripe-inline-card-element",className:"wc-block-gateway-input",options:s,onBlur:function(){return d(i)},onFocus:function(){return d(i)},onChange:function(e){e.error?m(e.error.message):m(""),c(e.empty),n(e)}}),Object(l.createElement)("label",{htmlFor:"wc-stripe-inline-card-element"},Object(p.__)("Credit Card Information","woocommerce-gateway-stripe"))),Object(l.createElement)(t,{errorMessage:f}))},X=function(e){var t=e.onChange,n=e.inputErrorComponent,r=Object(l.useState)({cardNumber:!0,cardExpiry:!0,cardCvc:!0}),o=a()(r,2),i=o[0],c=o[1],u=H({showIcon:!1}),s=u.options,d=u.onActive,m=u.error,v=u.setError,y=H(),b=y.options,g=y.onActive,h=y.error,_=y.setError,w=H(),O=w.options,E=w.onActive,j=w.error,C=w.setError,x=function(e,n){return function(r){r.error?e(r.error.message):e(""),c(Y(Y({},i),{},f()({},n,r.empty))),t(r)}};return Object(l.createElement)("div",{className:"wc-block-card-elements"},Object(l.createElement)("div",{className:"wc-block-gateway-container wc-card-number-element"},Object(l.createElement)(P.CardNumberElement,{onChange:x(v,"cardNumber"),options:s,className:"wc-block-gateway-input",id:"wc-stripe-card-number-element",onFocus:function(){return d(i.cardNumber)},onBlur:function(){return d(i.cardNumber)}}),Object(l.createElement)("label",{htmlFor:"wc-stripe-card-number-element"},Object(p.__)("Card Number","woocommerce-gateway-stripe")),Object(l.createElement)(n,{errorMessage:m})),Object(l.createElement)("div",{className:"wc-block-gateway-container wc-card-expiry-element"},Object(l.createElement)(P.CardExpiryElement,{onChange:x(_,"cardExpiry"),options:b,className:"wc-block-gateway-input",onFocus:function(){return g(i.cardExpiry)},onBlur:function(){return g(i.cardExpiry)},id:"wc-stripe-card-expiry-element"}),Object(l.createElement)("label",{htmlFor:"wc-stripe-card-expiry-element"},Object(p.__)("Expiry Date","woocommerce-gateway-stripe")),Object(l.createElement)(n,{errorMessage:h})),Object(l.createElement)("div",{className:"wc-block-gateway-container wc-card-cvc-element"},Object(l.createElement)(P.CardCvcElement,{onChange:x(C,"cardCvc"),options:O,className:"wc-block-gateway-input",onFocus:function(){return E(i.cardCvc)},onBlur:function(){return E(i.cardCvc)},id:"wc-stripe-card-code-element"}),Object(l.createElement)("label",{htmlFor:"wc-stripe-card-code-element"},Object(p.__)("CVV/CVC","woocommerce-gateway-stripe")),Object(l.createElement)(n,{errorMessage:j})))},ee=function(){var e,t;return Object.entries(null!==(e=null===(t=y())||void 0===t?void 0:t.icons)&&void 0!==e?e:{}).map((function(e){var t=a()(e,2),n=t[0],r=t[1];return{id:n,src:r.src,alt:r.alt}}))},te=function(e){var t,n=e.billing,r=e.eventRegistration,o=e.emitResponse,i=e.components,c=i.ValidationInputError,u=i.PaymentMethodIcons,s=Object(l.useState)(""),p=a()(s,2),d=p[0],f=p[1],m=Object(P.useStripe)(),b=function(e,t,n,r,o,i){var c=Object(l.useState)(""),u=a()(c,2),s=u[0],p=u[1],d=Object(l.useCallback)((function(e){var t,n=e.error.type,r=e.error.code||"",o=null!==(t=_(n,r))&&void 0!==t?t:e.error.message;return p(o),o}),[]),f=e.onCheckoutAfterProcessingWithSuccess,m=e.onPaymentProcessing,b=e.onCheckoutAfterProcessingWithError;return N(i,f,r,o),function(e,t,n,r,o,i,c,a){var u=Object(P.useElements)();Object(l.useEffect)((function(){var s=function(){var e=k()(A.a.mark((function e(t){var r,o;return A.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o="yes"===(null===(r=y())||void 0===r?void 0:r.inline_cc_form)?P.CardElement:P.CardNumberElement,e.next=3,n.createSource(null==u?void 0:u.getElement(o),{type:"card",owner:t});case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e)})));return function(_x){return e.apply(this,arguments)}}(),l=a(function(){var n=k()(A.a.mark((function n(){var a,u,l,p,d;return A.a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(n.prev=0,l=r.billingData,!t){n.next=4;break}return n.abrupt("return",{type:o.responseTypes.ERROR,message:t});case 4:if(""===i){n.next=6;break}return n.abrupt("return",{type:o.responseTypes.SUCCESS,meta:{paymentMethodData:{paymentMethod:"stripe",paymentRequestType:"cc",stripe_source:i},billingData:l}});case 6:return p={address:{line1:l.address_1,line2:l.address_2,city:l.city,state:l.state,postal_code:l.postcode,country:l.country}},l.phone&&(p.phone=l.phone),l.email&&(p.email=l.email),(l.first_name||l.last_name)&&(p.name="".concat(l.first_name," ").concat(l.last_name)),n.next=12,s(p);case 12:if(!(d=n.sent).error){n.next=15;break}return n.abrupt("return",{type:o.responseTypes.ERROR,message:e(d)});case 15:if(d.source&&d.source.id){n.next=17;break}throw new Error(_(v.API_ERROR));case 17:return c(d.source.id),n.abrupt("return",{type:o.responseTypes.SUCCESS,meta:{paymentMethodData:{stripe_source:d.source.id,billing_email:p.email,billing_first_name:null!==(a=null==l?void 0:l.first_name)&&void 0!==a?a:"",billing_last_name:null!==(u=null==l?void 0:l.last_name)&&void 0!==u?u:"",paymentMethod:"stripe",paymentRequestType:"cc"},billingData:l}});case 21:return n.prev=21,n.t0=n.catch(0),n.abrupt("return",{type:o.responseTypes.ERROR,message:n.t0});case 24:case"end":return n.stop()}}),n,null,[[0,21]])})));return function(){return n.apply(this,arguments)}}());return function(){l()}}),[a,r.billingData,n,i,c,e,t,o.noticeContexts.PAYMENTS,o.responseTypes.ERROR,o.responseTypes.SUCCESS,u])}(d,s,i,t,o,n,r,m),Object(l.useEffect)((function(){var e=b((function(e){var t,n=e.processingResponse;return null==n||null===(t=n.paymentDetails)||void 0===t||!t.errorMessage||{type:o.responseTypes.ERROR,message:n.paymentDetails.errorMessage,messageContext:o.noticeContexts.PAYMENTS}}));return function(){e()}}),[b,o.noticeContexts.PAYMENTS,o.responseTypes.ERROR]),d}(r,n,d,f,o,m),g=function(e){e.error&&b(e),f("")},h=ee(),w="yes"===(null===(t=y())||void 0===t?void 0:t.inline_cc_form)?Object(l.createElement)(K,{onChange:g,inputErrorComponent:c}):Object(l.createElement)(X,{onChange:g,inputErrorComponent:c});return Object(l.createElement)(l.Fragment,null,w,u&&h.length&&Object(l.createElement)(u,{icons:h,align:"left"}))},ne=function(e){var t=e.stripe;return Object(l.createElement)(P.Elements,{stripe:t},Object(l.createElement)(te,e))},re=R(),oe=function(e){var t=e.RenderedComponent,n=s()(e,["RenderedComponent"]),r=Object(l.useState)(""),o=a()(r,2),c=o[0],u=o[1];return Object(l.useEffect)((function(){Promise.resolve(re).then((function(e){var t=e.error;t&&u(t.message)}))}),[u]),Object(l.useEffect)((function(){if(c)throw new Error(c)}),[c]),Object(l.createElement)(t,i()({stripe:re},n))},ie=ee(),ce={name:"stripe",label:Object(l.createElement)((function(e){var t,n,r=e.components.PaymentMethodLabel,o=null!==(t=null===(n=y())||void 0===n?void 0:n.title)&&void 0!==t?t:Object(p.__)("Credit / Debit Card","woocommerce-gateway-stripe");return Object(l.createElement)(r,{text:o})}),null),content:Object(l.createElement)(oe,{RenderedComponent:ne}),edit:Object(l.createElement)(oe,{RenderedComponent:ne}),savedTokenComponent:Object(l.createElement)(oe,{RenderedComponent:function(e){var t=e.stripe,n=s()(e,["stripe"]);return Object(l.createElement)(P.Elements,{stripe:t},Object(l.createElement)(D,n))}}),icons:ie,canMakePayment:function(){return re},ariaLabel:Object(p.__)("Stripe Credit Card payment method","woocommerce-gateway-stripe"),supports:{showSavedCards:null!==(z=null===(Z=y())||void 0===Z?void 0:Z.showSavedCards)&&void 0!==z&&z,showSaveOption:null!==($=null===(Q=y())||void 0===Q?void 0:Q.showSaveOption)&&void 0!==$&&$,features:null!==(G=null===(J=y())||void 0===J?void 0:J.supports)&&void 0!==G?G:[]}},ae=function(e){var t,n,r=e.onButtonClicked,o=null===(t=y())||void 0===t?void 0:t.button,i=o.theme,c=void 0===i?"dark":i,u=o.locale,s=void 0===u?"en":u,p=o.height,d=void 0===p?"44":p,f=(null===(n=y())||void 0===n?void 0:n.button).branded_type,m=["short","long"].includes(f)?f:"long",v=function(e,t,n){var r="long"===e?"https://www.gstatic.com/instantbuy/svg/".concat(t,"/").concat(n,".svg"):"https://www.gstatic.com/instantbuy/svg/".concat(t,"_gpay.svg"),o=Object(l.useState)(r),i=a()(o,2),c=i[0],u=i[1];return Object(l.useEffect)((function(){var e=document.createElement("img");e.addEventListener("error",(function(){u("https://www.gstatic.com/instantbuy/svg/".concat(t,"/en.svg"))})),e.src=c}),[c,t]),c}(m,"dark"===c?"dark":"light",s);return Object(l.createElement)("button",{type:"button",id:"wc-stripe-branded-button","aria-label":"Google Pay",className:"gpay-button ".concat(c," ").concat(m),style:{backgroundImage:"url(".concat(v,")"),height:d+"px"},onClick:r})},ue=function(e){var t,n=e.onButtonClicked,r=null===(t=y())||void 0===t?void 0:t.button,o=r.theme,i=void 0===o?"dark":o,c=r.height,a=void 0===c?"44":c,u=r.customLabel,s=void 0===u?Object(p.__)("Buy now","woocommerce-gateway-stripe"):u;return Object(l.createElement)("button",{type:"button",id:"wc-stripe-custom-button",className:"button ".concat(i," is-active"),style:{height:a+"px"},onClick:n},s)},se=n(6),le=n.n(se);function pe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}var de,fe,me=function(e){var t,n,r;return null===(t=y())||void 0===t||null===(n=t.ajax_url)||void 0===n||null===(r=n.toString())||void 0===r?void 0:r.replace("%%endpoint%%","wc_stripe_"+e)},ve=function(e){var t,n,r,o,i;(t=e.shippingOption,i={security:null===(n=y())||void 0===n||null===(r=n.nonce)||void 0===r?void 0:r.update_shipping,shipping_method:[t.id],is_product_page:null===(o=y())||void 0===o?void 0:o.is_product_page},le.a.ajax({type:"POST",data:i,url:me("update_shipping_method")})).then((function(t){"success"===t.result&&e.updateWith({status:"success",total:t.total,displayItems:t.displayItems}),"fail"===t.result&&e.updateWith({status:"fail"})}))},ye=function(e,t){Object(l.useEffect)((function(){var n=null==e?void 0:e.on("shippingaddresschange",function(e){return function(t){(function(e,t){var n,r,o,i=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?pe(Object(n),!0).forEach((function(t){f()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):pe(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({security:null===(n=y())||void 0===n||null===(r=n.nonce)||void 0===r?void 0:r.shipping,payment_request_type:t,is_product_page:null===(o=y())||void 0===o?void 0:o.is_product_page},function(e){return{country:e.country,state:e.region,postcode:e.postalCode,city:e.city,address:void 0===e.addressLine[0]?"":e.addressLine[0],address_2:void 0===e.addressLine[1]?"":e.addressLine[1]}}(e));return le.a.ajax({type:"POST",data:i,url:me("get_shipping_options")})})(t.shippingAddress,e).then((function(e){t.updateWith({status:e.result,shippingOptions:e.shipping_options,total:e.total,displayItems:e.displayItems})}))}}(t));return function(){null==n||n.removeAllListeners()}}),[e,t])},be=function(e,t,n,r){Object(l.useEffect)((function(){var o=null==t?void 0:t.on("source",function(e,t,n){return function(r){var o,i,c,a,u,s;"yes"===(null===(o=y())||void 0===o||null===(i=o.stripe)||void 0===i?void 0:i.allow_prepaid_card)||"prepaid"!==(null==r||null===(c=r.source)||void 0===c||null===(a=c.card)||void 0===a?void 0:a.funding)?function(e,t){var n=function(e,t){var n,r,o,i,c,a,u,s,l,p,d,f,m,v,b,g,h,_,w,O,E,j,C,x,S,R,P,T,k,I,A=e.source,M=null==A||null===(n=A.owner)||void 0===n?void 0:n.email,N=null==A||null===(r=A.owner)||void 0===r?void 0:r.phone,L=null==A||null===(o=A.owner)||void 0===o?void 0:o.address,D=null==A||null===(i=A.owner)||void 0===i?void 0:i.name,q=null==e?void 0:e.shippingAddress,B={_wpnonce:null===(c=y())||void 0===c||null===(a=c.nonce)||void 0===a?void 0:a.checkout,billing_first_name:null!==(u=null==D||null===(s=D.split(" "))||void 0===s||null===(l=s.slice(0,1))||void 0===l?void 0:l.join(" "))&&void 0!==u?u:"",billing_last_name:null!==(p=null==D||null===(d=D.split(" "))||void 0===d||null===(f=d.slice(1))||void 0===f?void 0:f.join(" "))&&void 0!==p?p:"",billing_company:"",billing_email:null!=M?M:null==e?void 0:e.payerEmail,billing_phone:null!=N?N:null==e||null===(m=e.payerPhone)||void 0===m?void 0:m.replace("/[() -]/g",""),billing_country:null!==(v=null==L?void 0:L.country)&&void 0!==v?v:"",billing_address_1:null!==(b=null==L?void 0:L.line1)&&void 0!==b?b:"",billing_address_2:null!==(g=null==L?void 0:L.line2)&&void 0!==g?g:"",billing_city:null!==(h=null==L?void 0:L.city)&&void 0!==h?h:"",billing_state:null!==(_=null==L?void 0:L.state)&&void 0!==_?_:"",billing_postcode:null!==(w=null==L?void 0:L.postal_code)&&void 0!==w?w:"",shipping_first_name:"",shipping_last_name:"",shipping_company:"",shipping_country:"",shipping_address_1:"",shipping_address_2:"",shipping_city:"",shipping_state:"",shipping_postcode:"",shipping_method:[null==e||null===(O=e.shippingOption)||void 0===O?void 0:O.id],order_comments:"",payment_method:"stripe",ship_to_different_address:1,terms:1,stripe_source:A.id,payment_request_type:t};return q&&(B.shipping_first_name=null==q||null===(E=q.recipient)||void 0===E||null===(j=E.split(" "))||void 0===j||null===(C=j.slice(0,1))||void 0===C?void 0:C.join(" "),B.shipping_last_name=null==q||null===(x=q.recipient)||void 0===x||null===(S=x.split(" "))||void 0===S||null===(R=S.slice(1))||void 0===R?void 0:R.join(" "),B.shipping_company=null==q?void 0:q.organization,B.shipping_country=null==q?void 0:q.country,B.shipping_address_1=null!==(P=null==q||null===(T=q.addressLine)||void 0===T?void 0:T[0])&&void 0!==P?P:"",B.shipping_address_2=null!==(k=null==q||null===(I=q.addressLine)||void 0===I?void 0:I[1])&&void 0!==k?k:"",B.shipping_city=null==q?void 0:q.city,B.shipping_state=null==q?void 0:q.region,B.shipping_postcode=null==q?void 0:q.postalCode),B}(e,t);return le.a.ajax({type:"POST",data:n,dataType:"json",url:me("create_order")})}(r,t).then(function(e,t,n){return function(r){if("success"===r.result){t.complete("success");var o=function(e){var t=e.match(/^#?confirm-(pi|si)-([^:]+):(.+)$/);if(t&&!(t.length<4))return{type:t[1],clientSecret:t[2],redirectUrl:decodeURIComponent(t[3])}}(r.redirect);if(!o||o.length<4)return void(window.location=r.redirect);var i=o.type,c=o.clientSecret,a=o.redirectUrl;(function(e,t,n){return"si"===t?e.handleCardSetup(n):e.handleCardPayment(n)})(e,i,c).then(function(e,t){return function(n){if(n.error)throw n.error;var r=function(e,t){return"si"===t?e.setupIntent:e.paymentIntent}(n,t);(function(e){return"requires_capture"===e.status}(r)||function(e){return"succeeded"===e.status}(r))&&(window.location=e)}}(a,i)).catch((function(e){n(e.message),le.a.get(a+"&is_ajax")}))}else{var u,s;t.complete("fail");var l=document.createElement("div");l.innerHTML=r.messages;var p=null!==(u=null==l||null===(s=l.firstChild)||void 0===s?void 0:s.textContent)&&void 0!==u?u:"";n(p)}}}(e,r,n)):n(null===(u=y())||void 0===u||null===(s=u.i18n)||void 0===s?void 0:s.no_prepaid_card)}}(e,n,r));return function(){null==o||o.removeAllListeners()}}),[e,t,n,r])},ge=function(e){var t,n,r,o,i,c,u,s=e.billing,p=e.shippingData,d=e.onClick,f=e.onClose,m=e.setExpressPaymentError,v=Object(P.useStripe)(),g=function(e,t,n){var r=Object(l.useState)(null),o=a()(r,2),i=o[0],c=o[1],u=Object(l.useState)(null),s=a()(u,2),p=s[0],d=s[1];return Object(l.useEffect)((function(){var t,n,r;e&&!i&&(r={security:null===(t=y())||void 0===t||null===(n=t.nonce)||void 0===n?void 0:n.payment},le.a.ajax({type:"POST",data:r,url:me("get_cart_details")})).then((function(t){var n=b(e,t);n.canMakePayment().then((function(e){e&&(c(n),e.applePay?d("apple_pay"):e.googlePay?d("google_pay"):d("payment_request_api"))}))}))}),[i,e]),Object(l.useEffect)((function(){c(null)}),[t,n.cartTotal,n.cartTotalItems,n.currency.code]),[i,p]}(v,p.needsShipping,s),h=a()(g,2),_=h[0],w=h[1];ye(_,w),function(e,t){Object(l.useEffect)((function(){var t=null==e?void 0:e.on("shippingoptionchange",ve);return function(){null==t||t.removeAllListeners()}}),[e,t])}(_,w),be(v,_,w,m);var O=function(e,t){return Object(l.useCallback)((function(){e(""),t()}),[e,t])}(m,d);!function(e,t){Object(l.useEffect)((function(){null==e||e.on("cancel",(function(){t()}))}),[e,t])}(_,f);var E=null===(t=y())||void 0===t?void 0:t.button,j=E.type,C=void 0===j?"default":j,x=E.theme,S=void 0===x?"dark":x,R=E.height,T={paymentRequestButton:{type:C,theme:S,height:"".concat(void 0===R?"48":R,"px")}},k=null===(n=y())||void 0===n||null===(r=n.button)||void 0===r?void 0:r.is_branded,I=null===(o=y())||void 0===o||null===(i=o.button)||void 0===i?void 0:i.branded_type,A=null===(c=y())||void 0===c||null===(u=c.button)||void 0===u?void 0:u.is_custom;if(!_)return null;var M,N,L,D=function(){O(),_.show()};return A?Object(l.createElement)(ue,{onButtonClicked:D}):k&&(M=window.navigator.userAgent.toLowerCase(),L=(N=/chrome/.test(M)&&!/edge|edg|opr|brave\//.test(M)&&"Google Inc."===window.navigator.vendor)&&window.navigator.brave,N&&!L)?Object(l.createElement)(ae,{onButtonClicked:D}):(k&&(T.paymentRequestButton.type="long"===I?"buy":"default"),Object(l.createElement)(P.PaymentRequestButtonElement,{onClick:O,options:{style:T,paymentRequest:_}}))},he=R(),_e={name:"payment_request",content:Object(l.createElement)((function(e){var t=e.stripe;return Object(l.createElement)(P.Elements,{stripe:t},Object(l.createElement)(ge,e))}),{stripe:he}),edit:Object(l.createElement)((function(){return Object(l.createElement)("img",{src:"data:image/svg+xml,%3Csvg width='264' height='48' viewBox='0 0 264 48' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='264' height='48' rx='3' fill='black'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M125.114 16.6407C125.682 15.93 126.067 14.9756 125.966 14C125.135 14.0415 124.121 14.549 123.533 15.2602C123.006 15.8693 122.539 16.8641 122.661 17.7983C123.594 17.8797 124.526 17.3317 125.114 16.6407Z' fill='white'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M125.955 17.982C124.601 17.9011 123.448 18.7518 122.801 18.7518C122.154 18.7518 121.163 18.0224 120.092 18.0421C118.696 18.0629 117.402 18.8524 116.694 20.1079C115.238 22.6196 116.31 26.3453 117.726 28.3909C118.414 29.4028 119.242 30.5174 120.334 30.4769C121.366 30.4365 121.77 29.8087 123.024 29.8087C124.277 29.8087 124.641 30.4769 125.733 30.4567C126.865 30.4365 127.573 29.4443 128.261 28.4313C129.049 27.2779 129.373 26.1639 129.393 26.1027C129.373 26.0825 127.209 25.2515 127.189 22.7606C127.169 20.6751 128.888 19.6834 128.969 19.6217C127.998 18.1847 126.481 18.0224 125.955 17.982Z' fill='white'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M136.131 23.1804H138.834C140.886 23.1804 142.053 22.0752 142.053 20.1592C142.053 18.2432 140.886 17.1478 138.845 17.1478H136.131V23.1804ZM139.466 15.1582C142.411 15.1582 144.461 17.1903 144.461 20.1483C144.461 23.1172 142.369 25.1596 139.392 25.1596H136.131V30.3498H133.775V15.1582H139.466Z' fill='white'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M152.198 26.224V25.3712L149.579 25.5397C148.106 25.6341 147.339 26.182 147.339 27.14C147.339 28.0664 148.138 28.6667 149.39 28.6667C150.988 28.6667 152.198 27.6449 152.198 26.224ZM145.046 27.2032C145.046 25.2551 146.529 24.1395 149.263 23.971L152.198 23.7922V22.9498C152.198 21.7181 151.388 21.0442 149.947 21.0442C148.758 21.0442 147.896 21.6548 147.717 22.5916H145.592C145.656 20.6232 147.507 19.1914 150.01 19.1914C152.703 19.1914 154.459 20.602 154.459 22.7917V30.351H152.282V28.5298H152.229C151.609 29.719 150.241 30.4666 148.758 30.4666C146.571 30.4666 145.046 29.1612 145.046 27.2032Z' fill='white'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M156.461 34.4145V32.5934C156.608 32.6141 156.965 32.6354 157.155 32.6354C158.196 32.6354 158.785 32.1932 159.142 31.0564L159.353 30.3824L155.366 19.3281H157.827L160.604 28.298H160.657L163.434 19.3281H165.832L161.698 30.9402C160.752 33.6038 159.668 34.4778 157.376 34.4778C157.197 34.4778 156.618 34.4565 156.461 34.4145Z' fill='white'/%3E%3C/svg%3E%0A",alt:""})}),null),canMakePayment:function(e){var t,n;return!(null===(t=null===(n=y())||void 0===n?void 0:n.isAdmin)||void 0===t||!t)||R().then((function(t){var n,r,o,i,c,a={order_data:{total:{label:"Total",amount:parseInt(null!==(n=null==e||null===(r=e.cartTotals)||void 0===r?void 0:r.total_price)&&void 0!==n?n:0,10),pending:!0},currency:null==e||null===(o=e.cartTotals)||void 0===o||null===(i=o.currency_code)||void 0===i?void 0:i.toLowerCase(),country_code:null===(c=Object(m.getSetting)("baseLocation",{}))||void 0===c?void 0:c.country,displayItems:[]},shipping_required:!1};return b(t,a).canMakePayment()}))},paymentMethodId:"stripe",supports:{features:null!==(de=null===(fe=y())||void 0===fe?void 0:fe.supports)&&void 0!==de?de:[]}};Object(r.registerPaymentMethod)(ce),Object(r.registerExpressPaymentMethod)(_e)}]);
|
1 |
+
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=20)}([function(e,t){e.exports=window.wp.element},function(e,t){e.exports=window.wp.i18n},function(e,t){e.exports=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,n){var r=n(13),o=n(14),i=n(15),c=n(17);e.exports=function(e,t){return r(e)||o(e,t)||i(e,t)||c()},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,n){!function(e,t){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function o(){}function i(){}t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t,i.resetWarningCache=o;var c=function(e,t){return function(e){e.exports=function(){function e(e,t,n,r,o,i){if("SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"!==i){var c=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw c.name="Invariant Violation",c}}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:o};return n.PropTypes=n,n}()}(t={exports:{}}),t.exports}(),a=function(e){return null!==e&&"object"===n(e)},u=function e(t,n){if(!a(t)||!a(n))return t===n;var r=Array.isArray(t);if(r!==Array.isArray(n))return!1;var o="[object Object]"===Object.prototype.toString.call(t);if(o!==("[object Object]"===Object.prototype.toString.call(n)))return!1;if(!o&&!r)return!1;var i=Object.keys(t),c=Object.keys(n);if(i.length!==c.length)return!1;for(var u={},s=0;s<i.length;s+=1)u[i[s]]=!0;for(var l=0;l<c.length;l+=1)u[c[l]]=!0;var p=Object.keys(u);if(p.length!==i.length)return!1;var d=t,f=n;return p.every((function(t){return e(d[t],f[t])}))},s=function(e){var n=t.useRef(e);return t.useEffect((function(){n.current=e}),[e]),n.current},l=function(e){if(null===e||a(t=e)&&"function"==typeof t.elements&&"function"==typeof t.createToken&&"function"==typeof t.createPaymentMethod&&"function"==typeof t.confirmCardPayment)return e;var t;throw new Error("Invalid prop `stripe` supplied to `Elements`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.")},p=t.createContext(null);p.displayName="ElementsContext";var d=function(e){var n,o,i=e.stripe,c=e.options,d=e.children,f=t.useRef(!1),m=t.useRef(!0),v=t.useMemo((function(){return function(e){if(function(e){return a(e)&&"function"==typeof e.then}(e))return{tag:"async",stripePromise:Promise.resolve(e).then(l)};var t=l(e);return null===t?{tag:"empty"}:{tag:"sync",stripe:t}}(i)}),[i]),y=(n=t.useState((function(){return{stripe:null,elements:null}})),o=2,function(e){if(Array.isArray(e))return e}(n)||function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var n=[],_n=!0,r=!1,o=void 0;try{for(var i,c=e[Symbol.iterator]();!(_n=(i=c.next()).done)&&(n.push(i.value),!t||n.length!==t);_n=!0);}catch(e){r=!0,o=e}finally{try{_n||null==c.return||c.return()}finally{if(r)throw o}}return n}}(n,o)||function(e,t){if(e){if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}}(n,o)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),b=y[0],g=y[1],h=s(i),_=s(c);return null!==h&&(h!==i&&console.warn("Unsupported prop change on Elements: You cannot change the `stripe` prop after setting it."),u(c,_)||console.warn("Unsupported prop change on Elements: You cannot change the `options` prop after setting the `stripe` prop.")),f.current||("sync"===v.tag&&(f.current=!0,g({stripe:v.stripe,elements:v.stripe.elements(c)})),"async"===v.tag&&(f.current=!0,v.stripePromise.then((function(e){e&&m.current&&g({stripe:e,elements:e.elements(c)})})))),t.useEffect((function(){return function(){m.current=!1}}),[]),t.useEffect((function(){var e=b.stripe;e&&e._registerWrapper&&e._registerWrapper({name:"react-stripe-js",version:"1.2.2"})}),[b.stripe]),t.createElement(p.Provider,{value:b},d)};d.propTypes={stripe:c.any,options:c.object};var f=function(e){return function(e,t){if(!e)throw new Error("Could not find Elements context; You need to wrap the part of your app that ".concat(t," in an <Elements> provider."));return e}(t.useContext(p),e)},m=function(e){return(0,e.children)(f("mounts <ElementsConsumer>"))};m.propTypes={children:c.func.isRequired};var v=function(e){var n=t.useRef(e);return t.useEffect((function(){n.current=e}),[e]),function(){n.current&&n.current.apply(n,arguments)}},y=function(e){return a(e)?(e.paymentRequest,function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,["paymentRequest"])):{}},b=function(){},g=function(e,n){var r,o="".concat((r=e).charAt(0).toUpperCase()+r.slice(1),"Element"),i=n?function(e){f("mounts <".concat(o,">"));var n=e.id,r=e.className;return t.createElement("div",{id:n,className:r})}:function(n){var r=n.id,i=n.className,c=n.options,a=void 0===c?{}:c,s=n.onBlur,l=void 0===s?b:s,p=n.onFocus,d=void 0===p?b:p,m=n.onReady,g=void 0===m?b:m,h=n.onChange,_=void 0===h?b:h,w=n.onEscape,O=void 0===w?b:w,E=n.onClick,j=void 0===E?b:E,C=f("mounts <".concat(o,">")).elements,x=t.useRef(null),S=t.useRef(null),R=v(g),P=v(l),T=v(d),k=v(j),I=v(_),A=v(O);t.useLayoutEffect((function(){if(null==x.current&&C&&null!=S.current){var t=C.create(e,a);x.current=t,t.mount(S.current),t.on("ready",(function(){return R(t)})),t.on("change",I),t.on("blur",P),t.on("focus",T),t.on("escape",A),t.on("click",k)}}));var M=t.useRef(a);return t.useEffect((function(){M.current&&M.current.paymentRequest!==a.paymentRequest&&console.warn("Unsupported prop change: options.paymentRequest is not a customizable property.");var e=y(a);0===Object.keys(e).length||u(e,y(M.current))||x.current&&(x.current.update(e),M.current=a)}),[a]),t.useLayoutEffect((function(){return function(){x.current&&x.current.destroy()}}),[]),t.createElement("div",{id:r,className:i,ref:S})};return i.propTypes={id:c.string,className:c.string,onChange:c.func,onBlur:c.func,onFocus:c.func,onReady:c.func,onClick:c.func,options:c.object},i.displayName=o,i.__elementType=e,i},h="undefined"==typeof window,_=g("auBankAccount",h),w=g("card",h),O=g("cardNumber",h),E=g("cardExpiry",h),j=g("cardCvc",h),C=g("fpxBank",h),x=g("iban",h),S=g("idealBank",h),R=g("paymentRequestButton",h);e.AuBankAccountElement=_,e.CardCvcElement=j,e.CardElement=w,e.CardExpiryElement=E,e.CardNumberElement=O,e.Elements=d,e.ElementsConsumer=m,e.FpxBankElement=C,e.IbanElement=x,e.IdealBankElement=S,e.PaymentRequestButtonElement=R,e.useElements=function(){return f("calls useElements()").elements},e.useStripe=function(){return f("calls useStripe()").stripe},Object.defineProperty(e,"__esModule",{value:!0})}(t,n(19))},function(e,t){e.exports=window.regeneratorRuntime},function(e,t){function n(e,t,n,r,o,i,c){try{var a=e[i](c),u=a.value}catch(e){return void n(e)}a.done?t(u):Promise.resolve(u).then(r,o)}e.exports=function(e){return function(){var t=this,r=arguments;return new Promise((function(o,i){var c=e.apply(t,r);function a(e){n(c,o,i,a,u,"next",e)}function u(e){n(c,o,i,a,u,"throw",e)}a(void 0)}))}},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=window.jQuery},function(e,t,n){var r=n(18);e.exports=function(e,t){if(null==e)return{};var n,o,i=r(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(o=0;o<c.length;o++)n=c[o],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=window.wc.wcSettings},function(e,t){e.exports=window.wc.wcBlocksRegistry},function(e,t){function n(){return e.exports=n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},e.exports.default=e.exports,e.exports.__esModule=!0,n.apply(this,arguments)}e.exports=n,e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){function n(t){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?(e.exports=n=function(e){return typeof e},e.exports.default=e.exports,e.exports.__esModule=!0):(e.exports=n=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.default=e.exports,e.exports.__esModule=!0),n(t)}e.exports=n,e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(e){if(Array.isArray(e))return e},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var n=[],_n=!0,r=!1,o=void 0;try{for(var i,c=e[Symbol.iterator]();!(_n=(i=c.next()).done)&&(n.push(i.value),!t||n.length!==t);_n=!0);}catch(e){r=!0,o=e}finally{try{_n||null==c.return||c.return()}finally{if(r)throw o}}return n}},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,n){var r=n(16);e.exports=function(e,t){if(e){if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(o[n]=e[n]);return o},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=window.React},function(e,t,n){"use strict";n.r(t);var r=n(10),o=n(11),i=n.n(o),c=n(3),a=n.n(c),u=n(8),s=n.n(u),l=n(0),p=n(1),d=n(2),f=n.n(d),m=n(9),v={INVALID_EMAIL:"email_invalid",INVALID_REQUEST:"invalid_request_error",API_CONNECTION:"api_connection_error",API_ERROR:"api_error",AUTHENTICATION_ERROR:"authentication_error",RATE_LIMIT_ERROR:"rate_limit_error",CARD_ERROR:"card_error",VALIDATION_ERROR:"validation_error"},y=function(){var e=Object(m.getSetting)("stripe_data",null);if(!e)throw new Error("Stripe initialization data is not available");return e},b=function(e,t){var n,r,o={total:t.order_data.total,currency:t.order_data.currency,country:t.order_data.country_code,requestPayerName:!0,requestPayerEmail:!0,requestPayerPhone:null===(n=y())||void 0===n||null===(r=n.checkout)||void 0===r?void 0:r.needs_payer_phone,requestShipping:!!t.shipping_required,displayItems:t.order_data.displayItems};return"PR"===o.country&&(o.country="US"),e.paymentRequest(o)},g=function(e){return[v.INVALID_REQUEST,v.API_CONNECTION,v.API_ERROR,v.AUTHENTICATION_ERROR,v.RATE_LIMIT_ERROR].includes(e)},h=function(e){var t;return(t={},f()(t,"invalid_number",Object(p.__)("The card number is not a valid credit card number.","woocommerce-gateway-stripe")),f()(t,"invalid_expiry_month",Object(p.__)("The card expiration month is invalid.","woocommerce-gateway-stripe")),f()(t,"invalid_expiry_year",Object(p.__)("The card expiration year is invalid.","woocommerce-gateway-stripe")),f()(t,"invalid_cvc",Object(p.__)("The card security code is invalid.","woocommerce-gateway-stripe")),f()(t,"incorrect_number",Object(p.__)("The card number is incorrect.","woocommerce-gateway-stripe")),f()(t,"incomplete_number",Object(p.__)("The card number is incomplete.","woocommerce-gateway-stripe")),f()(t,"incomplete_cvc",Object(p.__)("The card security code is incomplete.","woocommerce-gateway-stripe")),f()(t,"incomplete_expiry",Object(p.__)("The card expiration date is incomplete.","woocommerce-gateway-stripe")),f()(t,"expired_card",Object(p.__)("The card has expired.","woocommerce-gateway-stripe")),f()(t,"incorrect_cvc",Object(p.__)("The card security code is incorrect.","woocommerce-gateway-stripe")),f()(t,"incorrect_zip",Object(p.__)("The card zip code failed validation.","woocommerce-gateway-stripe")),f()(t,"invalid_expiry_year_past",Object(p.__)("The card expiration year is in the past","woocommerce-gateway-stripe")),f()(t,"card_declined",Object(p.__)("The card was declined.","woocommerce-gateway-stripe")),f()(t,"missing",Object(p.__)("There is no card on a customer that is being charged.","woocommerce-gateway-stripe")),f()(t,"processing_error",Object(p.__)("An error occurred while processing the card.","woocommerce-gateway-stripe")),t)[e]||null},_=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";switch(e){case v.INVALID_EMAIL:return Object(p.__)("Invalid email address, please correct and try again.","woocommerce-gateway-stripe");case g(e):return Object(p.__)("Unable to process this payment, please try again or use alternative method.","woocommerce-gateway-stripe");case v.CARD_ERROR:return h(t);case v.VALIDATION_ERROR:return""}return null},w="https://js.stripe.com/v3",O=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,E="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used",j=null,C=function(e,t,n){if(null===e)return null;var r=e.apply(void 0,t);return function(e,t){e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",version:"1.11.0",startTime:t})}(r,n),r},x=Promise.resolve().then((function(){return e=null,null!==j?j:j=new Promise((function(t,n){if("undefined"!=typeof window)if(window.Stripe&&e&&console.warn(E),window.Stripe)t(window.Stripe);else try{var r=function(){for(var e=document.querySelectorAll('script[src^="'.concat(w,'"]')),t=0;t<e.length;t++){var n=e[t];if(O.test(n.src))return n}return null}();r&&e?console.warn(E):r||(r=function(e){var t=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",n=document.createElement("script");n.src="".concat(w).concat(t);var r=document.head||document.body;if(!r)throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");return r.appendChild(n),n}(e)),r.addEventListener("load",(function(){window.Stripe?t(window.Stripe):n(new Error("Stripe.js not available"))})),r.addEventListener("error",(function(){n(new Error("Failed to load Stripe.js"))}))}catch(e){return void n(e)}else t(null)}));var e})),S=!1;x.catch((function(e){S||console.warn(e)}));var R=function(){return new Promise((function(e){try{var t,n,r=null!==(t=null===(n=y())||void 0===n?void 0:n.stripe_locale)&&void 0!==t?t:"auto";e(function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];S=!0;var r=Date.now();return x.then((function(e){return C(e,t,r)}))}(function(){var e,t=null===(e=y())||void 0===e?void 0:e.key;if(!t)throw new Error("There is no api key available for stripe. Make sure it is available on the wc.stripe_data.stripe.key property.");return t}(),{locale:r}))}catch(t){e({error:t})}}))},P=n(4),T=n(6),k=n.n(T),I=n(5),A=n.n(I),M=function(e){var t=e.stripe,n=e.paymentDetails,r=e.errorContext,o=e.errorType,i={type:e.successType};if(!n.setup_intent_secret&&!n.payment_intent_secret)return!0;var c=!!n.setup_intent_secret,a=n.verification_endpoint,u=c?n.setup_intent_secret:n.payment_intent_secret;return t[c?"confirmCardSetup":"confirmCardPayment"](u).then((function(e){if(e.error)throw e.error;var t=e[c?"setupIntent":"paymentIntent"];return"requires_capture"!==t.status&&"succeeded"!==t.status||(i.redirectUrl=a),i})).catch((function(e){return i.type=o,i.message=e.message,i.retry=!0,i.messageContext=r,window.fetch(a+"&is_ajax"),i}))},N=function(e,t,n,r){Object(l.useEffect)((function(){var o=t(function(){var t=k()(A.a.mark((function t(o){var i,c,a;return A.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=o.processingResponse,c=i.paymentDetails||{},t.next=4,M({stripe:e,paymentDetails:c,errorContext:r.noticeContexts.PAYMENTS,errorType:r.responseTypes.ERROR,successType:r.responseTypes.SUCCESS});case 4:return(a=t.sent).type===r.responseTypes.ERROR&&a.retry&&n(""),t.abrupt("return",a);case 7:case"end":return t.stop()}}),t)})));return function(_x){return t.apply(this,arguments)}}());return function(){return o()}}),[t,r.noticeContexts.PAYMENTS,r.responseTypes.ERROR,r.responseTypes.SUCCESS,n,e])},L=function(){},D=function(e){var t=e.eventRegistration,n=e.emitResponse,r=Object(P.useStripe)(),o=t.onCheckoutAfterProcessingWithSuccess;return N(r,o,L,n),null},q=n(12),B=n.n(q);function U(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function F(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?U(Object(n),!0).forEach((function(t){f()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):U(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var V={style:{base:{iconColor:"#666EE8",color:"#31325F",fontSize:function(e,t,n){var r={};if("object"===("undefined"==typeof document?"undefined":B()(document))&&"function"==typeof document.querySelector&&"function"==typeof window.getComputedStyle){var o=document.querySelector(".wc-block-checkout");o&&(r=window.getComputedStyle(o))}return r.fontSize||"16px"}(),lineHeight:1.375,"::placeholder":{color:"#fff"}}},classes:{focus:"focused",empty:"empty",invalid:"has-error"}},H=function(e){var t=Object(l.useState)(!1),n=a()(t,2),r=n[0],o=n[1],i=Object(l.useState)(F(F({},V),e)),c=a()(i,2),u=c[0],s=c[1],p=Object(l.useState)(""),d=a()(p,2),f=d[0],m=d[1];return Object(l.useEffect)((function(){var e=r?"#CFD7E0":"#fff";s((function(t){var n=void 0!==t.showIcon?{showIcon:r}:{};return F(F({},t),{},{style:F(F({},t.style),{},{base:F(F({},t.style.base),{},{"::placeholder":{color:e}})})},n)}))}),[r]),{options:u,onActive:Object(l.useCallback)((function(e){o(!e||function(e){return!e})}),[o]),error:f,setError:m}};function W(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Y(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?W(Object(n),!0).forEach((function(t){f()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):W(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var z,Z,$,G,Q,J,K=function(e){var t=e.inputErrorComponent,n=e.onChange,r=Object(l.useState)(!0),o=a()(r,2),i=o[0],c=o[1],u=H({hidePostalCode:!0}),s=u.options,d=u.onActive,f=u.error,m=u.setError;return Object(l.createElement)(l.Fragment,null,Object(l.createElement)("div",{className:"wc-block-gateway-container wc-inline-card-element"},Object(l.createElement)(P.CardElement,{id:"wc-stripe-inline-card-element",className:"wc-block-gateway-input",options:s,onBlur:function(){return d(i)},onFocus:function(){return d(i)},onChange:function(e){e.error?m(e.error.message):m(""),c(e.empty),n(e)}}),Object(l.createElement)("label",{htmlFor:"wc-stripe-inline-card-element"},Object(p.__)("Credit Card Information","woocommerce-gateway-stripe"))),Object(l.createElement)(t,{errorMessage:f}))},X=function(e){var t=e.onChange,n=e.inputErrorComponent,r=Object(l.useState)({cardNumber:!0,cardExpiry:!0,cardCvc:!0}),o=a()(r,2),i=o[0],c=o[1],u=H({showIcon:!1}),s=u.options,d=u.onActive,m=u.error,v=u.setError,y=H(),b=y.options,g=y.onActive,h=y.error,_=y.setError,w=H(),O=w.options,E=w.onActive,j=w.error,C=w.setError,x=function(e,n){return function(r){r.error?e(r.error.message):e(""),c(Y(Y({},i),{},f()({},n,r.empty))),t(r)}};return Object(l.createElement)("div",{className:"wc-block-card-elements"},Object(l.createElement)("div",{className:"wc-block-gateway-container wc-card-number-element"},Object(l.createElement)(P.CardNumberElement,{onChange:x(v,"cardNumber"),options:s,className:"wc-block-gateway-input",id:"wc-stripe-card-number-element",onFocus:function(){return d(i.cardNumber)},onBlur:function(){return d(i.cardNumber)}}),Object(l.createElement)("label",{htmlFor:"wc-stripe-card-number-element"},Object(p.__)("Card Number","woocommerce-gateway-stripe")),Object(l.createElement)(n,{errorMessage:m})),Object(l.createElement)("div",{className:"wc-block-gateway-container wc-card-expiry-element"},Object(l.createElement)(P.CardExpiryElement,{onChange:x(_,"cardExpiry"),options:b,className:"wc-block-gateway-input",onFocus:function(){return g(i.cardExpiry)},onBlur:function(){return g(i.cardExpiry)},id:"wc-stripe-card-expiry-element"}),Object(l.createElement)("label",{htmlFor:"wc-stripe-card-expiry-element"},Object(p.__)("Expiry Date","woocommerce-gateway-stripe")),Object(l.createElement)(n,{errorMessage:h})),Object(l.createElement)("div",{className:"wc-block-gateway-container wc-card-cvc-element"},Object(l.createElement)(P.CardCvcElement,{onChange:x(C,"cardCvc"),options:O,className:"wc-block-gateway-input",onFocus:function(){return E(i.cardCvc)},onBlur:function(){return E(i.cardCvc)},id:"wc-stripe-card-code-element"}),Object(l.createElement)("label",{htmlFor:"wc-stripe-card-code-element"},Object(p.__)("CVV/CVC","woocommerce-gateway-stripe")),Object(l.createElement)(n,{errorMessage:j})))},ee=function(){var e,t;return Object.entries(null!==(e=null===(t=y())||void 0===t?void 0:t.icons)&&void 0!==e?e:{}).map((function(e){var t=a()(e,2),n=t[0],r=t[1];return{id:n,src:r.src,alt:r.alt}}))},te=function(e){var t,n=e.billing,r=e.eventRegistration,o=e.emitResponse,i=e.components,c=i.ValidationInputError,u=i.PaymentMethodIcons,s=Object(l.useState)(""),p=a()(s,2),d=p[0],f=p[1],m=Object(P.useStripe)(),b=function(e,t,n,r,o,i){var c=Object(l.useState)(""),u=a()(c,2),s=u[0],p=u[1],d=Object(l.useCallback)((function(e){var t,n=e.error.type,r=e.error.code||"",o=null!==(t=_(n,r))&&void 0!==t?t:e.error.message;return p(o),o}),[]),f=e.onCheckoutAfterProcessingWithSuccess,m=e.onPaymentProcessing,b=e.onCheckoutAfterProcessingWithError;return N(i,f,r,o),function(e,t,n,r,o,i,c,a){var u=Object(P.useElements)();Object(l.useEffect)((function(){var s=function(){var e=k()(A.a.mark((function e(t){var r,o;return A.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o="yes"===(null===(r=y())||void 0===r?void 0:r.inline_cc_form)?P.CardElement:P.CardNumberElement,e.next=3,n.createSource(null==u?void 0:u.getElement(o),{type:"card",owner:t});case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e)})));return function(_x){return e.apply(this,arguments)}}(),l=a(function(){var n=k()(A.a.mark((function n(){var a,u,l,p,d;return A.a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(n.prev=0,l=r.billingData,!t){n.next=4;break}return n.abrupt("return",{type:o.responseTypes.ERROR,message:t});case 4:if(""===i){n.next=6;break}return n.abrupt("return",{type:o.responseTypes.SUCCESS,meta:{paymentMethodData:{paymentMethod:"stripe",paymentRequestType:"cc",stripe_source:i},billingData:l}});case 6:return p={address:{line1:l.address_1,line2:l.address_2,city:l.city,state:l.state,postal_code:l.postcode,country:l.country}},l.phone&&(p.phone=l.phone),l.email&&(p.email=l.email),(l.first_name||l.last_name)&&(p.name="".concat(l.first_name," ").concat(l.last_name)),n.next=12,s(p);case 12:if(!(d=n.sent).error){n.next=15;break}return n.abrupt("return",{type:o.responseTypes.ERROR,message:e(d)});case 15:if(d.source&&d.source.id){n.next=17;break}throw new Error(_(v.API_ERROR));case 17:return c(d.source.id),n.abrupt("return",{type:o.responseTypes.SUCCESS,meta:{paymentMethodData:{stripe_source:d.source.id,billing_email:p.email,billing_first_name:null!==(a=null==l?void 0:l.first_name)&&void 0!==a?a:"",billing_last_name:null!==(u=null==l?void 0:l.last_name)&&void 0!==u?u:"",paymentMethod:"stripe",paymentRequestType:"cc"},billingData:l}});case 21:return n.prev=21,n.t0=n.catch(0),n.abrupt("return",{type:o.responseTypes.ERROR,message:n.t0});case 24:case"end":return n.stop()}}),n,null,[[0,21]])})));return function(){return n.apply(this,arguments)}}());return function(){l()}}),[a,r.billingData,n,i,c,e,t,o.noticeContexts.PAYMENTS,o.responseTypes.ERROR,o.responseTypes.SUCCESS,u])}(d,s,i,t,o,n,r,m),Object(l.useEffect)((function(){var e=b((function(e){var t,n=e.processingResponse;return null==n||null===(t=n.paymentDetails)||void 0===t||!t.errorMessage||{type:o.responseTypes.ERROR,message:n.paymentDetails.errorMessage,messageContext:o.noticeContexts.PAYMENTS}}));return function(){e()}}),[b,o.noticeContexts.PAYMENTS,o.responseTypes.ERROR]),d}(r,n,d,f,o,m),g=function(e){e.error&&b(e),f("")},h=ee(),w="yes"===(null===(t=y())||void 0===t?void 0:t.inline_cc_form)?Object(l.createElement)(K,{onChange:g,inputErrorComponent:c}):Object(l.createElement)(X,{onChange:g,inputErrorComponent:c});return Object(l.createElement)(l.Fragment,null,w,u&&h.length&&Object(l.createElement)(u,{icons:h,align:"left"}))},ne=function(e){var t=e.stripe;return Object(l.createElement)(P.Elements,{stripe:t},Object(l.createElement)(te,e))},re=R(),oe=function(e){var t=e.RenderedComponent,n=s()(e,["RenderedComponent"]),r=Object(l.useState)(""),o=a()(r,2),c=o[0],u=o[1];return Object(l.useEffect)((function(){Promise.resolve(re).then((function(e){var t=e.error;t&&u(t.message)}))}),[u]),Object(l.useEffect)((function(){if(c)throw new Error(c)}),[c]),Object(l.createElement)(t,i()({stripe:re},n))},ie=ee(),ce={name:"stripe",label:Object(l.createElement)((function(e){var t,n,r=e.components.PaymentMethodLabel,o=null!==(t=null===(n=y())||void 0===n?void 0:n.title)&&void 0!==t?t:Object(p.__)("Credit / Debit Card","woocommerce-gateway-stripe");return Object(l.createElement)(r,{text:o})}),null),content:Object(l.createElement)(oe,{RenderedComponent:ne}),edit:Object(l.createElement)(oe,{RenderedComponent:ne}),savedTokenComponent:Object(l.createElement)(oe,{RenderedComponent:function(e){var t=e.stripe,n=s()(e,["stripe"]);return Object(l.createElement)(P.Elements,{stripe:t},Object(l.createElement)(D,n))}}),icons:ie,canMakePayment:function(){return re},ariaLabel:Object(p.__)("Stripe Credit Card payment method","woocommerce-gateway-stripe"),supports:{showSavedCards:null!==(z=null===(Z=y())||void 0===Z?void 0:Z.showSavedCards)&&void 0!==z&&z,showSaveOption:null!==($=null===(G=y())||void 0===G?void 0:G.showSaveOption)&&void 0!==$&&$,features:null!==(Q=null===(J=y())||void 0===J?void 0:J.supports)&&void 0!==Q?Q:[]}},ae=function(e){var t,n,r=e.onButtonClicked,o=null===(t=y())||void 0===t?void 0:t.button,i=o.theme,c=void 0===i?"dark":i,u=o.locale,s=void 0===u?"en":u,p=o.height,d=void 0===p?"44":p,f=(null===(n=y())||void 0===n?void 0:n.button).branded_type,m=["short","long"].includes(f)?f:"long",v=function(e,t,n){var r="long"===e?"https://www.gstatic.com/instantbuy/svg/".concat(t,"/").concat(n,".svg"):"https://www.gstatic.com/instantbuy/svg/".concat(t,"_gpay.svg"),o=Object(l.useState)(r),i=a()(o,2),c=i[0],u=i[1];return Object(l.useEffect)((function(){var e=document.createElement("img");e.addEventListener("error",(function(){u("https://www.gstatic.com/instantbuy/svg/".concat(t,"/en.svg"))})),e.src=c}),[c,t]),c}(m,"dark"===c?"dark":"light",s);return Object(l.createElement)("button",{type:"button",id:"wc-stripe-branded-button","aria-label":"Google Pay",className:"gpay-button ".concat(c," ").concat(m),style:{backgroundImage:"url(".concat(v,")"),height:d+"px"},onClick:r})},ue=function(e){var t,n=e.onButtonClicked,r=null===(t=y())||void 0===t?void 0:t.button,o=r.theme,i=void 0===o?"dark":o,c=r.height,a=void 0===c?"44":c,u=r.customLabel,s=void 0===u?Object(p.__)("Buy now","woocommerce-gateway-stripe"):u;return Object(l.createElement)("button",{type:"button",id:"wc-stripe-custom-button",className:"button ".concat(i," is-active"),style:{height:a+"px"},onClick:n},s)},se=n(7),le=n.n(se);function pe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}var de,fe,me=function(e){var t,n,r;return null===(t=y())||void 0===t||null===(n=t.ajax_url)||void 0===n||null===(r=n.toString())||void 0===r?void 0:r.replace("%%endpoint%%","wc_stripe_"+e)},ve=function(e){var t,n,r,o,i;(t=e.shippingOption,i={security:null===(n=y())||void 0===n||null===(r=n.nonce)||void 0===r?void 0:r.update_shipping,shipping_method:[t.id],is_product_page:null===(o=y())||void 0===o?void 0:o.is_product_page},le.a.ajax({type:"POST",data:i,url:me("update_shipping_method")})).then((function(t){"success"===t.result&&e.updateWith({status:"success",total:t.total,displayItems:t.displayItems}),"fail"===t.result&&e.updateWith({status:"fail"})}))},ye=function(e,t){Object(l.useEffect)((function(){var n=null==e?void 0:e.on("shippingaddresschange",function(e){return function(t){(function(e,t){var n,r,o,i=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?pe(Object(n),!0).forEach((function(t){f()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):pe(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({security:null===(n=y())||void 0===n||null===(r=n.nonce)||void 0===r?void 0:r.shipping,payment_request_type:t,is_product_page:null===(o=y())||void 0===o?void 0:o.is_product_page},function(e){return{country:e.country,state:e.region,postcode:e.postalCode,city:e.city,address:void 0===e.addressLine[0]?"":e.addressLine[0],address_2:void 0===e.addressLine[1]?"":e.addressLine[1]}}(e));return le.a.ajax({type:"POST",data:i,url:me("get_shipping_options")})})(t.shippingAddress,e).then((function(e){t.updateWith({status:e.result,shippingOptions:e.shipping_options,total:e.total,displayItems:e.displayItems})}))}}(t));return function(){null==n||n.removeEventListener("shippingaddresschange")}}),[e,t])},be=function(e,t,n,r){Object(l.useEffect)((function(){var o=null==t?void 0:t.on("source",function(e,t,n){return function(r){var o,i,c,a,u,s;"yes"===(null===(o=y())||void 0===o||null===(i=o.stripe)||void 0===i?void 0:i.allow_prepaid_card)||"prepaid"!==(null==r||null===(c=r.source)||void 0===c||null===(a=c.card)||void 0===a?void 0:a.funding)?function(e,t){var n=function(e,t){var n,r,o,i,c,a,u,s,l,p,d,f,m,v,b,g,h,_,w,O,E,j,C,x,S,R,P,T,k,I,A=e.source,M=null==A||null===(n=A.owner)||void 0===n?void 0:n.email,N=null==A||null===(r=A.owner)||void 0===r?void 0:r.phone,L=null==A||null===(o=A.owner)||void 0===o?void 0:o.address,D=null==A||null===(i=A.owner)||void 0===i?void 0:i.name,q=null==e?void 0:e.shippingAddress,B={_wpnonce:null===(c=y())||void 0===c||null===(a=c.nonce)||void 0===a?void 0:a.checkout,billing_first_name:null!==(u=null==D||null===(s=D.split(" "))||void 0===s||null===(l=s.slice(0,1))||void 0===l?void 0:l.join(" "))&&void 0!==u?u:"",billing_last_name:null!==(p=null==D||null===(d=D.split(" "))||void 0===d||null===(f=d.slice(1))||void 0===f?void 0:f.join(" "))&&void 0!==p?p:"",billing_company:"",billing_email:null!=M?M:null==e?void 0:e.payerEmail,billing_phone:null!=N?N:null==e||null===(m=e.payerPhone)||void 0===m?void 0:m.replace("/[() -]/g",""),billing_country:null!==(v=null==L?void 0:L.country)&&void 0!==v?v:"",billing_address_1:null!==(b=null==L?void 0:L.line1)&&void 0!==b?b:"",billing_address_2:null!==(g=null==L?void 0:L.line2)&&void 0!==g?g:"",billing_city:null!==(h=null==L?void 0:L.city)&&void 0!==h?h:"",billing_state:null!==(_=null==L?void 0:L.state)&&void 0!==_?_:"",billing_postcode:null!==(w=null==L?void 0:L.postal_code)&&void 0!==w?w:"",shipping_first_name:"",shipping_last_name:"",shipping_company:"",shipping_country:"",shipping_address_1:"",shipping_address_2:"",shipping_city:"",shipping_state:"",shipping_postcode:"",shipping_method:[null==e||null===(O=e.shippingOption)||void 0===O?void 0:O.id],order_comments:"",payment_method:"stripe",ship_to_different_address:1,terms:1,stripe_source:A.id,payment_request_type:t};return q&&(B.shipping_first_name=null==q||null===(E=q.recipient)||void 0===E||null===(j=E.split(" "))||void 0===j||null===(C=j.slice(0,1))||void 0===C?void 0:C.join(" "),B.shipping_last_name=null==q||null===(x=q.recipient)||void 0===x||null===(S=x.split(" "))||void 0===S||null===(R=S.slice(1))||void 0===R?void 0:R.join(" "),B.shipping_company=null==q?void 0:q.organization,B.shipping_country=null==q?void 0:q.country,B.shipping_address_1=null!==(P=null==q||null===(T=q.addressLine)||void 0===T?void 0:T[0])&&void 0!==P?P:"",B.shipping_address_2=null!==(k=null==q||null===(I=q.addressLine)||void 0===I?void 0:I[1])&&void 0!==k?k:"",B.shipping_city=null==q?void 0:q.city,B.shipping_state=null==q?void 0:q.region,B.shipping_postcode=null==q?void 0:q.postalCode),B}(e,t);return le.a.ajax({type:"POST",data:n,dataType:"json",url:me("create_order")})}(r,t).then(function(e,t,n){return function(r){if("success"===r.result){t.complete("success");var o=function(e){var t=e.match(/^#?confirm-(pi|si)-([^:]+):(.+)$/);if(t&&!(t.length<4))return{type:t[1],clientSecret:t[2],redirectUrl:decodeURIComponent(t[3])}}(r.redirect);if(!o||o.length<4)return void(window.location=r.redirect);var i=o.type,c=o.clientSecret,a=o.redirectUrl;(function(e,t,n){return"si"===t?e.handleCardSetup(n):e.handleCardPayment(n)})(e,i,c).then(function(e,t){return function(n){if(n.error)throw n.error;var r=function(e,t){return"si"===t?e.setupIntent:e.paymentIntent}(n,t);(function(e){return"requires_capture"===e.status}(r)||function(e){return"succeeded"===e.status}(r))&&(window.location=e)}}(a,i)).catch((function(e){n(e.message),le.a.get(a+"&is_ajax")}))}else{var u,s;t.complete("fail");var l=document.createElement("div");l.innerHTML=r.messages;var p=null!==(u=null==l||null===(s=l.firstChild)||void 0===s?void 0:s.textContent)&&void 0!==u?u:"";n(p)}}}(e,r,n)):n(null===(u=y())||void 0===u||null===(s=u.i18n)||void 0===s?void 0:s.no_prepaid_card)}}(e,n,r));return function(){null==o||o.removeEventListener("source")}}),[e,t,n,r])},ge=function(e){var t,n,r,o,i,c,u,s=e.billing,p=e.shippingData,d=e.onClick,f=e.onClose,m=e.setExpressPaymentError,v=Object(P.useStripe)(),g=function(e,t,n){var r=Object(l.useState)(null),o=a()(r,2),i=o[0],c=o[1],u=Object(l.useState)(null),s=a()(u,2),p=s[0],d=s[1];return Object(l.useEffect)((function(){e&&function(){var t=k()(A.a.mark((function t(){var n,r,o;return A.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,void 0,a=void 0,void 0,u={security:null===(i=y())||void 0===i||null===(a=i.nonce)||void 0===a?void 0:a.payment},le.a.ajax({type:"POST",data:u,url:me("get_cart_details")});case 2:return n=t.sent,r=b(e,n),t.next=6,r.canMakePayment();case 6:(o=t.sent)?(c(r),d((function(){return o.applePay?"apple_pay":o.googlePay?"google_pay":"payment_request_api"}))):c(null);case 8:case"end":return t.stop()}var i,a,u}),t)})));return function(){return t.apply(this,arguments)}}()()}),[e,t,n.cartTotal,n.cartTotalItems,n.currency.code]),[i,p]}(v,p.needsShipping,s),h=a()(g,2),_=h[0],w=h[1];ye(_,w),function(e,t){Object(l.useEffect)((function(){var t=null==e?void 0:e.on("shippingoptionchange",ve);return function(){null==t||t.removeEventListener("shippingoptionchange")}}),[e,t])}(_,w),be(v,_,w,m);var O=function(e,t,n){return Object(l.useCallback)((function(r,o){var i;if(null!==(i=y())&&void 0!==i&&i.login_confirmation)return r.preventDefault(),void function(e){var t,n,r;if(null!==(t=y())&&void 0!==t&&t.login_confirmation){var o,i,c=null===(n=y())||void 0===n||null===(r=n.login_confirmation)||void 0===r?void 0:r.message;"payment_request_api"!==e&&(c=c.replace(/\*\*.*?\*\*/,"apple_pay"===e?"Apple Pay":"Google Pay")),c=c.replace(/\*\*/g,""),confirm(c)&&(window.location.href=null===(o=y())||void 0===o||null===(i=o.login_confirmation)||void 0===i?void 0:i.redirect_url)}}(e);t(""),n(),o&&o.show()}),[e,t,n])}(w,m,d);!function(e,t){Object(l.useEffect)((function(){var n=null==e?void 0:e.on("cancel",t);return function(){null==n||n.removeEventListener("cancel")}}),[e,t])}(_,f);var E,j,C,x=null===(t=y())||void 0===t?void 0:t.button,S=x.type,R=void 0===S?"default":S,T=x.theme,I=void 0===T?"dark":T,M=x.height,N={paymentRequestButton:{type:R,theme:I,height:"".concat(void 0===M?"48":M,"px")}},L=null===(n=y())||void 0===n||null===(r=n.button)||void 0===r?void 0:r.is_branded,D=null===(o=y())||void 0===o||null===(i=o.button)||void 0===i?void 0:i.branded_type,q=null===(c=y())||void 0===c||null===(u=c.button)||void 0===u?void 0:u.is_custom;return _?q?Object(l.createElement)(ue,{onButtonClicked:function(e){O(e,_)}}):L&&(E=window.navigator.userAgent.toLowerCase(),C=(j=/chrome/.test(E)&&!/edge|edg|opr|brave\//.test(E)&&"Google Inc."===window.navigator.vendor)&&window.navigator.brave,j&&!C)?Object(l.createElement)(ae,{onButtonClicked:function(e){O(e,_)}}):(L&&(N.paymentRequestButton.type="long"===D?"buy":"default"),Object(l.createElement)(P.PaymentRequestButtonElement,{onClick:O,options:{style:N,paymentRequest:_}})):null},he=R(),_e={name:"payment_request",content:Object(l.createElement)((function(e){var t=e.stripe;return Object(l.createElement)(P.Elements,{stripe:t},Object(l.createElement)(ge,e))}),{stripe:he}),edit:Object(l.createElement)((function(){return Object(l.createElement)("img",{src:"data:image/svg+xml,%3Csvg width='264' height='48' viewBox='0 0 264 48' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='264' height='48' rx='3' fill='black'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M125.114 16.6407C125.682 15.93 126.067 14.9756 125.966 14C125.135 14.0415 124.121 14.549 123.533 15.2602C123.006 15.8693 122.539 16.8641 122.661 17.7983C123.594 17.8797 124.526 17.3317 125.114 16.6407Z' fill='white'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M125.955 17.982C124.601 17.9011 123.448 18.7518 122.801 18.7518C122.154 18.7518 121.163 18.0224 120.092 18.0421C118.696 18.0629 117.402 18.8524 116.694 20.1079C115.238 22.6196 116.31 26.3453 117.726 28.3909C118.414 29.4028 119.242 30.5174 120.334 30.4769C121.366 30.4365 121.77 29.8087 123.024 29.8087C124.277 29.8087 124.641 30.4769 125.733 30.4567C126.865 30.4365 127.573 29.4443 128.261 28.4313C129.049 27.2779 129.373 26.1639 129.393 26.1027C129.373 26.0825 127.209 25.2515 127.189 22.7606C127.169 20.6751 128.888 19.6834 128.969 19.6217C127.998 18.1847 126.481 18.0224 125.955 17.982Z' fill='white'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M136.131 23.1804H138.834C140.886 23.1804 142.053 22.0752 142.053 20.1592C142.053 18.2432 140.886 17.1478 138.845 17.1478H136.131V23.1804ZM139.466 15.1582C142.411 15.1582 144.461 17.1903 144.461 20.1483C144.461 23.1172 142.369 25.1596 139.392 25.1596H136.131V30.3498H133.775V15.1582H139.466Z' fill='white'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M152.198 26.224V25.3712L149.579 25.5397C148.106 25.6341 147.339 26.182 147.339 27.14C147.339 28.0664 148.138 28.6667 149.39 28.6667C150.988 28.6667 152.198 27.6449 152.198 26.224ZM145.046 27.2032C145.046 25.2551 146.529 24.1395 149.263 23.971L152.198 23.7922V22.9498C152.198 21.7181 151.388 21.0442 149.947 21.0442C148.758 21.0442 147.896 21.6548 147.717 22.5916H145.592C145.656 20.6232 147.507 19.1914 150.01 19.1914C152.703 19.1914 154.459 20.602 154.459 22.7917V30.351H152.282V28.5298H152.229C151.609 29.719 150.241 30.4666 148.758 30.4666C146.571 30.4666 145.046 29.1612 145.046 27.2032Z' fill='white'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M156.461 34.4145V32.5934C156.608 32.6141 156.965 32.6354 157.155 32.6354C158.196 32.6354 158.785 32.1932 159.142 31.0564L159.353 30.3824L155.366 19.3281H157.827L160.604 28.298H160.657L163.434 19.3281H165.832L161.698 30.9402C160.752 33.6038 159.668 34.4778 157.376 34.4778C157.197 34.4778 156.618 34.4565 156.461 34.4145Z' fill='white'/%3E%3C/svg%3E%0A",alt:""})}),null),canMakePayment:function(e){var t,n,r;return!(null===(t=null===(n=y())||void 0===n?void 0:n.isAdmin)||void 0===t||!t)||!(null===(r=y())||void 0===r||!r.shouldShowPaymentRequestButton)&&R().then((function(t){var n,r,o,i,c,a={order_data:{total:{label:"Total",amount:parseInt(null!==(n=null==e||null===(r=e.cartTotals)||void 0===r?void 0:r.total_price)&&void 0!==n?n:0,10),pending:!0},currency:null==e||null===(o=e.cartTotals)||void 0===o||null===(i=o.currency_code)||void 0===i?void 0:i.toLowerCase(),country_code:null===(c=Object(m.getSetting)("baseLocation",{}))||void 0===c?void 0:c.country,displayItems:[]},shipping_required:!1};return b(t,a).canMakePayment()}))},paymentMethodId:"stripe",supports:{features:null!==(de=null===(fe=y())||void 0===fe?void 0:fe.supports)&&void 0!==de?de:[]}};Object(r.registerPaymentMethod)(ce),Object(r.registerExpressPaymentMethod)(_e)}]);
|
changelog.txt
CHANGED
@@ -1,5 +1,9 @@
|
|
1 |
*** Changelog ***
|
2 |
|
|
|
|
|
|
|
|
|
3 |
= 5.2.3 - 2021-06-11 =
|
4 |
* Fix - Credit card icons and credit card input on custom shortcode checkout pages.
|
5 |
|
1 |
*** Changelog ***
|
2 |
|
3 |
+
= 5.3.0 - 2021-07-21 =
|
4 |
+
* Fix - Disable Payment Request Buttons when order has to be split into multiple packages because Payment Requests do not support that use case.
|
5 |
+
* Tweak - Payment request button should guide users to login when necessary.
|
6 |
+
|
7 |
= 5.2.3 - 2021-06-11 =
|
8 |
* Fix - Credit card icons and credit card input on custom shortcode checkout pages.
|
9 |
|
includes/class-wc-stripe-blocks-support.php
CHANGED
@@ -100,19 +100,68 @@ final class WC_Stripe_Blocks_Support extends AbstractPaymentMethodType {
|
|
100 |
$this->get_payment_request_javascript_params(),
|
101 |
// Blocks-specific options
|
102 |
[
|
103 |
-
'title'
|
104 |
-
'icons'
|
105 |
-
'supports'
|
106 |
-
'showSavedCards'
|
107 |
-
'showSaveOption'
|
108 |
-
'isAdmin'
|
109 |
-
'
|
|
|
110 |
'customLabel' => $this->payment_request_configuration->get_button_label(),
|
111 |
],
|
112 |
]
|
113 |
);
|
114 |
}
|
115 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
/**
|
117 |
* Returns the Stripe Payment Gateway JavaScript configuration object.
|
118 |
*
|
100 |
$this->get_payment_request_javascript_params(),
|
101 |
// Blocks-specific options
|
102 |
[
|
103 |
+
'title' => $this->get_title(),
|
104 |
+
'icons' => $this->get_icons(),
|
105 |
+
'supports' => $this->get_supported_features(),
|
106 |
+
'showSavedCards' => $this->get_show_saved_cards(),
|
107 |
+
'showSaveOption' => $this->get_show_save_option(),
|
108 |
+
'isAdmin' => is_admin(),
|
109 |
+
'shouldShowPaymentRequestButton' => $this->should_show_payment_request_button(),
|
110 |
+
'button' => [
|
111 |
'customLabel' => $this->payment_request_configuration->get_button_label(),
|
112 |
],
|
113 |
]
|
114 |
);
|
115 |
}
|
116 |
|
117 |
+
/**
|
118 |
+
* Returns true if the PRB should be shown on the current page, false otherwise.
|
119 |
+
*
|
120 |
+
* Note: We use `has_block()` in this function, which isn't supported until WP 5.0. However,
|
121 |
+
* WooCommerce Blocks hasn't supported a WP version lower than 5.0 since 2019. Since this
|
122 |
+
* function is only called when the WooCommerce Blocks extension is available, it should be
|
123 |
+
* safe to call `has_block()` here.
|
124 |
+
* That said, we only run those checks if the `has_block()` function exists, just in case.
|
125 |
+
*
|
126 |
+
* @return boolean True if PRBs should be displayed, false otherwise
|
127 |
+
*/
|
128 |
+
private function should_show_payment_request_button() {
|
129 |
+
// TODO: Remove the `function_exists()` check once the minimum WP version has been bumped
|
130 |
+
// to version 5.0.
|
131 |
+
if ( function_exists( 'has_block' ) ) {
|
132 |
+
global $post;
|
133 |
+
|
134 |
+
// Don't show if PRBs are supposed to be hidden on the cart page.
|
135 |
+
// Note: The cart block has the PRB enabled by default.
|
136 |
+
if (
|
137 |
+
has_block( 'woocommerce/cart' )
|
138 |
+
&& ! apply_filters( 'wc_stripe_show_payment_request_on_cart', true )
|
139 |
+
) {
|
140 |
+
return false;
|
141 |
+
}
|
142 |
+
|
143 |
+
// Don't show if PRBs are supposed to be hidden on the checkout page.
|
144 |
+
// Note: The checkout block has the PRB enabled by default. This differs from the shortcode
|
145 |
+
// checkout where the PRB is disabled by default.
|
146 |
+
if (
|
147 |
+
has_block( 'woocommerce/checkout' )
|
148 |
+
&& ! apply_filters( 'wc_stripe_show_payment_request_on_checkout', true, $post )
|
149 |
+
) {
|
150 |
+
return false;
|
151 |
+
}
|
152 |
+
|
153 |
+
// Don't show PRB if there are unsupported products in the cart.
|
154 |
+
if (
|
155 |
+
( has_block( 'woocommerce/checkout' ) || has_block( 'woocommerce/cart' ) )
|
156 |
+
&& ! $this->payment_request_configuration->allowed_items_in_cart()
|
157 |
+
) {
|
158 |
+
return false;
|
159 |
+
}
|
160 |
+
}
|
161 |
+
|
162 |
+
return $this->payment_request_configuration->should_show_payment_request_button();
|
163 |
+
}
|
164 |
+
|
165 |
/**
|
166 |
* Returns the Stripe Payment Gateway JavaScript configuration object.
|
167 |
*
|
includes/payment-methods/class-wc-stripe-payment-request.php
CHANGED
@@ -94,29 +94,32 @@ class WC_Stripe_Payment_Request {
|
|
94 |
return;
|
95 |
}
|
96 |
|
97 |
-
add_action( 'template_redirect', [ $this, 'set_session' ] );
|
98 |
$this->init();
|
99 |
}
|
100 |
|
101 |
/**
|
102 |
* Checks whether authentication is required for checkout.
|
103 |
*
|
104 |
-
* @since
|
|
|
105 |
*
|
106 |
* @return bool
|
107 |
*/
|
108 |
public function is_authentication_required() {
|
109 |
-
// If guest checkout is disabled, authentication
|
110 |
-
if ( 'no' === get_option( 'woocommerce_enable_guest_checkout', 'yes' ) ) {
|
111 |
-
|
112 |
-
|
|
|
|
|
|
|
113 |
}
|
114 |
|
115 |
return false;
|
116 |
}
|
117 |
|
118 |
/**
|
119 |
-
* Checks whether account creation is possible
|
120 |
*
|
121 |
* @since 5.1.0
|
122 |
*
|
@@ -164,7 +167,7 @@ class WC_Stripe_Payment_Request {
|
|
164 |
* Sets the WC customer session if one is not set.
|
165 |
* This is needed so nonces can be verified by AJAX Request.
|
166 |
*
|
167 |
-
* @since
|
168 |
* @version 5.2.0
|
169 |
* @return void
|
170 |
*/
|
@@ -176,14 +179,39 @@ class WC_Stripe_Payment_Request {
|
|
176 |
WC()->session->set_customer_session_cookie( true );
|
177 |
}
|
178 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
/**
|
180 |
* Initialize hooks.
|
181 |
*
|
182 |
* @since 4.0.0
|
183 |
-
* @version
|
184 |
* @return void
|
185 |
*/
|
186 |
public function init() {
|
|
|
|
|
|
|
|
|
187 |
add_action( 'wp_enqueue_scripts', [ $this, 'scripts' ] );
|
188 |
|
189 |
add_action( 'woocommerce_after_add_to_cart_quantity', [ $this, 'display_payment_request_button_html' ], 1 );
|
@@ -206,6 +234,8 @@ class WC_Stripe_Payment_Request {
|
|
206 |
|
207 |
add_filter( 'woocommerce_gateway_title', [ $this, 'filter_gateway_title' ], 10, 2 );
|
208 |
add_action( 'woocommerce_checkout_order_processed', [ $this, 'add_order_meta' ], 10, 2 );
|
|
|
|
|
209 |
}
|
210 |
|
211 |
/**
|
@@ -521,6 +551,12 @@ class WC_Stripe_Payment_Request {
|
|
521 |
return false;
|
522 |
}
|
523 |
|
|
|
|
|
|
|
|
|
|
|
|
|
524 |
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
|
525 |
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
|
526 |
|
@@ -528,20 +564,51 @@ class WC_Stripe_Payment_Request {
|
|
528 |
return false;
|
529 |
}
|
530 |
|
531 |
-
// Not supported for subscription products when user is not authenticated and account creation is not possible.
|
532 |
-
if ( class_exists( 'WC_Subscriptions_Product' ) && WC_Subscriptions_Product::is_subscription( $_product ) && ! is_user_logged_in() && ! $this->is_account_creation_possible() ) {
|
533 |
-
return false;
|
534 |
-
}
|
535 |
-
|
536 |
// Trial subscriptions with shipping are not supported.
|
537 |
if ( class_exists( 'WC_Subscriptions_Product' ) && WC_Subscriptions_Product::is_subscription( $_product ) && $_product->needs_shipping() && WC_Subscriptions_Product::get_trial_length( $_product ) > 0 ) {
|
538 |
return false;
|
539 |
}
|
540 |
}
|
541 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
542 |
return true;
|
543 |
}
|
544 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
545 |
/**
|
546 |
* Checks if this is a product page or content contains a product_page shortcode.
|
547 |
*
|
@@ -577,6 +644,25 @@ class WC_Stripe_Payment_Request {
|
|
577 |
return false;
|
578 |
}
|
579 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
580 |
/**
|
581 |
* Returns the JavaScript configuration object used for any pages with a payment request button.
|
582 |
*
|
@@ -589,12 +675,12 @@ class WC_Stripe_Payment_Request {
|
|
589 |
}
|
590 |
|
591 |
return [
|
592 |
-
'ajax_url'
|
593 |
-
'stripe'
|
594 |
'key' => $this->publishable_key,
|
595 |
'allow_prepaid_card' => apply_filters( 'wc_stripe_allow_prepaid_card', true ) ? 'yes' : 'no',
|
596 |
],
|
597 |
-
'nonce'
|
598 |
'payment' => wp_create_nonce( 'wc-stripe-payment-request' ),
|
599 |
'shipping' => wp_create_nonce( 'wc-stripe-payment-request-shipping' ),
|
600 |
'update_shipping' => wp_create_nonce( 'wc-stripe-update-shipping-method' ),
|
@@ -604,12 +690,12 @@ class WC_Stripe_Payment_Request {
|
|
604 |
'log_errors' => wp_create_nonce( 'wc-stripe-log-errors' ),
|
605 |
'clear_cart' => wp_create_nonce( 'wc-stripe-clear-cart' ),
|
606 |
],
|
607 |
-
'i18n'
|
608 |
'no_prepaid_card' => __( 'Sorry, we\'re not accepting prepaid cards at this time.', 'woocommerce-gateway-stripe' ),
|
609 |
/* translators: Do not translate the [option] placeholder */
|
610 |
'unknown_shipping' => __( 'Unknown shipping option "[option]".', 'woocommerce-gateway-stripe' ),
|
611 |
],
|
612 |
-
'checkout'
|
613 |
'url' => wc_get_checkout_url(),
|
614 |
'currency_code' => strtolower( get_woocommerce_currency() ),
|
615 |
'country_code' => substr( get_option( 'woocommerce_default_country' ), 0, 2 ),
|
@@ -617,7 +703,7 @@ class WC_Stripe_Payment_Request {
|
|
617 |
// Defaults to 'required' to match how core initializes this option.
|
618 |
'needs_payer_phone' => 'required' === get_option( 'woocommerce_checkout_phone_field', 'required' ),
|
619 |
],
|
620 |
-
'button'
|
621 |
'type' => $this->get_button_type(),
|
622 |
'theme' => $this->get_button_theme(),
|
623 |
'height' => $this->get_button_height(),
|
@@ -627,8 +713,9 @@ class WC_Stripe_Payment_Request {
|
|
627 |
'css_selector' => $this->custom_button_selector(),
|
628 |
'branded_type' => $this->get_button_branded_type(),
|
629 |
],
|
630 |
-
'
|
631 |
-
'
|
|
|
632 |
];
|
633 |
}
|
634 |
|
@@ -639,30 +726,15 @@ class WC_Stripe_Payment_Request {
|
|
639 |
* @version 5.2.0
|
640 |
*/
|
641 |
public function scripts() {
|
642 |
-
// If keys are not set bail.
|
643 |
-
if ( ! $this->are_keys_set() ) {
|
644 |
-
WC_Stripe_Logger::log( 'Keys are not set correctly.' );
|
645 |
-
return;
|
646 |
-
}
|
647 |
-
|
648 |
-
// If no SSL bail.
|
649 |
-
if ( ! $this->testmode && ! is_ssl() ) {
|
650 |
-
WC_Stripe_Logger::log( 'Stripe Payment Request live mode requires SSL.' );
|
651 |
-
return;
|
652 |
-
}
|
653 |
-
|
654 |
// If page is not supported, bail.
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
) {
|
660 |
return;
|
661 |
}
|
662 |
|
663 |
-
if (
|
664 |
-
return;
|
665 |
-
} elseif ( ! $this->should_show_payment_button_on_cart() ) {
|
666 |
return;
|
667 |
}
|
668 |
|
@@ -688,6 +760,19 @@ class WC_Stripe_Payment_Request {
|
|
688 |
}
|
689 |
}
|
690 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
691 |
/**
|
692 |
* Display the payment request button.
|
693 |
*
|
@@ -695,21 +780,20 @@ class WC_Stripe_Payment_Request {
|
|
695 |
* @version 5.2.0
|
696 |
*/
|
697 |
public function display_payment_request_button_html() {
|
698 |
-
global $post;
|
699 |
-
|
700 |
$gateways = WC()->payment_gateways->get_available_payment_gateways();
|
701 |
|
702 |
if ( ! isset( $gateways['stripe'] ) ) {
|
703 |
return;
|
704 |
}
|
705 |
|
706 |
-
if ( !
|
707 |
return;
|
708 |
}
|
709 |
|
710 |
-
if (
|
711 |
return;
|
712 |
}
|
|
|
713 |
?>
|
714 |
<div id="wc-stripe-payment-request-wrapper" style="clear:both;padding-top:1.5em;display:none;">
|
715 |
<div id="wc-stripe-payment-request-button">
|
@@ -755,55 +839,74 @@ class WC_Stripe_Payment_Request {
|
|
755 |
}
|
756 |
|
757 |
/**
|
758 |
-
*
|
|
|
759 |
*
|
760 |
-
* @since
|
761 |
-
* @
|
|
|
762 |
*/
|
763 |
-
|
764 |
-
|
765 |
-
|
|
|
|
|
|
|
766 |
return false;
|
767 |
}
|
768 |
|
769 |
-
|
|
|
|
|
770 |
return false;
|
771 |
}
|
772 |
|
773 |
-
if
|
774 |
-
|
|
|
|
|
|
|
|
|
775 |
return false;
|
776 |
}
|
777 |
-
return true;
|
778 |
-
}
|
779 |
-
|
780 |
-
/**
|
781 |
-
* Whether payment button html should be rendered
|
782 |
-
*
|
783 |
-
* @since 4.3.2
|
784 |
-
* @version 5.2.0
|
785 |
-
* @return boolean
|
786 |
-
*/
|
787 |
-
private function should_show_payment_button_on_product_page() {
|
788 |
-
global $post;
|
789 |
|
790 |
-
|
|
|
791 |
return false;
|
792 |
}
|
793 |
|
794 |
-
|
|
|
|
|
|
|
795 |
|
796 |
-
|
|
|
|
|
|
|
|
|
797 |
return false;
|
798 |
}
|
799 |
|
800 |
-
//
|
801 |
-
if (
|
802 |
return false;
|
803 |
}
|
804 |
|
805 |
-
|
806 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
807 |
return false;
|
808 |
}
|
809 |
|
@@ -938,7 +1041,8 @@ class WC_Stripe_Payment_Request {
|
|
938 |
$chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods' );
|
939 |
$this->calculate_shipping( apply_filters( 'wc_stripe_payment_request_shipping_posted_values', $shipping_address ) );
|
940 |
|
941 |
-
$packages
|
|
|
942 |
|
943 |
if ( ! empty( $packages ) && WC()->customer->has_calculated_shipping() ) {
|
944 |
foreach ( $packages as $package_key => $package ) {
|
@@ -947,6 +1051,12 @@ class WC_Stripe_Payment_Request {
|
|
947 |
}
|
948 |
|
949 |
foreach ( $package['rates'] as $key => $rate ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
950 |
$data['shipping_options'][] = [
|
951 |
'id' => $rate->id,
|
952 |
'label' => $rate->label,
|
@@ -1566,4 +1676,33 @@ class WC_Stripe_Payment_Request {
|
|
1566 |
],
|
1567 |
];
|
1568 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1569 |
}
|
94 |
return;
|
95 |
}
|
96 |
|
|
|
97 |
$this->init();
|
98 |
}
|
99 |
|
100 |
/**
|
101 |
* Checks whether authentication is required for checkout.
|
102 |
*
|
103 |
+
* @since 5.1.0
|
104 |
+
* @version 5.3.0
|
105 |
*
|
106 |
* @return bool
|
107 |
*/
|
108 |
public function is_authentication_required() {
|
109 |
+
// If guest checkout is disabled and account creation upon checkout is not possible, authentication is required.
|
110 |
+
if ( 'no' === get_option( 'woocommerce_enable_guest_checkout', 'yes' ) && ! $this->is_account_creation_possible() ) {
|
111 |
+
return true;
|
112 |
+
}
|
113 |
+
// If cart contains subscription and account creation upon checkout is not posible, authentication is required.
|
114 |
+
if ( $this->has_subscription_product() && ! $this->is_account_creation_possible() ) {
|
115 |
+
return true;
|
116 |
}
|
117 |
|
118 |
return false;
|
119 |
}
|
120 |
|
121 |
/**
|
122 |
+
* Checks whether account creation is possible upon checkout.
|
123 |
*
|
124 |
* @since 5.1.0
|
125 |
*
|
167 |
* Sets the WC customer session if one is not set.
|
168 |
* This is needed so nonces can be verified by AJAX Request.
|
169 |
*
|
170 |
+
* @since 4.0.0
|
171 |
* @version 5.2.0
|
172 |
* @return void
|
173 |
*/
|
179 |
WC()->session->set_customer_session_cookie( true );
|
180 |
}
|
181 |
|
182 |
+
/**
|
183 |
+
* Handles payment request redirect when the redirect dialog "Continue" button is clicked.
|
184 |
+
*
|
185 |
+
* @since 5.3.0
|
186 |
+
*/
|
187 |
+
public function handle_payment_request_redirect() {
|
188 |
+
if (
|
189 |
+
! empty( $_GET['wc_stripe_payment_request_redirect_url'] )
|
190 |
+
&& ! empty( $_GET['_wpnonce'] )
|
191 |
+
&& wp_verify_nonce( $_GET['_wpnonce'], 'wc-stripe-set-redirect-url' ) // @codingStandardsIgnoreLine
|
192 |
+
) {
|
193 |
+
$url = rawurldecode( esc_url_raw( wp_unslash( $_GET['wc_stripe_payment_request_redirect_url'] ) ) );
|
194 |
+
// Sets a redirect URL cookie for 10 minutes, which we will redirect to after authentication.
|
195 |
+
// Users will have a 10 minute timeout to login/create account, otherwise redirect URL expires.
|
196 |
+
wc_setcookie( 'wc_stripe_payment_request_redirect_url', $url, time() + MINUTE_IN_SECONDS * 10 );
|
197 |
+
// Redirects to "my-account" page.
|
198 |
+
wp_safe_redirect( get_permalink( get_option( 'woocommerce_myaccount_page_id' ) ) );
|
199 |
+
exit;
|
200 |
+
}
|
201 |
+
}
|
202 |
+
|
203 |
/**
|
204 |
* Initialize hooks.
|
205 |
*
|
206 |
* @since 4.0.0
|
207 |
+
* @version 5.3.0
|
208 |
* @return void
|
209 |
*/
|
210 |
public function init() {
|
211 |
+
|
212 |
+
add_action( 'template_redirect', [ $this, 'set_session' ] );
|
213 |
+
add_action( 'template_redirect', [ $this, 'handle_payment_request_redirect' ] );
|
214 |
+
|
215 |
add_action( 'wp_enqueue_scripts', [ $this, 'scripts' ] );
|
216 |
|
217 |
add_action( 'woocommerce_after_add_to_cart_quantity', [ $this, 'display_payment_request_button_html' ], 1 );
|
234 |
|
235 |
add_filter( 'woocommerce_gateway_title', [ $this, 'filter_gateway_title' ], 10, 2 );
|
236 |
add_action( 'woocommerce_checkout_order_processed', [ $this, 'add_order_meta' ], 10, 2 );
|
237 |
+
add_filter( 'woocommerce_login_redirect', [ $this, 'get_login_redirect_url' ], 10, 3 );
|
238 |
+
add_filter( 'woocommerce_registration_redirect', [ $this, 'get_login_redirect_url' ], 10, 3 );
|
239 |
}
|
240 |
|
241 |
/**
|
551 |
return false;
|
552 |
}
|
553 |
|
554 |
+
// If the cart is not available we don't have any unsupported products in the cart, so we
|
555 |
+
// return true. This can happen e.g. when loading the cart or checkout blocks in Gutenberg.
|
556 |
+
if ( is_null( WC()->cart ) ) {
|
557 |
+
return true;
|
558 |
+
}
|
559 |
+
|
560 |
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
|
561 |
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
|
562 |
|
564 |
return false;
|
565 |
}
|
566 |
|
|
|
|
|
|
|
|
|
|
|
567 |
// Trial subscriptions with shipping are not supported.
|
568 |
if ( class_exists( 'WC_Subscriptions_Product' ) && WC_Subscriptions_Product::is_subscription( $_product ) && $_product->needs_shipping() && WC_Subscriptions_Product::get_trial_length( $_product ) > 0 ) {
|
569 |
return false;
|
570 |
}
|
571 |
}
|
572 |
|
573 |
+
// We don't support multiple packages with Payment Request Buttons because we can't offer
|
574 |
+
// a good UX.
|
575 |
+
$packages = WC()->cart->get_shipping_packages();
|
576 |
+
if ( 1 < count( $packages ) ) {
|
577 |
+
return false;
|
578 |
+
}
|
579 |
+
|
580 |
return true;
|
581 |
}
|
582 |
|
583 |
+
/**
|
584 |
+
* Checks whether cart contains a subscription product or this is a subscription product page.
|
585 |
+
*
|
586 |
+
* @since 5.3.0
|
587 |
+
* @version 5.3.0
|
588 |
+
* @return boolean
|
589 |
+
*/
|
590 |
+
public function has_subscription_product() {
|
591 |
+
if ( ! class_exists( 'WC_Subscriptions_Product' ) ) {
|
592 |
+
return false;
|
593 |
+
}
|
594 |
+
|
595 |
+
if ( $this->is_product() ) {
|
596 |
+
$product = $this->get_product();
|
597 |
+
if ( WC_Subscriptions_Product::is_subscription( $product ) ) {
|
598 |
+
return true;
|
599 |
+
}
|
600 |
+
} elseif ( WC_Stripe_Helper::has_cart_or_checkout_on_current_page() ) {
|
601 |
+
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
|
602 |
+
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
|
603 |
+
if ( WC_Subscriptions_Product::is_subscription( $_product ) ) {
|
604 |
+
return true;
|
605 |
+
}
|
606 |
+
}
|
607 |
+
}
|
608 |
+
|
609 |
+
return false;
|
610 |
+
}
|
611 |
+
|
612 |
/**
|
613 |
* Checks if this is a product page or content contains a product_page shortcode.
|
614 |
*
|
644 |
return false;
|
645 |
}
|
646 |
|
647 |
+
/**
|
648 |
+
* Returns the login redirect URL.
|
649 |
+
*
|
650 |
+
* @since 5.3.0
|
651 |
+
*
|
652 |
+
* @param string $redirect Default redirect URL.
|
653 |
+
* @return string Redirect URL.
|
654 |
+
*/
|
655 |
+
public function get_login_redirect_url( $redirect ) {
|
656 |
+
$url = esc_url_raw( wp_unslash( isset( $_COOKIE['wc_stripe_payment_request_redirect_url'] ) ? $_COOKIE['wc_stripe_payment_request_redirect_url'] : '' ) );
|
657 |
+
|
658 |
+
if ( empty( $url ) ) {
|
659 |
+
return $redirect;
|
660 |
+
}
|
661 |
+
wc_setcookie( 'wc_stripe_payment_request_redirect_url', null );
|
662 |
+
|
663 |
+
return $url;
|
664 |
+
}
|
665 |
+
|
666 |
/**
|
667 |
* Returns the JavaScript configuration object used for any pages with a payment request button.
|
668 |
*
|
675 |
}
|
676 |
|
677 |
return [
|
678 |
+
'ajax_url' => WC_AJAX::get_endpoint( '%%endpoint%%' ),
|
679 |
+
'stripe' => [
|
680 |
'key' => $this->publishable_key,
|
681 |
'allow_prepaid_card' => apply_filters( 'wc_stripe_allow_prepaid_card', true ) ? 'yes' : 'no',
|
682 |
],
|
683 |
+
'nonce' => [
|
684 |
'payment' => wp_create_nonce( 'wc-stripe-payment-request' ),
|
685 |
'shipping' => wp_create_nonce( 'wc-stripe-payment-request-shipping' ),
|
686 |
'update_shipping' => wp_create_nonce( 'wc-stripe-update-shipping-method' ),
|
690 |
'log_errors' => wp_create_nonce( 'wc-stripe-log-errors' ),
|
691 |
'clear_cart' => wp_create_nonce( 'wc-stripe-clear-cart' ),
|
692 |
],
|
693 |
+
'i18n' => [
|
694 |
'no_prepaid_card' => __( 'Sorry, we\'re not accepting prepaid cards at this time.', 'woocommerce-gateway-stripe' ),
|
695 |
/* translators: Do not translate the [option] placeholder */
|
696 |
'unknown_shipping' => __( 'Unknown shipping option "[option]".', 'woocommerce-gateway-stripe' ),
|
697 |
],
|
698 |
+
'checkout' => [
|
699 |
'url' => wc_get_checkout_url(),
|
700 |
'currency_code' => strtolower( get_woocommerce_currency() ),
|
701 |
'country_code' => substr( get_option( 'woocommerce_default_country' ), 0, 2 ),
|
703 |
// Defaults to 'required' to match how core initializes this option.
|
704 |
'needs_payer_phone' => 'required' === get_option( 'woocommerce_checkout_phone_field', 'required' ),
|
705 |
],
|
706 |
+
'button' => [
|
707 |
'type' => $this->get_button_type(),
|
708 |
'theme' => $this->get_button_theme(),
|
709 |
'height' => $this->get_button_height(),
|
713 |
'css_selector' => $this->custom_button_selector(),
|
714 |
'branded_type' => $this->get_button_branded_type(),
|
715 |
],
|
716 |
+
'login_confirmation' => $this->get_login_confirmation_settings(),
|
717 |
+
'is_product_page' => $this->is_product(),
|
718 |
+
'product' => $this->get_product_data(),
|
719 |
];
|
720 |
}
|
721 |
|
726 |
* @version 5.2.0
|
727 |
*/
|
728 |
public function scripts() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
729 |
// If page is not supported, bail.
|
730 |
+
// Note: This check is not in `should_show_payment_request_button()` because that function is
|
731 |
+
// also called by the blocks support class, and this check would fail *incorrectly* when
|
732 |
+
// called from there.
|
733 |
+
if ( ! $this->is_page_supported() ) {
|
|
|
734 |
return;
|
735 |
}
|
736 |
|
737 |
+
if ( ! $this->should_show_payment_request_button() ) {
|
|
|
|
|
738 |
return;
|
739 |
}
|
740 |
|
760 |
}
|
761 |
}
|
762 |
|
763 |
+
/**
|
764 |
+
* Returns true if the current page supports Payment Request Buttons, false otherwise.
|
765 |
+
*
|
766 |
+
* @since 5.3.0
|
767 |
+
* @version 5.3.0
|
768 |
+
* @return boolean True if the current page is supported, false otherwise.
|
769 |
+
*/
|
770 |
+
private function is_page_supported() {
|
771 |
+
return $this->is_product()
|
772 |
+
|| WC_Stripe_Helper::has_cart_or_checkout_on_current_page()
|
773 |
+
|| isset( $_GET['pay_for_order'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
774 |
+
}
|
775 |
+
|
776 |
/**
|
777 |
* Display the payment request button.
|
778 |
*
|
780 |
* @version 5.2.0
|
781 |
*/
|
782 |
public function display_payment_request_button_html() {
|
|
|
|
|
783 |
$gateways = WC()->payment_gateways->get_available_payment_gateways();
|
784 |
|
785 |
if ( ! isset( $gateways['stripe'] ) ) {
|
786 |
return;
|
787 |
}
|
788 |
|
789 |
+
if ( ! $this->is_page_supported() ) {
|
790 |
return;
|
791 |
}
|
792 |
|
793 |
+
if ( ! $this->should_show_payment_request_button() ) {
|
794 |
return;
|
795 |
}
|
796 |
+
|
797 |
?>
|
798 |
<div id="wc-stripe-payment-request-wrapper" style="clear:both;padding-top:1.5em;display:none;">
|
799 |
<div id="wc-stripe-payment-request-button">
|
839 |
}
|
840 |
|
841 |
/**
|
842 |
+
* Returns true if Payment Request Buttons are supported on the current page, false
|
843 |
+
* otherwise.
|
844 |
*
|
845 |
+
* @since 5.3.0
|
846 |
+
* @version 5.3.0
|
847 |
+
* @return boolean True if PRBs are supported on current page, false otherwise
|
848 |
*/
|
849 |
+
public function should_show_payment_request_button() {
|
850 |
+
global $post;
|
851 |
+
|
852 |
+
// If keys are not set bail.
|
853 |
+
if ( ! $this->are_keys_set() ) {
|
854 |
+
WC_Stripe_Logger::log( 'Keys are not set correctly.' );
|
855 |
return false;
|
856 |
}
|
857 |
|
858 |
+
// If no SSL bail.
|
859 |
+
if ( ! $this->testmode && ! is_ssl() ) {
|
860 |
+
WC_Stripe_Logger::log( 'Stripe Payment Request live mode requires SSL.' );
|
861 |
return false;
|
862 |
}
|
863 |
|
864 |
+
// Don't show if on the cart or checkout page, or if page contains the cart or checkout
|
865 |
+
// shortcodes, with items in the cart that aren't supported.
|
866 |
+
if (
|
867 |
+
WC_Stripe_Helper::has_cart_or_checkout_on_current_page()
|
868 |
+
&& ! $this->allowed_items_in_cart()
|
869 |
+
) {
|
870 |
return false;
|
871 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
872 |
|
873 |
+
// Don't show on cart if disabled.
|
874 |
+
if ( is_cart() && ! apply_filters( 'wc_stripe_show_payment_request_on_cart', true ) ) {
|
875 |
return false;
|
876 |
}
|
877 |
|
878 |
+
// Don't show on checkout if disabled.
|
879 |
+
if ( is_checkout() && ! apply_filters( 'wc_stripe_show_payment_request_on_checkout', false, $post ) ) {
|
880 |
+
return false;
|
881 |
+
}
|
882 |
|
883 |
+
// Don't show if product page PRB is disabled.
|
884 |
+
if (
|
885 |
+
$this->is_product()
|
886 |
+
&& apply_filters( 'wc_stripe_hide_payment_request_on_product_page', false, $post )
|
887 |
+
) {
|
888 |
return false;
|
889 |
}
|
890 |
|
891 |
+
// Don't show if product on current page is not supported.
|
892 |
+
if ( $this->is_product() && ! $this->is_product_supported( $this->get_product() ) ) {
|
893 |
return false;
|
894 |
}
|
895 |
|
896 |
+
return true;
|
897 |
+
}
|
898 |
+
|
899 |
+
/**
|
900 |
+
* Returns true if a the provided product is supported, false otherwise.
|
901 |
+
*
|
902 |
+
* @param WC_Product $param The product that's being checked for support.
|
903 |
+
*
|
904 |
+
* @since 5.3.0
|
905 |
+
* @version 5.3.0
|
906 |
+
* @return boolean True if the provided product is supported, false otherwise.
|
907 |
+
*/
|
908 |
+
private function is_product_supported( $product ) {
|
909 |
+
if ( ! is_object( $product ) || ! in_array( $product->get_type(), $this->supported_product_types() ) ) {
|
910 |
return false;
|
911 |
}
|
912 |
|
1041 |
$chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods' );
|
1042 |
$this->calculate_shipping( apply_filters( 'wc_stripe_payment_request_shipping_posted_values', $shipping_address ) );
|
1043 |
|
1044 |
+
$packages = WC()->shipping->get_packages();
|
1045 |
+
$shipping_rate_ids = [];
|
1046 |
|
1047 |
if ( ! empty( $packages ) && WC()->customer->has_calculated_shipping() ) {
|
1048 |
foreach ( $packages as $package_key => $package ) {
|
1051 |
}
|
1052 |
|
1053 |
foreach ( $package['rates'] as $key => $rate ) {
|
1054 |
+
if ( in_array( $rate->id, $shipping_rate_ids, true ) ) {
|
1055 |
+
// The Payment Requests will try to load indefinitely if there are duplicate shipping
|
1056 |
+
// option IDs.
|
1057 |
+
throw new Exception( __( 'Unable to provide shipping options for Payment Requests.', 'woocommerce-gateway-stripe' ) );
|
1058 |
+
}
|
1059 |
+
$shipping_rate_ids[] = $rate->id;
|
1060 |
$data['shipping_options'][] = [
|
1061 |
'id' => $rate->id,
|
1062 |
'label' => $rate->label,
|
1676 |
],
|
1677 |
];
|
1678 |
}
|
1679 |
+
|
1680 |
+
/**
|
1681 |
+
* Settings array for the user authentication dialog and redirection.
|
1682 |
+
*
|
1683 |
+
* @since 5.3.0
|
1684 |
+
* @version 5.3.0
|
1685 |
+
*
|
1686 |
+
* @return array
|
1687 |
+
*/
|
1688 |
+
public function get_login_confirmation_settings() {
|
1689 |
+
if ( is_user_logged_in() || ! $this->is_authentication_required() ) {
|
1690 |
+
return false;
|
1691 |
+
}
|
1692 |
+
|
1693 |
+
/* translators: The text encapsulated in `**` can be replaced with "Apple Pay" or "Google Pay". Please translate this text, but don't remove the `**`. */
|
1694 |
+
$message = __( 'To complete your transaction with **the selected payment method**, you must log in or create an account with our site.', 'woocommerce-gateway-stripe' );
|
1695 |
+
$redirect_url = add_query_arg(
|
1696 |
+
[
|
1697 |
+
'_wpnonce' => wp_create_nonce( 'wc-stripe-set-redirect-url' ),
|
1698 |
+
'wc_stripe_payment_request_redirect_url' => rawurlencode( home_url( add_query_arg( [] ) ) ), // Current URL to redirect to after login.
|
1699 |
+
],
|
1700 |
+
home_url()
|
1701 |
+
);
|
1702 |
+
|
1703 |
+
return [
|
1704 |
+
'message' => $message,
|
1705 |
+
'redirect_url' => $redirect_url,
|
1706 |
+
];
|
1707 |
+
}
|
1708 |
}
|
languages/woocommerce-gateway-stripe.pot
CHANGED
@@ -2,10 +2,10 @@
|
|
2 |
# This file is distributed under the same license as the WooCommerce Stripe Gateway package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: WooCommerce Stripe Gateway 5.
|
6 |
"Report-Msgid-Bugs-To: "
|
7 |
"https://wordpress.org/support/plugin/woocommerce-gateway-stripe\n"
|
8 |
-
"POT-Creation-Date: 2021-
|
9 |
"MIME-Version: 1.0\n"
|
10 |
"Content-Type: text/plain; charset=utf-8\n"
|
11 |
"Content-Transfer-Encoding: 8bit\n"
|
@@ -1108,31 +1108,31 @@ msgid ""
|
|
1108 |
"be enabled to see recorded logs."
|
1109 |
msgstr ""
|
1110 |
|
1111 |
-
#: includes/class-wc-stripe-blocks-support.php:
|
1112 |
msgid "Credit / Debit Card"
|
1113 |
msgstr ""
|
1114 |
|
1115 |
-
#: includes/class-wc-stripe-blocks-support.php:
|
1116 |
msgid "Visa"
|
1117 |
msgstr ""
|
1118 |
|
1119 |
-
#: includes/class-wc-stripe-blocks-support.php:
|
1120 |
msgid "American Express"
|
1121 |
msgstr ""
|
1122 |
|
1123 |
-
#: includes/class-wc-stripe-blocks-support.php:
|
1124 |
msgid "Mastercard"
|
1125 |
msgstr ""
|
1126 |
|
1127 |
-
#: includes/class-wc-stripe-blocks-support.php:
|
1128 |
msgid "Discover"
|
1129 |
msgstr ""
|
1130 |
|
1131 |
-
#: includes/class-wc-stripe-blocks-support.php:
|
1132 |
msgid "JCB"
|
1133 |
msgstr ""
|
1134 |
|
1135 |
-
#: includes/class-wc-stripe-blocks-support.php:
|
1136 |
msgid "Diners"
|
1137 |
msgstr ""
|
1138 |
|
@@ -1740,54 +1740,58 @@ msgstr ""
|
|
1740 |
msgid "Stripe SOFORT"
|
1741 |
msgstr ""
|
1742 |
|
1743 |
-
#: includes/payment-methods/class-wc-stripe-payment-request.php:
|
1744 |
-
#: includes/payment-methods/class-wc-stripe-payment-request.php:
|
1745 |
-
#: includes/payment-methods/class-wc-stripe-payment-request.php:
|
1746 |
msgid "Tax"
|
1747 |
msgstr ""
|
1748 |
|
1749 |
-
#: includes/payment-methods/class-wc-stripe-payment-request.php:
|
1750 |
-
#: includes/payment-methods/class-wc-stripe-payment-request.php:
|
1751 |
-
#: includes/payment-methods/class-wc-stripe-payment-request.php:
|
1752 |
msgid "Shipping"
|
1753 |
msgstr ""
|
1754 |
|
1755 |
-
#: includes/payment-methods/class-wc-stripe-payment-request.php:
|
1756 |
-
#: includes/payment-methods/class-wc-stripe-payment-request.php:
|
1757 |
msgid "Pending"
|
1758 |
msgstr ""
|
1759 |
|
1760 |
-
#: includes/payment-methods/class-wc-stripe-payment-request.php:
|
1761 |
msgid "Sorry, we're not accepting prepaid cards at this time."
|
1762 |
msgstr ""
|
1763 |
|
1764 |
-
#: includes/payment-methods/class-wc-stripe-payment-request.php:
|
1765 |
#. translators: Do not translate the [option] placeholder
|
1766 |
msgid "Unknown shipping option \"[option]\"."
|
1767 |
msgstr ""
|
1768 |
|
1769 |
-
#: includes/payment-methods/class-wc-stripe-payment-request.php:
|
1770 |
msgid "OR"
|
1771 |
msgstr ""
|
1772 |
|
1773 |
-
#: includes/payment-methods/class-wc-stripe-payment-request.php:
|
1774 |
-
#: includes/payment-methods/class-wc-stripe-payment-request.php:
|
1775 |
msgid "Unable to find shipping method for address."
|
1776 |
msgstr ""
|
1777 |
|
1778 |
-
#: includes/payment-methods/class-wc-stripe-payment-request.php:
|
|
|
|
|
|
|
|
|
1779 |
#. translators: %d is the product Id
|
1780 |
msgid "Product with the ID (%d) cannot be found."
|
1781 |
msgstr ""
|
1782 |
|
1783 |
-
#: includes/payment-methods/class-wc-stripe-payment-request.php:
|
1784 |
#. translators: 1: product name 2: quantity in stock
|
1785 |
msgid ""
|
1786 |
"You cannot add that amount of \"%1$s\"; to the cart because there is not "
|
1787 |
"enough stock (%2$s remaining)."
|
1788 |
msgstr ""
|
1789 |
|
1790 |
-
#: includes/payment-methods/class-wc-stripe-payment-request.php:
|
1791 |
#. translators: %s: country.
|
1792 |
msgid ""
|
1793 |
"The Payment Request button is not supported in %s because some required "
|
@@ -1795,14 +1799,22 @@ msgid ""
|
|
1795 |
"again."
|
1796 |
msgstr ""
|
1797 |
|
1798 |
-
#: includes/payment-methods/class-wc-stripe-payment-request.php:
|
1799 |
msgid "Empty cart"
|
1800 |
msgstr ""
|
1801 |
|
1802 |
-
#: includes/payment-methods/class-wc-stripe-payment-request.php:
|
1803 |
msgid "Discount"
|
1804 |
msgstr ""
|
1805 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1806 |
#: templates/emails/failed-preorder-authentication.php:20
|
1807 |
msgid "Authorize the payment now »"
|
1808 |
msgstr ""
|
2 |
# This file is distributed under the same license as the WooCommerce Stripe Gateway package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: WooCommerce Stripe Gateway 5.3.0\n"
|
6 |
"Report-Msgid-Bugs-To: "
|
7 |
"https://wordpress.org/support/plugin/woocommerce-gateway-stripe\n"
|
8 |
+
"POT-Creation-Date: 2021-07-21 19:34:48+00:00\n"
|
9 |
"MIME-Version: 1.0\n"
|
10 |
"Content-Type: text/plain; charset=utf-8\n"
|
11 |
"Content-Transfer-Encoding: 8bit\n"
|
1108 |
"be enabled to see recorded logs."
|
1109 |
msgstr ""
|
1110 |
|
1111 |
+
#: includes/class-wc-stripe-blocks-support.php:225
|
1112 |
msgid "Credit / Debit Card"
|
1113 |
msgstr ""
|
1114 |
|
1115 |
+
#: includes/class-wc-stripe-blocks-support.php:237
|
1116 |
msgid "Visa"
|
1117 |
msgstr ""
|
1118 |
|
1119 |
+
#: includes/class-wc-stripe-blocks-support.php:241
|
1120 |
msgid "American Express"
|
1121 |
msgstr ""
|
1122 |
|
1123 |
+
#: includes/class-wc-stripe-blocks-support.php:245
|
1124 |
msgid "Mastercard"
|
1125 |
msgstr ""
|
1126 |
|
1127 |
+
#: includes/class-wc-stripe-blocks-support.php:252
|
1128 |
msgid "Discover"
|
1129 |
msgstr ""
|
1130 |
|
1131 |
+
#: includes/class-wc-stripe-blocks-support.php:256
|
1132 |
msgid "JCB"
|
1133 |
msgstr ""
|
1134 |
|
1135 |
+
#: includes/class-wc-stripe-blocks-support.php:260
|
1136 |
msgid "Diners"
|
1137 |
msgstr ""
|
1138 |
|
1740 |
msgid "Stripe SOFORT"
|
1741 |
msgstr ""
|
1742 |
|
1743 |
+
#: includes/payment-methods/class-wc-stripe-payment-request.php:392
|
1744 |
+
#: includes/payment-methods/class-wc-stripe-payment-request.php:1207
|
1745 |
+
#: includes/payment-methods/class-wc-stripe-payment-request.php:1637
|
1746 |
msgid "Tax"
|
1747 |
msgstr ""
|
1748 |
|
1749 |
+
#: includes/payment-methods/class-wc-stripe-payment-request.php:400
|
1750 |
+
#: includes/payment-methods/class-wc-stripe-payment-request.php:1215
|
1751 |
+
#: includes/payment-methods/class-wc-stripe-payment-request.php:1644
|
1752 |
msgid "Shipping"
|
1753 |
msgstr ""
|
1754 |
|
1755 |
+
#: includes/payment-methods/class-wc-stripe-payment-request.php:407
|
1756 |
+
#: includes/payment-methods/class-wc-stripe-payment-request.php:1222
|
1757 |
msgid "Pending"
|
1758 |
msgstr ""
|
1759 |
|
1760 |
+
#: includes/payment-methods/class-wc-stripe-payment-request.php:694
|
1761 |
msgid "Sorry, we're not accepting prepaid cards at this time."
|
1762 |
msgstr ""
|
1763 |
|
1764 |
+
#: includes/payment-methods/class-wc-stripe-payment-request.php:696
|
1765 |
#. translators: Do not translate the [option] placeholder
|
1766 |
msgid "Unknown shipping option \"[option]\"."
|
1767 |
msgstr ""
|
1768 |
|
1769 |
+
#: includes/payment-methods/class-wc-stripe-payment-request.php:837
|
1770 |
msgid "OR"
|
1771 |
msgstr ""
|
1772 |
|
1773 |
+
#: includes/payment-methods/class-wc-stripe-payment-request.php:1050
|
1774 |
+
#: includes/payment-methods/class-wc-stripe-payment-request.php:1069
|
1775 |
msgid "Unable to find shipping method for address."
|
1776 |
msgstr ""
|
1777 |
|
1778 |
+
#: includes/payment-methods/class-wc-stripe-payment-request.php:1057
|
1779 |
+
msgid "Unable to provide shipping options for Payment Requests."
|
1780 |
+
msgstr ""
|
1781 |
+
|
1782 |
+
#: includes/payment-methods/class-wc-stripe-payment-request.php:1169
|
1783 |
#. translators: %d is the product Id
|
1784 |
msgid "Product with the ID (%d) cannot be found."
|
1785 |
msgstr ""
|
1786 |
|
1787 |
+
#: includes/payment-methods/class-wc-stripe-payment-request.php:1190
|
1788 |
#. translators: 1: product name 2: quantity in stock
|
1789 |
msgid ""
|
1790 |
"You cannot add that amount of \"%1$s\"; to the cart because there is not "
|
1791 |
"enough stock (%2$s remaining)."
|
1792 |
msgstr ""
|
1793 |
|
1794 |
+
#: includes/payment-methods/class-wc-stripe-payment-request.php:1462
|
1795 |
#. translators: %s: country.
|
1796 |
msgid ""
|
1797 |
"The Payment Request button is not supported in %s because some required "
|
1799 |
"again."
|
1800 |
msgstr ""
|
1801 |
|
1802 |
+
#: includes/payment-methods/class-wc-stripe-payment-request.php:1478
|
1803 |
msgid "Empty cart"
|
1804 |
msgstr ""
|
1805 |
|
1806 |
+
#: includes/payment-methods/class-wc-stripe-payment-request.php:1651
|
1807 |
msgid "Discount"
|
1808 |
msgstr ""
|
1809 |
|
1810 |
+
#: includes/payment-methods/class-wc-stripe-payment-request.php:1694
|
1811 |
+
#. translators: The text encapsulated in `**` can be replaced with "Apple Pay"
|
1812 |
+
#. or "Google Pay". Please translate this text, but don't remove the `**`.
|
1813 |
+
msgid ""
|
1814 |
+
"To complete your transaction with **the selected payment method**, you must "
|
1815 |
+
"log in or create an account with our site."
|
1816 |
+
msgstr ""
|
1817 |
+
|
1818 |
#: templates/emails/failed-preorder-authentication.php:20
|
1819 |
msgid "Authorize the payment now »"
|
1820 |
msgstr ""
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Tags: credit card, stripe, apple pay, payment request, google pay, sepa, sofort,
|
|
4 |
Requires at least: 4.4
|
5 |
Tested up to: 5.7
|
6 |
Requires PHP: 5.6
|
7 |
-
Stable tag: 5.
|
8 |
License: GPLv3
|
9 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
10 |
Attributions: thorsten-stripe
|
@@ -126,8 +126,8 @@ If you get stuck, you can ask for help in the Plugin Forum.
|
|
126 |
|
127 |
== Changelog ==
|
128 |
|
129 |
-
= 5.
|
130 |
-
|
131 |
-
*
|
132 |
|
133 |
[See changelog for all versions](https://raw.githubusercontent.com/woocommerce/woocommerce-gateway-stripe/trunk/changelog.txt).
|
4 |
Requires at least: 4.4
|
5 |
Tested up to: 5.7
|
6 |
Requires PHP: 5.6
|
7 |
+
Stable tag: 5.3.0
|
8 |
License: GPLv3
|
9 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
10 |
Attributions: thorsten-stripe
|
126 |
|
127 |
== Changelog ==
|
128 |
|
129 |
+
= 5.3.0 - 2021-07-21 =
|
130 |
+
* Fix - Disable Payment Request Buttons when order has to be split into multiple packages because Payment Requests do not support that use case.
|
131 |
+
* Tweak - Payment request button should guide users to login when necessary.
|
132 |
|
133 |
[See changelog for all versions](https://raw.githubusercontent.com/woocommerce/woocommerce-gateway-stripe/trunk/changelog.txt).
|
woocommerce-gateway-stripe.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
* Description: Take credit card payments on your store using Stripe.
|
6 |
* Author: WooCommerce
|
7 |
* Author URI: https://woocommerce.com/
|
8 |
-
* Version: 5.
|
9 |
* Requires at least: 4.4
|
10 |
* Tested up to: 5.7
|
11 |
* WC requires at least: 3.0
|
@@ -21,7 +21,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
21 |
/**
|
22 |
* Required minimums and constants
|
23 |
*/
|
24 |
-
define( 'WC_STRIPE_VERSION', '5.
|
25 |
define( 'WC_STRIPE_MIN_PHP_VER', '5.6.0' );
|
26 |
define( 'WC_STRIPE_MIN_WC_VER', '3.0' );
|
27 |
define( 'WC_STRIPE_FUTURE_MIN_WC_VER', '3.3' );
|
5 |
* Description: Take credit card payments on your store using Stripe.
|
6 |
* Author: WooCommerce
|
7 |
* Author URI: https://woocommerce.com/
|
8 |
+
* Version: 5.3.0
|
9 |
* Requires at least: 4.4
|
10 |
* Tested up to: 5.7
|
11 |
* WC requires at least: 3.0
|
21 |
/**
|
22 |
* Required minimums and constants
|
23 |
*/
|
24 |
+
define( 'WC_STRIPE_VERSION', '5.3.0' ); // WRCS: DEFINED_VERSION.
|
25 |
define( 'WC_STRIPE_MIN_PHP_VER', '5.6.0' );
|
26 |
define( 'WC_STRIPE_MIN_WC_VER', '3.0' );
|
27 |
define( 'WC_STRIPE_FUTURE_MIN_WC_VER', '3.3' );
|