Version Description
- Fix - Purchasing a subscription with PayPal could lead to a blank order note being added
- Fix - Ensure all upgrade routines run for users who have used both the SkyVerge Braintree and PayPal Powered by Braintree v1 in the past
- Fix - Issue where existing subscriptions in some cases couldn't switch to using a new PayPal account
- Fix - Ensure "Place Order" button always remains visible for PayPal when accepting terms
Download this release
Release Info
Developer | royho |
Plugin | WooCommerce PayPal Powered by Braintree Payment Gateway |
Version | 2.0.1 |
Comparing to | |
See all releases |
Code changes from version 2.0.0 to 2.0.1
- assets/js/frontend/wc-braintree.min.js +1 -1
- class-wc-braintree.php +94 -79
- i18n/languages/woocommerce-gateway-paypal-powered-by-braintree.pot +22 -16
- includes/api/class-wc-braintree-api.php +1 -1
- includes/class-wc-braintree-payment-method-handler.php +26 -0
- includes/class-wc-gateway-braintree-paypal.php +3 -0
- includes/class-wc-gateway-braintree.php +20 -1
- readme.txt +13 -29
- woocommerce-gateway-paypal-powered-by-braintree.php +1 -1
assets/js/frontend/wc-braintree.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
(function(){var a=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a},b={}.hasOwnProperty;jQuery(document).ready(function(b){"use strict";return window.WC_Braintree_Payment_Form_Handler=function(){function a(a){this.id=a.id,this.id_dasherized=a.id_dasherized,this.type=a.type,this.debug=a.debug,this.params=window.wc_braintree_params,"undefined"!=typeof braintree&&null!==braintree&&(b("form.checkout").length?this.handle_checkout_page():b("form#order_review").length?this.handle_pay_page():b("form#add_payment_method").length&&this.handle_add_payment_method_page())}return a.prototype.handle_checkout_page=function(){return this.form=b("form.checkout"),this.form_ui_selector=".woocommerce-checkout-payment",b(document.body).on("updated_checkout",function(a){return function(){return a.setup_braintree()}}(this)),b(document.body).on("updated_checkout",function(a){return function(){return a.handle_saved_payment_methods()}}(this)),b(document.body).on("checkout_error",function(a){return function(){return a.unblock_ui(),b("input[name=wc_"+a.id+"_payment_nonce]").val("")}}(this)),this.form.on("checkout_place_order_"+this.id,function(a){return function(){return a.block_ui(),a.verify_form()}}(this))},a.prototype.handle_pay_page=function(){return this.form=b("form#order_review"),this.form_ui_selector="#payment",this.handle_saved_payment_methods(),this.setup_braintree(),this.form.submit(function(a){return function(){if(a.block_ui(),a.verify_form())return HTMLFormElement.prototype.submit.call(a.form[0])}}(this))},a.prototype.handle_add_payment_method_page=function(){return this.form=b("form#add_payment_method"),this.form_ui_selector="#payment",this.setup_braintree(),this.form.submit(function(a){return function(){return!(a.is_braintree_selected()&&!a.has_payment_nonce())&&HTMLFormElement.prototype.submit.call(a.form[0])}}(this))},a.prototype.verify_form=function(){return!this.is_braintree_selected()||(!!this.using_payment_token()||!!this.has_payment_nonce()&&void 0)},a.prototype.submit_form=function(a){return b("input[name=wc_"+this.id+"_payment_nonce]").val(a),this.form.submit()},a.prototype.handle_saved_payment_methods=function(){var a;return a=b("div.js-wc-"+this.id_dasherized+"-new-payment-method-form"),b("input.js-wc-"+this.id_dasherized+"-payment-token").change(function(c){return function(){var d;return d=b("input.js-wc-"+c.id_dasherized+"-payment-token:checked").val(),d?a.slideUp(200):a.slideDown(200)}}(this)).change(),b("input#createaccount").change(function(a){return function(c){var d;return d=b("input.js-wc-"+a.id_dasherized+"-tokenize-payment-method").closest("p.form-row"),b(c.target).is(":checked")?(d.slideDown(),d.next().show()):(d.hide(),d.next().hide())}}(this)).change()},a.prototype.setup_braintree=function(){},a.prototype.refresh_braintree=function(){if(null!=this.integration)return this.block_ui(),this.integration.teardown(function(a){return function(){return a.integration=null,a.setup_braintree()}}(this))},a.prototype.teardown_braintree=function(){if(null!=this.integration)return this.block_ui(),this.integration.teardown(function(a){return function(){return a.integration=null,a.unblock_ui()}}(this))},a.prototype.on_payment_method_received=function(a){},a.prototype.on_error=function(a){if("VALIDATION"===a.type){if(!this.is_braintree_selected())return;if(this.id!==this.get_selected_gateway_id())return;this.render_error(this.get_error_message(a))}else this.log("configuration error",a.message);return this.unblock_ui()},a.prototype.get_error_message=function(a){},a.prototype.on_ready=function(a){return this.unblock_ui(),this.integration=a},a.prototype.block_ui=function(){return b(this.form_ui_selector).block({message:null,overlayCSS:{background:"#fff",opacity:.6}})},a.prototype.unblock_ui=function(){return b(this.form_ui_selector).unblock()},a.prototype.render_error=function(a){return b(".woocommerce-error, .woocommerce-message").remove(),this.form.prepend('<div class="woocommerce-error">'+a+"</div>").removeClass("processing").unblock(),b("html, body").animate({scrollTop:this.form.offset().top-100},1e3),b("input[name=wc_"+this.id+"_payment_nonce]").val(""),this.form.trigger("wc_"+this.id+"_rendered_error"),this.unblock_ui()},a.prototype.has_payment_nonce=function(){return this.form.find("input[name=wc_"+this.get_selected_gateway_id()+"_payment_nonce]").val()},a.prototype.using_payment_token=function(){return this.form.find("input.js-wc-"+this.get_selected_gateway_id_dasherized()+"-payment-token:checked").val()},a.prototype.get_selected_gateway_id=function(){return this.form.find("input[name=payment_method]:checked").val()},a.prototype.get_selected_gateway_id_dasherized=function(){return this.get_selected_gateway_id().replace(/_/g,"-")},a.prototype.is_braintree_selected=function(){var a;return"braintree_credit_card"===(a=this.form.find("input[name=payment_method]:checked").val())||"braintree_paypal"===a},a.prototype.is_credit_card_selected=function(){return"braintree_credit_card"===this.get_selected_gateway_id()},a.prototype.is_paypal_selected=function(){return"braintree_paypal"===this.get_selected_gateway_id()},a.prototype.log=function(a,b){if(this.debug)return console.log(a),console.log(b)},a}(),window.WC_Braintree_Credit_Card_Payment_Form_Handler=function(c){function d(a){this.csc_required=a.csc_required,this.hosted_fields_styles=a.hosted_fields_styles,this.threeds=a.threeds,d.__super__.constructor.call(this,a),this.is_3d_secure_enabled()&&this.setup_3d_secure()}return a(d,c),d.prototype.verify_form=function(){var a,c;return!this.is_braintree_selected()||(c=d.__super__.verify_form.call(this),!(this.csc_required&&!this.has_payment_nonce())&&(a=b("input.js-wc-braintree-credit-card-payment-token:checked"),this.should_verify_3d_secure_token(a)&&(this.verify_3d_secure(a.data("nonce"),a),c=!1),c))},d.prototype.setup_braintree=function(){var a;return this.integration?this.refresh_braintree():(this.block_ui(),a={number:{selector:"#wc-braintree-credit-card-account-number-hosted"},cvv:{selector:"#wc-braintree-credit-card-csc-hosted"},expirationDate:{selector:"#wc-braintree-credit-card-expiry-hosted"},styles:this.hosted_fields_styles,onFieldEvent:function(a){return function(b){return a.on_hosted_field_event(b)}}(this)},this.csc_required&&this.form.find("input.js-wc-"+this.id_dasherized+"-payment-token:checked").val()&&(delete a.number,delete a.expirationDate),this.csc_required||delete a.cvv,braintree.setup(this.params.client_token,"custom",{id:this.form[0],hostedFields:a,onPaymentMethodReceived:function(a){return function(b){return a.on_payment_method_received(b)}}(this),onError:function(a){return function(b){return a.on_error(b)}}(this),onReady:function(a){return function(b){return a.on_ready(b)}}(this)}))},d.prototype.on_ready=function(a){if(d.__super__.on_ready.call(this,a),!this.csc_required&&b("input.js-wc-braintree-credit-card-payment-token:checked").val())return this.teardown_braintree()},d.prototype.handle_saved_payment_methods=function(){var a,c;return d.__super__.handle_saved_payment_methods.call(this),c=b("div.js-wc-braintree-credit-card-new-payment-method-form"),a=b("div.wc-braintree-hosted-field-card-csc-parent"),b("input.js-wc-braintree-credit-card-payment-token").change(function(d){return function(){var e;return e=b("input.js-wc-braintree-credit-card-payment-token:checked").val(),e?d.csc_required&&a.hasClass("form-row-last")?(a.removeClass("form-row-last").addClass("form-row-first"),c.after(a),d.refresh_braintree()):void 0:d.csc_required&&a.hasClass("form-row-first")?(a.removeClass("form-row-first").addClass("form-row-last"),c.find("div.wc-braintree-hosted-field-card-expiry-parent").after(a),d.refresh_braintree()):d.setup_braintree()}}(this)).change()},d.prototype.get_error_message=function(a){var b,c,d,e;if(d=[],null!=a.details)for(e=a.details.invalidFieldKeys,b=0,c=e.length;b<c;b++)switch(e[b]){case"number":d.push(this.params.card_number_invalid);break;case"cvv":d.push(this.params.cvv_length_invalid);break;case"expirationDate":d.push(this.params.card_exp_date_invalid)}else switch(a.message){case"User did not enter a payment method":this.csc_required?this.using_payment_token()?d.push(this.params.cvv_missing):d.push(this.params.card_number_missing,this.params.card_exp_date_invalid,this.params.cvv_missing):d.push(this.params.card_number_missing,this.params.card_exp_date_invalid)}return d.length||d.push(a.message),d.join("<br/>")},d.prototype.on_payment_method_received=function(a){if(this.log("payment method received",a),null!=a.nonce)return this.should_verify_3d_secure(a)?this.verify_3d_secure(a.nonce):this.submit_form(a.nonce)},d.prototype.on_hosted_field_event=function(a){var c;if(c=b(".wc-braintree-hosted-field-card-number"),c.attr("class",function(a,b){return b.replace(/(^|\s)card-type-\S+/g,"")}),null!=a.card)return c.addClass("card-type-"+a.card.type)},d.prototype.is_3d_secure_enabled=function(){return this.threeds.enabled},d.prototype.setup_3d_secure=function(){return this.client=new braintree.api.Client({clientToken:this.params.client_token})},d.prototype.should_verify_3d_secure=function(a){var b;return b=a.details.cardType,this.is_3d_secure_enabled()&&"CreditCard"===a.type&&("Visa"===b||"MasterCard"===b)},d.prototype.should_verify_3d_secure_token=function(a){if(a.val()&&a.data("nonce")&&!a.data("verified"))return!0},d.prototype.verify_3d_secure=function(a,c){var d;return null==c&&(c=null),d=b("input[name=wc_braintree_credit_card_3d_secure_order_total]").val(),this.client.verify3DS({amount:d,creditCard:a},function(a){return function(d,e){return d?(a.render_error(d.message),a.log("3DS error",d)):(a.log("3DS response",e),a.threeds.liability_shift_always_required&&!e.verificationDetails.liabilityShifted&&a.render_error(a.threeds.failure_message),e.verificationDetails.liabilityShiftPossible&&!e.verificationDetails.liabilityShifted&&a.render_error(a.threeds.failure_message),null!=c&&c.data("verified",!0),b("input[name=wc_braintree_credit_card_3d_secure_verified]").val(1),a.submit_form(e.nonce))}}(this))},d}(WC_Braintree_Payment_Form_Handler),window.WC_Braintree_PayPal_Payment_Form_Handler=function(c){function d(a){this.must_login_message=a.must_login_message,this.must_login_add_method_message=a.must_login_add_method_message,d.__super__.constructor.call(this,a),b(document.body).on("click",'input[name="payment_method"], input.js-wc-braintree-paypal-payment-token',function(a){return function(){return!a.is_paypal_selected()||a.has_payment_nonce()||a.using_payment_token()?b("#place_order").show():b("#place_order").hide()}}(this))}return a(d,c),d.prototype.verify_form=function(){var a;return!this.is_braintree_selected()||(a=d.__super__.verify_form.call(this),this.has_payment_nonce()||this.render_error(this.must_login_message),a)},d.prototype.handle_add_payment_method_page=function(){return this.form=b("form#add_payment_method"),this.form_ui_selector="#payment",this.setup_braintree(),this.form.submit(function(a){return function(){return a.is_paypal_selected()&&(a.has_payment_nonce()||a.render_error(a.must_login_add_method_message)),!(a.is_braintree_selected()&&!a.has_payment_nonce())&&HTMLFormElement.prototype.submit.call(a.form[0])}}(this))},d.prototype.setup_braintree=function(){if(!this.has_payment_nonce())return this.block_ui(),braintree.setup(this.params.client_token,"paypal",{container:"wc_braintree_paypal_container",singleUse:this.is_single_use(),amount:this.get_order_amount(),currency:this.get_store_currency(),locale:this.get_store_locale(),onPaymentMethodReceived:function(a){return function(b){return a.on_payment_method_received(b)}}(this),onError:function(a){return function(b){return a.on_error(b)}}(this),onReady:function(a){return function(b){return a.on_ready(b)}}(this),onCancelled:function(a){return function(){return a.on_cancelled()}}(this),onUnsupported:function(a){return function(b){return a.on_unsupported(b)}}(this)})},d.prototype.on_cancelled=function(){if(b("input.js-wc-braintree-paypal-tokenize-payment-method").prop("disabled",!1),b("input[name=wc_braintree_paypal_payment_nonce]").val(""),this.is_paypal_selected())return b("#place_order").hide()},d.prototype.on_unsupported=function(a){return this.log("PayPal error",a),this.render_error(this.params.generic_error_message)},d.prototype.handle_saved_payment_methods=function(){return d.__super__.handle_saved_payment_methods.call(this),b("input.js-wc-braintree-paypal-tokenize-payment-method").change(function(a){return function(c){if(b(c.target).is(":visible"))return a.refresh_braintree()}}(this)).change()},d.prototype.on_payment_method_received=function(a){if(this.log("payment method received",a),null!=a.nonce)return this.is_single_use()&&b("input.js-wc-braintree-paypal-tokenize-payment-method").prop("disabled",!0),b("input[name=wc_braintree_paypal_payment_nonce]").val(a.nonce),b("#place_order").show()},d.prototype.is_single_use=function(){var a;return a=b("input[name=wc-braintree-paypal-tokenize-payment-method]"),0===a.length||("checkbox"===a.attr("type")?!a.is(":checked"):!a.val())},d.prototype.get_order_amount=function(){return b("input[name=wc_braintree_paypal_amount]").val()},d.prototype.get_store_currency=function(){return b("input[name=wc_braintree_paypal_currency]").val()},d.prototype.get_store_locale=function(){return b("input[name=wc_braintree_paypal_locale]").val()},d}(WC_Braintree_Payment_Form_Handler),window.WC_Braintree_PayPal_Cart_Handler=function(c){function d(a){d.__super__.constructor.call(this,a),this.form_ui_selector=".cart_totals",this.setup_braintree(),b(document.body).on("updated_cart_totals",function(a){return function(){return a.setup_braintree()}}(this))}return a(d,c),d.prototype.on_payment_method_received=function(a){if(this.log("payment method received",a),null!=a.nonce)return a.wp_nonce=this.params.cart_nonce,b.ajax({type:"POST",url:this.params.cart_handler_url,data:a,dataType:"json"}).done(function(a){return window.location=a.redirect_url})},d.prototype.is_single_use=function(){return"1"===b("input[name=wc_braintree_paypal_single_use]").val()},d.prototype.has_payment_nonce=function(){return!1},d}(WC_Braintree_PayPal_Payment_Form_Handler)})}).call(this);
|
1 |
+
(function(){var a=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a},b={}.hasOwnProperty;jQuery(document).ready(function(b){"use strict";return window.WC_Braintree_Payment_Form_Handler=function(){function a(a){this.id=a.id,this.id_dasherized=a.id_dasherized,this.type=a.type,this.debug=a.debug,this.params=window.wc_braintree_params,"undefined"!=typeof braintree&&null!==braintree&&(b("form.checkout").length?this.handle_checkout_page():b("form#order_review").length?this.handle_pay_page():b("form#add_payment_method").length&&this.handle_add_payment_method_page())}return a.prototype.handle_checkout_page=function(){return this.form=b("form.checkout"),this.form_ui_selector=".woocommerce-checkout-payment",b(document.body).on("updated_checkout",function(a){return function(){return a.setup_braintree()}}(this)),b(document.body).on("updated_checkout",function(a){return function(){return a.handle_saved_payment_methods()}}(this)),b(document.body).on("checkout_error",function(a){return function(){return a.unblock_ui(),b("input[name=wc_"+a.id+"_payment_nonce]").val("")}}(this)),this.form.on("checkout_place_order_"+this.id,function(a){return function(){return a.block_ui(),a.verify_form()}}(this))},a.prototype.handle_pay_page=function(){return this.form=b("form#order_review"),this.form_ui_selector="#payment",this.handle_saved_payment_methods(),this.setup_braintree(),this.form.submit(function(a){return function(){if(a.block_ui(),!1!==a.verify_form())return HTMLFormElement.prototype.submit.call(a.form[0])}}(this))},a.prototype.handle_add_payment_method_page=function(){return this.form=b("form#add_payment_method"),this.form_ui_selector="#payment",this.setup_braintree(),this.form.submit(function(a){return function(){return!(a.is_braintree_selected()&&!a.has_payment_nonce())&&HTMLFormElement.prototype.submit.call(a.form[0])}}(this))},a.prototype.verify_form=function(){return!this.is_braintree_selected()||(!!this.using_payment_token()||!!this.has_payment_nonce()&&void 0)},a.prototype.submit_form=function(a){return b("input[name=wc_"+this.id+"_payment_nonce]").val(a),this.form.submit()},a.prototype.handle_saved_payment_methods=function(){var a;return a=b("div.js-wc-"+this.id_dasherized+"-new-payment-method-form"),b("input.js-wc-"+this.id_dasherized+"-payment-token").change(function(c){return function(){var d;return d=b("input.js-wc-"+c.id_dasherized+"-payment-token:checked").val(),d?a.slideUp(200):a.slideDown(200)}}(this)).change(),b("input#createaccount").change(function(a){return function(c){var d;return d=b("input.js-wc-"+a.id_dasherized+"-tokenize-payment-method").closest("p.form-row"),b(c.target).is(":checked")?(d.slideDown(),d.next().show()):(d.hide(),d.next().hide())}}(this)).change()},a.prototype.setup_braintree=function(){},a.prototype.refresh_braintree=function(){if(null!=this.integration)return this.block_ui(),this.integration.teardown(function(a){return function(){return a.integration=null,a.setup_braintree()}}(this))},a.prototype.teardown_braintree=function(){if(null!=this.integration)return this.block_ui(),this.integration.teardown(function(a){return function(){return a.integration=null,a.unblock_ui()}}(this))},a.prototype.on_payment_method_received=function(a){},a.prototype.on_error=function(a){if("VALIDATION"===a.type){if(!this.is_braintree_selected())return;if(this.id!==this.get_selected_gateway_id())return;this.render_error(this.get_error_message(a))}else this.log("configuration error",a.message);return this.unblock_ui()},a.prototype.get_error_message=function(a){},a.prototype.on_ready=function(a){return this.unblock_ui(),this.integration=a},a.prototype.block_ui=function(){return b(this.form_ui_selector).block({message:null,overlayCSS:{background:"#fff",opacity:.6}})},a.prototype.unblock_ui=function(){return b(this.form_ui_selector).unblock()},a.prototype.render_error=function(a){return b(".woocommerce-error, .woocommerce-message").remove(),this.form.prepend('<div class="woocommerce-error">'+a+"</div>").removeClass("processing").unblock(),b("html, body").animate({scrollTop:this.form.offset().top-100},1e3),b("input[name=wc_"+this.id+"_payment_nonce]").val(""),this.form.trigger("wc_"+this.id+"_rendered_error"),this.unblock_ui()},a.prototype.has_payment_nonce=function(){return this.form.find("input[name=wc_"+this.get_selected_gateway_id()+"_payment_nonce]").val()},a.prototype.using_payment_token=function(){return this.form.find("input.js-wc-"+this.get_selected_gateway_id_dasherized()+"-payment-token:checked").val()},a.prototype.get_selected_gateway_id=function(){return this.form.find("input[name=payment_method]:checked").val()},a.prototype.get_selected_gateway_id_dasherized=function(){return this.get_selected_gateway_id().replace(/_/g,"-")},a.prototype.is_braintree_selected=function(){var a;return"braintree_credit_card"===(a=this.form.find("input[name=payment_method]:checked").val())||"braintree_paypal"===a},a.prototype.is_credit_card_selected=function(){return"braintree_credit_card"===this.get_selected_gateway_id()},a.prototype.is_paypal_selected=function(){return"braintree_paypal"===this.get_selected_gateway_id()},a.prototype.log=function(a,b){if(this.debug)return console.log(a),console.log(b)},a}(),window.WC_Braintree_Credit_Card_Payment_Form_Handler=function(c){function d(a){this.csc_required=a.csc_required,this.hosted_fields_styles=a.hosted_fields_styles,this.threeds=a.threeds,d.__super__.constructor.call(this,a),this.is_3d_secure_enabled()&&this.setup_3d_secure()}return a(d,c),d.prototype.verify_form=function(){var a,c;return!this.is_braintree_selected()||(c=d.__super__.verify_form.call(this),!(this.csc_required&&!this.has_payment_nonce())&&(a=b("input.js-wc-braintree-credit-card-payment-token:checked"),this.should_verify_3d_secure_token(a)&&(this.verify_3d_secure(a.data("nonce"),a),c=!1),c))},d.prototype.setup_braintree=function(){var a;return this.integration?this.refresh_braintree():(this.block_ui(),a={number:{selector:"#wc-braintree-credit-card-account-number-hosted"},cvv:{selector:"#wc-braintree-credit-card-csc-hosted"},expirationDate:{selector:"#wc-braintree-credit-card-expiry-hosted"},styles:this.hosted_fields_styles,onFieldEvent:function(a){return function(b){return a.on_hosted_field_event(b)}}(this)},this.csc_required&&this.form.find("input.js-wc-"+this.id_dasherized+"-payment-token:checked").val()&&(delete a.number,delete a.expirationDate),this.csc_required||delete a.cvv,braintree.setup(this.params.client_token,"custom",{id:this.form[0],hostedFields:a,onPaymentMethodReceived:function(a){return function(b){return a.on_payment_method_received(b)}}(this),onError:function(a){return function(b){return a.on_error(b)}}(this),onReady:function(a){return function(b){return a.on_ready(b)}}(this)}))},d.prototype.on_ready=function(a){if(d.__super__.on_ready.call(this,a),!this.csc_required&&b("input.js-wc-braintree-credit-card-payment-token:checked").val())return this.teardown_braintree()},d.prototype.handle_saved_payment_methods=function(){var a,c;return d.__super__.handle_saved_payment_methods.call(this),c=b("div.js-wc-braintree-credit-card-new-payment-method-form"),a=b("div.wc-braintree-hosted-field-card-csc-parent"),b("input.js-wc-braintree-credit-card-payment-token").change(function(d){return function(){var e;return e=b("input.js-wc-braintree-credit-card-payment-token:checked").val(),e?d.csc_required&&a.hasClass("form-row-last")?(a.removeClass("form-row-last").addClass("form-row-first"),c.after(a),d.refresh_braintree()):void 0:d.csc_required&&a.hasClass("form-row-first")?(a.removeClass("form-row-first").addClass("form-row-last"),c.find("div.wc-braintree-hosted-field-card-expiry-parent").after(a),d.refresh_braintree()):d.setup_braintree()}}(this)).change()},d.prototype.get_error_message=function(a){var b,c,d,e;if(d=[],null!=a.details)for(e=a.details.invalidFieldKeys,b=0,c=e.length;b<c;b++)switch(e[b]){case"number":d.push(this.params.card_number_invalid);break;case"cvv":d.push(this.params.cvv_length_invalid);break;case"expirationDate":d.push(this.params.card_exp_date_invalid)}else switch(a.message){case"User did not enter a payment method":this.csc_required?this.using_payment_token()?d.push(this.params.cvv_missing):d.push(this.params.card_number_missing,this.params.card_exp_date_invalid,this.params.cvv_missing):d.push(this.params.card_number_missing,this.params.card_exp_date_invalid)}return d.length||d.push(a.message),d.join("<br/>")},d.prototype.on_payment_method_received=function(a){if(this.log("payment method received",a),null!=a.nonce)return this.should_verify_3d_secure(a)?this.verify_3d_secure(a.nonce):this.submit_form(a.nonce)},d.prototype.on_hosted_field_event=function(a){var c;if(c=b(".wc-braintree-hosted-field-card-number"),c.attr("class",function(a,b){return b.replace(/(^|\s)card-type-\S+/g,"")}),null!=a.card)return c.addClass("card-type-"+a.card.type)},d.prototype.is_3d_secure_enabled=function(){return this.threeds.enabled},d.prototype.setup_3d_secure=function(){return this.client=new braintree.api.Client({clientToken:this.params.client_token})},d.prototype.should_verify_3d_secure=function(a){var b;return b=a.details.cardType,this.is_3d_secure_enabled()&&"CreditCard"===a.type&&("Visa"===b||"MasterCard"===b)},d.prototype.should_verify_3d_secure_token=function(a){if(a.val()&&a.data("nonce")&&!a.data("verified"))return!0},d.prototype.verify_3d_secure=function(a,c){var d;return null==c&&(c=null),d=b("input[name=wc_braintree_credit_card_3d_secure_order_total]").val(),this.client.verify3DS({amount:d,creditCard:a},function(a){return function(d,e){return d?(a.render_error(d.message),a.log("3DS error",d)):(a.log("3DS response",e),a.threeds.liability_shift_always_required&&!e.verificationDetails.liabilityShifted&&a.render_error(a.threeds.failure_message),e.verificationDetails.liabilityShiftPossible&&!e.verificationDetails.liabilityShifted&&a.render_error(a.threeds.failure_message),null!=c&&c.data("verified",!0),b("input[name=wc_braintree_credit_card_3d_secure_verified]").val(1),a.submit_form(e.nonce))}}(this))},d}(WC_Braintree_Payment_Form_Handler),window.WC_Braintree_PayPal_Payment_Form_Handler=function(c){function d(a){this.must_login_message=a.must_login_message,this.must_login_add_method_message=a.must_login_add_method_message,d.__super__.constructor.call(this,a),b(document.body).on("click",'input[name="payment_method"], input.js-wc-braintree-paypal-payment-token',function(a){return function(){return!a.is_paypal_selected()||a.has_payment_nonce()||a.using_payment_token()?b("#place_order").show():b("#place_order").hide()}}(this))}return a(d,c),d.prototype.handle_checkout_page=function(){return d.__super__.handle_checkout_page.call(this),b(document.body).on("checkout_error",function(a){return function(){return a.params.cart_payment_nonce?b("input[name=wc_"+a.id+"_payment_nonce]").val(a.params.cart_payment_nonce):a.setup_braintree()}}(this))},d.prototype.verify_form=function(){var a;return!this.is_braintree_selected()||(a=d.__super__.verify_form.call(this),this.has_payment_nonce()||this.using_payment_token()||this.render_error(this.must_login_message),a)},d.prototype.handle_add_payment_method_page=function(){return this.form=b("form#add_payment_method"),this.form_ui_selector="#payment",this.setup_braintree(),this.form.submit(function(a){return function(){return a.is_paypal_selected()&&(a.has_payment_nonce()||a.render_error(a.must_login_add_method_message)),!(a.is_braintree_selected()&&!a.has_payment_nonce())&&HTMLFormElement.prototype.submit.call(a.form[0])}}(this))},d.prototype.setup_braintree=function(){if(!this.params.cart_payment_nonce)return b("input[name=wc_braintree_paypal_payment_nonce]").val(""),this.integration?this.refresh_braintree():(this.block_ui(),braintree.setup(this.params.client_token,"paypal",{container:"wc_braintree_paypal_container",singleUse:this.is_single_use(),amount:this.get_order_amount(),currency:this.get_store_currency(),locale:this.get_store_locale(),onPaymentMethodReceived:function(a){return function(b){return a.on_payment_method_received(b)}}(this),onError:function(a){return function(b){return a.on_error(b)}}(this),onReady:function(a){return function(b){return a.on_ready(b)}}(this),onCancelled:function(a){return function(){return a.on_cancelled()}}(this),onUnsupported:function(a){return function(b){return a.on_unsupported(b)}}(this)}))},d.prototype.on_cancelled=function(){if(b("input.js-wc-braintree-paypal-tokenize-payment-method").prop("disabled",!1),b("input[name=wc_braintree_paypal_payment_nonce]").val(""),this.is_paypal_selected())return b("#place_order").hide()},d.prototype.on_unsupported=function(a){return this.log("PayPal error",a),this.render_error(this.params.generic_error_message)},d.prototype.handle_saved_payment_methods=function(){return d.__super__.handle_saved_payment_methods.call(this),b("input.js-wc-braintree-paypal-tokenize-payment-method").change(function(a){return function(c){if(b(c.target).is(":visible"))return a.refresh_braintree()}}(this)).change()},d.prototype.on_payment_method_received=function(a){if(this.log("payment method received",a),null!=a.nonce)return this.is_single_use()&&b("input.js-wc-braintree-paypal-tokenize-payment-method").prop("disabled",!0),b("input[name=wc_braintree_paypal_payment_nonce]").val(a.nonce),b("#place_order").show()},d.prototype.is_single_use=function(){var a;return a=b("input[name=wc-braintree-paypal-tokenize-payment-method]"),0===a.length||("checkbox"===a.attr("type")?!a.is(":checked"):!a.val())},d.prototype.get_order_amount=function(){return b("input[name=wc_braintree_paypal_amount]").val()},d.prototype.get_store_currency=function(){return b("input[name=wc_braintree_paypal_currency]").val()},d.prototype.get_store_locale=function(){return b("input[name=wc_braintree_paypal_locale]").val()},d}(WC_Braintree_Payment_Form_Handler),window.WC_Braintree_PayPal_Cart_Handler=function(c){function d(a){d.__super__.constructor.call(this,a),this.form=b("form.woocommerce-cart-form"),this.form_ui_selector=".cart_totals",this.setup_braintree(),b(document.body).on("updated_cart_totals",function(a){return function(){return a.setup_braintree()}}(this))}return a(d,c),d.prototype.on_payment_method_received=function(a){if(this.log("payment method received",a),null!=a.nonce)return a.wp_nonce=this.params.cart_nonce,b.ajax({type:"POST",url:this.params.cart_handler_url,data:a,dataType:"json"}).done(function(a){return window.location=a.redirect_url})},d.prototype.on_error=function(a){return this.log("PayPal error",a.message),this.unblock_ui()},d.prototype.on_unsupported=function(a){return console.log(a),this.unblock_ui()},d.prototype.is_single_use=function(){return"1"===b("input[name=wc_braintree_paypal_single_use]").val()},d.prototype.has_payment_nonce=function(){return!1},d}(WC_Braintree_PayPal_Payment_Form_Handler)})}).call(this);
|
class-wc-braintree.php
CHANGED
@@ -88,7 +88,7 @@ class WC_Braintree extends WC_Braintree_Framework\SV_WC_Payment_Gateway_Plugin {
|
|
88 |
|
89 |
|
90 |
/** plugin version number */
|
91 |
-
const VERSION = '2.0.
|
92 |
|
93 |
/** @var WC_Braintree single instance of this plugin */
|
94 |
protected static $instance;
|
@@ -635,88 +635,18 @@ class WC_Braintree extends WC_Braintree_Framework\SV_WC_Payment_Gateway_Plugin {
|
|
635 |
|
636 |
$this->log( 'Settings upgraded' );
|
637 |
|
638 |
-
|
639 |
-
|
640 |
-
$order_meta = array(
|
641 |
-
'_wc_paypal_braintree_customer_id' => 'customer_id',
|
642 |
-
'_wc_paypal_braintree_payment_method_token' => 'payment_token',
|
643 |
-
'_pp_braintree_charge_captured' => 'charge_captured',
|
644 |
-
);
|
645 |
-
|
646 |
-
$count = 0;
|
647 |
-
|
648 |
-
foreach ( $order_meta as $legacy_key => $new_suffix ) {
|
649 |
-
|
650 |
-
// update for the credit card gateway
|
651 |
-
$rows = $wpdb->query(
|
652 |
-
$wpdb->prepare(
|
653 |
-
"
|
654 |
-
UPDATE {$wpdb->postmeta} meta1, {$wpdb->postmeta} meta2
|
655 |
-
SET meta1.meta_key = %s
|
656 |
-
WHERE meta1.meta_key = %s
|
657 |
-
AND meta2.meta_key = '_payment_method'
|
658 |
-
AND meta2.meta_value = 'paypalbraintree_cards'
|
659 |
-
AND meta1.post_id = meta2.post_id
|
660 |
-
",
|
661 |
-
[
|
662 |
-
'_wc_braintree_credit_card_' . $new_suffix,
|
663 |
-
$legacy_key,
|
664 |
-
]
|
665 |
-
)
|
666 |
-
);
|
667 |
-
|
668 |
-
$count += $rows;
|
669 |
-
|
670 |
-
// update for the paypal gateway
|
671 |
-
$rows = $wpdb->query(
|
672 |
-
$wpdb->prepare(
|
673 |
-
"
|
674 |
-
UPDATE {$wpdb->postmeta} meta1, {$wpdb->postmeta} meta2
|
675 |
-
SET meta1.meta_key = %s
|
676 |
-
WHERE meta1.meta_key = %s
|
677 |
-
AND meta2.meta_key = '_payment_method'
|
678 |
-
AND meta2.meta_value = 'paypalbraintree_paypal'
|
679 |
-
AND meta1.post_id = meta2.post_id
|
680 |
-
",
|
681 |
-
[
|
682 |
-
'_wc_braintree_paypal_' . $new_suffix,
|
683 |
-
$legacy_key,
|
684 |
-
]
|
685 |
-
)
|
686 |
-
);
|
687 |
-
|
688 |
-
$count += $rows;
|
689 |
-
}
|
690 |
-
|
691 |
-
if ( $rows = $wpdb->update( $wpdb->postmeta, array( 'meta_value' => 'braintree_credit_card' ), array( 'meta_key' => '_payment_method', 'meta_value' => 'paypalbraintree_cards' ) ) ) {
|
692 |
-
$count += $rows;
|
693 |
-
}
|
694 |
-
if ( $rows = $wpdb->update( $wpdb->postmeta, array( 'meta_value' => 'braintree_paypal' ), array( 'meta_key' => '_payment_method', 'meta_value' => 'paypalbraintree_paypal' ) ) ) {
|
695 |
-
$count += $rows;
|
696 |
-
}
|
697 |
-
|
698 |
-
if ( $count ) {
|
699 |
-
$this->log( sprintf( '%d rows of order meta data updated.', $count ) );
|
700 |
-
}
|
701 |
-
|
702 |
-
/** Update user meta data *****************************************/
|
703 |
-
|
704 |
-
$customer_id_meta_key = 'wc_braintree_customer_id';
|
705 |
-
|
706 |
-
if ( $environment !== WC_Gateway_Braintree::ENVIRONMENT_PRODUCTION ) {
|
707 |
-
$customer_id_meta_key .= '_' . $environment;
|
708 |
-
}
|
709 |
-
|
710 |
-
// Customer IDs
|
711 |
-
// old key: _wc_paypal_braintree_customer_id
|
712 |
-
// new key: wc_braintree_customer_id
|
713 |
-
if ( $rows = $wpdb->update( $wpdb->usermeta, array( 'meta_key' => $customer_id_meta_key ), array( 'meta_key' => '_wc_paypal_braintree_customer_id' ) ) ) {
|
714 |
-
$this->log( sprintf( '%d user customer IDs updated.', $rows ) );
|
715 |
-
}
|
716 |
|
|
|
717 |
wp_cache_flush();
|
718 |
|
719 |
$this->log( 'Completed upgrade for 2.0.0' );
|
|
|
|
|
|
|
|
|
|
|
720 |
}
|
721 |
}
|
722 |
|
@@ -748,10 +678,95 @@ class WC_Braintree extends WC_Braintree_Framework\SV_WC_Payment_Gateway_Plugin {
|
|
748 |
|
749 |
update_option( 'wc_braintree_legacy_migrated', 'yes' );
|
750 |
|
|
|
|
|
|
|
|
|
751 |
$this->log( 'Completed migration to ' . $this->get_plugin_name() );
|
752 |
}
|
753 |
|
754 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
755 |
/**
|
756 |
* Determines if WooCommerce is active.
|
757 |
*
|
88 |
|
89 |
|
90 |
/** plugin version number */
|
91 |
+
const VERSION = '2.0.1';
|
92 |
|
93 |
/** @var WC_Braintree single instance of this plugin */
|
94 |
protected static $instance;
|
635 |
|
636 |
$this->log( 'Settings upgraded' );
|
637 |
|
638 |
+
// update the legacy order & user meta
|
639 |
+
$this->update_legacy_meta();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
640 |
|
641 |
+
// flush the options cache to ensure notices are displayed correctly
|
642 |
wp_cache_flush();
|
643 |
|
644 |
$this->log( 'Completed upgrade for 2.0.0' );
|
645 |
+
|
646 |
+
} elseif ( version_compare( $installed_version, '2.0.1', '<' ) ) {
|
647 |
+
|
648 |
+
// update meta again for those that may be seeing the legacy migration issue from previous installs
|
649 |
+
$this->update_legacy_meta();
|
650 |
}
|
651 |
}
|
652 |
|
678 |
|
679 |
update_option( 'wc_braintree_legacy_migrated', 'yes' );
|
680 |
|
681 |
+
// update legacy meta in case users had previously switched to v1 from
|
682 |
+
// the SkyVerge plugin prior to this migration
|
683 |
+
$this->update_legacy_meta();
|
684 |
+
|
685 |
$this->log( 'Completed migration to ' . $this->get_plugin_name() );
|
686 |
}
|
687 |
|
688 |
|
689 |
+
/**
|
690 |
+
* Migrates Braintree legacy order, subscription, and user meta to v2.
|
691 |
+
*
|
692 |
+
* @since 2.0.1
|
693 |
+
*/
|
694 |
+
protected function update_legacy_meta() {
|
695 |
+
global $wpdb;
|
696 |
+
|
697 |
+
$this->log( 'Updating legacy meta' );
|
698 |
+
|
699 |
+
$order_meta = array(
|
700 |
+
'_wc_paypal_braintree_customer_id' => 'customer_id',
|
701 |
+
'_wc_paypal_braintree_payment_method_token' => 'payment_token',
|
702 |
+
'_pp_braintree_charge_captured' => 'charge_captured',
|
703 |
+
);
|
704 |
+
|
705 |
+
$count = 0;
|
706 |
+
|
707 |
+
foreach ( $order_meta as $legacy_key => $new_suffix ) {
|
708 |
+
|
709 |
+
// update for the credit card gateway
|
710 |
+
$rows = $wpdb->query(
|
711 |
+
$wpdb->prepare(
|
712 |
+
"
|
713 |
+
UPDATE {$wpdb->postmeta} meta1, {$wpdb->postmeta} meta2
|
714 |
+
SET meta1.meta_key = %s
|
715 |
+
WHERE meta1.meta_key = %s
|
716 |
+
AND meta2.meta_key = '_payment_method'
|
717 |
+
AND meta2.meta_value = 'paypalbraintree_cards'
|
718 |
+
AND meta1.post_id = meta2.post_id
|
719 |
+
",
|
720 |
+
[
|
721 |
+
'_wc_braintree_credit_card_' . $new_suffix,
|
722 |
+
$legacy_key,
|
723 |
+
]
|
724 |
+
)
|
725 |
+
);
|
726 |
+
|
727 |
+
$count += $rows;
|
728 |
+
|
729 |
+
// update for the paypal gateway
|
730 |
+
$rows = $wpdb->query(
|
731 |
+
$wpdb->prepare(
|
732 |
+
"
|
733 |
+
UPDATE {$wpdb->postmeta} meta1, {$wpdb->postmeta} meta2
|
734 |
+
SET meta1.meta_key = %s
|
735 |
+
WHERE meta1.meta_key = %s
|
736 |
+
AND meta2.meta_key = '_payment_method'
|
737 |
+
AND meta2.meta_value = 'paypalbraintree_paypal'
|
738 |
+
AND meta1.post_id = meta2.post_id
|
739 |
+
",
|
740 |
+
[
|
741 |
+
'_wc_braintree_paypal_' . $new_suffix,
|
742 |
+
$legacy_key,
|
743 |
+
]
|
744 |
+
)
|
745 |
+
);
|
746 |
+
|
747 |
+
$count += $rows;
|
748 |
+
}
|
749 |
+
|
750 |
+
if ( $rows = $wpdb->update( $wpdb->postmeta, array( 'meta_value' => 'braintree_credit_card' ), array( 'meta_key' => '_payment_method', 'meta_value' => 'paypalbraintree_cards' ) ) ) {
|
751 |
+
$count += $rows;
|
752 |
+
}
|
753 |
+
if ( $rows = $wpdb->update( $wpdb->postmeta, array( 'meta_value' => 'braintree_paypal' ), array( 'meta_key' => '_payment_method', 'meta_value' => 'paypalbraintree_paypal' ) ) ) {
|
754 |
+
$count += $rows;
|
755 |
+
}
|
756 |
+
|
757 |
+
if ( $count ) {
|
758 |
+
$this->log( sprintf( '%d rows of order meta data updated.', $count ) );
|
759 |
+
}
|
760 |
+
|
761 |
+
// Customer IDs
|
762 |
+
// old key: _wc_paypal_braintree_customer_id
|
763 |
+
// new key: wc_braintree_customer_id
|
764 |
+
if ( $rows = $wpdb->update( $wpdb->usermeta, array( 'meta_key' => 'wc_braintree_customer_id' ), array( 'meta_key' => '_wc_paypal_braintree_customer_id' ) ) ) {
|
765 |
+
$this->log( sprintf( '%d user customer IDs updated.', $rows ) );
|
766 |
+
}
|
767 |
+
}
|
768 |
+
|
769 |
+
|
770 |
/**
|
771 |
* Determines if WooCommerce is active.
|
772 |
*
|
i18n/languages/woocommerce-gateway-paypal-powered-by-braintree.pot
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
# This file is distributed under the same license as the WooCommerce PayPal Powered by Braintree Gateway package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: WooCommerce PayPal Powered by Braintree Gateway 2.0.
|
6 |
"Report-Msgid-Bugs-To: "
|
7 |
"https://wordpress.org/support/plugin/woocommerce-gateway-paypal-powered-by-"
|
8 |
"braintree/\n"
|
@@ -141,6 +141,12 @@ msgstr ""
|
|
141 |
msgid "(default)"
|
142 |
msgstr ""
|
143 |
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
#: includes/class-wc-braintree-paypal-cart.php:370
|
145 |
msgid "Cancel"
|
146 |
msgstr ""
|
@@ -243,60 +249,60 @@ msgstr ""
|
|
243 |
msgid "Allow customers to securely pay using their PayPal account via Braintree."
|
244 |
msgstr ""
|
245 |
|
246 |
-
#: includes/class-wc-gateway-braintree-paypal.php:
|
247 |
msgid "Token ID"
|
248 |
msgstr ""
|
249 |
|
250 |
-
#: includes/class-wc-gateway-braintree-paypal.php:
|
251 |
msgid "Email"
|
252 |
msgstr ""
|
253 |
|
254 |
-
#: includes/class-wc-gateway-braintree-paypal.php:
|
255 |
msgid "Use a new PayPal account"
|
256 |
msgstr ""
|
257 |
|
258 |
-
#: includes/class-wc-gateway-braintree-paypal.php:
|
259 |
msgid "PayPal Accounts"
|
260 |
msgstr ""
|
261 |
|
262 |
-
#: includes/class-wc-gateway-braintree-paypal.php:
|
263 |
msgid "Unlink"
|
264 |
msgstr ""
|
265 |
|
266 |
-
#: includes/class-wc-gateway-braintree-paypal.php:
|
267 |
#. translators: Placeholders: %1$s - payment method title (e.g. PayPal), %2$s -
|
268 |
#. transaction environment (either Sandbox or blank string), %3$s - type of
|
269 |
#. transaction (either Authorization or Payment)
|
270 |
msgid "%1$s %2$s %3$s Approved"
|
271 |
msgstr ""
|
272 |
|
273 |
-
#: includes/class-wc-gateway-braintree-paypal.php:
|
274 |
-
#: includes/class-wc-gateway-braintree.php:
|
275 |
msgid "Sandbox"
|
276 |
msgstr ""
|
277 |
|
278 |
-
#: includes/class-wc-gateway-braintree-paypal.php:
|
279 |
msgid "Authorization"
|
280 |
msgstr ""
|
281 |
|
282 |
-
#: includes/class-wc-gateway-braintree-paypal.php:
|
283 |
msgid "Payment"
|
284 |
msgstr ""
|
285 |
|
286 |
-
#: includes/class-wc-gateway-braintree-paypal.php:
|
287 |
#. translators: Placeholders: %s - transaction ID
|
288 |
msgid "(Transaction ID %s)"
|
289 |
msgstr ""
|
290 |
|
291 |
-
#: includes/class-wc-gateway-braintree-paypal.php:
|
292 |
msgid "PayPal Account Saved: %s"
|
293 |
msgstr ""
|
294 |
|
295 |
-
#: includes/class-wc-gateway-braintree-paypal.php:
|
296 |
msgid "PayPal"
|
297 |
msgstr ""
|
298 |
|
299 |
-
#: includes/class-wc-gateway-braintree-paypal.php:
|
300 |
msgid ""
|
301 |
"Click the PayPal icon below to sign into your PayPal account and pay "
|
302 |
"securely."
|
@@ -460,7 +466,7 @@ msgstr ""
|
|
460 |
msgid "Remove this merchant account ID"
|
461 |
msgstr ""
|
462 |
|
463 |
-
#: includes/class-wc-gateway-braintree.php:
|
464 |
msgid "Production"
|
465 |
msgstr ""
|
466 |
|
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.0.1\n"
|
6 |
"Report-Msgid-Bugs-To: "
|
7 |
"https://wordpress.org/support/plugin/woocommerce-gateway-paypal-powered-by-"
|
8 |
"braintree/\n"
|
141 |
msgid "(default)"
|
142 |
msgstr ""
|
143 |
|
144 |
+
#: includes/class-wc-braintree-payment-method-handler.php:96
|
145 |
+
#. translators: Placeholders: %1$s - payment gateway title (PayPal), %2$s -
|
146 |
+
#. PayPal account email address
|
147 |
+
msgid "%1$s Account Saved: %2$s"
|
148 |
+
msgstr ""
|
149 |
+
|
150 |
#: includes/class-wc-braintree-paypal-cart.php:370
|
151 |
msgid "Cancel"
|
152 |
msgstr ""
|
249 |
msgid "Allow customers to securely pay using their PayPal account via Braintree."
|
250 |
msgstr ""
|
251 |
|
252 |
+
#: includes/class-wc-gateway-braintree-paypal.php:122
|
253 |
msgid "Token ID"
|
254 |
msgstr ""
|
255 |
|
256 |
+
#: includes/class-wc-gateway-braintree-paypal.php:127
|
257 |
msgid "Email"
|
258 |
msgstr ""
|
259 |
|
260 |
+
#: includes/class-wc-gateway-braintree-paypal.php:166
|
261 |
msgid "Use a new PayPal account"
|
262 |
msgstr ""
|
263 |
|
264 |
+
#: includes/class-wc-gateway-braintree-paypal.php:170
|
265 |
msgid "PayPal Accounts"
|
266 |
msgstr ""
|
267 |
|
268 |
+
#: includes/class-wc-gateway-braintree-paypal.php:191
|
269 |
msgid "Unlink"
|
270 |
msgstr ""
|
271 |
|
272 |
+
#: includes/class-wc-gateway-braintree-paypal.php:336
|
273 |
#. translators: Placeholders: %1$s - payment method title (e.g. PayPal), %2$s -
|
274 |
#. transaction environment (either Sandbox or blank string), %3$s - type of
|
275 |
#. transaction (either Authorization or Payment)
|
276 |
msgid "%1$s %2$s %3$s Approved"
|
277 |
msgstr ""
|
278 |
|
279 |
+
#: includes/class-wc-gateway-braintree-paypal.php:338
|
280 |
+
#: includes/class-wc-gateway-braintree.php:1267
|
281 |
msgid "Sandbox"
|
282 |
msgstr ""
|
283 |
|
284 |
+
#: includes/class-wc-gateway-braintree-paypal.php:339
|
285 |
msgid "Authorization"
|
286 |
msgstr ""
|
287 |
|
288 |
+
#: includes/class-wc-gateway-braintree-paypal.php:339
|
289 |
msgid "Payment"
|
290 |
msgstr ""
|
291 |
|
292 |
+
#: includes/class-wc-gateway-braintree-paypal.php:345
|
293 |
#. translators: Placeholders: %s - transaction ID
|
294 |
msgid "(Transaction ID %s)"
|
295 |
msgstr ""
|
296 |
|
297 |
+
#: includes/class-wc-gateway-braintree-paypal.php:366
|
298 |
msgid "PayPal Account Saved: %s"
|
299 |
msgstr ""
|
300 |
|
301 |
+
#: includes/class-wc-gateway-braintree-paypal.php:445
|
302 |
msgid "PayPal"
|
303 |
msgstr ""
|
304 |
|
305 |
+
#: includes/class-wc-gateway-braintree-paypal.php:459
|
306 |
msgid ""
|
307 |
"Click the PayPal icon below to sign into your PayPal account and pay "
|
308 |
"securely."
|
466 |
msgid "Remove this merchant account ID"
|
467 |
msgstr ""
|
468 |
|
469 |
+
#: includes/class-wc-gateway-braintree.php:1267
|
470 |
msgid "Production"
|
471 |
msgstr ""
|
472 |
|
includes/api/class-wc-braintree-api.php
CHANGED
@@ -202,7 +202,7 @@ class WC_Braintree_API extends WC_Braintree_Framework\SV_WC_API_Base implements
|
|
202 |
$message = $result->get_user_message();
|
203 |
}
|
204 |
|
205 |
-
throw new SV_WC_Payment_Gateway_Exception( $message );
|
206 |
}
|
207 |
}
|
208 |
}
|
202 |
$message = $result->get_user_message();
|
203 |
}
|
204 |
|
205 |
+
throw new WC_Braintree_Framework\SV_WC_Payment_Gateway_Exception( $message );
|
206 |
}
|
207 |
}
|
208 |
}
|
includes/class-wc-braintree-payment-method-handler.php
CHANGED
@@ -77,4 +77,30 @@ class WC_Braintree_Payment_Method_Handler extends WC_Braintree_Framework\SV_WC_P
|
|
77 |
}
|
78 |
|
79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
}
|
77 |
}
|
78 |
|
79 |
|
80 |
+
/**
|
81 |
+
* Gets the order note message when a customer saves their payment method
|
82 |
+
* to their account.
|
83 |
+
*
|
84 |
+
* @since 2.0.1
|
85 |
+
* @param \SV_WC_Payment_Gateway_Payment_Token $token the payment token being saved
|
86 |
+
* @return string
|
87 |
+
*/
|
88 |
+
protected function get_order_note( $token ) {
|
89 |
+
|
90 |
+
$message = parent::get_order_note( $token );
|
91 |
+
|
92 |
+
// order note for the PayPal gateway
|
93 |
+
if ( ! $message && $this->get_gateway()->is_paypal_gateway() ) {
|
94 |
+
|
95 |
+
/* translators: Placeholders: %1$s - payment gateway title (PayPal), %2$s - PayPal account email address */
|
96 |
+
$message = sprintf( __( '%1$s Account Saved: %2$s', 'woocommerce-gateway-paypal-powered-by-braintree' ),
|
97 |
+
$this->get_gateway()->get_method_title(),
|
98 |
+
$token->get_type_full()
|
99 |
+
);
|
100 |
+
}
|
101 |
+
|
102 |
+
return $message;
|
103 |
+
}
|
104 |
+
|
105 |
+
|
106 |
}
|
includes/class-wc-gateway-braintree-paypal.php
CHANGED
@@ -102,6 +102,9 @@ class WC_Gateway_Braintree_PayPal extends WC_Gateway_Braintree {
|
|
102 |
$params['cart_handler_url'] = add_query_arg( 'wc-api', get_class( $this ), home_url() );
|
103 |
}
|
104 |
|
|
|
|
|
|
|
105 |
return $params;
|
106 |
}
|
107 |
|
102 |
$params['cart_handler_url'] = add_query_arg( 'wc-api', get_class( $this ), home_url() );
|
103 |
}
|
104 |
|
105 |
+
// add a cart payment nonce if available
|
106 |
+
$params['cart_payment_nonce'] = $this->get_plugin()->get_paypal_cart_instance()->get_cart_nonce();
|
107 |
+
|
108 |
return $params;
|
109 |
}
|
110 |
|
includes/class-wc-gateway-braintree.php
CHANGED
@@ -872,7 +872,11 @@ class WC_Gateway_Braintree extends WC_Braintree_Framework\SV_WC_Payment_Gateway_
|
|
872 |
* Returns the customer ID for the given user ID. Braintree provides a customer
|
873 |
* ID after creation.
|
874 |
*
|
875 |
-
*
|
|
|
|
|
|
|
|
|
876 |
* @see SV_WC_Payment_Gateway::get_customer_id()
|
877 |
* @param int $user_id WP user ID
|
878 |
* @param array $args optional additional arguments which can include: environment_id, autocreate (true/false), and order
|
@@ -888,6 +892,21 @@ class WC_Gateway_Braintree extends WC_Braintree_Framework\SV_WC_Payment_Gateway_
|
|
888 |
|
889 |
$args = array_merge( $defaults, $args );
|
890 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
891 |
return parent::get_customer_id( $user_id, $args );
|
892 |
}
|
893 |
|
872 |
* Returns the customer ID for the given user ID. Braintree provides a customer
|
873 |
* ID after creation.
|
874 |
*
|
875 |
+
* This is overridden to account for merchants that switched to v1 from the
|
876 |
+
* SkyVerge plugin, then updated old subscriptions and/or processed new
|
877 |
+
* subscriptions while waiting for v2.
|
878 |
+
*
|
879 |
+
* @since 2.0.1
|
880 |
* @see SV_WC_Payment_Gateway::get_customer_id()
|
881 |
* @param int $user_id WP user ID
|
882 |
* @param array $args optional additional arguments which can include: environment_id, autocreate (true/false), and order
|
892 |
|
893 |
$args = array_merge( $defaults, $args );
|
894 |
|
895 |
+
$customer_ids = get_user_meta( $user_id, $this->get_customer_id_user_meta_name( $args['environment_id'] ) );
|
896 |
+
|
897 |
+
// if there is more than one customer ID, grab the latest and use it
|
898 |
+
if ( is_array( $customer_ids ) && count( $customer_ids ) > 1 ) {
|
899 |
+
|
900 |
+
$customer_id = end( $customer_ids );
|
901 |
+
|
902 |
+
if ( $customer_id ) {
|
903 |
+
|
904 |
+
$this->remove_customer_id( $user_id, $args['environment_id'] );
|
905 |
+
|
906 |
+
$this->update_customer_id( $user_id, $customer_id, $args['environment_id'] );
|
907 |
+
}
|
908 |
+
}
|
909 |
+
|
910 |
return parent::get_customer_id( $user_id, $args );
|
911 |
}
|
912 |
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: automattic, akeda, allendav, royho, slash1andy, woosteve, spraveen
|
|
3 |
Tags: ecommerce, e-commerce, commerce, woothemes, wordpress ecommerce, store, sales, sell, shop, shopping, cart, checkout, configurable, paypal, braintree
|
4 |
Requires at least: 4.4
|
5 |
Tested up to: 4.7.4
|
6 |
-
Stable tag: 2.0.
|
7 |
License: GPLv3
|
8 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
9 |
|
@@ -11,7 +11,7 @@ Accept PayPal, Credit Cards, and Debit Cards on your WooCommerce store.
|
|
11 |
|
12 |
== Description ==
|
13 |
|
14 |
-
This is a PayPal Powered by Braintree Payment Gateway for WooCommerce, which will let you accept credit card, debit card, and PayPal payments on your WooCommerce store via Braintree.
|
15 |
|
16 |
PayPal Powered by Braintree allows you to securely sell your products online using Hosted Fields to help you meet security requirements without losing flexibility and an integrated checkout process. Hosted Fields are little iFrames, hosted on PayPal's servers, that fit inside the checkout form elements and provide a secure means for your customers to enter their card information.
|
17 |
|
@@ -122,6 +122,12 @@ New feature requests and bugs reports can be made in the plugin forum.
|
|
122 |
|
123 |
== Changelog ==
|
124 |
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
= 2.0.0 =
|
126 |
* Feature - Now supports non-USA Braintree merchant accounts! Bonjour, hola, hallo, and g'day :)
|
127 |
* Feature - Supports WooCommerce Pre-Orders plugin
|
@@ -205,30 +211,8 @@ New feature requests and bugs reports can be made in the plugin forum.
|
|
205 |
|
206 |
== Upgrade Notice ==
|
207 |
|
208 |
-
= 2.0.
|
209 |
-
*
|
210 |
-
*
|
211 |
-
*
|
212 |
-
*
|
213 |
-
* Feature - Customers can manage or add new payment methods from the account area
|
214 |
-
* Feature - Uses an enhanced payment form with retina icons
|
215 |
-
* Feature - Add multiple merchant IDs to support multi-currency shops (requires a currency switcher)
|
216 |
-
* Feature - Supports Advanced Fraud tools and Kount Direct
|
217 |
-
* Feature - Supports 3D Secure for Visa / MasterCard transactions
|
218 |
-
* Feature - Add dynamic descriptors to be displayed for the transaction on customer's credit card statements
|
219 |
-
* Feature - Can show detailed decline messages at checkout to better inform customers of transaction decline reasons
|
220 |
-
* Feature - Allows bulk action to capture charges
|
221 |
-
* Feature - Orders with only virtual items can now force a charge instead of authorization
|
222 |
-
* Tweak - Capturing a charge now moves order status to "processing" automatically
|
223 |
-
* Tweak - Voided orders are now marked as "cancelled" instead of "refunded"
|
224 |
-
* Tweak - Admins can now manually update Subscription payment methods and view payment tokens
|
225 |
-
* Fix - Subscription orders will no longer force a charge and allow an authorization depending on settings
|
226 |
-
* Fix - Handle Subscriptions renewal failures by failing the order
|
227 |
-
* Fix - Customers can switch Subscriptions payment methods on their own from the account
|
228 |
-
* Fix - Stores sandbox and live customer tokens separately to avoid `Customer ID is invalid.` messages
|
229 |
-
* Fix - Ensures that payment can be made from the "My Account" page for pending orders
|
230 |
-
* Misc - Adds support for WooCommerce 3.0+
|
231 |
-
* Misc - Removes support for WooCommerce 2.4 and lower
|
232 |
-
* Misc - Added upgrade routine from SkyVerge Braintree plugin to allow for migrating existing tokens and subscriptions
|
233 |
-
* Misc - Refactor for improved performance and stability
|
234 |
-
* Misc - Other small fixes and improvements
|
3 |
Tags: ecommerce, e-commerce, commerce, woothemes, wordpress ecommerce, store, sales, sell, shop, shopping, cart, checkout, configurable, paypal, braintree
|
4 |
Requires at least: 4.4
|
5 |
Tested up to: 4.7.4
|
6 |
+
Stable tag: 2.0.1
|
7 |
License: GPLv3
|
8 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
9 |
|
11 |
|
12 |
== Description ==
|
13 |
|
14 |
+
This is a PayPal Powered by Braintree Payment Gateway for WooCommerce, which will let you accept **credit card, debit card, and PayPal payments** on your WooCommerce store via Braintree.
|
15 |
|
16 |
PayPal Powered by Braintree allows you to securely sell your products online using Hosted Fields to help you meet security requirements without losing flexibility and an integrated checkout process. Hosted Fields are little iFrames, hosted on PayPal's servers, that fit inside the checkout form elements and provide a secure means for your customers to enter their card information.
|
17 |
|
122 |
|
123 |
== Changelog ==
|
124 |
|
125 |
+
= 2.0.1 =
|
126 |
+
* Fix - Purchasing a subscription with PayPal could lead to a blank order note being added
|
127 |
+
* Fix - Ensure all upgrade routines run for users who have used both the SkyVerge Braintree and PayPal Powered by Braintree v1 in the past
|
128 |
+
* Fix - Issue where existing subscriptions in some cases couldn't switch to using a new PayPal account
|
129 |
+
* Fix - Ensure "Place Order" button always remains visible for PayPal when accepting terms
|
130 |
+
|
131 |
= 2.0.0 =
|
132 |
* Feature - Now supports non-USA Braintree merchant accounts! Bonjour, hola, hallo, and g'day :)
|
133 |
* Feature - Supports WooCommerce Pre-Orders plugin
|
211 |
|
212 |
== Upgrade Notice ==
|
213 |
|
214 |
+
= 2.0.1 =
|
215 |
+
* Fix - Purchasing a subscription with PayPal could lead to a blank order note being added
|
216 |
+
* Fix - Ensure all upgrade routines run for users who have used both the SkyVerge Braintree and PayPal Powered by Braintree v1 in the past
|
217 |
+
* Fix - Issue where existing subscriptions in some cases couldn't switch to using a new PayPal account
|
218 |
+
* Fix - Ensure "Place Order" button always remains visible for PayPal when accepting terms
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
woocommerce-gateway-paypal-powered-by-braintree.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
* Description: Receive credit card or PayPal payments using Paypal Powered by Braintree. A server with cURL, SSL support, and a valid SSL certificate is required (for security reasons) for this gateway to function. Requires PHP 5.4+
|
6 |
* Author: WooCommerce
|
7 |
* Author URI: http://woocommerce.com/
|
8 |
-
* Version: 2.0.
|
9 |
*
|
10 |
* Copyright (c) 2016-2017, Automattic, Inc.
|
11 |
*
|
5 |
* Description: Receive credit card or PayPal payments using Paypal Powered by Braintree. A server with cURL, SSL support, and a valid SSL certificate is required (for security reasons) for this gateway to function. Requires PHP 5.4+
|
6 |
* Author: WooCommerce
|
7 |
* Author URI: http://woocommerce.com/
|
8 |
+
* Version: 2.0.1
|
9 |
*
|
10 |
* Copyright (c) 2016-2017, Automattic, Inc.
|
11 |
*
|