WooCommerce PayPal Powered by Braintree Payment Gateway - Version 2.2.7

Version Description

Download this release

Release Info

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

Code changes from version 2.2.6 to 2.2.7

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){var a=Object.getPrototypeOf(t);return null===a?void 0:e(a,n,r)}if("value"in i)return i.value;var o=i.get;return void 0!==o?o.call(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)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 o(e,t){if(!(e instanceof t))throw new Error("Bound instance method accessed before binding")}var s=[].indexOf;jQuery(document).ready(function(d){var e,r;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 a(e){_classCallCheck(this,a);var t=_possibleConstructorReturn(this,(a.__proto__||Object.getPrototypeOf(a)).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_authorize=t.on_authorize.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_credit_enabled=e.is_paypal_credit_enabled,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.init(),t}return window.WC_Braintree_Payment_Form_Handler=(_createClass(t,[{key:"init",value:function(){return this.is_sdk_ready()?d("form.checkout").length?this.handle_checkout_page():d("form#order_review").length?this.handle_pay_page():d("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=d("form.checkout"),this.form_ui_selector=".woocommerce-checkout-payment",d(document.body).on("updated_checkout",function(){if(!e.setting_up)return e.setup_braintree()}),d(document.body).on("updated_checkout",function(){return e.handle_saved_payment_methods()}),d(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=d("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=d("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 d("input[name=wc_"+this.id+"_payment_nonce]").val(e),this.form.submit()}},{key:"handle_saved_payment_methods",value:function(){var e,n=this;if(e=d("div.js-wc-"+this.id_dasherized+"-new-payment-method-form"),d("input.js-wc-"+this.id_dasherized+"-payment-token").change(function(){return d("input.js-wc-"+n.id_dasherized+"-payment-token:checked").val()?e.slideUp(200):e.slideDown(200)}).change(),d("input#createaccount").change(function(e){var t;return t=d("input.js-wc-"+n.id_dasherized+"-tokenize-payment-method").closest("p.form-row"),d(e.target).is(":checked")?(t.slideDown(),t.next().show()):(t.hide(),t.next().hide())}),!d("input#createaccount").is(":checked"))return d("input#createaccount").change()}},{key:"setup_braintree",value:function(){return this.setting_up=!0,this.block_ui(),d("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})}).always(function(){return r.unblock_ui()})}},{key:"get_client_token",value:function(){var e;return this.id,e={action:"wc_"+this.id+"_get_client_token",nonce:this.client_token_nonce},d.post(this.ajax_url,e)}},{key:"setup_integration",value:function(){var t=this;return this.log("Creating integration."),this.get_integration_class().create(this.get_integration_options()).then(function(e){return t.integration=e,t.show_integration_ui(),t.do_integration_ready(),d(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)return this.block_ui(),this.integration.teardown(function(){return e.integration=null,e.unblock_ui()})}},{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 d(".woocommerce-error, .woocommerce-message").remove(),this.form.prepend('<div class="woocommerce-error">'+e+"</div>").removeClass("processing").unblock(),d("html, body").animate({scrollTop:this.form.offset().top-100},1e3),d("input[name=wc_"+this.id+"_payment_nonce]").val(""),this.form.trigger("wc_"+this.id+"_rendered_error"),d(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(d("div.js-wc-"+this.id_dasherized+"-new-payment-method-form").find(".woocommerce-error").remove(),d("input#createaccount").length&&d("input#createaccount").is(":checked"))return d("div.js-wc-"+this.id_dasherized+"-new-payment-method-form").find(".form-row").show()}},{key:"hide_integration_ui",value:function(){return d("div.js-wc-"+this.id_dasherized+"-new-payment-method-form").prepend('<div class="woocommerce-error">'+this.integration_error_message+"</div>"),d("div.js-wc-"+this.id_dasherized+"-new-payment-method-form").find(".form-row").hide()}},{key:"block_ui",value:function(){return d(this.form_ui_selector).block({message:null,overlayCSS:{background:"#fff",opacity:.6}})}},{key:"unblock_ui",value:function(){return d(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,t,n){var r=1<arguments.length&&void 0!==t?t:null;if(this.debug)return console.log(this.name+": "+e),r?console.log(r):void 0}}]),t),e=window.WC_Braintree_Credit_Card_Payment_Form_Handler=(_inherits(a,WC_Braintree_Payment_Form_Handler),_createClass(a,[{key:"handle_checkout_error",value:function(){return _get(a.prototype.__proto__||Object.getPrototypeOf(a.prototype),"handle_checkout_error",this).call(this),d("input[name=wc_"+this.id+"_payment_nonce]").val(""),d("input[name=wc-"+this.id_dasherized+"-card-type]").val(""),d("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=d("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(a.prototype.__proto__||Object.getPrototypeOf(a.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;return e={client:this.client,fields:{number:{selector:"#wc-braintree-credit-card-account-number-hosted",placeholder:d("#wc-braintree-credit-card-account-number-hosted").data("placeholder")},cvv:{selector:"#wc-braintree-credit-card-csc-hosted",placeholder:d("#wc-braintree-credit-card-csc-hosted").data("placeholder")},expirationDate:{selector:"#wc-braintree-credit-card-expiry-hosted",placeholder:d("#wc-braintree-credit-card-expiry-hosted").data("placeholder")}},styles:this.hosted_fields_styles},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&&d("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(a.prototype.__proto__||Object.getPrototypeOf(a.prototype),"handle_saved_payment_methods",this).call(this),t=d("div.js-wc-braintree-credit-card-new-payment-method-form"),e=d("div.wc-braintree-hosted-field-card-csc-parent"),d("input.js-wc-braintree-credit-card-payment-token").change(function(){return d("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;if(r=[],"CUSTOMER"===e.type)switch(e.code){case"HOSTED_FIELDS_FIELDS_EMPTY":this.csc_required&&r.push(this.params.cvv_missing),this.using_payment_token()||(r.push(this.params.card_number_missing),r.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":r.push(this.params.card_number_invalid);break;case"cvv":r.push(this.params.cvv_length_invalid);break;case"expirationDate":r.push(this.params.card_exp_date_invalid)}}return r.length?r.join("<br/>"):_get(a.prototype.__proto__||Object.getPrototypeOf(a.prototype),"get_user_message",this).call(this)}},{key:"on_card_type_change",value:function(e){var t,n,r;if(null!=e.cards)return(t=d("#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?(n=e.cards[0],d("input[name=wc-"+this.id_dasherized+"-card-type]").val(n.type),null!=n.type&&(r=n.type,0<=s.call(this.enabled_card_types,r))?t.addClass("card-type-"+n.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()?(d("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,d(document.body).on("click","#wc-braintree-credit-card-3dsecure-container",function(e){return d(e.currentTarget).fadeOut(200),t.threeDSecure.cancelVerifyCard(),t.unblock_ui()}),_get(a.prototype.__proto__||Object.getPrototypeOf(a.prototype),"setup_integration",t).call(t)}).catch(function(e){return t.handle_integration_error(e)})):_get(a.prototype.__proto__||Object.getPrototypeOf(a.prototype),"setup_integration",this).call(this)}},{key:"should_verify_3d_secure",value:function(e){var t;return t=e.details.cardType,this.is_3d_secure_enabled()&&"CreditCard"===e.type&&0<=s.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,n){var r,i,a,o,s,_,c,u=this,l=2<arguments.length&&void 0!==n?n:null;return o=d("#billing_state").val(),a=d("#billing_country").val(),_=d("#shipping_state").val(),s=d("#shipping_country").val(),i={givenName:d("input[name=billing_first_name]").val().latinise(),surname:d("input[name=billing_last_name]").val().latinise(),phoneNumber:d("input[name=billing_phone]").val(),streetAddress:d("input[name=billing_address_1]").val(),extendedAddress:d("input[name=billing_address_2]").val(),locality:d("#billing_city").val(),region:"string"==typeof o&&o.length<=2?o:"",postalCode:d("input[name=billing_postcode]").val(),countryCodeAlpha2:"string"==typeof a&&a.length<=2?a:""},r=d("input[name=shipping_first_name]").val()?{shippingGivenName:d("input[name=shipping_first_name]").val().latinise(),shippingSurname:d("input[name=shipping_last_name]").val().latinise(),shippingAddress:{streetAddress:d("input[name=shipping_address_1]").val(),extendedAddress:d("input[name=shipping_address_2]").val(),locality:d("input[name=shipping_city]").val(),region:"string"==typeof _&&_.length<=2?_:"",postalCode:d("input[name=shipping_postcode]").val(),countryCodeAlpha2:"string"==typeof s&&s.length<=2?s:""}}:{},c={nonce:e,amount:d("input[name=wc-"+this.id_dasherized+"-3d-secure-order-total]").val(),email:d("input[name=billing_email]").val(),billingAddress:i,additionalInformation:r,onLookupComplete:function(e,t){return u.log("3D Secure lookup complete.",e),t()}},"1"===d("input[name=wc-"+this.id_dasherized+"-cart-contains-subscription]").val()&&(c.challengeRequested=!0),this.log("Verifying 3D Secure.",c),this.threeDSecure.verifyCard(c).then(function(e){return u.log("3D Secure response received.",e),u.threeds.liability_shift_always_required&&!e.liabilityShifted?u.render_error(u.threeds.failure_message):(null!=l&&l.data("verified",!0),d("input[name=wc-"+u.id_dasherized+"-3d-secure-verified]").val(1),u.submit_form(e.nonce))}).catch(function(e){return u.handle_payment_error(e)})}},{key:"show_integration_ui",value:function(){return o(this,e),_get(a.prototype.__proto__||Object.getPrototypeOf(a.prototype),"show_integration_ui",this).call(this),d(".wc-braintree-hosted-field-parent").show()}},{key:"hide_integration_ui",value:function(){return o(this,e),_get(a.prototype.__proto__||Object.getPrototypeOf(a.prototype),"hide_integration_ui",this).call(this),d(".wc-braintree-hosted-field-parent").hide()}}]),a),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),d("input[name=wc_"+this.id+"_payment_nonce]").val(this.cart_payment_nonce),d(document.body).on("click",'input[name="payment_method"], input.js-wc-braintree-paypal-payment-token',function(){return t.toggle_order_button()}),d(document.body).on("payment_method_selected",function(){return t.toggle_order_button()}),d(document.body).on("click",".wc-braintree-paypal-account .cancel",function(e){return e.preventDefault(),d(e.currentTarget).parent().remove(),t.setup_braintree()})}},{key:"toggle_order_button",value:function(){return!this.is_selected()||this.has_payment_nonce()||this.using_payment_token()?d("#place_order").show():d("#place_order").hide()}},{key:"verify_form",value:function(){var e;return e=_get(n.prototype.__proto__||Object.getPrototypeOf(n.prototype),"verify_form",this).call(this),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),d("input.js-wc-braintree-paypal-tokenize-payment-method").prop("disabled",!1),this.toggle_order_button())}},{key:"do_integration_ready",value:function(){var e,t=this;return o(this,r),this.cart_payment_nonce?this.unblock_ui():(e=this.is_single_use()?"checkout":"vault",this.render_button(this.integration.createPayment({flow:e,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 d("#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_button",value:function(e,t,n){var r,i,a=this;return d(n).html(""),r=this.is_paypal_credit_enabled&&"USD"===this.get_store_currency()?{allowed:[paypal.FUNDING.CREDIT]}:{disallowed:[paypal.FUNDING.CREDIT]},i={env:this.is_test_environment?"sandbox":"production",commit:this.button_is_pay_now(),style:t,funding:r,payment:function(){return e},onAuthorize:function(e,t){return a.on_authorize(e,t)},onError:function(e){return a.handle_integration_error(e)}},paypal.Button.render(i,n)}},{key:"button_is_pay_now",value:function(){return!d("form#add_payment_method").length}},{key:"get_button_styles",value:function(){return this.button_styles}},{key:"on_authorize",value:function(e,t){var n=this;return o(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 d("input[name=wc_"+this.id+"_payment_nonce]").val(e.nonce),d("#wc_braintree_paypal_container").html(this.get_linked_account_html(e.details)),this.is_single_use()&&d("input.js-wc-braintree-paypal-tokenize-payment-method").prop("disabled",!0),d("#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),d("input.js-wc-braintree-paypal-tokenize-payment-method").change(function(e){if(null!=t.integration&&d(e.target).is(":visible"))return t.block_ui(),t.do_integration_ready()}).change()}},{key:"get_linked_account_html",value:function(e){var t;return o(this,r),t=d("<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;return 0===(e=d("input[name=wc-braintree-paypal-tokenize-payment-method]")).length||("checkbox"===e.attr("type")?!e.is(":checked"):!e.val())}},{key:"get_order_amount",value:function(){return d("input[name=wc_braintree_paypal_amount]").val()}},{key:"get_store_currency",value:function(){return d("input[name=wc_braintree_paypal_currency]").val()}},{key:"get_store_locale",value:function(){return d("input[name=wc_braintree_paypal_locale]").val()}},{key:"is_sdk_ready",value:function(){return _get(n.prototype.__proto__||Object.getPrototypeOf(n.prototype),"is_sdk_ready",this).call(this)&&"undefined"!=typeof paypal&&null!==paypal}}]),n),window.WC_Braintree_PayPal_Cart_Handler=(_inherits(i,WC_Braintree_PayPal_Payment_Form_Handler),_createClass(i,[{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,d.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"===d("input[name=wc_braintree_paypal_single_use]").val()}},{key:"has_payment_nonce",value:function(){return!1}}]),i);function i(e){_classCallCheck(this,i);var t=_possibleConstructorReturn(this,(i.__proto__||Object.getPrototypeOf(i)).call(this,e));return t.set_payment_method_nonce=e.set_payment_method_nonce,t.cart_handler_url=e.cart_handler_url,t.form=d("form.woocommerce-cart-form"),t.form_ui_selector="",t.setup_braintree(),d(document.body).on("updated_cart_totals",function(){return t.setup_braintree()}),t}})}).call(void 0);
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){var a=Object.getPrototypeOf(t);return null===a?void 0:e(a,n,r)}if("value"in i)return i.value;var o=i.get;return void 0!==o?o.call(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)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 o(e,t){if(!(e instanceof t))throw new Error("Bound instance method accessed before binding")}var s=[].indexOf;jQuery(document).ready(function(d){var e,r;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 a(e){_classCallCheck(this,a);var t=_possibleConstructorReturn(this,(a.__proto__||Object.getPrototypeOf(a)).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_authorize=t.on_authorize.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_credit_enabled=e.is_paypal_credit_enabled,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.init(),t}return window.WC_Braintree_Payment_Form_Handler=(_createClass(t,[{key:"init",value:function(){return this.is_sdk_ready()?d("form.checkout").length?this.handle_checkout_page():d("form#order_review").length?this.handle_pay_page():d("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=d("form.checkout"),this.form_ui_selector=".woocommerce-checkout-payment",d(document.body).on("updated_checkout",function(){if(!e.setting_up)return e.setup_braintree()}),d(document.body).on("updated_checkout",function(){return e.handle_saved_payment_methods()}),d(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=d("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=d("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 d("input[name=wc_"+this.id+"_payment_nonce]").val(e),this.form.submit()}},{key:"handle_saved_payment_methods",value:function(){var e,n=this;if(e=d("div.js-wc-"+this.id_dasherized+"-new-payment-method-form"),d("input.js-wc-"+this.id_dasherized+"-payment-token").change(function(){return d("input.js-wc-"+n.id_dasherized+"-payment-token:checked").val()?e.slideUp(200):e.slideDown(200)}).change(),d("input#createaccount").change(function(e){var t;return t=d("input.js-wc-"+n.id_dasherized+"-tokenize-payment-method").closest("p.form-row"),d(e.target).is(":checked")?(t.slideDown(),t.next().show()):(t.hide(),t.next().hide())}),!d("input#createaccount").is(":checked"))return d("input#createaccount").change()}},{key:"setup_braintree",value:function(){return this.setting_up=!0,this.block_ui(),d("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})}).always(function(){return r.unblock_ui()})}},{key:"get_client_token",value:function(){var e;return this.id,e={action:"wc_"+this.id+"_get_client_token",nonce:this.client_token_nonce},d.post(this.ajax_url,e)}},{key:"setup_integration",value:function(){var t=this;return this.log("Creating integration."),this.get_integration_class().create(this.get_integration_options()).then(function(e){return t.integration=e,t.show_integration_ui(),t.do_integration_ready(),d(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)return this.block_ui(),this.integration.teardown(function(){return e.integration=null,e.unblock_ui()})}},{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 d(".woocommerce-error, .woocommerce-message").remove(),this.form.prepend('<div class="woocommerce-error">'+e+"</div>").removeClass("processing").unblock(),d("html, body").animate({scrollTop:this.form.offset().top-100},1e3),d("input[name=wc_"+this.id+"_payment_nonce]").val(""),this.form.trigger("wc_"+this.id+"_rendered_error"),d(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(d("div.js-wc-"+this.id_dasherized+"-new-payment-method-form").find(".woocommerce-error").remove(),d("input#createaccount").length&&d("input#createaccount").is(":checked"))return d("div.js-wc-"+this.id_dasherized+"-new-payment-method-form").find(".form-row").show()}},{key:"hide_integration_ui",value:function(){return d("div.js-wc-"+this.id_dasherized+"-new-payment-method-form").prepend('<div class="woocommerce-error">'+this.integration_error_message+"</div>"),d("div.js-wc-"+this.id_dasherized+"-new-payment-method-form").find(".form-row").hide()}},{key:"block_ui",value:function(){return d(this.form_ui_selector).block({message:null,overlayCSS:{background:"#fff",opacity:.6}})}},{key:"unblock_ui",value:function(){return d(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,t,n){var r=1<arguments.length&&void 0!==t?t:null;if(this.debug)return console.log(this.name+": "+e),r?console.log(r):void 0}}]),t),e=window.WC_Braintree_Credit_Card_Payment_Form_Handler=(_inherits(a,WC_Braintree_Payment_Form_Handler),_createClass(a,[{key:"handle_checkout_error",value:function(){return _get(a.prototype.__proto__||Object.getPrototypeOf(a.prototype),"handle_checkout_error",this).call(this),d("input[name=wc_"+this.id+"_payment_nonce]").val(""),d("input[name=wc-"+this.id_dasherized+"-card-type]").val(""),d("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=d("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(a.prototype.__proto__||Object.getPrototypeOf(a.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;return e={client:this.client,fields:{number:{selector:"#wc-braintree-credit-card-account-number-hosted",placeholder:d("#wc-braintree-credit-card-account-number-hosted").data("placeholder")},cvv:{selector:"#wc-braintree-credit-card-csc-hosted",placeholder:d("#wc-braintree-credit-card-csc-hosted").data("placeholder")},expirationDate:{selector:"#wc-braintree-credit-card-expiry-hosted",placeholder:d("#wc-braintree-credit-card-expiry-hosted").data("placeholder")}},styles:this.hosted_fields_styles},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&&d("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(a.prototype.__proto__||Object.getPrototypeOf(a.prototype),"handle_saved_payment_methods",this).call(this),t=d("div.js-wc-braintree-credit-card-new-payment-method-form"),e=d("div.wc-braintree-hosted-field-card-csc-parent"),d("input.js-wc-braintree-credit-card-payment-token").change(function(){return d("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;if(r=[],"CUSTOMER"===e.type)switch(e.code){case"HOSTED_FIELDS_FIELDS_EMPTY":this.csc_required&&r.push(this.params.cvv_missing),this.using_payment_token()||(r.push(this.params.card_number_missing),r.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":r.push(this.params.card_number_invalid);break;case"cvv":r.push(this.params.cvv_length_invalid);break;case"expirationDate":r.push(this.params.card_exp_date_invalid)}}return r.length?r.join("<br/>"):_get(a.prototype.__proto__||Object.getPrototypeOf(a.prototype),"get_user_message",this).call(this)}},{key:"on_card_type_change",value:function(e){var t,n,r;if(null!=e.cards)return(t=d("#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?(n=e.cards[0],d("input[name=wc-"+this.id_dasherized+"-card-type]").val(n.type),null!=n.type&&(r=n.type,0<=s.call(this.enabled_card_types,r))?t.addClass("card-type-"+n.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()?(d("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,d(document.body).on("click","#wc-braintree-credit-card-3dsecure-container",function(e){return d(e.currentTarget).fadeOut(200),t.threeDSecure.cancelVerifyCard(),t.unblock_ui()}),_get(a.prototype.__proto__||Object.getPrototypeOf(a.prototype),"setup_integration",t).call(t)}).catch(function(e){return t.handle_integration_error(e)})):_get(a.prototype.__proto__||Object.getPrototypeOf(a.prototype),"setup_integration",this).call(this)}},{key:"should_verify_3d_secure",value:function(e){var t;return t=e.details.cardType,this.is_3d_secure_enabled()&&"CreditCard"===e.type&&0<=s.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,n){var r,i,a,o,s,_,c,u=this,l=2<arguments.length&&void 0!==n?n:null;return o=d("#billing_state").val(),a=d("#billing_country").val(),_=d("#shipping_state").val(),s=d("#shipping_country").val(),i=d("input[name=billing_first_name]").val()?{givenName:d("input[name=billing_first_name]").val().latinise(),surname:d("input[name=billing_last_name]").val().latinise(),phoneNumber:d("input[name=billing_phone]").val(),streetAddress:d("input[name=billing_address_1]").val(),extendedAddress:d("input[name=billing_address_2]").val(),locality:d("#billing_city").val(),region:"string"==typeof o&&o.length<=2?o:"",postalCode:d("input[name=billing_postcode]").val(),countryCodeAlpha2:"string"==typeof a&&a.length<=2?a:""}:{},r=d("input[name=shipping_first_name]").val()?{shippingGivenName:d("input[name=shipping_first_name]").val().latinise(),shippingSurname:d("input[name=shipping_last_name]").val().latinise(),shippingAddress:{streetAddress:d("input[name=shipping_address_1]").val(),extendedAddress:d("input[name=shipping_address_2]").val(),locality:d("input[name=shipping_city]").val(),region:"string"==typeof _&&_.length<=2?_:"",postalCode:d("input[name=shipping_postcode]").val(),countryCodeAlpha2:"string"==typeof s&&s.length<=2?s:""}}:{},c={nonce:e,amount:d("input[name=wc-"+this.id_dasherized+"-3d-secure-order-total]").val(),email:d("input[name=billing_email]").val(),billingAddress:i,additionalInformation:r,onLookupComplete:function(e,t){return u.log("3D Secure lookup complete.",e),t()}},"1"===d("input[name=wc-"+this.id_dasherized+"-cart-contains-subscription]").val()&&(c.challengeRequested=!0),this.log("Verifying 3D Secure.",c),this.threeDSecure.verifyCard(c).then(function(e){return u.log("3D Secure response received.",e),u.threeds.liability_shift_always_required&&!e.liabilityShifted?u.render_error(u.threeds.failure_message):(null!=l&&l.data("verified",!0),d("input[name=wc-"+u.id_dasherized+"-3d-secure-verified]").val(1),u.submit_form(e.nonce))}).catch(function(e){return u.handle_payment_error(e)})}},{key:"show_integration_ui",value:function(){return o(this,e),_get(a.prototype.__proto__||Object.getPrototypeOf(a.prototype),"show_integration_ui",this).call(this),d(".wc-braintree-hosted-field-parent").show()}},{key:"hide_integration_ui",value:function(){return o(this,e),_get(a.prototype.__proto__||Object.getPrototypeOf(a.prototype),"hide_integration_ui",this).call(this),d(".wc-braintree-hosted-field-parent").hide()}}]),a),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),d("input[name=wc_"+this.id+"_payment_nonce]").val(this.cart_payment_nonce),d(document.body).on("click",'input[name="payment_method"], input.js-wc-braintree-paypal-payment-token',function(){return t.toggle_order_button()}),d(document.body).on("payment_method_selected",function(){return t.toggle_order_button()}),d(document.body).on("click",".wc-braintree-paypal-account .cancel",function(e){return e.preventDefault(),d(e.currentTarget).parent().remove(),t.setup_braintree()})}},{key:"toggle_order_button",value:function(){return!this.is_selected()||this.has_payment_nonce()||this.using_payment_token()?d("#place_order").show():d("#place_order").hide()}},{key:"verify_form",value:function(){var e;return e=_get(n.prototype.__proto__||Object.getPrototypeOf(n.prototype),"verify_form",this).call(this),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),d("input.js-wc-braintree-paypal-tokenize-payment-method").prop("disabled",!1),this.toggle_order_button())}},{key:"do_integration_ready",value:function(){var e,t=this;return o(this,r),this.cart_payment_nonce?this.unblock_ui():(e=this.is_single_use()?"checkout":"vault",this.render_button(this.integration.createPayment({flow:e,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 d("#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_button",value:function(e,t,n){var r,i,a=this;return d(n).html(""),r=this.is_paypal_credit_enabled&&"USD"===this.get_store_currency()?{allowed:[paypal.FUNDING.CREDIT]}:{disallowed:[paypal.FUNDING.CREDIT]},i={env:this.is_test_environment?"sandbox":"production",commit:this.button_is_pay_now(),style:t,funding:r,payment:function(){return e},onAuthorize:function(e,t){return a.on_authorize(e,t)},onError:function(e){return a.handle_integration_error(e)}},paypal.Button.render(i,n)}},{key:"button_is_pay_now",value:function(){return!d("form#add_payment_method").length}},{key:"get_button_styles",value:function(){return this.button_styles}},{key:"on_authorize",value:function(e,t){var n=this;return o(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 d("input[name=wc_"+this.id+"_payment_nonce]").val(e.nonce),d("#wc_braintree_paypal_container").html(this.get_linked_account_html(e.details)),this.is_single_use()&&d("input.js-wc-braintree-paypal-tokenize-payment-method").prop("disabled",!0),d("#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),d("input.js-wc-braintree-paypal-tokenize-payment-method").change(function(e){if(null!=t.integration&&d(e.target).is(":visible"))return t.block_ui(),t.do_integration_ready()}).change()}},{key:"get_linked_account_html",value:function(e){var t;return o(this,r),t=d("<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;return 0===(e=d("input[name=wc-braintree-paypal-tokenize-payment-method]")).length||("checkbox"===e.attr("type")?!e.is(":checked"):!e.val())}},{key:"get_order_amount",value:function(){return d("input[name=wc_braintree_paypal_amount]").val()}},{key:"get_store_currency",value:function(){return d("input[name=wc_braintree_paypal_currency]").val()}},{key:"get_store_locale",value:function(){return d("input[name=wc_braintree_paypal_locale]").val()}},{key:"is_sdk_ready",value:function(){return _get(n.prototype.__proto__||Object.getPrototypeOf(n.prototype),"is_sdk_ready",this).call(this)&&"undefined"!=typeof paypal&&null!==paypal}}]),n),window.WC_Braintree_PayPal_Cart_Handler=(_inherits(i,WC_Braintree_PayPal_Payment_Form_Handler),_createClass(i,[{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,d.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"===d("input[name=wc_braintree_paypal_single_use]").val()}},{key:"has_payment_nonce",value:function(){return!1}}]),i);function i(e){_classCallCheck(this,i);var t=_possibleConstructorReturn(this,(i.__proto__||Object.getPrototypeOf(i)).call(this,e));return t.set_payment_method_nonce=e.set_payment_method_nonce,t.cart_handler_url=e.cart_handler_url,t.form=d("form.woocommerce-cart-form"),t.form_ui_selector="",t.setup_braintree(),d(document.body).on("updated_cart_totals",function(){return t.setup_braintree()}),t}})}).call(void 0);
class-wc-braintree.php CHANGED
@@ -88,7 +88,7 @@ class WC_Braintree extends WC_Braintree_Framework\SV_WC_Payment_Gateway_Plugin {
88
 
89
 
90
  /** plugin version number */
91
- const VERSION = '2.2.6';
92
 
93
  /** Braintree JS SDK version */
94
  const BRAINTREE_JS_SDK_VERSION = '3.48.0';
88
 
89
 
90
  /** plugin version number */
91
+ const VERSION = '2.2.7';
92
 
93
  /** Braintree JS SDK version */
94
  const BRAINTREE_JS_SDK_VERSION = '3.48.0';
i18n/languages/woocommerce-gateway-paypal-powered-by-braintree.pot CHANGED
@@ -2,10 +2,10 @@
2
  # This file is distributed under the same license as the WooCommerce PayPal Powered by Braintree Gateway package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: WooCommerce PayPal Powered by Braintree Gateway 2.2.6\n"
6
  "Report-Msgid-Bugs-To: "
7
  "https://woocommerce.com/my-account/marketplace-ticket-form/\n"
8
- "POT-Creation-Date: 2019-08-07 20:38:10+00:00\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=utf-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
2
  # This file is distributed under the same license as the WooCommerce PayPal Powered by Braintree Gateway package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: WooCommerce PayPal Powered by Braintree Gateway 2.2.7\n"
6
  "Report-Msgid-Bugs-To: "
7
  "https://woocommerce.com/my-account/marketplace-ticket-form/\n"
8
+ "POT-Creation-Date: 2019-09-12 16:05:02+00:00\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=utf-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
includes/payment-forms/class-wc-braintree-hosted-fields-payment-form.php CHANGED
@@ -228,6 +228,40 @@ class WC_Braintree_Hosted_Fields_Payment_Form extends WC_Braintree_Payment_Form
228
  echo '<input type="hidden" name="wc-' . $this->get_gateway()->get_id_dasherized() . '-cart-contains-subscription" value="1" />';
229
  }
230
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
231
  parent::render_payment_fields();
232
  }
233
 
228
  echo '<input type="hidden" name="wc-' . $this->get_gateway()->get_id_dasherized() . '-cart-contains-subscription" value="1" />';
229
  }
230
 
231
+ // add hidden inputs for billing information on the order pay page (so we can send it for 3D Secure)
232
+ if ( is_checkout_pay_page() && $order_id = $this->get_gateway()->get_checkout_pay_page_order_id() ) {
233
+
234
+ $order = wc_get_order( $order_id );
235
+
236
+ if ( $order ) {
237
+
238
+ echo '<input type="hidden" name="billing_first_name" value="' . esc_attr( WC_Braintree_Framework\SV_WC_Order_Compatibility::get_prop( $order, 'billing_first_name' ) ) . '" />';
239
+ echo '<input type="hidden" name="billing_last_name" value="' . esc_attr( WC_Braintree_Framework\SV_WC_Order_Compatibility::get_prop( $order, 'billing_last_name' ) ) . '" />';
240
+ echo '<input type="hidden" name="billing_phone" value="' . esc_attr( WC_Braintree_Framework\SV_WC_Order_Compatibility::get_prop( $order, 'billing_phone' ) ) . '" />';
241
+ echo '<input type="hidden" name="billing_address_1" value="' . esc_attr( WC_Braintree_Framework\SV_WC_Order_Compatibility::get_prop( $order, 'billing_address_1' ) ) . '" />';
242
+ echo '<input type="hidden" name="billing_address_2" value="' . esc_attr( WC_Braintree_Framework\SV_WC_Order_Compatibility::get_prop( $order, 'billing_address_2' ) ) . '" />';
243
+ echo '<input type="hidden" name="billing_postcode" value="' . esc_attr( WC_Braintree_Framework\SV_WC_Order_Compatibility::get_prop( $order, 'billing_postcode' ) ) . '" />';
244
+ echo '<input type="hidden" name="billing_email" value="' . esc_attr( WC_Braintree_Framework\SV_WC_Order_Compatibility::get_prop( $order, 'billing_email' ) ) . '" />';
245
+
246
+ echo '<input type="hidden" id="billing_city" value="' . esc_attr( WC_Braintree_Framework\SV_WC_Order_Compatibility::get_prop( $order, 'billing_city' ) ) . '" />';
247
+ echo '<input type="hidden" id="billing_state" value="' . esc_attr( WC_Braintree_Framework\SV_WC_Order_Compatibility::get_prop( $order, 'billing_state' ) ) . '" />';
248
+ echo '<input type="hidden" id="billing_country" value="' . esc_attr( WC_Braintree_Framework\SV_WC_Order_Compatibility::get_prop( $order, 'billing_country' ) ) . '" />';
249
+
250
+ if ( WC_Braintree_Framework\SV_WC_Order_Compatibility::has_shipping_address( $order ) ) {
251
+
252
+ echo '<input type="hidden" name="shipping_first_name" value="' . esc_attr( WC_Braintree_Framework\SV_WC_Order_Compatibility::get_prop( $order, 'shipping_first_name' ) ) . '" />';
253
+ echo '<input type="hidden" name="shipping_last_name" value="' . esc_attr( WC_Braintree_Framework\SV_WC_Order_Compatibility::get_prop( $order, 'shipping_last_name' ) ) . '" />';
254
+ echo '<input type="hidden" name="shipping_address_1" value="' . esc_attr( WC_Braintree_Framework\SV_WC_Order_Compatibility::get_prop( $order, 'shipping_address_1' ) ) . '" />';
255
+ echo '<input type="hidden" name="shipping_address_2" value="' . esc_attr( WC_Braintree_Framework\SV_WC_Order_Compatibility::get_prop( $order, 'shipping_address_2' ) ) . '" />';
256
+ echo '<input type="hidden" name="shipping_city" value="' . esc_attr( WC_Braintree_Framework\SV_WC_Order_Compatibility::get_prop( $order, 'shipping_city' ) ) . '" />';
257
+ echo '<input type="hidden" name="shipping_postcode" value="' . esc_attr( WC_Braintree_Framework\SV_WC_Order_Compatibility::get_prop( $order, 'shipping_postcode' ) ) . '" />';
258
+
259
+ echo '<input type="hidden" id="shipping_state" value="' . esc_attr( WC_Braintree_Framework\SV_WC_Order_Compatibility::get_prop( $order, 'shipping_state' ) ) . '" />';
260
+ echo '<input type="hidden" id="shipping_country" value="' . esc_attr( WC_Braintree_Framework\SV_WC_Order_Compatibility::get_prop( $order, 'shipping_country' ) ) . '" />';
261
+ }
262
+ }
263
+ }
264
+
265
  parent::render_payment_fields();
266
  }
267
 
readme.txt CHANGED
@@ -2,9 +2,9 @@
2
  Contributors: automattic, akeda, allendav, royho, slash1andy, woosteve, spraveenitpro, mikedmoore, fernashes, shellbeezy, danieldudzic, dsmithweb, fullysupportedphil, corsonr, zandyring, skyverge
3
  Tags: ecommerce, e-commerce, commerce, woothemes, wordpress ecommerce, store, sales, sell, shop, shopping, cart, checkout, configurable, paypal, braintree
4
  Requires at least: 4.4
5
- Tested up to: 5.2.2
6
  Requires PHP: 5.4
7
- Stable tag: 2.2.6
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -124,6 +124,9 @@ New feature requests and bugs reports can be made in the plugin forum.
124
 
125
  == Changelog ==
126
 
 
 
 
127
  = 2019.08.07 - version 2.2.6 =
128
  * Tweak - Add support for 3D Secure 2.0
129
  * Misc - Add support for WooCommerce 3.7
2
  Contributors: automattic, akeda, allendav, royho, slash1andy, woosteve, spraveenitpro, mikedmoore, fernashes, shellbeezy, danieldudzic, dsmithweb, fullysupportedphil, corsonr, zandyring, skyverge
3
  Tags: ecommerce, e-commerce, commerce, woothemes, wordpress ecommerce, store, sales, sell, shop, shopping, cart, checkout, configurable, paypal, braintree
4
  Requires at least: 4.4
5
+ Tested up to: 5.2.3
6
  Requires PHP: 5.4
7
+ Stable tag: 2.2.7
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
124
 
125
  == Changelog ==
126
 
127
+ = 2019.09.12 - version 2.2.7 =
128
+ * Fix - Fix JavaScript error blocking payments with 3D Secure from the Pay Order page
129
+
130
  = 2019.08.07 - version 2.2.6 =
131
  * Tweak - Add support for 3D Secure 2.0
132
  * Misc - Add support for WooCommerce 3.7
woocommerce-gateway-paypal-powered-by-braintree.php CHANGED
@@ -5,7 +5,7 @@
5
  * Description: Receive credit card or PayPal payments using Paypal Powered by Braintree. A server with cURL, SSL support, and a valid SSL certificate is required (for security reasons) for this gateway to function. Requires PHP 5.4+
6
  * Author: WooCommerce
7
  * Author URI: http://woocommerce.com/
8
- * Version: 2.2.6
9
  * Text Domain: woocommerce-gateway-paypal-powered-by-braintree
10
  * Domain Path: /i18n/languages/
11
  *
5
  * Description: Receive credit card or PayPal payments using Paypal Powered by Braintree. A server with cURL, SSL support, and a valid SSL certificate is required (for security reasons) for this gateway to function. Requires PHP 5.4+
6
  * Author: WooCommerce
7
  * Author URI: http://woocommerce.com/
8
+ * Version: 2.2.7
9
  * Text Domain: woocommerce-gateway-paypal-powered-by-braintree
10
  * Domain Path: /i18n/languages/
11
  *