Version Description
Download this release
Release Info
Developer | SkyVerge |
Plugin | WooCommerce PayPal Powered by Braintree Payment Gateway |
Version | 2.4.3 |
Comparing to | |
See all releases |
Code changes from version 2.4.2 to 2.4.3
- assets/js/frontend/wc-braintree.min.js +1 -1
- class-wc-braintree.php +1 -1
- i18n/languages/woocommerce-gateway-paypal-powered-by-braintree.pot +2 -2
- readme.txt +5 -2
- vendor/autoload.php +1 -1
- vendor/composer/ClassLoader.php +1 -1
- vendor/composer/autoload_real.php +4 -4
- vendor/composer/autoload_static.php +4 -4
- vendor/skyverge/wc-plugin-framework/woocommerce/payment-gateway/assets/js/frontend/sv-wc-payment-gateway-payment-form.min.js +1 -1
- woocommerce-gateway-paypal-powered-by-braintree.php +2 -2
assets/js/frontend/wc-braintree.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
"use strict";var _get=function e(t,n,r){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,n);if(void 0!==i){if("value"in i)return i.value;i=i.get;return void 0!==i?i.call(r):void 0}t=Object.getPrototypeOf(t);if(null!==t)return e(t,n,r)},_createClass=function(){function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}}();function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(function(){function c(e,t){if(!(e instanceof t))throw new Error("Bound instance method accessed before binding")}var u=[].indexOf;jQuery(document).ready(function(s){var e,n,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 i(e){_classCallCheck(this,i);var t=_possibleConstructorReturn(this,(i.__proto__||Object.getPrototypeOf(i)).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}function o(e){_classCallCheck(this,o);var t=_possibleConstructorReturn(this,(o.__proto__||Object.getPrototypeOf(o)).call(this,e));return t.set_payment_method_nonce=e.set_payment_method_nonce,t.cart_handler_url=e.cart_handler_url,t.form=s("form.woocommerce-cart-form"),t.form_ui_selector="",t.setup_braintree(),s(document.body).on("updated_cart_totals",function(){return t.setup_braintree()}),t}function _(e){_classCallCheck(this,_);var t=_possibleConstructorReturn(this,(_.__proto__||Object.getPrototypeOf(_)).call(this,e));return t.do_integration_ready=t.do_integration_ready.bind(t),t.validate_product_button=t.validate_product_button.bind(t),t.validate_product_data=t.validate_product_data.bind(t),t.product_checkout_nonce=e.product_checkout_nonce,t.product_checkout_url=e.product_checkout_url,t.is_product_page=e.is_product_page,t.validate_product_url=e.validate_product_url,t.validate_product_nonce=e.validate_product_nonce,t.should_validate_product_data=e.should_validate_product_data,t.form=s("form.woocommerce-cart-form"),t.form_ui_selector="",t.is_product_page&&t.handle_product_page(),t.setup_braintree(),s(document.body).on("updated_cart_totals",function(){return t.setup_braintree()}),t}return window.WC_Braintree_Payment_Form_Handler=(_createClass(t,[{key:"init",value:function(){return this.is_sdk_ready()?s("form.checkout").length?this.handle_checkout_page():s("form#order_review").length?this.handle_pay_page():s("form#add_payment_method").length?this.handle_add_payment_method_page():void 0:console.error("Braintree SDK is missing.")}},{key:"handle_checkout_page",value:function(){var e=this;return this.form=s("form.checkout"),this.form_ui_selector=".woocommerce-checkout-payment",s(document.body).on("updated_checkout",function(){if(!e.setting_up)return e.setup_braintree()}),s(document.body).on("updated_checkout",function(){return e.handle_saved_payment_methods()}),s(document.body).on("checkout_error",function(){return e.handle_checkout_error()}),this.form.on("checkout_place_order_"+this.id,function(){if(e.is_selected())return e.block_ui(),e.verify_form()})}},{key:"handle_checkout_error",value:function(){return this.unblock_ui()}},{key:"handle_pay_page",value:function(){var e=this;return this.form=s("form#order_review"),this.form_ui_selector="#payment",this.handle_saved_payment_methods(),this.setup_braintree(),this.form.submit(function(){if(e.is_selected())return e.block_ui(),e.verify_form()})}},{key:"handle_add_payment_method_page",value:function(){var e=this;return this.form=s("form#add_payment_method"),this.form_ui_selector="#payment",this.setup_braintree(),this.form.submit(function(){if(e.is_selected())return e.block_ui(),e.verify_form()})}},{key:"verify_form",value:function(){return!!this.using_payment_token()||!!this.has_payment_nonce()&&void 0}},{key:"submit_form",value:function(e){return s("input[name=wc_"+this.id+"_payment_nonce]").val(e),this.form.submit()}},{key:"handle_saved_payment_methods",value:function(){var n=this,e=s("div.js-wc-"+this.id_dasherized+"-new-payment-method-form");if(s("input.js-wc-"+this.id_dasherized+"-payment-token").change(function(){return s("input.js-wc-"+n.id_dasherized+"-payment-token:checked").val()?e.slideUp(200):e.slideDown(200)}).change(),s("input#createaccount").change(function(e){var t=s("input.js-wc-"+n.id_dasherized+"-tokenize-payment-method").closest("p.form-row");return s(e.target).is(":checked")?(t.slideDown(),t.next().show()):(t.hide(),t.next().hide())}),!s("input#createaccount").is(":checked"))return s("input#createaccount").change()}},{key:"setup_braintree",value:function(){if(!s("#wc-"+this.id_dasherized+"-account-number-hosted iframe").data("ready"))return this.setting_up=!0,this.block_ui(),s("input[name=wc_"+this.id+"_payment_nonce]").val(""),this.create_client()}},{key:"create_client",value:function(){var r=this;return this.log("Creating client."),this.get_client_token().done(function(e){return e.success?braintree.client.create({authorization:e.data}).then(function(e){return r.client=e,r.log("Client ready."),r.setup_integration()}).catch(function(e){return r.handle_integration_error(e),r.unblock_ui()}):r.handle_integration_error(e.data)}).fail(function(e,t,n){return r.handle_integration_error({message:"Could not retrieve the client token via AJAX: "+n}),r.unblock_ui()})}},{key:"get_client_token",value:function(){this.id;var e={action:"wc_"+this.id+"_get_client_token",nonce:this.client_token_nonce};return s.post(this.ajax_url,e)}},{key:"setup_integration",value:function(){var t=this;return this.log("Creating integration."),this.get_integration_class().create(this.get_integration_options()).then(function(e){return t.integration=e,t.show_integration_ui(),s("#wc-"+t.id_dasherized+"-account-number-hosted iframe").data("ready",!0),t.do_integration_ready(),s(document).trigger("wc_"+t.id+"_integration_ready",t.integration),t.log("Integration ready."),t.setting_up=!1}).catch(function(e){return t.handle_integration_error(e),t.unblock_ui(),t.setting_up=!1})}},{key:"refresh_braintree",value:function(){var e=this;if(null!=this.integration&&!this.refreshing&&!this.setting_up)return this.log("Refreshing integration."),this.refreshing=!0,this.block_ui(),this.integration.teardown(function(){return e.integration=null,e.refreshing=!1,e.setup_braintree()})}},{key:"teardown_braintree",value:function(){var e=this;if(null!=this.integration)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 s(".woocommerce-error, .woocommerce-message").remove(),this.form.prepend('<div class="woocommerce-error">'+e+"</div>").removeClass("processing").unblock(),s("html, body").animate({scrollTop:this.form.offset().top-100},1e3),s("input[name=wc_"+this.id+"_payment_nonce]").val(""),this.form.trigger("wc_"+this.id+"_rendered_error"),s(document.body).trigger("checkout_error"),this.unblock_ui()}},{key:"get_user_message",value:function(){return this.payment_error_message}},{key:"show_integration_ui",value:function(){if(s("div.js-wc-"+this.id_dasherized+"-new-payment-method-form").find(".woocommerce-error").remove(),s("input#createaccount").length&&s("input#createaccount").is(":checked"))return s("div.js-wc-"+this.id_dasherized+"-new-payment-method-form").find(".form-row").show()}},{key:"hide_integration_ui",value:function(){return s("div.js-wc-"+this.id_dasherized+"-new-payment-method-form").prepend('<div class="woocommerce-error">'+this.integration_error_message+"</div>"),s("div.js-wc-"+this.id_dasherized+"-new-payment-method-form").find(".form-row").hide()}},{key:"block_ui",value:function(){return s(this.form_ui_selector).block({message:null,overlayCSS:{background:"#fff",opacity:.6}})}},{key:"unblock_ui",value:function(){return s(this.form_ui_selector).unblock()}},{key:"is_selected",value:function(){return this.get_selected_gateway_id()===this.id}},{key:"is_sdk_ready",value:function(){return"undefined"!=typeof braintree&&null!==braintree&&null!=braintree.client&&null!=this.get_integration_class()}},{key:"has_payment_nonce",value:function(){return this.form.find("input[name=wc_"+this.id+"_payment_nonce]").val()}},{key:"using_payment_token",value:function(){return this.form.find("input.js-wc-"+this.id_dasherized+"-payment-token:checked").val()}},{key:"get_selected_gateway_id",value:function(){return this.form.find("input[name=payment_method]:checked").val()}},{key:"log",value:function(e,t){t=1<arguments.length&&void 0!==t?t:null;if(this.debug)return console.log(this.name+": "+e),t?console.log(t):void 0}}]),t),s(document.body).trigger("wc_braintree_payment_form_handler_loaded"),e=window.WC_Braintree_Credit_Card_Payment_Form_Handler=(_inherits(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),s("input[name=wc_"+this.id+"_payment_nonce]").val(""),s("input[name=wc-"+this.id_dasherized+"-card-type]").val(""),s("input[name=wc-"+this.id_dasherized+"-3d-secure-verified]").val(0)}},{key:"verify_form",value:function(){var e;return this.has_payment_nonce()||!this.csc_required&&this.using_payment_token()?(e=s("input.js-wc-braintree-credit-card-payment-token:checked"),this.should_verify_3d_secure_token(e)?(this.verify_3d_secure(e.data("nonce"),null,e),!1):_get(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={client:this.client,fields:{number:{selector:"#wc-braintree-credit-card-account-number-hosted",placeholder:s("#wc-braintree-credit-card-account-number-hosted").data("placeholder")},cvv:{selector:"#wc-braintree-credit-card-csc-hosted",placeholder:s("#wc-braintree-credit-card-csc-hosted").data("placeholder")},expirationDate:{selector:"#wc-braintree-credit-card-expiry-hosted",placeholder:s("#wc-braintree-credit-card-expiry-hosted").data("placeholder")}},styles:this.hosted_fields_styles};return this.csc_required&&this.using_payment_token()&&(delete e.fields.number,delete e.fields.expirationDate),this.csc_required||delete e.fields.cvv,e}},{key:"get_integration_class",value:function(){return braintree.hostedFields}},{key:"do_integration_ready",value:function(){var t=this;return this.integration.on("cardTypeChange",function(e){return t.on_card_type_change(e)}),!this.csc_required&&s("input.js-wc-braintree-credit-card-payment-token:checked").val()&&this.teardown_braintree(),this.unblock_ui()}},{key:"handle_saved_payment_methods",value:function(){var e,t,n=this;return _get(a.prototype.__proto__||Object.getPrototypeOf(a.prototype),"handle_saved_payment_methods",this).call(this),t=s("div.js-wc-braintree-credit-card-new-payment-method-form"),e=s("div.wc-braintree-hosted-field-card-csc-parent"),s("input.js-wc-braintree-credit-card-payment-token").change(function(){return s("input.js-wc-braintree-credit-card-payment-token:checked").val()?n.csc_required&&e.hasClass("form-row-last")?(e.removeClass("form-row-last").addClass("form-row-first"),t.after(e),n.refresh_braintree()):void 0:(n.csc_required&&e.hasClass("form-row-first")&&(e.removeClass("form-row-first").addClass("form-row-last"),t.find("div.wc-braintree-hosted-field-card-expiry-parent").after(e)),n.refresh_braintree())}).change()}},{key:"get_user_message",value:function(e){var t,n,r,i=[];if("CUSTOMER"===e.type)switch(e.code){case"HOSTED_FIELDS_FIELDS_EMPTY":this.csc_required&&i.push(this.params.cvv_missing),this.using_payment_token()||(i.push(this.params.card_number_missing),i.push(this.params.card_exp_date_invalid));break;case"HOSTED_FIELDS_FIELDS_INVALID":if(null!=e.details)for(t=0,n=(r=e.details.invalidFieldKeys).length;t<n;t++)switch(r[t]){case"number":i.push(this.params.card_number_invalid);break;case"cvv":i.push(this.params.cvv_length_invalid);break;case"expirationDate":i.push(this.params.card_exp_date_invalid)}}else"NETWORK"===e.type&&null!=e.details.originalError.error.message&&(e=e.details.originalError.error.message,/given name format is invalid/.test(e)&&i.push(this.params.first_name_unsupported_characters),/surname format is invalid/.test(e)&&i.push(this.params.last_name_unsupported_characters));return i.length?i.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;if(null!=e.cards)return(t=s("#wc-braintree-credit-card-account-number-hosted")).attr("class",function(e,t){return t.replace(/(^|\s)card-type-\S+/g,"")}),e.cards.length?1===e.cards.length?(n=e.cards[0],s("input[name=wc-"+this.id_dasherized+"-card-type]").val(n.type),null!=n.type&&(e=n.type,0<=u.call(this.enabled_card_types,e))?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()?(s("input[name=wc-"+this.id_dasherized+"-3d-secure-enabled]").val(1),this.threeDSecure&&this.threeDSecure.teardown(),braintree.threeDSecure.create({version:2,client:this.client}).then(function(e){return t.threeDSecure=e,s(document.body).on("click","#wc-braintree-credit-card-3dsecure-container",function(e){return s(e.currentTarget).fadeOut(200),t.threeDSecure.cancelVerifyCard(),t.unblock_ui()}),_get(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=e.details.cardType;return this.is_3d_secure_enabled()&&"CreditCard"===e.type&&0<=u.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=this,i=2<arguments.length&&void 0!==n?n:null,a=s("#billing_state").val(),o=s("#billing_country").val(),_=s("#shipping_state").val(),n=s("#shipping_country").val(),o=s("input[name=billing_first_name]").val()?{givenName:s("input[name=billing_first_name]").val().latinise(),surname:s("input[name=billing_last_name]").val().latinise(),phoneNumber:s("input[name=billing_phone]").val(),streetAddress:s("input[name=billing_address_1]").val(),extendedAddress:s("input[name=billing_address_2]").val(),locality:s("#billing_city").val(),region:"string"==typeof a&&a.length<=2?a:"",postalCode:s("input[name=billing_postcode]").val(),countryCodeAlpha2:"string"==typeof o&&o.length<=2?o:""}:{},n=s("input[name=shipping_first_name]").val()?{shippingGivenName:s("input[name=shipping_first_name]").val().latinise(),shippingSurname:s("input[name=shipping_last_name]").val().latinise(),shippingAddress:{streetAddress:s("input[name=shipping_address_1]").val(),extendedAddress:s("input[name=shipping_address_2]").val(),locality:s("input[name=shipping_city]").val(),region:"string"==typeof _&&_.length<=2?_:"",postalCode:s("input[name=shipping_postcode]").val(),countryCodeAlpha2:"string"==typeof n&&n.length<=2?n:""}}:{},n={nonce:e,amount:s("input[name=wc-"+this.id_dasherized+"-3d-secure-order-total]").val(),email:s("input[name=billing_email]").val(),billingAddress:o,additionalInformation:n,onLookupComplete:function(e,t){r.log("3D Secure lookup complete.",e);try{return t()}catch(e){return r.handle_payment_error(e)}}};return"1"===s("input[name=wc-"+this.id_dasherized+"-cart-contains-subscription]").val()&&(n.challengeRequested=!0),this.log("Verifying 3D Secure.",n),this.threeDSecure.verifyCard(n).then(function(e){return r.log("3D Secure response received.",e),r.threeds.liability_shift_always_required&&!e.liabilityShifted?r.render_error(r.threeds.failure_message):(null!=i&&i.data("verified",!0),s("input[name=wc-"+r.id_dasherized+"-3d-secure-verified]").val(1),r.submit_form(e.nonce))}).catch(function(e){return r.handle_payment_error(e)})}},{key:"show_integration_ui",value:function(){return c(this,e),_get(a.prototype.__proto__||Object.getPrototypeOf(a.prototype),"show_integration_ui",this).call(this),s(".wc-braintree-hosted-field-parent").show()}},{key:"hide_integration_ui",value:function(){return c(this,e),_get(a.prototype.__proto__||Object.getPrototypeOf(a.prototype),"hide_integration_ui",this).call(this),s(".wc-braintree-hosted-field-parent").hide()}}]),a),s(document.body).trigger("wc_braintree_credit_card_payment_form_handler_loaded"),n=window.WC_Braintree_PayPal_Payment_Form_Handler=(_inherits(i,WC_Braintree_Payment_Form_Handler),_createClass(i,[{key:"init",value:function(){var t=this;return _get(i.prototype.__proto__||Object.getPrototypeOf(i.prototype),"init",this).call(this),s("input[name=wc_"+this.id+"_payment_nonce]").val(this.cart_payment_nonce),s(document.body).on("click",'input[name="payment_method"], input.js-wc-braintree-paypal-payment-token',function(){return t.toggle_order_button()}),s(document.body).on("payment_method_selected",function(){return t.toggle_order_button()}),s(document.body).on("click",".wc-braintree-paypal-account .cancel",function(e){return e.preventDefault(),s(e.currentTarget).parent().remove(),t.setup_braintree()})}},{key:"toggle_order_button",value:function(){return!this.is_selected()||this.has_payment_nonce()||this.using_payment_token()?s("#place_order").show():s("#place_order").hide()}},{key:"verify_form",value:function(){var e=_get(i.prototype.__proto__||Object.getPrototypeOf(i.prototype),"verify_form",this).call(this);return this.has_payment_nonce()||this.using_payment_token()||this.render_error(this.must_login_message),e}},{key:"handle_payment_error",value:function(e){return _get(i.prototype.__proto__||Object.getPrototypeOf(i.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(i.prototype.__proto__||Object.getPrototypeOf(i.prototype),"setup_braintree",this).call(this),s("input.js-wc-braintree-paypal-tokenize-payment-method").prop("disabled",!1),this.toggle_order_button())}},{key:"do_integration_ready",value:function(){var e,t=this;return c(this,n),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 s("#wc_braintree_paypal_container").css({width:"100%"}),t.unblock_ui()}).catch(function(e){return t.log("Could not render the PayPal button. "+e.message,e),t.hide_integration_ui(),t.unblock_ui()}))}},{key:"render_button",value:function(e,t,n){var r,i=this;return s(n).html(""),r=this.is_paypal_credit_enabled&&"USD"===this.get_store_currency()?{allowed:[paypal.FUNDING.CREDIT]}:{disallowed:[paypal.FUNDING.CREDIT]},r={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 i.on_authorize(e,t)},onError:function(e){return i.handle_integration_error(e)}},paypal.Button.render(r,n)}},{key:"button_is_pay_now",value:function(){return!s("form#add_payment_method").length}},{key:"get_button_styles",value:function(){return this.button_styles}},{key:"on_authorize",value:function(e){var t=this;return c(this,n),this.block_ui(),this.integration.tokenizePayment(e).then(function(e){return t.log("Payment method tokenized.",e),t.set_payment_method(e)}).catch(function(e){return t.handle_payment_error(e),t.unblock_ui()})}},{key:"set_payment_method",value:function(e){return s("input[name=wc_"+this.id+"_payment_nonce]").val(e.nonce),s("#wc_braintree_paypal_container").html(this.get_linked_account_html(e.details)),this.is_single_use()&&s("input.js-wc-braintree-paypal-tokenize-payment-method").prop("disabled",!0),s("#place_order").show(),this.form.submit()}},{key:"handle_saved_payment_methods",value:function(){var t=this;return _get(i.prototype.__proto__||Object.getPrototypeOf(i.prototype),"handle_saved_payment_methods",this).call(this),s("input.js-wc-braintree-paypal-tokenize-payment-method").change(function(e){if(null!=t.integration&&s(e.target).is(":visible"))return t.block_ui(),t.do_integration_ready()}).change()}},{key:"get_linked_account_html",value:function(e){var t;return c(this,n),t=s("<div class='wc-"+this.id_dasherized+"-account'></div>"),null!=e.firstName&&null!=e.lastName&&t.append("<span class='name'>"+e.firstName+" "+e.lastName+"</span>"),t.append("<span class='email'>"+e.email+"</span>"),t.append("<a href='#' class='cancel'>Cancel</a>"),t}},{key:"is_single_use",value:function(){var e=s("input[name=wc-braintree-paypal-tokenize-payment-method]");return 0===e.length||("checkbox"===e.attr("type")?!e.is(":checked"):!e.val())}},{key:"get_order_amount",value:function(){return s("input[name=wc_braintree_paypal_amount]").val()}},{key:"get_store_currency",value:function(){return s("input[name=wc_braintree_paypal_currency]").val()}},{key:"get_store_locale",value:function(){return s("input[name=wc_braintree_paypal_locale]").val()}},{key:"is_sdk_ready",value:function(){return _get(i.prototype.__proto__||Object.getPrototypeOf(i.prototype),"is_sdk_ready",this).call(this)&&"undefined"!=typeof paypal&&null!==paypal}}]),i),s(document.body).trigger("wc_braintree_paypal_payment_form_handler_loaded"),window.WC_Braintree_PayPal_Cart_Handler=(_inherits(o,WC_Braintree_PayPal_Payment_Form_Handler),_createClass(o,[{key:"button_is_pay_now",value:function(){return!1}},{key:"set_payment_method",value:function(e){var t=this;if(null!=e.nonce)return e.wp_nonce=this.set_payment_method_nonce,s.ajax({type:"POST",url:this.cart_handler_url,data:e,dataType:"json"}).done(function(e){if(t.log("Cart response received.",e),null!=e.redirect_url)return window.location=e.redirect_url}).fail(function(e){return t.log("Error setting the PayPal cart data.",e,"error")}).always(function(){return t.unblock_ui()})}},{key:"is_single_use",value:function(){return"1"===s("input[name=wc_braintree_paypal_single_use]").val()}},{key:"has_payment_nonce",value:function(){return!1}}]),o),s(document.body).trigger("wc_braintree_paypal_cart_handler_loaded"),r=window.WC_Braintree_PayPal_Product_Button_Handler=(_inherits(_,WC_Braintree_PayPal_Payment_Form_Handler),_createClass(_,[{key:"handle_product_page",value:function(){return this.product_form={element:s("form.cart"),is_variable:s("form.cart").hasClass("variations_form")},this.should_validate_product_data&&this.product_form.element.on("change",this.validate_product_button),this.product_form.is_variable&&s(document.body).on("woocommerce_variation_has_changed",this.validate_product_button),this.validate_product_button()}},{key:"do_integration_ready",value:function(){if(c(this,r),_get(_.prototype.__proto__||Object.getPrototypeOf(_.prototype),"do_integration_ready",this).call(this),this.is_product_page)return this.validate_product_button()}},{key:"validate_product_button",value:function(){if(c(this,r),this.product_form.is_variable&&this.product_form.element.find(".single_add_to_cart_button").is(".disabled"))this.hide_button();else{if(!this.should_validate_product_data)return this.show_button();this.validate_product_data(this.show_button,this.hide_button)}}},{key:"validate_product_data",value:function(t,n){return c(this,r),s.ajax({type:"POST",url:this.validate_product_url,data:{wp_nonce:this.validate_product_nonce,product_id:s("input[name=wc_braintree_paypal_product_id]").val(),cart_form:s("form.cart").serialize()}}).done(function(e){return(e.data.is_valid?t:n)()}).fail(n)}},{key:"hide_button",value:function(){return s("#wc_braintree_paypal_container").slideUp()}},{key:"show_button",value:function(){return s("#wc_braintree_paypal_container").slideDown()}},{key:"button_is_pay_now",value:function(){return!1}},{key:"set_payment_method",value:function(e){var t=this;if(null!=e.nonce)return(e=e).wp_nonce=this.product_checkout_nonce,e.product_id=s("input[name=wc_braintree_paypal_product_id]").val(),e.cart_form=s("form.cart").serialize(),s.ajax({type:"POST",url:this.product_checkout_url,data:e,dataType:"json"}).done(function(e){if(t.log("Cart response received.",e),null!=e.redirect_url)return window.location=e.redirect_url}).fail(function(e){return t.log("Error setting the PayPal cart data.",e,"error")}).always(function(){return t.unblock_ui()})}},{key:"is_single_use",value:function(){return"1"===s("input[name=wc_braintree_paypal_single_use]").val()}},{key:"has_payment_nonce",value:function(){return!1}}]),_),s(document.body).trigger("wc_braintree_paypal_product_button_handler_loaded")})}).call(void 0);
|
1 |
+
"use strict";var _get=function e(t,n,r){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,n);if(void 0!==i){if("value"in i)return i.value;i=i.get;return void 0!==i?i.call(r):void 0}t=Object.getPrototypeOf(t);if(null!==t)return e(t,n,r)},_createClass=function(){function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}}();function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(function(){function c(e,t){if(!(e instanceof t))throw new Error("Bound instance method accessed before binding")}var u=[].indexOf;jQuery(document).ready(function(s){var e,n,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 i(e){_classCallCheck(this,i);var t=_possibleConstructorReturn(this,(i.__proto__||Object.getPrototypeOf(i)).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}function o(e){_classCallCheck(this,o);var t=_possibleConstructorReturn(this,(o.__proto__||Object.getPrototypeOf(o)).call(this,e));return t.set_payment_method_nonce=e.set_payment_method_nonce,t.cart_handler_url=e.cart_handler_url,t.form=s("form.woocommerce-cart-form"),t.form_ui_selector="",t.setup_braintree(),s(document.body).on("updated_cart_totals",function(){return t.setup_braintree()}),t}function _(e){_classCallCheck(this,_);var t=_possibleConstructorReturn(this,(_.__proto__||Object.getPrototypeOf(_)).call(this,e));return t.do_integration_ready=t.do_integration_ready.bind(t),t.validate_product_button=t.validate_product_button.bind(t),t.validate_product_data=t.validate_product_data.bind(t),t.product_checkout_nonce=e.product_checkout_nonce,t.product_checkout_url=e.product_checkout_url,t.is_product_page=e.is_product_page,t.validate_product_url=e.validate_product_url,t.validate_product_nonce=e.validate_product_nonce,t.should_validate_product_data=e.should_validate_product_data,t.form=s("form.woocommerce-cart-form"),t.form_ui_selector="",t.is_product_page&&t.handle_product_page(),t.setup_braintree(),s(document.body).on("updated_cart_totals",function(){return t.setup_braintree()}),t}return window.WC_Braintree_Payment_Form_Handler=(_createClass(t,[{key:"init",value:function(){return this.is_sdk_ready()?s("form.checkout").length?this.handle_checkout_page():s("form#order_review").length?this.handle_pay_page():s("form#add_payment_method").length?this.handle_add_payment_method_page():void 0:console.error("Braintree SDK is missing.")}},{key:"handle_checkout_page",value:function(){var e=this;return this.form=s("form.checkout"),this.form_ui_selector=".woocommerce-checkout-payment",s(document.body).on("updated_checkout",function(){if(!e.setting_up)return s('iframe[name^="braintree-"]').remove(),e.setup_braintree()}),s(document.body).on("updated_checkout",function(){return e.handle_saved_payment_methods()}),s(document.body).on("checkout_error",function(){return e.handle_checkout_error()}),this.form.on("checkout_place_order_"+this.id,function(){if(e.is_selected())return e.block_ui(),e.verify_form()})}},{key:"handle_checkout_error",value:function(){return this.unblock_ui()}},{key:"handle_pay_page",value:function(){var e=this;return this.form=s("form#order_review"),this.form_ui_selector="#payment",this.handle_saved_payment_methods(),this.setup_braintree(),this.form.submit(function(){if(e.is_selected())return e.block_ui(),e.verify_form()})}},{key:"handle_add_payment_method_page",value:function(){var e=this;return this.form=s("form#add_payment_method"),this.form_ui_selector="#payment",this.setup_braintree(),this.form.submit(function(){if(e.is_selected())return e.block_ui(),e.verify_form()})}},{key:"verify_form",value:function(){return!!this.using_payment_token()||!!this.has_payment_nonce()&&void 0}},{key:"submit_form",value:function(e){return s("input[name=wc_"+this.id+"_payment_nonce]").val(e),this.form.submit()}},{key:"handle_saved_payment_methods",value:function(){var n=this,e=s("div.js-wc-"+this.id_dasherized+"-new-payment-method-form");if(s("input.js-wc-"+this.id_dasherized+"-payment-token").change(function(){return s("input.js-wc-"+n.id_dasherized+"-payment-token:checked").val()?e.slideUp(200):e.slideDown(200)}).change(),s("input#createaccount").change(function(e){var t=s("input.js-wc-"+n.id_dasherized+"-tokenize-payment-method").closest("p.form-row");return s(e.target).is(":checked")?(t.slideDown(),t.next().show()):(t.hide(),t.next().hide())}),!s("input#createaccount").is(":checked"))return s("input#createaccount").change()}},{key:"setup_braintree",value:function(){if(!s("#wc-"+this.id_dasherized+"-account-number-hosted iframe").data("ready"))return this.setting_up=!0,this.block_ui(),s("input[name=wc_"+this.id+"_payment_nonce]").val(""),this.create_client()}},{key:"create_client",value:function(){var r=this;return this.log("Creating client."),this.get_client_token().done(function(e){return e.success?braintree.client.create({authorization:e.data}).then(function(e){return r.client=e,r.log("Client ready."),r.setup_integration()}).catch(function(e){return r.handle_integration_error(e),r.unblock_ui()}):r.handle_integration_error(e.data)}).fail(function(e,t,n){return r.handle_integration_error({message:"Could not retrieve the client token via AJAX: "+n}),r.unblock_ui()})}},{key:"get_client_token",value:function(){this.id;var e={action:"wc_"+this.id+"_get_client_token",nonce:this.client_token_nonce};return s.post(this.ajax_url,e)}},{key:"setup_integration",value:function(){var t=this;return this.log("Creating integration."),this.get_integration_class().create(this.get_integration_options()).then(function(e){return t.integration=e,t.show_integration_ui(),s("#wc-"+t.id_dasherized+"-account-number-hosted iframe").data("ready",!0),t.do_integration_ready(),s(document).trigger("wc_"+t.id+"_integration_ready",t.integration),t.log("Integration ready."),t.setting_up=!1}).catch(function(e){return t.handle_integration_error(e),t.unblock_ui(),t.setting_up=!1})}},{key:"refresh_braintree",value:function(){var e=this;if(null!=this.integration&&!this.refreshing&&!this.setting_up)return this.log("Refreshing integration."),this.refreshing=!0,this.block_ui(),this.integration.teardown(function(){return e.integration=null,e.refreshing=!1,e.setup_braintree()})}},{key:"teardown_braintree",value:function(){var e=this;if(null!=this.integration)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 s(".woocommerce-error, .woocommerce-message").remove(),this.form.prepend('<div class="woocommerce-error">'+e+"</div>").removeClass("processing").unblock(),s("html, body").animate({scrollTop:this.form.offset().top-100},1e3),s("input[name=wc_"+this.id+"_payment_nonce]").val(""),this.form.trigger("wc_"+this.id+"_rendered_error"),s(document.body).trigger("checkout_error"),this.unblock_ui()}},{key:"get_user_message",value:function(){return this.payment_error_message}},{key:"show_integration_ui",value:function(){if(s("div.js-wc-"+this.id_dasherized+"-new-payment-method-form").find(".woocommerce-error").remove(),s("input#createaccount").length&&s("input#createaccount").is(":checked"))return s("div.js-wc-"+this.id_dasherized+"-new-payment-method-form").find(".form-row").show()}},{key:"hide_integration_ui",value:function(){return s("div.js-wc-"+this.id_dasherized+"-new-payment-method-form").prepend('<div class="woocommerce-error">'+this.integration_error_message+"</div>"),s("div.js-wc-"+this.id_dasherized+"-new-payment-method-form").find(".form-row").hide()}},{key:"block_ui",value:function(){return s(this.form_ui_selector).block({message:null,overlayCSS:{background:"#fff",opacity:.6}})}},{key:"unblock_ui",value:function(){return s(this.form_ui_selector).unblock()}},{key:"is_selected",value:function(){return this.get_selected_gateway_id()===this.id}},{key:"is_sdk_ready",value:function(){return"undefined"!=typeof braintree&&null!==braintree&&null!=braintree.client&&null!=this.get_integration_class()}},{key:"has_payment_nonce",value:function(){return this.form.find("input[name=wc_"+this.id+"_payment_nonce]").val()}},{key:"using_payment_token",value:function(){return this.form.find("input.js-wc-"+this.id_dasherized+"-payment-token:checked").val()}},{key:"get_selected_gateway_id",value:function(){return this.form.find("input[name=payment_method]:checked").val()}},{key:"log",value:function(e,t){t=1<arguments.length&&void 0!==t?t:null;if(this.debug)return console.log(this.name+": "+e),t?console.log(t):void 0}}]),t),s(document.body).trigger("wc_braintree_payment_form_handler_loaded"),e=window.WC_Braintree_Credit_Card_Payment_Form_Handler=(_inherits(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),s("input[name=wc_"+this.id+"_payment_nonce]").val(""),s("input[name=wc-"+this.id_dasherized+"-card-type]").val(""),s("input[name=wc-"+this.id_dasherized+"-3d-secure-verified]").val(0)}},{key:"verify_form",value:function(){var e;return this.has_payment_nonce()||!this.csc_required&&this.using_payment_token()?(e=s("input.js-wc-braintree-credit-card-payment-token:checked"),this.should_verify_3d_secure_token(e)?(this.verify_3d_secure(e.data("nonce"),null,e),!1):_get(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={client:this.client,fields:{number:{selector:"#wc-braintree-credit-card-account-number-hosted",placeholder:s("#wc-braintree-credit-card-account-number-hosted").data("placeholder")},cvv:{selector:"#wc-braintree-credit-card-csc-hosted",placeholder:s("#wc-braintree-credit-card-csc-hosted").data("placeholder")},expirationDate:{selector:"#wc-braintree-credit-card-expiry-hosted",placeholder:s("#wc-braintree-credit-card-expiry-hosted").data("placeholder")}},styles:this.hosted_fields_styles};return this.csc_required&&this.using_payment_token()&&(delete e.fields.number,delete e.fields.expirationDate),this.csc_required||delete e.fields.cvv,e}},{key:"get_integration_class",value:function(){return braintree.hostedFields}},{key:"do_integration_ready",value:function(){var t=this;return this.integration.on("cardTypeChange",function(e){return t.on_card_type_change(e)}),!this.csc_required&&s("input.js-wc-braintree-credit-card-payment-token:checked").val()&&this.teardown_braintree(),this.unblock_ui()}},{key:"handle_saved_payment_methods",value:function(){var e,t,n=this;return _get(a.prototype.__proto__||Object.getPrototypeOf(a.prototype),"handle_saved_payment_methods",this).call(this),t=s("div.js-wc-braintree-credit-card-new-payment-method-form"),e=s("div.wc-braintree-hosted-field-card-csc-parent"),s("input.js-wc-braintree-credit-card-payment-token").change(function(){return s("input.js-wc-braintree-credit-card-payment-token:checked").val()?n.csc_required&&e.hasClass("form-row-last")?(e.removeClass("form-row-last").addClass("form-row-first"),t.after(e),n.refresh_braintree()):void 0:(n.csc_required&&e.hasClass("form-row-first")&&(e.removeClass("form-row-first").addClass("form-row-last"),t.find("div.wc-braintree-hosted-field-card-expiry-parent").after(e)),n.refresh_braintree())}).change()}},{key:"get_user_message",value:function(e){var t,n,r,i=[];if("CUSTOMER"===e.type)switch(e.code){case"HOSTED_FIELDS_FIELDS_EMPTY":this.csc_required&&i.push(this.params.cvv_missing),this.using_payment_token()||(i.push(this.params.card_number_missing),i.push(this.params.card_exp_date_invalid));break;case"HOSTED_FIELDS_FIELDS_INVALID":if(null!=e.details)for(t=0,n=(r=e.details.invalidFieldKeys).length;t<n;t++)switch(r[t]){case"number":i.push(this.params.card_number_invalid);break;case"cvv":i.push(this.params.cvv_length_invalid);break;case"expirationDate":i.push(this.params.card_exp_date_invalid)}}else"NETWORK"===e.type&&null!=e.details.originalError.error.message&&(e=e.details.originalError.error.message,/given name format is invalid/.test(e)&&i.push(this.params.first_name_unsupported_characters),/surname format is invalid/.test(e)&&i.push(this.params.last_name_unsupported_characters));return i.length?i.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;if(null!=e.cards)return(t=s("#wc-braintree-credit-card-account-number-hosted")).attr("class",function(e,t){return t.replace(/(^|\s)card-type-\S+/g,"")}),e.cards.length?1===e.cards.length?(n=e.cards[0],s("input[name=wc-"+this.id_dasherized+"-card-type]").val(n.type),null!=n.type&&(e=n.type,0<=u.call(this.enabled_card_types,e))?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()?(s("input[name=wc-"+this.id_dasherized+"-3d-secure-enabled]").val(1),this.threeDSecure&&this.threeDSecure.teardown(),braintree.threeDSecure.create({version:2,client:this.client}).then(function(e){return t.threeDSecure=e,s(document.body).on("click","#wc-braintree-credit-card-3dsecure-container",function(e){return s(e.currentTarget).fadeOut(200),t.threeDSecure.cancelVerifyCard(),t.unblock_ui()}),_get(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=e.details.cardType;return this.is_3d_secure_enabled()&&"CreditCard"===e.type&&0<=u.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=this,i=2<arguments.length&&void 0!==n?n:null,a=s("#billing_state").val(),o=s("#billing_country").val(),_=s("#shipping_state").val(),n=s("#shipping_country").val(),o=s("input[name=billing_first_name]").val()?{givenName:s("input[name=billing_first_name]").val().latinise(),surname:s("input[name=billing_last_name]").val().latinise(),phoneNumber:s("input[name=billing_phone]").val(),streetAddress:s("input[name=billing_address_1]").val(),extendedAddress:s("input[name=billing_address_2]").val(),locality:s("#billing_city").val(),region:"string"==typeof a&&a.length<=2?a:"",postalCode:s("input[name=billing_postcode]").val(),countryCodeAlpha2:"string"==typeof o&&o.length<=2?o:""}:{},n=s("input[name=shipping_first_name]").val()?{shippingGivenName:s("input[name=shipping_first_name]").val().latinise(),shippingSurname:s("input[name=shipping_last_name]").val().latinise(),shippingAddress:{streetAddress:s("input[name=shipping_address_1]").val(),extendedAddress:s("input[name=shipping_address_2]").val(),locality:s("input[name=shipping_city]").val(),region:"string"==typeof _&&_.length<=2?_:"",postalCode:s("input[name=shipping_postcode]").val(),countryCodeAlpha2:"string"==typeof n&&n.length<=2?n:""}}:{},n={nonce:e,amount:s("input[name=wc-"+this.id_dasherized+"-3d-secure-order-total]").val(),email:s("input[name=billing_email]").val(),billingAddress:o,additionalInformation:n,onLookupComplete:function(e,t){r.log("3D Secure lookup complete.",e);try{return t()}catch(e){return r.handle_payment_error(e)}}};return"1"===s("input[name=wc-"+this.id_dasherized+"-cart-contains-subscription]").val()&&(n.challengeRequested=!0),this.log("Verifying 3D Secure.",n),this.threeDSecure.verifyCard(n).then(function(e){return r.log("3D Secure response received.",e),r.threeds.liability_shift_always_required&&!e.liabilityShifted?r.render_error(r.threeds.failure_message):(null!=i&&i.data("verified",!0),s("input[name=wc-"+r.id_dasherized+"-3d-secure-verified]").val(1),r.submit_form(e.nonce))}).catch(function(e){return r.handle_payment_error(e)})}},{key:"show_integration_ui",value:function(){return c(this,e),_get(a.prototype.__proto__||Object.getPrototypeOf(a.prototype),"show_integration_ui",this).call(this),s(".wc-braintree-hosted-field-parent").show()}},{key:"hide_integration_ui",value:function(){return c(this,e),_get(a.prototype.__proto__||Object.getPrototypeOf(a.prototype),"hide_integration_ui",this).call(this),s(".wc-braintree-hosted-field-parent").hide()}}]),a),s(document.body).trigger("wc_braintree_credit_card_payment_form_handler_loaded"),n=window.WC_Braintree_PayPal_Payment_Form_Handler=(_inherits(i,WC_Braintree_Payment_Form_Handler),_createClass(i,[{key:"init",value:function(){var t=this;return _get(i.prototype.__proto__||Object.getPrototypeOf(i.prototype),"init",this).call(this),s("input[name=wc_"+this.id+"_payment_nonce]").val(this.cart_payment_nonce),s(document.body).on("click",'input[name="payment_method"], input.js-wc-braintree-paypal-payment-token',function(){return t.toggle_order_button()}),s(document.body).on("payment_method_selected",function(){return t.toggle_order_button()}),s(document.body).on("click",".wc-braintree-paypal-account .cancel",function(e){return e.preventDefault(),s(e.currentTarget).parent().remove(),t.setup_braintree()})}},{key:"toggle_order_button",value:function(){return!this.is_selected()||this.has_payment_nonce()||this.using_payment_token()?s("#place_order").show():s("#place_order").hide()}},{key:"verify_form",value:function(){var e=_get(i.prototype.__proto__||Object.getPrototypeOf(i.prototype),"verify_form",this).call(this);return this.has_payment_nonce()||this.using_payment_token()||this.render_error(this.must_login_message),e}},{key:"handle_payment_error",value:function(e){return _get(i.prototype.__proto__||Object.getPrototypeOf(i.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(i.prototype.__proto__||Object.getPrototypeOf(i.prototype),"setup_braintree",this).call(this),s("input.js-wc-braintree-paypal-tokenize-payment-method").prop("disabled",!1),this.toggle_order_button())}},{key:"do_integration_ready",value:function(){var e,t=this;return c(this,n),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 s("#wc_braintree_paypal_container").css({width:"100%"}),t.unblock_ui()}).catch(function(e){return t.log("Could not render the PayPal button. "+e.message,e),t.hide_integration_ui(),t.unblock_ui()}))}},{key:"render_button",value:function(e,t,n){var r,i=this;return s(n).html(""),r=this.is_paypal_credit_enabled&&"USD"===this.get_store_currency()?{allowed:[paypal.FUNDING.CREDIT]}:{disallowed:[paypal.FUNDING.CREDIT]},r={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 i.on_authorize(e,t)},onError:function(e){return i.handle_integration_error(e)}},paypal.Button.render(r,n)}},{key:"button_is_pay_now",value:function(){return!s("form#add_payment_method").length}},{key:"get_button_styles",value:function(){return this.button_styles}},{key:"on_authorize",value:function(e){var t=this;return c(this,n),this.block_ui(),this.integration.tokenizePayment(e).then(function(e){return t.log("Payment method tokenized.",e),t.set_payment_method(e)}).catch(function(e){return t.handle_payment_error(e),t.unblock_ui()})}},{key:"set_payment_method",value:function(e){return s("input[name=wc_"+this.id+"_payment_nonce]").val(e.nonce),s("#wc_braintree_paypal_container").html(this.get_linked_account_html(e.details)),this.is_single_use()&&s("input.js-wc-braintree-paypal-tokenize-payment-method").prop("disabled",!0),s("#place_order").show(),this.form.submit()}},{key:"handle_saved_payment_methods",value:function(){var t=this;return _get(i.prototype.__proto__||Object.getPrototypeOf(i.prototype),"handle_saved_payment_methods",this).call(this),s("input.js-wc-braintree-paypal-tokenize-payment-method").change(function(e){if(null!=t.integration&&s(e.target).is(":visible"))return t.block_ui(),t.do_integration_ready()}).change()}},{key:"get_linked_account_html",value:function(e){var t;return c(this,n),t=s("<div class='wc-"+this.id_dasherized+"-account'></div>"),null!=e.firstName&&null!=e.lastName&&t.append("<span class='name'>"+e.firstName+" "+e.lastName+"</span>"),t.append("<span class='email'>"+e.email+"</span>"),t.append("<a href='#' class='cancel'>Cancel</a>"),t}},{key:"is_single_use",value:function(){var e=s("input[name=wc-braintree-paypal-tokenize-payment-method]");return 0===e.length||("checkbox"===e.attr("type")?!e.is(":checked"):!e.val())}},{key:"get_order_amount",value:function(){return s("input[name=wc_braintree_paypal_amount]").val()}},{key:"get_store_currency",value:function(){return s("input[name=wc_braintree_paypal_currency]").val()}},{key:"get_store_locale",value:function(){return s("input[name=wc_braintree_paypal_locale]").val()}},{key:"is_sdk_ready",value:function(){return _get(i.prototype.__proto__||Object.getPrototypeOf(i.prototype),"is_sdk_ready",this).call(this)&&"undefined"!=typeof paypal&&null!==paypal}}]),i),s(document.body).trigger("wc_braintree_paypal_payment_form_handler_loaded"),window.WC_Braintree_PayPal_Cart_Handler=(_inherits(o,WC_Braintree_PayPal_Payment_Form_Handler),_createClass(o,[{key:"button_is_pay_now",value:function(){return!1}},{key:"set_payment_method",value:function(e){var t=this;if(null!=e.nonce)return e.wp_nonce=this.set_payment_method_nonce,s.ajax({type:"POST",url:this.cart_handler_url,data:e,dataType:"json"}).done(function(e){if(t.log("Cart response received.",e),null!=e.redirect_url)return window.location=e.redirect_url}).fail(function(e){return t.log("Error setting the PayPal cart data.",e,"error")}).always(function(){return t.unblock_ui()})}},{key:"is_single_use",value:function(){return"1"===s("input[name=wc_braintree_paypal_single_use]").val()}},{key:"has_payment_nonce",value:function(){return!1}}]),o),s(document.body).trigger("wc_braintree_paypal_cart_handler_loaded"),r=window.WC_Braintree_PayPal_Product_Button_Handler=(_inherits(_,WC_Braintree_PayPal_Payment_Form_Handler),_createClass(_,[{key:"handle_product_page",value:function(){return this.product_form={element:s("form.cart"),is_variable:s("form.cart").hasClass("variations_form")},this.should_validate_product_data&&this.product_form.element.on("change",this.validate_product_button),this.product_form.is_variable&&s(document.body).on("woocommerce_variation_has_changed",this.validate_product_button),this.validate_product_button()}},{key:"do_integration_ready",value:function(){if(c(this,r),_get(_.prototype.__proto__||Object.getPrototypeOf(_.prototype),"do_integration_ready",this).call(this),this.is_product_page)return this.validate_product_button()}},{key:"validate_product_button",value:function(){if(c(this,r),this.product_form.is_variable&&this.product_form.element.find(".single_add_to_cart_button").is(".disabled"))this.hide_button();else{if(!this.should_validate_product_data)return this.show_button();this.validate_product_data(this.show_button,this.hide_button)}}},{key:"validate_product_data",value:function(t,n){return c(this,r),s.ajax({type:"POST",url:this.validate_product_url,data:{wp_nonce:this.validate_product_nonce,product_id:s("input[name=wc_braintree_paypal_product_id]").val(),cart_form:s("form.cart").serialize()}}).done(function(e){return(e.data.is_valid?t:n)()}).fail(n)}},{key:"hide_button",value:function(){return s("#wc_braintree_paypal_container").slideUp()}},{key:"show_button",value:function(){return s("#wc_braintree_paypal_container").slideDown()}},{key:"button_is_pay_now",value:function(){return!1}},{key:"set_payment_method",value:function(e){var t=this;if(null!=e.nonce)return(e=e).wp_nonce=this.product_checkout_nonce,e.product_id=s("input[name=wc_braintree_paypal_product_id]").val(),e.cart_form=s("form.cart").serialize(),s.ajax({type:"POST",url:this.product_checkout_url,data:e,dataType:"json"}).done(function(e){if(t.log("Cart response received.",e),null!=e.redirect_url)return window.location=e.redirect_url}).fail(function(e){return t.log("Error setting the PayPal cart data.",e,"error")}).always(function(){return t.unblock_ui()})}},{key:"is_single_use",value:function(){return"1"===s("input[name=wc_braintree_paypal_single_use]").val()}},{key:"has_payment_nonce",value:function(){return!1}}]),_),s(document.body).trigger("wc_braintree_paypal_product_button_handler_loaded")})}).call(void 0);
|
class-wc-braintree.php
CHANGED
@@ -73,7 +73,7 @@ class WC_Braintree extends Framework\SV_WC_Payment_Gateway_Plugin {
|
|
73 |
|
74 |
|
75 |
/** plugin version number */
|
76 |
-
const VERSION = '2.4.
|
77 |
|
78 |
/** Braintree JS SDK version */
|
79 |
const BRAINTREE_JS_SDK_VERSION = '3.48.0';
|
73 |
|
74 |
|
75 |
/** plugin version number */
|
76 |
+
const VERSION = '2.4.3';
|
77 |
|
78 |
/** Braintree JS SDK version */
|
79 |
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 Braintree for WooCommerce Payment Gateway package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: Braintree for WooCommerce Payment Gateway 2.4.
|
6 |
"Report-Msgid-Bugs-To: "
|
7 |
"https://woocommerce.com/my-account/marketplace-ticket-form/\n"
|
8 |
-
"POT-Creation-Date: 2020-10-14
|
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 Braintree for WooCommerce Payment Gateway package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: Braintree for WooCommerce Payment Gateway 2.4.3\n"
|
6 |
"Report-Msgid-Bugs-To: "
|
7 |
"https://woocommerce.com/my-account/marketplace-ticket-form/\n"
|
8 |
+
"POT-Creation-Date: 2020-10-22 14:38:01+00:00\n"
|
9 |
"MIME-Version: 1.0\n"
|
10 |
"Content-Type: text/plain; charset=utf-8\n"
|
11 |
"Content-Transfer-Encoding: 8bit\n"
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Tags: ecommerce, e-commerce, commerce, woothemes, wordpress ecommerce, store, sa
|
|
4 |
Requires at least: 4.4
|
5 |
Tested up to: 5.5.1
|
6 |
Requires PHP: 5.4
|
7 |
-
Stable tag: 2.4.
|
8 |
License: GPLv3
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
@@ -107,7 +107,10 @@ If not, please get in touch with us through the [plugin forums](https://wordpres
|
|
107 |
|
108 |
== Changelog ==
|
109 |
|
110 |
-
= 2020.10.
|
|
|
|
|
|
|
111 |
* Fix - Address a possible race condition when loading Braintree device data scripts in front end
|
112 |
|
113 |
= 2020.09.28 - version 2.4.1 =
|
4 |
Requires at least: 4.4
|
5 |
Tested up to: 5.5.1
|
6 |
Requires PHP: 5.4
|
7 |
+
Stable tag: 2.4.3
|
8 |
License: GPLv3
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
107 |
|
108 |
== Changelog ==
|
109 |
|
110 |
+
= 2020.10.22 - version 2.4.3 =
|
111 |
+
* Fix - Fix a checkout error that removes the CSC field when a saved payment method is selected and the billing country is changed
|
112 |
+
|
113 |
+
= 2020.10.14 - version 2.4.2 =
|
114 |
* Fix - Address a possible race condition when loading Braintree device data scripts in front end
|
115 |
|
116 |
= 2020.09.28 - version 2.4.1 =
|
vendor/autoload.php
CHANGED
@@ -4,4 +4,4 @@
|
|
4 |
|
5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
|
7 |
-
return
|
4 |
|
5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
|
7 |
+
return ComposerAutoloaderInit4778c71b77d539e115031bbb3e913571::getLoader();
|
vendor/composer/ClassLoader.php
CHANGED
@@ -60,7 +60,7 @@ class ClassLoader
|
|
60 |
public function getPrefixes()
|
61 |
{
|
62 |
if (!empty($this->prefixesPsr0)) {
|
63 |
-
return call_user_func_array('array_merge',
|
64 |
}
|
65 |
|
66 |
return array();
|
60 |
public function getPrefixes()
|
61 |
{
|
62 |
if (!empty($this->prefixesPsr0)) {
|
63 |
+
return call_user_func_array('array_merge', $this->prefixesPsr0);
|
64 |
}
|
65 |
|
66 |
return array();
|
vendor/composer/autoload_real.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
-
class
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
@@ -22,15 +22,15 @@ class ComposerAutoloaderInitad72e62bb311e6a4633d357158916ed2
|
|
22 |
return self::$loader;
|
23 |
}
|
24 |
|
25 |
-
spl_autoload_register(array('
|
26 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
27 |
-
spl_autoload_unregister(array('
|
28 |
|
29 |
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
30 |
if ($useStaticLoader) {
|
31 |
require_once __DIR__ . '/autoload_static.php';
|
32 |
|
33 |
-
call_user_func(\Composer\Autoload\
|
34 |
} else {
|
35 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
36 |
foreach ($map as $namespace => $path) {
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
+
class ComposerAutoloaderInit4778c71b77d539e115031bbb3e913571
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
22 |
return self::$loader;
|
23 |
}
|
24 |
|
25 |
+
spl_autoload_register(array('ComposerAutoloaderInit4778c71b77d539e115031bbb3e913571', 'loadClassLoader'), true, true);
|
26 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
27 |
+
spl_autoload_unregister(array('ComposerAutoloaderInit4778c71b77d539e115031bbb3e913571', 'loadClassLoader'));
|
28 |
|
29 |
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
30 |
if ($useStaticLoader) {
|
31 |
require_once __DIR__ . '/autoload_static.php';
|
32 |
|
33 |
+
call_user_func(\Composer\Autoload\ComposerStaticInit4778c71b77d539e115031bbb3e913571::getInitializer($loader));
|
34 |
} else {
|
35 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
36 |
foreach ($map as $namespace => $path) {
|
vendor/composer/autoload_static.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
-
class
|
8 |
{
|
9 |
public static $prefixLengthsPsr4 = array (
|
10 |
'B' =>
|
@@ -33,9 +33,9 @@ class ComposerStaticInitad72e62bb311e6a4633d357158916ed2
|
|
33 |
public static function getInitializer(ClassLoader $loader)
|
34 |
{
|
35 |
return \Closure::bind(function () use ($loader) {
|
36 |
-
$loader->prefixLengthsPsr4 =
|
37 |
-
$loader->prefixDirsPsr4 =
|
38 |
-
$loader->prefixesPsr0 =
|
39 |
|
40 |
}, null, ClassLoader::class);
|
41 |
}
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
+
class ComposerStaticInit4778c71b77d539e115031bbb3e913571
|
8 |
{
|
9 |
public static $prefixLengthsPsr4 = array (
|
10 |
'B' =>
|
33 |
public static function getInitializer(ClassLoader $loader)
|
34 |
{
|
35 |
return \Closure::bind(function () use ($loader) {
|
36 |
+
$loader->prefixLengthsPsr4 = ComposerStaticInit4778c71b77d539e115031bbb3e913571::$prefixLengthsPsr4;
|
37 |
+
$loader->prefixDirsPsr4 = ComposerStaticInit4778c71b77d539e115031bbb3e913571::$prefixDirsPsr4;
|
38 |
+
$loader->prefixesPsr0 = ComposerStaticInit4778c71b77d539e115031bbb3e913571::$prefixesPsr0;
|
39 |
|
40 |
}, null, ClassLoader::class);
|
41 |
}
|
vendor/skyverge/wc-plugin-framework/woocommerce/payment-gateway/assets/js/frontend/sv-wc-payment-gateway-payment-form.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
/* WooCommerce SkyVerge Payment Gateway Framework Payment Form CoffeeScript Version 4.3.0-beta Copyright (c) 2014-2020, SkyVerge, Inc. Licensed under the GNU General Public License v3.0 http://www.gnu.org/licenses/gpl-3.0.html */(function() { var indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; jQuery(document).ready(function($) { "use strict"; window.SV_WC_Payment_Form_Handler_v5_7_1 = (function() { function SV_WC_Payment_Form_Handler_v5_7_1(args) { this.id = args.id; this.id_dasherized = args.id_dasherized; this.plugin_id = args.plugin_id; this.type = args.type; this.csc_required = args.csc_required; this.csc_required_for_tokens = args.csc_required_for_tokens; this.enabled_card_types = args.enabled_card_types; if ($('form.checkout').length) { this.form = $('form.checkout'); this.handle_checkout_page(); } else if ($('form#order_review').length) { this.form = $('form#order_review'); this.handle_pay_page(); } else if ($('form#add_payment_method').length) { this.form = $('form#add_payment_method'); this.handle_add_payment_method_page(); } else { console.log('No payment form found!'); return; } this.params = window["sv_wc_payment_gateway_payment_form_params"]; if (this.type === 'echeck') { this.form.on('click', '.js-sv-wc-payment-gateway-echeck-form-check-hint, .js-sv-wc-payment-gateway-echeck-form-sample-check', (function(_this) { return function() { return _this.handle_sample_check_hint(); }; })(this)); } $(document).trigger('sv_wc_payment_form_handler_init', { id: this.id, instance: this }); } SV_WC_Payment_Form_Handler_v5_7_1.prototype.handle_checkout_page = function() { if (this.type === 'credit-card') { $(document.body).on('updated_checkout', (function(_this) { return function() { return _this.format_credit_card_inputs(); }; })(this)); } $(document.body).on('updated_checkout', (function(_this) { return function() { return _this.set_payment_fields(); }; })(this)); $(document.body).on('updated_checkout', (function(_this) { return function() { return _this.handle_saved_payment_methods(); }; })(this)); return this.form.on("checkout_place_order_" + this.id, (function(_this) { return function() { return _this.validate_payment_data(); }; })(this)); }; SV_WC_Payment_Form_Handler_v5_7_1.prototype.handle_pay_page = function() { this.set_payment_fields(); if (this.type === 'credit-card') { this.format_credit_card_inputs(); } this.handle_saved_payment_methods(); return this.form.submit((function(_this) { return function() { if ($('#order_review input[name=payment_method]:checked').val() === _this.id) { return _this.validate_payment_data(); } }; })(this)); }; SV_WC_Payment_Form_Handler_v5_7_1.prototype.handle_add_payment_method_page = function() { this.set_payment_fields(); if (this.type === 'credit-card') { this.format_credit_card_inputs(); } return this.form.submit((function(_this) { return function() { if ($('#add_payment_method input[name=payment_method]:checked').val() === _this.id) { return _this.validate_payment_data(); } }; })(this)); }; SV_WC_Payment_Form_Handler_v5_7_1.prototype.set_payment_fields = function() { var $required_fields; this.payment_fields = $(".payment_method_" + this.id); $required_fields = this.payment_fields.find('.validate-required .input-text'); return $required_fields.each((function(_this) { return function(i, input) { if ($(input).val()) { return false; } return $(input).trigger('input'); }; })(this)); }; SV_WC_Payment_Form_Handler_v5_7_1.prototype.validate_payment_data = function() { var handler, valid; if (this.form.is('.processing')) { return false; } this.saved_payment_method_selected = this.payment_fields.find('.js-sv-wc-payment-gateway-payment-token:checked').val(); valid = this.type === 'credit-card' ? this.validate_card_data() : this.validate_account_data(); handler = $(document.body).triggerHandler('sv_wc_payment_form_valid_payment_data', { payment_form: this, passed_validation: valid }) !== false; return valid && handler; }; SV_WC_Payment_Form_Handler_v5_7_1.prototype.format_credit_card_inputs = function() { var $card_number, $csc, $expiry; $card_number = $('.js-sv-wc-payment-gateway-credit-card-form-account-number').payment('formatCardNumber'); $expiry = $('.js-sv-wc-payment-gateway-credit-card-form-expiry').payment('formatCardExpiry'); $csc = $('.js-sv-wc-payment-gateway-credit-card-form-csc').payment('formatCardCVC'); if ($card_number.val() && $card_number.val().length > 0) { $card_number.trigger('change'); } if ($expiry.val() && $expiry.val().length > 0) { $expiry.trigger('change'); } if ($csc.val() && $csc.val().length > 0) { $csc.trigger('change'); } return $('.js-sv-wc-payment-gateway-credit-card-form-input').on('change paste keyup', (function(_this) { return function() { return _this.do_inline_credit_card_validation(); }; })(this)); }; SV_WC_Payment_Form_Handler_v5_7_1.prototype.do_inline_credit_card_validation = function() { var $card_number, $card_type, $csc, $expiry; $card_number = $('.js-sv-wc-payment-gateway-credit-card-form-account-number'); $expiry = $('.js-sv-wc-payment-gateway-credit-card-form-expiry'); $csc = $('.js-sv-wc-payment-gateway-credit-card-form-csc'); $card_type = $.payment.cardType($card_number.val()); if (indexOf.call(this.enabled_card_types, $card_type) < 0) { $card_number.addClass('invalid-card-type'); } else { $card_number.removeClass('invalid-card-type'); } if ($.payment.validateCardExpiry($expiry.payment('cardExpiryVal'))) { $expiry.addClass('identified'); } else { $expiry.removeClass('identified'); } if ($.payment.validateCardCVC($csc.val())) { return $csc.addClass('identified'); } else { return $csc.removeClass('identified'); } }; SV_WC_Payment_Form_Handler_v5_7_1.prototype.validate_card_data = function() { var account_number, csc, errors, expiry; errors = []; csc = this.payment_fields.find('.js-sv-wc-payment-gateway-credit-card-form-csc').val(); if (csc != null) { if (csc) { if (/\D/.test(csc)) { errors.push(this.params.cvv_digits_invalid); } if (csc.length < 3 || csc.length > 4) { errors.push(this.params.cvv_length_invalid); } } else if (this.csc_required) { if (!this.saved_payment_method_selected || this.csc_required_for_tokens) { errors.push(this.params.cvv_missing); } } } if (!this.saved_payment_method_selected) { account_number = this.payment_fields.find('.js-sv-wc-payment-gateway-credit-card-form-account-number').val(); expiry = $.payment.cardExpiryVal(this.payment_fields.find('.js-sv-wc-payment-gateway-credit-card-form-expiry').val()); account_number = account_number.replace(/-|\s/g, ''); if (!account_number) { errors.push(this.params.card_number_missing); } else { if (account_number.length < 12 || account_number.length > 19) { errors.push(this.params.card_number_length_invalid); } if (/\D/.test(account_number)) { errors.push(this.params.card_number_digits_invalid); } if (!$.payment.validateCardNumber(account_number)) { errors.push(this.params.card_number_invalid); } } if (!$.payment.validateCardExpiry(expiry)) { errors.push(this.params.card_exp_date_invalid); } } if (errors.length > 0) { this.render_errors(errors); return false; } else { this.payment_fields.find('.js-sv-wc-payment-gateway-credit-card-form-account-number').val(account_number); return true; } }; SV_WC_Payment_Form_Handler_v5_7_1.prototype.validate_account_data = function() { var account_number, errors, routing_number; if (this.saved_payment_method_selected) { return true; } errors = []; routing_number = this.payment_fields.find('.js-sv-wc-payment-gateway-echeck-form-routing-number').val(); account_number = this.payment_fields.find('.js-sv-wc-payment-gateway-echeck-form-account-number').val(); if (!routing_number) { errors.push(this.params.routing_number_missing); } else { if (9 !== routing_number.length) { errors.push(this.params.routing_number_length_invalid); } if (/\D/.test(routing_number)) { errors.push(this.params.routing_number_digits_invalid); } } if (!account_number) { errors.push(this.params.account_number_missing); } else { if (account_number.length < 3 || account_number.length > 17) { errors.push(this.params.account_number_length_invalid); } if (/\D/.test(account_number)) { errors.push(this.params.account_number_invalid); } } if (errors.length > 0) { this.render_errors(errors); return false; } else { this.payment_fields.find('.js-sv-wc-payment-gateway-echeck-form-account-number').val(account_number); return true; } }; SV_WC_Payment_Form_Handler_v5_7_1.prototype.render_errors = function(errors) { $('.woocommerce-error, .woocommerce-message').remove(); this.form.prepend('<ul class="woocommerce-error"><li>' + errors.join('</li><li>') + '</li></ul>'); this.form.removeClass('processing').unblock(); this.form.find('.input-text, select').blur(); return $('html, body').animate({ scrollTop: this.form.offset().top - 100 }, 1000); }; SV_WC_Payment_Form_Handler_v5_7_1.prototype.handle_saved_payment_methods = function() { var $csc_field, $new_payment_method_selection, csc_required, csc_required_for_tokens, id_dasherized; id_dasherized = this.id_dasherized; csc_required = this.csc_required; csc_required_for_tokens = this.csc_required_for_tokens; $new_payment_method_selection = $("div.js-wc-" + id_dasherized + "-new-payment-method-form"); $csc_field = $new_payment_method_selection.find('.js-sv-wc-payment-gateway-credit-card-form-csc').closest('.form-row'); $("input.js-wc-" + this.id_dasherized + "-payment-token").change(function() { var tokenized_payment_method_selected; tokenized_payment_method_selected = $("input.js-wc-" + id_dasherized + "-payment-token:checked").val(); if (tokenized_payment_method_selected) { $new_payment_method_selection.slideUp(200); if (csc_required_for_tokens) { $csc_field.removeClass('form-row-last').addClass('form-row-first'); return $new_payment_method_selection.after($csc_field); } } else { $new_payment_method_selection.slideDown(200); if (csc_required_for_tokens) { $csc_field.removeClass('form-row-first').addClass('form-row-last'); return $new_payment_method_selection.find('.js-sv-wc-payment-gateway-credit-card-form-expiry').closest('.form-row').after($csc_field); } } }).change(); $('input#createaccount').change(function() { var $parent_row; $parent_row = $("input.js-wc-" + id_dasherized + "-tokenize-payment-method").closest('p.form-row'); if ($(this).is(':checked')) { $parent_row.slideDown(); return $parent_row.next().show(); } else { $parent_row.hide(); return $parent_row.next().hide(); } }); if (!$('input#createaccount').is(':checked')) { return $('input#createaccount').change(); } }; SV_WC_Payment_Form_Handler_v5_7_1.prototype.handle_sample_check_hint = function() { var $sample_check; $sample_check = this.payment_fields.find('.js-sv-wc-payment-gateway-echeck-form-sample-check'); if ($sample_check.is(":visible")) { return $sample_check.slideUp(); } else { return $sample_check.slideDown(); } }; SV_WC_Payment_Form_Handler_v5_7_1.prototype.block_ui = function() { return this.form.block({ message: null, overlayCSS: { background: '#fff', opacity: 0.6 } }); }; SV_WC_Payment_Form_Handler_v5_7_1.prototype.unblock_ui = function() { return this.form.unblock(); }; return SV_WC_Payment_Form_Handler_v5_7_1; })(); return $(document.body).trigger("sv_wc_payment_form_handler_v5_7_1_loaded"); });}).call(this);
|
1 |
+
/* WooCommerce SkyVerge Payment Gateway Framework Payment Form CoffeeScript Version 4.3.0-beta Copyright (c) 2014-2020, SkyVerge, Inc. Licensed under the GNU General Public License v3.0 http://www.gnu.org/licenses/gpl-3.0.html */(function() { var indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; jQuery(document).ready(function($) { console.log( '{AC} - ready' ); "use strict"; window.SV_WC_Payment_Form_Handler_v5_7_1 = (function() { function SV_WC_Payment_Form_Handler_v5_7_1(args) { this.id = args.id; this.id_dasherized = args.id_dasherized; this.plugin_id = args.plugin_id; this.type = args.type; this.csc_required = args.csc_required; this.csc_required_for_tokens = args.csc_required_for_tokens; this.enabled_card_types = args.enabled_card_types; if ($('form.checkout').length) { this.form = $('form.checkout'); this.handle_checkout_page(); } else if ($('form#order_review').length) { this.form = $('form#order_review'); this.handle_pay_page(); } else if ($('form#add_payment_method').length) { this.form = $('form#add_payment_method'); this.handle_add_payment_method_page(); } else { console.log('No payment form found!'); return; } this.params = window["sv_wc_payment_gateway_payment_form_params"]; if (this.type === 'echeck') { this.form.on('click', '.js-sv-wc-payment-gateway-echeck-form-check-hint, .js-sv-wc-payment-gateway-echeck-form-sample-check', (function(_this) { return function() { return _this.handle_sample_check_hint(); }; })(this)); } $(document).trigger('sv_wc_payment_form_handler_init', { id: this.id, instance: this }); } SV_WC_Payment_Form_Handler_v5_7_1.prototype.handle_checkout_page = function() { console.log( '{AC} - checkout' ); if (this.type === 'credit-card') { $(document.body).on('updated_checkout', (function(_this) { return function() { return _this.format_credit_card_inputs(); }; })(this)); } $(document.body).on('updated_checkout', (function(_this) { return function() { return _this.set_payment_fields(); }; })(this)); $(document.body).on('updated_checkout', (function(_this) { return function() { return _this.handle_saved_payment_methods(); }; })(this)); return this.form.on("checkout_place_order_" + this.id, (function(_this) { return function() { return _this.validate_payment_data(); }; })(this)); }; SV_WC_Payment_Form_Handler_v5_7_1.prototype.handle_pay_page = function() { console.log( '{AC} - handle_pay_page' ); this.set_payment_fields(); if (this.type === 'credit-card') { this.format_credit_card_inputs(); } this.handle_saved_payment_methods(); return this.form.submit((function(_this) { return function() { if ($('#order_review input[name=payment_method]:checked').val() === _this.id) { return _this.validate_payment_data(); } }; })(this)); }; SV_WC_Payment_Form_Handler_v5_7_1.prototype.handle_add_payment_method_page = function() { console.log( '{AC} - handle_add_payment_method_page' ); this.set_payment_fields(); if (this.type === 'credit-card') { this.format_credit_card_inputs(); } return this.form.submit((function(_this) { return function() { if ($('#add_payment_method input[name=payment_method]:checked').val() === _this.id) { return _this.validate_payment_data(); } }; })(this)); }; SV_WC_Payment_Form_Handler_v5_7_1.prototype.set_payment_fields = function() { console.log( '{AC} - set_payment_fields' ); var $required_fields; this.payment_fields = $(".payment_method_" + this.id); $required_fields = this.payment_fields.find('.validate-required .input-text'); return $required_fields.each((function(_this) { return function(i, input) { if ($(input).val()) { return false; } return $(input).trigger('input'); }; })(this)); }; SV_WC_Payment_Form_Handler_v5_7_1.prototype.validate_payment_data = function() { console.log( '{AC} - validate_payment_data' ); var handler, valid; if (this.form.is('.processing')) { return false; } this.saved_payment_method_selected = this.payment_fields.find('.js-sv-wc-payment-gateway-payment-token:checked').val(); valid = this.type === 'credit-card' ? this.validate_card_data() : this.validate_account_data(); handler = $(document.body).triggerHandler('sv_wc_payment_form_valid_payment_data', { payment_form: this, passed_validation: valid }) !== false; return valid && handler; }; SV_WC_Payment_Form_Handler_v5_7_1.prototype.format_credit_card_inputs = function() { console.log( '{AC} - format_credit_card_inputs' ); var $card_number, $csc, $expiry; $card_number = $('.js-sv-wc-payment-gateway-credit-card-form-account-number').payment('formatCardNumber'); $expiry = $('.js-sv-wc-payment-gateway-credit-card-form-expiry').payment('formatCardExpiry'); $csc = $('.js-sv-wc-payment-gateway-credit-card-form-csc').payment('formatCardCVC'); if ($card_number.val() && $card_number.val().length > 0) { $card_number.trigger('change'); } if ($expiry.val() && $expiry.val().length > 0) { $expiry.trigger('change'); } if ($csc.val() && $csc.val().length > 0) { $csc.trigger('change'); } return $('.js-sv-wc-payment-gateway-credit-card-form-input').on('change paste keyup', (function(_this) { return function() { return _this.do_inline_credit_card_validation(); }; })(this)); }; SV_WC_Payment_Form_Handler_v5_7_1.prototype.do_inline_credit_card_validation = function() { console.log( '{AC} - do_inline_credit_card_validation' ); var $card_number, $card_type, $csc, $expiry; $card_number = $('.js-sv-wc-payment-gateway-credit-card-form-account-number'); $expiry = $('.js-sv-wc-payment-gateway-credit-card-form-expiry'); $csc = $('.js-sv-wc-payment-gateway-credit-card-form-csc'); $card_type = $.payment.cardType($card_number.val()); if (indexOf.call(this.enabled_card_types, $card_type) < 0) { $card_number.addClass('invalid-card-type'); } else { $card_number.removeClass('invalid-card-type'); } if ($.payment.validateCardExpiry($expiry.payment('cardExpiryVal'))) { $expiry.addClass('identified'); } else { $expiry.removeClass('identified'); } if ($.payment.validateCardCVC($csc.val())) { return $csc.addClass('identified'); } else { return $csc.removeClass('identified'); } }; SV_WC_Payment_Form_Handler_v5_7_1.prototype.validate_card_data = function() { console.log( '{AC} - validate_card_data' ); var account_number, csc, errors, expiry; errors = []; csc = this.payment_fields.find('.js-sv-wc-payment-gateway-credit-card-form-csc').val(); if (csc != null) { if (csc) { if (/\D/.test(csc)) { errors.push(this.params.cvv_digits_invalid); } if (csc.length < 3 || csc.length > 4) { errors.push(this.params.cvv_length_invalid); } } else if (this.csc_required) { if (!this.saved_payment_method_selected || this.csc_required_for_tokens) { errors.push(this.params.cvv_missing); } } } if (!this.saved_payment_method_selected) { account_number = this.payment_fields.find('.js-sv-wc-payment-gateway-credit-card-form-account-number').val(); expiry = $.payment.cardExpiryVal(this.payment_fields.find('.js-sv-wc-payment-gateway-credit-card-form-expiry').val()); account_number = account_number.replace(/-|\s/g, ''); if (!account_number) { errors.push(this.params.card_number_missing); } else { if (account_number.length < 12 || account_number.length > 19) { errors.push(this.params.card_number_length_invalid); } if (/\D/.test(account_number)) { errors.push(this.params.card_number_digits_invalid); } if (!$.payment.validateCardNumber(account_number)) { errors.push(this.params.card_number_invalid); } } if (!$.payment.validateCardExpiry(expiry)) { errors.push(this.params.card_exp_date_invalid); } } if (errors.length > 0) { this.render_errors(errors); return false; } else { this.payment_fields.find('.js-sv-wc-payment-gateway-credit-card-form-account-number').val(account_number); return true; } }; SV_WC_Payment_Form_Handler_v5_7_1.prototype.validate_account_data = function() { console.log( '{AC} - validate_account_data' ); var account_number, errors, routing_number; if (this.saved_payment_method_selected) { return true; } errors = []; routing_number = this.payment_fields.find('.js-sv-wc-payment-gateway-echeck-form-routing-number').val(); account_number = this.payment_fields.find('.js-sv-wc-payment-gateway-echeck-form-account-number').val(); if (!routing_number) { errors.push(this.params.routing_number_missing); } else { if (9 !== routing_number.length) { errors.push(this.params.routing_number_length_invalid); } if (/\D/.test(routing_number)) { errors.push(this.params.routing_number_digits_invalid); } } if (!account_number) { errors.push(this.params.account_number_missing); } else { if (account_number.length < 3 || account_number.length > 17) { errors.push(this.params.account_number_length_invalid); } if (/\D/.test(account_number)) { errors.push(this.params.account_number_invalid); } } if (errors.length > 0) { this.render_errors(errors); return false; } else { this.payment_fields.find('.js-sv-wc-payment-gateway-echeck-form-account-number').val(account_number); return true; } }; SV_WC_Payment_Form_Handler_v5_7_1.prototype.render_errors = function(errors) { console.log( '{AC} - render_errors' ); $('.woocommerce-error, .woocommerce-message').remove(); this.form.prepend('<ul class="woocommerce-error"><li>' + errors.join('</li><li>') + '</li></ul>'); this.form.removeClass('processing').unblock(); this.form.find('.input-text, select').blur(); return $('html, body').animate({ scrollTop: this.form.offset().top - 100 }, 1000); }; SV_WC_Payment_Form_Handler_v5_7_1.prototype.handle_saved_payment_methods = function() { console.log( '{AC} - handle_saved_payment_methods' ); var $csc_field, $new_payment_method_selection, csc_required, csc_required_for_tokens, id_dasherized; id_dasherized = this.id_dasherized; csc_required = this.csc_required; csc_required_for_tokens = this.csc_required_for_tokens; $new_payment_method_selection = $("div.js-wc-" + id_dasherized + "-new-payment-method-form"); $csc_field = $new_payment_method_selection.find('.js-sv-wc-payment-gateway-credit-card-form-csc').closest('.form-row'); $("input.js-wc-" + this.id_dasherized + "-payment-token").change(function() { var tokenized_payment_method_selected; tokenized_payment_method_selected = $("input.js-wc-" + id_dasherized + "-payment-token:checked").val(); if (tokenized_payment_method_selected) { $new_payment_method_selection.slideUp(200); if (csc_required_for_tokens) { $csc_field.removeClass('form-row-last').addClass('form-row-first'); return $new_payment_method_selection.after($csc_field); } } else { $new_payment_method_selection.slideDown(200); if (csc_required_for_tokens) { $csc_field.removeClass('form-row-first').addClass('form-row-last'); return $new_payment_method_selection.find('.js-sv-wc-payment-gateway-credit-card-form-expiry').closest('.form-row').after($csc_field); } } }).change(); $('input#createaccount').change(function() { var $parent_row; $parent_row = $("input.js-wc-" + id_dasherized + "-tokenize-payment-method").closest('p.form-row'); if ($(this).is(':checked')) { $parent_row.slideDown(); return $parent_row.next().show(); } else { $parent_row.hide(); return $parent_row.next().hide(); } }); if (!$('input#createaccount').is(':checked')) { return $('input#createaccount').change(); } }; SV_WC_Payment_Form_Handler_v5_7_1.prototype.handle_sample_check_hint = function() { console.log( '{AC} - handle_sample_check_hint' ); var $sample_check; $sample_check = this.payment_fields.find('.js-sv-wc-payment-gateway-echeck-form-sample-check'); if ($sample_check.is(":visible")) { return $sample_check.slideUp(); } else { return $sample_check.slideDown(); } }; SV_WC_Payment_Form_Handler_v5_7_1.prototype.block_ui = function() { console.log( '{AC} - block_ui' ); return this.form.block({ message: null, overlayCSS: { background: '#fff', opacity: 0.6 } }); }; SV_WC_Payment_Form_Handler_v5_7_1.prototype.unblock_ui = function() { console.log( '{AC} - unblock_ui' ); return this.form.unblock(); }; return SV_WC_Payment_Form_Handler_v5_7_1; })(); return $(document.body).trigger("sv_wc_payment_form_handler_v5_7_1_loaded"); });}).call(this);
|
woocommerce-gateway-paypal-powered-by-braintree.php
CHANGED
@@ -5,12 +5,12 @@
|
|
5 |
* Description: Receive credit card or PayPal payments using Braintree for WooCommerce. A server with cURL, SSL support, and a valid SSL certificate is required (for security reasons) for this gateway to function. Requires PHP 5.4+
|
6 |
* Author: WooCommerce
|
7 |
* Author URI: http://woocommerce.com/
|
8 |
-
* Version: 2.4.
|
9 |
* Text Domain: woocommerce-gateway-paypal-powered-by-braintree
|
10 |
* Domain Path: /i18n/languages/
|
11 |
*
|
12 |
* WC requires at least: 3.0.9
|
13 |
-
* WC tested up to: 4.
|
14 |
*
|
15 |
* Copyright (c) 2016-2020, Automattic, Inc.
|
16 |
*
|
5 |
* Description: Receive credit card or PayPal payments using Braintree for WooCommerce. A server with cURL, SSL support, and a valid SSL certificate is required (for security reasons) for this gateway to function. Requires PHP 5.4+
|
6 |
* Author: WooCommerce
|
7 |
* Author URI: http://woocommerce.com/
|
8 |
+
* Version: 2.4.3
|
9 |
* Text Domain: woocommerce-gateway-paypal-powered-by-braintree
|
10 |
* Domain Path: /i18n/languages/
|
11 |
*
|
12 |
* WC requires at least: 3.0.9
|
13 |
+
* WC tested up to: 4.6.1
|
14 |
*
|
15 |
* Copyright (c) 2016-2020, Automattic, Inc.
|
16 |
*
|