WooCommerce PayPal Powered by Braintree Payment Gateway - Version 2.9.0

Version Description

  • 2022-11-01 =
  • Add Support for High-performance Order Storage (HPOS).
  • Add Declare compatibility with High-Performance Order Storage (HPOS).
  • Fix Display more detailed error messages on checkout.
Download this release

Release Info

Developer automattic
Plugin Icon 128x128 WooCommerce PayPal Powered by Braintree Payment Gateway
Version 2.9.0
Comparing to
See all releases

Code changes from version 2.8.0 to 2.9.0

assets/js/frontend/wc-braintree-apple-pay.min.js CHANGED
@@ -1 +1 @@
1
- "use strict";var _createClass=function(){function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}}(),_get=function e(t,n,r){null===t&&(t=Function.prototype);var o=Object.getOwnPropertyDescriptor(t,n);if(void 0!==o){if("value"in o)return o.value;o=o.get;return void 0!==o?o.call(r):void 0}o=Object.getPrototypeOf(t);if(null!==o)return e(o,n,r)};function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}!function(){function i(e,t){if(!(e instanceof t))throw new Error("Bound instance method accessed before binding")}jQuery(document).ready(function(t){var r;function o(e){_classCallCheck(this,o);var t=_possibleConstructorReturn(this,(o.__proto__||Object.getPrototypeOf(o)).call(this,e));return t.on_validate_merchant=t.on_validate_merchant.bind(t),t.process_authorization=t.process_authorization.bind(t),t.store_name=e.store_name,t.client_token_nonce=e.client_token_nonce,t}return r=window.WC_Braintree_Apple_Pay_Handler=(_inherits(o,SV_WC_Apple_Pay_Handler_v5_10_12),_createClass(o,[{key:"is_available",value:function(){return window.ApplePaySession&&ApplePaySession.canMakePayments()}},{key:"init",value:function(){if(this.is_available()||t(".sv-wc-external-checkout").hide(),this.is_available())return this.instance?_get(o.prototype.__proto__||Object.getPrototypeOf(o.prototype),"init",this).call(this):this.create_client()}},{key:"create_client",value:function(){var t=this;return this.get_client_token().done(function(e){if(e.success)return braintree.client.create({authorization:e.data}).then(function(e){return t.client=e,t.create_instance()}).catch(function(e){return console.error("Could not create Braintree client"),console.error(e)})}).fail(function(e,t,n){return console.error("Could not retrieve the client token via AJAX: "+n)})}},{key:"get_client_token",value:function(){var e={action:"wc_"+this.gateway_id+"_get_client_token",nonce:this.client_token_nonce};return t.post(this.ajax_url,e)}},{key:"create_instance",value:function(){var t=this;return braintree.applePay.create({client:this.client}).then(function(e){return t.instance=e,ApplePaySession.canMakePaymentsWithActiveCard(e.merchantIdentifier).then(function(e){if(e)return t.init()})}).catch(function(e){return console.error("Could not create Braintree Apple Pay instance. "+e.message),console.error(e)})}},{key:"get_new_session",value:function(e){e=this.instance.createPaymentRequest(e);return _get(o.prototype.__proto__||Object.getPrototypeOf(o.prototype),"get_new_session",this).call(this,e)}},{key:"on_validate_merchant",value:function(e){var t=this;return i(this,r),this.instance.performValidation({validationURL:e.validationURL,displayName:this.store_name}).then(function(e){return t.session.completeMerchantValidation(e)}).catch(function(e){return t.session.abort(),t.fail_payment("Merchant could not be validated. "+e.message)})}},{key:"process_authorization",value:function(t){var n=this;return i(this,r),this.instance.tokenize({token:t.token}).then(function(e){return t.braintree_nonce=e.nonce,_get(o.prototype.__proto__||Object.getPrototypeOf(o.prototype),"process_authorization",n).call(n,t)}).catch(function(e){return n.set_payment_status(!1),n.fail_payment("Payment could not be processed. "+e)})}}]),o),t(document.body).trigger("wc_braintree_apple_pay_handler_loaded")})}.call(void 0);
1
+ "use strict";var _createClass=function(){function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}}(),_get=function e(t,n,r){null===t&&(t=Function.prototype);var o=Object.getOwnPropertyDescriptor(t,n);return void 0!==o?"value"in o?o.value:void 0!==(o=o.get)?o.call(r):void 0:null!==(o=Object.getPrototypeOf(t))?e(o,n,r):void 0};function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(e)return!t||"object"!=typeof t&&"function"!=typeof t?e:t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}!function(){function i(e,t){if(!(e instanceof t))throw new Error("Bound instance method accessed before binding")}jQuery(document).ready(function(t){var r;function o(e){_classCallCheck(this,o);var t=_possibleConstructorReturn(this,(o.__proto__||Object.getPrototypeOf(o)).call(this,e));return t.on_validate_merchant=t.on_validate_merchant.bind(t),t.process_authorization=t.process_authorization.bind(t),t.store_name=e.store_name,t.client_token_nonce=e.client_token_nonce,t}return r=window.WC_Braintree_Apple_Pay_Handler=(_inherits(o,SV_WC_Apple_Pay_Handler_v5_10_12),_createClass(o,[{key:"is_available",value:function(){return window.ApplePaySession&&ApplePaySession.canMakePayments()}},{key:"init",value:function(){if(this.is_available()||t(".sv-wc-external-checkout").hide(),this.is_available())return this.instance?_get(o.prototype.__proto__||Object.getPrototypeOf(o.prototype),"init",this).call(this):this.create_client()}},{key:"create_client",value:function(){var t=this;return this.get_client_token().done(function(e){if(e.success)return braintree.client.create({authorization:e.data}).then(function(e){return t.client=e,t.create_instance()}).catch(function(e){return console.error("Could not create Braintree client"),console.error(e)})}).fail(function(e,t,n){return console.error("Could not retrieve the client token via AJAX: "+n)})}},{key:"get_client_token",value:function(){var e={action:"wc_"+this.gateway_id+"_get_client_token",nonce:this.client_token_nonce};return t.post(this.ajax_url,e)}},{key:"create_instance",value:function(){var t=this;return braintree.applePay.create({client:this.client}).then(function(e){return t.instance=e,ApplePaySession.canMakePaymentsWithActiveCard(e.merchantIdentifier).then(function(e){if(e)return t.init()})}).catch(function(e){return console.error("Could not create Braintree Apple Pay instance. "+e.message),console.error(e)})}},{key:"get_new_session",value:function(e){e=this.instance.createPaymentRequest(e);return _get(o.prototype.__proto__||Object.getPrototypeOf(o.prototype),"get_new_session",this).call(this,e)}},{key:"on_validate_merchant",value:function(e){var t=this;return i(this,r),this.instance.performValidation({validationURL:e.validationURL,displayName:this.store_name}).then(function(e){return t.session.completeMerchantValidation(e)}).catch(function(e){return t.session.abort(),t.fail_payment("Merchant could not be validated. "+e.message)})}},{key:"process_authorization",value:function(t){var n=this;return i(this,r),this.instance.tokenize({token:t.token}).then(function(e){return t.braintree_nonce=e.nonce,_get(o.prototype.__proto__||Object.getPrototypeOf(o.prototype),"process_authorization",n).call(n,t)}).catch(function(e){return n.set_payment_status(!1),n.fail_payment("Payment could not be processed. "+e)})}}]),o),t(document.body).trigger("wc_braintree_apple_pay_handler_loaded")})}.call(void 0);
assets/js/frontend/wc-braintree-my-payment-methods.min.js CHANGED
@@ -1 +1 @@
1
- "use strict";var _createClass=function(){function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}}();function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}!function(){jQuery(document).ready(function(n){var a;function t(e){_classCallCheck(this,t);e=_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return e.save_method=e.save_method.bind(e),e}return a=window.WC_Braintree_My_Payment_Methods_Handler=(_inherits(t,SV_WC_Payment_Methods_Handler_v5_10_12),_createClass(t,[{key:"save_method",value:function(e){var t,r,o=this;if(!(this instanceof a))throw new Error("Bound instance method accessed before binding");if(e.preventDefault(),t=n(e.currentTarget),0!==(r=t.parents("tr")).find("input[name=plugin-id][value="+this.slug+"]").length)return this.block_ui(),r.next(".error").remove(),e={action:"wc_"+this.id+"_save_payment_method",nonce:this.ajax_nonce,token_id:r.find("input[name=token-id]").val(),data:r.find("input[name]").serialize()},n.post(this.ajax_url,e).done(function(e){return e.success?(null!=e.data.title&&r.find(".woocommerce-PaymentMethod--method").html(e.data.title),null!=e.data.expires&&r.find(".woocommerce-PaymentMethod--expires").html(e.data.expires),null!=e.data.nonce&&(o.ajax_nonce=e.data.nonce),t.siblings(".cancel-edit").removeClass("cancel-edit").addClass("edit").text(o.i18n.edit_button).addClass("button"),o.disable_editing_ui()):o.display_error(r,e.data)}).fail(function(e,t,n){return o.display_error(r,n)}).always(function(){return o.unblock_ui()})}}]),t),n(document.body).trigger("wc_braintree_my_payment_methods_handler_loaded")})}.call(void 0);
1
+ "use strict";var _createClass=function(){function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}}();function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(e)return!t||"object"!=typeof t&&"function"!=typeof t?e:t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}!function(){jQuery(document).ready(function(n){var a;function t(e){_classCallCheck(this,t);e=_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return e.save_method=e.save_method.bind(e),e}return a=window.WC_Braintree_My_Payment_Methods_Handler=(_inherits(t,SV_WC_Payment_Methods_Handler_v5_10_12),_createClass(t,[{key:"save_method",value:function(e){var t,r,o=this;if(!(this instanceof a))throw new Error("Bound instance method accessed before binding");if(e.preventDefault(),t=n(e.currentTarget),0!==(r=t.parents("tr")).find("input[name=plugin-id][value="+this.slug+"]").length)return this.block_ui(),r.next(".error").remove(),e={action:"wc_"+this.id+"_save_payment_method",nonce:this.ajax_nonce,token_id:r.find("input[name=token-id]").val(),data:r.find("input[name]").serialize()},n.post(this.ajax_url,e).done(function(e){return e.success?(null!=e.data.title&&r.find(".woocommerce-PaymentMethod--method").html(e.data.title),null!=e.data.expires&&r.find(".woocommerce-PaymentMethod--expires").html(e.data.expires),null!=e.data.nonce&&(o.ajax_nonce=e.data.nonce),t.siblings(".cancel-edit").removeClass("cancel-edit").addClass("edit").text(o.i18n.edit_button).addClass("button"),o.disable_editing_ui()):o.display_error(r,e.data)}).fail(function(e,t,n){return o.display_error(r,n)}).always(function(){return o.unblock_ui()})}}]),t),n(document.body).trigger("wc_braintree_my_payment_methods_handler_loaded")})}.call(void 0);
assets/js/frontend/wc-braintree.min.js CHANGED
@@ -1 +1 @@
1
- "use strict";var _get=function e(t,n,r){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,n);if(void 0!==i){if("value"in i)return i.value;i=i.get;return void 0!==i?i.call(r):void 0}i=Object.getPrototypeOf(t);if(null!==i)return e(i,n,r)},_createClass=function(){function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}}();function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}!function(){function u(e,t){if(!(e instanceof t))throw new Error("Bound instance method accessed before binding")}var c=[].indexOf;jQuery(document).ready(function(s){var e,r,i;function t(e){_classCallCheck(this,t),this.show_integration_ui=this.show_integration_ui.bind(this),this.hide_integration_ui=this.hide_integration_ui.bind(this),this.id=e.id,this.id_dasherized=e.id_dasherized,this.name=e.name,this.type=e.type,this.debug=e.debug,this.client_token_nonce=e.client_token_nonce,this.ajax_url=e.ajax_url,this.integration_error_message=e.integration_error_message,this.payment_error_message=e.payment_error_message,this.params=window.sv_wc_payment_gateway_payment_form_params}function o(e){_classCallCheck(this,o);var t=_possibleConstructorReturn(this,(o.__proto__||Object.getPrototypeOf(o)).call(this,e));return t.show_integration_ui=t.show_integration_ui.bind(t),t.hide_integration_ui=t.hide_integration_ui.bind(t),t.csc_required=e.csc_required,t.hosted_fields_styles=e.hosted_fields_styles,t.threeds=e.threeds,t.enabled_card_types=e.enabled_card_types,t.init(),t}function n(e){_classCallCheck(this,n);var t=_possibleConstructorReturn(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e));return t.do_integration_ready=t.do_integration_ready.bind(t),t.on_approve=t.on_approve.bind(t),t.get_linked_account_html=t.get_linked_account_html.bind(t),t.is_test_environment=e.is_test_environment,t.is_paypal_pay_later_enabled=e.is_paypal_pay_later_enabled,t.is_paypal_card_enabled=e.is_paypal_card_enabled,t.disabled_funding_options=e.paypal_disabled_funding_options,t.force_buyer_country=e.force_buyer_country,t.must_login_message=e.must_login_message,t.must_login_add_method_message=e.must_login_add_method_message,t.button_styles=e.button_styles,t.cart_payment_nonce=e.cart_payment_nonce,t.paypal_intent=e.paypal_intent,t.init(),t}function a(e){_classCallCheck(this,a);var t=_possibleConstructorReturn(this,(a.__proto__||Object.getPrototypeOf(a)).call(this,e));return t.is_paypal_card_enabled=!1,t.set_payment_method_nonce=e.set_payment_method_nonce,t.cart_handler_url=e.cart_handler_url,t.form=s("form.woocommerce-cart-form"),t.form_ui_selector="",t.setup_braintree(),s(document.body).on("updated_cart_totals",function(){return t.setup_braintree()}),t}function _(e){_classCallCheck(this,_);var t=_possibleConstructorReturn(this,(_.__proto__||Object.getPrototypeOf(_)).call(this,e));return t.do_integration_ready=t.do_integration_ready.bind(t),t.validate_product_button=t.validate_product_button.bind(t),t.validate_product_data=t.validate_product_data.bind(t),t.is_paypal_card_enabled=!1,t.product_checkout_nonce=e.product_checkout_nonce,t.product_checkout_url=e.product_checkout_url,t.is_product_page=e.is_product_page,t.validate_product_url=e.validate_product_url,t.validate_product_nonce=e.validate_product_nonce,t.should_validate_product_data=e.should_validate_product_data,t.form=s("form.woocommerce-cart-form"),t.form_ui_selector="",t.is_product_page&&t.handle_product_page(),t.setup_braintree(),s(document.body).on("updated_cart_totals",function(){return t.setup_braintree()}),t}return window.WC_Braintree_Payment_Form_Handler=(_createClass(t,[{key:"init",value:function(){return this.is_sdk_ready()?s("form.checkout").length?this.handle_checkout_page():s("form#order_review").length?this.handle_pay_page():s("form#add_payment_method").length?this.handle_add_payment_method_page():void 0:console.error("Braintree SDK is missing.")}},{key:"handle_checkout_page",value:function(){var e=this;return this.form=s("form.checkout"),this.form_ui_selector=".woocommerce-checkout-payment",s(document.body).on("updated_checkout",function(){if(!e.setting_up)return s('iframe[name^="braintree-"]').remove(),e.setup_braintree()}),s(document.body).on("updated_checkout",function(){return e.handle_saved_payment_methods()}),s(document.body).on("checkout_error",function(){return e.handle_checkout_error()}),this.form.on("checkout_place_order_"+this.id,function(){if(e.is_selected())return e.block_ui(),e.verify_form()})}},{key:"handle_checkout_error",value:function(){return this.unblock_ui()}},{key:"handle_pay_page",value:function(){var e=this;return this.form=s("form#order_review"),this.form_ui_selector="#payment",this.handle_saved_payment_methods(),this.setup_braintree(),this.form.submit(function(){if(e.is_selected())return e.block_ui(),e.verify_form()})}},{key:"handle_add_payment_method_page",value:function(){var e=this;return this.form=s("form#add_payment_method"),this.form_ui_selector="#payment",this.setup_braintree(),this.form.submit(function(){if(e.is_selected())return e.block_ui(),e.verify_form()})}},{key:"verify_form",value:function(){return!!this.using_payment_token()||!!this.has_payment_nonce()&&void 0}},{key:"submit_form",value:function(e){return s("input[name=wc_"+this.id+"_payment_nonce]").val(e),this.form.submit()}},{key:"handle_saved_payment_methods",value:function(){var n=this,e=s("div.js-wc-"+this.id_dasherized+"-new-payment-method-form");if(s("input.js-wc-"+this.id_dasherized+"-payment-token").change(function(){return s("input.js-wc-"+n.id_dasherized+"-payment-token:checked").val()?e.slideUp(200):e.slideDown(200)}).change(),s("input#createaccount").change(function(e){var t=s("input.js-wc-"+n.id_dasherized+"-tokenize-payment-method").closest("p.form-row");return s(e.target).is(":checked")?(t.slideDown(),t.next().show()):(t.hide(),t.next().hide())}),!s("input#createaccount").is(":checked"))return s("input#createaccount").change()}},{key:"setup_braintree",value:function(){if(!s("#wc-"+this.id_dasherized+"-account-number-hosted iframe").data("ready"))return this.setting_up=!0,this.block_ui(),s("input[name=wc_"+this.id+"_payment_nonce]").val(""),this.create_client()}},{key:"create_client",value:function(){var r=this;return this.log("Creating client."),this.get_client_token().done(function(e){return e.success?braintree.client.create({authorization:e.data}).then(function(e){return r.client=e,r.log("Client ready."),r.setup_integration()}).catch(function(e){return r.handle_integration_error(e),r.unblock_ui()}):r.handle_integration_error(e.data)}).fail(function(e,t,n){return r.handle_integration_error({message:"Could not retrieve the client token via AJAX: "+n}),r.unblock_ui()})}},{key:"get_client_token",value:function(){this.id;var e={action:"wc_"+this.id+"_get_client_token",nonce:this.client_token_nonce};return s.post(this.ajax_url,e)}},{key:"setup_integration",value:function(){var t=this;return this.set_device_data(),this.log("Creating integration."),this.get_integration_class().create(this.get_integration_options()).then(function(e){return t.integration=e,t.show_integration_ui(),s("#wc-"+t.id_dasherized+"-account-number-hosted iframe").data("ready",!0),t.do_integration_ready(),s(document).trigger("wc_"+t.id+"_integration_ready",t.integration),t.log("Integration ready."),t.setting_up=!1}).catch(function(e){return t.handle_integration_error(e),t.unblock_ui(),t.setting_up=!1})}},{key:"refresh_braintree",value:function(){var e=this;if(null!=this.integration&&!this.refreshing&&!this.setting_up)return this.log("Refreshing integration."),this.refreshing=!0,this.block_ui(),this.integration.teardown(function(){return e.integration=null,e.refreshing=!1,e.setup_braintree()})}},{key:"teardown_braintree",value:function(){var e=this;if(null!=this.integration&&!this.tearing_down&&!this.setting_up)return this.log("Tearing down integration."),this.tearing_down=!0,this.block_ui(),this.integration.teardown(function(){return e.integration=null,e.tearing_down=!1,e.unblock_ui()})}},{key:"set_device_data",value:function(){if(braintree&&braintree.dataCollector)return braintree.dataCollector.create({client:this.client}).then(function(e){if(e&&e.deviceData)return s("input[id*='wc_braintree_device_data']").val(e.deviceData)})}},{key:"do_integration_ready",value:function(){}},{key:"get_integration_options",value:function(){return{client:this.client}}},{key:"get_integration_class",value:function(){}},{key:"handle_integration_error",value:function(e){return this.log("Integration error. "+e.message,e,"error"),this.hide_integration_ui(),this.unblock_ui()}},{key:"handle_payment_error",value:function(e){return this.log("Payment error. "+e.message,e,"error"),this.render_error(this.get_user_message(e)),this.unblock_ui()}},{key:"render_error",value:function(e){return s(".woocommerce-error, .woocommerce-message").remove(),this.form.prepend('<div class="woocommerce-error">'+e+"</div>").removeClass("processing").unblock(),s("html, body").animate({scrollTop:this.form.offset().top-100},1e3),s("input[name=wc_"+this.id+"_payment_nonce]").val(""),this.form.trigger("wc_"+this.id+"_rendered_error"),s(document.body).trigger("checkout_error"),this.unblock_ui()}},{key:"get_user_message",value:function(e){return this.payment_error_message}},{key:"show_integration_ui",value:function(){if(s("div.js-wc-"+this.id_dasherized+"-new-payment-method-form").find(".woocommerce-error").remove(),s("input#createaccount").length&&s("input#createaccount").is(":checked"))return s("div.js-wc-"+this.id_dasherized+"-new-payment-method-form").find(".form-row").show()}},{key:"hide_integration_ui",value:function(){return s("div.js-wc-"+this.id_dasherized+"-new-payment-method-form").prepend('<div class="woocommerce-error">'+this.integration_error_message+"</div>"),s("div.js-wc-"+this.id_dasherized+"-new-payment-method-form").find(".form-row").hide()}},{key:"block_ui",value:function(){return s(this.form_ui_selector).block({message:null,overlayCSS:{background:"#fff",opacity:.6}})}},{key:"unblock_ui",value:function(){return s(this.form_ui_selector).unblock()}},{key:"is_selected",value:function(){return this.get_selected_gateway_id()===this.id}},{key:"is_sdk_ready",value:function(){return"undefined"!=typeof braintree&&null!==braintree&&null!=braintree.client&&null!=this.get_integration_class()}},{key:"has_payment_nonce",value:function(){return this.form.find("input[name=wc_"+this.id+"_payment_nonce]").val()}},{key:"using_payment_token",value:function(){return this.form.find("input.js-wc-"+this.id_dasherized+"-payment-token:checked").val()}},{key:"get_selected_gateway_id",value:function(){return this.form.find("input[name=payment_method]:checked").val()}},{key:"log",value:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;if(this.debug)return console.log(this.name+": "+e),t?console.log(t):void 0}}]),t),s(document.body).trigger("wc_braintree_payment_form_handler_loaded"),e=window.WC_Braintree_Credit_Card_Payment_Form_Handler=(_inherits(o,WC_Braintree_Payment_Form_Handler),_createClass(o,[{key:"handle_checkout_error",value:function(){return _get(o.prototype.__proto__||Object.getPrototypeOf(o.prototype),"handle_checkout_error",this).call(this),s("input[name=wc_"+this.id+"_payment_nonce]").val(""),s("input[name=wc-"+this.id_dasherized+"-card-type]").val(""),s("input[name=wc-"+this.id_dasherized+"-3d-secure-verified]").val(0)}},{key:"verify_form",value:function(){var e;return this.has_payment_nonce()||!this.csc_required&&this.using_payment_token()?(e=s("input.js-wc-braintree-credit-card-payment-token:checked"),this.should_verify_3d_secure_token(e)?(this.verify_3d_secure(e.data("nonce"),null,e),!1):_get(o.prototype.__proto__||Object.getPrototypeOf(o.prototype),"verify_form",this).call(this)):(this.tokenize_payment(),!1)}},{key:"tokenize_payment",value:function(){var t=this;return this.integration.tokenize().then(function(e){if(t.log("Payment method received.",e),null!=e.nonce&&null!=e.details&&null!=e.details.bin)return t.should_verify_3d_secure(e)?t.verify_3d_secure(e.nonce,e.details.bin):t.submit_form(e.nonce)}).catch(function(e){return t.handle_payment_error(e)})}},{key:"get_integration_options",value:function(){var e={client:this.client,fields:{number:{selector:"#wc-braintree-credit-card-account-number-hosted",placeholder:s("#wc-braintree-credit-card-account-number-hosted").data("placeholder")},cvv:{selector:"#wc-braintree-credit-card-csc-hosted",placeholder:s("#wc-braintree-credit-card-csc-hosted").data("placeholder")},expirationDate:{selector:"#wc-braintree-credit-card-expiry-hosted",placeholder:s("#wc-braintree-credit-card-expiry-hosted").data("placeholder")}},styles:this.hosted_fields_styles};return this.csc_required&&this.using_payment_token()&&(delete e.fields.number,delete e.fields.expirationDate),this.csc_required||delete e.fields.cvv,e}},{key:"get_integration_class",value:function(){return braintree.hostedFields}},{key:"do_integration_ready",value:function(){var t=this;return this.integration.on("cardTypeChange",function(e){return t.on_card_type_change(e)}),!this.csc_required&&s("input.js-wc-braintree-credit-card-payment-token:checked").val()&&this.teardown_braintree(),this.unblock_ui()}},{key:"handle_saved_payment_methods",value:function(){var e,t,n=this;return _get(o.prototype.__proto__||Object.getPrototypeOf(o.prototype),"handle_saved_payment_methods",this).call(this),t=s("div.js-wc-braintree-credit-card-new-payment-method-form"),e=s("div.wc-braintree-hosted-field-card-csc-parent"),s("input.js-wc-braintree-credit-card-payment-token").change(function(){return s("input.js-wc-braintree-credit-card-payment-token:checked").val()?n.csc_required&&e.hasClass("form-row-last")?(e.removeClass("form-row-last").addClass("form-row-first"),t.after(e),n.refresh_braintree()):void 0:(n.csc_required&&e.hasClass("form-row-first")&&(e.removeClass("form-row-first").addClass("form-row-last"),t.find("div.wc-braintree-hosted-field-card-expiry-parent").after(e)),n.refresh_braintree())}).change()}},{key:"get_user_message",value:function(e){var t,n,r,i,a=[];if("CUSTOMER"===e.type)switch(e.code){case"HOSTED_FIELDS_FIELDS_EMPTY":this.csc_required&&a.push(this.params.cvv_missing),this.using_payment_token()||(a.push(this.params.card_number_missing),a.push(this.params.card_exp_date_invalid));break;case"HOSTED_FIELDS_FIELDS_INVALID":if(null!=e.details)for(t=0,n=(i=e.details.invalidFieldKeys).length;t<n;t++)switch(i[t]){case"number":a.push(this.params.card_number_invalid);break;case"cvv":a.push(this.params.cvv_length_invalid);break;case"expirationDate":a.push(this.params.card_exp_date_invalid)}}else"NETWORK"===e.type&&null!=e.details.originalError.error.message&&(r=e.details.originalError.error.message,/given name format is invalid/.test(r)&&a.push(this.params.first_name_unsupported_characters),/surname format is invalid/.test(r)&&a.push(this.params.last_name_unsupported_characters));return a.length?a.join("<br/>"):_get(o.prototype.__proto__||Object.getPrototypeOf(o.prototype),"get_user_message",this).call(this)}},{key:"on_card_type_change",value:function(e){var t,n;if(null!=e.cards)return(t=s("#wc-braintree-credit-card-account-number-hosted")).attr("class",function(e,t){return t.replace(/(^|\s)card-type-\S+/g,"")}),e.cards.length?1===e.cards.length?(e=e.cards[0],s("input[name=wc-"+this.id_dasherized+"-card-type]").val(e.type),null!=e.type&&(n=e.type,0<=c.call(this.enabled_card_types,n))?t.addClass("card-type-"+e.type):t.addClass("card-type-invalid")):void 0:t.addClass("card-type-invalid")}},{key:"is_3d_secure_enabled",value:function(){return this.threeds.enabled&&null!=braintree.threeDSecure}},{key:"setup_integration",value:function(){var t=this;return this.threeds.enabled&&(this.threeds.enabled=this.client.getConfiguration().gatewayConfiguration.threeDSecureEnabled),this.is_3d_secure_enabled()?(s("input[name=wc-"+this.id_dasherized+"-3d-secure-enabled]").val(1),this.threeDSecure&&this.threeDSecure.teardown(),braintree.threeDSecure.create({version:2,client:this.client}).then(function(e){return t.threeDSecure=e,s(document.body).on("click","#wc-braintree-credit-card-3dsecure-container",function(e){return s(e.currentTarget).fadeOut(200),t.threeDSecure.cancelVerifyCard(),t.unblock_ui()}),_get(o.prototype.__proto__||Object.getPrototypeOf(o.prototype),"setup_integration",t).call(t)}).catch(function(e){return t.handle_integration_error(e)})):_get(o.prototype.__proto__||Object.getPrototypeOf(o.prototype),"setup_integration",this).call(this)}},{key:"should_verify_3d_secure",value:function(e){var t=e.details.cardType;return this.is_3d_secure_enabled()&&"CreditCard"===e.type&&0<=c.call(this.threeds.card_types,t)}},{key:"should_verify_3d_secure_token",value:function(e){if(this.is_3d_secure_enabled()&&e.val()&&e.data("nonce")&&!e.data("verified"))return!0}},{key:"verify_3d_secure",value:function(e,t){var n=this,r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,i=s("#billing_state").val(),a=s("#billing_country").val(),o=s("#shipping_state").val(),_=s("#shipping_country").val(),i=s("input[name=billing_first_name]").val()?{givenName:s("input[name=billing_first_name]").val().latinise(),surname:s("input[name=billing_last_name]").val().latinise(),phoneNumber:s("input[name=billing_phone]").val(),streetAddress:s("input[name=billing_address_1]").val(),extendedAddress:s("input[name=billing_address_2]").val(),locality:s("#billing_city").val(),region:"string"==typeof i&&i.length<=2?i:"",postalCode:s("input[name=billing_postcode]").val(),countryCodeAlpha2:"string"==typeof a&&a.length<=2?a:""}:{},a=s("input[name=shipping_first_name]").val()?{shippingGivenName:s("input[name=shipping_first_name]").val().latinise(),shippingSurname:s("input[name=shipping_last_name]").val().latinise(),shippingAddress:{streetAddress:s("input[name=shipping_address_1]").val(),extendedAddress:s("input[name=shipping_address_2]").val(),locality:s("input[name=shipping_city]").val(),region:"string"==typeof o&&o.length<=2?o:"",postalCode:s("input[name=shipping_postcode]").val(),countryCodeAlpha2:"string"==typeof _&&_.length<=2?_:""}}:{},o={nonce:e,amount:s("input[name=wc-"+this.id_dasherized+"-3d-secure-order-total]").val(),email:s("input[name=billing_email]").val(),billingAddress:i,additionalInformation:a,onLookupComplete:function(e,t){n.log("3D Secure lookup complete.",e);try{return t()}catch(e){return n.handle_payment_error(e)}}};return"1"===s("input[name=wc-"+this.id_dasherized+"-cart-contains-subscription]").val()&&(o.challengeRequested=!0),this.log("Verifying 3D Secure.",o),this.threeDSecure.verifyCard(o).then(function(e){return n.log("3D Secure response received.",e),n.threeds.liability_shift_always_required&&!e.liabilityShifted?n.render_error(n.threeds.failure_message):(null!=r&&r.data("verified",!0),s("input[name=wc-"+n.id_dasherized+"-3d-secure-verified]").val(1),n.submit_form(e.nonce))}).catch(function(e){return n.handle_payment_error(e)})}},{key:"show_integration_ui",value:function(){return u(this,e),_get(o.prototype.__proto__||Object.getPrototypeOf(o.prototype),"show_integration_ui",this).call(this),s(".wc-braintree-hosted-field-parent").show()}},{key:"hide_integration_ui",value:function(){return u(this,e),_get(o.prototype.__proto__||Object.getPrototypeOf(o.prototype),"hide_integration_ui",this).call(this),s(".wc-braintree-hosted-field-parent").hide()}}]),o),s(document.body).trigger("wc_braintree_credit_card_payment_form_handler_loaded"),r=window.WC_Braintree_PayPal_Payment_Form_Handler=(_inherits(n,WC_Braintree_Payment_Form_Handler),_createClass(n,[{key:"init",value:function(){var t=this;return _get(n.prototype.__proto__||Object.getPrototypeOf(n.prototype),"init",this).call(this),s("input[name=wc_"+this.id+"_payment_nonce]").val(this.cart_payment_nonce),s(document.body).on("click",'input[name="payment_method"], input.js-wc-braintree-paypal-payment-token',function(){return t.toggle_order_button()}),s(document.body).on("payment_method_selected",function(){return t.toggle_order_button()}),s(document.body).on("click",".wc-braintree-paypal-account .cancel",function(e){return e.preventDefault(),s(e.currentTarget).parent().remove(),t.setup_braintree()}),s(document.body).on("update_checkout",function(e){return t.teardown_braintree()})}},{key:"toggle_order_button",value:function(){return!this.is_selected()||this.has_payment_nonce()||this.using_payment_token()?s("#place_order").show():s("#place_order").hide()}},{key:"verify_form",value:function(){var e=_get(n.prototype.__proto__||Object.getPrototypeOf(n.prototype),"verify_form",this).call(this);return this.has_payment_nonce()||this.using_payment_token()||this.render_error(this.must_login_message),e}},{key:"handle_payment_error",value:function(e){return _get(n.prototype.__proto__||Object.getPrototypeOf(n.prototype),"handle_payment_error",this).call(this,e),this.cart_payment_nonce=!1,this.setup_braintree()}},{key:"get_integration_class",value:function(){return braintree.paypalCheckout}},{key:"setup_braintree",value:function(){return this.cart_payment_nonce?this.unblock_ui():(_get(n.prototype.__proto__||Object.getPrototypeOf(n.prototype),"setup_braintree",this).call(this),s("input.js-wc-braintree-paypal-tokenize-payment-method").prop("disabled",!1),this.toggle_order_button())}},{key:"do_integration_ready",value:function(){return u(this,r),this.cart_payment_nonce?this.unblock_ui():this.load_paypal_sdk()}},{key:"load_paypal_sdk",value:function(){var e,t=this,n=this.get_sdk_options();return this.paypal_sdk_loaded&&this.previous_paypal_sdk_options&&JSON.stringify(this.previous_paypal_sdk_options)===JSON.stringify(n)?this.do_paypal_sdk_loaded():(e=n,this.paypal_sdk_messages_component_loaded&&(e.components="buttons"),this.integration.loadPayPalSDK(e,function(){return t.paypal_sdk_loaded=!0,t.previous_paypal_sdk_options=n,paypal.Messages&&(t.paypal_sdk_messages_component_loaded=!0),t.do_paypal_sdk_loaded()}))}},{key:"do_paypal_sdk_loaded",value:function(){var t=this,e=this.is_single_use()?"checkout":"vault";return this.render_pay_later_messaging(),this.render_button(this.integration.createPayment({flow:e,intent:this.is_single_use()?this.paypal_intent:"tokenize",amount:this.get_order_amount(),currency:this.get_store_currency(),locale:this.get_store_locale()}),this.get_button_styles(),"#wc_braintree_paypal_container").then(function(){return"undefined"===t.get_button_styles().height&&s("#wc_braintree_paypal_container").css({width:"100%"}),t.unblock_ui()}).catch(function(e){return t.log("Could not render the PayPal button. "+e.message,e),t.hide_integration_ui(),t.unblock_ui()})}},{key:"render_pay_later_messaging",value:function(){var t=this,e=s("#wc_braintree_paypal_pay_later_messaging_container");if(e.length)return paypal.Messages?paypal.Messages({amount:this.get_order_amount()}).render("#wc_braintree_paypal_pay_later_messaging_container").catch(function(e){return t.log("Could not render the PayPal Pay Later messeging. "+e.message,e)}):e.hide()}},{key:"render_button",value:function(e,t,n){var r=this;return s(n).html(""),t={env:this.is_test_environment?"sandbox":"production",commit:this.button_is_pay_now(),style:t,onApprove:function(e,t){return r.on_approve(e,t)},onError:function(e){return r.handle_integration_error(e)}},this.is_single_use()?t.createOrder=function(){return e}:t.createBillingAgreement=function(){return e},paypal.Buttons(t).render(n)}},{key:"button_is_pay_now",value:function(){return!s("form#add_payment_method").length}},{key:"get_button_styles",value:function(){return this.button_styles}},{key:"on_approve",value:function(e,t){var n=this;return u(this,r),this.block_ui(),this.integration.tokenizePayment(e).then(function(e){return n.log("Payment method tokenized.",e),n.set_payment_method(e)}).catch(function(e){return n.handle_payment_error(e),n.unblock_ui()})}},{key:"set_payment_method",value:function(e){return s("input[name=wc_"+this.id+"_payment_nonce]").val(e.nonce),s("#wc_braintree_paypal_container").html(this.get_linked_account_html(e.details)),this.is_single_use()&&s("input.js-wc-braintree-paypal-tokenize-payment-method").prop("disabled",!0),s("#place_order").show(),this.form.submit()}},{key:"handle_saved_payment_methods",value:function(){var t=this;return _get(n.prototype.__proto__||Object.getPrototypeOf(n.prototype),"handle_saved_payment_methods",this).call(this),s("input.js-wc-braintree-paypal-tokenize-payment-method").change(function(e){if(null!=t.integration&&s(e.target).is(":visible"))return t.block_ui(),t.do_integration_ready()}).change()}},{key:"get_linked_account_html",value:function(e){var t;return u(this,r),t=s("<div class='wc-"+this.id_dasherized+"-account'></div>"),null!=e.firstName&&null!=e.lastName&&t.append("<span class='name'>"+e.firstName+" "+e.lastName+"</span>"),t.append("<span class='email'>"+e.email+"</span>"),t.append("<a href='#' class='cancel'>Cancel</a>"),t}},{key:"is_single_use",value:function(){var e=s("input[name=wc-braintree-paypal-tokenize-payment-method]");return 0===e.length||("checkbox"===e.attr("type")?!e.is(":checked"):!e.val())}},{key:"get_order_amount",value:function(){return s("input[name=wc_braintree_paypal_amount]").val()}},{key:"get_store_currency",value:function(){return s("input[name=wc_braintree_paypal_currency]").val()}},{key:"get_store_locale",value:function(){return s("input[name=wc_braintree_paypal_locale]").val()}},{key:"get_sdk_options",value:function(){var e,t=[[],this.disabled_funding_options],n=t[0],t=t[1];return this.is_paypal_card_enabled||t.push("card"),(this.is_paypal_pay_later_enabled?n:t).push("paylater"),e={components:this.is_paypal_pay_later_enabled?"buttons,messages":"buttons",currency:this.get_store_currency(),intent:this.is_single_use()?this.paypal_intent:"tokenize",vault:!this.is_single_use(),commit:this.button_is_pay_now()},this.force_buyer_country&&(e["buyer-country"]=this.force_buyer_country),n.length&&(e["enable-funding"]=n.join(",")),t.length&&(e["disable-funding"]=t.join(",")),e}}]),n),s(document.body).trigger("wc_braintree_paypal_payment_form_handler_loaded"),window.WC_Braintree_PayPal_Cart_Handler=(_inherits(a,WC_Braintree_PayPal_Payment_Form_Handler),_createClass(a,[{key:"button_is_pay_now",value:function(){return!1}},{key:"set_payment_method",value:function(e){var t=this;if(null!=e.nonce)return e.wp_nonce=this.set_payment_method_nonce,s.ajax({type:"POST",url:this.cart_handler_url,data:e,dataType:"json"}).done(function(e){if(t.log("Cart response received.",e),null!=e.redirect_url)return window.location=e.redirect_url}).fail(function(e){return t.log("Error setting the PayPal cart data.",e,"error")}).always(function(){return t.unblock_ui()})}},{key:"is_single_use",value:function(){return"1"===s("input[name=wc_braintree_paypal_single_use]").val()}},{key:"has_payment_nonce",value:function(){return!1}}]),a),s(document.body).trigger("wc_braintree_paypal_cart_handler_loaded"),i=window.WC_Braintree_PayPal_Product_Button_Handler=(_inherits(_,WC_Braintree_PayPal_Payment_Form_Handler),_createClass(_,[{key:"handle_product_page",value:function(){return this.product_form={element:s("form.cart"),is_variable:s("form.cart").hasClass("variations_form")},this.should_validate_product_data&&this.product_form.element.on("change",this.validate_product_button),this.product_form.is_variable&&s(document.body).on("woocommerce_variation_has_changed",this.validate_product_button),this.validate_product_button()}},{key:"do_integration_ready",value:function(){if(u(this,i),_get(_.prototype.__proto__||Object.getPrototypeOf(_.prototype),"do_integration_ready",this).call(this),this.is_product_page)return this.validate_product_button()}},{key:"validate_product_button",value:function(){if(u(this,i),this.product_form.is_variable&&this.product_form.element.find(".single_add_to_cart_button").is(".disabled"))this.hide_button();else{if(!this.should_validate_product_data)return this.show_button();this.validate_product_data(this.show_button,this.hide_button)}}},{key:"validate_product_data",value:function(t,n){var r=this;return u(this,i),s.ajax({type:"POST",url:this.validate_product_url,data:{wp_nonce:this.validate_product_nonce,product_id:s("input[name=wc_braintree_paypal_product_id]").val(),cart_form:s("form.cart").serialize()}}).done(function(e){return e.data.is_valid?(e.data.order_amount&&r.maybe_update_order_amount(e.data.order_amount),t()):n()}).fail(n)}},{key:"hide_button",value:function(){return s("#wc_braintree_paypal_container, #wc_braintree_paypal_pay_later_messaging_container").slideUp()}},{key:"show_button",value:function(){return s("#wc_braintree_paypal_container, #wc_braintree_paypal_pay_later_messaging_container").slideDown()}},{key:"maybe_update_order_amount",value:function(e){if(parseFloat(e)!==parseFloat(this.get_order_amount()))return s('[name="wc_braintree_paypal_amount"]').val(e),this.refresh_braintree()}},{key:"button_is_pay_now",value:function(){return!1}},{key:"set_payment_method",value:function(e){var t=this;if(null!=e.nonce)return(e=e).wp_nonce=this.product_checkout_nonce,e.product_id=s("input[name=wc_braintree_paypal_product_id]").val(),e.cart_form=s("form.cart").serialize(),s.ajax({type:"POST",url:this.product_checkout_url,data:e,dataType:"json"}).done(function(e){if(t.log("Cart response received.",e),null!=e.redirect_url)return window.location=e.redirect_url}).fail(function(e){return t.log("Error setting the PayPal cart data.",e,"error")}).always(function(){return t.unblock_ui()})}},{key:"is_single_use",value:function(){return"1"===s("input[name=wc_braintree_paypal_single_use]").val()}},{key:"has_payment_nonce",value:function(){return!1}}]),_),s(document.body).trigger("wc_braintree_paypal_product_button_handler_loaded")})}.call(void 0);
1
+ "use strict";var _get=function e(t,n,r){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,n);return void 0!==i?"value"in i?i.value:void 0!==(i=i.get)?i.call(r):void 0:null!==(i=Object.getPrototypeOf(t))?e(i,n,r):void 0},_createClass=function(){function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}}();function _possibleConstructorReturn(e,t){if(e)return!t||"object"!=typeof t&&"function"!=typeof t?e:t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}!function(){function u(e,t){if(!(e instanceof t))throw new Error("Bound instance method accessed before binding")}var c=[].indexOf;jQuery(document).ready(function(s){var e,r,i;function t(e){_classCallCheck(this,t),this.show_integration_ui=this.show_integration_ui.bind(this),this.hide_integration_ui=this.hide_integration_ui.bind(this),this.id=e.id,this.id_dasherized=e.id_dasherized,this.name=e.name,this.type=e.type,this.debug=e.debug,this.client_token_nonce=e.client_token_nonce,this.ajax_url=e.ajax_url,this.integration_error_message=e.integration_error_message,this.payment_error_message=e.payment_error_message,this.params=window.sv_wc_payment_gateway_payment_form_params}function o(e){_classCallCheck(this,o);var t=_possibleConstructorReturn(this,(o.__proto__||Object.getPrototypeOf(o)).call(this,e));return t.show_integration_ui=t.show_integration_ui.bind(t),t.hide_integration_ui=t.hide_integration_ui.bind(t),t.csc_required=e.csc_required,t.hosted_fields_styles=e.hosted_fields_styles,t.threeds=e.threeds,t.enabled_card_types=e.enabled_card_types,t.init(),t}function n(e){_classCallCheck(this,n);var t=_possibleConstructorReturn(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e));return t.do_integration_ready=t.do_integration_ready.bind(t),t.on_approve=t.on_approve.bind(t),t.get_linked_account_html=t.get_linked_account_html.bind(t),t.is_test_environment=e.is_test_environment,t.is_paypal_pay_later_enabled=e.is_paypal_pay_later_enabled,t.is_paypal_card_enabled=e.is_paypal_card_enabled,t.disabled_funding_options=e.paypal_disabled_funding_options,t.force_buyer_country=e.force_buyer_country,t.must_login_message=e.must_login_message,t.must_login_add_method_message=e.must_login_add_method_message,t.button_styles=e.button_styles,t.cart_payment_nonce=e.cart_payment_nonce,t.paypal_intent=e.paypal_intent,t.init(),t}function a(e){_classCallCheck(this,a);var t=_possibleConstructorReturn(this,(a.__proto__||Object.getPrototypeOf(a)).call(this,e));return t.is_paypal_card_enabled=!1,t.set_payment_method_nonce=e.set_payment_method_nonce,t.cart_handler_url=e.cart_handler_url,t.form=s("form.woocommerce-cart-form"),t.form_ui_selector="",t.setup_braintree(),s(document.body).on("updated_cart_totals",function(){return t.setup_braintree()}),t}function _(e){_classCallCheck(this,_);var t=_possibleConstructorReturn(this,(_.__proto__||Object.getPrototypeOf(_)).call(this,e));return t.do_integration_ready=t.do_integration_ready.bind(t),t.validate_product_button=t.validate_product_button.bind(t),t.validate_product_data=t.validate_product_data.bind(t),t.is_paypal_card_enabled=!1,t.product_checkout_nonce=e.product_checkout_nonce,t.product_checkout_url=e.product_checkout_url,t.is_product_page=e.is_product_page,t.validate_product_url=e.validate_product_url,t.validate_product_nonce=e.validate_product_nonce,t.should_validate_product_data=e.should_validate_product_data,t.form=s("form.woocommerce-cart-form"),t.form_ui_selector="",t.is_product_page&&t.handle_product_page(),t.setup_braintree(),s(document.body).on("updated_cart_totals",function(){return t.setup_braintree()}),t}return window.WC_Braintree_Payment_Form_Handler=(_createClass(t,[{key:"init",value:function(){return this.is_sdk_ready()?s("form.checkout").length?this.handle_checkout_page():s("form#order_review").length?this.handle_pay_page():s("form#add_payment_method").length?this.handle_add_payment_method_page():void 0:console.error("Braintree SDK is missing.")}},{key:"handle_checkout_page",value:function(){var e=this;return this.form=s("form.checkout"),this.form_ui_selector=".woocommerce-checkout-payment",s(document.body).on("updated_checkout",function(){if(!e.setting_up)return s('iframe[name^="braintree-"]').remove(),e.setup_braintree()}),s(document.body).on("updated_checkout",function(){return e.handle_saved_payment_methods()}),s(document.body).on("checkout_error",function(){return e.handle_checkout_error()}),this.form.on("checkout_place_order_"+this.id,function(){if(e.is_selected())return e.block_ui(),e.verify_form()})}},{key:"handle_checkout_error",value:function(){return this.unblock_ui()}},{key:"handle_pay_page",value:function(){var e=this;return this.form=s("form#order_review"),this.form_ui_selector="#payment",this.handle_saved_payment_methods(),this.setup_braintree(),this.form.submit(function(){if(e.is_selected())return e.block_ui(),e.verify_form()})}},{key:"handle_add_payment_method_page",value:function(){var e=this;return this.form=s("form#add_payment_method"),this.form_ui_selector="#payment",this.setup_braintree(),this.form.submit(function(){if(e.is_selected())return e.block_ui(),e.verify_form()})}},{key:"verify_form",value:function(){return!!this.using_payment_token()||!!this.has_payment_nonce()&&void 0}},{key:"submit_form",value:function(e){return s("input[name=wc_"+this.id+"_payment_nonce]").val(e),this.form.submit()}},{key:"handle_saved_payment_methods",value:function(){var n=this,e=s("div.js-wc-"+this.id_dasherized+"-new-payment-method-form");if(s("input.js-wc-"+this.id_dasherized+"-payment-token").change(function(){return s("input.js-wc-"+n.id_dasherized+"-payment-token:checked").val()?e.slideUp(200):e.slideDown(200)}).change(),s("input#createaccount").change(function(e){var t=s("input.js-wc-"+n.id_dasherized+"-tokenize-payment-method").closest("p.form-row");return s(e.target).is(":checked")?(t.slideDown(),t.next().show()):(t.hide(),t.next().hide())}),!s("input#createaccount").is(":checked"))return s("input#createaccount").change()}},{key:"setup_braintree",value:function(){if(!s("#wc-"+this.id_dasherized+"-account-number-hosted iframe").data("ready"))return this.setting_up=!0,this.block_ui(),s("input[name=wc_"+this.id+"_payment_nonce]").val(""),this.create_client()}},{key:"create_client",value:function(){var r=this;return this.log("Creating client."),this.get_client_token().done(function(e){return e.success?braintree.client.create({authorization:e.data}).then(function(e){return r.client=e,r.log("Client ready."),r.setup_integration()}).catch(function(e){return r.handle_integration_error(e),r.unblock_ui()}):r.handle_integration_error(e.data)}).fail(function(e,t,n){return r.handle_integration_error({message:"Could not retrieve the client token via AJAX: "+n}),r.unblock_ui()})}},{key:"get_client_token",value:function(){this.id;var e={action:"wc_"+this.id+"_get_client_token",nonce:this.client_token_nonce};return s.post(this.ajax_url,e)}},{key:"setup_integration",value:function(){var t=this;return this.set_device_data(),this.log("Creating integration."),this.get_integration_class().create(this.get_integration_options()).then(function(e){return t.integration=e,t.show_integration_ui(),s("#wc-"+t.id_dasherized+"-account-number-hosted iframe").data("ready",!0),t.do_integration_ready(),s(document).trigger("wc_"+t.id+"_integration_ready",t.integration),t.log("Integration ready."),t.setting_up=!1}).catch(function(e){return t.handle_integration_error(e),t.unblock_ui(),t.setting_up=!1})}},{key:"refresh_braintree",value:function(){var e=this;if(null!=this.integration&&!this.refreshing&&!this.setting_up)return this.log("Refreshing integration."),this.refreshing=!0,this.block_ui(),this.integration.teardown(function(){return e.integration=null,e.refreshing=!1,e.setup_braintree()})}},{key:"teardown_braintree",value:function(){var e=this;if(null!=this.integration&&!this.tearing_down&&!this.setting_up)return this.log("Tearing down integration."),this.tearing_down=!0,this.block_ui(),this.integration.teardown(function(){return e.integration=null,e.tearing_down=!1,e.unblock_ui()})}},{key:"set_device_data",value:function(){if(braintree&&braintree.dataCollector)return braintree.dataCollector.create({client:this.client}).then(function(e){if(e&&e.deviceData)return s("input[id*='wc_braintree_device_data']").val(e.deviceData)})}},{key:"do_integration_ready",value:function(){}},{key:"get_integration_options",value:function(){return{client:this.client}}},{key:"get_integration_class",value:function(){}},{key:"handle_integration_error",value:function(e){return this.log("Integration error. "+e.message,e,"error"),this.hide_integration_ui(),this.unblock_ui()}},{key:"handle_payment_error",value:function(e){return this.log("Payment error. "+e.message,e,"error"),this.render_error(this.get_user_message(e)),this.unblock_ui()}},{key:"render_error",value:function(e){return s(".woocommerce-error, .woocommerce-message").remove(),this.form.prepend('<div class="woocommerce-error">'+e+"</div>").removeClass("processing").unblock(),s("html, body").animate({scrollTop:this.form.offset().top-100},1e3),s("input[name=wc_"+this.id+"_payment_nonce]").val(""),this.form.trigger("wc_"+this.id+"_rendered_error"),s(document.body).trigger("checkout_error"),this.unblock_ui()}},{key:"get_user_message",value:function(e){return this.payment_error_message}},{key:"show_integration_ui",value:function(){if(s("div.js-wc-"+this.id_dasherized+"-new-payment-method-form").find(".woocommerce-error").remove(),s("input#createaccount").length&&s("input#createaccount").is(":checked"))return s("div.js-wc-"+this.id_dasherized+"-new-payment-method-form").find(".form-row").show()}},{key:"hide_integration_ui",value:function(){return s("div.js-wc-"+this.id_dasherized+"-new-payment-method-form").prepend('<div class="woocommerce-error">'+this.integration_error_message+"</div>"),s("div.js-wc-"+this.id_dasherized+"-new-payment-method-form").find(".form-row").hide()}},{key:"block_ui",value:function(){return s(this.form_ui_selector).block({message:null,overlayCSS:{background:"#fff",opacity:.6}})}},{key:"unblock_ui",value:function(){return s(this.form_ui_selector).unblock()}},{key:"is_selected",value:function(){return this.get_selected_gateway_id()===this.id}},{key:"is_sdk_ready",value:function(){return"undefined"!=typeof braintree&&null!==braintree&&null!=braintree.client&&null!=this.get_integration_class()}},{key:"has_payment_nonce",value:function(){return this.form.find("input[name=wc_"+this.id+"_payment_nonce]").val()}},{key:"using_payment_token",value:function(){return this.form.find("input.js-wc-"+this.id_dasherized+"-payment-token:checked").val()}},{key:"get_selected_gateway_id",value:function(){return this.form.find("input[name=payment_method]:checked").val()}},{key:"log",value:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;if(this.debug)return console.log(this.name+": "+e),t?console.log(t):void 0}}]),t),s(document.body).trigger("wc_braintree_payment_form_handler_loaded"),e=window.WC_Braintree_Credit_Card_Payment_Form_Handler=(_inherits(o,WC_Braintree_Payment_Form_Handler),_createClass(o,[{key:"handle_checkout_error",value:function(){return _get(o.prototype.__proto__||Object.getPrototypeOf(o.prototype),"handle_checkout_error",this).call(this),s("input[name=wc_"+this.id+"_payment_nonce]").val(""),s("input[name=wc-"+this.id_dasherized+"-card-type]").val(""),s("input[name=wc-"+this.id_dasherized+"-3d-secure-verified]").val(0)}},{key:"verify_form",value:function(){var e;return this.has_payment_nonce()||!this.csc_required&&this.using_payment_token()?(e=s("input.js-wc-braintree-credit-card-payment-token:checked"),this.should_verify_3d_secure_token(e)?(this.verify_3d_secure(e.data("nonce"),null,e),!1):_get(o.prototype.__proto__||Object.getPrototypeOf(o.prototype),"verify_form",this).call(this)):(this.tokenize_payment(),!1)}},{key:"tokenize_payment",value:function(){var t=this;return this.integration.tokenize().then(function(e){if(t.log("Payment method received.",e),null!=e.nonce&&null!=e.details&&null!=e.details.bin)return t.should_verify_3d_secure(e)?t.verify_3d_secure(e.nonce,e.details.bin):t.submit_form(e.nonce)}).catch(function(e){return t.handle_payment_error(e)})}},{key:"get_integration_options",value:function(){var e={client:this.client,fields:{number:{selector:"#wc-braintree-credit-card-account-number-hosted",placeholder:s("#wc-braintree-credit-card-account-number-hosted").data("placeholder")},cvv:{selector:"#wc-braintree-credit-card-csc-hosted",placeholder:s("#wc-braintree-credit-card-csc-hosted").data("placeholder")},expirationDate:{selector:"#wc-braintree-credit-card-expiry-hosted",placeholder:s("#wc-braintree-credit-card-expiry-hosted").data("placeholder")}},styles:this.hosted_fields_styles};return this.csc_required&&this.using_payment_token()&&(delete e.fields.number,delete e.fields.expirationDate),this.csc_required||delete e.fields.cvv,e}},{key:"get_integration_class",value:function(){return braintree.hostedFields}},{key:"do_integration_ready",value:function(){var t=this;return this.integration.on("cardTypeChange",function(e){return t.on_card_type_change(e)}),!this.csc_required&&s("input.js-wc-braintree-credit-card-payment-token:checked").val()&&this.teardown_braintree(),this.unblock_ui()}},{key:"handle_saved_payment_methods",value:function(){var e,t,n=this;return _get(o.prototype.__proto__||Object.getPrototypeOf(o.prototype),"handle_saved_payment_methods",this).call(this),t=s("div.js-wc-braintree-credit-card-new-payment-method-form"),e=s("div.wc-braintree-hosted-field-card-csc-parent"),s("input.js-wc-braintree-credit-card-payment-token").change(function(){return s("input.js-wc-braintree-credit-card-payment-token:checked").val()?n.csc_required&&e.hasClass("form-row-last")?(e.removeClass("form-row-last").addClass("form-row-first"),t.after(e),n.refresh_braintree()):void 0:(n.csc_required&&e.hasClass("form-row-first")&&(e.removeClass("form-row-first").addClass("form-row-last"),t.find("div.wc-braintree-hosted-field-card-expiry-parent").after(e)),n.refresh_braintree())}).change()}},{key:"get_user_message",value:function(e){var t,n,r,i,a=[];if("CUSTOMER"===e.type)switch(e.code){case"HOSTED_FIELDS_FIELDS_EMPTY":this.csc_required&&a.push(this.params.cvv_missing),this.using_payment_token()||(a.push(this.params.card_number_missing),a.push(this.params.card_exp_date_invalid));break;case"HOSTED_FIELDS_FIELDS_INVALID":if(null!=e.details)for(t=0,n=(i=e.details.invalidFieldKeys).length;t<n;t++)switch(i[t]){case"number":a.push(this.params.card_number_invalid);break;case"cvv":a.push(this.params.cvv_length_invalid);break;case"expirationDate":a.push(this.params.card_exp_date_invalid)}break;default:null!=e.message&&a.push(e.message),null!=e.error&&null!=e.error.message&&a.push(e.error.message),null!=e.details&&null!=e.details.originalError&&(a=a.concat(this.get_user_message(e.details.originalError)))}else"NETWORK"===e.type&&null!=e.details.originalError.error.message&&(r=e.details.originalError.error.message,/given name format is invalid/.test(r)?a.push(this.params.first_name_unsupported_characters):/surname format is invalid/.test(r)?a.push(this.params.last_name_unsupported_characters):a.push(r));return a.length?a.join("<br/>"):_get(o.prototype.__proto__||Object.getPrototypeOf(o.prototype),"get_user_message",this).call(this)}},{key:"on_card_type_change",value:function(e){var t,n;if(null!=e.cards)return(t=s("#wc-braintree-credit-card-account-number-hosted")).attr("class",function(e,t){return t.replace(/(^|\s)card-type-\S+/g,"")}),e.cards.length?1===e.cards.length?(e=e.cards[0],s("input[name=wc-"+this.id_dasherized+"-card-type]").val(e.type),null!=e.type&&(n=e.type,0<=c.call(this.enabled_card_types,n))?t.addClass("card-type-"+e.type):t.addClass("card-type-invalid")):void 0:t.addClass("card-type-invalid")}},{key:"is_3d_secure_enabled",value:function(){return this.threeds.enabled&&null!=braintree.threeDSecure}},{key:"setup_integration",value:function(){var t=this;return this.threeds.enabled&&(this.threeds.enabled=this.client.getConfiguration().gatewayConfiguration.threeDSecureEnabled),this.is_3d_secure_enabled()?(s("input[name=wc-"+this.id_dasherized+"-3d-secure-enabled]").val(1),this.threeDSecure&&this.threeDSecure.teardown(),braintree.threeDSecure.create({version:2,client:this.client}).then(function(e){return t.threeDSecure=e,s(document.body).on("click","#wc-braintree-credit-card-3dsecure-container",function(e){return s(e.currentTarget).fadeOut(200),t.threeDSecure.cancelVerifyCard(),t.unblock_ui()}),_get(o.prototype.__proto__||Object.getPrototypeOf(o.prototype),"setup_integration",t).call(t)}).catch(function(e){return t.handle_integration_error(e)})):_get(o.prototype.__proto__||Object.getPrototypeOf(o.prototype),"setup_integration",this).call(this)}},{key:"should_verify_3d_secure",value:function(e){var t=e.details.cardType;return this.is_3d_secure_enabled()&&"CreditCard"===e.type&&0<=c.call(this.threeds.card_types,t)}},{key:"should_verify_3d_secure_token",value:function(e){if(this.is_3d_secure_enabled()&&e.val()&&e.data("nonce")&&!e.data("verified"))return!0}},{key:"verify_3d_secure",value:function(e,t){var n=this,r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,i=s("#billing_state").val(),a=s("#billing_country").val(),o=s("#shipping_state").val(),_=s("#shipping_country").val(),i=s("input[name=billing_first_name]").val()?{givenName:s("input[name=billing_first_name]").val().latinise(),surname:s("input[name=billing_last_name]").val().latinise(),phoneNumber:s("input[name=billing_phone]").val(),streetAddress:s("input[name=billing_address_1]").val(),extendedAddress:s("input[name=billing_address_2]").val(),locality:s("#billing_city").val(),region:"string"==typeof i&&i.length<=2?i:"",postalCode:s("input[name=billing_postcode]").val(),countryCodeAlpha2:"string"==typeof a&&a.length<=2?a:""}:{},a=s("input[name=shipping_first_name]").val()?{shippingGivenName:s("input[name=shipping_first_name]").val().latinise(),shippingSurname:s("input[name=shipping_last_name]").val().latinise(),shippingAddress:{streetAddress:s("input[name=shipping_address_1]").val(),extendedAddress:s("input[name=shipping_address_2]").val(),locality:s("input[name=shipping_city]").val(),region:"string"==typeof o&&o.length<=2?o:"",postalCode:s("input[name=shipping_postcode]").val(),countryCodeAlpha2:"string"==typeof _&&_.length<=2?_:""}}:{},o={nonce:e,amount:s("input[name=wc-"+this.id_dasherized+"-3d-secure-order-total]").val(),email:s("input[name=billing_email]").val(),billingAddress:i,additionalInformation:a,onLookupComplete:function(e,t){n.log("3D Secure lookup complete.",e);try{return t()}catch(e){return n.handle_payment_error(e)}}};return"1"===s("input[name=wc-"+this.id_dasherized+"-cart-contains-subscription]").val()&&(o.challengeRequested=!0),this.log("Verifying 3D Secure.",o),this.threeDSecure.verifyCard(o).then(function(e){return n.log("3D Secure response received.",e),n.threeds.liability_shift_always_required&&!e.liabilityShifted?n.render_error(n.threeds.failure_message):(null!=r&&r.data("verified",!0),s("input[name=wc-"+n.id_dasherized+"-3d-secure-verified]").val(1),n.submit_form(e.nonce))}).catch(function(e){return n.handle_payment_error(e)})}},{key:"show_integration_ui",value:function(){return u(this,e),_get(o.prototype.__proto__||Object.getPrototypeOf(o.prototype),"show_integration_ui",this).call(this),s(".wc-braintree-hosted-field-parent").show()}},{key:"hide_integration_ui",value:function(){return u(this,e),_get(o.prototype.__proto__||Object.getPrototypeOf(o.prototype),"hide_integration_ui",this).call(this),s(".wc-braintree-hosted-field-parent").hide()}}]),o),s(document.body).trigger("wc_braintree_credit_card_payment_form_handler_loaded"),r=window.WC_Braintree_PayPal_Payment_Form_Handler=(_inherits(n,WC_Braintree_Payment_Form_Handler),_createClass(n,[{key:"init",value:function(){var t=this;return _get(n.prototype.__proto__||Object.getPrototypeOf(n.prototype),"init",this).call(this),s("input[name=wc_"+this.id+"_payment_nonce]").val(this.cart_payment_nonce),s(document.body).on("click",'input[name="payment_method"], input.js-wc-braintree-paypal-payment-token',function(){return t.toggle_order_button()}),s(document.body).on("payment_method_selected",function(){return t.toggle_order_button()}),s(document.body).on("click",".wc-braintree-paypal-account .cancel",function(e){return e.preventDefault(),s(e.currentTarget).parent().remove(),t.setup_braintree()}),s(document.body).on("update_checkout",function(e){return t.teardown_braintree()})}},{key:"toggle_order_button",value:function(){return!this.is_selected()||this.has_payment_nonce()||this.using_payment_token()?s("#place_order").show():s("#place_order").hide()}},{key:"verify_form",value:function(){var e=_get(n.prototype.__proto__||Object.getPrototypeOf(n.prototype),"verify_form",this).call(this);return this.has_payment_nonce()||this.using_payment_token()||this.render_error(this.must_login_message),e}},{key:"handle_payment_error",value:function(e){return _get(n.prototype.__proto__||Object.getPrototypeOf(n.prototype),"handle_payment_error",this).call(this,e),this.cart_payment_nonce=!1,this.setup_braintree()}},{key:"get_integration_class",value:function(){return braintree.paypalCheckout}},{key:"setup_braintree",value:function(){return this.cart_payment_nonce?this.unblock_ui():(_get(n.prototype.__proto__||Object.getPrototypeOf(n.prototype),"setup_braintree",this).call(this),s("input.js-wc-braintree-paypal-tokenize-payment-method").prop("disabled",!1),this.toggle_order_button())}},{key:"do_integration_ready",value:function(){return u(this,r),this.cart_payment_nonce?this.unblock_ui():this.load_paypal_sdk()}},{key:"load_paypal_sdk",value:function(){var e,t=this,n=this.get_sdk_options();return this.paypal_sdk_loaded&&this.previous_paypal_sdk_options&&JSON.stringify(this.previous_paypal_sdk_options)===JSON.stringify(n)?this.do_paypal_sdk_loaded():(e=n,this.paypal_sdk_messages_component_loaded&&(e.components="buttons"),this.integration.loadPayPalSDK(e,function(){return t.paypal_sdk_loaded=!0,t.previous_paypal_sdk_options=n,paypal.Messages&&(t.paypal_sdk_messages_component_loaded=!0),t.do_paypal_sdk_loaded()}))}},{key:"do_paypal_sdk_loaded",value:function(){var t=this,e=this.is_single_use()?"checkout":"vault";return this.render_pay_later_messaging(),this.render_button(this.integration.createPayment({flow:e,intent:this.is_single_use()?this.paypal_intent:"tokenize",amount:this.get_order_amount(),currency:this.get_store_currency(),locale:this.get_store_locale()}),this.get_button_styles(),"#wc_braintree_paypal_container").then(function(){return"undefined"===t.get_button_styles().height&&s("#wc_braintree_paypal_container").css({width:"100%"}),t.unblock_ui()}).catch(function(e){return t.log("Could not render the PayPal button. "+e.message,e),t.hide_integration_ui(),t.unblock_ui()})}},{key:"render_pay_later_messaging",value:function(){var t=this,e=s("#wc_braintree_paypal_pay_later_messaging_container");if(e.length)return paypal.Messages?paypal.Messages({amount:this.get_order_amount()}).render("#wc_braintree_paypal_pay_later_messaging_container").catch(function(e){return t.log("Could not render the PayPal Pay Later messeging. "+e.message,e)}):e.hide()}},{key:"render_button",value:function(e,t,n){var r=this;return s(n).html(""),t={env:this.is_test_environment?"sandbox":"production",commit:this.button_is_pay_now(),style:t,onApprove:function(e,t){return r.on_approve(e,t)},onError:function(e){return r.handle_integration_error(e)}},this.is_single_use()?t.createOrder=function(){return e}:t.createBillingAgreement=function(){return e},paypal.Buttons(t).render(n)}},{key:"button_is_pay_now",value:function(){return!s("form#add_payment_method").length}},{key:"get_button_styles",value:function(){return this.button_styles}},{key:"on_approve",value:function(e,t){var n=this;return u(this,r),this.block_ui(),this.integration.tokenizePayment(e).then(function(e){return n.log("Payment method tokenized.",e),n.set_payment_method(e)}).catch(function(e){return n.handle_payment_error(e),n.unblock_ui()})}},{key:"set_payment_method",value:function(e){return s("input[name=wc_"+this.id+"_payment_nonce]").val(e.nonce),s("#wc_braintree_paypal_container").html(this.get_linked_account_html(e.details)),this.is_single_use()&&s("input.js-wc-braintree-paypal-tokenize-payment-method").prop("disabled",!0),s("#place_order").show(),this.form.submit()}},{key:"handle_saved_payment_methods",value:function(){var t=this;return _get(n.prototype.__proto__||Object.getPrototypeOf(n.prototype),"handle_saved_payment_methods",this).call(this),s("input.js-wc-braintree-paypal-tokenize-payment-method").change(function(e){if(null!=t.integration&&s(e.target).is(":visible"))return t.block_ui(),t.do_integration_ready()}).change()}},{key:"get_linked_account_html",value:function(e){var t;return u(this,r),t=s("<div class='wc-"+this.id_dasherized+"-account'></div>"),null!=e.firstName&&null!=e.lastName&&t.append("<span class='name'>"+e.firstName+" "+e.lastName+"</span>"),t.append("<span class='email'>"+e.email+"</span>"),t.append("<a href='#' class='cancel'>Cancel</a>"),t}},{key:"is_single_use",value:function(){var e=s("input[name=wc-braintree-paypal-tokenize-payment-method]");return 0===e.length||("checkbox"===e.attr("type")?!e.is(":checked"):!e.val())}},{key:"get_order_amount",value:function(){return s("input[name=wc_braintree_paypal_amount]").val()}},{key:"get_store_currency",value:function(){return s("input[name=wc_braintree_paypal_currency]").val()}},{key:"get_store_locale",value:function(){return s("input[name=wc_braintree_paypal_locale]").val()}},{key:"get_sdk_options",value:function(){var e,t=[[],this.disabled_funding_options],n=t[0],t=t[1];return this.is_paypal_card_enabled||t.push("card"),(this.is_paypal_pay_later_enabled?n:t).push("paylater"),e={components:this.is_paypal_pay_later_enabled?"buttons,messages":"buttons",currency:this.get_store_currency(),intent:this.is_single_use()?this.paypal_intent:"tokenize",vault:!this.is_single_use(),commit:this.button_is_pay_now()},this.force_buyer_country&&(e["buyer-country"]=this.force_buyer_country),n.length&&(e["enable-funding"]=n.join(",")),t.length&&(e["disable-funding"]=t.join(",")),e}}]),n),s(document.body).trigger("wc_braintree_paypal_payment_form_handler_loaded"),window.WC_Braintree_PayPal_Cart_Handler=(_inherits(a,WC_Braintree_PayPal_Payment_Form_Handler),_createClass(a,[{key:"button_is_pay_now",value:function(){return!1}},{key:"set_payment_method",value:function(e){var t=this;if(null!=e.nonce)return e.wp_nonce=this.set_payment_method_nonce,s.ajax({type:"POST",url:this.cart_handler_url,data:e,dataType:"json"}).done(function(e){if(t.log("Cart response received.",e),null!=e.redirect_url)return window.location=e.redirect_url}).fail(function(e){return t.log("Error setting the PayPal cart data.",e,"error")}).always(function(){return t.unblock_ui()})}},{key:"is_single_use",value:function(){return"1"===s("input[name=wc_braintree_paypal_single_use]").val()}},{key:"has_payment_nonce",value:function(){return!1}}]),a),s(document.body).trigger("wc_braintree_paypal_cart_handler_loaded"),i=window.WC_Braintree_PayPal_Product_Button_Handler=(_inherits(_,WC_Braintree_PayPal_Payment_Form_Handler),_createClass(_,[{key:"handle_product_page",value:function(){return this.product_form={element:s("form.cart"),is_variable:s("form.cart").hasClass("variations_form")},this.should_validate_product_data&&this.product_form.element.on("change",this.validate_product_button),this.product_form.is_variable&&s(document.body).on("woocommerce_variation_has_changed",this.validate_product_button),this.validate_product_button()}},{key:"do_integration_ready",value:function(){if(u(this,i),_get(_.prototype.__proto__||Object.getPrototypeOf(_.prototype),"do_integration_ready",this).call(this),this.is_product_page)return this.validate_product_button()}},{key:"validate_product_button",value:function(){if(u(this,i),this.product_form.is_variable&&this.product_form.element.find(".single_add_to_cart_button").is(".disabled"))this.hide_button();else{if(!this.should_validate_product_data)return this.show_button();this.validate_product_data(this.show_button,this.hide_button)}}},{key:"validate_product_data",value:function(t,n){var r=this;return u(this,i),s.ajax({type:"POST",url:this.validate_product_url,data:{wp_nonce:this.validate_product_nonce,product_id:s("input[name=wc_braintree_paypal_product_id]").val(),cart_form:s("form.cart").serialize()}}).done(function(e){return(e.data.is_valid?(e.data.order_amount&&r.maybe_update_order_amount(e.data.order_amount),t):n)()}).fail(n)}},{key:"hide_button",value:function(){return s("#wc_braintree_paypal_container, #wc_braintree_paypal_pay_later_messaging_container").slideUp()}},{key:"show_button",value:function(){return s("#wc_braintree_paypal_container, #wc_braintree_paypal_pay_later_messaging_container").slideDown()}},{key:"maybe_update_order_amount",value:function(e){if(parseFloat(e)!==parseFloat(this.get_order_amount()))return s('[name="wc_braintree_paypal_amount"]').val(e),this.refresh_braintree()}},{key:"button_is_pay_now",value:function(){return!1}},{key:"set_payment_method",value:function(e){var t=this;if(null!=e.nonce)return(e=e).wp_nonce=this.product_checkout_nonce,e.product_id=s("input[name=wc_braintree_paypal_product_id]").val(),e.cart_form=s("form.cart").serialize(),s.ajax({type:"POST",url:this.product_checkout_url,data:e,dataType:"json"}).done(function(e){if(t.log("Cart response received.",e),null!=e.redirect_url)return window.location=e.redirect_url}).fail(function(e){return t.log("Error setting the PayPal cart data.",e,"error")}).always(function(){return t.unblock_ui()})}},{key:"is_single_use",value:function(){return"1"===s("input[name=wc_braintree_paypal_single_use]").val()}},{key:"has_payment_nonce",value:function(){return!1}}]),_),s(document.body).trigger("wc_braintree_paypal_product_button_handler_loaded")})}.call(void 0);
changelog.txt CHANGED
@@ -1,5 +1,10 @@
1
  *** Changelog ***
