WooCommerce PayPal Powered by Braintree Payment Gateway - Version 2.1.1

Version Description

  • Fix - Fix the payment form JavaScript compatibility with IE 11
Download this release

Release Info

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

Code changes from version 2.1.0 to 2.1.1

assets/js/frontend/wc-braintree.min.js CHANGED
@@ -1 +1 @@
1
- (function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b=function(a,b){function d(){this.constructor=a}for(var e in b)c.call(b,e)&&(a[e]=b[e]);return d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype,a},c={}.hasOwnProperty,d=[].indexOf||function(a){for(var b=0,c=this.length;b<c;b++)if(b in this&&this[b]===a)return b;return-1};jQuery(document).ready(function(c){"use strict";return window.WC_Braintree_Payment_Form_Handler=function(){function b(b){if(this.hide_integration_ui=a(this.hide_integration_ui,this),this.show_integration_ui=a(this.show_integration_ui,this),this.id=b.id,this.id_dasherized=b.id_dasherized,this.type=b.type,this.debug=b.debug,this.client_token_nonce=b.client_token_nonce,this.params=window.wc_braintree_params,!this.is_sdk_ready())return console.error("Braintree SDK is missing.");this.init()}return b.prototype.init=function(){return c("form.checkout").length?this.handle_checkout_page():c("form#order_review").length?this.handle_pay_page():c("form#add_payment_method").length?this.handle_add_payment_method_page():void 0},b.prototype.handle_checkout_page=function(){return this.form=c("form.checkout"),this.form_ui_selector=".woocommerce-checkout-payment",c(document.body).on("updated_checkout",function(a){return function(){return a.setup_braintree()}}(this)),c(document.body).on("updated_checkout",function(a){return function(){return a.handle_saved_payment_methods()}}(this)),c(document.body).on("checkout_error",function(a){return function(){return a.handle_checkout_error()}}(this)),this.form.on("checkout_place_order_"+this.id,function(a){return function(){if(a.is_selected())return a.block_ui(),a.verify_form()}}(this))},b.prototype.handle_checkout_error=function(){return this.unblock_ui()},b.prototype.handle_pay_page=function(){return this.form=c("form#order_review"),this.form_ui_selector="#payment",this.handle_saved_payment_methods(),this.setup_braintree(),this.form.submit(function(a){return function(){if(a.is_selected())return a.block_ui(),a.verify_form()}}(this))},b.prototype.handle_add_payment_method_page=function(){return this.form=c("form#add_payment_method"),this.form_ui_selector="#payment",this.setup_braintree(),this.form.submit(function(a){return function(){if(a.is_selected())return a.block_ui(),a.verify_form()}}(this))},b.prototype.verify_form=function(){return!!this.using_payment_token()||!!this.has_payment_nonce()&&void 0},b.prototype.submit_form=function(a){return c("input[name=wc_"+this.id+"_payment_nonce]").val(a),this.form.submit()},b.prototype.handle_saved_payment_methods=function(){var a;return a=c("div.js-wc-"+this.id_dasherized+"-new-payment-method-form"),c("input.js-wc-"+this.id_dasherized+"-payment-token").change(function(b){return function(){var d;return d=c("input.js-wc-"+b.id_dasherized+"-payment-token:checked").val(),d?a.slideUp(200):a.slideDown(200)}}(this)).change(),c("input#createaccount").change(function(a){return function(b){var d;return d=c("input.js-wc-"+a.id_dasherized+"-tokenize-payment-method").closest("p.form-row"),c(b.target).is(":checked")?(d.slideDown(),d.next().show()):(d.hide(),d.next().hide())}}(this)).change()},b.prototype.setup_braintree=function(){return this.block_ui(),c("input[name=wc_"+this.id+"_payment_nonce]").val(""),null!=this.client?this.setup_integration():this.create_client()},b.prototype.create_client=function(){return this.get_client_token().then(function(a){return function(b){return braintree.client.create({authorization:b}).then(function(b){return a.client=b,a.setup_integration()})}}(this)).catch(function(a){return function(b){return a.handle_integration_error(b),a.unblock_ui()}}(this))},b.prototype.get_client_token=function(){return new Promise(function(a){return function(b,d){var e;return a.id+"_client_token_nonce",e={action:"wc_"+a.id+"_get_client_token",nonce:a.client_token_nonce},c.post(a.params.ajax_url,e).done(function(a){return a.success?b(a.data):d(a.data)}).fail(function(a,b,c){return d({message:"Could not retrieve the client token via AJAX"})})}}(this))},b.prototype.setup_integration=function(){return this.get_integration_class().create(this.get_integration_options()).then(function(a){return function(b){return a.integration=b,a.show_integration_ui(),a.do_integration_ready(),c(document).trigger("wc_"+a.id+"_integration_ready",a.integration)}}(this),function(a){return function(b){return a.handle_integration_error(b),a.unblock_ui()}}(this))},b.prototype.refresh_braintree=function(){if(null!=this.integration)return this.block_ui(),this.integration.teardown(function(a){return function(){return a.integration=null,a.setup_braintree()}}(this))},b.prototype.teardown_braintree=function(){if(null!=this.integration)return this.block_ui(),this.integration.teardown(function(a){return function(){return a.integration=null,a.unblock_ui()}}(this))},b.prototype.do_integration_ready=function(){},b.prototype.get_integration_options=function(){return{client:this.client}},b.prototype.get_integration_class=function(){},b.prototype.handle_integration_error=function(a){return this.log("Integration error: "+a.message,a),this.hide_integration_ui(),this.unblock_ui()},b.prototype.handle_payment_error=function(a){return this.log("Payment error: "+a.message,a),this.render_error(this.get_user_message(a)),this.unblock_ui()},b.prototype.render_error=function(a){return c(".woocommerce-error, .woocommerce-message").remove(),this.form.prepend('<div class="woocommerce-error">'+a+"</div>").removeClass("processing").unblock(),c("html, body").animate({scrollTop:this.form.offset().top-100},1e3),c("input[name=wc_"+this.id+"_payment_nonce]").val(""),this.form.trigger("wc_"+this.id+"_rendered_error"),this.unblock_ui()},b.prototype.get_user_message=function(a){return this.params.payment_error_message},b.prototype.show_integration_ui=function(){if(c("div.js-wc-"+this.id_dasherized+"-new-payment-method-form").find(".woocommerce-error").remove(),c("input#createaccount").length&&c("input#createaccount").is(":checked"))return c("div.js-wc-"+this.id_dasherized+"-new-payment-method-form").find(".form-row").show()},b.prototype.hide_integration_ui=function(){return c("div.js-wc-"+this.id_dasherized+"-new-payment-method-form").prepend('<div class="woocommerce-error">'+this.params.integration_error_message+"</div>"),c("div.js-wc-"+this.id_dasherized+"-new-payment-method-form").find(".form-row").hide()},b.prototype.block_ui=function(){return c(this.form_ui_selector).block({message:null,overlayCSS:{background:"#fff",opacity:.6}})},b.prototype.unblock_ui=function(){return c(this.form_ui_selector).unblock()},b.prototype.is_selected=function(){return this.get_selected_gateway_id()===this.id},b.prototype.is_sdk_ready=function(){return"undefined"!=typeof braintree&&null!==braintree&&null!=braintree.client&&null!=this.get_integration_class()},b.prototype.has_payment_nonce=function(){return this.form.find("input[name=wc_"+this.id+"_payment_nonce]").val()},b.prototype.using_payment_token=function(){return this.form.find("input.js-wc-"+this.id_dasherized+"-payment-token:checked").val()},b.prototype.get_selected_gateway_id=function(){return this.form.find("input[name=payment_method]:checked").val()},b.prototype.log=function(a,b){if(this.debug)return console.log("[Braintree] "+a),console.log(b)},b}(),window.WC_Braintree_Credit_Card_Payment_Form_Handler=function(e){function f(b){this.hide_integration_ui=a(this.hide_integration_ui,this),this.show_integration_ui=a(this.show_integration_ui,this),this.remove_3ds_ui=a(this.remove_3ds_ui,this),this.add_3ds_ui=a(this.add_3ds_ui,this),this.csc_required=b.csc_required,this.hosted_fields_styles=b.hosted_fields_styles,this.threeds=b.threeds,this.enabled_card_types=b.enabled_card_types,f.__super__.constructor.call(this,b)}return b(f,e),f.prototype.handle_checkout_error=function(){return f.__super__.handle_checkout_error.call(this),c("input[name=wc_"+this.id+"_payment_nonce]").val("")},f.prototype.verify_form=function(){var a;return this.has_payment_nonce()||!this.csc_required&&this.using_payment_token()?(a=c("input.js-wc-braintree-credit-card-payment-token:checked"),this.should_verify_3d_secure_token(a)?(this.verify_3d_secure(a.data("nonce"),a),!1):f.__super__.verify_form.call(this)):(this.tokenize_payment(),!1)},f.prototype.tokenize_payment=function(){return this.integration.tokenize().then(function(a){return function(b){if(a.log("payment method received",b),null!=b.nonce)return a.should_verify_3d_secure(b)?a.verify_3d_secure(b.nonce):a.submit_form(b.nonce)}}(this)).catch(function(a){return function(b){return a.handle_payment_error(b)}}(this))},f.prototype.get_integration_options=function(){var a;return a={client:this.client,fields:{number:{selector:"#wc-braintree-credit-card-account-number-hosted",placeholder:c("#wc-braintree-credit-card-account-number-hosted").data("placeholder")},cvv:{selector:"#wc-braintree-credit-card-csc-hosted",placeholder:c("#wc-braintree-credit-card-csc-hosted").data("placeholder")},expirationDate:{selector:"#wc-braintree-credit-card-expiry-hosted",placeholder:c("#wc-braintree-credit-card-expiry-hosted").data("placeholder")}},styles:this.hosted_fields_styles},this.csc_required&&this.using_payment_token()&&(delete a.fields.number,delete a.fields.expirationDate),this.csc_required||delete a.fields.cvv,a},f.prototype.get_integration_class=function(){return braintree.hostedFields},f.prototype.do_integration_ready=function(){return this.integration.on("cardTypeChange",function(a){return function(b){return a.on_card_type_change(b)}}(this)),!this.csc_required&&c("input.js-wc-braintree-credit-card-payment-token:checked").val()&&this.teardown_braintree(),this.unblock_ui()},f.prototype.handle_saved_payment_methods=function(){var a,b;return f.__super__.handle_saved_payment_methods.call(this),b=c("div.js-wc-braintree-credit-card-new-payment-method-form"),a=c("div.wc-braintree-hosted-field-card-csc-parent"),c("input.js-wc-braintree-credit-card-payment-token").change(function(d){return function(){var e;return e=c("input.js-wc-braintree-credit-card-payment-token:checked").val(),e?d.csc_required&&a.hasClass("form-row-last")?(a.removeClass("form-row-last").addClass("form-row-first"),b.after(a),d.refresh_braintree()):void 0:(d.csc_required&&a.hasClass("form-row-first")&&(a.removeClass("form-row-first").addClass("form-row-last"),b.find("div.wc-braintree-hosted-field-card-expiry-parent").after(a)),d.refresh_braintree())}}(this)).change()},f.prototype.get_user_message=function(a){var b,c,d,e;if(d=[],"CUSTOMER"===a.type)switch(a.code){case"HOSTED_FIELDS_FIELDS_EMPTY":this.csc_required&&d.push(this.params.cvv_missing),this.using_payment_token()||(d.push(this.params.card_number_missing),d.push(this.params.card_exp_date_invalid));break;case"HOSTED_FIELDS_FIELDS_INVALID":if(null!=a.details)for(e=a.details.invalidFieldKeys,b=0,c=e.length;b<c;b++)switch(e[b]){case"number":d.push(this.params.card_number_invalid);break;case"cvv":d.push(this.params.cvv_length_invalid);break;case"expirationDate":d.push(this.params.card_exp_date_invalid)}}return d.length?d.join("<br/>"):f.__super__.get_user_message.call(this)},f.prototype.on_card_type_change=function(a){var b,e,f;if(null!=a.cards)return b=c("#wc-braintree-credit-card-account-number-hosted"),b.attr("class",function(a,b){return b.replace(/(^|\s)card-type-\S+/g,"")}),a.cards.length?1===a.cards.length?(e=a.cards[0],null!=e.type&&(f=e.type,d.call(this.enabled_card_types,f)>=0)?b.addClass("card-type-"+e.type):b.addClass("card-type-invalid")):void 0:b.addClass("card-type-invalid")},f.prototype.is_3d_secure_enabled=function(){return this.threeds.enabled&&null!=braintree.threeDSecure},f.prototype.setup_integration=function(){return this.is_3d_secure_enabled()?braintree.threeDSecure.create({client:this.client}).then(function(a){return function(b){return a.threeDSecure=b,c(document.body).on("click","#wc-braintree-credit-card-3dsecure-container",function(b){return c(b.currentTarget).fadeOut(200),a.threeDSecure.cancelVerifyCard(),a.unblock_ui()}),f.__super__.setup_integration.call(a)}}(this)).catch(function(a){return function(b){return a.handle_integration_error(b)}}(this)):f.__super__.setup_integration.call(this)},f.prototype.should_verify_3d_secure=function(a){var b;return b=a.details.cardType,this.is_3d_secure_enabled()&&"CreditCard"===a.type&&("Visa"===b||"MasterCard"===b)},f.prototype.should_verify_3d_secure_token=function(a){if(a.val()&&a.data("nonce")&&!a.data("verified"))return!0},f.prototype.verify_3d_secure=function(a,b){return null==b&&(b=null),this.threeDSecure.verifyCard({nonce:a,amount:c("input[name=wc_braintree_credit_card_3d_secure_order_total]").val(),addFrame:function(a){return function(b,c){return a.add_3ds_ui(b,c)}}(this),removeFrame:function(a){return function(){return a.remove_3ds_ui()}}(this)}).then(function(a){return function(d){return a.log("3DS response",d),a.threeds.liability_shift_always_required&&!d.liabilityShifted&&a.render_error(a.threeds.failure_message),d.liabilityShiftPossible&&!d.liabilityShifted&&a.render_error(a.threeds.failure_message),null!=b&&b.data("verified",!0),c("input[name=wc_braintree_credit_card_3d_secure_verified]").val(1),a.submit_form(d.nonce)}}(this)).catch(function(a){return function(b){return a.handle_payment_error(b)}}(this))},f.prototype.add_3ds_ui=function(a,b){var d;return a?this.handle_payment_error(a):(d=c("<div>",{id:"wc-"+this.id_dasherized+"-3dsecure-container"}),d.html(b),c(document.body).append(d),d.fadeIn(400))},f.prototype.remove_3ds_ui=function(){return c("#wc-"+this.id_dasherized+"-3dsecure-container").fadeOut(400,function(a){return c(this).remove()})},f.prototype.show_integration_ui=function(){return f.__super__.show_integration_ui.call(this),c(".wc-braintree-hosted-field-parent").show()},f.prototype.hide_integration_ui=function(){return f.__super__.hide_integration_ui.call(this),c(".wc-braintree-hosted-field-parent").hide()},f}(WC_Braintree_Payment_Form_Handler),window.WC_Braintree_PayPal_Payment_Form_Handler=function(d){function e(b){this.get_linked_account_html=a(this.get_linked_account_html,this),this.on_authorize=a(this.on_authorize,this),this.do_integration_ready=a(this.do_integration_ready,this),this.is_test_environment=b.is_test_environment,this.must_login_message=b.must_login_message,this.must_login_add_method_message=b.must_login_add_method_message,this.button_styles=b.button_styles,e.__super__.constructor.call(this,b)}return b(e,d),e.prototype.init=function(){return e.__super__.init.call(this),c("input[name=wc_"+this.id+"_payment_nonce]").val(this.params.cart_payment_nonce),c(document.body).on("click",'input[name="payment_method"], input.js-wc-braintree-paypal-payment-token',function(a){return function(){return!a.is_selected()||a.has_payment_nonce()||a.using_payment_token()?c("#place_order").show():c("#place_order").hide()}}(this)),c(document.body).on("click",".wc-braintree-paypal-account .cancel",function(a){return function(b){return b.preventDefault(),c(b.currentTarget).parent().remove(),a.setup_braintree()}}(this))},e.prototype.verify_form=function(){var a;return a=e.__super__.verify_form.call(this),this.has_payment_nonce()||this.using_payment_token()||this.render_error(this.must_login_message),a},e.prototype.handle_payment_error=function(a){return e.__super__.handle_payment_error.call(this,a),this.params.cart_payment_nonce=!1,this.setup_braintree()},e.prototype.get_integration_class=function(){return braintree.paypalCheckout},e.prototype.setup_braintree=function(){return this.params.cart_payment_nonce?this.unblock_ui():(e.__super__.setup_braintree.call(this),c("input.js-wc-braintree-paypal-tokenize-payment-method").prop("disabled",!1),this.is_selected()?c("#place_order").hide():void 0)},e.prototype.do_integration_ready=function(){var a;return this.params.cart_payment_nonce?this.unblock_ui():(c("#wc_braintree_paypal_container").html(""),a=this.is_single_use()?"checkout":"vault",this.integration.createPayment({flow:a,amount:this.get_order_amount(),currency:this.get_store_currency(),locale:this.get_store_locale()}).then(function(a){return function(b){return a.render_button(b)}}(this)).then(function(a){return function(){return c("#wc_braintree_paypal_container").css({width:"100%"}),a.unblock_ui()}}(this)).catch(function(a){return function(b){return a.handle_integration_error(b),a.unblock_ui()}}(this)))},e.prototype.render_button=function(a){var b;return b={env:this.is_test_environment?"sandbox":"production",commit:this.button_is_pay_now(),style:this.get_button_styles(),payment:function(b){return function(){return a}}(),onAuthorize:function(a){return function(b,c){return a.on_authorize(b,c)}}(this),onCancel:function(a){return function(b){return a.on_cancelled(b)}}(this),onError:function(a){return function(b){return a.handle_integration_error(b)}}(this)},paypal.Button.render(b,"#wc_braintree_paypal_container")},e.prototype.button_is_pay_now=function(){return!c("form#add_payment_method").length},e.prototype.get_button_styles=function(){return this.button_styles},e.prototype.on_authorize=function(a,b){return this.block_ui(),this.integration.tokenizePayment(a).then(function(a){return function(b){return a.log("PayPal method tokenized.",b),a.set_payment_method(b)}}(this)).catch(function(a){return function(b){return a.handle_payment_error(b),a.unblock_ui()}}(this))},e.prototype.set_payment_method=function(a){return c("input[name=wc_"+this.id+"_payment_nonce]").val(a.nonce),c("#wc_braintree_paypal_container").html(this.get_linked_account_html(a.details)),this.is_single_use()&&c("input.js-wc-braintree-paypal-tokenize-payment-method").prop("disabled",!0),c("#place_order").show(),this.form.submit()},e.prototype.on_cancelled=function(a){if(c("input.js-wc-braintree-paypal-tokenize-payment-method").prop("disabled",!1),c("input[name=wc_braintree_paypal_payment_nonce]").val(""),this.is_selected())return c("#place_order").hide()},e.prototype.handle_saved_payment_methods=function(){return e.__super__.handle_saved_payment_methods.call(this),c("input.js-wc-braintree-paypal-tokenize-payment-method").change(function(a){return function(b){if(null!=a.integration&&c(b.target).is(":visible"))return a.block_ui(),a.do_integration_ready()}}(this)).change()},e.prototype.get_linked_account_html=function(a){var b;return b=c("<div class='wc-"+this.id_dasherized+"-account'></div>"),null!=a.firstName&&null!=a.lastName&&b.append("<span class='name'>"+a.firstName+" "+a.lastName+"</span>"),b.append("<span class='email'>"+a.email+"</span>"),b.append("<a href='#' class='cancel'>Cancel</a>"),b},e.prototype.is_single_use=function(){var a;return a=c("input[name=wc-braintree-paypal-tokenize-payment-method]"),0===a.length||("checkbox"===a.attr("type")?!a.is(":checked"):!a.val())},e.prototype.get_order_amount=function(){return c("input[name=wc_braintree_paypal_amount]").val()},e.prototype.get_store_currency=function(){return c("input[name=wc_braintree_paypal_currency]").val()},e.prototype.get_store_locale=function(){return c("input[name=wc_braintree_paypal_locale]").val()},e.prototype.is_sdk_ready=function(){return e.__super__.is_sdk_ready.call(this)&&"undefined"!=typeof paypal&&null!==paypal},e}(WC_Braintree_Payment_Form_Handler),window.WC_Braintree_PayPal_Cart_Handler=function(a){function d(a){d.__super__.constructor.call(this,a),this.form=c("form.woocommerce-cart-form"),this.form_ui_selector="",this.setup_braintree(),c(document.body).on("updated_cart_totals",function(a){return function(){return a.setup_braintree()}}(this))}return b(d,a),d.prototype.button_is_pay_now=function(){return!1},d.prototype.set_payment_method=function(a){if(null!=a.nonce)return a.wp_nonce=this.params.cart_nonce,c.ajax({type:"POST",url:this.params.cart_handler_url,data:a,dataType:"json"}).done(function(a){return function(b){if(a.log("PayPal Cart response",b),null!=b.redirect_url)return window.location=b.redirect_url}}(this)).fail(function(a){return function(b){return a.log("Error setting the PayPal cart data.",b)}}(this)).always(function(a){return function(){return a.unblock_ui()}}(this))},d.prototype.is_single_use=function(){return"1"===c("input[name=wc_braintree_paypal_single_use]").val()},d.prototype.has_payment_nonce=function(){return!1},d}(WC_Braintree_PayPal_Payment_Form_Handler)})}).call(this);
1
+ (function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b=function(a,b){function d(){this.constructor=a}for(var e in b)c.call(b,e)&&(a[e]=b[e]);return d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype,a},c={}.hasOwnProperty,d=[].indexOf||function(a){for(var b=0,c=this.length;b<c;b++)if(b in this&&this[b]===a)return b;return-1};jQuery(document).ready(function(c){"use strict";return window.WC_Braintree_Payment_Form_Handler=function(){function b(b){if(this.hide_integration_ui=a(this.hide_integration_ui,this),this.show_integration_ui=a(this.show_integration_ui,this),this.id=b.id,this.id_dasherized=b.id_dasherized,this.type=b.type,this.debug=b.debug,this.client_token_nonce=b.client_token_nonce,this.params=window.wc_braintree_params,!this.is_sdk_ready())return console.error("Braintree SDK is missing.");this.init()}return b.prototype.init=function(){return c("form.checkout").length?this.handle_checkout_page():c("form#order_review").length?this.handle_pay_page():c("form#add_payment_method").length?this.handle_add_payment_method_page():void 0},b.prototype.handle_checkout_page=function(){return this.form=c("form.checkout"),this.form_ui_selector=".woocommerce-checkout-payment",c(document.body).on("updated_checkout",function(a){return function(){return a.setup_braintree()}}(this)),c(document.body).on("updated_checkout",function(a){return function(){return a.handle_saved_payment_methods()}}(this)),c(document.body).on("checkout_error",function(a){return function(){return a.handle_checkout_error()}}(this)),this.form.on("checkout_place_order_"+this.id,function(a){return function(){if(a.is_selected())return a.block_ui(),a.verify_form()}}(this))},b.prototype.handle_checkout_error=function(){return this.unblock_ui()},b.prototype.handle_pay_page=function(){return this.form=c("form#order_review"),this.form_ui_selector="#payment",this.handle_saved_payment_methods(),this.setup_braintree(),this.form.submit(function(a){return function(){if(a.is_selected())return a.block_ui(),a.verify_form()}}(this))},b.prototype.handle_add_payment_method_page=function(){return this.form=c("form#add_payment_method"),this.form_ui_selector="#payment",this.setup_braintree(),this.form.submit(function(a){return function(){if(a.is_selected())return a.block_ui(),a.verify_form()}}(this))},b.prototype.verify_form=function(){return!!this.using_payment_token()||!!this.has_payment_nonce()&&void 0},b.prototype.submit_form=function(a){return c("input[name=wc_"+this.id+"_payment_nonce]").val(a),this.form.submit()},b.prototype.handle_saved_payment_methods=function(){var a;return a=c("div.js-wc-"+this.id_dasherized+"-new-payment-method-form"),c("input.js-wc-"+this.id_dasherized+"-payment-token").change(function(b){return function(){var d;return d=c("input.js-wc-"+b.id_dasherized+"-payment-token:checked").val(),d?a.slideUp(200):a.slideDown(200)}}(this)).change(),c("input#createaccount").change(function(a){return function(b){var d;return d=c("input.js-wc-"+a.id_dasherized+"-tokenize-payment-method").closest("p.form-row"),c(b.target).is(":checked")?(d.slideDown(),d.next().show()):(d.hide(),d.next().hide())}}(this)).change()},b.prototype.setup_braintree=function(){return this.block_ui(),c("input[name=wc_"+this.id+"_payment_nonce]").val(""),null!=this.client?this.setup_integration():this.create_client()},b.prototype.create_client=function(){return this.get_client_token().done(function(a){return function(b){return b.success?braintree.client.create({authorization:b.data}).then(function(b){return a.client=b,a.setup_integration()}).catch(function(b){return a.handle_integration_error(b),a.unblock_ui()}):a.handle_integration_error(b.data)}}(this)).fail(function(a){return function(b,c,d){return a.handle_integration_error({message:"Could not retrieve the client token via AJAX: "+d})}}(this)).always(function(a){return function(){return a.unblock_ui()}}(this))},b.prototype.get_client_token=function(){var a;return this.id+"_client_token_nonce",a={action:"wc_"+this.id+"_get_client_token",nonce:this.client_token_nonce},c.post(this.params.ajax_url,a)},b.prototype.setup_integration=function(){return this.get_integration_class().create(this.get_integration_options()).then(function(a){return function(b){return a.integration=b,a.show_integration_ui(),a.do_integration_ready(),c(document).trigger("wc_"+a.id+"_integration_ready",a.integration)}}(this),function(a){return function(b){return a.handle_integration_error(b),a.unblock_ui()}}(this))},b.prototype.refresh_braintree=function(){if(null!=this.integration)return this.block_ui(),this.integration.teardown(function(a){return function(){return a.integration=null,a.setup_braintree()}}(this))},b.prototype.teardown_braintree=function(){if(null!=this.integration)return this.block_ui(),this.integration.teardown(function(a){return function(){return a.integration=null,a.unblock_ui()}}(this))},b.prototype.do_integration_ready=function(){},b.prototype.get_integration_options=function(){return{client:this.client}},b.prototype.get_integration_class=function(){},b.prototype.handle_integration_error=function(a){return this.log("Integration error: "+a.message,a),this.hide_integration_ui(),this.unblock_ui()},b.prototype.handle_payment_error=function(a){return this.log("Payment error: "+a.message,a),this.render_error(this.get_user_message(a)),this.unblock_ui()},b.prototype.render_error=function(a){return c(".woocommerce-error, .woocommerce-message").remove(),this.form.prepend('<div class="woocommerce-error">'+a+"</div>").removeClass("processing").unblock(),c("html, body").animate({scrollTop:this.form.offset().top-100},1e3),c("input[name=wc_"+this.id+"_payment_nonce]").val(""),this.form.trigger("wc_"+this.id+"_rendered_error"),this.unblock_ui()},b.prototype.get_user_message=function(a){return this.params.payment_error_message},b.prototype.show_integration_ui=function(){if(c("div.js-wc-"+this.id_dasherized+"-new-payment-method-form").find(".woocommerce-error").remove(),c("input#createaccount").length&&c("input#createaccount").is(":checked"))return c("div.js-wc-"+this.id_dasherized+"-new-payment-method-form").find(".form-row").show()},b.prototype.hide_integration_ui=function(){return c("div.js-wc-"+this.id_dasherized+"-new-payment-method-form").prepend('<div class="woocommerce-error">'+this.params.integration_error_message+"</div>"),c("div.js-wc-"+this.id_dasherized+"-new-payment-method-form").find(".form-row").hide()},b.prototype.block_ui=function(){return c(this.form_ui_selector).block({message:null,overlayCSS:{background:"#fff",opacity:.6}})},b.prototype.unblock_ui=function(){return c(this.form_ui_selector).unblock()},b.prototype.is_selected=function(){return this.get_selected_gateway_id()===this.id},b.prototype.is_sdk_ready=function(){return"undefined"!=typeof braintree&&null!==braintree&&null!=braintree.client&&null!=this.get_integration_class()},b.prototype.has_payment_nonce=function(){return this.form.find("input[name=wc_"+this.id+"_payment_nonce]").val()},b.prototype.using_payment_token=function(){return this.form.find("input.js-wc-"+this.id_dasherized+"-payment-token:checked").val()},b.prototype.get_selected_gateway_id=function(){return this.form.find("input[name=payment_method]:checked").val()},b.prototype.log=function(a,b){if(this.debug)return console.log("[Braintree] "+a),console.log(b)},b}(),window.WC_Braintree_Credit_Card_Payment_Form_Handler=function(e){function f(b){this.hide_integration_ui=a(this.hide_integration_ui,this),this.show_integration_ui=a(this.show_integration_ui,this),this.remove_3ds_ui=a(this.remove_3ds_ui,this),this.add_3ds_ui=a(this.add_3ds_ui,this),this.csc_required=b.csc_required,this.hosted_fields_styles=b.hosted_fields_styles,this.threeds=b.threeds,this.enabled_card_types=b.enabled_card_types,f.__super__.constructor.call(this,b)}return b(f,e),f.prototype.handle_checkout_error=function(){return f.__super__.handle_checkout_error.call(this),c("input[name=wc_"+this.id+"_payment_nonce]").val("")},f.prototype.verify_form=function(){var a;return this.has_payment_nonce()||!this.csc_required&&this.using_payment_token()?(a=c("input.js-wc-braintree-credit-card-payment-token:checked"),this.should_verify_3d_secure_token(a)?(this.verify_3d_secure(a.data("nonce"),a),!1):f.__super__.verify_form.call(this)):(this.tokenize_payment(),!1)},f.prototype.tokenize_payment=function(){return this.integration.tokenize().then(function(a){return function(b){if(a.log("payment method received",b),null!=b.nonce)return a.should_verify_3d_secure(b)?a.verify_3d_secure(b.nonce):a.submit_form(b.nonce)}}(this)).catch(function(a){return function(b){return a.handle_payment_error(b)}}(this))},f.prototype.get_integration_options=function(){var a;return a={client:this.client,fields:{number:{selector:"#wc-braintree-credit-card-account-number-hosted",placeholder:c("#wc-braintree-credit-card-account-number-hosted").data("placeholder")},cvv:{selector:"#wc-braintree-credit-card-csc-hosted",placeholder:c("#wc-braintree-credit-card-csc-hosted").data("placeholder")},expirationDate:{selector:"#wc-braintree-credit-card-expiry-hosted",placeholder:c("#wc-braintree-credit-card-expiry-hosted").data("placeholder")}},styles:this.hosted_fields_styles},this.csc_required&&this.using_payment_token()&&(delete a.fields.number,delete a.fields.expirationDate),this.csc_required||delete a.fields.cvv,a},f.prototype.get_integration_class=function(){return braintree.hostedFields},f.prototype.do_integration_ready=function(){return this.integration.on("cardTypeChange",function(a){return function(b){return a.on_card_type_change(b)}}(this)),!this.csc_required&&c("input.js-wc-braintree-credit-card-payment-token:checked").val()&&this.teardown_braintree(),this.unblock_ui()},f.prototype.handle_saved_payment_methods=function(){var a,b;return f.__super__.handle_saved_payment_methods.call(this),b=c("div.js-wc-braintree-credit-card-new-payment-method-form"),a=c("div.wc-braintree-hosted-field-card-csc-parent"),c("input.js-wc-braintree-credit-card-payment-token").change(function(d){return function(){var e;return e=c("input.js-wc-braintree-credit-card-payment-token:checked").val(),e?d.csc_required&&a.hasClass("form-row-last")?(a.removeClass("form-row-last").addClass("form-row-first"),b.after(a),d.refresh_braintree()):void 0:(d.csc_required&&a.hasClass("form-row-first")&&(a.removeClass("form-row-first").addClass("form-row-last"),b.find("div.wc-braintree-hosted-field-card-expiry-parent").after(a)),d.refresh_braintree())}}(this)).change()},f.prototype.get_user_message=function(a){var b,c,d,e;if(d=[],"CUSTOMER"===a.type)switch(a.code){case"HOSTED_FIELDS_FIELDS_EMPTY":this.csc_required&&d.push(this.params.cvv_missing),this.using_payment_token()||(d.push(this.params.card_number_missing),d.push(this.params.card_exp_date_invalid));break;case"HOSTED_FIELDS_FIELDS_INVALID":if(null!=a.details)for(e=a.details.invalidFieldKeys,b=0,c=e.length;b<c;b++)switch(e[b]){case"number":d.push(this.params.card_number_invalid);break;case"cvv":d.push(this.params.cvv_length_invalid);break;case"expirationDate":d.push(this.params.card_exp_date_invalid)}}return d.length?d.join("<br/>"):f.__super__.get_user_message.call(this)},f.prototype.on_card_type_change=function(a){var b,e,f;if(null!=a.cards)return b=c("#wc-braintree-credit-card-account-number-hosted"),b.attr("class",function(a,b){return b.replace(/(^|\s)card-type-\S+/g,"")}),a.cards.length?1===a.cards.length?(e=a.cards[0],null!=e.type&&(f=e.type,d.call(this.enabled_card_types,f)>=0)?b.addClass("card-type-"+e.type):b.addClass("card-type-invalid")):void 0:b.addClass("card-type-invalid")},f.prototype.is_3d_secure_enabled=function(){return this.threeds.enabled&&null!=braintree.threeDSecure},f.prototype.setup_integration=function(){return this.is_3d_secure_enabled()?braintree.threeDSecure.create({client:this.client}).then(function(a){return function(b){return a.threeDSecure=b,c(document.body).on("click","#wc-braintree-credit-card-3dsecure-container",function(b){return c(b.currentTarget).fadeOut(200),a.threeDSecure.cancelVerifyCard(),a.unblock_ui()}),f.__super__.setup_integration.call(a)}}(this)).catch(function(a){return function(b){return a.handle_integration_error(b)}}(this)):f.__super__.setup_integration.call(this)},f.prototype.should_verify_3d_secure=function(a){var b;return b=a.details.cardType,this.is_3d_secure_enabled()&&"CreditCard"===a.type&&("Visa"===b||"MasterCard"===b)},f.prototype.should_verify_3d_secure_token=function(a){if(a.val()&&a.data("nonce")&&!a.data("verified"))return!0},f.prototype.verify_3d_secure=function(a,b){return null==b&&(b=null),this.threeDSecure.verifyCard({nonce:a,amount:c("input[name=wc_braintree_credit_card_3d_secure_order_total]").val(),addFrame:function(a){return function(b,c){return a.add_3ds_ui(b,c)}}(this),removeFrame:function(a){return function(){return a.remove_3ds_ui()}}(this)}).then(function(a){return function(d){return a.log("3DS response",d),a.threeds.liability_shift_always_required&&!d.liabilityShifted&&a.render_error(a.threeds.failure_message),d.liabilityShiftPossible&&!d.liabilityShifted&&a.render_error(a.threeds.failure_message),null!=b&&b.data("verified",!0),c("input[name=wc_braintree_credit_card_3d_secure_verified]").val(1),a.submit_form(d.nonce)}}(this)).catch(function(a){return function(b){return a.handle_payment_error(b)}}(this))},f.prototype.add_3ds_ui=function(a,b){var d;return a?this.handle_payment_error(a):(d=c("<div>",{id:"wc-"+this.id_dasherized+"-3dsecure-container"}),d.html(b),c(document.body).append(d),d.fadeIn(400))},f.prototype.remove_3ds_ui=function(){return c("#wc-"+this.id_dasherized+"-3dsecure-container").fadeOut(400,function(a){return c(this).remove()})},f.prototype.show_integration_ui=function(){return f.__super__.show_integration_ui.call(this),c(".wc-braintree-hosted-field-parent").show()},f.prototype.hide_integration_ui=function(){return f.__super__.hide_integration_ui.call(this),c(".wc-braintree-hosted-field-parent").hide()},f}(WC_Braintree_Payment_Form_Handler),window.WC_Braintree_PayPal_Payment_Form_Handler=function(d){function e(b){this.get_linked_account_html=a(this.get_linked_account_html,this),this.on_authorize=a(this.on_authorize,this),this.do_integration_ready=a(this.do_integration_ready,this),this.is_test_environment=b.is_test_environment,this.must_login_message=b.must_login_message,this.must_login_add_method_message=b.must_login_add_method_message,this.button_styles=b.button_styles,e.__super__.constructor.call(this,b)}return b(e,d),e.prototype.init=function(){return e.__super__.init.call(this),c("input[name=wc_"+this.id+"_payment_nonce]").val(this.params.cart_payment_nonce),c(document.body).on("click",'input[name="payment_method"], input.js-wc-braintree-paypal-payment-token',function(a){return function(){return!a.is_selected()||a.has_payment_nonce()||a.using_payment_token()?c("#place_order").show():c("#place_order").hide()}}(this)),c(document.body).on("click",".wc-braintree-paypal-account .cancel",function(a){return function(b){return b.preventDefault(),c(b.currentTarget).parent().remove(),a.setup_braintree()}}(this))},e.prototype.verify_form=function(){var a;return a=e.__super__.verify_form.call(this),this.has_payment_nonce()||this.using_payment_token()||this.render_error(this.must_login_message),a},e.prototype.handle_payment_error=function(a){return e.__super__.handle_payment_error.call(this,a),this.params.cart_payment_nonce=!1,this.setup_braintree()},e.prototype.get_integration_class=function(){return braintree.paypalCheckout},e.prototype.setup_braintree=function(){return this.params.cart_payment_nonce?this.unblock_ui():(e.__super__.setup_braintree.call(this),c("input.js-wc-braintree-paypal-tokenize-payment-method").prop("disabled",!1),this.is_selected()?c("#place_order").hide():void 0)},e.prototype.do_integration_ready=function(){var a;return this.params.cart_payment_nonce?this.unblock_ui():(c("#wc_braintree_paypal_container").html(""),a=this.is_single_use()?"checkout":"vault",this.integration.createPayment({flow:a,amount:this.get_order_amount(),currency:this.get_store_currency(),locale:this.get_store_locale()}).then(function(a){return function(b){return a.render_button(b)}}(this)).then(function(a){return function(){return c("#wc_braintree_paypal_container").css({width:"100%"}),a.unblock_ui()}}(this)).catch(function(a){return function(b){return a.handle_integration_error(b),a.unblock_ui()}}(this)))},e.prototype.render_button=function(a){var b;return b={env:this.is_test_environment?"sandbox":"production",commit:this.button_is_pay_now(),style:this.get_button_styles(),payment:function(b){return function(){return a}}(),onAuthorize:function(a){return function(b,c){return a.on_authorize(b,c)}}(this),onCancel:function(a){return function(b){return a.on_cancelled(b)}}(this),onError:function(a){return function(b){return a.handle_integration_error(b)}}(this)},paypal.Button.render(b,"#wc_braintree_paypal_container")},e.prototype.button_is_pay_now=function(){return!c("form#add_payment_method").length},e.prototype.get_button_styles=function(){return this.button_styles},e.prototype.on_authorize=function(a,b){return this.block_ui(),this.integration.tokenizePayment(a).then(function(a){return function(b){return a.log("PayPal method tokenized.",b),a.set_payment_method(b)}}(this)).catch(function(a){return function(b){return a.handle_payment_error(b),a.unblock_ui()}}(this))},e.prototype.set_payment_method=function(a){return c("input[name=wc_"+this.id+"_payment_nonce]").val(a.nonce),c("#wc_braintree_paypal_container").html(this.get_linked_account_html(a.details)),this.is_single_use()&&c("input.js-wc-braintree-paypal-tokenize-payment-method").prop("disabled",!0),c("#place_order").show(),this.form.submit()},e.prototype.on_cancelled=function(a){if(c("input.js-wc-braintree-paypal-tokenize-payment-method").prop("disabled",!1),c("input[name=wc_braintree_paypal_payment_nonce]").val(""),this.is_selected())return c("#place_order").hide()},e.prototype.handle_saved_payment_methods=function(){return e.__super__.handle_saved_payment_methods.call(this),c("input.js-wc-braintree-paypal-tokenize-payment-method").change(function(a){return function(b){if(null!=a.integration&&c(b.target).is(":visible"))return a.block_ui(),a.do_integration_ready()}}(this)).change()},e.prototype.get_linked_account_html=function(a){var b;return b=c("<div class='wc-"+this.id_dasherized+"-account'></div>"),null!=a.firstName&&null!=a.lastName&&b.append("<span class='name'>"+a.firstName+" "+a.lastName+"</span>"),b.append("<span class='email'>"+a.email+"</span>"),b.append("<a href='#' class='cancel'>Cancel</a>"),b},e.prototype.is_single_use=function(){var a;return a=c("input[name=wc-braintree-paypal-tokenize-payment-method]"),0===a.length||("checkbox"===a.attr("type")?!a.is(":checked"):!a.val())},e.prototype.get_order_amount=function(){return c("input[name=wc_braintree_paypal_amount]").val()},e.prototype.get_store_currency=function(){return c("input[name=wc_braintree_paypal_currency]").val()},e.prototype.get_store_locale=function(){return c("input[name=wc_braintree_paypal_locale]").val()},e.prototype.is_sdk_ready=function(){return e.__super__.is_sdk_ready.call(this)&&"undefined"!=typeof paypal&&null!==paypal},e}(WC_Braintree_Payment_Form_Handler),window.WC_Braintree_PayPal_Cart_Handler=function(a){function d(a){d.__super__.constructor.call(this,a),this.form=c("form.woocommerce-cart-form"),this.form_ui_selector="",this.setup_braintree(),c(document.body).on("updated_cart_totals",function(a){return function(){return a.setup_braintree()}}(this))}return b(d,a),d.prototype.button_is_pay_now=function(){return!1},d.prototype.set_payment_method=function(a){if(null!=a.nonce)return a.wp_nonce=this.params.cart_nonce,c.ajax({type:"POST",url:this.params.cart_handler_url,data:a,dataType:"json"}).done(function(a){return function(b){if(a.log("PayPal Cart response",b),null!=b.redirect_url)return window.location=b.redirect_url}}(this)).fail(function(a){return function(b){return a.log("Error setting the PayPal cart data.",b)}}(this)).always(function(a){return function(){return a.unblock_ui()}}(this))},d.prototype.is_single_use=function(){return"1"===c("input[name=wc_braintree_paypal_single_use]").val()},d.prototype.has_payment_nonce=function(){return!1},d}(WC_Braintree_PayPal_Payment_Form_Handler)})}).call(this);
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.1.0';
92
 
