WooCommerce PayPal Powered by Braintree Payment Gateway - Version 2.2.2

Version Description

Download this release

Release Info

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

Code changes from version 2.2.1 to 2.2.2

Files changed (55) hide show
  1. assets/js/frontend/wc-braintree.min.js +1 -1
  2. class-wc-braintree.php +1 -1
  3. i18n/languages/woocommerce-gateway-paypal-powered-by-braintree.pot +2 -2
  4. lib/skyverge/license.txt +0 -0
  5. lib/skyverge/woocommerce/api/class-sv-wc-api-base.php +0 -0
  6. lib/skyverge/woocommerce/api/class-sv-wc-api-exception.php +0 -0
  7. lib/skyverge/woocommerce/api/interface-sv-wc-api-request.php +0 -0
  8. lib/skyverge/woocommerce/api/interface-sv-wc-api-response.php +0 -0
  9. lib/skyverge/woocommerce/class-sv-wc-admin-notice-handler.php +0 -0
  10. lib/skyverge/woocommerce/class-sv-wc-helper.php +0 -0
  11. lib/skyverge/woocommerce/class-sv-wc-hook-deprecator.php +0 -0
  12. lib/skyverge/woocommerce/class-sv-wc-plugin-compatibility.php +0 -0
  13. lib/skyverge/woocommerce/class-sv-wc-plugin-exception.php +0 -0
  14. lib/skyverge/woocommerce/class-sv-wc-plugin.php +0 -0
  15. lib/skyverge/woocommerce/class-sv-wp-admin-message-handler.php +0 -0
  16. lib/skyverge/woocommerce/compatibility/abstract-sv-wc-data-compatibility.php +0 -0
  17. lib/skyverge/woocommerce/compatibility/class-sv-wc-datetime.php +0 -0
  18. lib/skyverge/woocommerce/compatibility/class-sv-wc-order-compatibility.php +0 -0
  19. lib/skyverge/woocommerce/compatibility/class-sv-wc-product-compatibility.php +0 -0
  20. lib/skyverge/woocommerce/index.php +0 -0
  21. lib/skyverge/woocommerce/payment-gateway/admin/class-sv-wc-payment-gateway-admin-payment-token-editor.php +0 -0
  22. lib/skyverge/woocommerce/payment-gateway/admin/class-sv-wc-payment-gateway-admin-user-handler.php +0 -0
  23. lib/skyverge/woocommerce/payment-gateway/admin/views/html-admin-gateway-status.php +0 -0
  24. lib/skyverge/woocommerce/payment-gateway/admin/views/html-user-payment-token-editor-token.php +0 -0
  25. lib/skyverge/woocommerce/payment-gateway/admin/views/html-user-payment-token-editor.php +0 -0
  26. lib/skyverge/woocommerce/payment-gateway/admin/views/html-user-profile-field-customer-id.php +0 -0
  27. lib/skyverge/woocommerce/payment-gateway/admin/views/html-user-profile-section.php +0 -0
  28. lib/skyverge/woocommerce/payment-gateway/api/class-sv-wc-payment-gateway-api-response-message-helper.php +0 -0
  29. lib/skyverge/woocommerce/payment-gateway/api/interface-sv-wc-payment-gateway-api-authorization-response.php +0 -0
  30. lib/skyverge/woocommerce/payment-gateway/api/interface-sv-wc-payment-gateway-api-create-payment-token-response.php +0 -0
  31. lib/skyverge/woocommerce/payment-gateway/api/interface-sv-wc-payment-gateway-api-customer-response.php +0 -0
  32. lib/skyverge/woocommerce/payment-gateway/api/interface-sv-wc-payment-gateway-api-get-tokenized-payment-methods-response.php +0 -0
  33. lib/skyverge/woocommerce/payment-gateway/api/interface-sv-wc-payment-gateway-api-request.php +0 -0
  34. lib/skyverge/woocommerce/payment-gateway/api/interface-sv-wc-payment-gateway-api-response.php +0 -0
  35. lib/skyverge/woocommerce/payment-gateway/api/interface-sv-wc-payment-gateway-api.php +0 -0
  36. lib/skyverge/woocommerce/payment-gateway/assets/css/admin/sv-wc-payment-gateway-token-editor.scss +0 -0
  37. lib/skyverge/woocommerce/payment-gateway/assets/css/frontend/sv-wc-payment-gateway-my-payment-methods.scss +0 -0
  38. lib/skyverge/woocommerce/payment-gateway/assets/css/frontend/sv-wc-payment-gateway-payment-form.scss +0 -0
  39. lib/skyverge/woocommerce/payment-gateway/assets/js/frontend/sv-wc-payment-gateway-payment-form.coffee +0 -0
  40. lib/skyverge/woocommerce/payment-gateway/assets/js/frontend/sv-wc-payment-gateway-payment-form.min.js +0 -0
  41. lib/skyverge/woocommerce/payment-gateway/class-sv-wc-payment-gateway-direct.php +0 -0
  42. lib/skyverge/woocommerce/payment-gateway/class-sv-wc-payment-gateway-helper.php +0 -0
  43. lib/skyverge/woocommerce/payment-gateway/class-sv-wc-payment-gateway-my-payment-methods.php +0 -0
  44. lib/skyverge/woocommerce/payment-gateway/class-sv-wc-payment-gateway-payment-form.php +0 -0
  45. lib/skyverge/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php +0 -0
  46. lib/skyverge/woocommerce/payment-gateway/class-sv-wc-payment-gateway-privacy.php +0 -0
  47. lib/skyverge/woocommerce/payment-gateway/class-sv-wc-payment-gateway.php +0 -0
  48. lib/skyverge/woocommerce/payment-gateway/exceptions/class-sv-wc-payment-gateway-exception.php +0 -0
  49. lib/skyverge/woocommerce/payment-gateway/integrations/abstract-sv-wc-payment-gateway-integration.php +0 -0
  50. lib/skyverge/woocommerce/payment-gateway/integrations/class-sv-wc-payment-gateway-integration-pre-orders.php +0 -0
  51. lib/skyverge/woocommerce/payment-gateway/integrations/class-sv-wc-payment-gateway-integration-subscriptions.php +0 -0
  52. lib/skyverge/woocommerce/payment-gateway/payment-tokens/class-sv-wc-payment-gateway-payment-token.php +0 -0
  53. lib/skyverge/woocommerce/payment-gateway/payment-tokens/class-sv-wc-payment-gateway-payment-tokens-handler.php +0 -0
  54. readme.txt +5 -2
  55. 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){var a=Object.getPrototypeOf(t);return null===a?void 0:e(a,n,r)}if("value"in i)return i.value;var o=i.get;return void 0!==o?o.call(r):void 0},_createClass=function(){function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}}();function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(function(){var s=[].indexOf,_=function(e,t){if(!(e instanceof t))throw new Error("Bound instance method accessed before binding")};jQuery(document).ready(function(o){var r,i;return window.WC_Braintree_Payment_Form_Handler=function(){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}return _createClass(t,[{key:"init",value:function(){return this.is_sdk_ready()?o("form.checkout").length?this.handle_checkout_page():o("form#order_review").length?this.handle_pay_page():o("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=o("form.checkout"),this.form_ui_selector=".woocommerce-checkout-payment",o(document.body).on("updated_checkout",function(){if(!e.setting_up)return e.setup_braintree()}),o(document.body).on("updated_checkout",function(){return e.handle_saved_payment_methods()}),o(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=o("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=o("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 o("input[name=wc_"+this.id+"_payment_nonce]").val(e),this.form.submit()}},{key:"handle_saved_payment_methods",value:function(){var e,n=this;if(e=o("div.js-wc-"+this.id_dasherized+"-new-payment-method-form"),o("input.js-wc-"+this.id_dasherized+"-payment-token").change(function(){return o("input.js-wc-"+n.id_dasherized+"-payment-token:checked").val()?e.slideUp(200):e.slideDown(200)}).change(),o("input#createaccount").change(function(e){var t;return t=o("input.js-wc-"+n.id_dasherized+"-tokenize-payment-method").closest("p.form-row"),o(e.target).is(":checked")?(t.slideDown(),t.next().show()):(t.hide(),t.next().hide())}),!o("input#createaccount").is(":checked"))return o("input#createaccount").change()}},{key:"setup_braintree",value:function(){return this.setting_up=!0,this.block_ui(),o("input[name=wc_"+this.id+"_payment_nonce]").val(""),null!=this.client?this.setup_integration():this.create_client()}},{key:"create_client",value:function(){var r=this;return this.log("Creating client."),this.get_client_token().done(function(e){return e.success?braintree.client.create({authorization:e.data}).then(function(e){return r.client=e,r.log("Client ready."),r.setup_integration()}).catch(function(e){return r.handle_integration_error(e),r.unblock_ui()}):r.handle_integration_error(e.data)}).fail(function(e,t,n){return r.handle_integration_error({message:"Could not retrieve the client token via AJAX: "+n})}).always(function(){return r.unblock_ui()})}},{key:"get_client_token",value:function(){var e;return this.id+"_client_token_nonce",e={action:"wc_"+this.id+"_get_client_token",nonce:this.client_token_nonce},o.post(this.ajax_url,e)}},{key:"setup_integration",value:function(){var t=this;return this.log("Creating integration."),this.get_integration_class().create(this.get_integration_options()).then(function(e){return t.integration=e,t.show_integration_ui(),t.do_integration_ready(),o(document).trigger("wc_"+t.id+"_integration_ready",t.integration),t.log("Integration ready.")}).catch(function(e){return t.handle_integration_error(e),t.unblock_ui()}).finally(function(){return 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 o(".woocommerce-error, .woocommerce-message").remove(),this.form.prepend('<div class="woocommerce-error">'+e+"</div>").removeClass("processing").unblock(),o("html, body").animate({scrollTop:this.form.offset().top-100},1e3),o("input[name=wc_"+this.id+"_payment_nonce]").val(""),this.form.trigger("wc_"+this.id+"_rendered_error"),o(document.body).trigger("checkout_error"),this.unblock_ui()}},{key:"get_user_message",value:function(e){return this.payment_error_message}},{key:"show_integration_ui",value:function(){if(o("div.js-wc-"+this.id_dasherized+"-new-payment-method-form").find(".woocommerce-error").remove(),o("input#createaccount").length&&o("input#createaccount").is(":checked"))return o("div.js-wc-"+this.id_dasherized+"-new-payment-method-form").find(".form-row").show()}},{key:"hide_integration_ui",value:function(){return o("div.js-wc-"+this.id_dasherized+"-new-payment-method-form").prepend('<div class="woocommerce-error">'+this.integration_error_message+"</div>"),o("div.js-wc-"+this.id_dasherized+"-new-payment-method-form").find(".form-row").hide()}},{key:"block_ui",value:function(){return o(this.form_ui_selector).block({message:null,overlayCSS:{background:"#fff",opacity:.6}})}},{key:"unblock_ui",value:function(){return o(this.form_ui_selector).unblock()}},{key:"is_selected",value:function(){return this.get_selected_gateway_id()===this.id}},{key:"is_sdk_ready",value:function(){return"undefined"!=typeof braintree&&null!==braintree&&null!=braintree.client&&null!=this.get_integration_class()}},{key:"has_payment_nonce",value:function(){return this.form.find("input[name=wc_"+this.id+"_payment_nonce]").val()}},{key:"using_payment_token",value:function(){return this.form.find("input.js-wc-"+this.id_dasherized+"-payment-token:checked").val()}},{key:"get_selected_gateway_id",value:function(){return this.form.find("input[name=payment_method]:checked").val()}},{key:"log",value:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;2<arguments.length&&void 0!==arguments[2]&&arguments[2];if(this.debug)return console.log(this.name+": "+e),t?console.log(t):void 0}}]),t}(),r=window.WC_Braintree_Credit_Card_Payment_Form_Handler=function(e){function a(e){_classCallCheck(this,a);var t=_possibleConstructorReturn(this,(a.__proto__||Object.getPrototypeOf(a)).call(this,e));return t.add_3ds_ui=t.add_3ds_ui.bind(t),t.remove_3ds_ui=t.remove_3ds_ui.bind(t),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}return _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),o("input[name=wc_"+this.id+"_payment_nonce]").val(""),o("input[name=wc-"+this.id_dasherized+"-card-type]").val(""),o("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=o("input.js-wc-braintree-credit-card-payment-token:checked"),this.should_verify_3d_secure_token(e)?(this.verify_3d_secure(e.data("nonce"),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)return t.should_verify_3d_secure(e)?t.verify_3d_secure(e.nonce):t.submit_form(e.nonce)}).catch(function(e){return t.handle_payment_error(e)})}},{key:"get_integration_options",value:function(){var e;return e={client:this.client,fields:{number:{selector:"#wc-braintree-credit-card-account-number-hosted",placeholder:o("#wc-braintree-credit-card-account-number-hosted").data("placeholder")},cvv:{selector:"#wc-braintree-credit-card-csc-hosted",placeholder:o("#wc-braintree-credit-card-csc-hosted").data("placeholder")},expirationDate:{selector:"#wc-braintree-credit-card-expiry-hosted",placeholder:o("#wc-braintree-credit-card-expiry-hosted").data("placeholder")}},styles:this.hosted_fields_styles},this.csc_required&&this.using_payment_token()&&(delete e.fields.number,delete e.fields.expirationDate),this.csc_required||delete e.fields.cvv,e}},{key:"get_integration_class",value:function(){return braintree.hostedFields}},{key:"do_integration_ready",value:function(){var t=this;return this.integration.on("cardTypeChange",function(e){return t.on_card_type_change(e)}),!this.csc_required&&o("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=o("div.js-wc-braintree-credit-card-new-payment-method-form"),e=o("div.wc-braintree-hosted-field-card-csc-parent"),o("input.js-wc-braintree-credit-card-payment-token").change(function(){return o("input.js-wc-braintree-credit-card-payment-token:checked").val()?n.csc_required&&e.hasClass("form-row-last")?(e.removeClass("form-row-last").addClass("form-row-first"),t.after(e),n.refresh_braintree()):void 0:(n.csc_required&&e.hasClass("form-row-first")&&(e.removeClass("form-row-first").addClass("form-row-last"),t.find("div.wc-braintree-hosted-field-card-expiry-parent").after(e)),n.refresh_braintree())}).change()}},{key:"get_user_message",value:function(e){var t,n,r,i;if(r=[],"CUSTOMER"===e.type)switch(e.code){case"HOSTED_FIELDS_FIELDS_EMPTY":this.csc_required&&r.push(this.params.cvv_missing),this.using_payment_token()||(r.push(this.params.card_number_missing),r.push(this.params.card_exp_date_invalid));break;case"HOSTED_FIELDS_FIELDS_INVALID":if(null!=e.details)for(t=0,n=(i=e.details.invalidFieldKeys).length;t<n;t++)switch(i[t]){case"number":r.push(this.params.card_number_invalid);break;case"cvv":r.push(this.params.cvv_length_invalid);break;case"expirationDate":r.push(this.params.card_exp_date_invalid)}}return r.length?r.join("<br/>"):_get(a.prototype.__proto__||Object.getPrototypeOf(a.prototype),"get_user_message",this).call(this)}},{key:"on_card_type_change",value:function(e){var t,n,r;if(null!=e.cards)return(t=o("#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],o("input[name=wc-"+this.id_dasherized+"-card-type]").val(n.type),null!=n.type&&(r=n.type,0<=s.call(this.enabled_card_types,r))?t.addClass("card-type-"+n.type):t.addClass("card-type-invalid")):void 0:t.addClass("card-type-invalid")}},{key:"is_3d_secure_enabled",value:function(){return this.threeds.enabled&&null!=braintree.threeDSecure}},{key:"setup_integration",value:function(){var t=this;return this.threeds.enabled&&(this.threeds.enabled=this.client.getConfiguration().gatewayConfiguration.threeDSecureEnabled),this.is_3d_secure_enabled()?(o("input[name=wc-"+this.id_dasherized+"-3d-secure-enabled]").val(1),braintree.threeDSecure.create({client:this.client}).then(function(e){return t.threeDSecure=e,o(document.body).on("click","#wc-braintree-credit-card-3dsecure-container",function(e){return o(e.currentTarget).fadeOut(200),t.threeDSecure.cancelVerifyCard(),t.unblock_ui()}),_get(a.prototype.__proto__||Object.getPrototypeOf(a.prototype),"setup_integration",t).call(t)}).catch(function(e){return t.handle_integration_error(e)})):_get(a.prototype.__proto__||Object.getPrototypeOf(a.prototype),"setup_integration",this).call(this)}},{key:"should_verify_3d_secure",value:function(e){var t;return t=e.details.cardType,this.is_3d_secure_enabled()&&"CreditCard"===e.type&&0<=s.call(this.threeds.card_types,t)}},{key:"should_verify_3d_secure_token",value:function(e){if(this.is_3d_secure_enabled()&&e.val()&&e.data("nonce")&&!e.data("verified"))return!0}},{key:"verify_3d_secure",value:function(e){var t,n,r,i=this,a=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;return r=o("#billing_state").val(),t=o("#billing_country").val(),n={billingAddress:{firstName:o("input[name=billing_first_name]").val(),lastName:o("input[name=billing_last_name]").val(),streetAddress:o("input[name=billing_address_1]").val(),extendedAddress:o("input[name=billing_address_2]").val(),locality:o("#billing_city").val(),region:"string"==typeof r&&r.length<=2?r:"",postalCode:o("input[name=billing_postcode]").val(),countryCodeAlpha2:"string"==typeof t&&t.length<=2?t:""}},this.threeDSecure.verifyCard({nonce:e,amount:o("input[name=wc-"+this.id_dasherized+"-3d-secure-order-total]").val(),customer:n,addFrame:function(e,t){return i.add_3ds_ui(e,t)},removeFrame:function(){return i.remove_3ds_ui()}}).then(function(e){return i.log("3D Secure response received.",e),i.threeds.liability_shift_always_required&&!e.liabilityShifted?i.render_error(i.threeds.failure_message):(null!=a&&a.data("verified",!0),o("input[name=wc-"+i.id_dasherized+"-3d-secure-verified]").val(1),i.submit_form(e.nonce))}).catch(function(e){return i.handle_payment_error(e)})}},{key:"add_3ds_ui",value:function(e,t){var n;return _(this,r),e?this.handle_payment_error(e):((n=o("<div>",{id:"wc-"+this.id_dasherized+"-3dsecure-container"})).html(t),o(document.body).append(n),n.fadeIn(400))}},{key:"remove_3ds_ui",value:function(){return _(this,r),o("#wc-"+this.id_dasherized+"-3dsecure-container").fadeOut(400,function(e){return o(this).remove()})}},{key:"show_integration_ui",value:function(){return _(this,r),_get(a.prototype.__proto__||Object.getPrototypeOf(a.prototype),"show_integration_ui",this).call(this),o(".wc-braintree-hosted-field-parent").show()}},{key:"hide_integration_ui",value:function(){return _(this,r),_get(a.prototype.__proto__||Object.getPrototypeOf(a.prototype),"hide_integration_ui",this).call(this),o(".wc-braintree-hosted-field-parent").hide()}}]),a}(),i=window.WC_Braintree_PayPal_Payment_Form_Handler=function(e){function n(e){_classCallCheck(this,n);var t=_possibleConstructorReturn(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e));return t.do_integration_ready=t.do_integration_ready.bind(t),t.on_authorize=t.on_authorize.bind(t),t.get_linked_account_html=t.get_linked_account_html.bind(t),t.is_test_environment=e.is_test_environment,t.is_paypal_credit_enabled=e.is_paypal_credit_enabled,t.must_login_message=e.must_login_message,t.must_login_add_method_message=e.must_login_add_method_message,t.button_styles=e.button_styles,t.cart_payment_nonce=e.cart_payment_nonce,t.init(),t}return _inherits(n,WC_Braintree_Payment_Form_Handler),_createClass(n,[{key:"init",value:function(){var t=this;return _get(n.prototype.__proto__||Object.getPrototypeOf(n.prototype),"init",this).call(this),o("input[name=wc_"+this.id+"_payment_nonce]").val(this.cart_payment_nonce),o(document.body).on("click",'input[name="payment_method"], input.js-wc-braintree-paypal-payment-token',function(){return t.toggle_order_button()}),o(document.body).on("payment_method_selected",function(){return t.toggle_order_button()}),o(document.body).on("click",".wc-braintree-paypal-account .cancel",function(e){return e.preventDefault(),o(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()?o("#place_order").show():o("#place_order").hide()}},{key:"verify_form",value:function(){var e;return e=_get(n.prototype.__proto__||Object.getPrototypeOf(n.prototype),"verify_form",this).call(this),this.has_payment_nonce()||this.using_payment_token()||this.render_error(this.must_login_message),e}},{key:"handle_payment_error",value:function(e){return _get(n.prototype.__proto__||Object.getPrototypeOf(n.prototype),"handle_payment_error",this).call(this,e),this.cart_payment_nonce=!1,this.setup_braintree()}},{key:"get_integration_class",value:function(){return braintree.paypalCheckout}},{key:"setup_braintree",value:function(){return this.cart_payment_nonce?this.unblock_ui():(_get(n.prototype.__proto__||Object.getPrototypeOf(n.prototype),"setup_braintree",this).call(this),o("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 _(this,i),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 o("#wc_braintree_paypal_container").css({width:"100%"})}).catch(function(e){return t.log("Could not render the PayPal button. "+e.message,e),t.hide_integration_ui()}).finally(function(){return t.unblock_ui()}))}},{key:"render_button",value:function(e,t,n){var r,i,a=this;return o(n).html(""),r=this.is_paypal_credit_enabled&&"USD"===this.get_store_currency()?{allowed:[paypal.FUNDING.CREDIT]}:{disallowed:[paypal.FUNDING.CREDIT]},i={env:this.is_test_environment?"sandbox":"production",commit:this.button_is_pay_now(),style:t,funding:r,payment:function(){return e},onAuthorize:function(e,t){return a.on_authorize(e,t)},onError:function(e){return a.handle_integration_error(e)}},paypal.Button.render(i,n)}},{key:"button_is_pay_now",value:function(){return!o("form#add_payment_method").length}},{key:"get_button_styles",value:function(){return this.button_styles}},{key:"on_authorize",value:function(e,t){var n=this;return _(this,i),this.block_ui(),this.integration.tokenizePayment(e).then(function(e){return n.log("Payment method tokenized.",e),n.set_payment_method(e)}).catch(function(e){return n.handle_payment_error(e),n.unblock_ui()})}},{key:"set_payment_method",value:function(e){return o("input[name=wc_"+this.id+"_payment_nonce]").val(e.nonce),o("#wc_braintree_paypal_container").html(this.get_linked_account_html(e.details)),this.is_single_use()&&o("input.js-wc-braintree-paypal-tokenize-payment-method").prop("disabled",!0),o("#place_order").show(),this.form.submit()}},{key:"handle_saved_payment_methods",value:function(){var t=this;return _get(n.prototype.__proto__||Object.getPrototypeOf(n.prototype),"handle_saved_payment_methods",this).call(this),o("input.js-wc-braintree-paypal-tokenize-payment-method").change(function(e){if(null!=t.integration&&o(e.target).is(":visible"))return t.block_ui(),t.do_integration_ready()}).change()}},{key:"get_linked_account_html",value:function(e){var t;return _(this,i),t=o("<div class='wc-"+this.id_dasherized+"-account'></div>"),null!=e.firstName&&null!=e.lastName&&t.append("<span class='name'>"+e.firstName+" "+e.lastName+"</span>"),t.append("<span class='email'>"+e.email+"</span>"),t.append("<a href='#' class='cancel'>Cancel</a>"),t}},{key:"is_single_use",value:function(){var e;return 0===(e=o("input[name=wc-braintree-paypal-tokenize-payment-method]")).length||("checkbox"===e.attr("type")?!e.is(":checked"):!e.val())}},{key:"get_order_amount",value:function(){return o("input[name=wc_braintree_paypal_amount]").val()}},{key:"get_store_currency",value:function(){return o("input[name=wc_braintree_paypal_currency]").val()}},{key:"get_store_locale",value:function(){return o("input[name=wc_braintree_paypal_locale]").val()}},{key:"is_sdk_ready",value:function(){return _get(n.prototype.__proto__||Object.getPrototypeOf(n.prototype),"is_sdk_ready",this).call(this)&&"undefined"!=typeof paypal&&null!==paypal}}]),n}(),window.WC_Braintree_PayPal_Cart_Handler=function(e){function n(e){_classCallCheck(this,n);var t=_possibleConstructorReturn(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e));return t.set_payment_method_nonce=e.set_payment_method_nonce,t.cart_handler_url=e.cart_handler_url,t.form=o("form.woocommerce-cart-form"),t.form_ui_selector="",t.setup_braintree(),o(document.body).on("updated_cart_totals",function(){return t.setup_braintree()}),t}return _inherits(n,WC_Braintree_PayPal_Payment_Form_Handler),_createClass(n,[{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,o.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"===o("input[name=wc_braintree_paypal_single_use]").val()}},{key:"has_payment_nonce",value:function(){return!1}}]),n}()})}).call(void 0);
1
+ "use strict";var _get=function e(t,n,r){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,n);if(void 0===i){var a=Object.getPrototypeOf(t);return null===a?void 0:e(a,n,r)}if("value"in i)return i.value;var o=i.get;return void 0!==o?o.call(r):void 0},_createClass=function(){function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}}();function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(function(){var s=[].indexOf,_=function(e,t){if(!(e instanceof t))throw new Error("Bound instance method accessed before binding")};jQuery(document).ready(function(o){var r,i;return window.WC_Braintree_Payment_Form_Handler=function(){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}return _createClass(t,[{key:"init",value:function(){return this.is_sdk_ready()?o("form.checkout").length?this.handle_checkout_page():o("form#order_review").length?this.handle_pay_page():o("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=o("form.checkout"),this.form_ui_selector=".woocommerce-checkout-payment",o(document.body).on("updated_checkout",function(){if(!e.setting_up)return e.setup_braintree()}),o(document.body).on("updated_checkout",function(){return e.handle_saved_payment_methods()}),o(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=o("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=o("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 o("input[name=wc_"+this.id+"_payment_nonce]").val(e),this.form.submit()}},{key:"handle_saved_payment_methods",value:function(){var e,n=this;if(e=o("div.js-wc-"+this.id_dasherized+"-new-payment-method-form"),o("input.js-wc-"+this.id_dasherized+"-payment-token").change(function(){return o("input.js-wc-"+n.id_dasherized+"-payment-token:checked").val()?e.slideUp(200):e.slideDown(200)}).change(),o("input#createaccount").change(function(e){var t;return t=o("input.js-wc-"+n.id_dasherized+"-tokenize-payment-method").closest("p.form-row"),o(e.target).is(":checked")?(t.slideDown(),t.next().show()):(t.hide(),t.next().hide())}),!o("input#createaccount").is(":checked"))return o("input#createaccount").change()}},{key:"setup_braintree",value:function(){return this.setting_up=!0,this.block_ui(),o("input[name=wc_"+this.id+"_payment_nonce]").val(""),null!=this.client?this.setup_integration():this.create_client()}},{key:"create_client",value:function(){var r=this;return this.log("Creating client."),this.get_client_token().done(function(e){return e.success?braintree.client.create({authorization:e.data}).then(function(e){return r.client=e,r.log("Client ready."),r.setup_integration()}).catch(function(e){return r.handle_integration_error(e),r.unblock_ui()}):r.handle_integration_error(e.data)}).fail(function(e,t,n){return r.handle_integration_error({message:"Could not retrieve the client token via AJAX: "+n})}).always(function(){return r.unblock_ui()})}},{key:"get_client_token",value:function(){var e;return this.id+"_client_token_nonce",e={action:"wc_"+this.id+"_get_client_token",nonce:this.client_token_nonce},o.post(this.ajax_url,e)}},{key:"setup_integration",value:function(){var t=this;return this.log("Creating integration."),this.get_integration_class().create(this.get_integration_options()).then(function(e){return t.integration=e,t.show_integration_ui(),t.do_integration_ready(),o(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 o(".woocommerce-error, .woocommerce-message").remove(),this.form.prepend('<div class="woocommerce-error">'+e+"</div>").removeClass("processing").unblock(),o("html, body").animate({scrollTop:this.form.offset().top-100},1e3),o("input[name=wc_"+this.id+"_payment_nonce]").val(""),this.form.trigger("wc_"+this.id+"_rendered_error"),o(document.body).trigger("checkout_error"),this.unblock_ui()}},{key:"get_user_message",value:function(e){return this.payment_error_message}},{key:"show_integration_ui",value:function(){if(o("div.js-wc-"+this.id_dasherized+"-new-payment-method-form").find(".woocommerce-error").remove(),o("input#createaccount").length&&o("input#createaccount").is(":checked"))return o("div.js-wc-"+this.id_dasherized+"-new-payment-method-form").find(".form-row").show()}},{key:"hide_integration_ui",value:function(){return o("div.js-wc-"+this.id_dasherized+"-new-payment-method-form").prepend('<div class="woocommerce-error">'+this.integration_error_message+"</div>"),o("div.js-wc-"+this.id_dasherized+"-new-payment-method-form").find(".form-row").hide()}},{key:"block_ui",value:function(){return o(this.form_ui_selector).block({message:null,overlayCSS:{background:"#fff",opacity:.6}})}},{key:"unblock_ui",value:function(){return o(this.form_ui_selector).unblock()}},{key:"is_selected",value:function(){return this.get_selected_gateway_id()===this.id}},{key:"is_sdk_ready",value:function(){return"undefined"!=typeof braintree&&null!==braintree&&null!=braintree.client&&null!=this.get_integration_class()}},{key:"has_payment_nonce",value:function(){return this.form.find("input[name=wc_"+this.id+"_payment_nonce]").val()}},{key:"using_payment_token",value:function(){return this.form.find("input.js-wc-"+this.id_dasherized+"-payment-token:checked").val()}},{key:"get_selected_gateway_id",value:function(){return this.form.find("input[name=payment_method]:checked").val()}},{key:"log",value:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;2<arguments.length&&void 0!==arguments[2]&&arguments[2];if(this.debug)return console.log(this.name+": "+e),t?console.log(t):void 0}}]),t}(),r=window.WC_Braintree_Credit_Card_Payment_Form_Handler=function(e){function a(e){_classCallCheck(this,a);var t=_possibleConstructorReturn(this,(a.__proto__||Object.getPrototypeOf(a)).call(this,e));return t.add_3ds_ui=t.add_3ds_ui.bind(t),t.remove_3ds_ui=t.remove_3ds_ui.bind(t),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}return _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),o("input[name=wc_"+this.id+"_payment_nonce]").val(""),o("input[name=wc-"+this.id_dasherized+"-card-type]").val(""),o("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=o("input.js-wc-braintree-credit-card-payment-token:checked"),this.should_verify_3d_secure_token(e)?(this.verify_3d_secure(e.data("nonce"),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)return t.should_verify_3d_secure(e)?t.verify_3d_secure(e.nonce):t.submit_form(e.nonce)}).catch(function(e){return t.handle_payment_error(e)})}},{key:"get_integration_options",value:function(){var e;return e={client:this.client,fields:{number:{selector:"#wc-braintree-credit-card-account-number-hosted",placeholder:o("#wc-braintree-credit-card-account-number-hosted").data("placeholder")},cvv:{selector:"#wc-braintree-credit-card-csc-hosted",placeholder:o("#wc-braintree-credit-card-csc-hosted").data("placeholder")},expirationDate:{selector:"#wc-braintree-credit-card-expiry-hosted",placeholder:o("#wc-braintree-credit-card-expiry-hosted").data("placeholder")}},styles:this.hosted_fields_styles},this.csc_required&&this.using_payment_token()&&(delete e.fields.number,delete e.fields.expirationDate),this.csc_required||delete e.fields.cvv,e}},{key:"get_integration_class",value:function(){return braintree.hostedFields}},{key:"do_integration_ready",value:function(){var t=this;return this.integration.on("cardTypeChange",function(e){return t.on_card_type_change(e)}),!this.csc_required&&o("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=o("div.js-wc-braintree-credit-card-new-payment-method-form"),e=o("div.wc-braintree-hosted-field-card-csc-parent"),o("input.js-wc-braintree-credit-card-payment-token").change(function(){return o("input.js-wc-braintree-credit-card-payment-token:checked").val()?n.csc_required&&e.hasClass("form-row-last")?(e.removeClass("form-row-last").addClass("form-row-first"),t.after(e),n.refresh_braintree()):void 0:(n.csc_required&&e.hasClass("form-row-first")&&(e.removeClass("form-row-first").addClass("form-row-last"),t.find("div.wc-braintree-hosted-field-card-expiry-parent").after(e)),n.refresh_braintree())}).change()}},{key:"get_user_message",value:function(e){var t,n,r,i;if(r=[],"CUSTOMER"===e.type)switch(e.code){case"HOSTED_FIELDS_FIELDS_EMPTY":this.csc_required&&r.push(this.params.cvv_missing),this.using_payment_token()||(r.push(this.params.card_number_missing),r.push(this.params.card_exp_date_invalid));break;case"HOSTED_FIELDS_FIELDS_INVALID":if(null!=e.details)for(t=0,n=(i=e.details.invalidFieldKeys).length;t<n;t++)switch(i[t]){case"number":r.push(this.params.card_number_invalid);break;case"cvv":r.push(this.params.cvv_length_invalid);break;case"expirationDate":r.push(this.params.card_exp_date_invalid)}}return r.length?r.join("<br/>"):_get(a.prototype.__proto__||Object.getPrototypeOf(a.prototype),"get_user_message",this).call(this)}},{key:"on_card_type_change",value:function(e){var t,n,r;if(null!=e.cards)return(t=o("#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],o("input[name=wc-"+this.id_dasherized+"-card-type]").val(n.type),null!=n.type&&(r=n.type,0<=s.call(this.enabled_card_types,r))?t.addClass("card-type-"+n.type):t.addClass("card-type-invalid")):void 0:t.addClass("card-type-invalid")}},{key:"is_3d_secure_enabled",value:function(){return this.threeds.enabled&&null!=braintree.threeDSecure}},{key:"setup_integration",value:function(){var t=this;return this.threeds.enabled&&(this.threeds.enabled=this.client.getConfiguration().gatewayConfiguration.threeDSecureEnabled),this.is_3d_secure_enabled()?(o("input[name=wc-"+this.id_dasherized+"-3d-secure-enabled]").val(1),braintree.threeDSecure.create({client:this.client}).then(function(e){return t.threeDSecure=e,o(document.body).on("click","#wc-braintree-credit-card-3dsecure-container",function(e){return o(e.currentTarget).fadeOut(200),t.threeDSecure.cancelVerifyCard(),t.unblock_ui()}),_get(a.prototype.__proto__||Object.getPrototypeOf(a.prototype),"setup_integration",t).call(t)}).catch(function(e){return t.handle_integration_error(e)})):_get(a.prototype.__proto__||Object.getPrototypeOf(a.prototype),"setup_integration",this).call(this)}},{key:"should_verify_3d_secure",value:function(e){var t;return t=e.details.cardType,this.is_3d_secure_enabled()&&"CreditCard"===e.type&&0<=s.call(this.threeds.card_types,t)}},{key:"should_verify_3d_secure_token",value:function(e){if(this.is_3d_secure_enabled()&&e.val()&&e.data("nonce")&&!e.data("verified"))return!0}},{key:"verify_3d_secure",value:function(e){var t,n,r,i=this,a=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;return r=o("#billing_state").val(),t=o("#billing_country").val(),n={billingAddress:{firstName:o("input[name=billing_first_name]").val(),lastName:o("input[name=billing_last_name]").val(),streetAddress:o("input[name=billing_address_1]").val(),extendedAddress:o("input[name=billing_address_2]").val(),locality:o("#billing_city").val(),region:"string"==typeof r&&r.length<=2?r:"",postalCode:o("input[name=billing_postcode]").val(),countryCodeAlpha2:"string"==typeof t&&t.length<=2?t:""}},this.threeDSecure.verifyCard({nonce:e,amount:o("input[name=wc-"+this.id_dasherized+"-3d-secure-order-total]").val(),customer:n,addFrame:function(e,t){return i.add_3ds_ui(e,t)},removeFrame:function(){return i.remove_3ds_ui()}}).then(function(e){return i.log("3D Secure response received.",e),i.threeds.liability_shift_always_required&&!e.liabilityShifted?i.render_error(i.threeds.failure_message):(null!=a&&a.data("verified",!0),o("input[name=wc-"+i.id_dasherized+"-3d-secure-verified]").val(1),i.submit_form(e.nonce))}).catch(function(e){return i.handle_payment_error(e)})}},{key:"add_3ds_ui",value:function(e,t){var n;return _(this,r),e?this.handle_payment_error(e):((n=o("<div>",{id:"wc-"+this.id_dasherized+"-3dsecure-container"})).html(t),o(document.body).append(n),n.fadeIn(400))}},{key:"remove_3ds_ui",value:function(){return _(this,r),o("#wc-"+this.id_dasherized+"-3dsecure-container").fadeOut(400,function(e){return o(this).remove()})}},{key:"show_integration_ui",value:function(){return _(this,r),_get(a.prototype.__proto__||Object.getPrototypeOf(a.prototype),"show_integration_ui",this).call(this),o(".wc-braintree-hosted-field-parent").show()}},{key:"hide_integration_ui",value:function(){return _(this,r),_get(a.prototype.__proto__||Object.getPrototypeOf(a.prototype),"hide_integration_ui",this).call(this),o(".wc-braintree-hosted-field-parent").hide()}}]),a}(),i=window.WC_Braintree_PayPal_Payment_Form_Handler=function(e){function n(e){_classCallCheck(this,n);var t=_possibleConstructorReturn(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e));return t.do_integration_ready=t.do_integration_ready.bind(t),t.on_authorize=t.on_authorize.bind(t),t.get_linked_account_html=t.get_linked_account_html.bind(t),t.is_test_environment=e.is_test_environment,t.is_paypal_credit_enabled=e.is_paypal_credit_enabled,t.must_login_message=e.must_login_message,t.must_login_add_method_message=e.must_login_add_method_message,t.button_styles=e.button_styles,t.cart_payment_nonce=e.cart_payment_nonce,t.init(),t}return _inherits(n,WC_Braintree_Payment_Form_Handler),_createClass(n,[{key:"init",value:function(){var t=this;return _get(n.prototype.__proto__||Object.getPrototypeOf(n.prototype),"init",this).call(this),o("input[name=wc_"+this.id+"_payment_nonce]").val(this.cart_payment_nonce),o(document.body).on("click",'input[name="payment_method"], input.js-wc-braintree-paypal-payment-token',function(){return t.toggle_order_button()}),o(document.body).on("payment_method_selected",function(){return t.toggle_order_button()}),o(document.body).on("click",".wc-braintree-paypal-account .cancel",function(e){return e.preventDefault(),o(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()?o("#place_order").show():o("#place_order").hide()}},{key:"verify_form",value:function(){var e;return e=_get(n.prototype.__proto__||Object.getPrototypeOf(n.prototype),"verify_form",this).call(this),this.has_payment_nonce()||this.using_payment_token()||this.render_error(this.must_login_message),e}},{key:"handle_payment_error",value:function(e){return _get(n.prototype.__proto__||Object.getPrototypeOf(n.prototype),"handle_payment_error",this).call(this,e),this.cart_payment_nonce=!1,this.setup_braintree()}},{key:"get_integration_class",value:function(){return braintree.paypalCheckout}},{key:"setup_braintree",value:function(){return this.cart_payment_nonce?this.unblock_ui():(_get(n.prototype.__proto__||Object.getPrototypeOf(n.prototype),"setup_braintree",this).call(this),o("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 _(this,i),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 o("#wc_braintree_paypal_container").css({width:"100%"}),t.unblock_ui()}).catch(function(e){return t.log("Could not render the PayPal button. "+e.message,e),t.hide_integration_ui(),t.unblock_ui()}))}},{key:"render_button",value:function(e,t,n){var r,i,a=this;return o(n).html(""),r=this.is_paypal_credit_enabled&&"USD"===this.get_store_currency()?{allowed:[paypal.FUNDING.CREDIT]}:{disallowed:[paypal.FUNDING.CREDIT]},i={env:this.is_test_environment?"sandbox":"production",commit:this.button_is_pay_now(),style:t,funding:r,payment:function(){return e},onAuthorize:function(e,t){return a.on_authorize(e,t)},onError:function(e){return a.handle_integration_error(e)}},paypal.Button.render(i,n)}},{key:"button_is_pay_now",value:function(){return!o("form#add_payment_method").length}},{key:"get_button_styles",value:function(){return this.button_styles}},{key:"on_authorize",value:function(e,t){var n=this;return _(this,i),this.block_ui(),this.integration.tokenizePayment(e).then(function(e){return n.log("Payment method tokenized.",e),n.set_payment_method(e)}).catch(function(e){return n.handle_payment_error(e),n.unblock_ui()})}},{key:"set_payment_method",value:function(e){return o("input[name=wc_"+this.id+"_payment_nonce]").val(e.nonce),o("#wc_braintree_paypal_container").html(this.get_linked_account_html(e.details)),this.is_single_use()&&o("input.js-wc-braintree-paypal-tokenize-payment-method").prop("disabled",!0),o("#place_order").show(),this.form.submit()}},{key:"handle_saved_payment_methods",value:function(){var t=this;return _get(n.prototype.__proto__||Object.getPrototypeOf(n.prototype),"handle_saved_payment_methods",this).call(this),o("input.js-wc-braintree-paypal-tokenize-payment-method").change(function(e){if(null!=t.integration&&o(e.target).is(":visible"))return t.block_ui(),t.do_integration_ready()}).change()}},{key:"get_linked_account_html",value:function(e){var t;return _(this,i),t=o("<div class='wc-"+this.id_dasherized+"-account'></div>"),null!=e.firstName&&null!=e.lastName&&t.append("<span class='name'>"+e.firstName+" "+e.lastName+"</span>"),t.append("<span class='email'>"+e.email+"</span>"),t.append("<a href='#' class='cancel'>Cancel</a>"),t}},{key:"is_single_use",value:function(){var e;return 0===(e=o("input[name=wc-braintree-paypal-tokenize-payment-method]")).length||("checkbox"===e.attr("type")?!e.is(":checked"):!e.val())}},{key:"get_order_amount",value:function(){return o("input[name=wc_braintree_paypal_amount]").val()}},{key:"get_store_currency",value:function(){return o("input[name=wc_braintree_paypal_currency]").val()}},{key:"get_store_locale",value:function(){return o("input[name=wc_braintree_paypal_locale]").val()}},{key:"is_sdk_ready",value:function(){return _get(n.prototype.__proto__||Object.getPrototypeOf(n.prototype),"is_sdk_ready",this).call(this)&&"undefined"!=typeof paypal&&null!==paypal}}]),n}(),window.WC_Braintree_PayPal_Cart_Handler=function(e){function n(e){_classCallCheck(this,n);var t=_possibleConstructorReturn(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e));return t.set_payment_method_nonce=e.set_payment_method_nonce,t.cart_handler_url=e.cart_handler_url,t.form=o("form.woocommerce-cart-form"),t.form_ui_selector="",t.setup_braintree(),o(document.body).on("updated_cart_totals",function(){return t.setup_braintree()}),t}return _inherits(n,WC_Braintree_PayPal_Payment_Form_Handler),_createClass(n,[{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,o.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"===o("input[name=wc_braintree_paypal_single_use]").val()}},{key:"has_payment_nonce",value:function(){return!1}}]),n}()})}).call(void 0);
class-wc-braintree.php CHANGED
@@ -88,7 +88,7 @@ class WC_Braintree extends WC_Braintree_Framework\SV_WC_Payment_Gateway_Plugin {
88
 
89
 
90
  /** plugin version number */
91
- const VERSION = '2.2.1';
92
 
93
  /** Braintree JS SDK version */
94
  const BRAINTREE_JS_SDK_VERSION = '3.38.0';
88
 
89
 
90
  /** plugin version number */
91
+ const VERSION = '2.2.2';
92
 
93
  /** Braintree JS SDK version */
94
  const BRAINTREE_JS_SDK_VERSION = '3.38.0';
i18n/languages/woocommerce-gateway-paypal-powered-by-braintree.pot CHANGED
@@ -2,10 +2,10 @@
2
  # This file is distributed under the same license as the WooCommerce PayPal Powered by Braintree Gateway package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: WooCommerce PayPal Powered by Braintree Gateway 2.2.1\n"
6
  "Report-Msgid-Bugs-To: "
7
  "https://woocommerce.com/my-account/marketplace-ticket-form/\n"
8
- "POT-Creation-Date: 2019-02-06 23:02:07+00:00\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=utf-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
2
  # This file is distributed under the same license as the WooCommerce PayPal Powered by Braintree Gateway package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: WooCommerce PayPal Powered by Braintree Gateway 2.2.2\n"
6
  "Report-Msgid-Bugs-To: "
7
  "https://woocommerce.com/my-account/marketplace-ticket-form/\n"
8
+ "POT-Creation-Date: 2019-02-28 23:59:10+00:00\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=utf-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
lib/skyverge/license.txt CHANGED
File without changes
lib/skyverge/woocommerce/api/class-sv-wc-api-base.php CHANGED
File without changes
lib/skyverge/woocommerce/api/class-sv-wc-api-exception.php CHANGED
File without changes
lib/skyverge/woocommerce/api/interface-sv-wc-api-request.php CHANGED
File without changes
lib/skyverge/woocommerce/api/interface-sv-wc-api-response.php CHANGED
File without changes
lib/skyverge/woocommerce/class-sv-wc-admin-notice-handler.php CHANGED
File without changes
lib/skyverge/woocommerce/class-sv-wc-helper.php CHANGED
File without changes
lib/skyverge/woocommerce/class-sv-wc-hook-deprecator.php CHANGED
File without changes
lib/skyverge/woocommerce/class-sv-wc-plugin-compatibility.php CHANGED
File without changes
lib/skyverge/woocommerce/class-sv-wc-plugin-exception.php CHANGED
File without changes
lib/skyverge/woocommerce/class-sv-wc-plugin.php CHANGED
File without changes
lib/skyverge/woocommerce/class-sv-wp-admin-message-handler.php CHANGED
File without changes
lib/skyverge/woocommerce/compatibility/abstract-sv-wc-data-compatibility.php CHANGED
File without changes
lib/skyverge/woocommerce/compatibility/class-sv-wc-datetime.php CHANGED
File without changes
lib/skyverge/woocommerce/compatibility/class-sv-wc-order-compatibility.php CHANGED
File without changes
lib/skyverge/woocommerce/compatibility/class-sv-wc-product-compatibility.php CHANGED
File without changes
lib/skyverge/woocommerce/index.php CHANGED
File without changes
lib/skyverge/woocommerce/payment-gateway/admin/class-sv-wc-payment-gateway-admin-payment-token-editor.php CHANGED
File without changes
lib/skyverge/woocommerce/payment-gateway/admin/class-sv-wc-payment-gateway-admin-user-handler.php CHANGED
File without changes
lib/skyverge/woocommerce/payment-gateway/admin/views/html-admin-gateway-status.php CHANGED
File without changes
lib/skyverge/woocommerce/payment-gateway/admin/views/html-user-payment-token-editor-token.php CHANGED
File without changes
lib/skyverge/woocommerce/payment-gateway/admin/views/html-user-payment-token-editor.php CHANGED
File without changes
lib/skyverge/woocommerce/payment-gateway/admin/views/html-user-profile-field-customer-id.php CHANGED
File without changes
lib/skyverge/woocommerce/payment-gateway/admin/views/html-user-profile-section.php CHANGED
File without changes
lib/skyverge/woocommerce/payment-gateway/api/class-sv-wc-payment-gateway-api-response-message-helper.php CHANGED
File without changes
lib/skyverge/woocommerce/payment-gateway/api/interface-sv-wc-payment-gateway-api-authorization-response.php CHANGED
File without changes
lib/skyverge/woocommerce/payment-gateway/api/interface-sv-wc-payment-gateway-api-create-payment-token-response.php CHANGED
File without changes
lib/skyverge/woocommerce/payment-gateway/api/interface-sv-wc-payment-gateway-api-customer-response.php CHANGED
File without changes
lib/skyverge/woocommerce/payment-gateway/api/interface-sv-wc-payment-gateway-api-get-tokenized-payment-methods-response.php CHANGED
File without changes
lib/skyverge/woocommerce/payment-gateway/api/interface-sv-wc-payment-gateway-api-request.php CHANGED
File without changes
lib/skyverge/woocommerce/payment-gateway/api/interface-sv-wc-payment-gateway-api-response.php CHANGED
File without changes
lib/skyverge/woocommerce/payment-gateway/api/interface-sv-wc-payment-gateway-api.php CHANGED
File without changes
lib/skyverge/woocommerce/payment-gateway/assets/css/admin/sv-wc-payment-gateway-token-editor.scss CHANGED
File without changes
lib/skyverge/woocommerce/payment-gateway/assets/css/frontend/sv-wc-payment-gateway-my-payment-methods.scss CHANGED
File without changes
lib/skyverge/woocommerce/payment-gateway/assets/css/frontend/sv-wc-payment-gateway-payment-form.scss CHANGED
File without changes
lib/skyverge/woocommerce/payment-gateway/assets/js/frontend/sv-wc-payment-gateway-payment-form.coffee CHANGED
File without changes
lib/skyverge/woocommerce/payment-gateway/assets/js/frontend/sv-wc-payment-gateway-payment-form.min.js CHANGED
File without changes
lib/skyverge/woocommerce/payment-gateway/class-sv-wc-payment-gateway-direct.php CHANGED
File without changes
lib/skyverge/woocommerce/payment-gateway/class-sv-wc-payment-gateway-helper.php CHANGED
File without changes
lib/skyverge/woocommerce/payment-gateway/class-sv-wc-payment-gateway-my-payment-methods.php CHANGED
File without changes
lib/skyverge/woocommerce/payment-gateway/class-sv-wc-payment-gateway-payment-form.php CHANGED
File without changes
lib/skyverge/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php CHANGED
File without changes
lib/skyverge/woocommerce/payment-gateway/class-sv-wc-payment-gateway-privacy.php CHANGED
File without changes
lib/skyverge/woocommerce/payment-gateway/class-sv-wc-payment-gateway.php CHANGED
File without changes
lib/skyverge/woocommerce/payment-gateway/exceptions/class-sv-wc-payment-gateway-exception.php CHANGED
File without changes
lib/skyverge/woocommerce/payment-gateway/integrations/abstract-sv-wc-payment-gateway-integration.php CHANGED
File without changes
lib/skyverge/woocommerce/payment-gateway/integrations/class-sv-wc-payment-gateway-integration-pre-orders.php CHANGED
File without changes
lib/skyverge/woocommerce/payment-gateway/integrations/class-sv-wc-payment-gateway-integration-subscriptions.php CHANGED
File without changes
lib/skyverge/woocommerce/payment-gateway/payment-tokens/class-sv-wc-payment-gateway-payment-token.php CHANGED
File without changes
lib/skyverge/woocommerce/payment-gateway/payment-tokens/class-sv-wc-payment-gateway-payment-tokens-handler.php CHANGED
File without changes
readme.txt CHANGED
@@ -2,9 +2,9 @@
2
  Contributors: automattic, akeda, allendav, royho, slash1andy, woosteve, spraveenitpro, mikedmoore, fernashes, shellbeezy, danieldudzic, dsmithweb, fullysupportedphil, corsonr, zandyring, skyverge
3
  Tags: ecommerce, e-commerce, commerce, woothemes, wordpress ecommerce, store, sales, sell, shop, shopping, cart, checkout, configurable, paypal, braintree
4
  Requires at least: 4.4
5
- Tested up to: 5.0.3
6
  Requires PHP: 5.4
7
- Stable tag: 2.2.1
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -124,6 +124,9 @@ New feature requests and bugs reports can be made in the plugin forum.
124
 
125
  == Changelog ==
126
 
 
 
 
127
  = 2019.02.06 - version 2.2.1 =
128
  * Fix - Ensure updated order totals are used for validating 3D Secure when the checkout is refreshed
129
  * Fix - Prevent 3D Secure errors when non-US region codes are used during validation
2
  Contributors: automattic, akeda, allendav, royho, slash1andy, woosteve, spraveenitpro, mikedmoore, fernashes, shellbeezy, danieldudzic, dsmithweb, fullysupportedphil, corsonr, zandyring, skyverge
3
  Tags: ecommerce, e-commerce, commerce, woothemes, wordpress ecommerce, store, sales, sell, shop, shopping, cart, checkout, configurable, paypal, braintree
4
  Requires at least: 4.4
5
+ Tested up to: 5.1
6
  Requires PHP: 5.4
7
+ Stable tag: 2.2.2
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
124
 
125
  == Changelog ==
126
 
127
+ = 2019.02.28 - version 2.2.2 =
128
+ * Fix - Prevent JS errors when reloading the payment form in IE and Edge
129
+
130
  = 2019.02.06 - version 2.2.1 =
131
  * Fix - Ensure updated order totals are used for validating 3D Secure when the checkout is refreshed
132
  * Fix - Prevent 3D Secure errors when non-US region codes are used during validation
woocommerce-gateway-paypal-powered-by-braintree.php CHANGED
@@ -5,12 +5,12 @@
5
  * Description: Receive credit card or PayPal payments using Paypal Powered by Braintree. A server with cURL, SSL support, and a valid SSL certificate is required (for security reasons) for this gateway to function. Requires PHP 5.4+
6
  * Author: WooCommerce
7
  * Author URI: http://woocommerce.com/
8
- * Version: 2.2.1
9
  * Text Domain: woocommerce-gateway-paypal-powered-by-braintree
10
  * Domain Path: /i18n/languages/
11
  *
12
  * WC requires at least: 2.6.14
13
- * WC tested up to: 3.5.4
14
  *
15
  * Copyright (c) 2016-2019, Automattic, Inc.
16
  *
5
  * Description: Receive credit card or PayPal payments using Paypal Powered by Braintree. A server with cURL, SSL support, and a valid SSL certificate is required (for security reasons) for this gateway to function. Requires PHP 5.4+
6
  * Author: WooCommerce
7
  * Author URI: http://woocommerce.com/
8
+ * Version: 2.2.2
9
  * Text Domain: woocommerce-gateway-paypal-powered-by-braintree
10
  * Domain Path: /i18n/languages/
11
  *
12
  * WC requires at least: 2.6.14
13
+ * WC tested up to: 3.5.5
14
  *
15
  * Copyright (c) 2016-2019, Automattic, Inc.
16
  *