2
 
 
 
 
 
 
3
  = 2.8.0 - 2022-10-12 =
4
  * Add - Support for 3DS2 / EMV 3DS cards.
5
  * Fix - Upgrade Braintree PHP SDK from v3.34.0 to v6.7.0.
1
  *** Changelog ***
2
 
3
+ = 2.9.0 - 2022-11-01 =
4
+ * Add – Support for High-performance Order Storage (“HPOS”).
5
+ * Add – Declare compatibility with High-Performance Order Storage (“HPOS”).
6
+ * Fix – Display more detailed error messages on checkout.
7
+
8
  = 2.8.0 - 2022-10-12 =
9
  * Add - Support for 3DS2 / EMV 3DS cards.
10
  * Fix - Upgrade Braintree PHP SDK from v3.34.0 to v6.7.0.
class-wc-braintree.php CHANGED
@@ -35,7 +35,7 @@ class WC_Braintree extends Framework\SV_WC_Payment_Gateway_Plugin {
35
 
36
 
37
  /** plugin version number */
38
- const VERSION = '2.8.0';
39
 
40
  /** Braintree JS SDK version */
41
  const BRAINTREE_JS_SDK_VERSION = '3.73.1';
35
 
36
 
37
  /** plugin version number */
38
+ const VERSION = '2.9.0';
39
 
40
  /** Braintree JS SDK version */
41
  const BRAINTREE_JS_SDK_VERSION = '3.73.1';
includes/class-wc-gateway-braintree.php CHANGED
@@ -1036,26 +1036,26 @@ class WC_Gateway_Braintree extends Framework\SV_WC_Payment_Gateway_Direct {
1036
 
1037
  $order_id = $order->get_id();
1038
 
1039
- // update a legacy payment token if it exists
1040
- if ( 'payment_token' === $key && metadata_exists( 'post', $order_id, '_wc_paypal_braintree_payment_method_token' ) && ! get_post_meta( $order_id, $this->get_order_meta_prefix() . $key, true ) && $this->get_id() === get_post_meta( $order_id, '_payment_method', true ) ) {
1041
 
1042
- $legacy_token = get_post_meta( $order_id, '_wc_paypal_braintree_payment_method_token', true );
1043
 
1044
- update_post_meta( $order_id, $this->get_order_meta_prefix() . $key, $legacy_token );
1045
-
1046
- delete_post_meta( $order_id, '_wc_paypal_braintree_payment_method_token' );
1047
 
1048
  return $legacy_token;
1049
  }
1050
 
1051
- // update a legacy customer ID if it exists
1052
- if ( 'customer_id' === $key && metadata_exists( 'post', $order_id, '_wc_paypal_braintree_customer_id' ) && ! get_post_meta( $order_id, $this->get_order_meta_prefix() . $key, true ) && $this->get_id() === get_post_meta( $order_id, '_payment_method', true ) ) {
1053
-
1054
- $legacy_customer_id = get_post_meta( $order_id, '_wc_paypal_braintree_customer_id', true );
1055
 
1056
- update_post_meta( $order_id, $this->get_order_meta_prefix() . $key, $legacy_customer_id );
1057
 
1058
- delete_post_meta( $order_id, '_wc_paypal_braintree_customer_id' );
 
 
1059
 
1060
  return $legacy_customer_id;
1061
  }
@@ -1592,5 +1592,29 @@ class WC_Gateway_Braintree extends Framework\SV_WC_Payment_Gateway_Direct {
1592
  return $this->get_option( 'transaction_type' );
1593
  }
1594
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1595
 
1596
  }
1036
 
1037
  $order_id = $order->get_id();
1038
 
1039
+ // update a legacy payment token if it exists.
1040
+ if ( 'payment_token' === $key && $order->meta_exists( '_wc_paypal_braintree_payment_method_token' ) && ! $order->get_meta( $this->get_order_meta_prefix() . $key, true, 'edit' ) && $this->get_id() === $order->get_payment_method( 'edit' ) ) {
1041
 
1042
+ $legacy_token = $order->get_meta( '_wc_paypal_braintree_payment_method_token', true, 'edit' );
1043
 
1044
+ $order->update_meta_data( $this->get_order_meta_prefix() . $key, $legacy_token );
1045
+ $order->delete_meta_data( '_wc_paypal_braintree_payment_method_token' );
1046
+ $order->save_meta_data();
1047
 
1048
  return $legacy_token;
1049
  }
1050
 
1051
+ // update a legacy customer ID if it exists.
1052
+ if ( 'customer_id' === $key && $order->meta_exists( '_wc_paypal_braintree_customer_id' ) && ! $order->get_meta( $this->get_order_meta_prefix() . $key, true, 'edit' ) && $this->get_id() === $order->get_payment_method( 'edit' ) ) {
 
 
1053
 
1054
+ $legacy_customer_id = $order->get_meta( '_wc_paypal_braintree_customer_id', true, 'edit' );
1055
 
1056
+ $order->update_meta_data( $this->get_order_meta_prefix() . $key, $legacy_customer_id );
1057
+ $order->delete_meta_data( '_wc_paypal_braintree_customer_id' );
1058
+ $order->save_meta_data();
1059
 
1060
  return $legacy_customer_id;
1061
  }
1592
  return $this->get_option( 'transaction_type' );
1593
  }