93
  /** @var WC_Braintree single instance of this plugin */
94
  protected static $instance;
88
 
89
 
90
  /** plugin version number */
91
+ const VERSION = '2.1.1';
92
 
93
  /** @var WC_Braintree single instance of this plugin */
94
  protected static $instance;
i18n/languages/woocommerce-gateway-paypal-powered-by-braintree.pot CHANGED
@@ -2,7 +2,7 @@
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.1.0\n"
6
  "Report-Msgid-Bugs-To: "
7
  "https://wordpress.org/support/plugin/woocommerce-gateway-paypal-powered-by-"
8
  "braintree/\n"
@@ -1616,13 +1616,13 @@ msgstr ""
1616
  msgid "%1$s eCheck Payment Method Saved: %2$s account ending in %3$s"
1617
  msgstr ""
1618
 
1619
- #: woocommerce-gateway-paypal-powered-by-braintree.php:113
1620
  msgid ""
1621
  "WooCommerce PayPal powered by Braintree is inactive. Please deactivate the "
1622
  "retired WooCommerce Braintree plugin."
1623
  msgstr ""
1624
 
1625
- #: woocommerce-gateway-paypal-powered-by-braintree.php:201
1626
  msgid ""
1627
  "The minimum PHP version required for this plugin is %1$s. You are running "
