WooCommerce Stripe Payment Gateway - Version 4.1.9

Version Description

  • 2018-08-27 =
  • Fix - Don't display admin notices to user that cannot manage woocommerce.
  • Fix - Fatal error when clicking on order link that doesn't exist.
  • Fix - When capturing a charge from authorize, Stripe fees not displaying.
  • Fix - Undefined property error on card type in rare cases.
  • Tweak - Update SEPA IBAN to use new elements implementation.
  • Add - Filter for Payment Request Button locale wc_stripe_payment_request_button_locale.

See changelog for all versions.

=

Download this release

Release Info

Developer royho
Plugin Icon 128x128 WooCommerce Stripe Payment Gateway
Version 4.1.9
Comparing to
See all releases

Code changes from version 4.1.8 to 4.1.9

assets/css/stripe-styles.css CHANGED
@@ -1,4 +1,4 @@
1
- .wc-stripe-elements-field { border:1px solid #ddd; margin:5px 0; padding:5px; background-color:#fff; outline:0; }
2
3
#add_payment_method .woocommerce-PaymentMethod label { margin-left: 10px; }
4
#add_payment_method li { clear: right; }
1
+ .wc-stripe-elements-field, .wc-stripe-iban-element-field { border:1px solid #ddd; margin:5px 0; padding:5px; background-color:#fff; outline:0; }
2
3
#add_payment_method .woocommerce-PaymentMethod label { margin-left: 10px; }
4
#add_payment_method li { clear: right; }
assets/js/stripe.js CHANGED
@@ -5,13 +5,14 @@ jQuery( function( $ ) {
5
6
var stripe = Stripe( wc_stripe_params.key );
7
8
- var stripe_elements_options = wc_stripe_params.elements_options.length ? wc_stripe_params.elements_options : {},
9
- elements = stripe.elements( stripe_elements_options ),
10
stripe_card,
11
stripe_exp,
12
stripe_cvc;
13
14
-
15
/**
16
* Object to handle Stripe elements payment form.
17
*/
@@ -42,6 +43,7 @@ jQuery( function( $ ) {
42
if ( ! $( '#stripe-card-element' ).length ) {
43
return;
44
}
45
if ( 'yes' === wc_stripe_params.inline_cc_form ) {
46
stripe_card.mount( '#stripe-card-element' );
47
} else {
@@ -126,9 +128,17 @@ jQuery( function( $ ) {
126
}
127
128
wc_stripe_form.mountElements();
129
} );
130
} else if ( $( 'form#add_payment_method' ).length || $( 'form#order_review' ).length ) {
131
wc_stripe_form.mountElements();
132
}
133
},
134
@@ -213,6 +223,11 @@ jQuery( function( $ ) {
213
this.reset
214
);
215
216
wc_stripe_form.createElements();
217
218
if ( 'yes' === wc_stripe_params.is_stripe_checkout ) {
@@ -403,15 +418,19 @@ jQuery( function( $ ) {
403
* we need to remove the parameter if we're not
404
* passing any value.
405
*/
406
- if ( typeof extra_details.owner.phone !== 'undefined' && 0 >= extra_details.owner.phone.length ) {
407
delete extra_details.owner.phone;
408
}
409
410
- if ( typeof extra_details.owner.email !== 'undefined' && 0 >= extra_details.owner.email.length ) {
411
- delete extra_details.owner.email;
412
}
413
414
- if ( typeof extra_details.owner.name !== 'undefined' && 0 >= extra_details.owner.name.length ) {
415
delete extra_details.owner.name;
416
}
417
@@ -486,14 +505,8 @@ jQuery( function( $ ) {
486
// Handle special inputs that are unique to a payment method.
487
switch ( source_type ) {
488
case 'sepa_debit':
489
- var owner = $( '#stripe-payment-data' ),
490
- email = $( '#billing_email' ).length ? $( '#billing_email' ).val() : owner.data( 'email' );
491
-
492
- extra_details.currency = $( '#stripe-' + source_type + '-payment-data' ).data( 'currency' );
493
- extra_details.owner.name = $( '#stripe-sepa-owner' ).val();
494
- extra_details.owner.email = email;
495
- extra_details.sepa_debit = { iban: $( '#stripe-sepa-iban' ).val() };
496
- extra_details.mandate = { notification_method: wc_stripe_params.sepa_mandate_notification };
497
break;
498
case 'ideal':
499
extra_details.ideal = { bank: $( '#stripe-ideal-bank' ).val() };
@@ -509,7 +522,11 @@ jQuery( function( $ ) {
509
510
extra_details.type = source_type;
511
512
- stripe.createSource( extra_details ).then( wc_stripe_form.sourceResponse );
513
}
514
},
515
@@ -562,20 +579,6 @@ jQuery( function( $ ) {
562
}
563
}
564
565
- if ( wc_stripe_form.isSepaChosen() ) {
566
- // Check if SEPA owner is filled before proceed.
567
- if ( '' === $( '#stripe-sepa-owner' ).val() ) {
568
- $( document.body ).trigger( 'stripeError', { error: { message: wc_stripe_params.no_sepa_owner_msg } } );
569
- return false;
570
- }
571
-
572
- // Check if SEPA IBAN is filled before proceed.
573
- if ( '' === $( '#stripe-sepa-iban' ).val() ) {
574
- $( document.body ).trigger( 'stripeError', { error: { message: wc_stripe_params.no_sepa_iban_msg } } );
575
- return false;
576
- }
577
- }
578
-
579
/*
580
* For methods that needs redirect, we will create the
581
* source server side so we can obtain the order ID.
@@ -653,10 +656,35 @@ jQuery( function( $ ) {
653
}
654
},
655
656
onError: function( e, result ) {
657
var message = result.error.message,
658
errorContainer = wc_stripe_form.getSelectedPaymentElement().parents( 'li' ).eq(0).find( '.stripe-source-errors' );
659
660
/*
661
* Customers do not need to know the specifics of the below type of errors
662
* therefore return a generic localizable error message.
5
6
var stripe = Stripe( wc_stripe_params.key );
7
8
+ var stripe_elements_options = Object.keys( wc_stripe_params.elements_options ).length ? wc_stripe_params.elements_options : {},
9
+ sepa_elements_options = Object.keys( wc_stripe_params.sepa_elements_options ).length ? wc_stripe_params.sepa_elements_options : {},
10
+ elements = stripe.elements( stripe_elements_options ),
11
+ iban = elements.create( 'iban', sepa_elements_options ),
12
stripe_card,
13
stripe_exp,
14
stripe_cvc;
15
16
/**
17
* Object to handle Stripe elements payment form.
18
*/
43
if ( ! $( '#stripe-card-element' ).length ) {
44
return;
45
}
46
+
47
if ( 'yes' === wc_stripe_params.inline_cc_form ) {
48
stripe_card.mount( '#stripe-card-element' );
49
} else {
128
}
129
130
wc_stripe_form.mountElements();
131
+
132
+ if ( $( '#stripe-iban-element' ).length ) {
133
+ iban.mount( '#stripe-iban-element' );
134
+ }
135
} );
136
} else if ( $( 'form#add_payment_method' ).length || $( 'form#order_review' ).length ) {
137
wc_stripe_form.mountElements();
138
+
139
+ if ( $( '#stripe-iban-element' ).length ) {
140
+ iban.mount( '#stripe-iban-element' );
141
+ }
142
}
143
},
144
223
this.reset
224
);
225
226
+ // SEPA IBAN.
227
+ iban.on( 'change',
228
+ this.onSepaError
229
+ );
230
+
231
wc_stripe_form.createElements();
232
233
if ( 'yes' === wc_stripe_params.is_stripe_checkout ) {
418
* we need to remove the parameter if we're not
419
* passing any value.
420
*/
421
+ if ( typeof extra_details.owner.phone === 'undefined' || 0 >= extra_details.owner.phone.length ) {
422
delete extra_details.owner.phone;
423
}
424
425
+ if ( typeof extra_details.owner.email === 'undefined' || 0 >= extra_details.owner.email.length ) {
426
+ if ( $( '#stripe-payment-data' ).data( 'email' ).length ) {
427
+ extra_details.owner.email = $( '#stripe-payment-data' ).data( 'email' );
428
+ } else {
429
+ delete extra_details.owner.email;
430
+ }
431
}
432
433
+ if ( typeof extra_details.owner.name === 'undefined' || 0 >= extra_details.owner.name.length ) {
434
delete extra_details.owner.name;
435
}
436
505
// Handle special inputs that are unique to a payment method.
506
switch ( source_type ) {
507
case 'sepa_debit':
508
+ extra_details.currency = $( '#stripe-' + source_type + '-payment-data' ).data( 'currency' );
509
+ extra_details.mandate = { notification_method: wc_stripe_params.sepa_mandate_notification };
510
break;
511
case 'ideal':
512
extra_details.ideal = { bank: $( '#stripe-ideal-bank' ).val() };
522
523
extra_details.type = source_type;
524
525
+ if ( 'sepa_debit' === source_type ) {
526
+ stripe.createSource( iban, extra_details ).then( wc_stripe_form.sourceResponse );
527
+ } else {
528
+ stripe.createSource( extra_details ).then( wc_stripe_form.sourceResponse );
529
+ }
530
}
531
},
532
579
}
580
}
581
582
/*
583
* For methods that needs redirect, we will create the
584
* source server side so we can obtain the order ID.
656
}
657
},
658
659
+ onSepaError: function( e ) {
660
+ var errorContainer = wc_stripe_form.getSelectedPaymentElement().parents( 'li' ).eq(0).find( '.stripe-source-errors' );
661
+
662
+ if ( e.error ) {
663
+ console.log( e.error.message ); // Leave for troubleshooting.
664
+ $( errorContainer ).html( '<ul class="woocommerce_error woocommerce-error wc-stripe-error"><li>' + e.error.message + '</li></ul>' );
665
+ } else {
666
+ $( errorContainer ).html( '' );
667
+ }
668
+ },
669
+
670
onError: function( e, result ) {
671
var message = result.error.message,
672
errorContainer = wc_stripe_form.getSelectedPaymentElement().parents( 'li' ).eq(0).find( '.stripe-source-errors' );
673
674
+ /*
675
+ * If payment method is SEPA and owner name is not completed,
676
+ * source cannot be created. So we need to show the normal
677
+ * Billing name is required error message on top of form instead
678
+ * of inline.
679
+ */
680
+ if ( wc_stripe_form.isSepaChosen() ) {
681
+ if ( 'invalid_owner_name' === result.error.code && wc_stripe_params.hasOwnProperty( result.error.code ) ) {
682
+ var error = '<ul class="woocommerce-error"><li>' + wc_stripe_params[ result.error.code ] + '</li></ul>';
683
+
684
+ return wc_stripe_form.submitError( error );
685
+ }
686
+ }
687
+
688
/*
689
* Customers do not need to know the specifics of the below type of errors
690
* therefore return a generic localizable error message.
assets/js/stripe.min.js CHANGED
@@ -1 +1 @@
1
- jQuery(function(e){"use strict";var r,t,o,n=Stripe(wc_stripe_params.key),a=wc_stripe_params.elements_options.length?wc_stripe_params.elements_options:{},s=n.elements(a),i={getAjaxURL:function(e){return wc_stripe_params.ajaxurl.toString().replace("%%endpoint%%","wc_stripe_"+e)},unmountElements:function(){"yes"===wc_stripe_params.inline_cc_form?r.unmount("#stripe-card-element"):(r.unmount("#stripe-card-element"),t.unmount("#stripe-exp-element"),o.unmount("#stripe-cvc-element"))},mountElements:function(){e("#stripe-card-element").length&&("yes"===wc_stripe_params.inline_cc_form?r.mount("#stripe-card-element"):(r.mount("#stripe-card-element"),t.mount("#stripe-exp-element"),o.mount("#stripe-cvc-element")))},createElements:function(){var n={base:{iconColor:"#666EE8",color:"#31325F",fontSize:"15px","::placeholder":{color:"#CFD7E0"}}},a={focus:"focused",empty:"empty",invalid:"invalid"};n=wc_stripe_params.elements_styling?wc_stripe_params.elements_styling:n,a=wc_stripe_params.elements_classes?wc_stripe_params.elements_classes:a,"yes"===wc_stripe_params.inline_cc_form?(r=s.create("card",{style:n,hidePostalCode:!0})).addEventListener("change",function(r){i.onCCFormChange(),r.error&&e(document.body).trigger("stripeError",r)}):(r=s.create("cardNumber",{style:n,classes:a}),t=s.create("cardExpiry",{style:n,classes:a}),o=s.create("cardCvc",{style:n,classes:a}),r.addEventListener("change",function(r){i.onCCFormChange(),i.updateCardBrand(r.brand),r.error&&e(document.body).trigger("stripeError",r)}),t.addEventListener("change",function(r){i.onCCFormChange(),r.error&&e(document.body).trigger("stripeError",r)}),o.addEventListener("change",function(r){i.onCCFormChange(),r.error&&e(document.body).trigger("stripeError",r)})),"yes"===wc_stripe_params.is_checkout?e(document.body).on("updated_checkout",function(){r&&i.unmountElements(),i.mountElements()}):(e("form#add_payment_method").length||e("form#order_review").length)&&i.mountElements()},updateCardBrand:function(r){var t={visa:"stripe-visa-brand",mastercard:"stripe-mastercard-brand",amex:"stripe-amex-brand",discover:"stripe-discover-brand",diners:"stripe-diners-brand",jcb:"stripe-jcb-brand",unknown:"stripe-credit-card-brand"},o=e(".stripe-card-brand"),n="stripe-credit-card-brand";r in t&&(n=t[r]),e.each(t,function(e,r){o.removeClass(r)}),o.addClass(n)},init:function(){"yes"!==wc_stripe_params.is_change_payment_page&&"yes"!==wc_stripe_params.is_pay_for_order_page||e(document.body).trigger("wc-credit-card-form-init"),this.stripe_checkout_submit=!1,e("form.woocommerce-checkout").length&&(this.form=e("form.woocommerce-checkout")),e("form.woocommerce-checkout").on("checkout_place_order_stripe checkout_place_order_stripe_bancontact checkout_place_order_stripe_sofort checkout_place_order_stripe_giropay checkout_place_order_stripe_ideal checkout_place_order_stripe_alipay checkout_place_order_stripe_sepa",this.onSubmit),e("form#order_review").length&&(this.form=e("form#order_review")),e("form#order_review, form#add_payment_method").on("submit",this.onSubmit),e("form#add_payment_method").length&&(this.form=e("form#add_payment_method")),e("form.woocommerce-checkout").on("change",this.reset),e(document).on("stripeError",this.onError).on("checkout_error",this.reset),i.createElements(),"yes"===wc_stripe_params.is_stripe_checkout&&e(document.body).on("click",".wc-stripe-checkout-button",function(){return i.openModal(),!1})},isStripeChosen:function(){return e("#payment_method_stripe, #payment_method_stripe_bancontact, #payment_method_stripe_sofort, #payment_method_stripe_giropay, #payment_method_stripe_ideal, #payment_method_stripe_alipay, #payment_method_stripe_sepa, #payment_method_stripe_eps, #payment_method_stripe_multibanco").is(":checked")||e("#payment_method_stripe").is(":checked")&&"new"===e('input[name="wc-stripe-payment-token"]:checked').val()||e("#payment_method_stripe_sepa").is(":checked")&&"new"===e('input[name="wc-stripe-payment-token"]:checked').val()},isStripeSaveCardChosen:function(){return e("#payment_method_stripe").is(":checked")&&e('input[name="wc-stripe-payment-token"]').is(":checked")&&"new"!==e('input[name="wc-stripe-payment-token"]:checked').val()||e("#payment_method_stripe_sepa").is(":checked")&&e('input[name="wc-stripe_sepa-payment-token"]').is(":checked")&&"new"!==e('input[name="wc-stripe_sepa-payment-token"]:checked').val()},isStripeCardChosen:function(){return e("#payment_method_stripe").is(":checked")},isBancontactChosen:function(){return e("#payment_method_stripe_bancontact").is(":checked")},isGiropayChosen:function(){return e("#payment_method_stripe_giropay").is(":checked")},isIdealChosen:function(){return e("#payment_method_stripe_ideal").is(":checked")},isSofortChosen:function(){return e("#payment_method_stripe_sofort").is(":checked")},isAlipayChosen:function(){return e("#payment_method_stripe_alipay").is(":checked")},isSepaChosen:function(){return e("#payment_method_stripe_sepa").is(":checked")},isP24Chosen:function(){return e("#payment_method_stripe_p24").is(":checked")},isEpsChosen:function(){return e("#payment_method_stripe_eps").is(":checked")},isMultibancoChosen:function(){return e("#payment_method_stripe_multibanco").is(":checked")},hasSource:function(){return 0<e("input.stripe-source").length},hasToken:function(){return 0<e("input.stripe_token").length},isMobile:function(){return!!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)},isStripeModalNeeded:function(e){var r=i.form.find("input.stripe_token");return(!i.stripe_submit||!r)&&!!i.isStripeChosen()},block:function(){i.isMobile()||i.form.block({message:null,overlayCSS:{background:"#fff",opacity:.6}})},unblock:function(){i.form.unblock()},getSelectedPaymentElement:function(){return e('.payment_methods input[name="payment_method"]:checked')},openModal:function(){var r=i.form,t=e("#stripe-payment-data");i.reset();StripeCheckout.open({key:wc_stripe_params.key,billingAddress:t.data("billing-address"),zipCode:t.data("verify-zip"),amount:t.data("amount"),name:t.data("name"),description:t.data("description"),currency:t.data("currency"),image:t.data("image"),locale:t.data("locale"),email:e("#billing_email").val()||t.data("email"),panelLabel:t.data("panel-label"),allowRememberMe:t.data("allow-remember-me"),token:function(e){if(r.find("input.stripe_source").remove(),"token"===e.object)n.createSource({type:"card",token:e.id}).then(i.sourceResponse);else if("source"===e.object){var t={source:e};i.sourceResponse(t)}},closed:i.onClose()})},resetModal:function(){i.reset(),i.stripe_checkout_submit=!1},onClose:function(){i.unblock()},getOwnerDetails:function(){var r=e("#billing_first_name").length?e("#billing_first_name").val():wc_stripe_params.billing_first_name,t=e("#billing_last_name").length?e("#billing_last_name").val():wc_stripe_params.billing_last_name,o={owner:{name:"",address:{},email:"",phone:""}};return o.owner.name=r,o.owner.name=r&&t?r+" "+t:e("#stripe-payment-data").data("full-name"),o.owner.email=e("#billing_email").val(),o.owner.phone=e("#billing_phone").val(),void 0!==o.owner.phone&&0>=o.owner.phone.length&&delete o.owner.phone,void 0!==o.owner.email&&0>=o.owner.email.length&&delete o.owner.email,void 0!==o.owner.name&&0>=o.owner.name.length&&delete o.owner.name,e("#billing_address_1").length>0?(o.owner.address.line1=e("#billing_address_1").val(),o.owner.address.line2=e("#billing_address_2").val(),o.owner.address.state=e("#billing_state").val(),o.owner.address.city=e("#billing_city").val(),o.owner.address.postal_code=e("#billing_postcode").val(),o.owner.address.country=e("#billing_country").val()):wc_stripe_params.billing_address_1&&(o.owner.address.line1=wc_stripe_params.billing_address_1,o.owner.address.line2=wc_stripe_params.billing_address_2,o.owner.address.state=wc_stripe_params.billing_state,o.owner.address.city=wc_stripe_params.billing_city,o.owner.address.postal_code=wc_stripe_params.billing_postcode,o.owner.address.country=wc_stripe_params.billing_country),o},createSource:function(){var t=i.getOwnerDetails(),o="card";if(i.isBancontactChosen()&&(o="bancontact"),i.isSepaChosen()&&(o="sepa_debit"),i.isIdealChosen()&&(o="ideal"),i.isSofortChosen()&&(o="sofort"),i.isGiropayChosen()&&(o="giropay"),i.isAlipayChosen()&&(o="alipay"),"card"===o)n.createSource(r,t).then(i.sourceResponse);else{switch(o){case"bancontact":case"giropay":case"ideal":case"sofort":case"alipay":t.amount=e("#stripe-"+o+"-payment-data").data("amount"),t.currency=e("#stripe-"+o+"-payment-data").data("currency"),t.redirect={return_url:wc_stripe_params.return_url},wc_stripe_params.statement_descriptor&&(t.statement_descriptor=wc_stripe_params.statement_descriptor)}switch(o){case"sepa_debit":var a=e("#stripe-payment-data"),s=e("#billing_email").length?e("#billing_email").val():a.data("email");t.currency=e("#stripe-"+o+"-payment-data").data("currency"),t.owner.name=e("#stripe-sepa-owner").val(),t.owner.email=s,t.sepa_debit={iban:e("#stripe-sepa-iban").val()},t.mandate={notification_method:wc_stripe_params.sepa_mandate_notification};break;case"ideal":t.ideal={bank:e("#stripe-ideal-bank").val()};break;case"alipay":t.currency=e("#stripe-"+o+"-payment-data").data("currency"),t.amount=e("#stripe-"+o+"-payment-data").data("amount");break;case"sofort":t.sofort={country:e("#billing_country").val()}}t.type=o,n.createSource(t).then(i.sourceResponse)}},sourceResponse:function(r){r.error?e(document.body).trigger("stripeError",r):"no"===wc_stripe_params.allow_prepaid_card&&"card"===r.source.type&&"prepaid"===r.source.card.funding?(r.error={message:wc_stripe_params.no_prepaid_card_msg},"yes"===wc_stripe_params.is_stripe_checkout?i.submitError('<ul class="woocommerce-error"><li>'+wc_stripe_params.no_prepaid_card_msg+"</li></ul>"):e(document.body).trigger("stripeError",r)):i.processStripeResponse(r.source)},processStripeResponse:function(r){i.reset(),i.form.append("<input type='hidden' class='stripe-source' name='stripe_source' value='"+r.id+"'/>"),e("form#add_payment_method").length&&e(i.form).off("submit",i.form.onSubmit),i.form.submit()},onSubmit:function(r){if(i.isStripeChosen()){if(!(i.isStripeSaveCardChosen()||i.hasSource()||i.hasToken())){if(r.preventDefault(),i.block(),"yes"===wc_stripe_params.is_stripe_checkout&&i.isStripeModalNeeded()&&i.isStripeCardChosen())return"yes"===wc_stripe_params.is_checkout||(i.openModal(),!1);if(i.isSepaChosen()){if(""===e("#stripe-sepa-owner").val())return e(document.body).trigger("stripeError",{error:{message:wc_stripe_params.no_sepa_owner_msg}}),!1;if(""===e("#stripe-sepa-iban").val())return e(document.body).trigger("stripeError",{error:{message:wc_stripe_params.no_sepa_iban_msg}}),!1}if(i.isBancontactChosen()||i.isGiropayChosen()||i.isIdealChosen()||i.isAlipayChosen()||i.isSofortChosen()||i.isP24Chosen()||i.isEpsChosen()||i.isMultibancoChosen()){if(e("form#order_review").length)return e("form#order_review").off("submit",this.onSubmit),i.form.submit(),!1;if(e("form.woocommerce-checkout").length)return!0;if(e("form#add_payment_method").length)return e("form#add_payment_method").off("submit",this.onSubmit),i.form.submit(),!1}return i.createSource(),!1}return e("form#add_payment_method").length?(r.preventDefault(),"yes"===wc_stripe_params.is_stripe_checkout&&i.isStripeModalNeeded()&&i.isStripeCardChosen()?(i.openModal(),!1):(i.block(),i.createSource(),!1)):void 0}},onCCFormChange:function(){i.reset()},reset:function(){e(".wc-stripe-error, .stripe-source, .stripe_token").remove(),"yes"===wc_stripe_params.is_stripe_checkout&&(i.stripe_submit=!1)},onError:function(r,t){var o=t.error.message,n=i.getSelectedPaymentElement().parents("li").eq(0).find(".stripe-source-errors");"invalid_request_error"!==t.error.type&&"api_connection_error"!==t.error.type&&"api_error"!==t.error.type&&"authentication_error"!==t.error.type&&"rate_limit_error"!==t.error.type||(o=wc_stripe_params.invalid_request_error),"card_error"===t.error.type&&wc_stripe_params.hasOwnProperty(t.error.code)&&(o=wc_stripe_params[t.error.code]),"validation_error"===t.error.type&&wc_stripe_params.hasOwnProperty(t.error.code)&&(o=wc_stripe_params[t.error.code]),i.reset(),e(".woocommerce-NoticeGroup-checkout").remove(),console.log(t.error.message),e(n).html('<ul class="woocommerce_error woocommerce-error wc-stripe-error"><li>'+o+"</li></ul>"),e(".wc-stripe-error").length&&e("html, body").animate({scrollTop:e(".wc-stripe-error").offset().top-200},200),i.unblock()},submitError:function(r){e(".woocommerce-NoticeGroup-checkout, .woocommerce-error, .woocommerce-message").remove(),i.form.prepend('<div class="woocommerce-NoticeGroup woocommerce-NoticeGroup-checkout">'+r+"</div>"),i.form.removeClass("processing").unblock(),i.form.find(".input-text, select, input:checkbox").blur();var t="";e("#add_payment_method").length&&(t=e("#add_payment_method")),e("#order_review").length&&(t=e("#order_review")),e("form.checkout").length&&(t=e("form.checkout")),t.length&&e("html, body").animate({scrollTop:t.offset().top-100},500),e(document.body).trigger("checkout_error"),i.unblock()}};i.init()});
1
+ jQuery(function(e){"use strict";var r,t,o,n=Stripe(wc_stripe_params.key),s=Object.keys(wc_stripe_params.elements_options).length?wc_stripe_params.elements_options:{},a=Object.keys(wc_stripe_params.sepa_elements_options).length?wc_stripe_params.sepa_elements_options:{},i=n.elements(s),c=i.create("iban",a),p={getAjaxURL:function(e){return wc_stripe_params.ajaxurl.toString().replace("%%endpoint%%","wc_stripe_"+e)},unmountElements:function(){"yes"===wc_stripe_params.inline_cc_form?r.unmount("#stripe-card-element"):(r.unmount("#stripe-card-element"),t.unmount("#stripe-exp-element"),o.unmount("#stripe-cvc-element"))},mountElements:function(){e("#stripe-card-element").length&&("yes"===wc_stripe_params.inline_cc_form?r.mount("#stripe-card-element"):(r.mount("#stripe-card-element"),t.mount("#stripe-exp-element"),o.mount("#stripe-cvc-element")))},createElements:function(){var n={base:{iconColor:"#666EE8",color:"#31325F",fontSize:"15px","::placeholder":{color:"#CFD7E0"}}},s={focus:"focused",empty:"empty",invalid:"invalid"};n=wc_stripe_params.elements_styling?wc_stripe_params.elements_styling:n,s=wc_stripe_params.elements_classes?wc_stripe_params.elements_classes:s,"yes"===wc_stripe_params.inline_cc_form?(r=i.create("card",{style:n,hidePostalCode:!0})).addEventListener("change",function(r){p.onCCFormChange(),r.error&&e(document.body).trigger("stripeError",r)}):(r=i.create("cardNumber",{style:n,classes:s}),t=i.create("cardExpiry",{style:n,classes:s}),o=i.create("cardCvc",{style:n,classes:s}),r.addEventListener("change",function(r){p.onCCFormChange(),p.updateCardBrand(r.brand),r.error&&e(document.body).trigger("stripeError",r)}),t.addEventListener("change",function(r){p.onCCFormChange(),r.error&&e(document.body).trigger("stripeError",r)}),o.addEventListener("change",function(r){p.onCCFormChange(),r.error&&e(document.body).trigger("stripeError",r)})),"yes"===wc_stripe_params.is_checkout?e(document.body).on("updated_checkout",function(){r&&p.unmountElements(),p.mountElements(),e("#stripe-iban-element").length&&c.mount("#stripe-iban-element")}):(e("form#add_payment_method").length||e("form#order_review").length)&&(p.mountElements(),e("#stripe-iban-element").length&&c.mount("#stripe-iban-element"))},updateCardBrand:function(r){var t={visa:"stripe-visa-brand",mastercard:"stripe-mastercard-brand",amex:"stripe-amex-brand",discover:"stripe-discover-brand",diners:"stripe-diners-brand",jcb:"stripe-jcb-brand",unknown:"stripe-credit-card-brand"},o=e(".stripe-card-brand"),n="stripe-credit-card-brand";r in t&&(n=t[r]),e.each(t,function(e,r){o.removeClass(r)}),o.addClass(n)},init:function(){"yes"!==wc_stripe_params.is_change_payment_page&&"yes"!==wc_stripe_params.is_pay_for_order_page||e(document.body).trigger("wc-credit-card-form-init"),this.stripe_checkout_submit=!1,e("form.woocommerce-checkout").length&&(this.form=e("form.woocommerce-checkout")),e("form.woocommerce-checkout").on("checkout_place_order_stripe checkout_place_order_stripe_bancontact checkout_place_order_stripe_sofort checkout_place_order_stripe_giropay checkout_place_order_stripe_ideal checkout_place_order_stripe_alipay checkout_place_order_stripe_sepa",this.onSubmit),e("form#order_review").length&&(this.form=e("form#order_review")),e("form#order_review, form#add_payment_method").on("submit",this.onSubmit),e("form#add_payment_method").length&&(this.form=e("form#add_payment_method")),e("form.woocommerce-checkout").on("change",this.reset),e(document).on("stripeError",this.onError).on("checkout_error",this.reset),c.on("change",this.onSepaError),p.createElements(),"yes"===wc_stripe_params.is_stripe_checkout&&e(document.body).on("click",".wc-stripe-checkout-button",function(){return p.openModal(),!1})},isStripeChosen:function(){return e("#payment_method_stripe, #payment_method_stripe_bancontact, #payment_method_stripe_sofort, #payment_method_stripe_giropay, #payment_method_stripe_ideal, #payment_method_stripe_alipay, #payment_method_stripe_sepa, #payment_method_stripe_eps, #payment_method_stripe_multibanco").is(":checked")||e("#payment_method_stripe").is(":checked")&&"new"===e('input[name="wc-stripe-payment-token"]:checked').val()||e("#payment_method_stripe_sepa").is(":checked")&&"new"===e('input[name="wc-stripe-payment-token"]:checked').val()},isStripeSaveCardChosen:function(){return e("#payment_method_stripe").is(":checked")&&e('input[name="wc-stripe-payment-token"]').is(":checked")&&"new"!==e('input[name="wc-stripe-payment-token"]:checked').val()||e("#payment_method_stripe_sepa").is(":checked")&&e('input[name="wc-stripe_sepa-payment-token"]').is(":checked")&&"new"!==e('input[name="wc-stripe_sepa-payment-token"]:checked').val()},isStripeCardChosen:function(){return e("#payment_method_stripe").is(":checked")},isBancontactChosen:function(){return e("#payment_method_stripe_bancontact").is(":checked")},isGiropayChosen:function(){return e("#payment_method_stripe_giropay").is(":checked")},isIdealChosen:function(){return e("#payment_method_stripe_ideal").is(":checked")},isSofortChosen:function(){return e("#payment_method_stripe_sofort").is(":checked")},isAlipayChosen:function(){return e("#payment_method_stripe_alipay").is(":checked")},isSepaChosen:function(){return e("#payment_method_stripe_sepa").is(":checked")},isP24Chosen:function(){return e("#payment_method_stripe_p24").is(":checked")},isEpsChosen:function(){return e("#payment_method_stripe_eps").is(":checked")},isMultibancoChosen:function(){return e("#payment_method_stripe_multibanco").is(":checked")},hasSource:function(){return 0<e("input.stripe-source").length},hasToken:function(){return 0<e("input.stripe_token").length},isMobile:function(){return!!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)},isStripeModalNeeded:function(e){var r=p.form.find("input.stripe_token");return(!p.stripe_submit||!r)&&!!p.isStripeChosen()},block:function(){p.isMobile()||p.form.block({message:null,overlayCSS:{background:"#fff",opacity:.6}})},unblock:function(){p.form.unblock()},getSelectedPaymentElement:function(){return e('.payment_methods input[name="payment_method"]:checked')},openModal:function(){var r=p.form,t=e("#stripe-payment-data");p.reset();StripeCheckout.open({key:wc_stripe_params.key,billingAddress:t.data("billing-address"),zipCode:t.data("verify-zip"),amount:t.data("amount"),name:t.data("name"),description:t.data("description"),currency:t.data("currency"),image:t.data("image"),locale:t.data("locale"),email:e("#billing_email").val()||t.data("email"),panelLabel:t.data("panel-label"),allowRememberMe:t.data("allow-remember-me"),token:function(e){if(r.find("input.stripe_source").remove(),"token"===e.object)n.createSource({type:"card",token:e.id}).then(p.sourceResponse);else if("source"===e.object){var t={source:e};p.sourceResponse(t)}},closed:p.onClose()})},resetModal:function(){p.reset(),p.stripe_checkout_submit=!1},onClose:function(){p.unblock()},getOwnerDetails:function(){var r=e("#billing_first_name").length?e("#billing_first_name").val():wc_stripe_params.billing_first_name,t=e("#billing_last_name").length?e("#billing_last_name").val():wc_stripe_params.billing_last_name,o={owner:{name:"",address:{},email:"",phone:""}};return o.owner.name=r,o.owner.name=r&&t?r+" "+t:e("#stripe-payment-data").data("full-name"),o.owner.email=e("#billing_email").val(),o.owner.phone=e("#billing_phone").val(),(void 0===o.owner.phone||0>=o.owner.phone.length)&&delete o.owner.phone,(void 0===o.owner.email||0>=o.owner.email.length)&&(e("#stripe-payment-data").data("email").length?o.owner.email=e("#stripe-payment-data").data("email"):delete o.owner.email),(void 0===o.owner.name||0>=o.owner.name.length)&&delete o.owner.name,e("#billing_address_1").length>0?(o.owner.address.line1=e("#billing_address_1").val(),o.owner.address.line2=e("#billing_address_2").val(),o.owner.address.state=e("#billing_state").val(),o.owner.address.city=e("#billing_city").val(),o.owner.address.postal_code=e("#billing_postcode").val(),o.owner.address.country=e("#billing_country").val()):wc_stripe_params.billing_address_1&&(o.owner.address.line1=wc_stripe_params.billing_address_1,o.owner.address.line2=wc_stripe_params.billing_address_2,o.owner.address.state=wc_stripe_params.billing_state,o.owner.address.city=wc_stripe_params.billing_city,o.owner.address.postal_code=wc_stripe_params.billing_postcode,o.owner.address.country=wc_stripe_params.billing_country),o},createSource:function(){var t=p.getOwnerDetails(),o="card";if(p.isBancontactChosen()&&(o="bancontact"),p.isSepaChosen()&&(o="sepa_debit"),p.isIdealChosen()&&(o="ideal"),p.isSofortChosen()&&(o="sofort"),p.isGiropayChosen()&&(o="giropay"),p.isAlipayChosen()&&(o="alipay"),"card"===o)n.createSource(r,t).then(p.sourceResponse);else{switch(o){case"bancontact":case"giropay":case"ideal":case"sofort":case"alipay":t.amount=e("#stripe-"+o+"-payment-data").data("amount"),t.currency=e("#stripe-"+o+"-payment-data").data("currency"),t.redirect={return_url:wc_stripe_params.return_url},wc_stripe_params.statement_descriptor&&(t.statement_descriptor=wc_stripe_params.statement_descriptor)}switch(o){case"sepa_debit":t.currency=e("#stripe-"+o+"-payment-data").data("currency"),t.mandate={notification_method:wc_stripe_params.sepa_mandate_notification};break;case"ideal":t.ideal={bank:e("#stripe-ideal-bank").val()};break;case"alipay":t.currency=e("#stripe-"+o+"-payment-data").data("currency"),t.amount=e("#stripe-"+o+"-payment-data").data("amount");break;case"sofort":t.sofort={country:e("#billing_country").val()}}t.type=o,"sepa_debit"===o?n.createSource(c,t).then(p.sourceResponse):n.createSource(t).then(p.sourceResponse)}},sourceResponse:function(r){r.error?e(document.body).trigger("stripeError",r):"no"===wc_stripe_params.allow_prepaid_card&&"card"===r.source.type&&"prepaid"===r.source.card.funding?(r.error={message:wc_stripe_params.no_prepaid_card_msg},"yes"===wc_stripe_params.is_stripe_checkout?p.submitError('<ul class="woocommerce-error"><li>'+wc_stripe_params.no_prepaid_card_msg+"</li></ul>"):e(document.body).trigger("stripeError",r)):p.processStripeResponse(r.source)},processStripeResponse:function(r){p.reset(),p.form.append("<input type='hidden' class='stripe-source' name='stripe_source' value='"+r.id+"'/>"),e("form#add_payment_method").length&&e(p.form).off("submit",p.form.onSubmit),p.form.submit()},onSubmit:function(r){if(p.isStripeChosen()){if(!(p.isStripeSaveCardChosen()||p.hasSource()||p.hasToken())){if(r.preventDefault(),p.block(),"yes"===wc_stripe_params.is_stripe_checkout&&p.isStripeModalNeeded()&&p.isStripeCardChosen())return"yes"===wc_stripe_params.is_checkout||(p.openModal(),!1);if(p.isBancontactChosen()||p.isGiropayChosen()||p.isIdealChosen()||p.isAlipayChosen()||p.isSofortChosen()||p.isP24Chosen()||p.isEpsChosen()||p.isMultibancoChosen()){if(e("form#order_review").length)return e("form#order_review").off("submit",this.onSubmit),p.form.submit(),!1;if(e("form.woocommerce-checkout").length)return!0;if(e("form#add_payment_method").length)return e("form#add_payment_method").off("submit",this.onSubmit),p.form.submit(),!1}return p.createSource(),!1}return e("form#add_payment_method").length?(r.preventDefault(),"yes"===wc_stripe_params.is_stripe_checkout&&p.isStripeModalNeeded()&&p.isStripeCardChosen()?(p.openModal(),!1):(p.block(),p.createSource(),!1)):void 0}},onCCFormChange:function(){p.reset()},reset:function(){e(".wc-stripe-error, .stripe-source, .stripe_token").remove(),"yes"===wc_stripe_params.is_stripe_checkout&&(p.stripe_submit=!1)},onSepaError:function(r){var t=p.getSelectedPaymentElement().parents("li").eq(0).find(".stripe-source-errors");r.error?(console.log(r.error.message),e(t).html('<ul class="woocommerce_error woocommerce-error wc-stripe-error"><li>'+r.error.message+"</li></ul>")):e(t).html("")},onError:function(r,t){var o=t.error.message,n=p.getSelectedPaymentElement().parents("li").eq(0).find(".stripe-source-errors");if(p.isSepaChosen()&&"invalid_owner_name"===t.error.code&&wc_stripe_params.hasOwnProperty(t.error.code)){var s='<ul class="woocommerce-error"><li>'+wc_stripe_params[t.error.code]+"</li></ul>";return p.submitError(s)}"invalid_request_error"!==t.error.type&&"api_connection_error"!==t.error.type&&"api_error"!==t.error.type&&"authentication_error"!==t.error.type&&"rate_limit_error"!==t.error.type||(o=wc_stripe_params.invalid_request_error),"card_error"===t.error.type&&wc_stripe_params.hasOwnProperty(t.error.code)&&(o=wc_stripe_params[t.error.code]),"validation_error"===t.error.type&&wc_stripe_params.hasOwnProperty(t.error.code)&&(o=wc_stripe_params[t.error.code]),p.reset(),e(".woocommerce-NoticeGroup-checkout").remove(),console.log(t.error.message),e(n).html('<ul class="woocommerce_error woocommerce-error wc-stripe-error"><li>'+o+"</li></ul>"),e(".wc-stripe-error").length&&e("html, body").animate({scrollTop:e(".wc-stripe-error").offset().top-200},200),p.unblock()},submitError:function(r){e(".woocommerce-NoticeGroup-checkout, .woocommerce-error, .woocommerce-message").remove(),p.form.prepend('<div class="woocommerce-NoticeGroup woocommerce-NoticeGroup-checkout">'+r+"</div>"),p.form.removeClass("processing").unblock(),p.form.find(".input-text, select, input:checkbox").blur();var t="";e("#add_payment_method").length&&(t=e("#add_payment_method")),e("#order_review").length&&(t=e("#order_review")),e("form.checkout").length&&(t=e("form.checkout")),t.length&&e("html, body").animate({scrollTop:t.offset().top-100},500),e(document.body).trigger("checkout_error"),p.unblock()}};p.init()});
changelog.txt CHANGED
@@ -1,5 +1,13 @@
1
*** Changelog ***
2
3
= 4.1.8 - 2018-07-19 =
4
* Fix - 3DS payment sometimes will create additional transaction in Stripe.
5
* Fix - WC 2.6 with SEPA saved payment causing error on checkout.
1
*** Changelog ***
2
3
+ = 4.1.9 - 2018-08-27 =
4
+ * Fix - Don't display admin notices to user that cannot manage woocommerce.
5
+ * Fix - Fatal error when clicking on order link that doesn't exist.
6
+ * Fix - When capturing a charge from authorize, Stripe fees not displaying.
7
+ * Fix - Undefined property error on card type in rare cases.
8
+ * Tweak - Update SEPA IBAN to use new elements implementation.
9
+ * Add - Filter for Payment Request Button locale `wc_stripe_payment_request_button_locale`.
10
+
11
= 4.1.8 - 2018-07-19 =
12
* Fix - 3DS payment sometimes will create additional transaction in Stripe.
13
* Fix - WC 2.6 with SEPA saved payment causing error on checkout.
includes/class-wc-gateway-stripe.php CHANGED
@@ -168,8 +168,8 @@ class WC_Gateway_Stripe extends WC_Stripe_Payment_Gateway {
168
add_action( 'wp_enqueue_scripts', array( $this, 'payment_scripts' ) );
169
add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
170
add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
171
- add_action( 'woocommerce_admin_order_totals_after_total', array( $this, 'display_order_fee' ), 10, 1 );
172
- add_action( 'woocommerce_admin_order_totals_after_total', array( $this, 'display_order_payout' ), 20, 1 );
173
add_action( 'woocommerce_customer_save_address', array( $this, 'show_update_card_notice' ), 10, 2 );
174
add_action( 'woocommerce_receipt_stripe', array( $this, 'stripe_checkout_receipt_page' ) );
175
add_action( 'woocommerce_api_' . strtolower( get_class( $this ) ), array( $this, 'stripe_checkout_return_handler' ) );
@@ -395,6 +395,7 @@ class WC_Gateway_Stripe extends WC_Stripe_Payment_Gateway {
395
396
<!-- Used to display form errors -->
397
<div class="stripe-source-errors" role="alert"></div>
398
<?php do_action( 'woocommerce_credit_card_form_end', $this->id ); ?>
399
<div class="clear"></div>
400
</fieldset>
@@ -478,14 +479,16 @@ class WC_Gateway_Stripe extends WC_Stripe_Payment_Gateway {
478
$order_id = wc_get_order_id_by_order_key( urldecode( $_GET['key'] ) );
479
$order = wc_get_order( $order_id );
480
481
- $stripe_params['billing_first_name'] = WC_Stripe_Helper::is_pre_30() ? $order->billing_first_name : $order->get_billing_first_name();
482
- $stripe_params['billing_last_name'] = WC_Stripe_Helper::is_pre_30() ? $order->billing_last_name : $order->get_billing_last_name();
483
- $stripe_params['billing_address_1'] = WC_Stripe_Helper::is_pre_30() ? $order->billing_address_1 : $order->get_billing_address_1();
484
- $stripe_params['billing_address_2'] = WC_Stripe_Helper::is_pre_30() ? $order->billing_address_2 : $order->get_billing_address_2();
485
- $stripe_params['billing_state'] = WC_Stripe_Helper::is_pre_30() ? $order->billing_state : $order->get_billing_state();
486
- $stripe_params['billing_city'] = WC_Stripe_Helper::is_pre_30() ? $order->billing_city : $order->get_billing_city();
487
- $stripe_params['billing_postcode'] = WC_Stripe_Helper::is_pre_30() ? $order->billing_postcode : $order->get_billing_postcode();
488
- $stripe_params['billing_country'] = WC_Stripe_Helper::is_pre_30() ? $order->billing_country : $order->get_billing_country();
489
}
490
491
$stripe_params['no_prepaid_card_msg'] = __( 'Sorry, we\'re not accepting prepaid cards at this time. Your credit card has not been charge. Please try with alternative payment method.', 'woocommerce-gateway-stripe' );
@@ -501,6 +504,8 @@ class WC_Gateway_Stripe extends WC_Stripe_Payment_Gateway {
501
$stripe_params['stripe_nonce'] = wp_create_nonce( '_wc_stripe_nonce' );
502
$stripe_params['statement_descriptor'] = $this->statement_descriptor;
503
$stripe_params['elements_options'] = apply_filters( 'wc_stripe_elements_options', array() );
504
$stripe_params['is_stripe_checkout'] = $this->stripe_checkout ? 'yes' : 'no';
505
$stripe_params['is_change_payment_page'] = isset( $_GET['change_payment_method'] ) ? 'yes' : 'no';
506
$stripe_params['is_add_payment_page'] = is_wc_endpoint_url( 'add-payment-method' ) ? 'yes' : 'no';
168
add_action( 'wp_enqueue_scripts', array( $this, 'payment_scripts' ) );
169
add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
170
add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
171
+ add_action( 'woocommerce_admin_order_totals_after_total', array( $this, 'display_order_fee' ) );
172
+ add_action( 'woocommerce_admin_order_totals_after_total', array( $this, 'display_order_payout' ), 20 );
173
add_action( 'woocommerce_customer_save_address', array( $this, 'show_update_card_notice' ), 10, 2 );
174
add_action( 'woocommerce_receipt_stripe', array( $this, 'stripe_checkout_receipt_page' ) );
175
add_action( 'woocommerce_api_' . strtolower( get_class( $this ) ), array( $this, 'stripe_checkout_return_handler' ) );
395
396
<!-- Used to display form errors -->
397
<div class="stripe-source-errors" role="alert"></div>
398
+ <br />
399
<?php do_action( 'woocommerce_credit_card_form_end', $this->id ); ?>
400
<div class="clear"></div>
401
</fieldset>
479
$order_id = wc_get_order_id_by_order_key( urldecode( $_GET['key'] ) );
480
$order = wc_get_order( $order_id );
481
482
+ if ( is_a( $order, 'WC_Order' ) ) {
483
+ $stripe_params['billing_first_name'] = WC_Stripe_Helper::is_pre_30() ? $order->billing_first_name : $order->get_billing_first_name();
484
+ $stripe_params['billing_last_name'] = WC_Stripe_Helper::is_pre_30() ? $order->billing_last_name : $order->get_billing_last_name();
485
+ $stripe_params['billing_address_1'] = WC_Stripe_Helper::is_pre_30() ? $order->billing_address_1 : $order->get_billing_address_1();
486
+ $stripe_params['billing_address_2'] = WC_Stripe_Helper::is_pre_30() ? $order->billing_address_2 : $order->get_billing_address_2();
487
+ $stripe_params['billing_state'] = WC_Stripe_Helper::is_pre_30() ? $order->billing_state : $order->get_billing_state();
488
+ $stripe_params['billing_city'] = WC_Stripe_Helper::is_pre_30() ? $order->billing_city : $order->get_billing_city();
489
+ $stripe_params['billing_postcode'] = WC_Stripe_Helper::is_pre_30() ? $order->billing_postcode : $order->get_billing_postcode();
490
+ $stripe_params['billing_country'] = WC_Stripe_Helper::is_pre_30() ? $order->billing_country : $order->get_billing_country();
491
+ }
492
}
493
494
$stripe_params['no_prepaid_card_msg'] = __( 'Sorry, we\'re not accepting prepaid cards at this time. Your credit card has not been charge. Please try with alternative payment method.', 'woocommerce-gateway-stripe' );
504
$stripe_params['stripe_nonce'] = wp_create_nonce( '_wc_stripe_nonce' );
505
$stripe_params['statement_descriptor'] = $this->statement_descriptor;
506
$stripe_params['elements_options'] = apply_filters( 'wc_stripe_elements_options', array() );
507
+ $stripe_params['sepa_elements_options'] = apply_filters( 'wc_stripe_sepa_elements_options', array( 'supportedCountries' => array( 'SEPA' ), 'placeholderCountry' => WC()->countries->get_base_country(), 'style' => array( 'base' => array( 'fontSize' => '15px' ) ) ) );
508
+ $stripe_params['invalid_owner_name'] = __( 'Billing First Name and Last Name are required.', 'woocommerce-gateway-stripe' );
509
$stripe_params['is_stripe_checkout'] = $this->stripe_checkout ? 'yes' : 'no';
510
$stripe_params['is_change_payment_page'] = isset( $_GET['change_payment_method'] ) ? 'yes' : 'no';
511
$stripe_params['is_add_payment_page'] = is_wc_endpoint_url( 'add-payment-method' ) ? 'yes' : 'no';
includes/class-wc-stripe-apple-pay-registration.php CHANGED
@@ -217,6 +217,10 @@ class WC_Stripe_Apple_Pay_Registration {
217
if ( ! $this->stripe_enabled ) {
218
return;
219
}
220
221
if ( $this->payment_request && ! empty( $this->apple_pay_verify_notice ) ) {
222
$allowed_html = array(
217
if ( ! $this->stripe_enabled ) {
218
return;
219
}
220
+
221
+ if ( ! current_user_can( 'manage_woocommerce' ) ) {
222
+ return;
223
+ }
224
225
if ( $this->payment_request && ! empty( $this->apple_pay_verify_notice ) ) {
226
$allowed_html = array(
includes/class-wc-stripe-order-handler.php CHANGED
@@ -259,6 +259,10 @@ class WC_Stripe_Order_Handler extends WC_Stripe_Payment_Gateway {
259
$net = ! empty( $result->balance_transaction->net ) ? WC_Stripe_Helper::format_balance_fee( $result->balance_transaction, 'net' ) : 0;
260
WC_Stripe_Helper::update_stripe_fee( $order, $fee );
261
WC_Stripe_Helper::update_stripe_net( $order, $net );
262
}
263
264
if ( is_callable( array( $order, 'save' ) ) ) {
259
$net = ! empty( $result->balance_transaction->net ) ? WC_Stripe_Helper::format_balance_fee( $result->balance_transaction, 'net' ) : 0;
260
WC_Stripe_Helper::update_stripe_fee( $order, $fee );
261
WC_Stripe_Helper::update_stripe_net( $order, $net );
262
+
263
+ // Store currency stripe.
264
+ $currency = ! empty( $result->balance_transaction->currency ) ? strtoupper( $result->balance_transaction->currency ) : null;
265
+ WC_Stripe_Helper::update_stripe_currency( $order, $currency );
266
}
267
268
if ( is_callable( array( $order, 'save' ) ) ) {
includes/compat/class-wc-stripe-subs-compat.php CHANGED
@@ -466,6 +466,7 @@ class WC_Stripe_Subs_Compat extends WC_Gateway_Stripe {
466
if ( $sources ) {
467
$card = false;
468
$found_source = false;
469
foreach ( $sources as $source ) {
470
if ( isset( $source->type ) && 'card' === $source->type ) {
471
$card = $source->card;
@@ -487,7 +488,7 @@ class WC_Stripe_Subs_Compat extends WC_Gateway_Stripe {
487
}
488
489
if ( ! $found_source ) {
490
- if ( 'card' === $sources[0]->type ) {
491
$card = $sources[0]->card;
492
}
493
466
if ( $sources ) {
467
$card = false;
468
$found_source = false;
469
+
470
foreach ( $sources as $source ) {
471
if ( isset( $source->type ) && 'card' === $source->type ) {
472
$card = $source->card;
488
}
489
490
if ( ! $found_source ) {
491
+ if ( isset( $sources[0]->type ) && 'card' === $sources[0]->type ) {
492
$card = $sources[0]->card;
493
}
494
includes/payment-methods/class-wc-gateway-stripe-sepa.php CHANGED
@@ -220,19 +220,17 @@ class WC_Gateway_Stripe_Sepa extends WC_Stripe_Payment_Gateway {
220
<?php do_action( 'woocommerce_credit_card_form_start', $this->id ); ?>
221
<p class="wc-stripe-sepa-mandate" style="margin-bottom:40px;"><?php $this->mandate_display(); ?></p>
222
<p class="form-row form-row-wide">
223
- <label for="stripe-sepa-owner">
224
- <?php esc_html_e( 'IBAN Account Name.', 'woocommerce-gateway-stripe' ); ?> <span class="required">*</span>
225
</label>
226
- <input id="stripe-sepa-owner" class="wc-stripe-elements-field" name="stripe_sepa_owner" value="" />
227
- </p>
228
- <p class="form-row form-row-wide">
229
- <label for="stripe-sepa-iban">
230
- <?php esc_html_e( 'IBAN Account Number.', 'woocommerce-gateway-stripe' ); ?> <span class="required">*</span>
231
- </label>
232
- <input id="stripe-sepa-iban" class="wc-stripe-elements-field" name="stripe_sepa_iban" value="" />
233
</p>
234
<!-- Used to display form errors -->
235
<div class="stripe-source-errors" role="alert"></div>
236
<?php do_action( 'woocommerce_credit_card_form_end', $this->id ); ?>
237
<div class="clear"></div>
238
</fieldset>
220
<?php do_action( 'woocommerce_credit_card_form_start', $this->id ); ?>
221
<p class="wc-stripe-sepa-mandate" style="margin-bottom:40px;"><?php $this->mandate_display(); ?></p>
222
<p class="form-row form-row-wide">
223
+ <label for="stripe-iban-element">
224
+ <?php esc_html_e( 'IBAN.', 'woocommerce-gateway-stripe' ); ?> <span class="required">*</span>
225
</label>
226
+ <div id="stripe-iban-element" class="wc-stripe-iban-element-field">
227
+ <!-- A Stripe Element will be inserted here. -->
228
+ </div>
229
</p>
230
+
231
<!-- Used to display form errors -->
232
<div class="stripe-source-errors" role="alert"></div>
233
+ <br />
234
<?php do_action( 'woocommerce_credit_card_form_end', $this->id ); ?>
235
<div class="clear"></div>
236
</fieldset>
includes/payment-methods/class-wc-stripe-payment-request.php CHANGED
@@ -518,7 +518,7 @@ class WC_Stripe_Payment_Request {
518
'type' => $this->get_button_type(),
519
'theme' => $this->get_button_theme(),
520
'height' => $this->get_button_height(),
521
- 'locale' => substr( get_locale(), 0, 2 ), // Default format is en_US.
522
),
523
'is_product_page' => is_product(),
524
'product' => $this->get_product_data(),
518
'type' => $this->get_button_type(),
519
'theme' => $this->get_button_theme(),
520
'height' => $this->get_button_height(),
521
+ 'locale' => apply_filters( 'wc_stripe_payment_request_button_locale', substr( get_locale(), 0, 2 ) ), // Default format is en_US.
522
),
523
'is_product_page' => is_product(),
524
'product' => $this->get_product_data(),
languages/woocommerce-gateway-stripe.pot CHANGED
@@ -2,10 +2,10 @@
2
# This file is distributed under the same license as the WooCommerce Stripe Gateway package.
3
msgid ""
4
msgstr ""
5
- "Project-Id-Version: WooCommerce Stripe Gateway 4.1.8\n"
6
"Report-Msgid-Bugs-To: "
7
"https://github.com/woocommerce/woocommerce-gateway-stripe/issues\n"
8
- "POT-Creation-Date: 2018-07-19 13:30:28+00:00\n"
9
"MIME-Version: 1.0\n"
10
"Content-Type: text/plain; charset=utf-8\n"
11
"Content-Transfer-Encoding: 8bit\n"
@@ -63,7 +63,7 @@ msgid "Stripe charge complete (Charge ID: %s)"
63
msgstr ""
64
65
#: includes/abstracts/abstract-wc-stripe-payment-gateway.php:464
66
- #: includes/class-wc-gateway-stripe.php:703
67
#: includes/compat/class-wc-stripe-sepa-subs-compat.php:134
68
#: includes/compat/class-wc-stripe-subs-compat.php:96
69
msgid "Payment processing failed. Please retry."
@@ -186,10 +186,10 @@ msgstr ""
186
187
#: includes/admin/class-wc-stripe-privacy.php:41
188
#: includes/compat/class-wc-stripe-sepa-subs-compat.php:429
189
- #: includes/compat/class-wc-stripe-subs-compat.php:481
190
- #: includes/compat/class-wc-stripe-subs-compat.php:483
191
- #: includes/compat/class-wc-stripe-subs-compat.php:496
192
- #: includes/compat/class-wc-stripe-subs-compat.php:498
193
msgid "N/A"
194
msgstr ""
195
@@ -821,68 +821,72 @@ msgstr ""
821
msgid "Card Code (CVC)"
822
msgstr ""
823
824
- #: includes/class-wc-gateway-stripe.php:472
825
msgid "Please accept the terms and conditions first"
826
msgstr ""
827
828
- #: includes/class-wc-gateway-stripe.php:473
829
msgid "Please fill in required checkout fields first"
830
msgstr ""
831
832
- #: includes/class-wc-gateway-stripe.php:491
833
- #: includes/class-wc-gateway-stripe.php:698
834
#: includes/compat/class-wc-stripe-subs-compat.php:91
835
msgid ""
836
"Sorry, we're not accepting prepaid cards at this time. Your credit card has "
837
"not been charge. Please try with alternative payment method."
838
msgstr ""
839
840
- #: includes/class-wc-gateway-stripe.php:492
841
msgid "Please enter your IBAN account name."
842
msgstr ""
843
844
- #: includes/class-wc-gateway-stripe.php:493
845
msgid "Please enter your IBAN account number."
846
msgstr ""
847
848
- #: includes/class-wc-gateway-stripe.php:587
849
msgid "Place Order"
850
msgstr ""
851
852
- #: includes/class-wc-gateway-stripe.php:785
853
#: includes/class-wc-stripe-order-handler.php:144
854
#: includes/class-wc-stripe-webhook-handler.php:187
855
- #: includes/payment-methods/class-wc-gateway-stripe-sepa.php:348
856
msgid "This card is no longer available and has been removed."
857
msgstr ""
858
859
- #: includes/class-wc-gateway-stripe.php:804
860
#: includes/class-wc-stripe-order-handler.php:162
861
#: includes/class-wc-stripe-webhook-handler.php:206
862
#: includes/compat/class-wc-stripe-sepa-subs-compat.php:222
863
#: includes/compat/class-wc-stripe-subs-compat.php:237
864
- #: includes/payment-methods/class-wc-gateway-stripe-sepa.php:368
865
msgid ""
866
"Sorry, we are unable to process your payment at this time. Please retry "
867
"later."
868
msgstr ""
869
870
- #: includes/class-wc-gateway-stripe.php:881
871
#. translators: error message
872
msgid "This represents the fee Stripe collects for the transaction."
873
msgstr ""
874
875
- #: includes/class-wc-gateway-stripe.php:882
876
msgid "Stripe Fee:"
877
msgstr ""
878
879
- #: includes/class-wc-gateway-stripe.php:918
880
msgid ""
881
"This represents the net total that will be credited to your Stripe bank "
882
"account. This may be in the currency that is set in your Stripe account."
883
msgstr ""
884
885
- #: includes/class-wc-gateway-stripe.php:919
886
msgid "Stripe Payout:"
887
msgstr ""
888
@@ -908,7 +912,7 @@ msgstr ""
908
msgid "Unable to copy domain association file to domain root."
909
msgstr ""
910
911
- #: includes/class-wc-stripe-apple-pay-registration.php:239
912
#. translators: 1) HTML anchor open tag 2) HTML anchor closing tag
913
msgid ""
914
"Apple Pay domain verification failed. Please check the %1$slog%2$s to see "
@@ -1102,8 +1106,8 @@ msgstr ""
1102
msgid "Via SEPA Direct Debit ending in %1$s"
1103
msgstr ""
1104
1105
- #: includes/compat/class-wc-stripe-subs-compat.php:481
1106
- #: includes/compat/class-wc-stripe-subs-compat.php:496
1107
#. translators: 1) card brand 2) last 4 digits
1108
msgid "Via %1$s card ending in %2$s"
1109
msgstr ""
@@ -1209,14 +1213,10 @@ msgid ""
1209
msgstr ""
1210
1211
#: includes/payment-methods/class-wc-gateway-stripe-sepa.php:224
1212
- msgid "IBAN Account Name."
1213
- msgstr ""
1214
-
1215
- #: includes/payment-methods/class-wc-gateway-stripe-sepa.php:230
1216
- msgid "IBAN Account Number."
1217
msgstr ""
1218
1219
- #: includes/payment-methods/class-wc-gateway-stripe-sepa.php:267
1220
msgid ""
1221
"TEST MODE ENABLED. In test mode, you can use IBAN number "
1222
"DE89370400440532013000."
2
# This file is distributed under the same license as the WooCommerce Stripe Gateway package.
3
msgid ""
4
msgstr ""
5
+ "Project-Id-Version: WooCommerce Stripe Gateway 4.1.9\n"
6
"Report-Msgid-Bugs-To: "
7
"https://github.com/woocommerce/woocommerce-gateway-stripe/issues\n"
8
+ "POT-Creation-Date: 2018-08-27 16:21:18+00:00\n"
9
"MIME-Version: 1.0\n"
10
"Content-Type: text/plain; charset=utf-8\n"
11
"Content-Transfer-Encoding: 8bit\n"
63
msgstr ""
64
65
#: includes/abstracts/abstract-wc-stripe-payment-gateway.php:464
66
+ #: includes/class-wc-gateway-stripe.php:708
67
#: includes/compat/class-wc-stripe-sepa-subs-compat.php:134
68
#: includes/compat/class-wc-stripe-subs-compat.php:96
69
msgid "Payment processing failed. Please retry."
186
187
#: includes/admin/class-wc-stripe-privacy.php:41
188
#: includes/compat/class-wc-stripe-sepa-subs-compat.php:429
189
+ #: includes/compat/class-wc-stripe-subs-compat.php:482
190
+ #: includes/compat/class-wc-stripe-subs-compat.php:484
191
+ #: includes/compat/class-wc-stripe-subs-compat.php:497
192
+ #: includes/compat/class-wc-stripe-subs-compat.php:499
193
msgid "N/A"
194
msgstr ""
195
821
msgid "Card Code (CVC)"
822
msgstr ""
823
824
+ #: includes/class-wc-gateway-stripe.php:473
825
msgid "Please accept the terms and conditions first"
826
msgstr ""
827
828
+ #: includes/class-wc-gateway-stripe.php:474
829
msgid "Please fill in required checkout fields first"
830
msgstr ""
831
832
+ #: includes/class-wc-gateway-stripe.php:494
833
+ #: includes/class-wc-gateway-stripe.php:703
834
#: includes/compat/class-wc-stripe-subs-compat.php:91
835
msgid ""
836
"Sorry, we're not accepting prepaid cards at this time. Your credit card has "
837
"not been charge. Please try with alternative payment method."
838
msgstr ""
839
840
+ #: includes/class-wc-gateway-stripe.php:495
841
msgid "Please enter your IBAN account name."
842
msgstr ""
843
844
+ #: includes/class-wc-gateway-stripe.php:496
845
msgid "Please enter your IBAN account number."
846
msgstr ""
847
848
+ #: includes/class-wc-gateway-stripe.php:508
849
+ msgid "Billing First Name and Last Name are required."
850
+ msgstr ""
851
+
852
+ #: includes/class-wc-gateway-stripe.php:592
853
msgid "Place Order"
854
msgstr ""
855
856
+ #: includes/class-wc-gateway-stripe.php:790
857
#: includes/class-wc-stripe-order-handler.php:144
858
#: includes/class-wc-stripe-webhook-handler.php:187
859
+ #: includes/payment-methods/class-wc-gateway-stripe-sepa.php:346
860
msgid "This card is no longer available and has been removed."
861
msgstr ""
862
863
+ #: includes/class-wc-gateway-stripe.php:809
864
#: includes/class-wc-stripe-order-handler.php:162
865
#: includes/class-wc-stripe-webhook-handler.php:206
866
#: includes/compat/class-wc-stripe-sepa-subs-compat.php:222
867
#: includes/compat/class-wc-stripe-subs-compat.php:237
868
+ #: includes/payment-methods/class-wc-gateway-stripe-sepa.php:366
869
msgid ""
870
"Sorry, we are unable to process your payment at this time. Please retry "
871
"later."
872
msgstr ""
873
874
+ #: includes/class-wc-gateway-stripe.php:886
875
#. translators: error message
876
msgid "This represents the fee Stripe collects for the transaction."
877
msgstr ""
878
879
+ #: includes/class-wc-gateway-stripe.php:887
880
msgid "Stripe Fee:"
881
msgstr ""
882
883
+ #: includes/class-wc-gateway-stripe.php:923
884
msgid ""
885
"This represents the net total that will be credited to your Stripe bank "
886
"account. This may be in the currency that is set in your Stripe account."
887
msgstr ""
888
889
+ #: includes/class-wc-gateway-stripe.php:924
890
msgid "Stripe Payout:"
891
msgstr ""
892
912
msgid "Unable to copy domain association file to domain root."
913
msgstr ""
914
915
+ #: includes/class-wc-stripe-apple-pay-registration.php:243
916
#. translators: 1) HTML anchor open tag 2) HTML anchor closing tag
917
msgid ""
918
"Apple Pay domain verification failed. Please check the %1$slog%2$s to see "
1106
msgid "Via SEPA Direct Debit ending in %1$s"
1107
msgstr ""
1108
1109
+ #: includes/compat/class-wc-stripe-subs-compat.php:482
1110
+ #: includes/compat/class-wc-stripe-subs-compat.php:497
1111
#. translators: 1) card brand 2) last 4 digits
1112
msgid "Via %1$s card ending in %2$s"
1113
msgstr ""
1213
msgstr ""
1214
1215
#: includes/payment-methods/class-wc-gateway-stripe-sepa.php:224
1216
+ msgid "IBAN."
1217
msgstr ""
1218
1219
+ #: includes/payment-methods/class-wc-gateway-stripe-sepa.php:265
1220
msgid ""
1221
"TEST MODE ENABLED. In test mode, you can use IBAN number "
1222
"DE89370400440532013000."
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: credit card, stripe, apple pay, payment request, google pay, sepa, sofort,
4
Requires at least: 4.4
5
Tested up to: 4.9
6
Requires PHP: 5.6
7
- Stable tag: 4.1.8
8
License: GPLv3
9
License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
Attributions: thorsten-stripe
@@ -101,10 +101,13 @@ If you get stuck, you can ask for help in the Plugin Forum.
101
102
== Changelog ==
103
104
- = 4.1.8 - 2018-07-19 =
105
- * Fix - 3DS payment sometimes will create additional transaction in Stripe.
106
- * Fix - WC 2.6 with SEPA saved payment causing error on checkout.
107
- * Update - EPS logo.
108
109
[See changelog for all versions](https://raw.githubusercontent.com/woothemes/woocommerce-gateway-stripe/master/changelog.txt).
110
4
Requires at least: 4.4
5
Tested up to: 4.9
6
Requires PHP: 5.6
7
+ Stable tag: 4.1.9
8
License: GPLv3
9
License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
Attributions: thorsten-stripe
101
102
== Changelog ==
103
104
+ = 4.1.9 - 2018-08-27 =
105
+ * Fix - Don't display admin notices to user that cannot manage woocommerce.
106
+ * Fix - Fatal error when clicking on order link that doesn't exist.
107
+ * Fix - When capturing a charge from authorize, Stripe fees not displaying.
108
+ * Fix - Undefined property error on card type in rare cases.
109
+ * Tweak - Update SEPA IBAN to use new elements implementation.
110
+ * Add - Filter for Payment Request Button locale `wc_stripe_payment_request_button_locale`.
111
112
[See changelog for all versions](https://raw.githubusercontent.com/woothemes/woocommerce-gateway-stripe/master/changelog.txt).
113
woo-includes/class-wc-stripe-dependencies.php DELETED
@@ -1,28 +0,0 @@
1
- <?php
2
- /**
3
- * WC Dependency Checker
4
- *
5
- * Checks if WooCommerce is enabled
6
- */
7
- class WC_Stripe_Dependencies {
8
-
9
- private static $active_plugins;
10
-
11
- public static function init() {
12
-
13
- self::$active_plugins = (array) get_option( 'active_plugins', array() );
14
-
15
- if ( is_multisite() )
16
- self::$active_plugins = array_merge( self::$active_plugins, get_site_option( 'active_sitewide_plugins', array() ) );
17
- }
18
-
19
- public static function woocommerce_active_check() {
20
-
21
- if ( ! self::$active_plugins ) self::init();
22
-
23
- return in_array( 'woocommerce/woocommerce.php', self::$active_plugins ) || array_key_exists( 'woocommerce/woocommerce.php', self::$active_plugins );
24
- }
25
-
26
- }
27
-
28
-
woo-includes/woo-functions.php DELETED
@@ -1,16 +0,0 @@
1
- <?php
2
- /**
3
- * Functions used by plugins
4
- */
5
- if ( ! class_exists( 'WC_Stripe_Dependencies' ) ) {
6
- require_once( dirname( __FILE__ ) . '/class-wc-stripe-dependencies.php' );
7
- }
8
-
9
- /**
10
- * WC Detection
11
- */
12
- if ( ! function_exists( 'wc_stripe_is_wc_active' ) ) {
13
- function wc_stripe_is_wc_active() {
14
- return WC_Stripe_Dependencies::woocommerce_active_check();
15
- }
16
- }
woocommerce-gateway-stripe.php CHANGED
@@ -5,13 +5,13 @@
5
* Description: Take credit card payments on your store using Stripe.
6
* Author: WooCommerce
7
* Author URI: https://woocommerce.com/
8
- * Version: 4.1.8
9
* Requires at least: 4.4
10
* Tested up to: 4.9
11
* WC requires at least: 2.6
12
* WC tested up to: 3.4
13
* Text Domain: woocommerce-gateway-stripe
14
- * Domain Path: /languages/
15
*
16
*/
17
@@ -44,7 +44,7 @@ function woocommerce_gateway_stripe_init() {
44
/**
45
* Required minimums and constants
46
*/
47
- define( 'WC_STRIPE_VERSION', '4.1.8' );
48
define( 'WC_STRIPE_MIN_PHP_VER', '5.6.0' );
49
define( 'WC_STRIPE_MIN_WC_VER', '2.6.0' );
50
define( 'WC_STRIPE_MAIN_FILE', __FILE__ );
5
* Description: Take credit card payments on your store using Stripe.
6
* Author: WooCommerce
7
* Author URI: https://woocommerce.com/
8
+ * Version: 4.1.9
9
* Requires at least: 4.4
10
* Tested up to: 4.9
11
* WC requires at least: 2.6
12
* WC tested up to: 3.4
13
* Text Domain: woocommerce-gateway-stripe
14
+ * Domain Path: /languages
15
*
16
*/
17
44
/**
45
* Required minimums and constants
46
*/
47
+ define( 'WC_STRIPE_VERSION', '4.1.9' );
48
define( 'WC_STRIPE_MIN_PHP_VER', '5.6.0' );
49
define( 'WC_STRIPE_MIN_WC_VER', '2.6.0' );
50
define( 'WC_STRIPE_MAIN_FILE', __FILE__ );