1594
 
1595
+ /**
1596
+ * Adds the standard transaction data to the order.
1597
+ * This function is added to set transaction ID to order using WooCommerce Order API.
1598
+ *
1599
+ * @since 2.9.0
1600
+ *
1601
+ * @param \WC_Order $order the order object.
1602
+ * @param SV_WC_Payment_Gateway_API_Response|null $response optional transaction response.
1603
+ */
1604
+ public function add_transaction_data( $order, $response = null ) {
1605
+ if ( $response && $response->get_transaction_id() ) {
1606
+ // Save transaction id if available.
1607
+ if ( is_numeric( $order ) ) {
1608
+ $order = wc_get_order( $order );
1609
+ }
1610
+
1611
+ if ( $order instanceof \WC_Order ) {
1612
+ $order->set_transaction_id( $response->get_transaction_id() );
1613
+ $order->save();
1614
+ }
1615
+ }
1616
+
1617
+ return parent::add_transaction_data( $order, $response );
1618
+ }
1619
 
1620
  }
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: ecommerce, e-commerce, commerce, woothemes, wordpress ecommerce, store, sa
4
  Requires at least: 5.6
5
  Tested up to: 6.0
6
  Requires PHP: 7.3
7
- Stable tag: 2.8.0
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -107,6 +107,11 @@ If not, please get in touch with us through the [plugin forums](https://wordpres
107
 
108
  == Changelog ==
109
 
 
 
 
 
 
110
  = 2.8.0 - 2022-10-12 =
111
  * Add - Support for 3DS2 / EMV 3DS cards.
112
  * Fix - Upgrade Braintree PHP SDK from v3.34.0 to v6.7.0.
4
  Requires at least: 5.6
5
  Tested up to: 6.0
6
  Requires PHP: 7.3
7
+ Stable tag: 2.9.0
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
107
 
108
  == Changelog ==
109
 
110
+ = 2.9.0 - 2022-11-01 =
111
+ * Add – Support for High-performance Order Storage (“HPOS”).
112
+ * Add – Declare compatibility with High-Performance Order Storage (“HPOS”).
113
+ * Fix – Display more detailed error messages on checkout.
114
+
115
  = 2.8.0 - 2022-10-12 =
116
  * Add - Support for 3DS2 / EMV 3DS cards.
117
  * Fix - Upgrade Braintree PHP SDK from v3.34.0 to v6.7.0.
vendor/autoload.php CHANGED
@@ -3,10 +3,23 @@
3
  // autoload.php @generated by Composer
4
 
5
  if (PHP_VERSION_ID < 50600) {
6
- echo 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
7
- exit(1);
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  }
9
 
10
  require_once __DIR__ . '/composer/autoload_real.php';
11
 
12
- return ComposerAutoloaderInit6493576a93c8a5819bd1c57c1ca2bae7::getLoader();
3
  // autoload.php @generated by Composer
4
 
5
  if (PHP_VERSION_ID < 50600) {
6
+ if (!headers_sent()) {
7
+ header('HTTP/1.1 500 Internal Server Error');
8
+ }
9
+ $err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
10
+ if (!ini_get('display_errors')) {
11
+ if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
12
+ fwrite(STDERR, $err);
13
+ } elseif (!headers_sent()) {
14
+ echo $err;
15
+ }
16
+ }
17
+ trigger_error(
18
+ $err,
19
+ E_USER_ERROR
20
+ );
21
  }