1628
  "%2$s."
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.1.1\n"
6
  "Report-Msgid-Bugs-To: "
7
  "https://wordpress.org/support/plugin/woocommerce-gateway-paypal-powered-by-"
8
  "braintree/\n"
1616
  msgid "%1$s eCheck Payment Method Saved: %2$s account ending in %3$s"
1617
  msgstr ""
1618
 
1619
+ #: woocommerce-gateway-paypal-powered-by-braintree.php:116
1620
  msgid ""
1621
  "WooCommerce PayPal powered by Braintree is inactive. Please deactivate the "
1622
  "retired WooCommerce Braintree plugin."
1623
  msgstr ""
1624
 
1625
+ #: woocommerce-gateway-paypal-powered-by-braintree.php:204
1626
  msgid ""
1627
  "The minimum PHP version required for this plugin is %1$s. You are running "
1628
  "%2$s."
readme.txt CHANGED
@@ -2,8 +2,8 @@
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: 4.9.1
6
- Stable tag: 2.1.0
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
@@ -122,6 +122,9 @@ New feature requests and bugs reports can be made in the plugin forum.
122
 
123
  == Changelog ==
124
 
 
 
 
125
  = 2.1.0 =
126
  * Feature - Upgrade to the latest Braintree JavaScript SDK for improved customer experience, reliability, and error handling
127
  * Tweak - Add placeholder text for credit card inputs
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: 4.9.2
6
+ Stable tag: 2.1.1
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
122
 
123
  == Changelog ==
124
 
125
+ = 2.1.1 =
126
+ * Fix - Fix the payment form JavaScript compatibility with IE 11
127
+
128
  = 2.1.0 =
129
  * Feature - Upgrade to the latest Braintree JavaScript SDK for improved customer experience, reliability, and error handling
130
  * Tweak - Add placeholder text for credit card inputs
woocommerce-gateway-paypal-powered-by-braintree.php CHANGED
@@ -5,7 +5,10 @@
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.1.0
 
 
 
9
  *
10
  * Copyright (c) 2016-2018, Automattic, Inc.
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.1.1
9
+ *
10
+ * WC requires at least: 2.5.5
11
+ * WC tested up to: 3.3.0
12
  *
13
  * Copyright (c) 2016-2018, Automattic, Inc.
14
  *