22
 
23
  require_once __DIR__ . '/composer/autoload_real.php';
24
 
25
+ return ComposerAutoloaderInit5914c3b5bd0c13acba721f0d1cf8a9f0::getLoader();
vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
- class ComposerAutoloaderInit6493576a93c8a5819bd1c57c1ca2bae7
6
  {
7
  private static $loader;
8
 
@@ -24,12 +24,12 @@ class ComposerAutoloaderInit6493576a93c8a5819bd1c57c1ca2bae7
24
 
25
  require __DIR__ . '/platform_check.php';
26
 
27
- spl_autoload_register(array('ComposerAutoloaderInit6493576a93c8a5819bd1c57c1ca2bae7', 'loadClassLoader'), true, true);
28
  self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
29
- spl_autoload_unregister(array('ComposerAutoloaderInit6493576a93c8a5819bd1c57c1ca2bae7', 'loadClassLoader'));
30
 
31
  require __DIR__ . '/autoload_static.php';
32
- call_user_func(\Composer\Autoload\ComposerStaticInit6493576a93c8a5819bd1c57c1ca2bae7::getInitializer($loader));
33
 
34
  $loader->register(true);
35
 
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
+ class ComposerAutoloaderInit5914c3b5bd0c13acba721f0d1cf8a9f0
6
  {
7
  private static $loader;
8
 
24
 
25
  require __DIR__ . '/platform_check.php';
26
 
27
+ spl_autoload_register(array('ComposerAutoloaderInit5914c3b5bd0c13acba721f0d1cf8a9f0', 'loadClassLoader'), true, true);
28
  self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
29
+ spl_autoload_unregister(array('ComposerAutoloaderInit5914c3b5bd0c13acba721f0d1cf8a9f0', 'loadClassLoader'));
30
 
31
  require __DIR__ . '/autoload_static.php';
32
+ call_user_func(\Composer\Autoload\ComposerStaticInit5914c3b5bd0c13acba721f0d1cf8a9f0::getInitializer($loader));
33
 
34
  $loader->register(true);
35
 
vendor/composer/autoload_static.php CHANGED
@@ -4,7 +4,7 @@
4
 
5
  namespace Composer\Autoload;
6
 
7
- class ComposerStaticInit6493576a93c8a5819bd1c57c1ca2bae7
8
  {
9
  public static $prefixLengthsPsr4 = array (
10
  'B' =>
@@ -27,9 +27,9 @@ class ComposerStaticInit6493576a93c8a5819bd1c57c1ca2bae7
27
  public static function getInitializer(ClassLoader $loader)
28
  {
29
  return \Closure::bind(function () use ($loader) {
30
- $loader->prefixLengthsPsr4 = ComposerStaticInit6493576a93c8a5819bd1c57c1ca2bae7::$prefixLengthsPsr4;
31
- $loader->prefixDirsPsr4 = ComposerStaticInit6493576a93c8a5819bd1c57c1ca2bae7::$prefixDirsPsr4;
32
- $loader->classMap = ComposerStaticInit6493576a93c8a5819bd1c57c1ca2bae7::$classMap;
33
 
34
  }, null, ClassLoader::class);
35
  }
4
 
5
  namespace Composer\Autoload;
6
 
7
+ class ComposerStaticInit5914c3b5bd0c13acba721f0d1cf8a9f0
8
  {
9
  public static $prefixLengthsPsr4 = array (
10
  'B' =>
27
  public static function getInitializer(ClassLoader $loader)
28
  {
29
  return \Closure::bind(function () use ($loader) {
30
+ $loader->prefixLengthsPsr4 = ComposerStaticInit5914c3b5bd0c13acba721f0d1cf8a9f0::$prefixLengthsPsr4;
31
+ $loader->prefixDirsPsr4 = ComposerStaticInit5914c3b5bd0c13acba721f0d1cf8a9f0::$prefixDirsPsr4;
32
+ $loader->classMap = ComposerStaticInit5914c3b5bd0c13acba721f0d1cf8a9f0::$classMap;
33
 
34
  }, null, ClassLoader::class);
35
  }
vendor/composer/installed.php CHANGED
@@ -3,7 +3,7 @@
3
  'name' => '__root__',
4
  'pretty_version' => 'dev-trunk',
5
  'version' => 'dev-trunk',
6
- 'reference' => '287fa0d3deb5b36708b38c313eec6beda488a20e',
7
  'type' => 'library',
8
  'install_path' => __DIR__ . '/../../',
9
  'aliases' => array(),
@@ -13,7 +13,7 @@
13
  '__root__' => array(
14
  'pretty_version' => 'dev-trunk',
15
  'version' => 'dev-trunk',
16
- 'reference' => '287fa0d3deb5b36708b38c313eec6beda488a20e',
17
  'type' => 'library',
18
  'install_path' => __DIR__ . '/../../',
19
  'aliases' => array(),
3
  'name' => '__root__',
4
  'pretty_version' => 'dev-trunk',
5
  'version' => 'dev-trunk',
6
+ 'reference' => '44a8cb02cd7961329018b789a13e9270e4c827ed',
7
  'type' => 'library',
8
  'install_path' => __DIR__ . '/../../',
9
  'aliases' => array(),
13
  '__root__' => array(
14
  'pretty_version' => 'dev-trunk',
15
  'version' => 'dev-trunk',
16
+ 'reference' => '44a8cb02cd7961329018b789a13e9270e4c827ed',
17
  'type' => 'library',
18
  'install_path' => __DIR__ . '/../../',
19
  'aliases' => array(),
woocommerce-gateway-paypal-powered-by-braintree.php CHANGED
@@ -6,7 +6,7 @@
6
  * Description: Receive credit card or PayPal payments using Braintree for WooCommerce. A server with cURL, SSL support, and a valid SSL certificate is required (for security reasons) for this gateway to function. Requires PHP 7.3+
7
  * Author: WooCommerce
8
  * Author URI: http://woocommerce.com/
9
- * Version: 2.8.0
10
  * Text Domain: woocommerce-gateway-paypal-powered-by-braintree
11
  * Domain Path: /i18n/languages/
12
  *
@@ -95,6 +95,8 @@ class WC_PayPal_Braintree_Loader {
95
  if ( $this->is_environment_compatible() ) {
96
  add_action( 'plugins_loaded', array( $this, 'init_plugin' ) );
97
  }
 
 
98
  }
99
 
100
 
@@ -471,7 +473,16 @@ class WC_PayPal_Braintree_Loader {
471
  return self::$instance;
472
  }
473
 
474
-
 
 
 
 
 
 
 
 
 
475
  }
476
 
477
  WC_PayPal_Braintree_Loader::instance();
6
  * Description: Receive credit card or PayPal payments using Braintree for WooCommerce. A server with cURL, SSL support, and a valid SSL certificate is required (for security reasons) for this gateway to function. Requires PHP 7.3+
7
  * Author: WooCommerce
8
  * Author URI: http://woocommerce.com/
9
+ * Version: 2.9.0
10
  * Text Domain: woocommerce-gateway-paypal-powered-by-braintree
11
  * Domain Path: /i18n/languages/
12
  *
95
  if ( $this->is_environment_compatible() ) {
96
  add_action( 'plugins_loaded', array( $this, 'init_plugin' ) );
97
  }
98
+ // Declare compatibility with High-Performance Order Storage.
99
+ add_action( 'before_woocommerce_init', array( $this, 'declare_hpos_compatibility' ) );
100
  }
101
 
102
 
473
  return self::$instance;
474
  }
475
 
476
+ /**
477
+ * Declare compatibility with High-Performance Order Storage.
478
+ *
479
+ * @since x.x.x
480
+ */
481
+ public function declare_hpos_compatibility() {
482
+ if ( class_exists( '\Automattic\WooCommerce\Utilities\FeaturesUtil' ) ) {
483
+ \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
484
+ }
485
+ }
486
  }
487
 
488
  WC_PayPal_Braintree_Loader::instance();