Version Description
- Fixed - Do not redirect to order received page if customer has not completed local payment process
- Fixed - Disable Apple Pay button on variation product when no default product is selected
- Added - Mini-cart integration for GPay and Apple Pay.
- Added - Filter wc_stripe_get_source_args added
- Added - Email validation for local payment methods
- Added - WC tested up to: 4.3.2
- Updated - Stripe PHP lib version 7.45.0
Download this release
Release Info
Developer | mr.clayton |
Plugin | Payment Plugins for Stripe WooCommerce |
Version | 3.1.8 |
Comparing to | |
See all releases |
Code changes from version 3.1.7 to 3.1.8
- assets/css/stripe.css +31 -1
- assets/img/grabpay.svg +15 -0
- assets/js/frontend/applepay-checkout.js +9 -9
- assets/js/frontend/applepay-product.js +16 -39
- assets/js/frontend/credit-card.js +80 -67
- assets/js/frontend/googlepay-product.js +0 -2
- assets/js/frontend/local-payment.js +60 -51
- assets/js/frontend/mini-cart.js +144 -0
- assets/js/frontend/payment-request.js +45 -64
- assets/js/frontend/wc-stripe.js +561 -536
- assets/js/frontend/wc-stripe.min.js +1 -1
- composer.json +5 -0
- composer.lock +76 -0
- i18n/languages/woo-stripe-payment.pot +166 -150
- includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php +16 -11
- includes/abstract/abstract-wc-payment-gateway-stripe.php +121 -20
- includes/class-stripe.php +4 -2
- includes/class-wc-stripe-field-manager.php +32 -77
- includes/class-wc-stripe-frontend-scripts.php +16 -0
- includes/class-wc-stripe-payment-intent.php +5 -0
- includes/class-wc-stripe-redirect-handler.php +5 -2
- includes/class-wc-stripe-rest-api.php +22 -16
- includes/controllers/class-wc-stripe-controller-cart.php +33 -18
- includes/controllers/class-wc-stripe-controller-checkout.php +10 -12
- includes/controllers/class-wc-stripe-controller-googlepay.php +19 -17
- includes/controllers/class-wc-stripe-controller-order-actions.php +8 -8
- includes/controllers/class-wc-stripe-controller-payment-intent.php +1 -1
- includes/gateways/class-wc-payment-gateway-stripe-applepay.php +5 -6
- includes/gateways/class-wc-payment-gateway-stripe-fpx.php +2 -1
- includes/gateways/class-wc-payment-gateway-stripe-googlepay.php +33 -20
- includes/gateways/class-wc-payment-gateway-stripe-grabpay.php +32 -0
- includes/gateways/class-wc-payment-gateway-stripe-payment-request.php +5 -5
- includes/gateways/settings/applepay-settings.php +4 -3
- includes/gateways/settings/googlepay-settings.php +3 -9
- includes/gateways/settings/payment-request-settings.php +1 -0
- includes/traits/wc-stripe-controller-cart-trait.php +0 -28
- includes/traits/wc-stripe-controller-traits.php +70 -0
- includes/wc-stripe-functions.php +82 -62
- includes/wc-stripe-webhook-functions.php +1 -1
- readme.txt +10 -2
- stripe-payments.php +14 -13
- templates/cart/googlepay.php +1 -3
- templates/cart/payment-methods.php +2 -2
- templates/checkout/checkout-banner.php +1 -1
- templates/checkout/googlepay.php +1 -3
- templates/mini-cart/applepay.php +8 -0
- templates/mini-cart/googlepay.php +6 -0
- templates/mini-cart/payment-methods.php +15 -0
- templates/mini-cart/payment-request.php +6 -0
- templates/product/googlepay.php +1 -3
- templates/product/payment-methods.php +1 -1
- vendor/composer/installed.json +6 -6
- vendor/stripe/stripe-php/CHANGELOG.md +18 -0
- vendor/stripe/stripe-php/VERSION +1 -1
- vendor/stripe/stripe-php/lib/Card.php +1 -1
- vendor/stripe/stripe-php/lib/Checkout/Session.php +8 -1
- vendor/stripe/stripe-php/lib/Collection.php +20 -0
- vendor/stripe/stripe-php/lib/CreditNote.php +4 -3
- vendor/stripe/stripe-php/lib/CreditNoteLineItem.php +1 -0
- vendor/stripe/stripe-php/lib/Customer.php +1 -1
- vendor/stripe/stripe-php/lib/Event.php +1 -1
- vendor/stripe/stripe-php/lib/File.php +10 -1
- vendor/stripe/stripe-php/lib/Invoice.php +3 -1
- vendor/stripe/stripe-php/lib/InvoiceItem.php +1 -0
- vendor/stripe/stripe-php/lib/InvoiceLineItem.php +2 -0
- vendor/stripe/stripe-php/lib/Issuing/Cardholder.php +1 -1
- vendor/stripe/stripe-php/lib/PaymentIntent.php +1 -1
- vendor/stripe/stripe-php/lib/Person.php +4 -0
- vendor/stripe/stripe-php/lib/Recipient.php +1 -4
- vendor/stripe/stripe-php/lib/Service/PaymentIntentService.php +1 -1
- vendor/stripe/stripe-php/lib/Service/SetupIntentService.php +2 -2
- vendor/stripe/stripe-php/lib/Service/SubscriptionItemService.php +1 -1
- vendor/stripe/stripe-php/lib/Stripe.php +1 -1
- vendor/stripe/stripe-php/lib/Subscription.php +1 -1
- vendor/stripe/stripe-php/lib/SubscriptionSchedule.php +1 -1
- vendor/stripe/stripe-php/lib/TaxId.php +2 -2
- vendor/stripe/stripe-php/lib/TaxRate.php +7 -2
- vendor/stripe/stripe-php/lib/UsageRecord.php +1 -1
assets/css/stripe.css
CHANGED
@@ -120,10 +120,11 @@ label.wc-stripe-label-payment-type:after {
|
|
120 |
display: none !important;
|
121 |
}
|
122 |
|
123 |
-
.select2-container .select2-selection--single .wc-stripe-select2-container,
|
124 |
.select2-results__options li.wc-stripe-select2-container {
|
125 |
display: flex;
|
126 |
align-items: center;
|
|
|
127 |
line-height: 42px !important;
|
128 |
}
|
129 |
|
@@ -562,6 +563,12 @@ ul.payment_methods li.payment_method_stripe_alipay img {
|
|
562 |
max-height: 36px;
|
563 |
}
|
564 |
|
|
|
|
|
|
|
|
|
|
|
|
|
565 |
#wc-stripe-card-element {
|
566 |
width: 100%;
|
567 |
}
|
@@ -738,4 +745,27 @@ li.payment_method_stripe_sepa,
|
|
738 |
li.payment_method_stripe_sofort,
|
739 |
li.payment_method_stripe_wechat {
|
740 |
display: none;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
741 |
}
|
120 |
display: none !important;
|
121 |
}
|
122 |
|
123 |
+
.wc-stripe-saved-methods-container .select2-container .select2-selection--single .wc-stripe-select2-container,
|
124 |
.select2-results__options li.wc-stripe-select2-container {
|
125 |
display: flex;
|
126 |
align-items: center;
|
127 |
+
height: 42px;
|
128 |
line-height: 42px !important;
|
129 |
}
|
130 |
|
563 |
max-height: 36px;
|
564 |
}
|
565 |
|
566 |
+
ul.payment_methods li.payment_method_stripe_grabpay img {
|
567 |
+
max-width: 95px;
|
568 |
+
width: 95px;
|
569 |
+
max-height: 28px;
|
570 |
+
}
|
571 |
+
|
572 |
#wc-stripe-card-element {
|
573 |
width: 100%;
|
574 |
}
|
745 |
li.payment_method_stripe_sofort,
|
746 |
li.payment_method_stripe_wechat {
|
747 |
display: none;
|
748 |
+
}
|
749 |
+
|
750 |
+
.widget_shopping_cart_content .wc-stripe-mini-cart-payment-methods{
|
751 |
+
list-style: none;
|
752 |
+
margin: 0;
|
753 |
+
padding: 0;
|
754 |
+
}
|
755 |
+
.widget_shopping_cart_content .wc-stripe-mini-cart-payment-methods li{
|
756 |
+
margin: 0;
|
757 |
+
}
|
758 |
+
.widget_shopping_cart_content .payment_method_stripe_googlepay.active,
|
759 |
+
.widget_shopping_cart_content .payment_method_stripe_applepay.active,
|
760 |
+
.widget_shopping_cart_content .payment_method_stripe_payment_request.active{
|
761 |
+
display: block;
|
762 |
+
}
|
763 |
+
.wc-stripe-gpay-mini-cart .gpay-button-container .gpay-button{
|
764 |
+
width: 100%;
|
765 |
+
}
|
766 |
+
.wc-stripe-payment-request-mini-cart.StripeElement{
|
767 |
+
padding: 0;
|
768 |
+
background: transparent;
|
769 |
+
border: none;
|
770 |
+
width: 100%;
|
771 |
}
|
assets/img/grabpay.svg
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="utf-8"?>
|
2 |
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
3 |
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Logo" x="0px" y="0px" width="350px" height="100px" viewBox="24 15 356 100" xml:space="preserve"><script xmlns="" id="tinyhippos-injected"/>
|
4 |
+
<style type="text/css">
|
5 |
+
.st0{fill:#00AB4E;}
|
6 |
+
</style>
|
7 |
+
<g>
|
8 |
+
<g>
|
9 |
+
<path class="st0" d="M270.5,48.72c0,13.64-9,21.63-22.63,21.63h-11.54v19.82h-11.36V27.45h22.91 C261.5,27.45,270.5,34.99,270.5,48.72z M259.23,48.72c0-7.63-4.73-10.64-11.36-10.64h-11.54v21.63h11.54 C254.5,59.71,259.23,56.26,259.23,48.72z"/>
|
10 |
+
<path class="st0" d="M323.85,61.81v27.81h-11.18v-5c0,0.09-3.91,5.55-13.54,5.55c-14.72,0-23.73-9.45-23.73-24.18v-4.18 c0-14.82,9.55-24.09,24.36-24.09C314.58,37.72,323.85,46.99,323.85,61.81z M312.67,61.81c0-8.18-5.27-13.18-12.91-13.18 c-7.64,0-13.18,5-13.18,13.18v4.18c0,7.73,5.64,13.27,13.18,13.27c8.09,0,12.91-4.54,12.91-13V61.81z"/>
|
11 |
+
<path class="st0" d="M375.34,38.32v51.81c0,13.81-9.36,20.9-23.45,20.9c-6.82,0-12.91-2.72-16.91-6.36V93.4 c4,3.63,10.18,6.91,17.45,6.91c7.73,0,12.36-3.27,12.36-10.81v-4.82c-2.54,3.36-7.82,5.27-12.91,5.27 c-13.09,0-20.91-8.91-20.91-21.81V38.32h11.82v29.81c0,6.36,4.18,10.91,10.55,10.91c6.36,0,10.55-4,10.55-10.36V38.32H375.34z"/>
|
12 |
+
</g>
|
13 |
+
<path class="st0" d="M208.33,46.2c-4.44-4.44-10.28-6.89-16.42-6.89c-4.5,0-9.01,1.67-11.5,3.33c-5.13,3.42-9.36,7.14-16.96,16.96 v7.06c6.45-8.41,12.55-15.03,17.19-18.67c3.04-2.45,7.37-3.96,11.27-3.96c10.07,0,18.58,8.51,18.58,18.58v4.25 c0,4.98-1.96,9.66-5.52,13.18c-3.53,3.49-8.17,5.4-13.06,5.4c-8.27,0-15.56-5.68-17.54-13.43l-3.33,4.03 c2.42,8.13,11.19,14.12,20.87,14.12c6.14,0,11.98-2.44,16.42-6.88c4.44-4.44,6.88-10.27,6.88-16.42v-4.25 C215.21,56.47,212.77,50.64,208.33,46.2 M107.23,44.03c3.21,0,5.98,0.69,8.48,2.1c1.18-1.47,2.37-2.66,3.25-3.55 c-2.64-2.02-7.13-3.28-11.73-3.28c-6.56,0-12.5,2.36-16.76,6.66c-4.22,4.26-6.55,10.17-6.55,16.64v27.55h4.72V62.61 C88.65,51.68,96.29,44.03,107.23,44.03 M152.09,90.16V62.61c0-8.47-6.64-15.11-15.11-15.11c-3.95,0-7.71,1.6-10.61,4.5 c-2.9,2.9-4.5,6.67-4.5,10.61v4.25c0,8.19,6.92,15.11,15.11,15.11c2.24,0,5.3-0.55,7.17-2.08V74.9c-1.83,1.48-4.5,2.36-7.17,2.36 c-5.82,0-10.39-4.56-10.39-10.39v-4.25c0-5.82,4.56-10.39,10.39-10.39c5.83,0,10.39,4.56,10.39,10.39v27.55H152.09z M25.66,59.89 v1.52c0,8.18,3.11,15.82,8.75,21.49c5.62,5.67,13.17,8.78,21.23,8.78c6.48,0,12.23-1.46,17.08-4.35c4-2.38,5.77-4.79,5.92-5.01 V56.91H54.49v4.72h19.43v19.22l-0.02,0.02c-2.28,2.28-7.68,6.09-18.26,6.09c-6.9,0-13.29-2.63-17.99-7.42 c-4.69-4.76-7.26-11.2-7.26-18.14v-1.52c0-6.56,2.95-13.09,8.1-17.92c5.26-4.93,12.11-7.64,19.29-7.64 c6.69,0,11.36,1.02,15.11,3.28v-5.3c-3.9-1.66-8.56-2.41-15.11-2.41C40.36,29.91,25.66,43.64,25.66,59.89 M107.23,52.23 c1.79,0,3.31,0.3,4.52,0.89c0.59-1.47,1.19-2.68,2.07-4.14c-1.28-0.92-4.34-1.47-6.59-1.47c-8.61,0-15.11,6.49-15.11,15.11v27.55 h4.72V62.61C96.85,56.5,101.11,52.23,107.23,52.23 M72.87,46.69v-5.58c-4.27-2.29-8.93-3.31-15.11-3.31 c-6.3,0-12.28,2.31-16.84,6.51c-4.56,4.2-7.07,9.74-7.07,15.58v1.52c0,12.18,9.77,22.09,21.78,22.09c9.77,0,13.78-3.2,14.8-4.21 V65.11H54.49v4.72h11.54v7.1l-0.04,0.01c-1.48,0.6-4.57,1.83-10.34,1.83c-4.58,0-8.87-1.78-12.08-5.03 c-3.22-3.25-4.99-7.63-4.99-12.33v-1.52c0-9.42,8.79-17.37,19.19-17.37C64.96,42.52,69.21,43.69,72.87,46.69 M184.28,55.58 c2.13-2.13,4.92-3.35,7.63-3.35c5.82,0,10.39,4.56,10.39,10.39v4.25c0,5.83-4.56,10.39-10.39,10.39c-2.82,0-5.54-1.54-7.68-4.35 c-1.89-2.48-3.12-5.83-3.31-8.84l-3.82,4.67c0.75,3.58,2.62,6.99,5.25,9.39c2.72,2.48,6.11,3.84,9.55,3.84 c8.33,0,15.11-6.77,15.11-15.11v-4.25c0-3.94-1.6-7.71-4.49-10.61c-2.9-2.9-6.67-4.5-10.61-4.5c-2.5,0-6.46,0.9-11.19,5.15 l-0.02,0.02c-1.27,1.26-4.24,4.23-6.04,6.35c-3.04,3.31-7.46,8.31-11.21,13.33v7.37c4.17-5.37,6.57-8.37,10.5-12.9 C177.47,62.72,181.82,57.74,184.28,55.58 M113.68,66.86c0,6.15,2.44,11.98,6.88,16.42c4.44,4.44,10.27,6.88,16.42,6.88 c2.6,0,5.28-0.55,7.17-1.48v-4.72c-2.21,0.92-4.88,1.48-7.17,1.48c-10.07,0-18.58-8.51-18.58-18.58v-4.25 c0-10.07,8.51-18.58,18.58-18.58c5.01,0,9.69,1.92,13.17,5.41c3.49,3.49,5.41,8.17,5.41,13.17v27.55h4.72V61.71 c-0.29-6.01-2.86-11.64-7.22-15.85c-4.37-4.22-10.08-6.55-16.07-6.55c-6.14,0-11.98,2.44-16.42,6.89 c-4.44,4.44-6.88,10.27-6.88,16.41V66.86z M168.31,48.59c1.45-1.73,2.94-3.5,4.72-4.98V18.68h-4.72V48.59z M176.5,41.68v-23h4.72 v19.76C179.94,39.08,178.15,40.32,176.5,41.68"/>
|
14 |
+
</g>
|
15 |
+
</svg>
|
assets/js/frontend/applepay-checkout.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
(function($, wc_stripe) {
|
2 |
|
3 |
/**
|
4 |
* @constructor
|
@@ -13,18 +13,18 @@
|
|
13 |
*/
|
14 |
ApplePay.prototype = $.extend({}, wc_stripe.BaseGateway.prototype, wc_stripe.CheckoutGateway.prototype, wc_stripe.ApplePay.prototype);
|
15 |
|
16 |
-
ApplePay.prototype.initialize = function() {
|
17 |
wc_stripe.CheckoutGateway.call(this);
|
18 |
wc_stripe.ApplePay.prototype.initialize.call(this);
|
19 |
}
|
20 |
|
21 |
-
ApplePay.prototype.canMakePayment = function() {
|
22 |
-
wc_stripe.ApplePay.prototype.canMakePayment.apply(this, arguments).then(function() {
|
23 |
if (this.banner_enabled()) {
|
24 |
var $button = $(this.params.button);
|
25 |
$button.addClass('banner-checkout');
|
26 |
-
$(this.banner_container).show().parent().parent().addClass('active');
|
27 |
$(this.banner_container).append($button);
|
|
|
28 |
}
|
29 |
}.bind(this))
|
30 |
}
|
@@ -32,12 +32,12 @@
|
|
32 |
/**
|
33 |
* @return {[type]}
|
34 |
*/
|
35 |
-
ApplePay.prototype.append_button = function() {
|
36 |
$('#place_order').parent().append(this.$button);
|
37 |
this.trigger_payment_method_selected();
|
38 |
}
|
39 |
|
40 |
-
ApplePay.prototype.updated_checkout = function() {
|
41 |
if (this.can_pay) {
|
42 |
this.create_button();
|
43 |
$(this.container).show();
|
@@ -48,7 +48,7 @@
|
|
48 |
* [Wrapper for main start function]
|
49 |
* @param {[@event]} e [description]
|
50 |
*/
|
51 |
-
ApplePay.prototype.start = function(e) {
|
52 |
if ($(e.target).is('.banner-checkout')) {
|
53 |
this.set_payment_method(this.gateway_id);
|
54 |
this.set_use_new_option(true);
|
@@ -56,7 +56,7 @@
|
|
56 |
wc_stripe.ApplePay.prototype.start.apply(this, arguments);
|
57 |
}
|
58 |
|
59 |
-
ApplePay.prototype.on_token_received = function() {
|
60 |
wc_stripe.CheckoutGateway.prototype.on_token_received.apply(this, arguments);
|
61 |
if (this.checkout_fields_valid()) {
|
62 |
this.get_form().submit();
|
1 |
+
(function ($, wc_stripe) {
|
2 |
|
3 |
/**
|
4 |
* @constructor
|
13 |
*/
|
14 |
ApplePay.prototype = $.extend({}, wc_stripe.BaseGateway.prototype, wc_stripe.CheckoutGateway.prototype, wc_stripe.ApplePay.prototype);
|
15 |
|
16 |
+
ApplePay.prototype.initialize = function () {
|
17 |
wc_stripe.CheckoutGateway.call(this);
|
18 |
wc_stripe.ApplePay.prototype.initialize.call(this);
|
19 |
}
|
20 |
|
21 |
+
ApplePay.prototype.canMakePayment = function () {
|
22 |
+
wc_stripe.ApplePay.prototype.canMakePayment.apply(this, arguments).then(function () {
|
23 |
if (this.banner_enabled()) {
|
24 |
var $button = $(this.params.button);
|
25 |
$button.addClass('banner-checkout');
|
|
|
26 |
$(this.banner_container).append($button);
|
27 |
+
$(this.banner_container).show().parent().parent().addClass('active');
|
28 |
}
|
29 |
}.bind(this))
|
30 |
}
|
32 |
/**
|
33 |
* @return {[type]}
|
34 |
*/
|
35 |
+
ApplePay.prototype.append_button = function () {
|
36 |
$('#place_order').parent().append(this.$button);
|
37 |
this.trigger_payment_method_selected();
|
38 |
}
|
39 |
|
40 |
+
ApplePay.prototype.updated_checkout = function () {
|
41 |
if (this.can_pay) {
|
42 |
this.create_button();
|
43 |
$(this.container).show();
|
48 |
* [Wrapper for main start function]
|
49 |
* @param {[@event]} e [description]
|
50 |
*/
|
51 |
+
ApplePay.prototype.start = function (e) {
|
52 |
if ($(e.target).is('.banner-checkout')) {
|
53 |
this.set_payment_method(this.gateway_id);
|
54 |
this.set_use_new_option(true);
|
56 |
wc_stripe.ApplePay.prototype.start.apply(this, arguments);
|
57 |
}
|
58 |
|
59 |
+
ApplePay.prototype.on_token_received = function () {
|
60 |
wc_stripe.CheckoutGateway.prototype.on_token_received.apply(this, arguments);
|
61 |
if (this.checkout_fields_valid()) {
|
62 |
this.get_form().submit();
|
assets/js/frontend/applepay-product.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
(function($, wc_stripe) {
|
2 |
|
3 |
function ApplePay() {
|
4 |
wc_stripe.BaseGateway.call(this, wc_stripe_applepay_product_params);
|
@@ -11,7 +11,8 @@
|
|
11 |
*/
|
12 |
ApplePay.prototype = $.extend({}, wc_stripe.BaseGateway.prototype, wc_stripe.ProductGateway.prototype, wc_stripe.ApplePay.prototype);
|
13 |
|
14 |
-
ApplePay.prototype.initialize = function() {
|
|
|
15 |
wc_stripe.ProductGateway.call(this);
|
16 |
wc_stripe.ApplePay.prototype.initialize.call(this);
|
17 |
}
|
@@ -19,27 +20,17 @@
|
|
19 |
/**
|
20 |
* @return {[type]}
|
21 |
*/
|
22 |
-
ApplePay.prototype.canMakePayment = function() {
|
23 |
-
wc_stripe.ApplePay.prototype.canMakePayment.call(this).then(function() {
|
24 |
$(document.body).on('change', '[name="quantity"]', this.add_to_cart.bind(this));
|
25 |
$(this.container).parent().parent().addClass('active');
|
26 |
if (!this.is_variable_product()) {
|
27 |
-
this.cart_calculation()
|
28 |
-
this.paymentRequest.update(this.get_payment_request_update({
|
29 |
-
total: {
|
30 |
-
pending: false
|
31 |
-
}
|
32 |
-
}));
|
33 |
-
}.bind(this)).catch(function() {
|
34 |
-
$('[name="quantity"]').val(0);
|
35 |
-
}.bind(this))
|
36 |
} else {
|
37 |
-
if (this.
|
38 |
-
this.
|
39 |
-
|
40 |
-
|
41 |
-
}
|
42 |
-
}));
|
43 |
}
|
44 |
}
|
45 |
}.bind(this))
|
@@ -49,8 +40,8 @@
|
|
49 |
* @param {[type]}
|
50 |
* @return {[type]}
|
51 |
*/
|
52 |
-
ApplePay.prototype.start = function(e) {
|
53 |
-
if (this.get_quantity()
|
54 |
e.preventDefault();
|
55 |
this.submit_error(this.params.messages.invalid_amount);
|
56 |
} else {
|
@@ -61,33 +52,19 @@
|
|
61 |
/**
|
62 |
* @return {[type]}
|
63 |
*/
|
64 |
-
ApplePay.prototype.append_button = function() {
|
65 |
$('#wc-stripe-applepay-container').append(this.$button);
|
66 |
}
|
67 |
|
68 |
-
ApplePay.prototype.
|
69 |
-
if (this.can_pay) {
|
70 |
-
this.cart_calculation(variation.variation_id).then(function() {
|
71 |
-
wc_stripe.ProductGateway.prototype.found_variation.call(this, e, variation);
|
72 |
-
if (this.can_pay) {
|
73 |
-
this.paymentRequest.update(this.get_payment_request_update({
|
74 |
-
total: {
|
75 |
-
pending: false
|
76 |
-
}
|
77 |
-
}));
|
78 |
-
}
|
79 |
-
}.bind(this))
|
80 |
-
}
|
81 |
-
}
|
82 |
-
|
83 |
-
ApplePay.prototype.add_to_cart = function(e) {
|
84 |
if (this.$button.is('.disabled') && this.can_pay) {
|
85 |
$('[name="quantity"]').val(this.old_qty);
|
86 |
this.submit_error(this.params.messages.choose_product);
|
87 |
return;
|
88 |
}
|
89 |
this.old_qty = this.get_quantity();
|
90 |
-
|
|
|
91 |
}
|
92 |
|
93 |
new ApplePay();
|
1 |
+
(function ($, wc_stripe) {
|
2 |
|
3 |
function ApplePay() {
|
4 |
wc_stripe.BaseGateway.call(this, wc_stripe_applepay_product_params);
|
11 |
*/
|
12 |
ApplePay.prototype = $.extend({}, wc_stripe.BaseGateway.prototype, wc_stripe.ProductGateway.prototype, wc_stripe.ApplePay.prototype);
|
13 |
|
14 |
+
ApplePay.prototype.initialize = function () {
|
15 |
+
this.container = '.wc_stripe_product_payment_methods ' + this.container;
|
16 |
wc_stripe.ProductGateway.call(this);
|
17 |
wc_stripe.ApplePay.prototype.initialize.call(this);
|
18 |
}
|
20 |
/**
|
21 |
* @return {[type]}
|
22 |
*/
|
23 |
+
ApplePay.prototype.canMakePayment = function () {
|
24 |
+
wc_stripe.ApplePay.prototype.canMakePayment.call(this).then(function () {
|
25 |
$(document.body).on('change', '[name="quantity"]', this.add_to_cart.bind(this));
|
26 |
$(this.container).parent().parent().addClass('active');
|
27 |
if (!this.is_variable_product()) {
|
28 |
+
this.cart_calculation();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
} else {
|
30 |
+
if (this.variable_product_selected()) {
|
31 |
+
this.cart_calculation(this.get_product_data().variation.variation_id);
|
32 |
+
} else {
|
33 |
+
this.disable_payment_button();
|
|
|
|
|
34 |
}
|
35 |
}
|
36 |
}.bind(this))
|
40 |
* @param {[type]}
|
41 |
* @return {[type]}
|
42 |
*/
|
43 |
+
ApplePay.prototype.start = function (e) {
|
44 |
+
if (this.get_quantity() === 0) {
|
45 |
e.preventDefault();
|
46 |
this.submit_error(this.params.messages.invalid_amount);
|
47 |
} else {
|
52 |
/**
|
53 |
* @return {[type]}
|
54 |
*/
|
55 |
+
ApplePay.prototype.append_button = function () {
|
56 |
$('#wc-stripe-applepay-container').append(this.$button);
|
57 |
}
|
58 |
|
59 |
+
ApplePay.prototype.add_to_cart = function (e) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
if (this.$button.is('.disabled') && this.can_pay) {
|
61 |
$('[name="quantity"]').val(this.old_qty);
|
62 |
this.submit_error(this.params.messages.choose_product);
|
63 |
return;
|
64 |
}
|
65 |
this.old_qty = this.get_quantity();
|
66 |
+
var variation = this.get_product_data().variation;
|
67 |
+
this.cart_calculation(variation.variation_id);
|
68 |
}
|
69 |
|
70 |
new ApplePay();
|
assets/js/frontend/credit-card.js
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
-
(function($, wc_stripe) {
|
2 |
|
3 |
/**
|
4 |
* Credit card class.
|
5 |
-
*
|
6 |
* @constructor
|
7 |
*/
|
8 |
function CC() {
|
@@ -21,15 +21,15 @@
|
|
21 |
CC.prototype = $.extend({}, wc_stripe.BaseGateway.prototype, wc_stripe.CheckoutGateway.prototype);
|
22 |
|
23 |
/**
|
24 |
-
*
|
25 |
*/
|
26 |
-
CC.prototype.initialize = function() {
|
27 |
$(document.body).on('click', '#place_order', this.place_order.bind(this));
|
28 |
this.setup_card();
|
29 |
this.create_card_element();
|
30 |
|
31 |
-
if (this.
|
32 |
-
this.create_setup_intent().then(function(response) {
|
33 |
if (response.code) {
|
34 |
this.submit_error(response.message);
|
35 |
} else {
|
@@ -40,9 +40,9 @@
|
|
40 |
}
|
41 |
|
42 |
/**
|
43 |
-
*
|
44 |
*/
|
45 |
-
CC.prototype.setup_card = function() {
|
46 |
if (this.is_custom_form()) {
|
47 |
// create individual card sections
|
48 |
this.cardNumber = this.elements.create('cardNumber', {
|
@@ -64,7 +64,7 @@
|
|
64 |
this.validate_postal_field();
|
65 |
}
|
66 |
}
|
67 |
-
$(document.body).on('change', '#billing_postcode', function(e) {
|
68 |
var val = $('#billing_postcode').val();
|
69 |
$('#stripe-postal-code').val(val).trigger('keyup');
|
70 |
}.bind(this));
|
@@ -77,12 +77,12 @@
|
|
77 |
style: this.params.style,
|
78 |
iconStyle: 'default'
|
79 |
});
|
80 |
-
$(document.body).on('change', '#billing_postcode', function(e) {
|
81 |
if (this.card) {
|
82 |
-
this.card.update({
|
83 |
}
|
84 |
}.bind(this));
|
85 |
-
this.card.addEventListener('change', function(event) {
|
86 |
|
87 |
}.bind(this))
|
88 |
}
|
@@ -90,7 +90,7 @@
|
|
90 |
setInterval(this.create_card_element.bind(this), 2000);
|
91 |
}
|
92 |
|
93 |
-
CC.prototype.validate_postal_field = function() {
|
94 |
if ($('#billing_postcode').length && $('#stripe-postal-code').length) {
|
95 |
// validate postal code
|
96 |
if (this.params.postal_regex[$('#billing_country').val()]) {
|
@@ -121,9 +121,9 @@
|
|
121 |
}
|
122 |
|
123 |
/**
|
124 |
-
*
|
125 |
*/
|
126 |
-
CC.prototype.create_card_element = function() {
|
127 |
if (this.is_custom_form()) {
|
128 |
if ($('#wc-stripe-cc-custom-form').length && $('#wc-stripe-cc-custom-form').find('iframe').length == 0) {
|
129 |
if ($('#stripe-card-number').length) {
|
@@ -137,13 +137,13 @@
|
|
137 |
this.cardCvc.mount('#stripe-cvv');
|
138 |
}
|
139 |
if ($('#stripe-postal-code').length) {
|
140 |
-
$('#stripe-postal-code, .postalCode').on('focus', function(e) {
|
141 |
$('#stripe-postal-code').addClass('focused');
|
142 |
}.bind(this));
|
143 |
-
$('#stripe-postal-code, .postalCode').on('blur', function(e) {
|
144 |
$('#stripe-postal-code').removeClass('focused').trigger('keyup');
|
145 |
}.bind(this));
|
146 |
-
$('#stripe-postal-code').on('keyup', function(e) {
|
147 |
if ($('#stripe-postal-code').val() == 0) {
|
148 |
$('#stripe-postal-code').addClass('empty');
|
149 |
} else {
|
@@ -174,18 +174,18 @@
|
|
174 |
}
|
175 |
|
176 |
/**
|
177 |
-
*
|
178 |
*/
|
179 |
-
CC.prototype.hashChange = function(e) {
|
180 |
if (this.is_gateway_selected()) {
|
181 |
var match = e.newURL.match(/response=(.*)/);
|
182 |
if (match) {
|
183 |
var obj = JSON.parse(window.atob(match[1]));
|
184 |
-
this.stripe.handleCardAction(obj.client_secret).then(function(result) {
|
185 |
if (result.error) {
|
186 |
this.payment_token_received = false;
|
187 |
this.submit_error(result.error);
|
188 |
-
this.sync_payment_intent(obj.order_id, obj.client_secret).catch(function(response) {
|
189 |
this.submit_error(response.message);
|
190 |
}.bind(this));
|
191 |
return;
|
@@ -193,7 +193,7 @@
|
|
193 |
var $form = $(this.token_selector).closest('form');
|
194 |
$form.unblock().removeClass('processing');
|
195 |
$form.submit();
|
196 |
-
}.bind(this)).catch(function(error) {
|
197 |
this.submit_error(error.message);
|
198 |
}.bind(this))
|
199 |
return false;
|
@@ -204,18 +204,18 @@
|
|
204 |
}
|
205 |
|
206 |
/**
|
207 |
-
*
|
208 |
*/
|
209 |
-
CC.prototype.place_order = function(e) {
|
210 |
if (this.is_gateway_selected()) {
|
211 |
-
if (this.
|
212 |
e.preventDefault();
|
213 |
this.stripe.confirmCardSetup(this.client_secret, {
|
214 |
payment_method: {
|
215 |
card: this.is_custom_form() ? this.cardNumber : this.card,
|
216 |
-
billing_details: $.extend({}, this.is_custom_form() ? {
|
217 |
}
|
218 |
-
}).then(function(result) {
|
219 |
if (result.error) {
|
220 |
this.submit_error(result.error);
|
221 |
return;
|
@@ -229,7 +229,7 @@
|
|
229 |
type: 'card',
|
230 |
card: this.is_custom_form() ? this.cardNumber : this.card,
|
231 |
billing_details: this.get_billing_details()
|
232 |
-
}).then(function(result) {
|
233 |
if (result.error) {
|
234 |
this.submit_error(result.error);
|
235 |
return;
|
@@ -241,93 +241,102 @@
|
|
241 |
}
|
242 |
}
|
243 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
244 |
/**
|
245 |
* [sync_payment_intent description]
|
246 |
* @param {[type]} order_id [description]
|
247 |
* @param {[type]} client_secret [description]
|
248 |
* @return {[type]} [description]
|
249 |
*/
|
250 |
-
CC.prototype.sync_payment_intent = function(order_id, client_secret) {
|
251 |
-
return new Promise(function(resolve, reject) {
|
252 |
// call intent api
|
253 |
$.when($.ajax({
|
254 |
method: 'POST',
|
255 |
dataType: 'json',
|
256 |
url: this.params.routes.sync_intent,
|
257 |
-
data: {
|
258 |
-
beforeSend:
|
259 |
-
|
260 |
-
}.bind(this)
|
261 |
-
})).done(function(response) {
|
262 |
if (response.code) {
|
263 |
reject(response);
|
264 |
} else {
|
265 |
resolve(response);
|
266 |
}
|
267 |
-
}).fail(function(xhr, textStatus, errorThrown) {
|
268 |
this.submit_error(errorThrown);
|
269 |
}.bind(this));
|
270 |
}.bind(this))
|
271 |
}
|
272 |
|
273 |
/**
|
274 |
-
*
|
275 |
*/
|
276 |
-
CC.prototype.create_setup_intent = function() {
|
277 |
-
return new Promise(function(resolve, reject) {
|
278 |
// call intent api
|
279 |
$.when($.ajax({
|
280 |
method: 'GET',
|
281 |
dataType: 'json',
|
282 |
url: this.params.routes.setup_intent,
|
283 |
-
beforeSend:
|
284 |
-
|
285 |
-
}.bind(this)
|
286 |
-
})).done(function(response) {
|
287 |
if (response.code) {
|
288 |
reject(response);
|
289 |
} else {
|
290 |
resolve(response);
|
291 |
}
|
292 |
-
}).fail(function(xhr, textStatus, errorThrown) {
|
293 |
this.submit_error(errorThrown);
|
294 |
}.bind(this));
|
295 |
}.bind(this))
|
296 |
}
|
297 |
|
298 |
/**
|
299 |
-
*
|
300 |
*/
|
301 |
-
CC.prototype.on_token_received = function(paymentMethod) {
|
302 |
this.payment_token_received = true;
|
303 |
-
|
304 |
-
|
305 |
}
|
306 |
|
307 |
/**
|
308 |
-
*
|
309 |
*/
|
310 |
-
CC.prototype.on_setup_intent_received = function(payment_method) {
|
311 |
this.payment_token_received = true;
|
312 |
-
|
313 |
-
|
314 |
}
|
315 |
|
316 |
/**
|
317 |
-
*
|
318 |
*/
|
319 |
-
CC.prototype.updated_checkout = function() {
|
320 |
this.create_card_element();
|
321 |
}
|
322 |
|
323 |
/**
|
324 |
-
*
|
325 |
*/
|
326 |
-
CC.prototype.update_checkout = function() {
|
327 |
this.clear_card_elements();
|
328 |
}
|
329 |
|
330 |
-
CC.prototype.show_payment_button = function() {
|
331 |
wc_stripe.CheckoutGateway.prototype.show_place_order.apply(this, arguments);
|
332 |
}
|
333 |
|
@@ -335,7 +344,7 @@
|
|
335 |
* [Leave empty so that the place order button is not hidden]
|
336 |
* @return {[type]} [description]
|
337 |
*/
|
338 |
-
CC.prototype.hide_place_order = function() {
|
339 |
|
340 |
}
|
341 |
|
@@ -343,11 +352,11 @@
|
|
343 |
* Returns true if a custom form is being used.
|
344 |
* @return {Boolean} [description]
|
345 |
*/
|
346 |
-
CC.prototype.is_custom_form = function() {
|
347 |
return this.params.custom_form === "1";
|
348 |
}
|
349 |
|
350 |
-
CC.prototype.get_element_options = function() {
|
351 |
return this.params.elementOptions;
|
352 |
}
|
353 |
|
@@ -355,7 +364,7 @@
|
|
355 |
* [get_postal_code description]
|
356 |
* @return {[type]} [description]
|
357 |
*/
|
358 |
-
CC.prototype.get_postal_code = function() {
|
359 |
if (this.is_custom_form()) {
|
360 |
if ($('#stripe-postal-code').length > 0) {
|
361 |
return $('#stripe-postal-code').val();
|
@@ -365,7 +374,7 @@
|
|
365 |
return $('#billing_postcode').val();
|
366 |
}
|
367 |
|
368 |
-
CC.prototype.card_number_change = function(data) {
|
369 |
if (data.brand === "unkown") {
|
370 |
$('#wc-stripe-card').removeClass('active');
|
371 |
} else {
|
@@ -374,7 +383,7 @@
|
|
374 |
$('#wc-stripe-card').attr('src', this.params.cards[data.brand]);
|
375 |
}
|
376 |
|
377 |
-
CC.prototype.clear_card_elements = function() {
|
378 |
var elements = ['cardNumber', 'cardExpiry', 'cardCvc'];
|
379 |
for (var i = 0; i < elements.length; i++) {
|
380 |
if (this[elements[i]]) {
|
@@ -383,16 +392,16 @@
|
|
383 |
}
|
384 |
}
|
385 |
|
386 |
-
CC.prototype.checkout_error = function() {
|
387 |
if (this.is_gateway_selected()) {
|
388 |
this.payment_token_received = false;
|
389 |
}
|
390 |
wc_stripe.CheckoutGateway.prototype.checkout_error.call(this);
|
391 |
}
|
392 |
|
393 |
-
CC.prototype.get_billing_details = function() {
|
394 |
var details = {
|
395 |
-
name:
|
396 |
address: {
|
397 |
city: $('#billing_city').val(),
|
398 |
country: $('#billing_country').val(),
|
@@ -411,6 +420,10 @@
|
|
411 |
return details;
|
412 |
}
|
413 |
|
|
|
|
|
|
|
|
|
414 |
new CC();
|
415 |
|
416 |
}(jQuery, window.wc_stripe))
|
1 |
+
(function ($, wc_stripe) {
|
2 |
|
3 |
/**
|
4 |
* Credit card class.
|
5 |
+
*
|
6 |
* @constructor
|
7 |
*/
|
8 |
function CC() {
|
21 |
CC.prototype = $.extend({}, wc_stripe.BaseGateway.prototype, wc_stripe.CheckoutGateway.prototype);
|
22 |
|
23 |
/**
|
24 |
+
*
|
25 |
*/
|
26 |
+
CC.prototype.initialize = function () {
|
27 |
$(document.body).on('click', '#place_order', this.place_order.bind(this));
|
28 |
this.setup_card();
|
29 |
this.create_card_element();
|
30 |
|
31 |
+
if (this.can_create_setup_intent()) {
|
32 |
+
this.create_setup_intent().then(function (response) {
|
33 |
if (response.code) {
|
34 |
this.submit_error(response.message);
|
35 |
} else {
|
40 |
}
|
41 |
|
42 |
/**
|
43 |
+
*
|
44 |
*/
|
45 |
+
CC.prototype.setup_card = function () {
|
46 |
if (this.is_custom_form()) {
|
47 |
// create individual card sections
|
48 |
this.cardNumber = this.elements.create('cardNumber', {
|
64 |
this.validate_postal_field();
|
65 |
}
|
66 |
}
|
67 |
+
$(document.body).on('change', '#billing_postcode', function (e) {
|
68 |
var val = $('#billing_postcode').val();
|
69 |
$('#stripe-postal-code').val(val).trigger('keyup');
|
70 |
}.bind(this));
|
77 |
style: this.params.style,
|
78 |
iconStyle: 'default'
|
79 |
});
|
80 |
+
$(document.body).on('change', '#billing_postcode', function (e) {
|
81 |
if (this.card) {
|
82 |
+
this.card.update({value: $('#billing_postcode').val()});
|
83 |
}
|
84 |
}.bind(this));
|
85 |
+
this.card.addEventListener('change', function (event) {
|
86 |
|
87 |
}.bind(this))
|
88 |
}
|
90 |
setInterval(this.create_card_element.bind(this), 2000);
|
91 |
}
|
92 |
|
93 |
+
CC.prototype.validate_postal_field = function () {
|
94 |
if ($('#billing_postcode').length && $('#stripe-postal-code').length) {
|
95 |
// validate postal code
|
96 |
if (this.params.postal_regex[$('#billing_country').val()]) {
|
121 |
}
|
122 |
|
123 |
/**
|
124 |
+
*
|
125 |
*/
|
126 |
+
CC.prototype.create_card_element = function () {
|
127 |
if (this.is_custom_form()) {
|
128 |
if ($('#wc-stripe-cc-custom-form').length && $('#wc-stripe-cc-custom-form').find('iframe').length == 0) {
|
129 |
if ($('#stripe-card-number').length) {
|
137 |
this.cardCvc.mount('#stripe-cvv');
|
138 |
}
|
139 |
if ($('#stripe-postal-code').length) {
|
140 |
+
$('#stripe-postal-code, .postalCode').on('focus', function (e) {
|
141 |
$('#stripe-postal-code').addClass('focused');
|
142 |
}.bind(this));
|
143 |
+
$('#stripe-postal-code, .postalCode').on('blur', function (e) {
|
144 |
$('#stripe-postal-code').removeClass('focused').trigger('keyup');
|
145 |
}.bind(this));
|
146 |
+
$('#stripe-postal-code').on('keyup', function (e) {
|
147 |
if ($('#stripe-postal-code').val() == 0) {
|
148 |
$('#stripe-postal-code').addClass('empty');
|
149 |
} else {
|
174 |
}
|
175 |
|
176 |
/**
|
177 |
+
*
|
178 |
*/
|
179 |
+
CC.prototype.hashChange = function (e) {
|
180 |
if (this.is_gateway_selected()) {
|
181 |
var match = e.newURL.match(/response=(.*)/);
|
182 |
if (match) {
|
183 |
var obj = JSON.parse(window.atob(match[1]));
|
184 |
+
this.stripe.handleCardAction(obj.client_secret).then(function (result) {
|
185 |
if (result.error) {
|
186 |
this.payment_token_received = false;
|
187 |
this.submit_error(result.error);
|
188 |
+
this.sync_payment_intent(obj.order_id, obj.client_secret).catch(function (response) {
|
189 |
this.submit_error(response.message);
|
190 |
}.bind(this));
|
191 |
return;
|
193 |
var $form = $(this.token_selector).closest('form');
|
194 |
$form.unblock().removeClass('processing');
|
195 |
$form.submit();
|
196 |
+
}.bind(this)).catch(function (error) {
|
197 |
this.submit_error(error.message);
|
198 |
}.bind(this))
|
199 |
return false;
|
204 |
}
|
205 |
|
206 |
/**
|
207 |
+
*
|
208 |
*/
|
209 |
+
CC.prototype.place_order = function (e) {
|
210 |
if (this.is_gateway_selected()) {
|
211 |
+
if (this.can_create_setup_intent() && !this.is_saved_method_selected()) {
|
212 |
e.preventDefault();
|
213 |
this.stripe.confirmCardSetup(this.client_secret, {
|
214 |
payment_method: {
|
215 |
card: this.is_custom_form() ? this.cardNumber : this.card,
|
216 |
+
billing_details: $.extend({}, this.is_custom_form() ? {address: {postal_code: $('#stripe-postal-code').val()}} : {})
|
217 |
}
|
218 |
+
}).then(function (result) {
|
219 |
if (result.error) {
|
220 |
this.submit_error(result.error);
|
221 |
return;
|
229 |
type: 'card',
|
230 |
card: this.is_custom_form() ? this.cardNumber : this.card,
|
231 |
billing_details: this.get_billing_details()
|
232 |
+
}).then(function (result) {
|
233 |
if (result.error) {
|
234 |
this.submit_error(result.error);
|
235 |
return;
|
241 |
}
|
242 |
}
|
243 |
|
244 |
+
/**
|
245 |
+
* @since 3.1.8 - added to ensure 3rd party plugin's can't stop the tokenization process
|
246 |
+
* if e.preventDefault is called on place_order
|
247 |
+
* @returns {boolean}
|
248 |
+
*/
|
249 |
+
CC.prototype.checkout_place_order = function () {
|
250 |
+
if (!this.is_saved_method_selected() && !this.payment_token_received) {
|
251 |
+
this.place_order.apply(this, arguments);
|
252 |
+
return false;
|
253 |
+
}
|
254 |
+
return wc_stripe.CheckoutGateway.prototype.checkout_place_order.apply(this, arguments);
|
255 |
+
}
|
256 |
+
|
257 |
/**
|
258 |
* [sync_payment_intent description]
|
259 |
* @param {[type]} order_id [description]
|
260 |
* @param {[type]} client_secret [description]
|
261 |
* @return {[type]} [description]
|
262 |
*/
|
263 |
+
CC.prototype.sync_payment_intent = function (order_id, client_secret) {
|
264 |
+
return new Promise(function (resolve, reject) {
|
265 |
// call intent api
|
266 |
$.when($.ajax({
|
267 |
method: 'POST',
|
268 |
dataType: 'json',
|
269 |
url: this.params.routes.sync_intent,
|
270 |
+
data: {order_id: order_id, client_secret: client_secret},
|
271 |
+
beforeSend: this.ajax_before_send.bind(this)
|
272 |
+
})).done(function (response) {
|
|
|
|
|
273 |
if (response.code) {
|
274 |
reject(response);
|
275 |
} else {
|
276 |
resolve(response);
|
277 |
}
|
278 |
+
}).fail(function (xhr, textStatus, errorThrown) {
|
279 |
this.submit_error(errorThrown);
|
280 |
}.bind(this));
|
281 |
}.bind(this))
|
282 |
}
|
283 |
|
284 |
/**
|
285 |
+
*
|
286 |
*/
|
287 |
+
CC.prototype.create_setup_intent = function () {
|
288 |
+
return new Promise(function (resolve, reject) {
|
289 |
// call intent api
|
290 |
$.when($.ajax({
|
291 |
method: 'GET',
|
292 |
dataType: 'json',
|
293 |
url: this.params.routes.setup_intent,
|
294 |
+
beforeSend: this.ajax_before_send.bind(this)
|
295 |
+
})).done(function (response) {
|
|
|
|
|
296 |
if (response.code) {
|
297 |
reject(response);
|
298 |
} else {
|
299 |
resolve(response);
|
300 |
}
|
301 |
+
}).fail(function (xhr, textStatus, errorThrown) {
|
302 |
this.submit_error(errorThrown);
|
303 |
}.bind(this));
|
304 |
}.bind(this))
|
305 |
}
|
306 |
|
307 |
/**
|
308 |
+
*
|
309 |
*/
|
310 |
+
CC.prototype.on_token_received = function (paymentMethod) {
|
311 |
this.payment_token_received = true;
|
312 |
+
this.set_nonce(paymentMethod.id);
|
313 |
+
this.get_form().submit();
|
314 |
}
|
315 |
|
316 |
/**
|
317 |
+
*
|
318 |
*/
|
319 |
+
CC.prototype.on_setup_intent_received = function (payment_method) {
|
320 |
this.payment_token_received = true;
|
321 |
+
this.set_nonce(payment_method);
|
322 |
+
this.get_form().submit();
|
323 |
}
|
324 |
|
325 |
/**
|
326 |
+
*
|
327 |
*/
|
328 |
+
CC.prototype.updated_checkout = function () {
|
329 |
this.create_card_element();
|
330 |
}
|
331 |
|
332 |
/**
|
333 |
+
*
|
334 |
*/
|
335 |
+
CC.prototype.update_checkout = function () {
|
336 |
this.clear_card_elements();
|
337 |
}
|
338 |
|
339 |
+
CC.prototype.show_payment_button = function () {
|
340 |
wc_stripe.CheckoutGateway.prototype.show_place_order.apply(this, arguments);
|
341 |
}
|
342 |
|
344 |
* [Leave empty so that the place order button is not hidden]
|
345 |
* @return {[type]} [description]
|
346 |
*/
|
347 |
+
CC.prototype.hide_place_order = function () {
|
348 |
|
349 |
}
|
350 |
|
352 |
* Returns true if a custom form is being used.
|
353 |
* @return {Boolean} [description]
|
354 |
*/
|
355 |
+
CC.prototype.is_custom_form = function () {
|
356 |
return this.params.custom_form === "1";
|
357 |
}
|
358 |
|
359 |
+
CC.prototype.get_element_options = function () {
|
360 |
return this.params.elementOptions;
|
361 |
}
|
362 |
|
364 |
* [get_postal_code description]
|
365 |
* @return {[type]} [description]
|
366 |
*/
|
367 |
+
CC.prototype.get_postal_code = function () {
|
368 |
if (this.is_custom_form()) {
|
369 |
if ($('#stripe-postal-code').length > 0) {
|
370 |
return $('#stripe-postal-code').val();
|
374 |
return $('#billing_postcode').val();
|
375 |
}
|
376 |
|
377 |
+
CC.prototype.card_number_change = function (data) {
|
378 |
if (data.brand === "unkown") {
|
379 |
$('#wc-stripe-card').removeClass('active');
|
380 |
} else {
|
383 |
$('#wc-stripe-card').attr('src', this.params.cards[data.brand]);
|
384 |
}
|
385 |
|
386 |
+
CC.prototype.clear_card_elements = function () {
|
387 |
var elements = ['cardNumber', 'cardExpiry', 'cardCvc'];
|
388 |
for (var i = 0; i < elements.length; i++) {
|
389 |
if (this[elements[i]]) {
|
392 |
}
|
393 |
}
|
394 |
|
395 |
+
CC.prototype.checkout_error = function () {
|
396 |
if (this.is_gateway_selected()) {
|
397 |
this.payment_token_received = false;
|
398 |
}
|
399 |
wc_stripe.CheckoutGateway.prototype.checkout_error.call(this);
|
400 |
}
|
401 |
|
402 |
+
CC.prototype.get_billing_details = function () {
|
403 |
var details = {
|
404 |
+
name: this.get_customer_name('#billing'),
|
405 |
address: {
|
406 |
city: $('#billing_city').val(),
|
407 |
country: $('#billing_country').val(),
|
420 |
return details;
|
421 |
}
|
422 |
|
423 |
+
CC.prototype.can_create_setup_intent = function () {
|
424 |
+
return this.is_add_payment_method_page() || this.is_change_payment_method();
|
425 |
+
}
|
426 |
+
|
427 |
new CC();
|
428 |
|
429 |
}(jQuery, window.wc_stripe))
|
assets/js/frontend/googlepay-product.js
CHANGED
@@ -51,8 +51,6 @@
|
|
51 |
GPay.prototype.start = function() {
|
52 |
if (this.get_quantity() > 0) {
|
53 |
this.add_to_cart().then(function(data) {
|
54 |
-
// update the line items
|
55 |
-
this.set_googlepay_display_items(data.googlepay.displayItems);
|
56 |
wc_stripe.GooglePay.prototype.start.apply(this, arguments);
|
57 |
}.bind(this))
|
58 |
} else {
|
51 |
GPay.prototype.start = function() {
|
52 |
if (this.get_quantity() > 0) {
|
53 |
this.add_to_cart().then(function(data) {
|
|
|
|
|
54 |
wc_stripe.GooglePay.prototype.start.apply(this, arguments);
|
55 |
}.bind(this))
|
56 |
} else {
|
assets/js/frontend/local-payment.js
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
-
(function($, wc_stripe) {
|
2 |
|
3 |
var place_order_width = $('#place_order').css('width');
|
4 |
|
5 |
// this will ensure the place order's width does not change when the
|
6 |
// text for the local payment method is added
|
7 |
-
$(document.body).on('updated_checkout', function() {
|
8 |
$('#place_order').css('min-width', place_order_width)
|
9 |
})
|
10 |
|
@@ -27,13 +27,13 @@
|
|
27 |
LocalPayment.prototype = $.extend({}, wc_stripe.BaseGateway.prototype, wc_stripe.CheckoutGateway.prototype);
|
28 |
|
29 |
|
30 |
-
LocalPayment.prototype.initialize = function() {
|
31 |
this.mount_button();
|
32 |
}
|
33 |
|
34 |
LocalPayment.prototype.elementType = null;
|
35 |
|
36 |
-
LocalPayment.prototype.maybe_hide_gateway = function() {
|
37 |
if (!$('#wc_stripe_local_payment_' + this.gateway_id).data('active')) {
|
38 |
$(this.container).hide();
|
39 |
} else {
|
@@ -45,9 +45,9 @@
|
|
45 |
* [createSource description]
|
46 |
* @return {[type]} [description]
|
47 |
*/
|
48 |
-
LocalPayment.prototype.createSource = function() {
|
49 |
-
return new Promise(function(resolve, reject) {
|
50 |
-
var handler = function(result) {
|
51 |
if (result.error) {
|
52 |
this.submit_error(result.error.message);
|
53 |
} else {
|
@@ -63,10 +63,13 @@
|
|
63 |
this.payment_token_received = true;
|
64 |
this.get_form().submit();
|
65 |
} else {
|
66 |
-
return this.submit_error({
|
|
|
|
|
|
|
67 |
}
|
68 |
} else {
|
69 |
-
this.stripe.createSource(this.element, this.getSourceArgs()).then(handler).catch(function(e) {
|
70 |
this.submit_error(e.message);
|
71 |
}.bind(this))
|
72 |
}
|
@@ -77,7 +80,7 @@
|
|
77 |
}.bind(this));
|
78 |
}
|
79 |
|
80 |
-
LocalPayment.prototype.place_order = function(e) {
|
81 |
if (this.is_gateway_selected()) {
|
82 |
if (!this.payment_token_received) {
|
83 |
e.preventDefault();
|
@@ -86,30 +89,30 @@
|
|
86 |
}
|
87 |
}
|
88 |
|
89 |
-
LocalPayment.prototype.process_order_pay = function(e) {
|
90 |
if (this.is_gateway_selected()) {
|
91 |
e.preventDefault();
|
92 |
var data = this.get_form().serializeArray();
|
93 |
-
data.push({
|
94 |
-
data.push({
|
95 |
$.ajax({
|
96 |
url: this.params.routes.order_pay + window.location.search,
|
97 |
method: 'POST',
|
98 |
dataType: 'json',
|
99 |
data: $.param(data)
|
100 |
-
}).done(function(response) {
|
101 |
if (response.success) {
|
102 |
window.location.href = response.redirect;
|
103 |
} else {
|
104 |
this.submit_error(response.message);
|
105 |
}
|
106 |
-
}.bind(this)).fail(function(jqXHR, textStatus, errorThrown) {
|
107 |
this.submit_error(errorThrown);
|
108 |
}.bind(this))
|
109 |
}
|
110 |
}
|
111 |
|
112 |
-
LocalPayment.prototype.show_payment_button = function() {
|
113 |
this.show_place_order();
|
114 |
}
|
115 |
|
@@ -117,18 +120,18 @@
|
|
117 |
* [Leave empty so that the place order button is not hidden]
|
118 |
* @return {[type]} [description]
|
119 |
*/
|
120 |
-
LocalPayment.prototype.hide_place_order = function() {
|
121 |
|
122 |
}
|
123 |
|
124 |
-
LocalPayment.prototype.show_place_order = function() {
|
125 |
wc_stripe.CheckoutGateway.prototype.show_place_order.apply(this, arguments);
|
126 |
if (this.payment_token_received) {
|
127 |
$('#place_order').text($('#place_order').data('value'));
|
128 |
}
|
129 |
}
|
130 |
|
131 |
-
LocalPayment.prototype.getSourceArgs = function() {
|
132 |
return {
|
133 |
type: this.params.local_payment_type,
|
134 |
amount: this.get_total_price_cents(),
|
@@ -143,12 +146,12 @@
|
|
143 |
}
|
144 |
}
|
145 |
|
146 |
-
LocalPayment.prototype.updated_checkout = function() {
|
147 |
this.mount_button()
|
148 |
this.maybe_hide_gateway();
|
149 |
}
|
150 |
|
151 |
-
LocalPayment.prototype.mount_button = function() {
|
152 |
var id = '#wc_stripe_local_payment_' + this.gateway_id;
|
153 |
if ($(id).length && this.elementType != null) {
|
154 |
$(id).empty();
|
@@ -162,21 +165,21 @@
|
|
162 |
|
163 |
}
|
164 |
|
165 |
-
LocalPayment.prototype.handleElementChange = function(e) {
|
166 |
this.elementEmpty = e.empty;
|
167 |
}
|
168 |
|
169 |
-
LocalPayment.prototype.load_external_script = function(url) {
|
170 |
var script = document.createElement('script');
|
171 |
script.type = "text/javascript";
|
172 |
script.src = url;
|
173 |
-
script.onload = function() {
|
174 |
this.script_loaded = true;
|
175 |
}.bind(this);
|
176 |
document.body.appendChild(script);
|
177 |
}
|
178 |
|
179 |
-
LocalPayment.prototype.hashChange = function(e) {
|
180 |
if (this.is_gateway_selected()) {
|
181 |
var match = e.newURL.match(/response=(.*)/);
|
182 |
if (match) {
|
@@ -186,8 +189,8 @@
|
|
186 |
}
|
187 |
}
|
188 |
|
189 |
-
LocalPayment.prototype.processConfirmation = function(obj) {
|
190 |
-
this.stripe[this.confirmation_method](obj.client_secret, this.get_confirmation_args(obj)).then(function(result) {
|
191 |
if (result.error) {
|
192 |
return this.submit_error(result.error.message);
|
193 |
}
|
@@ -195,7 +198,7 @@
|
|
195 |
}.bind(this))
|
196 |
}
|
197 |
|
198 |
-
LocalPayment.prototype.get_confirmation_args = function(obj) {
|
199 |
var args = {
|
200 |
payment_method: {
|
201 |
billing_details: {
|
@@ -203,30 +206,30 @@
|
|
203 |
}
|
204 |
},
|
205 |
return_url: obj.return_url
|
|
|
|
|
|
|
206 |
}
|
207 |
-
args['payment_method'][this.params.local_payment_type] = this.element;
|
208 |
return args;
|
209 |
}
|
210 |
|
211 |
-
LocalPayment.prototype.isValidElement = function() {
|
212 |
if (this.element) {
|
213 |
return !this.elementEmpty;
|
214 |
}
|
215 |
return true;
|
216 |
}
|
217 |
|
218 |
-
LocalPayment.prototype.delete_order_source = function() {
|
219 |
-
return new Promise(function(resolve, reject) {
|
220 |
$.ajax({
|
221 |
url: this.params.routes.delete_source,
|
222 |
method: 'DELETE',
|
223 |
dataType: 'json',
|
224 |
-
beforeSend:
|
225 |
-
|
226 |
-
}.bind(this)
|
227 |
-
}).done(function(response) {
|
228 |
resolve(response);
|
229 |
-
}.bind(this)).fail(function() {
|
230 |
reject(response);
|
231 |
}.bind(this))
|
232 |
}.bind(this))
|
@@ -272,7 +275,13 @@
|
|
272 |
window.addEventListener('hashchange', this.hashChange.bind(this));
|
273 |
}
|
274 |
|
275 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
276 |
var $el = $(e.currentTarget);
|
277 |
if ($el.is(':checked')) {
|
278 |
$('[id^="klarna-instance-"]').slideUp();
|
@@ -281,14 +290,14 @@
|
|
281 |
}
|
282 |
}
|
283 |
|
284 |
-
Klarna.prototype.processConfirmation = function(source) {
|
285 |
var $form = $(this.token_selector).closest('form');
|
286 |
$form.unblock().removeClass('processing');
|
287 |
// get the source
|
288 |
this.source = source;
|
289 |
window.Klarna.Payments.init({
|
290 |
client_token: source.klarna.client_token
|
291 |
-
}, function(response) {
|
292 |
|
293 |
}.bind(this));
|
294 |
this.payment_categories = source.klarna.payment_method_categories.split(",");
|
@@ -296,7 +305,7 @@
|
|
296 |
this.show_place_order();
|
297 |
}
|
298 |
|
299 |
-
Klarna.prototype.render_ui = function(trigger_change) {
|
300 |
this.show_form_false = 0;
|
301 |
if (this.payment_categories.length > 0) {
|
302 |
$('#wc_stripe_local_payment_stripe_klarna').show();
|
@@ -309,7 +318,7 @@
|
|
309 |
container: container,
|
310 |
payment_method_category: this.payment_categories[i], //source.klarna.payment_method_categories
|
311 |
instance_id: 'klarna-instance-' + this.payment_categories[i]
|
312 |
-
}, function(response) {
|
313 |
if (!response.show_form) {
|
314 |
this.show_form_false++;
|
315 |
if (this.show_form_false == this.payment_categories.length) {
|
@@ -329,14 +338,14 @@
|
|
329 |
}
|
330 |
}
|
331 |
|
332 |
-
Klarna.prototype.place_order = function(e) {
|
333 |
if (this.is_gateway_selected()) {
|
334 |
e.preventDefault();
|
335 |
this.payment_token_received = true;
|
336 |
if (this.payment_categories) {
|
337 |
window.Klarna.Payments.authorize({
|
338 |
instance_id: 'klarna-instance-' + $('[name="klarna_category"]:checked').val()
|
339 |
-
}, function(res) {
|
340 |
if (res.approved) {
|
341 |
this.block();
|
342 |
this.payment_token_received = true;
|
@@ -357,29 +366,29 @@
|
|
357 |
}
|
358 |
}
|
359 |
|
360 |
-
Klarna.prototype.initialize = function() {
|
361 |
|
362 |
}
|
363 |
|
364 |
-
Klarna.prototype.createSource = function() {
|
365 |
this.block();
|
366 |
}
|
367 |
|
368 |
-
Klarna.prototype.updated_checkout = function() {
|
369 |
if (this.payment_categories) {
|
370 |
this.render_ui(false);
|
371 |
}
|
372 |
LocalPayment.prototype.updated_checkout.apply(this, arguments);
|
373 |
}
|
374 |
|
375 |
-
WeChat.prototype.updated_checkout = function() {
|
376 |
if (!this.script_loaded && $(this.container).length) {
|
377 |
this.load_external_script(this.params.qr_script);
|
378 |
}
|
379 |
LocalPayment.prototype.updated_checkout.apply(this, arguments);
|
380 |
}
|
381 |
|
382 |
-
WeChat.prototype.hashChange = function(e) {
|
383 |
if (this.is_gateway_selected()) {
|
384 |
var match = e.newURL.match(/qrcode=(.*)/);
|
385 |
if (match) {
|
@@ -400,7 +409,7 @@
|
|
400 |
}
|
401 |
}
|
402 |
|
403 |
-
WeChat.prototype.place_order = function() {
|
404 |
if (this.get_form().is('.wechat')) {
|
405 |
window.location = this.qrcode.redirect;
|
406 |
} else {
|
@@ -408,7 +417,7 @@
|
|
408 |
}
|
409 |
}
|
410 |
|
411 |
-
BECS.prototype.get_confirmation_args = function(obj) {
|
412 |
var args = LocalPayment.prototype.get_confirmation_args.apply(this, arguments);
|
413 |
args.payment_method.billing_details.email = $('#billing_email').val();
|
414 |
return args;
|
1 |
+
(function ($, wc_stripe) {
|
2 |
|
3 |
var place_order_width = $('#place_order').css('width');
|
4 |
|
5 |
// this will ensure the place order's width does not change when the
|
6 |
// text for the local payment method is added
|
7 |
+
$(document.body).on('updated_checkout', function () {
|
8 |
$('#place_order').css('min-width', place_order_width)
|
9 |
})
|
10 |
|
27 |
LocalPayment.prototype = $.extend({}, wc_stripe.BaseGateway.prototype, wc_stripe.CheckoutGateway.prototype);
|
28 |
|
29 |
|
30 |
+
LocalPayment.prototype.initialize = function () {
|
31 |
this.mount_button();
|
32 |
}
|
33 |
|
34 |
LocalPayment.prototype.elementType = null;
|
35 |
|
36 |
+
LocalPayment.prototype.maybe_hide_gateway = function () {
|
37 |
if (!$('#wc_stripe_local_payment_' + this.gateway_id).data('active')) {
|
38 |
$(this.container).hide();
|
39 |
} else {
|
45 |
* [createSource description]
|
46 |
* @return {[type]} [description]
|
47 |
*/
|
48 |
+
LocalPayment.prototype.createSource = function () {
|
49 |
+
return new Promise(function (resolve, reject) {
|
50 |
+
var handler = function (result) {
|
51 |
if (result.error) {
|
52 |
this.submit_error(result.error.message);
|
53 |
} else {
|
63 |
this.payment_token_received = true;
|
64 |
this.get_form().submit();
|
65 |
} else {
|
66 |
+
return this.submit_error({
|
67 |
+
code: 'empty_element_' + this.params.local_payment_type,
|
68 |
+
message: wc_stripe_messages.empty_element
|
69 |
+
});
|
70 |
}
|
71 |
} else {
|
72 |
+
this.stripe.createSource(this.element, this.getSourceArgs()).then(handler).catch(function (e) {
|
73 |
this.submit_error(e.message);
|
74 |
}.bind(this))
|
75 |
}
|
80 |
}.bind(this));
|
81 |
}
|
82 |
|
83 |
+
LocalPayment.prototype.place_order = function (e) {
|
84 |
if (this.is_gateway_selected()) {
|
85 |
if (!this.payment_token_received) {
|
86 |
e.preventDefault();
|
89 |
}
|
90 |
}
|
91 |
|
92 |
+
LocalPayment.prototype.process_order_pay = function (e) {
|
93 |
if (this.is_gateway_selected()) {
|
94 |
e.preventDefault();
|
95 |
var data = this.get_form().serializeArray();
|
96 |
+
data.push({name: '_wpnonce', value: this.params.rest_nonce});
|
97 |
+
data.push({name: 'order_id', value: this.params.order_id});
|
98 |
$.ajax({
|
99 |
url: this.params.routes.order_pay + window.location.search,
|
100 |
method: 'POST',
|
101 |
dataType: 'json',
|
102 |
data: $.param(data)
|
103 |
+
}).done(function (response) {
|
104 |
if (response.success) {
|
105 |
window.location.href = response.redirect;
|
106 |
} else {
|
107 |
this.submit_error(response.message);
|
108 |
}
|
109 |
+
}.bind(this)).fail(function (jqXHR, textStatus, errorThrown) {
|
110 |
this.submit_error(errorThrown);
|
111 |
}.bind(this))
|
112 |
}
|
113 |
}
|
114 |
|
115 |
+
LocalPayment.prototype.show_payment_button = function () {
|
116 |
this.show_place_order();
|
117 |
}
|
118 |
|
120 |
* [Leave empty so that the place order button is not hidden]
|
121 |
* @return {[type]} [description]
|
122 |
*/
|
123 |
+
LocalPayment.prototype.hide_place_order = function () {
|
124 |
|
125 |
}
|
126 |
|
127 |
+
LocalPayment.prototype.show_place_order = function () {
|
128 |
wc_stripe.CheckoutGateway.prototype.show_place_order.apply(this, arguments);
|
129 |
if (this.payment_token_received) {
|
130 |
$('#place_order').text($('#place_order').data('value'));
|
131 |
}
|
132 |
}
|
133 |
|
134 |
+
LocalPayment.prototype.getSourceArgs = function () {
|
135 |
return {
|
136 |
type: this.params.local_payment_type,
|
137 |
amount: this.get_total_price_cents(),
|
146 |
}
|
147 |
}
|
148 |
|
149 |
+
LocalPayment.prototype.updated_checkout = function () {
|
150 |
this.mount_button()
|
151 |
this.maybe_hide_gateway();
|
152 |
}
|
153 |
|
154 |
+
LocalPayment.prototype.mount_button = function () {
|
155 |
var id = '#wc_stripe_local_payment_' + this.gateway_id;
|
156 |
if ($(id).length && this.elementType != null) {
|
157 |
$(id).empty();
|
165 |
|
166 |
}
|
167 |
|
168 |
+
LocalPayment.prototype.handleElementChange = function (e) {
|
169 |
this.elementEmpty = e.empty;
|
170 |
}
|
171 |
|
172 |
+
LocalPayment.prototype.load_external_script = function (url) {
|
173 |
var script = document.createElement('script');
|
174 |
script.type = "text/javascript";
|
175 |
script.src = url;
|
176 |
+
script.onload = function () {
|
177 |
this.script_loaded = true;
|
178 |
}.bind(this);
|
179 |
document.body.appendChild(script);
|
180 |
}
|
181 |
|
182 |
+
LocalPayment.prototype.hashChange = function (e) {
|
183 |
if (this.is_gateway_selected()) {
|
184 |
var match = e.newURL.match(/response=(.*)/);
|
185 |
if (match) {
|
189 |
}
|
190 |
}
|
191 |
|
192 |
+
LocalPayment.prototype.processConfirmation = function (obj) {
|
193 |
+
this.stripe[this.confirmation_method](obj.client_secret, this.get_confirmation_args(obj)).then(function (result) {
|
194 |
if (result.error) {
|
195 |
return this.submit_error(result.error.message);
|
196 |
}
|
198 |
}.bind(this))
|
199 |
}
|
200 |
|
201 |
+
LocalPayment.prototype.get_confirmation_args = function (obj) {
|
202 |
var args = {
|
203 |
payment_method: {
|
204 |
billing_details: {
|
206 |
}
|
207 |
},
|
208 |
return_url: obj.return_url
|
209 |
+
};
|
210 |
+
if (this.elementType) {
|
211 |
+
args.payment_method[this.params.local_payment_type] = this.element;
|
212 |
}
|
|
|
213 |
return args;
|
214 |
}
|
215 |
|
216 |
+
LocalPayment.prototype.isValidElement = function () {
|
217 |
if (this.element) {
|
218 |
return !this.elementEmpty;
|
219 |
}
|
220 |
return true;
|
221 |
}
|
222 |
|
223 |
+
LocalPayment.prototype.delete_order_source = function () {
|
224 |
+
return new Promise(function (resolve, reject) {
|
225 |
$.ajax({
|
226 |
url: this.params.routes.delete_source,
|
227 |
method: 'DELETE',
|
228 |
dataType: 'json',
|
229 |
+
beforeSend: this.ajax_before_send.bind(this)
|
230 |
+
}).done(function (response) {
|
|
|
|
|
231 |
resolve(response);
|
232 |
+
}.bind(this)).fail(function () {
|
233 |
reject(response);
|
234 |
}.bind(this))
|
235 |
}.bind(this))
|
275 |
window.addEventListener('hashchange', this.hashChange.bind(this));
|
276 |
}
|
277 |
|
278 |
+
function GrabPay(params) {
|
279 |
+
this.confirmation_method = 'confirmGrabPayPayment';
|
280 |
+
LocalPayment.call(this, params);
|
281 |
+
window.addEventListener('hashchange', this.hashChange.bind(this));
|
282 |
+
}
|
283 |
+
|
284 |
+
Klarna.prototype.category_change = function (e) {
|
285 |
var $el = $(e.currentTarget);
|
286 |
if ($el.is(':checked')) {
|
287 |
$('[id^="klarna-instance-"]').slideUp();
|
290 |
}
|
291 |
}
|
292 |
|
293 |
+
Klarna.prototype.processConfirmation = function (source) {
|
294 |
var $form = $(this.token_selector).closest('form');
|
295 |
$form.unblock().removeClass('processing');
|
296 |
// get the source
|
297 |
this.source = source;
|
298 |
window.Klarna.Payments.init({
|
299 |
client_token: source.klarna.client_token
|
300 |
+
}, function (response) {
|
301 |
|
302 |
}.bind(this));
|
303 |
this.payment_categories = source.klarna.payment_method_categories.split(",");
|
305 |
this.show_place_order();
|
306 |
}
|
307 |
|
308 |
+
Klarna.prototype.render_ui = function (trigger_change) {
|
309 |
this.show_form_false = 0;
|
310 |
if (this.payment_categories.length > 0) {
|
311 |
$('#wc_stripe_local_payment_stripe_klarna').show();
|
318 |
container: container,
|
319 |
payment_method_category: this.payment_categories[i], //source.klarna.payment_method_categories
|
320 |
instance_id: 'klarna-instance-' + this.payment_categories[i]
|
321 |
+
}, function (response) {
|
322 |
if (!response.show_form) {
|
323 |
this.show_form_false++;
|
324 |
if (this.show_form_false == this.payment_categories.length) {
|
338 |
}
|
339 |
}
|
340 |
|
341 |
+
Klarna.prototype.place_order = function (e) {
|
342 |
if (this.is_gateway_selected()) {
|
343 |
e.preventDefault();
|
344 |
this.payment_token_received = true;
|
345 |
if (this.payment_categories) {
|
346 |
window.Klarna.Payments.authorize({
|
347 |
instance_id: 'klarna-instance-' + $('[name="klarna_category"]:checked').val()
|
348 |
+
}, function (res) {
|
349 |
if (res.approved) {
|
350 |
this.block();
|
351 |
this.payment_token_received = true;
|
366 |
}
|
367 |
}
|
368 |
|
369 |
+
Klarna.prototype.initialize = function () {
|
370 |
|
371 |
}
|
372 |
|
373 |
+
Klarna.prototype.createSource = function () {
|
374 |
this.block();
|
375 |
}
|
376 |
|
377 |
+
Klarna.prototype.updated_checkout = function () {
|
378 |
if (this.payment_categories) {
|
379 |
this.render_ui(false);
|
380 |
}
|
381 |
LocalPayment.prototype.updated_checkout.apply(this, arguments);
|
382 |
}
|
383 |
|
384 |
+
WeChat.prototype.updated_checkout = function () {
|
385 |
if (!this.script_loaded && $(this.container).length) {
|
386 |
this.load_external_script(this.params.qr_script);
|
387 |
}
|
388 |
LocalPayment.prototype.updated_checkout.apply(this, arguments);
|
389 |
}
|
390 |
|
391 |
+
WeChat.prototype.hashChange = function (e) {
|
392 |
if (this.is_gateway_selected()) {
|
393 |
var match = e.newURL.match(/qrcode=(.*)/);
|
394 |
if (match) {
|
409 |
}
|
410 |
}
|
411 |
|
412 |
+
WeChat.prototype.place_order = function () {
|
413 |
if (this.get_form().is('.wechat')) {
|
414 |
window.location = this.qrcode.redirect;
|
415 |
} else {
|
417 |
}
|
418 |
}
|
419 |
|
420 |
+
BECS.prototype.get_confirmation_args = function (obj) {
|
421 |
var args = LocalPayment.prototype.get_confirmation_args.apply(this, arguments);
|
422 |
args.payment_method.billing_details.email = $('#billing_email').val();
|
423 |
return args;
|
assets/js/frontend/mini-cart.js
ADDED
@@ -0,0 +1,144 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(function ($, wc_stripe) {
|
2 |
+
|
3 |
+
/**
|
4 |
+
*
|
5 |
+
* @param container
|
6 |
+
* @constructor
|
7 |
+
*/
|
8 |
+
function MiniCart(params) {
|
9 |
+
this.message_container = '.widget_shopping_cart_content';
|
10 |
+
wc_stripe.BaseGateway.call(this, params);
|
11 |
+
}
|
12 |
+
|
13 |
+
/**
|
14 |
+
* This is the mini-cart so always return "cart" for the page.
|
15 |
+
* @returns {string}
|
16 |
+
*/
|
17 |
+
MiniCart.prototype.get_page = function () {
|
18 |
+
return 'cart';
|
19 |
+
}
|
20 |
+
|
21 |
+
MiniCart.prototype.add_gateway_active_class = function () {
|
22 |
+
$(this.container).addClass('active');
|
23 |
+
}
|
24 |
+
|
25 |
+
MiniCart.prototype.init_events = function () {
|
26 |
+
|
27 |
+
}
|
28 |
+
|
29 |
+
MiniCart.prototype.get_gateway_data = function () {
|
30 |
+
return $(this.container).find('#' + this.gateway_id + '_' + this.get_page() + '_data').data('gateway');
|
31 |
+
}
|
32 |
+
|
33 |
+
MiniCart.prototype.set_gateway_data = function (data) {
|
34 |
+
$(this.container).find('#' + this.gateway_id + '_' + this.get_page() + '_data').data('gateway', data);
|
35 |
+
}
|
36 |
+
|
37 |
+
/*------------------------- GPay -------------------------*/
|
38 |
+
function GPay(params) {
|
39 |
+
MiniCart.apply(this, arguments);
|
40 |
+
}
|
41 |
+
|
42 |
+
GPay.prototype = Object.assign({}, wc_stripe.BaseGateway.prototype, MiniCart.prototype, wc_stripe.GooglePay.prototype);
|
43 |
+
|
44 |
+
GPay.prototype.initialize = function () {
|
45 |
+
this.container = container + ' ' + this.container;
|
46 |
+
this.createPaymentsClient();
|
47 |
+
this.isReadyToPay().then(function () {
|
48 |
+
this.$button.find('.gpay-button').addClass('button');
|
49 |
+
this.append_button();
|
50 |
+
}.bind(this));
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* @return {[type]}
|
55 |
+
*/
|
56 |
+
GPay.prototype.create_button = function () {
|
57 |
+
wc_stripe.GooglePay.prototype.create_button.apply(this, arguments);
|
58 |
+
}
|
59 |
+
|
60 |
+
GPay.prototype.append_button = function () {
|
61 |
+
if (this.$button && $(this.container).find('.wc-stripe-gpay-mini-cart').is(':empty')) {
|
62 |
+
$(this.container).find('.wc-stripe-gpay-mini-cart').append(this.$button);
|
63 |
+
this.add_gateway_active_class();
|
64 |
+
}
|
65 |
+
}
|
66 |
+
|
67 |
+
/*------------------------- ApplePay -------------------------*/
|
68 |
+
function ApplePay(params) {
|
69 |
+
MiniCart.apply(this, arguments);
|
70 |
+
}
|
71 |
+
|
72 |
+
ApplePay.prototype = Object.assign({}, wc_stripe.BaseGateway.prototype, MiniCart.prototype, wc_stripe.ApplePay.prototype);
|
73 |
+
|
74 |
+
|
75 |
+
ApplePay.prototype.initialize = function () {
|
76 |
+
this.container = container + ' ' + this.container;
|
77 |
+
wc_stripe.ApplePay.prototype.initialize.apply(this, arguments);
|
78 |
+
}
|
79 |
+
|
80 |
+
ApplePay.prototype.append_button = function () {
|
81 |
+
if (this.$button && $(this.container).find('.wc-stripe-applepay-mini-cart').is(':empty')) {
|
82 |
+
$(this.container).find('.wc-stripe-applepay-mini-cart').append(this.$button);
|
83 |
+
this.$button.addClass('button');
|
84 |
+
this.add_gateway_active_class();
|
85 |
+
}
|
86 |
+
}
|
87 |
+
|
88 |
+
/*------------------------- PaymentRequest -------------------------*/
|
89 |
+
function PaymentRequest(params) {
|
90 |
+
MiniCart.apply(this, arguments);
|
91 |
+
}
|
92 |
+
|
93 |
+
PaymentRequest.prototype = Object.assign({}, wc_stripe.BaseGateway.prototype, MiniCart.prototype, wc_stripe.PaymentRequest.prototype);
|
94 |
+
|
95 |
+
PaymentRequest.prototype.initialize = function () {
|
96 |
+
this.container = container + ' ' + this.container;
|
97 |
+
wc_stripe.PaymentRequest.prototype.initialize.apply(this, arguments);
|
98 |
+
}
|
99 |
+
|
100 |
+
PaymentRequest.prototype.create_button = function () {
|
101 |
+
this.append_button();
|
102 |
+
}
|
103 |
+
|
104 |
+
PaymentRequest.prototype.append_button = function () {
|
105 |
+
if ($(this.container).find('.wc-stripe-payment-request-mini-cart').is(':empty')) {
|
106 |
+
this.paymentRequestButton.mount($(this.container).find('.wc-stripe-payment-request-mini-cart').first()[0]);
|
107 |
+
$(this.container).find('.wc-stripe-payment-request-mini-cart').addClass('button');
|
108 |
+
this.add_gateway_active_class();
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
+
/*-------------------------------------------------------------------------*/
|
113 |
+
|
114 |
+
var gateways = [], container = null;
|
115 |
+
|
116 |
+
if (typeof wc_stripe_googlepay_mini_cart_params !== 'undefined') {
|
117 |
+
gateways.push([GPay, wc_stripe_googlepay_mini_cart_params]);
|
118 |
+
}
|
119 |
+
if (typeof wc_stripe_applepay_mini_cart_params !== 'undefined') {
|
120 |
+
gateways.push([ApplePay, wc_stripe_applepay_mini_cart_params]);
|
121 |
+
}
|
122 |
+
if (typeof wc_stripe_payment_request_mini_cart_params !== 'undefined') {
|
123 |
+
gateways.push([PaymentRequest, wc_stripe_payment_request_mini_cart_params]);
|
124 |
+
}
|
125 |
+
|
126 |
+
function load_mini_cart() {
|
127 |
+
$('.widget_shopping_cart_content').not(':empty').each(function (idx, el) {
|
128 |
+
if ($(el).find('.wc-stripe-mini-cart-payment-methods').length) {
|
129 |
+
var $parent = $(el).parent();
|
130 |
+
if ($parent.length) {
|
131 |
+
var class_name = 'wc-stripe-mini-cart-idx-' + idx;
|
132 |
+
$parent.addClass(class_name);
|
133 |
+
container = '.' + class_name + ' .widget_shopping_cart_content';
|
134 |
+
gateways.forEach(function (gateway) {
|
135 |
+
new gateway[0](gateway[1]);
|
136 |
+
})
|
137 |
+
}
|
138 |
+
}
|
139 |
+
});
|
140 |
+
}
|
141 |
+
|
142 |
+
$(document.body).on('wc_fragments_refreshed wc_fragments_loaded', load_mini_cart);
|
143 |
+
|
144 |
+
}(jQuery, window.wc_stripe));
|
assets/js/frontend/payment-request.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
(function($, wc_stripe) {
|
2 |
|
3 |
// Product page functionality
|
4 |
if ($(document.body).is('.single-product')) {
|
@@ -7,13 +7,12 @@
|
|
7 |
*/
|
8 |
function PaymentRequest() {
|
9 |
wc_stripe.BaseGateway.call(this, wc_stripe_payment_request_params);
|
10 |
-
wc_stripe.ProductGateway.call(this);
|
11 |
this.old_qty = this.get_quantity();
|
12 |
}
|
13 |
|
14 |
PaymentRequest.prototype = $.extend({}, wc_stripe.BaseGateway.prototype, wc_stripe.ProductGateway.prototype, wc_stripe.PaymentRequest.prototype);
|
15 |
|
16 |
-
PaymentRequest.prototype.initialize = function() {
|
17 |
wc_stripe.ProductGateway.call(this);
|
18 |
wc_stripe.PaymentRequest.prototype.initialize.call(this);
|
19 |
}
|
@@ -22,77 +21,59 @@
|
|
22 |
* [canMakePayment description]
|
23 |
* @return {[type]} [description]
|
24 |
*/
|
25 |
-
PaymentRequest.prototype.canMakePayment = function() {
|
26 |
-
wc_stripe.PaymentRequest.prototype.canMakePayment.apply(this, arguments).then(function(result) {
|
27 |
$(document.body).on('change', '[name="quantity"]', this.add_to_cart.bind(this));
|
28 |
$(this.container).parent().parent().addClass('active');
|
29 |
if (!this.is_variable_product()) {
|
30 |
-
this.cart_calculation()
|
31 |
-
this.paymentRequest.update(this.get_payment_request_update({
|
32 |
-
total: {
|
33 |
-
pending: false
|
34 |
-
}
|
35 |
-
}));
|
36 |
-
}.bind(this)).catch(function() {
|
37 |
-
|
38 |
-
}.bind(this))
|
39 |
} else {
|
40 |
-
if (this
|
41 |
-
this.
|
|
|
|
|
42 |
}
|
43 |
}
|
44 |
}.bind(this))
|
45 |
}
|
46 |
|
47 |
-
PaymentRequest.prototype.create_button = function() {
|
48 |
-
wc_stripe.PaymentRequest.prototype.create_button.apply(this, arguments);
|
49 |
-
this.$button = $('#wc-stripe-payment-request-container');
|
50 |
-
}
|
51 |
-
|
52 |
-
PaymentRequest.prototype.button_click = function(e) {
|
53 |
-
if (this.$button.is('.disabled')) {
|
54 |
-
e.preventDefault();
|
55 |
-
} else if (this.get_quantity() == 0) {
|
56 |
-
e.preventDefault();
|
57 |
-
this.submit_error(this.params.messages.invalid_amount);
|
58 |
-
}
|
59 |
-
}
|
60 |
-
|
61 |
/**
|
62 |
* [add_to_cart description]
|
63 |
*/
|
64 |
-
PaymentRequest.prototype.add_to_cart = function(e) {
|
65 |
if (this.$button.is('.disabled') && this.can_pay) {
|
66 |
$('[name="quantity"]').val(this.old_qty);
|
67 |
this.submit_error(this.params.messages.choose_product);
|
68 |
return;
|
69 |
}
|
70 |
this.old_qty = this.get_quantity();
|
71 |
-
|
72 |
-
|
|
|
|
|
|
|
|
|
73 |
this.paymentRequest.update(this.get_payment_request_update({
|
74 |
total: {
|
75 |
pending: false
|
76 |
}
|
77 |
}));
|
78 |
-
|
79 |
-
|
|
|
80 |
}
|
81 |
|
82 |
-
PaymentRequest.prototype.
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
}.bind(this)).catch(function() {
|
94 |
-
wc_stripe.ProductGateway.prototype.found_variation.call(this, e, variation);
|
95 |
-
}.bind(this))
|
96 |
}
|
97 |
}
|
98 |
|
@@ -100,7 +81,7 @@
|
|
100 |
* [block description]
|
101 |
* @return {[type]} [description]
|
102 |
*/
|
103 |
-
PaymentRequest.prototype.block = function() {
|
104 |
$.blockUI({
|
105 |
message: this.adding_to_cart ? this.params.messages.add_to_cart : null,
|
106 |
overlayCSS: {
|
@@ -123,13 +104,13 @@
|
|
123 |
|
124 |
PaymentRequest.prototype = $.extend({}, wc_stripe.BaseGateway.prototype, wc_stripe.CartGateway.prototype, wc_stripe.PaymentRequest.prototype);
|
125 |
|
126 |
-
PaymentRequest.prototype.initialize = function() {
|
127 |
wc_stripe.CartGateway.call(this);
|
128 |
wc_stripe.PaymentRequest.prototype.initialize.call(this);
|
129 |
}
|
130 |
|
131 |
-
PaymentRequest.prototype.canMakePayment = function() {
|
132 |
-
wc_stripe.PaymentRequest.prototype.canMakePayment.apply(this, arguments).then(function() {
|
133 |
$(this.container).addClass('active').parent().addClass('active');
|
134 |
}.bind(this))
|
135 |
}
|
@@ -138,7 +119,7 @@
|
|
138 |
* New paymentRequest is needed since cart might have changed.
|
139 |
* @return {[type]} [description]
|
140 |
*/
|
141 |
-
PaymentRequest.prototype.init_payment_request = function() {
|
142 |
this.paymentRequestButton.destroy();
|
143 |
}
|
144 |
|
@@ -146,7 +127,7 @@
|
|
146 |
* [updated_html description]
|
147 |
* @return {[type]} [description]
|
148 |
*/
|
149 |
-
PaymentRequest.prototype.updated_html = function() {
|
150 |
if (!$(this.container).length) {
|
151 |
this.can_pay = false;
|
152 |
}
|
@@ -156,7 +137,7 @@
|
|
156 |
}
|
157 |
}
|
158 |
|
159 |
-
PaymentRequest.prototype.button_click = function(e) {
|
160 |
this.paymentRequest.update(this.get_payment_request_update({
|
161 |
total: {
|
162 |
pending: false
|
@@ -169,7 +150,7 @@
|
|
169 |
* @param {[type]} e [description]
|
170 |
* @return {[type]} [description]
|
171 |
*/
|
172 |
-
PaymentRequest.prototype.cart_emptied = function(e) {
|
173 |
this.can_pay = false;
|
174 |
}
|
175 |
}
|
@@ -185,7 +166,7 @@
|
|
185 |
|
186 |
PaymentRequest.prototype = $.extend({}, wc_stripe.BaseGateway.prototype, wc_stripe.CheckoutGateway.prototype, wc_stripe.PaymentRequest.prototype);
|
187 |
|
188 |
-
PaymentRequest.prototype.initialize = function() {
|
189 |
wc_stripe.CheckoutGateway.call(this);
|
190 |
wc_stripe.PaymentRequest.prototype.initialize.call(this);
|
191 |
}
|
@@ -193,8 +174,8 @@
|
|
193 |
* [canMakePayment description]
|
194 |
* @return {[type]} [description]
|
195 |
*/
|
196 |
-
PaymentRequest.prototype.canMakePayment = function() {
|
197 |
-
wc_stripe.PaymentRequest.prototype.canMakePayment.apply(this, arguments).then(function(result) {
|
198 |
if (this.banner_enabled()) {
|
199 |
$(this.banner_container).show().append('<div id="wc-stripe-payment-request-banner"></div>');
|
200 |
$(this.banner_container).show().parent().parent().addClass('active');
|
@@ -219,7 +200,7 @@
|
|
219 |
* [create_button description]
|
220 |
* @return {[type]} [description]
|
221 |
*/
|
222 |
-
PaymentRequest.prototype.create_button = function() {
|
223 |
var $parent = $('#place_order').parent();
|
224 |
if (this.$button) {
|
225 |
this.$button.remove();
|
@@ -234,7 +215,7 @@
|
|
234 |
* [updated_checkout description]
|
235 |
* @return {[type]} [description]
|
236 |
*/
|
237 |
-
PaymentRequest.prototype.updated_checkout = function() {
|
238 |
if (this.can_pay) {
|
239 |
$(this.container).show();
|
240 |
this.create_button();
|
@@ -246,12 +227,12 @@
|
|
246 |
* @param {[type]} e [description]
|
247 |
* @return {[type]} [description]
|
248 |
*/
|
249 |
-
PaymentRequest.prototype.banner_checkout = function(e) {
|
250 |
this.set_payment_method(this.gateway_id);
|
251 |
this.set_use_new_option(true);
|
252 |
}
|
253 |
|
254 |
-
PaymentRequest.prototype.on_token_received = function() {
|
255 |
wc_stripe.CheckoutGateway.prototype.on_token_received.apply(this, arguments);
|
256 |
if (this.checkout_fields_valid()) {
|
257 |
this.get_form().submit();
|
1 |
+
(function ($, wc_stripe) {
|
2 |
|
3 |
// Product page functionality
|
4 |
if ($(document.body).is('.single-product')) {
|
7 |
*/
|
8 |
function PaymentRequest() {
|
9 |
wc_stripe.BaseGateway.call(this, wc_stripe_payment_request_params);
|
|
|
10 |
this.old_qty = this.get_quantity();
|
11 |
}
|
12 |
|
13 |
PaymentRequest.prototype = $.extend({}, wc_stripe.BaseGateway.prototype, wc_stripe.ProductGateway.prototype, wc_stripe.PaymentRequest.prototype);
|
14 |
|
15 |
+
PaymentRequest.prototype.initialize = function () {
|
16 |
wc_stripe.ProductGateway.call(this);
|
17 |
wc_stripe.PaymentRequest.prototype.initialize.call(this);
|
18 |
}
|
21 |
* [canMakePayment description]
|
22 |
* @return {[type]} [description]
|
23 |
*/
|
24 |
+
PaymentRequest.prototype.canMakePayment = function () {
|
25 |
+
wc_stripe.PaymentRequest.prototype.canMakePayment.apply(this, arguments).then(function (result) {
|
26 |
$(document.body).on('change', '[name="quantity"]', this.add_to_cart.bind(this));
|
27 |
$(this.container).parent().parent().addClass('active');
|
28 |
if (!this.is_variable_product()) {
|
29 |
+
this.cart_calculation();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
} else {
|
31 |
+
if (this.variable_product_selected()) {
|
32 |
+
this.cart_calculation(this.get_product_data().variation.variation_id);
|
33 |
+
} else {
|
34 |
+
this.disable_payment_button();
|
35 |
}
|
36 |
}
|
37 |
}.bind(this))
|
38 |
}
|
39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
/**
|
41 |
* [add_to_cart description]
|
42 |
*/
|
43 |
+
PaymentRequest.prototype.add_to_cart = function (e) {
|
44 |
if (this.$button.is('.disabled') && this.can_pay) {
|
45 |
$('[name="quantity"]').val(this.old_qty);
|
46 |
this.submit_error(this.params.messages.choose_product);
|
47 |
return;
|
48 |
}
|
49 |
this.old_qty = this.get_quantity();
|
50 |
+
var variation = this.get_product_data().variation;
|
51 |
+
this.cart_calculation(variation.variation_id);
|
52 |
+
}
|
53 |
+
|
54 |
+
PaymentRequest.prototype.cart_calculation = function () {
|
55 |
+
wc_stripe.ProductGateway.prototype.cart_calculation.apply(this, arguments).then(function () {
|
56 |
this.paymentRequest.update(this.get_payment_request_update({
|
57 |
total: {
|
58 |
pending: false
|
59 |
}
|
60 |
}));
|
61 |
+
}.bind(this)).catch(function () {
|
62 |
+
|
63 |
+
}.bind(this));
|
64 |
}
|
65 |
|
66 |
+
PaymentRequest.prototype.create_button = function () {
|
67 |
+
wc_stripe.PaymentRequest.prototype.create_button.apply(this, arguments);
|
68 |
+
this.$button = $('#wc-stripe-payment-request-container');
|
69 |
+
}
|
70 |
+
|
71 |
+
PaymentRequest.prototype.button_click = function (e) {
|
72 |
+
if (this.$button.is('.disabled')) {
|
73 |
+
e.preventDefault();
|
74 |
+
} else if (this.get_quantity() == 0) {
|
75 |
+
e.preventDefault();
|
76 |
+
this.submit_error(this.params.messages.invalid_amount);
|
|
|
|
|
|
|
77 |
}
|
78 |
}
|
79 |
|
81 |
* [block description]
|
82 |
* @return {[type]} [description]
|
83 |
*/
|
84 |
+
PaymentRequest.prototype.block = function () {
|
85 |
$.blockUI({
|
86 |
message: this.adding_to_cart ? this.params.messages.add_to_cart : null,
|
87 |
overlayCSS: {
|
104 |
|
105 |
PaymentRequest.prototype = $.extend({}, wc_stripe.BaseGateway.prototype, wc_stripe.CartGateway.prototype, wc_stripe.PaymentRequest.prototype);
|
106 |
|
107 |
+
PaymentRequest.prototype.initialize = function () {
|
108 |
wc_stripe.CartGateway.call(this);
|
109 |
wc_stripe.PaymentRequest.prototype.initialize.call(this);
|
110 |
}
|
111 |
|
112 |
+
PaymentRequest.prototype.canMakePayment = function () {
|
113 |
+
wc_stripe.PaymentRequest.prototype.canMakePayment.apply(this, arguments).then(function () {
|
114 |
$(this.container).addClass('active').parent().addClass('active');
|
115 |
}.bind(this))
|
116 |
}
|
119 |
* New paymentRequest is needed since cart might have changed.
|
120 |
* @return {[type]} [description]
|
121 |
*/
|
122 |
+
PaymentRequest.prototype.init_payment_request = function () {
|
123 |
this.paymentRequestButton.destroy();
|
124 |
}
|
125 |
|
127 |
* [updated_html description]
|
128 |
* @return {[type]} [description]
|
129 |
*/
|
130 |
+
PaymentRequest.prototype.updated_html = function () {
|
131 |
if (!$(this.container).length) {
|
132 |
this.can_pay = false;
|
133 |
}
|
137 |
}
|
138 |
}
|
139 |
|
140 |
+
PaymentRequest.prototype.button_click = function (e) {
|
141 |
this.paymentRequest.update(this.get_payment_request_update({
|
142 |
total: {
|
143 |
pending: false
|
150 |
* @param {[type]} e [description]
|
151 |
* @return {[type]} [description]
|
152 |
*/
|
153 |
+
PaymentRequest.prototype.cart_emptied = function (e) {
|
154 |
this.can_pay = false;
|
155 |
}
|
156 |
}
|
166 |
|
167 |
PaymentRequest.prototype = $.extend({}, wc_stripe.BaseGateway.prototype, wc_stripe.CheckoutGateway.prototype, wc_stripe.PaymentRequest.prototype);
|
168 |
|
169 |
+
PaymentRequest.prototype.initialize = function () {
|
170 |
wc_stripe.CheckoutGateway.call(this);
|
171 |
wc_stripe.PaymentRequest.prototype.initialize.call(this);
|
172 |
}
|
174 |
* [canMakePayment description]
|
175 |
* @return {[type]} [description]
|
176 |
*/
|
177 |
+
PaymentRequest.prototype.canMakePayment = function () {
|
178 |
+
wc_stripe.PaymentRequest.prototype.canMakePayment.apply(this, arguments).then(function (result) {
|
179 |
if (this.banner_enabled()) {
|
180 |
$(this.banner_container).show().append('<div id="wc-stripe-payment-request-banner"></div>');
|
181 |
$(this.banner_container).show().parent().parent().addClass('active');
|
200 |
* [create_button description]
|
201 |
* @return {[type]} [description]
|
202 |
*/
|
203 |
+
PaymentRequest.prototype.create_button = function () {
|
204 |
var $parent = $('#place_order').parent();
|
205 |
if (this.$button) {
|
206 |
this.$button.remove();
|
215 |
* [updated_checkout description]
|
216 |
* @return {[type]} [description]
|
217 |
*/
|
218 |
+
PaymentRequest.prototype.updated_checkout = function () {
|
219 |
if (this.can_pay) {
|
220 |
$(this.container).show();
|
221 |
this.create_button();
|
227 |
* @param {[type]} e [description]
|
228 |
* @return {[type]} [description]
|
229 |
*/
|
230 |
+
PaymentRequest.prototype.banner_checkout = function (e) {
|
231 |
this.set_payment_method(this.gateway_id);
|
232 |
this.set_use_new_option(true);
|
233 |
}
|
234 |
|
235 |
+
PaymentRequest.prototype.on_token_received = function () {
|
236 |
wc_stripe.CheckoutGateway.prototype.on_token_received.apply(this, arguments);
|
237 |
if (this.checkout_fields_valid()) {
|
238 |
this.get_form().submit();
|
assets/js/frontend/wc-stripe.js
CHANGED
@@ -1,27 +1,33 @@
|
|
1 |
-
(function(window, $) {
|
2 |
window.wc_stripe = {};
|
3 |
var stripe = null;
|
4 |
|
|
|
|
|
|
|
|
|
5 |
/**
|
6 |
-
* @
|
7 |
*/
|
8 |
-
wc_stripe.BaseGateway = function(params) {
|
9 |
this.params = params;
|
10 |
this.gateway_id = this.params.gateway_id;
|
|
|
11 |
this.token_selector = this.params.token_selector;
|
12 |
this.saved_method_selector = this.params.saved_method_selector;
|
13 |
-
this.payment_intent_selector = this.params.payment_intent_selector;
|
14 |
this.payment_token_received = false;
|
15 |
this.stripe = stripe;
|
16 |
-
this.elements = stripe.elements($.extend({}, {
|
|
|
17 |
this.initialize();
|
18 |
}
|
19 |
|
20 |
-
wc_stripe.BaseGateway.prototype.get_page = function() {
|
21 |
return wc_stripe_params_v3.page;
|
22 |
}
|
23 |
|
24 |
-
wc_stripe.BaseGateway.prototype.set_nonce = function(value) {
|
|
|
25 |
$(this.token_selector).val(value);
|
26 |
}
|
27 |
|
@@ -29,38 +35,37 @@
|
|
29 |
* [get_element_options description]
|
30 |
* @return {[type]} [description]
|
31 |
*/
|
32 |
-
wc_stripe.BaseGateway.prototype.get_element_options = function() {
|
33 |
return {};
|
34 |
}
|
35 |
|
36 |
-
wc_stripe.BaseGateway.prototype.initialize = function() {
|
|
|
37 |
|
38 |
/**
|
39 |
* @return {[type]}
|
40 |
*/
|
41 |
-
wc_stripe.BaseGateway.prototype.create_button = function() {
|
|
|
42 |
|
43 |
/**
|
44 |
* @returns {Boolean}
|
45 |
*/
|
46 |
-
wc_stripe.BaseGateway.prototype.is_gateway_selected = function() {
|
47 |
return $('[name="payment_method"]:checked').val() === this.gateway_id;
|
48 |
}
|
49 |
|
50 |
/**
|
51 |
* @returns {Boolean}
|
52 |
*/
|
53 |
-
wc_stripe.BaseGateway.prototype.is_saved_method_selected = function() {
|
54 |
-
return this.is_gateway_selected() &&
|
55 |
-
$(
|
56 |
-
'[name="' + this.gateway_id +
|
57 |
-
'_payment_type_key"]:checked').val() === 'saved';
|
58 |
}
|
59 |
|
60 |
/**
|
61 |
* @return {Boolean}
|
62 |
*/
|
63 |
-
wc_stripe.BaseGateway.prototype.has_checkout_error = function() {
|
64 |
return $('#wc_stripe_checkout_error').length > 0 && this.is_gateway_selected();
|
65 |
}
|
66 |
|
@@ -68,7 +73,7 @@
|
|
68 |
* @param {[type]}
|
69 |
* @return {[type]}
|
70 |
*/
|
71 |
-
wc_stripe.BaseGateway.prototype.submit_error = function(message) {
|
72 |
message = this.get_error_message(message);
|
73 |
if (message.indexOf('</ul>') == -1) {
|
74 |
message = '<div class="woocommerce-error">' + message + '</div>';
|
@@ -76,11 +81,11 @@
|
|
76 |
this.submit_message(message);
|
77 |
}
|
78 |
|
79 |
-
wc_stripe.BaseGateway.prototype.submit_error_code = function(code) {
|
80 |
|
81 |
}
|
82 |
|
83 |
-
wc_stripe.BaseGateway.prototype.get_error_message = function(message) {
|
84 |
if (typeof message == 'object' && message.code) {
|
85 |
if (wc_stripe_messages[message.code]) {
|
86 |
message = wc_stripe_messages[message.code];
|
@@ -95,7 +100,7 @@
|
|
95 |
* @param {[type]}
|
96 |
* @return {[type]}
|
97 |
*/
|
98 |
-
wc_stripe.BaseGateway.prototype.submit_message = function(message) {
|
99 |
$('.woocommerce-error, .woocommerce-message, .woocommerce-info')
|
100 |
.remove();
|
101 |
var $container = $(this.message_container);
|
@@ -114,48 +119,56 @@
|
|
114 |
}
|
115 |
}
|
116 |
|
117 |
-
wc_stripe.BaseGateway.prototype.get_first_name = function(prefix) {
|
118 |
return $('#' + prefix + '_first_name').val();
|
119 |
}
|
120 |
|
121 |
-
wc_stripe.BaseGateway.prototype.get_last_name = function(prefix) {
|
122 |
return $('#' + prefix + '_last_name').val();
|
123 |
}
|
124 |
|
125 |
/**
|
126 |
* Return true if the source should be saved.
|
127 |
-
*
|
128 |
* @returns {Boolean}
|
129 |
*/
|
130 |
-
wc_stripe.BaseGateway.prototype.should_save_method = function() {
|
131 |
return $('#' + this.gateway_id + '_save_source_key').is(':checked');
|
132 |
}
|
133 |
|
134 |
-
wc_stripe.BaseGateway.prototype.is_add_payment_method_page = function() {
|
135 |
-
return $(document.body).hasClass('woocommerce-add-payment-method');
|
136 |
}
|
137 |
|
138 |
-
wc_stripe.BaseGateway.prototype.
|
|
|
|
|
|
|
|
|
139 |
return $(this.saved_method_selector).val();
|
140 |
}
|
141 |
|
142 |
-
wc_stripe.BaseGateway.prototype.needs_shipping = function() {
|
143 |
-
return this.
|
|
|
|
|
|
|
|
|
144 |
}
|
145 |
|
146 |
-
wc_stripe.BaseGateway.prototype.
|
147 |
-
return $('#
|
148 |
}
|
149 |
|
150 |
-
wc_stripe.BaseGateway.prototype.
|
151 |
-
|
152 |
}
|
153 |
|
154 |
/**
|
155 |
* [get_customer_name description]
|
156 |
* @return {[type]} [description]
|
157 |
*/
|
158 |
-
wc_stripe.BaseGateway.prototype.get_customer_name = function(prefix) {
|
159 |
return $(prefix + '_first_name').val() + ' ' + $(prefix + '_last_name').val();
|
160 |
}
|
161 |
|
@@ -163,7 +176,7 @@
|
|
163 |
* [get_customer_email description]
|
164 |
* @return {[type]} [description]
|
165 |
*/
|
166 |
-
wc_stripe.BaseGateway.prototype.get_customer_email = function() {
|
167 |
return $('#billing_email').val();
|
168 |
}
|
169 |
|
@@ -172,11 +185,11 @@
|
|
172 |
* @param {[type]}
|
173 |
* @return {[type]}
|
174 |
*/
|
175 |
-
wc_stripe.BaseGateway.prototype.get_address_field_hash = function(prefix) {
|
176 |
-
var params = ['_first_name', '_last_name', '_address_1', '_address_2', '_postcode', '_city', '_state', '_country',
|
177 |
var hash = "";
|
178 |
for (var i = 0; i < params.length; i++) {
|
179 |
-
hash +=
|
180 |
}
|
181 |
return hash;
|
182 |
}
|
@@ -184,7 +197,7 @@
|
|
184 |
/**
|
185 |
* @return {[type]}
|
186 |
*/
|
187 |
-
wc_stripe.BaseGateway.prototype.block = function() {
|
188 |
$.blockUI({
|
189 |
message: null,
|
190 |
overlayCSS: {
|
@@ -197,54 +210,58 @@
|
|
197 |
/**
|
198 |
* @return {[type]}
|
199 |
*/
|
200 |
-
wc_stripe.BaseGateway.prototype.unblock = function() {
|
201 |
$.unblockUI();
|
202 |
}
|
203 |
|
204 |
/**
|
205 |
* @return {[type]}
|
206 |
*/
|
207 |
-
wc_stripe.BaseGateway.prototype.get_form = function() {
|
208 |
return $(this.token_selector).closest('form');
|
209 |
}
|
210 |
|
211 |
/**
|
212 |
* @return {[type]}
|
213 |
*/
|
214 |
-
wc_stripe.BaseGateway.prototype.get_total_price = function() {
|
215 |
-
return
|
216 |
}
|
217 |
|
218 |
-
wc_stripe.BaseGateway.prototype.get_total_price_cents = function() {
|
219 |
-
return
|
220 |
}
|
221 |
|
222 |
/**
|
223 |
* @return {[type]}
|
224 |
*/
|
225 |
-
wc_stripe.BaseGateway.prototype.set_total_price = function(total) {
|
226 |
-
|
|
|
|
|
227 |
}
|
228 |
|
229 |
/**
|
230 |
* @return {[type]}
|
231 |
*/
|
232 |
-
wc_stripe.BaseGateway.prototype.set_total_price_cents = function(total) {
|
233 |
-
|
|
|
|
|
234 |
}
|
235 |
|
236 |
/**
|
237 |
* [set_payment_method description]
|
238 |
* @param {[type]} payment_method [description]
|
239 |
*/
|
240 |
-
wc_stripe.BaseGateway.prototype.set_payment_method = function(payment_method) {
|
241 |
$('[name="payment_method"][value="' + payment_method + '"]').prop("checked", true).trigger('click');
|
242 |
}
|
243 |
|
244 |
/**
|
245 |
* [set_shipping_methods description]
|
246 |
*/
|
247 |
-
wc_stripe.BaseGateway.prototype.set_selected_shipping_methods = function(shipping_methods) {
|
248 |
if (shipping_methods && $('[name^="shipping_method"]').length) {
|
249 |
for (var i in shipping_methods) {
|
250 |
var method = shipping_methods[i];
|
@@ -257,13 +274,13 @@
|
|
257 |
* @param {[type]}
|
258 |
* @return {[type]}
|
259 |
*/
|
260 |
-
wc_stripe.BaseGateway.prototype.on_token_received = function(paymentMethod) {
|
261 |
this.payment_token_received = true;
|
262 |
-
|
263 |
this.process_checkout();
|
264 |
}
|
265 |
|
266 |
-
wc_stripe.BaseGateway.prototype.createPaymentRequest = function() {
|
267 |
try {
|
268 |
this.paymentRequest = stripe.paymentRequest(this.get_payment_request_options());
|
269 |
} catch (err) {
|
@@ -282,7 +299,7 @@
|
|
282 |
/**
|
283 |
* @return {[Object]}
|
284 |
*/
|
285 |
-
wc_stripe.BaseGateway.prototype.get_payment_request_options = function() {
|
286 |
var options = {
|
287 |
country: this.params.country_code,
|
288 |
currency: this.get_currency().toLowerCase(),
|
@@ -292,8 +309,8 @@
|
|
292 |
pending: true
|
293 |
},
|
294 |
requestPayerName: true,
|
295 |
-
requestPayerEmail:
|
296 |
-
requestPayerPhone:
|
297 |
requestShipping: this.needs_shipping()
|
298 |
}
|
299 |
var displayItems = this.get_display_items(),
|
@@ -310,7 +327,7 @@
|
|
310 |
/**
|
311 |
* @return {[Object]}
|
312 |
*/
|
313 |
-
wc_stripe.BaseGateway.prototype.get_payment_request_update = function(data) {
|
314 |
var options = {
|
315 |
currency: this.get_currency().toLowerCase(),
|
316 |
total: {
|
@@ -336,31 +353,35 @@
|
|
336 |
/**
|
337 |
* @return {[type]}
|
338 |
*/
|
339 |
-
wc_stripe.BaseGateway.prototype.get_display_items = function() {
|
340 |
-
return
|
341 |
}
|
342 |
|
343 |
/**
|
344 |
* @return {[type]}
|
345 |
*/
|
346 |
-
wc_stripe.BaseGateway.prototype.set_display_items = function(items) {
|
347 |
-
|
|
|
|
|
348 |
}
|
349 |
|
350 |
/**
|
351 |
* Return an array of shipping options for display in the Google payment sheet
|
352 |
* @return {[type]}
|
353 |
*/
|
354 |
-
wc_stripe.BaseGateway.prototype.get_shipping_options = function() {
|
355 |
-
return
|
356 |
}
|
357 |
|
358 |
/**
|
359 |
* Update the shipping options.
|
360 |
* @param {[type]}
|
361 |
*/
|
362 |
-
wc_stripe.BaseGateway.prototype.set_shipping_options = function(items) {
|
363 |
-
|
|
|
|
|
364 |
}
|
365 |
|
366 |
/**
|
@@ -368,7 +389,7 @@
|
|
368 |
* @param {[type]}
|
369 |
* @return {[type]}
|
370 |
*/
|
371 |
-
wc_stripe.BaseGateway.prototype.map_address = function(address) {
|
372 |
return {
|
373 |
city: address.city,
|
374 |
postcode: address.postalCode,
|
@@ -381,7 +402,7 @@
|
|
381 |
* @param {[type]}
|
382 |
* @return {[type]}
|
383 |
*/
|
384 |
-
wc_stripe.BaseGateway.prototype.on_payment_method_received = function(paymentResponse) {
|
385 |
try {
|
386 |
this.payment_response = paymentResponse;
|
387 |
this.populate_checkout_fields(paymentResponse);
|
@@ -395,8 +416,8 @@
|
|
395 |
/**
|
396 |
* @return {[type]}
|
397 |
*/
|
398 |
-
wc_stripe.BaseGateway.prototype.populate_checkout_fields = function(data) {
|
399 |
-
|
400 |
this.populate_address_fields(data);
|
401 |
}
|
402 |
|
@@ -404,184 +425,64 @@
|
|
404 |
* @param {[type]}
|
405 |
* @return {[type]}
|
406 |
*/
|
407 |
-
wc_stripe.BaseGateway.prototype.populate_address_fields = function(data) {
|
408 |
-
var mappings = this.address_mappings();
|
409 |
if (data.payerName) {
|
410 |
-
mappings.
|
411 |
}
|
412 |
if (data.payerEmail) {
|
413 |
-
mappings.
|
414 |
}
|
415 |
if (data.payerPhone) {
|
416 |
-
mappings.
|
417 |
}
|
418 |
if (data.shippingAddress) {
|
419 |
var address = data.shippingAddress;
|
420 |
for (var k in address) {
|
421 |
-
|
422 |
-
mappings[k].set.call(this, address[k], '#shipping');
|
423 |
-
}
|
424 |
}
|
425 |
}
|
426 |
if (data.paymentMethod.billing_details.address) {
|
427 |
var address = data.paymentMethod.billing_details.address;
|
428 |
for (var k in address) {
|
429 |
-
|
430 |
-
mappings[k].set.call(this, address[k], '#billing');
|
431 |
-
}
|
432 |
}
|
433 |
}
|
434 |
-
this.
|
435 |
-
|
|
|
|
|
|
|
436 |
}
|
437 |
|
438 |
/**
|
439 |
* @return {[type]}
|
440 |
*/
|
441 |
-
wc_stripe.BaseGateway.prototype.address_mappings = function() {
|
442 |
-
return
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
}
|
449 |
-
if (name.length > 1) {
|
450 |
-
$('#billing_last_name').val(name[1]);
|
451 |
-
}
|
452 |
-
},
|
453 |
-
get: function(prefix) {
|
454 |
-
return $('#billing_first_name').val() + ' ' + $('#billing_last_name').val()
|
455 |
-
}
|
456 |
-
},
|
457 |
-
payerEmail: {
|
458 |
-
set: function(v) {
|
459 |
-
$('#billing_email').val(v);
|
460 |
-
},
|
461 |
-
get: function() {
|
462 |
-
return $('#billing_email').val();
|
463 |
-
}
|
464 |
-
},
|
465 |
-
payerPhone: {
|
466 |
-
set: function(v) {
|
467 |
-
$('#billing_phone').val(v);
|
468 |
-
},
|
469 |
-
get: function() {
|
470 |
-
return $('#billing_phone').val();
|
471 |
-
}
|
472 |
-
},
|
473 |
-
recipient: {
|
474 |
-
set: function(v, prefix) {
|
475 |
-
var name = v.split(" ");
|
476 |
-
if (name.length > 0) {
|
477 |
-
$(prefix + '_first_name').val(name[0]);
|
478 |
-
}
|
479 |
-
if (name.length > 1) {
|
480 |
-
$(prefix + '_last_name').val(name[1]);
|
481 |
-
}
|
482 |
-
},
|
483 |
-
get: function(prefix) {
|
484 |
-
return $(prefix + '_first_name').val() + ' ' + $(prefix + '_last_name').val()
|
485 |
-
}
|
486 |
-
},
|
487 |
-
country: {
|
488 |
-
set: function(v, prefix) {
|
489 |
-
$(prefix + '_country').val(v);
|
490 |
-
},
|
491 |
-
get: function(prefix) {
|
492 |
-
return $(prefix + '_country').val();
|
493 |
-
}
|
494 |
-
},
|
495 |
-
addressLine: {
|
496 |
-
set: function(v, prefix) {
|
497 |
-
if (v.length > 0) {
|
498 |
-
$(prefix + '_address_1').val(v[0]);
|
499 |
-
}
|
500 |
-
if (v.length > 1) {
|
501 |
-
$(prefix + '_address_2').val(v[1]);
|
502 |
-
}
|
503 |
-
},
|
504 |
-
get: function(prefix) {
|
505 |
-
return [
|
506 |
-
$(prefix + '_address_1').val(),
|
507 |
-
$(prefix + '_address_2').val(),
|
508 |
-
]
|
509 |
-
}
|
510 |
-
},
|
511 |
-
line1: {
|
512 |
-
set: function(v, prefix) {
|
513 |
-
$(prefix + '_address_1').val(v);
|
514 |
-
},
|
515 |
-
get: function(prefix) {
|
516 |
-
return $(prefix + '_address_1').val();
|
517 |
-
}
|
518 |
-
},
|
519 |
-
line2: {
|
520 |
-
set: function(v, prefix) {
|
521 |
-
$(prefix + '_address_2').val(v);
|
522 |
-
},
|
523 |
-
get: function(prefix) {
|
524 |
-
return $(prefix + '_address_2').val();
|
525 |
-
}
|
526 |
-
},
|
527 |
-
region: {
|
528 |
-
set: function(v, prefix) {
|
529 |
-
$(prefix + '_state').val(v);
|
530 |
-
},
|
531 |
-
get: function(prefix) {
|
532 |
-
$(prefix + '_state').val();
|
533 |
-
}
|
534 |
-
},
|
535 |
-
state: {
|
536 |
-
set: function(v, prefix) {
|
537 |
-
$(prefix + '_state').val(v);
|
538 |
-
},
|
539 |
-
get: function(prefix) {
|
540 |
-
$(prefix + '_state').val();
|
541 |
-
}
|
542 |
-
},
|
543 |
-
city: {
|
544 |
-
set: function(v, prefix) {
|
545 |
-
$(prefix + '_city').val(v);
|
546 |
-
},
|
547 |
-
get: function(prefix) {
|
548 |
-
$(prefix + '_city').val();
|
549 |
-
}
|
550 |
-
},
|
551 |
-
postalCode: {
|
552 |
-
set: function(v, prefix) {
|
553 |
-
$(prefix + '_postcode').val(v);
|
554 |
-
},
|
555 |
-
get: function(prefix) {
|
556 |
-
$(prefix + '_postcode').val();
|
557 |
-
}
|
558 |
-
},
|
559 |
-
postal_code: {
|
560 |
-
set: function(v, prefix) {
|
561 |
-
$(prefix + '_postcode').val(v);
|
562 |
-
},
|
563 |
-
get: function(prefix) {
|
564 |
-
$(prefix + '_postcode').val();
|
565 |
-
}
|
566 |
-
}
|
567 |
}
|
568 |
}
|
569 |
|
570 |
/**
|
571 |
* @return {[type]}
|
572 |
*/
|
573 |
-
wc_stripe.BaseGateway.prototype.process_checkout = function() {
|
574 |
-
return new Promise(function(resolve, reject) {
|
575 |
this.block();
|
576 |
$.ajax({
|
577 |
url: this.params.routes.checkout,
|
578 |
method: 'POST',
|
579 |
dataType: 'json',
|
580 |
-
data: $.extend({}, this.
|
581 |
-
|
582 |
-
|
583 |
-
}
|
584 |
-
|
|
|
585 |
if (result.reload) {
|
586 |
window.location.reload();
|
587 |
return;
|
@@ -594,7 +495,7 @@
|
|
594 |
}
|
595 |
this.unblock();
|
596 |
}
|
597 |
-
}.bind(this)).fail(function(xhr, textStatus, errorThrown) {
|
598 |
this.unblock();
|
599 |
this.submit_error(errorThrown);
|
600 |
}.bind(this))
|
@@ -604,8 +505,8 @@
|
|
604 |
/**
|
605 |
* @return {[type]}
|
606 |
*/
|
607 |
-
wc_stripe.BaseGateway.prototype.serialize_form = function($form) {
|
608 |
-
var formData = $form.find('input').filter(function(i, e) {
|
609 |
if ($(e).is('[name^="add-to-cart"]')) {
|
610 |
return false;
|
611 |
}
|
@@ -621,14 +522,18 @@
|
|
621 |
return data;
|
622 |
}
|
623 |
|
|
|
|
|
|
|
|
|
624 |
/**
|
625 |
* @param {[type]}
|
626 |
* @return {[type]}
|
627 |
*/
|
628 |
-
wc_stripe.BaseGateway.prototype.map_shipping_methods = function(shippingData) {
|
629 |
var methods = {};
|
630 |
if (shippingData !== "default") {
|
631 |
-
var matches = shippingData.match(/^(\
|
632 |
if (matches.length > 1) {
|
633 |
methods[matches[1]] = matches[2];
|
634 |
}
|
@@ -640,28 +545,30 @@
|
|
640 |
* [maybe_set_ship_to_different description]
|
641 |
* @return {[type]} [description]
|
642 |
*/
|
643 |
-
wc_stripe.BaseGateway.prototype.maybe_set_ship_to_different = function() {
|
644 |
// if shipping and billing address are different,
|
645 |
// set the ship to different address option.
|
646 |
if ($('[name="ship_to_different_address"]').length) {
|
647 |
-
$('[name="ship_to_different_address"]').prop('checked', this.get_address_field_hash("
|
648 |
}
|
649 |
}
|
650 |
|
651 |
/**
|
652 |
* @return {[@event]}
|
653 |
*/
|
654 |
-
wc_stripe.BaseGateway.prototype.update_shipping_address = function(ev) {
|
655 |
-
return new Promise(function(resolve, reject) {
|
656 |
$.ajax({
|
657 |
url: this.params.routes.shipping_address,
|
658 |
method: 'POST',
|
659 |
dataType: 'json',
|
660 |
-
data: {
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
|
|
|
|
665 |
if (response.code) {
|
666 |
ev.updateWith(response.data.newData);
|
667 |
reject(response.data);
|
@@ -669,7 +576,7 @@
|
|
669 |
ev.updateWith(response.data.newData);
|
670 |
resolve(response.data);
|
671 |
}
|
672 |
-
}.bind(this)).fail(function(xhr, textStatus, errorThrown) {
|
673 |
|
674 |
}.bind(this))
|
675 |
}.bind(this))
|
@@ -678,17 +585,19 @@
|
|
678 |
/**
|
679 |
* @return {[@event]}
|
680 |
*/
|
681 |
-
wc_stripe.BaseGateway.prototype.update_shipping_method = function(ev) {
|
682 |
-
return new Promise(function(resolve, reject) {
|
683 |
$.ajax({
|
684 |
url: this.params.routes.shipping_method,
|
685 |
method: 'POST',
|
686 |
dataType: 'json',
|
687 |
-
data: {
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
|
|
|
|
692 |
if (response.code) {
|
693 |
ev.updateWith(response.data.newData);
|
694 |
reject(response.data);
|
@@ -697,7 +606,7 @@
|
|
697 |
ev.updateWith(response.data.newData);
|
698 |
resolve(response.data);
|
699 |
}
|
700 |
-
}.bind(this)).fail(function(xhr, textStatus, errorThrown) {
|
701 |
this.submit_error(errorThrown);
|
702 |
}.bind(this))
|
703 |
}.bind(this))
|
@@ -709,8 +618,8 @@
|
|
709 |
/**
|
710 |
* @constructor
|
711 |
*/
|
712 |
-
wc_stripe.CheckoutGateway = function() {
|
713 |
-
this.
|
714 |
this.banner_container = 'li.banner_payment_method_' + this.gateway_id;
|
715 |
$(document.body).on('update_checkout', this.update_checkout.bind(this));
|
716 |
$(document.body).on('updated_checkout', this.updated_checkout.bind(this));
|
@@ -731,7 +640,7 @@
|
|
731 |
this.order_review();
|
732 |
}
|
733 |
|
734 |
-
wc_stripe.CheckoutGateway.prototype.order_review = function() {
|
735 |
var url = window.location.href;
|
736 |
var matches = url.match(/order_review.+payment_method=([\w]+).+payment_nonce=(.+)/);
|
737 |
if (matches && matches.length > 1) {
|
@@ -748,17 +657,19 @@
|
|
748 |
/**
|
749 |
* Called on the WC updated_checkout event
|
750 |
*/
|
751 |
-
wc_stripe.CheckoutGateway.prototype.updated_checkout = function() {
|
|
|
752 |
|
753 |
/**
|
754 |
* Called on the WC update_checkout event
|
755 |
*/
|
756 |
-
wc_stripe.CheckoutGateway.prototype.update_checkout = function() {
|
|
|
757 |
|
758 |
/**
|
759 |
* Called on the WC checkout_error event
|
760 |
*/
|
761 |
-
wc_stripe.CheckoutGateway.prototype.checkout_error = function() {
|
762 |
if (this.has_checkout_error()) {
|
763 |
this.payment_token_received = false;
|
764 |
this.payment_response = null;
|
@@ -768,9 +679,9 @@
|
|
768 |
}
|
769 |
|
770 |
/**
|
771 |
-
*
|
772 |
*/
|
773 |
-
wc_stripe.CheckoutGateway.prototype.is_valid_checkout = function() {
|
774 |
if ($('[name="terms"]').length) {
|
775 |
if (!$('[name="terms"]').is(':checked')) {
|
776 |
return false;
|
@@ -781,21 +692,21 @@
|
|
781 |
|
782 |
/**
|
783 |
* Returns the selected payment gateway's id.
|
784 |
-
*
|
785 |
* @returns {String}
|
786 |
*/
|
787 |
-
wc_stripe.CheckoutGateway.prototype.get_payment_method = function() {
|
788 |
return $('[name="payment_method"]:checked').val();
|
789 |
}
|
790 |
|
791 |
-
wc_stripe.CheckoutGateway.prototype.set_use_new_option = function(bool) {
|
792 |
$('#' + this.gateway_id + '_use_new').prop("checked", bool).trigger('change');
|
793 |
}
|
794 |
|
795 |
/**
|
796 |
* Called on the WC checkout_place_order_{$gateway_id} event
|
797 |
*/
|
798 |
-
wc_stripe.CheckoutGateway.prototype.checkout_place_order = function() {
|
799 |
if (!this.is_valid_checkout()) {
|
800 |
this.submit_error(this.params.messages.terms);
|
801 |
return false;
|
@@ -809,9 +720,9 @@
|
|
809 |
* @param {[type]}
|
810 |
* @return {[type]}
|
811 |
*/
|
812 |
-
wc_stripe.CheckoutGateway.prototype.on_token_received = function(paymentMethod) {
|
813 |
this.payment_token_received = true;
|
814 |
-
|
815 |
this.hide_payment_button();
|
816 |
this.show_place_order();
|
817 |
}
|
@@ -819,7 +730,7 @@
|
|
819 |
/**
|
820 |
* @return {[type]}
|
821 |
*/
|
822 |
-
wc_stripe.CheckoutGateway.prototype.block = function() {
|
823 |
$('form.checkout').block({
|
824 |
message: null,
|
825 |
overlayCSS: {
|
@@ -832,18 +743,18 @@
|
|
832 |
/**
|
833 |
* @return {[type]}
|
834 |
*/
|
835 |
-
wc_stripe.CheckoutGateway.prototype.unblock = function() {
|
836 |
$('form.checkout').unblock();
|
837 |
}
|
838 |
|
839 |
-
wc_stripe.CheckoutGateway.prototype.hide_place_order = function() {
|
840 |
$('#place_order').addClass('wc-stripe-hide');
|
841 |
}
|
842 |
|
843 |
/**
|
844 |
* @return {[type]}
|
845 |
*/
|
846 |
-
wc_stripe.CheckoutGateway.prototype.show_place_order = function() {
|
847 |
$('#place_order').removeClass('wc-stripe-hide');
|
848 |
}
|
849 |
|
@@ -853,7 +764,7 @@
|
|
853 |
* @param {[String]}
|
854 |
* @return {[type]}
|
855 |
*/
|
856 |
-
wc_stripe.CheckoutGateway.prototype.on_show_new_methods = function() {
|
857 |
if (this.payment_token_received) {
|
858 |
this.show_place_order();
|
859 |
this.hide_payment_button();
|
@@ -869,7 +780,7 @@
|
|
869 |
* @param {[type]}
|
870 |
* @return {[type]}
|
871 |
*/
|
872 |
-
wc_stripe.CheckoutGateway.prototype.on_show_saved_methods = function() {
|
873 |
this.hide_payment_button();
|
874 |
this.show_place_order();
|
875 |
}
|
@@ -877,7 +788,7 @@
|
|
877 |
/**
|
878 |
* @return {[type]}
|
879 |
*/
|
880 |
-
wc_stripe.CheckoutGateway.prototype.show_payment_button = function() {
|
881 |
if (this.$button) {
|
882 |
this.$button.show();
|
883 |
}
|
@@ -886,7 +797,7 @@
|
|
886 |
/**
|
887 |
* @return {[type]}
|
888 |
*/
|
889 |
-
wc_stripe.CheckoutGateway.prototype.hide_payment_button = function() {
|
890 |
if (this.$button) {
|
891 |
this.$button.hide();
|
892 |
}
|
@@ -897,7 +808,7 @@
|
|
897 |
* any DOM events.
|
898 |
* @return {[type]}
|
899 |
*/
|
900 |
-
wc_stripe.CheckoutGateway.prototype.trigger_payment_method_selected = function() {
|
901 |
this.on_payment_method_selected(null, $('[name="payment_method"]:checked').val());
|
902 |
}
|
903 |
|
@@ -906,7 +817,7 @@
|
|
906 |
* @param {[type]}
|
907 |
* @return {[type]}
|
908 |
*/
|
909 |
-
wc_stripe.CheckoutGateway.prototype.on_payment_method_selected = function(e, payment_method) {
|
910 |
if (payment_method === this.gateway_id) {
|
911 |
if (this.payment_token_received || this.is_saved_method_selected()) {
|
912 |
this.hide_payment_button();
|
@@ -927,53 +838,54 @@
|
|
927 |
* [Return true if the banner option has been enabled for the gateway.]
|
928 |
* @return {[type]} [description]
|
929 |
*/
|
930 |
-
wc_stripe.CheckoutGateway.prototype.banner_enabled = function() {
|
931 |
return this.params.banner_enabled === "1";
|
932 |
}
|
933 |
|
934 |
-
wc_stripe.CheckoutGateway.prototype.checkout_fields_valid = function() {
|
935 |
-
if (typeof wc_stripe_checkout_fields == 'undefined') {
|
936 |
return true;
|
937 |
}
|
938 |
-
var billing = Object.keys(wc_stripe_checkout_fields.billing),
|
939 |
-
shipping = Object.keys(wc_stripe_checkout_fields.shipping);
|
940 |
valid = true;
|
941 |
|
942 |
-
function validateFields(
|
943 |
-
for (var
|
944 |
-
var field = fields[
|
945 |
-
if (field.required) {
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
|
|
|
|
950 |
}
|
951 |
}
|
952 |
}
|
953 |
}
|
954 |
|
955 |
-
validateFields(billing, wc_stripe_checkout_fields
|
956 |
|
957 |
if (this.needs_shipping() && $('#ship-to-different-address-checkbox').is(':checked')) {
|
958 |
-
validateFields(shipping, wc_stripe_checkout_fields
|
|
|
|
|
|
|
959 |
}
|
960 |
-
valid = this.is_valid_checkout();
|
961 |
return valid;
|
962 |
}
|
963 |
|
964 |
/************** Product Gateway ***************/
|
965 |
|
966 |
-
wc_stripe.ProductGateway = function() {
|
967 |
-
this.container = 'li.payment_method_' + this.gateway_id;
|
968 |
this.message_container = 'div.product';
|
969 |
|
970 |
// events
|
971 |
-
$(document.body).on('wc_stripe_updated_rest_nonce', this.set_rest_nonce.bind(this));
|
972 |
$('form.cart').on('found_variation', this.found_variation.bind(this));
|
973 |
$('form.cart').on('reset_data', this.reset_variation_data.bind(this));
|
974 |
|
975 |
this.buttonWidth = $('div.quantity').outerWidth(true) + $('.single_add_to_cart_button').outerWidth();
|
976 |
-
|
|
|
977 |
this.buttonWidth += parseInt(marginLeft.replace('px', ''));
|
978 |
}
|
979 |
$(this.container).css('max-width', this.buttonWidth + 'px');
|
@@ -982,7 +894,7 @@
|
|
982 |
/**
|
983 |
* @return {[@int]}
|
984 |
*/
|
985 |
-
wc_stripe.ProductGateway.prototype.get_quantity = function() {
|
986 |
return parseInt($('[name="quantity"]').val());
|
987 |
}
|
988 |
|
@@ -990,7 +902,7 @@
|
|
990 |
* @param {[type]}
|
991 |
* @param {[type]}
|
992 |
*/
|
993 |
-
wc_stripe.ProductGateway.prototype.set_rest_nonce = function(e, nonce) {
|
994 |
this.params.rest_nonce = nonce;
|
995 |
}
|
996 |
|
@@ -999,26 +911,29 @@
|
|
999 |
* @param {[type]}
|
1000 |
* @return {[type]}
|
1001 |
*/
|
1002 |
-
wc_stripe.ProductGateway.prototype.found_variation = function(e, variation) {
|
1003 |
-
var data = this.
|
1004 |
-
data.price = variation.display_price;
|
1005 |
data.needs_shipping = !variation.is_virtual;
|
1006 |
-
data.variation = variation;
|
1007 |
-
this.
|
1008 |
this.enable_payment_button();
|
1009 |
}
|
1010 |
|
1011 |
/**
|
1012 |
* @return {[type]}
|
1013 |
*/
|
1014 |
-
wc_stripe.ProductGateway.prototype.reset_variation_data = function() {
|
|
|
|
|
|
|
1015 |
this.disable_payment_button();
|
1016 |
}
|
1017 |
|
1018 |
/**
|
1019 |
* @return {[type]}
|
1020 |
*/
|
1021 |
-
wc_stripe.ProductGateway.prototype.disable_payment_button = function() {
|
1022 |
if (this.$button) {
|
1023 |
this.get_button().prop('disabled', true).addClass('disabled');
|
1024 |
}
|
@@ -1027,7 +942,7 @@
|
|
1027 |
/**
|
1028 |
* @return {[type]}
|
1029 |
*/
|
1030 |
-
wc_stripe.ProductGateway.prototype.enable_payment_button = function() {
|
1031 |
if (this.$button) {
|
1032 |
this.get_button().prop('disabled', false).removeClass('disabled');
|
1033 |
}
|
@@ -1036,61 +951,57 @@
|
|
1036 |
/**
|
1037 |
* @return {[type]}
|
1038 |
*/
|
1039 |
-
wc_stripe.ProductGateway.prototype.get_button = function() {
|
1040 |
return this.$button;
|
1041 |
}
|
1042 |
|
1043 |
/**
|
1044 |
* @return {Boolean}
|
1045 |
*/
|
1046 |
-
wc_stripe.ProductGateway.prototype.is_variable_product = function() {
|
1047 |
return $('[name="variation_id"]').length > 0;
|
1048 |
}
|
1049 |
|
1050 |
-
|
1051 |
-
|
1052 |
-
*/
|
1053 |
-
wc_stripe.ProductGateway.prototype.needs_shipping = function() {
|
1054 |
-
return this.get_product_data().needs_shipping;
|
1055 |
}
|
1056 |
|
1057 |
/**
|
1058 |
* @return {[type]}
|
1059 |
*/
|
1060 |
-
wc_stripe.ProductGateway.prototype.get_product_data = function() {
|
1061 |
-
return
|
1062 |
}
|
1063 |
|
1064 |
/**
|
1065 |
* @return {[type]}
|
1066 |
*/
|
1067 |
-
wc_stripe.ProductGateway.prototype.set_product_data = function(
|
1068 |
-
|
|
|
|
|
1069 |
}
|
1070 |
|
1071 |
/**
|
1072 |
* Add a product to the WC shopping cart
|
1073 |
*/
|
1074 |
-
wc_stripe.ProductGateway.prototype.add_to_cart = function() {
|
1075 |
-
return new Promise(function(resolve, reject) {
|
1076 |
this.block();
|
1077 |
$.ajax({
|
1078 |
url: this.params.routes.add_to_cart,
|
1079 |
method: 'POST',
|
1080 |
dataType: 'json',
|
1081 |
data: {
|
1082 |
-
product_id:
|
1083 |
variation_id: this.is_variable_product() ? $('[name="variation_id"]').val() : 0,
|
1084 |
qty: $('[name="quantity"]').val(),
|
1085 |
payment_method: this.gateway_id,
|
1086 |
page_id: this.get_page()
|
1087 |
},
|
1088 |
-
beforeSend:
|
1089 |
-
|
1090 |
-
}.bind(this)
|
1091 |
-
}).done(function(response, status, xhr) {
|
1092 |
this.unblock();
|
1093 |
-
$(document.body).triggerHandler('wc_stripe_updated_rest_nonce', xhr.getResponseHeader('X-WP-Nonce'));
|
1094 |
if (response.code) {
|
1095 |
this.submit_error(response.message);
|
1096 |
reject(response);
|
@@ -1100,39 +1011,37 @@
|
|
1100 |
this.set_display_items(response.data.displayItems);
|
1101 |
resolve(response.data);
|
1102 |
}
|
1103 |
-
}.bind(this)).fail(function(xhr, textStatus, errorThrown) {
|
1104 |
this.unblock();
|
1105 |
this.submit_error(errorThrown);
|
1106 |
}.bind(this))
|
1107 |
}.bind(this))
|
1108 |
}
|
1109 |
|
1110 |
-
wc_stripe.ProductGateway.prototype.cart_calculation = function(variation_id) {
|
1111 |
-
return new Promise(function(resolve, reject) {
|
1112 |
$.ajax({
|
1113 |
url: this.params.routes.cart_calculation,
|
1114 |
method: 'POST',
|
1115 |
dataType: 'json',
|
1116 |
data: {
|
1117 |
-
product_id:
|
1118 |
variation_id: this.is_variable_product() && variation_id ? variation_id : 0,
|
1119 |
qty: $('[name="quantity"]').val(),
|
1120 |
payment_method: this.gateway_id
|
1121 |
},
|
1122 |
-
beforeSend:
|
1123 |
-
|
1124 |
-
}.bind(this)
|
1125 |
-
}).done(function(response, status, xhr) {
|
1126 |
-
$(document.body).triggerHandler('wc_stripe_updated_rest_nonce', xhr.getResponseHeader('X-WP-Nonce'));
|
1127 |
if (response.code) {
|
1128 |
this.cart_calculation_error = true;
|
|
|
1129 |
} else {
|
1130 |
this.set_total_price(response.data.total);
|
1131 |
this.set_total_price_cents(response.data.totalCents);
|
1132 |
this.set_display_items(response.data.displayItems);
|
1133 |
resolve(response.data);
|
1134 |
}
|
1135 |
-
}.bind(this)).fail(function(xhr, textStatus, errorThrown) {
|
1136 |
|
1137 |
}.bind(this))
|
1138 |
}.bind(this))
|
@@ -1143,8 +1052,7 @@
|
|
1143 |
/**
|
1144 |
* @constructor
|
1145 |
*/
|
1146 |
-
wc_stripe.CartGateway = function() {
|
1147 |
-
this.container = 'li.payment_method_' + this.gateway_id;
|
1148 |
this.message_container = 'div.woocommerce';
|
1149 |
|
1150 |
// cart events
|
@@ -1153,15 +1061,11 @@
|
|
1153 |
$(document.body).on('wc_cart_emptied', this.cart_emptied.bind(this));
|
1154 |
}
|
1155 |
|
1156 |
-
wc_stripe.CartGateway.prototype.needs_shipping = function() {
|
1157 |
-
return $('#wc_stripe_needs_shipping').data('value') === 1;
|
1158 |
-
}
|
1159 |
-
|
1160 |
/**
|
1161 |
* @param {[type]}
|
1162 |
* @return {[type]}
|
1163 |
*/
|
1164 |
-
wc_stripe.CartGateway.prototype.submit_error = function(message) {
|
1165 |
this.submit_message(this.get_error_message(message));
|
1166 |
}
|
1167 |
|
@@ -1169,19 +1073,21 @@
|
|
1169 |
* @param {[@event]}
|
1170 |
* @return {[null]}
|
1171 |
*/
|
1172 |
-
wc_stripe.CartGateway.prototype.updated_html = function(e) {
|
1173 |
|
1174 |
}
|
1175 |
|
1176 |
-
wc_stripe.CartGateway.prototype.cart_emptied = function(e) {
|
|
|
1177 |
|
1178 |
-
wc_stripe.CartGateway.prototype.add_cart_totals_class = function() {
|
1179 |
$('.cart_totals').addClass('stripe_cart_gateway_active');
|
1180 |
}
|
1181 |
|
1182 |
/************* Google Pay Mixins **************/
|
1183 |
|
1184 |
-
wc_stripe.GooglePay = function() {
|
|
|
1185 |
|
1186 |
const googlePayBaseRequest = {
|
1187 |
apiVersion: 2,
|
@@ -1200,120 +1106,36 @@
|
|
1200 |
}
|
1201 |
}
|
1202 |
|
1203 |
-
/**
|
1204 |
-
* Retrun an object of address mappings.
|
1205 |
-
* @param {[type]}
|
1206 |
-
* @return {[type]}
|
1207 |
-
*/
|
1208 |
-
wc_stripe.GooglePay.prototype.address_mappings = function(prefix) {
|
1209 |
-
return {
|
1210 |
-
name: {
|
1211 |
-
set: function(v, prefix) {
|
1212 |
-
var name = v.split(" ");
|
1213 |
-
$(prefix + '_first_name').val(name[0]);
|
1214 |
-
$(prefix + '_last_name').val(name[1]);
|
1215 |
-
},
|
1216 |
-
get: function(prefix) {
|
1217 |
-
return $(prefix + '_first_name').val() + $(prefix + '_last_name').val()
|
1218 |
-
}
|
1219 |
-
},
|
1220 |
-
postalCode: {
|
1221 |
-
set: function(v, prefix) {
|
1222 |
-
$(prefix + '_postcode').val(v);
|
1223 |
-
},
|
1224 |
-
get: function(prefix) {
|
1225 |
-
return $(prefix + '_postcode').val();
|
1226 |
-
}
|
1227 |
-
},
|
1228 |
-
countryCode: {
|
1229 |
-
set: function(v, prefix) {
|
1230 |
-
$(prefix + '_country').val(v);
|
1231 |
-
},
|
1232 |
-
get: function(prefix) {
|
1233 |
-
return $(prefix + '_country').val();
|
1234 |
-
}
|
1235 |
-
},
|
1236 |
-
phoneNumber: {
|
1237 |
-
set: function(v, prefix) {
|
1238 |
-
$('#billing_phone').val(v);
|
1239 |
-
},
|
1240 |
-
get: function() {
|
1241 |
-
return ('#billing_phone').val();
|
1242 |
-
}
|
1243 |
-
},
|
1244 |
-
address1: {
|
1245 |
-
set: function(v, prefix) {
|
1246 |
-
$(prefix + '_address_1').val(v);
|
1247 |
-
},
|
1248 |
-
get: function(prefix) {
|
1249 |
-
return $(prefix + '_address_1').val();
|
1250 |
-
}
|
1251 |
-
},
|
1252 |
-
address2: {
|
1253 |
-
set: function(v, prefix) {
|
1254 |
-
$(prefix + '_address_2').val(v);
|
1255 |
-
},
|
1256 |
-
get: function(prefix) {
|
1257 |
-
return $(prefix + '_address_2').val();
|
1258 |
-
}
|
1259 |
-
},
|
1260 |
-
locality: {
|
1261 |
-
set: function(v, prefix) {
|
1262 |
-
$(prefix + '_city').val(v);
|
1263 |
-
},
|
1264 |
-
get: function(prefix) {
|
1265 |
-
return $(prefix + '_city').val();
|
1266 |
-
}
|
1267 |
-
},
|
1268 |
-
administrativeArea: {
|
1269 |
-
set: function(v, prefix) {
|
1270 |
-
$(prefix + '_state').val(v);
|
1271 |
-
},
|
1272 |
-
get: function(prefix) {
|
1273 |
-
return $(prefix + '_state').val();
|
1274 |
-
}
|
1275 |
-
}
|
1276 |
-
}
|
1277 |
-
}
|
1278 |
-
|
1279 |
-
wc_stripe.GooglePay.prototype.serialize_form = function($form) {
|
1280 |
-
return $.extend({}, wc_stripe.BaseGateway.prototype.serialize_form.apply(this, arguments), {
|
1281 |
-
order_review: !this.dynamic_price_enabled()
|
1282 |
-
});
|
1283 |
-
}
|
1284 |
-
|
1285 |
/**
|
1286 |
* Populate the WC checkout fields.
|
1287 |
* @param {[type]}
|
1288 |
* @return {[type]}
|
1289 |
*/
|
1290 |
-
wc_stripe.GooglePay.prototype.populate_address_fields = function(paymentData) {
|
1291 |
-
var billingAddress = paymentData.paymentMethodData.info.billingAddress
|
1292 |
-
addressMappings = this.address_mappings();
|
1293 |
for (var k in billingAddress) {
|
1294 |
-
|
1295 |
-
addressMappings[k].set.call(this, billingAddress[k], "#billing");
|
1296 |
-
}
|
1297 |
}
|
1298 |
if (paymentData.shippingAddress) {
|
1299 |
for (var k in paymentData.shippingAddress) {
|
1300 |
-
|
1301 |
-
addressMappings[k].set.call(this, paymentData.shippingAddress[k], "#shipping");
|
1302 |
-
}
|
1303 |
}
|
1304 |
}
|
1305 |
if (paymentData.email) {
|
1306 |
-
|
|
|
|
|
|
|
|
|
|
|
1307 |
}
|
1308 |
-
this.maybe_set_ship_to_different();
|
1309 |
-
$('[name="billing_country"]').trigger('change');
|
1310 |
}
|
1311 |
|
1312 |
/**
|
1313 |
* @param {[type]}
|
1314 |
* @return {[type]}
|
1315 |
*/
|
1316 |
-
wc_stripe.GooglePay.prototype.map_address = function(address) {
|
1317 |
return {
|
1318 |
city: address.locality,
|
1319 |
postcode: address.postalCode,
|
@@ -1326,28 +1148,26 @@
|
|
1326 |
* @param {[type]}
|
1327 |
* @return {[type]}
|
1328 |
*/
|
1329 |
-
wc_stripe.GooglePay.prototype.update_payment_data = function(data) {
|
1330 |
-
return new Promise(function(resolve, reject) {
|
|
|
1331 |
$.when($.ajax({
|
1332 |
url: this.params.routes.payment_data,
|
1333 |
dataType: 'json',
|
1334 |
method: 'POST',
|
1335 |
data: {
|
1336 |
shipping_address: this.map_address(data.shippingAddress),
|
1337 |
-
|
1338 |
-
shipping_method_id: data.shippingOptionData.id,
|
1339 |
page_id: this.get_page()
|
1340 |
},
|
1341 |
-
beforeSend:
|
1342 |
-
|
1343 |
-
}.bind(this)
|
1344 |
-
})).done(function(response) {
|
1345 |
if (response.code) {
|
1346 |
reject(response.data.data);
|
1347 |
} else {
|
1348 |
resolve(response.data);
|
1349 |
}
|
1350 |
-
}.bind(this)).fail(function() {
|
1351 |
reject();
|
1352 |
}.bind(this))
|
1353 |
}.bind(this))
|
@@ -1357,13 +1177,13 @@
|
|
1357 |
* @param {[type]}
|
1358 |
* @return {[type]}
|
1359 |
*/
|
1360 |
-
wc_stripe.GooglePay.prototype.on_payment_data_changed = function(address) {
|
1361 |
-
return new Promise(function(resolve, reject) {
|
1362 |
-
this.update_payment_data(address).then(function(response) {
|
1363 |
resolve(response.paymentRequestUpdate);
|
1364 |
this.set_selected_shipping_methods(response.shipping_methods);
|
1365 |
this.payment_data_updated(response, address);
|
1366 |
-
}.bind(this)).catch(function(data) {
|
1367 |
resolve(data);
|
1368 |
}.bind(this))
|
1369 |
}.bind(this))
|
@@ -1375,38 +1195,14 @@
|
|
1375 |
* @param {[type]}
|
1376 |
* @return {[type]}
|
1377 |
*/
|
1378 |
-
wc_stripe.GooglePay.prototype.payment_data_updated = function(response) {
|
1379 |
-
|
1380 |
-
}
|
1381 |
-
|
1382 |
-
/**
|
1383 |
-
* Return an array of line items for display in the Google payment sheet
|
1384 |
-
* @return {[type]}
|
1385 |
-
*/
|
1386 |
-
wc_stripe.GooglePay.prototype.get_googlepay_display_items = function() {
|
1387 |
-
return $('#googlepay_display_items').data('items');
|
1388 |
-
}
|
1389 |
-
|
1390 |
-
/**
|
1391 |
-
* Set the display items in the DOM as a data attribute.
|
1392 |
-
* @param {[type]}
|
1393 |
-
*/
|
1394 |
-
wc_stripe.GooglePay.prototype.set_googlepay_display_items = function(displayItems) {
|
1395 |
-
$('#googlepay_display_items').data('items', displayItems);
|
1396 |
-
}
|
1397 |
|
1398 |
-
/**
|
1399 |
-
* Return an array of shipping options for display in the Google payment sheet
|
1400 |
-
* @return {[type]}
|
1401 |
-
*/
|
1402 |
-
wc_stripe.GooglePay.prototype.get_shipping_options = function() {
|
1403 |
-
return $('#googlepay_shipping_options').data('items');
|
1404 |
}
|
1405 |
|
1406 |
/**
|
1407 |
* @return {[type]}
|
1408 |
*/
|
1409 |
-
wc_stripe.GooglePay.prototype.get_merchant_info = function() {
|
1410 |
var options = {
|
1411 |
merchantId: this.params.merchant_id,
|
1412 |
merchantName: this.params.merchant_name
|
@@ -1417,39 +1213,29 @@
|
|
1417 |
return options;
|
1418 |
}
|
1419 |
|
1420 |
-
/**
|
1421 |
-
* Return true if dynamic pricing is enabled.
|
1422 |
-
* @return {[type]} [description]
|
1423 |
-
*/
|
1424 |
-
wc_stripe.GooglePay.prototype.dynamic_price_enabled = function() {
|
1425 |
-
return this.params.dynamic_price === "1";
|
1426 |
-
}
|
1427 |
-
|
1428 |
/**
|
1429 |
* @return {[type]}
|
1430 |
*/
|
1431 |
-
wc_stripe.GooglePay.prototype.get_payment_options = function() {
|
1432 |
var options = {
|
1433 |
environment: this.params.environment,
|
1434 |
merchantInfo: this.get_merchant_info()
|
1435 |
}
|
1436 |
-
if (this.
|
1437 |
-
|
1438 |
-
|
1439 |
-
|
1440 |
-
|
1441 |
-
|
1442 |
-
|
1443 |
-
|
1444 |
-
|
1445 |
-
|
1446 |
-
|
1447 |
-
|
1448 |
-
|
1449 |
-
|
1450 |
-
|
1451 |
-
}.bind(this))
|
1452 |
-
}
|
1453 |
}
|
1454 |
}
|
1455 |
}
|
@@ -1459,9 +1245,9 @@
|
|
1459 |
/**
|
1460 |
* @return {[type]}
|
1461 |
*/
|
1462 |
-
wc_stripe.GooglePay.prototype.build_payment_request = function() {
|
1463 |
var request = $.extend({}, googlePayBaseRequest, {
|
1464 |
-
emailRequired:
|
1465 |
merchantInfo: this.get_merchant_info(),
|
1466 |
allowedPaymentMethods: [$.extend({
|
1467 |
type: "CARD",
|
@@ -1479,26 +1265,24 @@
|
|
1479 |
currencyCode: this.get_currency(),
|
1480 |
totalPriceStatus: "ESTIMATED",
|
1481 |
totalPrice: this.get_total_price().toString(),
|
1482 |
-
displayItems: this.
|
1483 |
totalPriceLabel: this.params.total_price_label
|
1484 |
}
|
1485 |
})
|
1486 |
request.allowedPaymentMethods[0].parameters['billingAddressRequired'] = true;
|
1487 |
request.allowedPaymentMethods[0].parameters['billingAddressParameters'] = {
|
1488 |
format: "FULL",
|
1489 |
-
phoneNumberRequired:
|
1490 |
-
}
|
1491 |
-
if (this.
|
1492 |
-
|
1493 |
-
|
1494 |
-
|
1495 |
-
|
1496 |
-
|
1497 |
-
|
1498 |
-
|
1499 |
-
|
1500 |
-
request['callbackIntents'] = ["PAYMENT_AUTHORIZATION"];
|
1501 |
-
}
|
1502 |
}
|
1503 |
return request;
|
1504 |
}
|
@@ -1506,28 +1290,28 @@
|
|
1506 |
/**
|
1507 |
* @return {[type]}
|
1508 |
*/
|
1509 |
-
wc_stripe.GooglePay.prototype.createPaymentsClient = function() {
|
1510 |
this.paymentsClient = new google.payments.api.PaymentsClient(this.get_payment_options());
|
1511 |
}
|
1512 |
|
1513 |
/**
|
1514 |
* @return {Promise}
|
1515 |
*/
|
1516 |
-
wc_stripe.GooglePay.prototype.isReadyToPay = function() {
|
1517 |
-
return new Promise(function(resolve) {
|
1518 |
var isReadyToPayRequest = $.extend({}, googlePayBaseRequest);
|
1519 |
isReadyToPayRequest.allowedPaymentMethods = [baseCardPaymentMethod];
|
1520 |
-
this.paymentsClient.isReadyToPay(isReadyToPayRequest).then(function() {
|
1521 |
this.can_pay = true;
|
1522 |
this.create_button();
|
1523 |
resolve();
|
1524 |
-
}.bind(this)).catch(function(err) {
|
1525 |
this.submit_error(err);
|
1526 |
}.bind(this))
|
1527 |
}.bind(this))
|
1528 |
}
|
1529 |
|
1530 |
-
wc_stripe.GooglePay.prototype.create_button = function() {
|
1531 |
if (this.$button) {
|
1532 |
this.$button.remove();
|
1533 |
}
|
@@ -1542,14 +1326,14 @@
|
|
1542 |
/**
|
1543 |
* @return {[type]}
|
1544 |
*/
|
1545 |
-
wc_stripe.GooglePay.prototype.start = function() {
|
1546 |
// always recreate the paymentClient to ensure latest data is used.
|
1547 |
this.createPaymentsClient();
|
1548 |
-
this.paymentsClient.loadPaymentData(this.build_payment_request()).then(function(paymentData) {
|
1549 |
var data = JSON.parse(paymentData.paymentMethodData.tokenizationData.token);
|
1550 |
this.populate_address_fields(paymentData);
|
1551 |
this.on_token_received(data);
|
1552 |
-
}.bind(this)).catch(function(err) {
|
1553 |
if (err.statusCode === "CANCELED") {
|
1554 |
return;
|
1555 |
}
|
@@ -1566,20 +1350,24 @@
|
|
1566 |
/**
|
1567 |
* @constructor
|
1568 |
*/
|
1569 |
-
wc_stripe.ApplePay = function() {
|
1570 |
|
1571 |
}
|
1572 |
|
1573 |
/**
|
1574 |
* @return {[type]}
|
1575 |
*/
|
1576 |
-
wc_stripe.ApplePay.prototype.initialize = function() {
|
1577 |
-
|
|
|
|
|
|
|
|
|
1578 |
this.createPaymentRequest();
|
1579 |
this.canMakePayment();
|
1580 |
}
|
1581 |
|
1582 |
-
wc_stripe.ApplePay.prototype.create_button = function() {
|
1583 |
if (this.$button) {
|
1584 |
this.$button.remove();
|
1585 |
}
|
@@ -1590,9 +1378,9 @@
|
|
1590 |
/**
|
1591 |
* @return {[type]}
|
1592 |
*/
|
1593 |
-
wc_stripe.ApplePay.prototype.canMakePayment = function() {
|
1594 |
-
return new Promise(function(resolve, reject) {
|
1595 |
-
this.paymentRequest.canMakePayment().then(function(result) {
|
1596 |
if (result && result.applePay) {
|
1597 |
this.can_pay = true;
|
1598 |
this.create_button();
|
@@ -1606,7 +1394,7 @@
|
|
1606 |
/**
|
1607 |
* @return {[type]}
|
1608 |
*/
|
1609 |
-
wc_stripe.ApplePay.prototype.start = function(e) {
|
1610 |
e.preventDefault();
|
1611 |
this.paymentRequest.update(this.get_payment_request_update({
|
1612 |
total: {
|
@@ -1618,7 +1406,7 @@
|
|
1618 |
|
1619 |
/*********** PaymentRequest *********/
|
1620 |
|
1621 |
-
wc_stripe.PaymentRequest = function() {
|
1622 |
|
1623 |
}
|
1624 |
|
@@ -1626,7 +1414,7 @@
|
|
1626 |
* [initialize description]
|
1627 |
* @return {[type]} [description]
|
1628 |
*/
|
1629 |
-
wc_stripe.PaymentRequest.prototype.initialize = function() {
|
1630 |
this.createPaymentRequest();
|
1631 |
this.canMakePayment();
|
1632 |
this.paymentRequestButton = this.createPaymentRequestButton();
|
@@ -1638,13 +1426,14 @@
|
|
1638 |
* @param {[type]} event [description]
|
1639 |
* @return {[type]} [description]
|
1640 |
*/
|
1641 |
-
wc_stripe.PaymentRequest.prototype.button_click = function(event) {
|
|
|
1642 |
|
1643 |
/**
|
1644 |
* [createPaymentRequestButton description]
|
1645 |
* @return {[type]} [description]
|
1646 |
*/
|
1647 |
-
wc_stripe.PaymentRequest.prototype.createPaymentRequestButton = function() {
|
1648 |
return this.elements.create("paymentRequestButton", {
|
1649 |
paymentRequest: this.paymentRequest,
|
1650 |
style: {
|
@@ -1661,9 +1450,9 @@
|
|
1661 |
* [canMakePayment description]
|
1662 |
* @return {[type]} [description]
|
1663 |
*/
|
1664 |
-
wc_stripe.PaymentRequest.prototype.canMakePayment = function() {
|
1665 |
-
return new Promise(function(resolve, reject) {
|
1666 |
-
this.paymentRequest.canMakePayment().then(function(result) {
|
1667 |
if (result && !result.applePay) {
|
1668 |
this.can_pay = true;
|
1669 |
this.create_button();
|
@@ -1678,12 +1467,248 @@
|
|
1678 |
* [create_button description]
|
1679 |
* @return {[type]} [description]
|
1680 |
*/
|
1681 |
-
wc_stripe.PaymentRequest.prototype.create_button = function() {
|
1682 |
this.paymentRequestButton.mount('#wc-stripe-payment-request-container');
|
1683 |
}
|
1684 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1685 |
try {
|
1686 |
-
stripe = Stripe(wc_stripe_params_v3.api_key, {
|
1687 |
} catch (error) {
|
1688 |
window.alert(error);
|
1689 |
console.log(error);
|
1 |
+
(function (window, $) {
|
2 |
window.wc_stripe = {};
|
3 |
var stripe = null;
|
4 |
|
5 |
+
if (typeof wc_stripe_checkout_fields === 'undefined') {
|
6 |
+
wc_stripe_checkout_fields = [];
|
7 |
+
}
|
8 |
+
|
9 |
/**
|
10 |
+
* @consructorget_total_price
|
11 |
*/
|
12 |
+
wc_stripe.BaseGateway = function (params) {
|
13 |
this.params = params;
|
14 |
this.gateway_id = this.params.gateway_id;
|
15 |
+
this.container = 'li.payment_method_' + this.gateway_id;
|
16 |
this.token_selector = this.params.token_selector;
|
17 |
this.saved_method_selector = this.params.saved_method_selector;
|
|
|
18 |
this.payment_token_received = false;
|
19 |
this.stripe = stripe;
|
20 |
+
this.elements = stripe.elements($.extend({}, {locale: 'auto'}, this.get_element_options()));
|
21 |
+
this.mappings = new wc_stripe.CheckoutFields(wc_stripe_checkout_fields);
|
22 |
this.initialize();
|
23 |
}
|
24 |
|
25 |
+
wc_stripe.BaseGateway.prototype.get_page = function () {
|
26 |
return wc_stripe_params_v3.page;
|
27 |
}
|
28 |
|
29 |
+
wc_stripe.BaseGateway.prototype.set_nonce = function (value) {
|
30 |
+
this.mappings.set(this.gateway_id + '_token_key', value);
|
31 |
$(this.token_selector).val(value);
|
32 |
}
|
33 |
|
35 |
* [get_element_options description]
|
36 |
* @return {[type]} [description]
|
37 |
*/
|
38 |
+
wc_stripe.BaseGateway.prototype.get_element_options = function () {
|
39 |
return {};
|
40 |
}
|
41 |
|
42 |
+
wc_stripe.BaseGateway.prototype.initialize = function () {
|
43 |
+
};
|
44 |
|
45 |
/**
|
46 |
* @return {[type]}
|
47 |
*/
|
48 |
+
wc_stripe.BaseGateway.prototype.create_button = function () {
|
49 |
+
}
|
50 |
|
51 |
/**
|
52 |
* @returns {Boolean}
|
53 |
*/
|
54 |
+
wc_stripe.BaseGateway.prototype.is_gateway_selected = function () {
|
55 |
return $('[name="payment_method"]:checked').val() === this.gateway_id;
|
56 |
}
|
57 |
|
58 |
/**
|
59 |
* @returns {Boolean}
|
60 |
*/
|
61 |
+
wc_stripe.BaseGateway.prototype.is_saved_method_selected = function () {
|
62 |
+
return this.is_gateway_selected() && $('[name="' + this.gateway_id + '_payment_type_key"]:checked').val() === 'saved';
|
|
|
|
|
|
|
63 |
}
|
64 |
|
65 |
/**
|
66 |
* @return {Boolean}
|
67 |
*/
|
68 |
+
wc_stripe.BaseGateway.prototype.has_checkout_error = function () {
|
69 |
return $('#wc_stripe_checkout_error').length > 0 && this.is_gateway_selected();
|
70 |
}
|
71 |
|
73 |
* @param {[type]}
|
74 |
* @return {[type]}
|
75 |
*/
|
76 |
+
wc_stripe.BaseGateway.prototype.submit_error = function (message) {
|
77 |
message = this.get_error_message(message);
|
78 |
if (message.indexOf('</ul>') == -1) {
|
79 |
message = '<div class="woocommerce-error">' + message + '</div>';
|
81 |
this.submit_message(message);
|
82 |
}
|
83 |
|
84 |
+
wc_stripe.BaseGateway.prototype.submit_error_code = function (code) {
|
85 |
|
86 |
}
|
87 |
|
88 |
+
wc_stripe.BaseGateway.prototype.get_error_message = function (message) {
|
89 |
if (typeof message == 'object' && message.code) {
|
90 |
if (wc_stripe_messages[message.code]) {
|
91 |
message = wc_stripe_messages[message.code];
|
100 |
* @param {[type]}
|
101 |
* @return {[type]}
|
102 |
*/
|
103 |
+
wc_stripe.BaseGateway.prototype.submit_message = function (message) {
|
104 |
$('.woocommerce-error, .woocommerce-message, .woocommerce-info')
|
105 |
.remove();
|
106 |
var $container = $(this.message_container);
|
119 |
}
|
120 |
}
|
121 |
|
122 |
+
wc_stripe.BaseGateway.prototype.get_first_name = function (prefix) {
|
123 |
return $('#' + prefix + '_first_name').val();
|
124 |
}
|
125 |
|
126 |
+
wc_stripe.BaseGateway.prototype.get_last_name = function (prefix) {
|
127 |
return $('#' + prefix + '_last_name').val();
|
128 |
}
|
129 |
|
130 |
/**
|
131 |
* Return true if the source should be saved.
|
132 |
+
*
|
133 |
* @returns {Boolean}
|
134 |
*/
|
135 |
+
wc_stripe.BaseGateway.prototype.should_save_method = function () {
|
136 |
return $('#' + this.gateway_id + '_save_source_key').is(':checked');
|
137 |
}
|
138 |
|
139 |
+
wc_stripe.BaseGateway.prototype.is_add_payment_method_page = function () {
|
140 |
+
return this.get_page() === 'add_payment_method' || $(document.body).hasClass('woocommerce-add-payment-method');
|
141 |
}
|
142 |
|
143 |
+
wc_stripe.BaseGateway.prototype.is_change_payment_method = function () {
|
144 |
+
return this.get_page() === 'change_payment_method';
|
145 |
+
}
|
146 |
+
|
147 |
+
wc_stripe.BaseGateway.prototype.get_selected_payment_method = function () {
|
148 |
return $(this.saved_method_selector).val();
|
149 |
}
|
150 |
|
151 |
+
wc_stripe.BaseGateway.prototype.needs_shipping = function () {
|
152 |
+
return this.get_gateway_data().needs_shipping;
|
153 |
+
}
|
154 |
+
|
155 |
+
wc_stripe.BaseGateway.prototype.get_currency = function () {
|
156 |
+
return this.get_gateway_data().currency;
|
157 |
}
|
158 |
|
159 |
+
wc_stripe.BaseGateway.prototype.get_gateway_data = function () {
|
160 |
+
return $('#' + this.gateway_id + '_' + this.get_page() + '_data').data('gateway');
|
161 |
}
|
162 |
|
163 |
+
wc_stripe.BaseGateway.prototype.set_gateway_data = function (data) {
|
164 |
+
$('#' + this.gateway_id + '_' + this.get_page() + '_data').data('gateway', data);
|
165 |
}
|
166 |
|
167 |
/**
|
168 |
* [get_customer_name description]
|
169 |
* @return {[type]} [description]
|
170 |
*/
|
171 |
+
wc_stripe.BaseGateway.prototype.get_customer_name = function (prefix) {
|
172 |
return $(prefix + '_first_name').val() + ' ' + $(prefix + '_last_name').val();
|
173 |
}
|
174 |
|
176 |
* [get_customer_email description]
|
177 |
* @return {[type]} [description]
|
178 |
*/
|
179 |
+
wc_stripe.BaseGateway.prototype.get_customer_email = function () {
|
180 |
return $('#billing_email').val();
|
181 |
}
|
182 |
|
185 |
* @param {[type]}
|
186 |
* @return {[type]}
|
187 |
*/
|
188 |
+
wc_stripe.BaseGateway.prototype.get_address_field_hash = function (prefix) {
|
189 |
+
var params = ['_first_name', '_last_name', '_address_1', '_address_2', '_postcode', '_city', '_state', '_country',];
|
190 |
var hash = "";
|
191 |
for (var i = 0; i < params.length; i++) {
|
192 |
+
hash += this.mappings.get(prefix + params[i]) + '_';
|
193 |
}
|
194 |
return hash;
|
195 |
}
|
197 |
/**
|
198 |
* @return {[type]}
|
199 |
*/
|
200 |
+
wc_stripe.BaseGateway.prototype.block = function () {
|
201 |
$.blockUI({
|
202 |
message: null,
|
203 |
overlayCSS: {
|
210 |
/**
|
211 |
* @return {[type]}
|
212 |
*/
|
213 |
+
wc_stripe.BaseGateway.prototype.unblock = function () {
|
214 |
$.unblockUI();
|
215 |
}
|
216 |
|
217 |
/**
|
218 |
* @return {[type]}
|
219 |
*/
|
220 |
+
wc_stripe.BaseGateway.prototype.get_form = function () {
|
221 |
return $(this.token_selector).closest('form');
|
222 |
}
|
223 |
|
224 |
/**
|
225 |
* @return {[type]}
|
226 |
*/
|
227 |
+
wc_stripe.BaseGateway.prototype.get_total_price = function () {
|
228 |
+
return this.get_gateway_data().total;
|
229 |
}
|
230 |
|
231 |
+
wc_stripe.BaseGateway.prototype.get_total_price_cents = function () {
|
232 |
+
return this.get_gateway_data().total_cents;
|
233 |
}
|
234 |
|
235 |
/**
|
236 |
* @return {[type]}
|
237 |
*/
|
238 |
+
wc_stripe.BaseGateway.prototype.set_total_price = function (total) {
|
239 |
+
var data = this.get_gateway_data();
|
240 |
+
data.total = total;
|
241 |
+
this.set_gateway_data(data);
|
242 |
}
|
243 |
|
244 |
/**
|
245 |
* @return {[type]}
|
246 |
*/
|
247 |
+
wc_stripe.BaseGateway.prototype.set_total_price_cents = function (total) {
|
248 |
+
var data = this.get_gateway_data();
|
249 |
+
data.total_cents = total;
|
250 |
+
this.set_gateway_data(data);
|
251 |
}
|
252 |
|
253 |
/**
|
254 |
* [set_payment_method description]
|
255 |
* @param {[type]} payment_method [description]
|
256 |
*/
|
257 |
+
wc_stripe.BaseGateway.prototype.set_payment_method = function (payment_method) {
|
258 |
$('[name="payment_method"][value="' + payment_method + '"]').prop("checked", true).trigger('click');
|
259 |
}
|
260 |
|
261 |
/**
|
262 |
* [set_shipping_methods description]
|
263 |
*/
|
264 |
+
wc_stripe.BaseGateway.prototype.set_selected_shipping_methods = function (shipping_methods) {
|
265 |
if (shipping_methods && $('[name^="shipping_method"]').length) {
|
266 |
for (var i in shipping_methods) {
|
267 |
var method = shipping_methods[i];
|
274 |
* @param {[type]}
|
275 |
* @return {[type]}
|
276 |
*/
|
277 |
+
wc_stripe.BaseGateway.prototype.on_token_received = function (paymentMethod) {
|
278 |
this.payment_token_received = true;
|
279 |
+
this.set_nonce(paymentMethod.id);
|
280 |
this.process_checkout();
|
281 |
}
|
282 |
|
283 |
+
wc_stripe.BaseGateway.prototype.createPaymentRequest = function () {
|
284 |
try {
|
285 |
this.paymentRequest = stripe.paymentRequest(this.get_payment_request_options());
|
286 |
} catch (err) {
|
299 |
/**
|
300 |
* @return {[Object]}
|
301 |
*/
|
302 |
+
wc_stripe.BaseGateway.prototype.get_payment_request_options = function () {
|
303 |
var options = {
|
304 |
country: this.params.country_code,
|
305 |
currency: this.get_currency().toLowerCase(),
|
309 |
pending: true
|
310 |
},
|
311 |
requestPayerName: true,
|
312 |
+
requestPayerEmail: this.mappings.required('billing_email'),
|
313 |
+
requestPayerPhone: this.mappings.required('billing_phone'),
|
314 |
requestShipping: this.needs_shipping()
|
315 |
}
|
316 |
var displayItems = this.get_display_items(),
|
327 |
/**
|
328 |
* @return {[Object]}
|
329 |
*/
|
330 |
+
wc_stripe.BaseGateway.prototype.get_payment_request_update = function (data) {
|
331 |
var options = {
|
332 |
currency: this.get_currency().toLowerCase(),
|
333 |
total: {
|
353 |
/**
|
354 |
* @return {[type]}
|
355 |
*/
|
356 |
+
wc_stripe.BaseGateway.prototype.get_display_items = function () {
|
357 |
+
return this.get_gateway_data().items;
|
358 |
}
|
359 |
|
360 |
/**
|
361 |
* @return {[type]}
|
362 |
*/
|
363 |
+
wc_stripe.BaseGateway.prototype.set_display_items = function (items) {
|
364 |
+
var data = this.get_gateway_data();
|
365 |
+
data.items = items;
|
366 |
+
this.set_gateway_data(data);
|
367 |
}
|
368 |
|
369 |
/**
|
370 |
* Return an array of shipping options for display in the Google payment sheet
|
371 |
* @return {[type]}
|
372 |
*/
|
373 |
+
wc_stripe.BaseGateway.prototype.get_shipping_options = function () {
|
374 |
+
return this.get_gateway_data().shipping_options;
|
375 |
}
|
376 |
|
377 |
/**
|
378 |
* Update the shipping options.
|
379 |
* @param {[type]}
|
380 |
*/
|
381 |
+
wc_stripe.BaseGateway.prototype.set_shipping_options = function (items) {
|
382 |
+
var data = this.get_gateway_data();
|
383 |
+
data.shipping_options = items;
|
384 |
+
this.set_gateway_data(data);
|
385 |
}
|
386 |
|
387 |
/**
|
389 |
* @param {[type]}
|
390 |
* @return {[type]}
|
391 |
*/
|
392 |
+
wc_stripe.BaseGateway.prototype.map_address = function (address) {
|
393 |
return {
|
394 |
city: address.city,
|
395 |
postcode: address.postalCode,
|
402 |
* @param {[type]}
|
403 |
* @return {[type]}
|
404 |
*/
|
405 |
+
wc_stripe.BaseGateway.prototype.on_payment_method_received = function (paymentResponse) {
|
406 |
try {
|
407 |
this.payment_response = paymentResponse;
|
408 |
this.populate_checkout_fields(paymentResponse);
|
416 |
/**
|
417 |
* @return {[type]}
|
418 |
*/
|
419 |
+
wc_stripe.BaseGateway.prototype.populate_checkout_fields = function (data) {
|
420 |
+
this.set_nonce(data.paymentMethod.id);
|
421 |
this.populate_address_fields(data);
|
422 |
}
|
423 |
|
425 |
* @param {[type]}
|
426 |
* @return {[type]}
|
427 |
*/
|
428 |
+
wc_stripe.BaseGateway.prototype.populate_address_fields = function (data) {
|
|
|
429 |
if (data.payerName) {
|
430 |
+
this.mappings.set('name', data.payerName, 'billing');
|
431 |
}
|
432 |
if (data.payerEmail) {
|
433 |
+
this.mappings.set('email', data.payerEmail, 'billing');
|
434 |
}
|
435 |
if (data.payerPhone) {
|
436 |
+
this.mappings.set('phone', data.payerPhone, 'billing');
|
437 |
}
|
438 |
if (data.shippingAddress) {
|
439 |
var address = data.shippingAddress;
|
440 |
for (var k in address) {
|
441 |
+
this.mappings.set(k, address[k], 'shipping');
|
|
|
|
|
442 |
}
|
443 |
}
|
444 |
if (data.paymentMethod.billing_details.address) {
|
445 |
var address = data.paymentMethod.billing_details.address;
|
446 |
for (var k in address) {
|
447 |
+
this.mappings.set(k, address[k], 'billing');
|
|
|
|
|
448 |
}
|
449 |
}
|
450 |
+
if ('checkout' === this.get_page()) {
|
451 |
+
this.maybe_set_ship_to_different();
|
452 |
+
this.mappings.toFormFields();
|
453 |
+
$('[name="billing_country"]').trigger('change');
|
454 |
+
}
|
455 |
}
|
456 |
|
457 |
/**
|
458 |
* @return {[type]}
|
459 |
*/
|
460 |
+
wc_stripe.BaseGateway.prototype.address_mappings = function () {
|
461 |
+
return new wc_stripe.CheckoutFields();
|
462 |
+
}
|
463 |
+
|
464 |
+
wc_stripe.BaseGateway.prototype.ajax_before_send = function (xhr) {
|
465 |
+
if (this.params.user_id > 0) {
|
466 |
+
xhr.setRequestHeader('X-WP-Nonce', this.params.rest_nonce);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
467 |
}
|
468 |
}
|
469 |
|
470 |
/**
|
471 |
* @return {[type]}
|
472 |
*/
|
473 |
+
wc_stripe.BaseGateway.prototype.process_checkout = function () {
|
474 |
+
return new Promise(function (resolve, reject) {
|
475 |
this.block();
|
476 |
$.ajax({
|
477 |
url: this.params.routes.checkout,
|
478 |
method: 'POST',
|
479 |
dataType: 'json',
|
480 |
+
data: $.extend({}, this.serialize_fields(), {
|
481 |
+
payment_method: this.gateway_id,
|
482 |
+
page_id: this.get_page()
|
483 |
+
}),
|
484 |
+
beforeSend: this.ajax_before_send.bind(this)
|
485 |
+
}).done(function (result) {
|
486 |
if (result.reload) {
|
487 |
window.location.reload();
|
488 |
return;
|
495 |
}
|
496 |
this.unblock();
|
497 |
}
|
498 |
+
}.bind(this)).fail(function (xhr, textStatus, errorThrown) {
|
499 |
this.unblock();
|
500 |
this.submit_error(errorThrown);
|
501 |
}.bind(this))
|
505 |
/**
|
506 |
* @return {[type]}
|
507 |
*/
|
508 |
+
wc_stripe.BaseGateway.prototype.serialize_form = function ($form) {
|
509 |
+
var formData = $form.find('input').filter(function (i, e) {
|
510 |
if ($(e).is('[name^="add-to-cart"]')) {
|
511 |
return false;
|
512 |
}
|
522 |
return data;
|
523 |
}
|
524 |
|
525 |
+
wc_stripe.BaseGateway.prototype.serialize_fields = function () {
|
526 |
+
return this.mappings.toJson();
|
527 |
+
}
|
528 |
+
|
529 |
/**
|
530 |
* @param {[type]}
|
531 |
* @return {[type]}
|
532 |
*/
|
533 |
+
wc_stripe.BaseGateway.prototype.map_shipping_methods = function (shippingData) {
|
534 |
var methods = {};
|
535 |
if (shippingData !== "default") {
|
536 |
+
var matches = shippingData.match(/^([\w+]):(.+)$/);
|
537 |
if (matches.length > 1) {
|
538 |
methods[matches[1]] = matches[2];
|
539 |
}
|
545 |
* [maybe_set_ship_to_different description]
|
546 |
* @return {[type]} [description]
|
547 |
*/
|
548 |
+
wc_stripe.BaseGateway.prototype.maybe_set_ship_to_different = function () {
|
549 |
// if shipping and billing address are different,
|
550 |
// set the ship to different address option.
|
551 |
if ($('[name="ship_to_different_address"]').length) {
|
552 |
+
$('[name="ship_to_different_address"]').prop('checked', this.get_address_field_hash("billing") !== this.get_address_field_hash("shipping")).trigger('change');
|
553 |
}
|
554 |
}
|
555 |
|
556 |
/**
|
557 |
* @return {[@event]}
|
558 |
*/
|
559 |
+
wc_stripe.BaseGateway.prototype.update_shipping_address = function (ev) {
|
560 |
+
return new Promise(function (resolve, reject) {
|
561 |
$.ajax({
|
562 |
url: this.params.routes.shipping_address,
|
563 |
method: 'POST',
|
564 |
dataType: 'json',
|
565 |
+
data: {
|
566 |
+
address: this.map_address(ev.shippingAddress),
|
567 |
+
payment_method: this.gateway_id,
|
568 |
+
page_id: this.get_page()
|
569 |
+
},
|
570 |
+
beforeSend: this.ajax_before_send.bind(this)
|
571 |
+
}).done(function (response) {
|
572 |
if (response.code) {
|
573 |
ev.updateWith(response.data.newData);
|
574 |
reject(response.data);
|
576 |
ev.updateWith(response.data.newData);
|
577 |
resolve(response.data);
|
578 |
}
|
579 |
+
}.bind(this)).fail(function (xhr, textStatus, errorThrown) {
|
580 |
|
581 |
}.bind(this))
|
582 |
}.bind(this))
|
585 |
/**
|
586 |
* @return {[@event]}
|
587 |
*/
|
588 |
+
wc_stripe.BaseGateway.prototype.update_shipping_method = function (ev) {
|
589 |
+
return new Promise(function (resolve, reject) {
|
590 |
$.ajax({
|
591 |
url: this.params.routes.shipping_method,
|
592 |
method: 'POST',
|
593 |
dataType: 'json',
|
594 |
+
data: {
|
595 |
+
shipping_method: ev.shippingOption.id,
|
596 |
+
payment_method: this.gateway_id,
|
597 |
+
page_id: this.get_page()
|
598 |
+
},
|
599 |
+
beforeSend: this.ajax_before_send.bind(this)
|
600 |
+
}).done(function (response) {
|
601 |
if (response.code) {
|
602 |
ev.updateWith(response.data.newData);
|
603 |
reject(response.data);
|
606 |
ev.updateWith(response.data.newData);
|
607 |
resolve(response.data);
|
608 |
}
|
609 |
+
}.bind(this)).fail(function (xhr, textStatus, errorThrown) {
|
610 |
this.submit_error(errorThrown);
|
611 |
}.bind(this))
|
612 |
}.bind(this))
|
618 |
/**
|
619 |
* @constructor
|
620 |
*/
|
621 |
+
wc_stripe.CheckoutGateway = function () {
|
622 |
+
this.message_container = 'li.payment_method_' + this.gateway_id;
|
623 |
this.banner_container = 'li.banner_payment_method_' + this.gateway_id;
|
624 |
$(document.body).on('update_checkout', this.update_checkout.bind(this));
|
625 |
$(document.body).on('updated_checkout', this.updated_checkout.bind(this));
|
640 |
this.order_review();
|
641 |
}
|
642 |
|
643 |
+
wc_stripe.CheckoutGateway.prototype.order_review = function () {
|
644 |
var url = window.location.href;
|
645 |
var matches = url.match(/order_review.+payment_method=([\w]+).+payment_nonce=(.+)/);
|
646 |
if (matches && matches.length > 1) {
|
657 |
/**
|
658 |
* Called on the WC updated_checkout event
|
659 |
*/
|
660 |
+
wc_stripe.CheckoutGateway.prototype.updated_checkout = function () {
|
661 |
+
}
|
662 |
|
663 |
/**
|
664 |
* Called on the WC update_checkout event
|
665 |
*/
|
666 |
+
wc_stripe.CheckoutGateway.prototype.update_checkout = function () {
|
667 |
+
}
|
668 |
|
669 |
/**
|
670 |
* Called on the WC checkout_error event
|
671 |
*/
|
672 |
+
wc_stripe.CheckoutGateway.prototype.checkout_error = function () {
|
673 |
if (this.has_checkout_error()) {
|
674 |
this.payment_token_received = false;
|
675 |
this.payment_response = null;
|
679 |
}
|
680 |
|
681 |
/**
|
682 |
+
*
|
683 |
*/
|
684 |
+
wc_stripe.CheckoutGateway.prototype.is_valid_checkout = function () {
|
685 |
if ($('[name="terms"]').length) {
|
686 |
if (!$('[name="terms"]').is(':checked')) {
|
687 |
return false;
|
692 |
|
693 |
/**
|
694 |
* Returns the selected payment gateway's id.
|
695 |
+
*
|
696 |
* @returns {String}
|
697 |
*/
|
698 |
+
wc_stripe.CheckoutGateway.prototype.get_payment_method = function () {
|
699 |
return $('[name="payment_method"]:checked').val();
|
700 |
}
|
701 |
|
702 |
+
wc_stripe.CheckoutGateway.prototype.set_use_new_option = function (bool) {
|
703 |
$('#' + this.gateway_id + '_use_new').prop("checked", bool).trigger('change');
|
704 |
}
|
705 |
|
706 |
/**
|
707 |
* Called on the WC checkout_place_order_{$gateway_id} event
|
708 |
*/
|
709 |
+
wc_stripe.CheckoutGateway.prototype.checkout_place_order = function () {
|
710 |
if (!this.is_valid_checkout()) {
|
711 |
this.submit_error(this.params.messages.terms);
|
712 |
return false;
|
720 |
* @param {[type]}
|
721 |
* @return {[type]}
|
722 |
*/
|
723 |
+
wc_stripe.CheckoutGateway.prototype.on_token_received = function (paymentMethod) {
|
724 |
this.payment_token_received = true;
|
725 |
+
this.set_nonce(paymentMethod.id);
|
726 |
this.hide_payment_button();
|
727 |
this.show_place_order();
|
728 |
}
|
730 |
/**
|
731 |
* @return {[type]}
|
732 |
*/
|
733 |
+
wc_stripe.CheckoutGateway.prototype.block = function () {
|
734 |
$('form.checkout').block({
|
735 |
message: null,
|
736 |
overlayCSS: {
|
743 |
/**
|
744 |
* @return {[type]}
|
745 |
*/
|
746 |
+
wc_stripe.CheckoutGateway.prototype.unblock = function () {
|
747 |
$('form.checkout').unblock();
|
748 |
}
|
749 |
|
750 |
+
wc_stripe.CheckoutGateway.prototype.hide_place_order = function () {
|
751 |
$('#place_order').addClass('wc-stripe-hide');
|
752 |
}
|
753 |
|
754 |
/**
|
755 |
* @return {[type]}
|
756 |
*/
|
757 |
+
wc_stripe.CheckoutGateway.prototype.show_place_order = function () {
|
758 |
$('#place_order').removeClass('wc-stripe-hide');
|
759 |
}
|
760 |
|
764 |
* @param {[String]}
|
765 |
* @return {[type]}
|
766 |
*/
|
767 |
+
wc_stripe.CheckoutGateway.prototype.on_show_new_methods = function () {
|
768 |
if (this.payment_token_received) {
|
769 |
this.show_place_order();
|
770 |
this.hide_payment_button();
|
780 |
* @param {[type]}
|
781 |
* @return {[type]}
|
782 |
*/
|
783 |
+
wc_stripe.CheckoutGateway.prototype.on_show_saved_methods = function () {
|
784 |
this.hide_payment_button();
|
785 |
this.show_place_order();
|
786 |
}
|
788 |
/**
|
789 |
* @return {[type]}
|
790 |
*/
|
791 |
+
wc_stripe.CheckoutGateway.prototype.show_payment_button = function () {
|
792 |
if (this.$button) {
|
793 |
this.$button.show();
|
794 |
}
|
797 |
/**
|
798 |
* @return {[type]}
|
799 |
*/
|
800 |
+
wc_stripe.CheckoutGateway.prototype.hide_payment_button = function () {
|
801 |
if (this.$button) {
|
802 |
this.$button.hide();
|
803 |
}
|
808 |
* any DOM events.
|
809 |
* @return {[type]}
|
810 |
*/
|
811 |
+
wc_stripe.CheckoutGateway.prototype.trigger_payment_method_selected = function () {
|
812 |
this.on_payment_method_selected(null, $('[name="payment_method"]:checked').val());
|
813 |
}
|
814 |
|
817 |
* @param {[type]}
|
818 |
* @return {[type]}
|
819 |
*/
|
820 |
+
wc_stripe.CheckoutGateway.prototype.on_payment_method_selected = function (e, payment_method) {
|
821 |
if (payment_method === this.gateway_id) {
|
822 |
if (this.payment_token_received || this.is_saved_method_selected()) {
|
823 |
this.hide_payment_button();
|
838 |
* [Return true if the banner option has been enabled for the gateway.]
|
839 |
* @return {[type]} [description]
|
840 |
*/
|
841 |
+
wc_stripe.CheckoutGateway.prototype.banner_enabled = function () {
|
842 |
return this.params.banner_enabled === "1";
|
843 |
}
|
844 |
|
845 |
+
wc_stripe.CheckoutGateway.prototype.checkout_fields_valid = function () {
|
846 |
+
if (typeof wc_stripe_checkout_fields == 'undefined' || this.get_page() !== 'checkout') {
|
847 |
return true;
|
848 |
}
|
|
|
|
|
849 |
valid = true;
|
850 |
|
851 |
+
function validateFields(prefix, fields) {
|
852 |
+
for (var k in fields) {
|
853 |
+
var field = fields[k];
|
854 |
+
if (k.indexOf(prefix) > -1 && field.required) {
|
855 |
+
if ($('#' + k).length) {
|
856 |
+
var val = $('#' + k).val();
|
857 |
+
if (typeof val === 'undefined' || val.length == 0) {
|
858 |
+
valid = false;
|
859 |
+
return
|
860 |
+
}
|
861 |
}
|
862 |
}
|
863 |
}
|
864 |
}
|
865 |
|
866 |
+
validateFields('billing', wc_stripe_checkout_fields);
|
867 |
|
868 |
if (this.needs_shipping() && $('#ship-to-different-address-checkbox').is(':checked')) {
|
869 |
+
validateFields('shipping', wc_stripe_checkout_fields);
|
870 |
+
}
|
871 |
+
if (valid) {
|
872 |
+
valid = this.is_valid_checkout();
|
873 |
}
|
|
|
874 |
return valid;
|
875 |
}
|
876 |
|
877 |
/************** Product Gateway ***************/
|
878 |
|
879 |
+
wc_stripe.ProductGateway = function () {
|
|
|
880 |
this.message_container = 'div.product';
|
881 |
|
882 |
// events
|
|
|
883 |
$('form.cart').on('found_variation', this.found_variation.bind(this));
|
884 |
$('form.cart').on('reset_data', this.reset_variation_data.bind(this));
|
885 |
|
886 |
this.buttonWidth = $('div.quantity').outerWidth(true) + $('.single_add_to_cart_button').outerWidth();
|
887 |
+
var marginLeft = $('.single_add_to_cart_button').css('marginLeft');
|
888 |
+
if (marginLeft) {
|
889 |
this.buttonWidth += parseInt(marginLeft.replace('px', ''));
|
890 |
}
|
891 |
$(this.container).css('max-width', this.buttonWidth + 'px');
|
894 |
/**
|
895 |
* @return {[@int]}
|
896 |
*/
|
897 |
+
wc_stripe.ProductGateway.prototype.get_quantity = function () {
|
898 |
return parseInt($('[name="quantity"]').val());
|
899 |
}
|
900 |
|
902 |
* @param {[type]}
|
903 |
* @param {[type]}
|
904 |
*/
|
905 |
+
wc_stripe.ProductGateway.prototype.set_rest_nonce = function (e, nonce) {
|
906 |
this.params.rest_nonce = nonce;
|
907 |
}
|
908 |
|
911 |
* @param {[type]}
|
912 |
* @return {[type]}
|
913 |
*/
|
914 |
+
wc_stripe.ProductGateway.prototype.found_variation = function (e, variation) {
|
915 |
+
var data = this.get_gateway_data();
|
916 |
+
data.product.price = variation.display_price;
|
917 |
data.needs_shipping = !variation.is_virtual;
|
918 |
+
data.product.variation = variation;
|
919 |
+
this.set_gateway_data(data);
|
920 |
this.enable_payment_button();
|
921 |
}
|
922 |
|
923 |
/**
|
924 |
* @return {[type]}
|
925 |
*/
|
926 |
+
wc_stripe.ProductGateway.prototype.reset_variation_data = function () {
|
927 |
+
var data = this.get_product_data();
|
928 |
+
data.variation = false;
|
929 |
+
this.set_product_data(data);
|
930 |
this.disable_payment_button();
|
931 |
}
|
932 |
|
933 |
/**
|
934 |
* @return {[type]}
|
935 |
*/
|
936 |
+
wc_stripe.ProductGateway.prototype.disable_payment_button = function () {
|
937 |
if (this.$button) {
|
938 |
this.get_button().prop('disabled', true).addClass('disabled');
|
939 |
}
|
942 |
/**
|
943 |
* @return {[type]}
|
944 |
*/
|
945 |
+
wc_stripe.ProductGateway.prototype.enable_payment_button = function () {
|
946 |
if (this.$button) {
|
947 |
this.get_button().prop('disabled', false).removeClass('disabled');
|
948 |
}
|
951 |
/**
|
952 |
* @return {[type]}
|
953 |
*/
|
954 |
+
wc_stripe.ProductGateway.prototype.get_button = function () {
|
955 |
return this.$button;
|
956 |
}
|
957 |
|
958 |
/**
|
959 |
* @return {Boolean}
|
960 |
*/
|
961 |
+
wc_stripe.ProductGateway.prototype.is_variable_product = function () {
|
962 |
return $('[name="variation_id"]').length > 0;
|
963 |
}
|
964 |
|
965 |
+
wc_stripe.ProductGateway.prototype.variable_product_selected = function () {
|
966 |
+
return this.get_product_data().variation !== false;
|
|
|
|
|
|
|
967 |
}
|
968 |
|
969 |
/**
|
970 |
* @return {[type]}
|
971 |
*/
|
972 |
+
wc_stripe.ProductGateway.prototype.get_product_data = function () {
|
973 |
+
return this.get_gateway_data().product;
|
974 |
}
|
975 |
|
976 |
/**
|
977 |
* @return {[type]}
|
978 |
*/
|
979 |
+
wc_stripe.ProductGateway.prototype.set_product_data = function (product) {
|
980 |
+
var data = this.get_gateway_data();
|
981 |
+
data.product = product;
|
982 |
+
this.set_gateway_data(data);
|
983 |
}
|
984 |
|
985 |
/**
|
986 |
* Add a product to the WC shopping cart
|
987 |
*/
|
988 |
+
wc_stripe.ProductGateway.prototype.add_to_cart = function () {
|
989 |
+
return new Promise(function (resolve, reject) {
|
990 |
this.block();
|
991 |
$.ajax({
|
992 |
url: this.params.routes.add_to_cart,
|
993 |
method: 'POST',
|
994 |
dataType: 'json',
|
995 |
data: {
|
996 |
+
product_id: this.get_product_data().id,
|
997 |
variation_id: this.is_variable_product() ? $('[name="variation_id"]').val() : 0,
|
998 |
qty: $('[name="quantity"]').val(),
|
999 |
payment_method: this.gateway_id,
|
1000 |
page_id: this.get_page()
|
1001 |
},
|
1002 |
+
beforeSend: this.ajax_before_send.bind(this)
|
1003 |
+
}).done(function (response, status, xhr) {
|
|
|
|
|
1004 |
this.unblock();
|
|
|
1005 |
if (response.code) {
|
1006 |
this.submit_error(response.message);
|
1007 |
reject(response);
|
1011 |
this.set_display_items(response.data.displayItems);
|
1012 |
resolve(response.data);
|
1013 |
}
|
1014 |
+
}.bind(this)).fail(function (xhr, textStatus, errorThrown) {
|
1015 |
this.unblock();
|
1016 |
this.submit_error(errorThrown);
|
1017 |
}.bind(this))
|
1018 |
}.bind(this))
|
1019 |
}
|
1020 |
|
1021 |
+
wc_stripe.ProductGateway.prototype.cart_calculation = function (variation_id) {
|
1022 |
+
return new Promise(function (resolve, reject) {
|
1023 |
$.ajax({
|
1024 |
url: this.params.routes.cart_calculation,
|
1025 |
method: 'POST',
|
1026 |
dataType: 'json',
|
1027 |
data: {
|
1028 |
+
product_id: this.get_product_data().id,
|
1029 |
variation_id: this.is_variable_product() && variation_id ? variation_id : 0,
|
1030 |
qty: $('[name="quantity"]').val(),
|
1031 |
payment_method: this.gateway_id
|
1032 |
},
|
1033 |
+
beforeSend: this.ajax_before_send.bind(this)
|
1034 |
+
}).done(function (response, status, xhr) {
|
|
|
|
|
|
|
1035 |
if (response.code) {
|
1036 |
this.cart_calculation_error = true;
|
1037 |
+
reject(response);
|
1038 |
} else {
|
1039 |
this.set_total_price(response.data.total);
|
1040 |
this.set_total_price_cents(response.data.totalCents);
|
1041 |
this.set_display_items(response.data.displayItems);
|
1042 |
resolve(response.data);
|
1043 |
}
|
1044 |
+
}.bind(this)).fail(function (xhr, textStatus, errorThrown) {
|
1045 |
|
1046 |
}.bind(this))
|
1047 |
}.bind(this))
|
1052 |
/**
|
1053 |
* @constructor
|
1054 |
*/
|
1055 |
+
wc_stripe.CartGateway = function () {
|
|
|
1056 |
this.message_container = 'div.woocommerce';
|
1057 |
|
1058 |
// cart events
|
1061 |
$(document.body).on('wc_cart_emptied', this.cart_emptied.bind(this));
|
1062 |
}
|
1063 |
|
|
|
|
|
|
|
|
|
1064 |
/**
|
1065 |
* @param {[type]}
|
1066 |
* @return {[type]}
|
1067 |
*/
|
1068 |
+
wc_stripe.CartGateway.prototype.submit_error = function (message) {
|
1069 |
this.submit_message(this.get_error_message(message));
|
1070 |
}
|
1071 |
|
1073 |
* @param {[@event]}
|
1074 |
* @return {[null]}
|
1075 |
*/
|
1076 |
+
wc_stripe.CartGateway.prototype.updated_html = function (e) {
|
1077 |
|
1078 |
}
|
1079 |
|
1080 |
+
wc_stripe.CartGateway.prototype.cart_emptied = function (e) {
|
1081 |
+
}
|
1082 |
|
1083 |
+
wc_stripe.CartGateway.prototype.add_cart_totals_class = function () {
|
1084 |
$('.cart_totals').addClass('stripe_cart_gateway_active');
|
1085 |
}
|
1086 |
|
1087 |
/************* Google Pay Mixins **************/
|
1088 |
|
1089 |
+
wc_stripe.GooglePay = function () {
|
1090 |
+
}
|
1091 |
|
1092 |
const googlePayBaseRequest = {
|
1093 |
apiVersion: 2,
|
1106 |
}
|
1107 |
}
|
1108 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1109 |
/**
|
1110 |
* Populate the WC checkout fields.
|
1111 |
* @param {[type]}
|
1112 |
* @return {[type]}
|
1113 |
*/
|
1114 |
+
wc_stripe.GooglePay.prototype.populate_address_fields = function (paymentData) {
|
1115 |
+
var billingAddress = paymentData.paymentMethodData.info.billingAddress;
|
|
|
1116 |
for (var k in billingAddress) {
|
1117 |
+
this.mappings.set(k, billingAddress[k], 'billing');
|
|
|
|
|
1118 |
}
|
1119 |
if (paymentData.shippingAddress) {
|
1120 |
for (var k in paymentData.shippingAddress) {
|
1121 |
+
this.mappings.set(k, paymentData.shippingAddress[k], "shipping");
|
|
|
|
|
1122 |
}
|
1123 |
}
|
1124 |
if (paymentData.email) {
|
1125 |
+
this.mappings.set('email', paymentData.email, 'billing');
|
1126 |
+
}
|
1127 |
+
if ('checkout' === this.get_page()) {
|
1128 |
+
this.maybe_set_ship_to_different();
|
1129 |
+
this.mappings.toFormFields();
|
1130 |
+
$('[name="billing_country"]').trigger('change');
|
1131 |
}
|
|
|
|
|
1132 |
}
|
1133 |
|
1134 |
/**
|
1135 |
* @param {[type]}
|
1136 |
* @return {[type]}
|
1137 |
*/
|
1138 |
+
wc_stripe.GooglePay.prototype.map_address = function (address) {
|
1139 |
return {
|
1140 |
city: address.locality,
|
1141 |
postcode: address.postalCode,
|
1148 |
* @param {[type]}
|
1149 |
* @return {[type]}
|
1150 |
*/
|
1151 |
+
wc_stripe.GooglePay.prototype.update_payment_data = function (data) {
|
1152 |
+
return new Promise(function (resolve, reject) {
|
1153 |
+
var shipping_method = data.shippingOptionData.id == 'default' ? null : data.shippingOptionData.id;
|
1154 |
$.when($.ajax({
|
1155 |
url: this.params.routes.payment_data,
|
1156 |
dataType: 'json',
|
1157 |
method: 'POST',
|
1158 |
data: {
|
1159 |
shipping_address: this.map_address(data.shippingAddress),
|
1160 |
+
shipping_method: shipping_method,
|
|
|
1161 |
page_id: this.get_page()
|
1162 |
},
|
1163 |
+
beforeSend: this.ajax_before_send.bind(this)
|
1164 |
+
})).done(function (response) {
|
|
|
|
|
1165 |
if (response.code) {
|
1166 |
reject(response.data.data);
|
1167 |
} else {
|
1168 |
resolve(response.data);
|
1169 |
}
|
1170 |
+
}.bind(this)).fail(function () {
|
1171 |
reject();
|
1172 |
}.bind(this))
|
1173 |
}.bind(this))
|
1177 |
* @param {[type]}
|
1178 |
* @return {[type]}
|
1179 |
*/
|
1180 |
+
wc_stripe.GooglePay.prototype.on_payment_data_changed = function (address) {
|
1181 |
+
return new Promise(function (resolve, reject) {
|
1182 |
+
this.update_payment_data(address).then(function (response) {
|
1183 |
resolve(response.paymentRequestUpdate);
|
1184 |
this.set_selected_shipping_methods(response.shipping_methods);
|
1185 |
this.payment_data_updated(response, address);
|
1186 |
+
}.bind(this)).catch(function (data) {
|
1187 |
resolve(data);
|
1188 |
}.bind(this))
|
1189 |
}.bind(this))
|
1195 |
* @param {[type]}
|
1196 |
* @return {[type]}
|
1197 |
*/
|
1198 |
+
wc_stripe.GooglePay.prototype.payment_data_updated = function (response) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1199 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1200 |
}
|
1201 |
|
1202 |
/**
|
1203 |
* @return {[type]}
|
1204 |
*/
|
1205 |
+
wc_stripe.GooglePay.prototype.get_merchant_info = function () {
|
1206 |
var options = {
|
1207 |
merchantId: this.params.merchant_id,
|
1208 |
merchantName: this.params.merchant_name
|
1213 |
return options;
|
1214 |
}
|
1215 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1216 |
/**
|
1217 |
* @return {[type]}
|
1218 |
*/
|
1219 |
+
wc_stripe.GooglePay.prototype.get_payment_options = function () {
|
1220 |
var options = {
|
1221 |
environment: this.params.environment,
|
1222 |
merchantInfo: this.get_merchant_info()
|
1223 |
}
|
1224 |
+
if (this.needs_shipping() && (this.get_total_price_cents() > 0)) {
|
1225 |
+
options.paymentDataCallbacks = {
|
1226 |
+
onPaymentDataChanged: this.on_payment_data_changed.bind(this),
|
1227 |
+
onPaymentAuthorized: function (data) {
|
1228 |
+
return new Promise(function (resolve, reject) {
|
1229 |
+
resolve({transactionState: "SUCCESS"})
|
1230 |
+
}.bind(this))
|
1231 |
+
}.bind(this)
|
1232 |
+
}
|
1233 |
+
} else {
|
1234 |
+
options.paymentDataCallbacks = {
|
1235 |
+
onPaymentAuthorized: function (data) {
|
1236 |
+
return new Promise(function (resolve, reject) {
|
1237 |
+
resolve({transactionState: "SUCCESS"})
|
1238 |
+
}.bind(this))
|
|
|
|
|
1239 |
}
|
1240 |
}
|
1241 |
}
|
1245 |
/**
|
1246 |
* @return {[type]}
|
1247 |
*/
|
1248 |
+
wc_stripe.GooglePay.prototype.build_payment_request = function () {
|
1249 |
var request = $.extend({}, googlePayBaseRequest, {
|
1250 |
+
emailRequired: this.mappings.required('billing_email'),
|
1251 |
merchantInfo: this.get_merchant_info(),
|
1252 |
allowedPaymentMethods: [$.extend({
|
1253 |
type: "CARD",
|
1265 |
currencyCode: this.get_currency(),
|
1266 |
totalPriceStatus: "ESTIMATED",
|
1267 |
totalPrice: this.get_total_price().toString(),
|
1268 |
+
displayItems: this.get_display_items(),
|
1269 |
totalPriceLabel: this.params.total_price_label
|
1270 |
}
|
1271 |
})
|
1272 |
request.allowedPaymentMethods[0].parameters['billingAddressRequired'] = true;
|
1273 |
request.allowedPaymentMethods[0].parameters['billingAddressParameters'] = {
|
1274 |
format: "FULL",
|
1275 |
+
phoneNumberRequired: this.mappings.required('billing_phone')
|
1276 |
+
}
|
1277 |
+
if (this.needs_shipping() && (this.get_total_price_cents() > 0)) {
|
1278 |
+
request['shippingAddressParameters'] = {};
|
1279 |
+
request['shippingOptionRequired'] = true;
|
1280 |
+
request['shippingOptionParameters'] = {
|
1281 |
+
shippingOptions: this.get_shipping_options(),
|
1282 |
+
};
|
1283 |
+
request['callbackIntents'] = ["SHIPPING_ADDRESS", "SHIPPING_OPTION", "PAYMENT_AUTHORIZATION"];
|
1284 |
+
} else {
|
1285 |
+
request['callbackIntents'] = ["PAYMENT_AUTHORIZATION"];
|
|
|
|
|
1286 |
}
|
1287 |
return request;
|
1288 |
}
|
1290 |
/**
|
1291 |
* @return {[type]}
|
1292 |
*/
|
1293 |
+
wc_stripe.GooglePay.prototype.createPaymentsClient = function () {
|
1294 |
this.paymentsClient = new google.payments.api.PaymentsClient(this.get_payment_options());
|
1295 |
}
|
1296 |
|
1297 |
/**
|
1298 |
* @return {Promise}
|
1299 |
*/
|
1300 |
+
wc_stripe.GooglePay.prototype.isReadyToPay = function () {
|
1301 |
+
return new Promise(function (resolve) {
|
1302 |
var isReadyToPayRequest = $.extend({}, googlePayBaseRequest);
|
1303 |
isReadyToPayRequest.allowedPaymentMethods = [baseCardPaymentMethod];
|
1304 |
+
this.paymentsClient.isReadyToPay(isReadyToPayRequest).then(function () {
|
1305 |
this.can_pay = true;
|
1306 |
this.create_button();
|
1307 |
resolve();
|
1308 |
+
}.bind(this)).catch(function (err) {
|
1309 |
this.submit_error(err);
|
1310 |
}.bind(this))
|
1311 |
}.bind(this))
|
1312 |
}
|
1313 |
|
1314 |
+
wc_stripe.GooglePay.prototype.create_button = function () {
|
1315 |
if (this.$button) {
|
1316 |
this.$button.remove();
|
1317 |
}
|
1326 |
/**
|
1327 |
* @return {[type]}
|
1328 |
*/
|
1329 |
+
wc_stripe.GooglePay.prototype.start = function () {
|
1330 |
// always recreate the paymentClient to ensure latest data is used.
|
1331 |
this.createPaymentsClient();
|
1332 |
+
this.paymentsClient.loadPaymentData(this.build_payment_request()).then(function (paymentData) {
|
1333 |
var data = JSON.parse(paymentData.paymentMethodData.tokenizationData.token);
|
1334 |
this.populate_address_fields(paymentData);
|
1335 |
this.on_token_received(data);
|
1336 |
+
}.bind(this)).catch(function (err) {
|
1337 |
if (err.statusCode === "CANCELED") {
|
1338 |
return;
|
1339 |
}
|
1350 |
/**
|
1351 |
* @constructor
|
1352 |
*/
|
1353 |
+
wc_stripe.ApplePay = function () {
|
1354 |
|
1355 |
}
|
1356 |
|
1357 |
/**
|
1358 |
* @return {[type]}
|
1359 |
*/
|
1360 |
+
wc_stripe.ApplePay.prototype.initialize = function () {
|
1361 |
+
var selector = '.apple-pay-button';
|
1362 |
+
if (['checkout', 'order_pay'].indexOf(this.get_page()) < 0) {
|
1363 |
+
selector = this.container + ' .apple-pay-button';
|
1364 |
+
}
|
1365 |
+
$(document.body).on('click', selector, this.start.bind(this));
|
1366 |
this.createPaymentRequest();
|
1367 |
this.canMakePayment();
|
1368 |
}
|
1369 |
|
1370 |
+
wc_stripe.ApplePay.prototype.create_button = function () {
|
1371 |
if (this.$button) {
|
1372 |
this.$button.remove();
|
1373 |
}
|
1378 |
/**
|
1379 |
* @return {[type]}
|
1380 |
*/
|
1381 |
+
wc_stripe.ApplePay.prototype.canMakePayment = function () {
|
1382 |
+
return new Promise(function (resolve, reject) {
|
1383 |
+
this.paymentRequest.canMakePayment().then(function (result) {
|
1384 |
if (result && result.applePay) {
|
1385 |
this.can_pay = true;
|
1386 |
this.create_button();
|
1394 |
/**
|
1395 |
* @return {[type]}
|
1396 |
*/
|
1397 |
+
wc_stripe.ApplePay.prototype.start = function (e) {
|
1398 |
e.preventDefault();
|
1399 |
this.paymentRequest.update(this.get_payment_request_update({
|
1400 |
total: {
|
1406 |
|
1407 |
/*********** PaymentRequest *********/
|
1408 |
|
1409 |
+
wc_stripe.PaymentRequest = function () {
|
1410 |
|
1411 |
}
|
1412 |
|
1414 |
* [initialize description]
|
1415 |
* @return {[type]} [description]
|
1416 |
*/
|
1417 |
+
wc_stripe.PaymentRequest.prototype.initialize = function () {
|
1418 |
this.createPaymentRequest();
|
1419 |
this.canMakePayment();
|
1420 |
this.paymentRequestButton = this.createPaymentRequestButton();
|
1426 |
* @param {[type]} event [description]
|
1427 |
* @return {[type]} [description]
|
1428 |
*/
|
1429 |
+
wc_stripe.PaymentRequest.prototype.button_click = function (event) {
|
1430 |
+
}
|
1431 |
|
1432 |
/**
|
1433 |
* [createPaymentRequestButton description]
|
1434 |
* @return {[type]} [description]
|
1435 |
*/
|
1436 |
+
wc_stripe.PaymentRequest.prototype.createPaymentRequestButton = function () {
|
1437 |
return this.elements.create("paymentRequestButton", {
|
1438 |
paymentRequest: this.paymentRequest,
|
1439 |
style: {
|
1450 |
* [canMakePayment description]
|
1451 |
* @return {[type]} [description]
|
1452 |
*/
|
1453 |
+
wc_stripe.PaymentRequest.prototype.canMakePayment = function () {
|
1454 |
+
return new Promise(function (resolve, reject) {
|
1455 |
+
this.paymentRequest.canMakePayment().then(function (result) {
|
1456 |
if (result && !result.applePay) {
|
1457 |
this.can_pay = true;
|
1458 |
this.create_button();
|
1467 |
* [create_button description]
|
1468 |
* @return {[type]} [description]
|
1469 |
*/
|
1470 |
+
wc_stripe.PaymentRequest.prototype.create_button = function () {
|
1471 |
this.paymentRequestButton.mount('#wc-stripe-payment-request-container');
|
1472 |
}
|
1473 |
|
1474 |
+
wc_stripe.CheckoutFields = function (params) {
|
1475 |
+
this.params = params;
|
1476 |
+
this.fields = new Map(Object.keys(this.params).map(function (k) {
|
1477 |
+
return [k, this.params[k].value];
|
1478 |
+
}.bind(this)));
|
1479 |
+
}
|
1480 |
+
|
1481 |
+
wc_stripe.CheckoutFields.prototype.set = function (k, v, prefix) {
|
1482 |
+
if (this[k] && typeof this[k] === 'function') {
|
1483 |
+
this[k]().set.call(this, v, prefix);
|
1484 |
+
} else {
|
1485 |
+
this.fields.set(k, v);
|
1486 |
+
}
|
1487 |
+
}
|
1488 |
+
|
1489 |
+
wc_stripe.CheckoutFields.prototype.get = function (k, prefix) {
|
1490 |
+
if (this[k] && typeof this[k] === 'function') {
|
1491 |
+
return this[k]().get.call(this, v, prefix);
|
1492 |
+
} else {
|
1493 |
+
return this.fields.get(k);
|
1494 |
+
}
|
1495 |
+
}
|
1496 |
+
|
1497 |
+
/**
|
1498 |
+
* Return true if the field is required
|
1499 |
+
* @param k
|
1500 |
+
* @returns bool
|
1501 |
+
*/
|
1502 |
+
wc_stripe.CheckoutFields.prototype.required = function (k) {
|
1503 |
+
return this.params[k] && this.params[k].required;
|
1504 |
+
}
|
1505 |
+
|
1506 |
+
wc_stripe.CheckoutFields.prototype.name = function () {
|
1507 |
+
return {
|
1508 |
+
set: function (v, prefix) {
|
1509 |
+
var name = v.split(" ");
|
1510 |
+
this.fields.set(prefix + '_first_name', name[0]);
|
1511 |
+
this.fields.set(prefix + '_last_name', name[1]);
|
1512 |
+
},
|
1513 |
+
get: function (prefix) {
|
1514 |
+
return this.fields.get(prefix + '_first_name') + ' ' + this.fields.get(prefix + '_last_name');
|
1515 |
+
}
|
1516 |
+
}
|
1517 |
+
}
|
1518 |
+
|
1519 |
+
wc_stripe.CheckoutFields.prototype.payerName = function () {
|
1520 |
+
return wc_stripe.CheckoutFields.prototype.name.apply(this, arguments);
|
1521 |
+
}
|
1522 |
+
|
1523 |
+
wc_stripe.CheckoutFields.prototype.email = function () {
|
1524 |
+
return {
|
1525 |
+
set: function (v, prefix) {
|
1526 |
+
this.fields.set(prefix + '_email', v);
|
1527 |
+
},
|
1528 |
+
get: function (prefix) {
|
1529 |
+
return this.fields.get(prefix + '_email');
|
1530 |
+
}
|
1531 |
+
}
|
1532 |
+
}
|
1533 |
+
|
1534 |
+
wc_stripe.CheckoutFields.prototype.payerEmail = function () {
|
1535 |
+
return wc_stripe.CheckoutFields.prototype.email.apply(this, arguments);
|
1536 |
+
}
|
1537 |
+
|
1538 |
+
wc_stripe.CheckoutFields.prototype.phone = function () {
|
1539 |
+
return {
|
1540 |
+
set: function (v, prefix) {
|
1541 |
+
this.fields.set(prefix + '_phone', v);
|
1542 |
+
},
|
1543 |
+
get: function (prefix) {
|
1544 |
+
return this.fields.get(prefix + '_phone');
|
1545 |
+
}
|
1546 |
+
}
|
1547 |
+
}
|
1548 |
+
|
1549 |
+
wc_stripe.CheckoutFields.prototype.payerPhone = function () {
|
1550 |
+
return wc_stripe.CheckoutFields.prototype.phone.apply(this, arguments);
|
1551 |
+
}
|
1552 |
+
|
1553 |
+
wc_stripe.CheckoutFields.prototype.phoneNumber = function () {
|
1554 |
+
return wc_stripe.CheckoutFields.prototype.phone.apply(this, arguments);
|
1555 |
+
}
|
1556 |
+
|
1557 |
+
wc_stripe.CheckoutFields.prototype.recipient = function () {
|
1558 |
+
return {
|
1559 |
+
set: function (v, prefix) {
|
1560 |
+
var name = v.split(" ");
|
1561 |
+
if (name.length > 0) {
|
1562 |
+
this.fields.set(prefix + '_first_name', name[0]);
|
1563 |
+
}
|
1564 |
+
if (name.length > 1) {
|
1565 |
+
this.fields.set(prefix + '_last_name', name[1]);
|
1566 |
+
}
|
1567 |
+
},
|
1568 |
+
get: function (prefix) {
|
1569 |
+
return this.fields.get(prefix + '_first_name') + ' ' + this.fields.get(prefix + '_last_name');
|
1570 |
+
}
|
1571 |
+
}
|
1572 |
+
}
|
1573 |
+
|
1574 |
+
wc_stripe.CheckoutFields.prototype.country = function () {
|
1575 |
+
return {
|
1576 |
+
set: function (v, prefix) {
|
1577 |
+
this.fields.set(prefix + '_country', v);
|
1578 |
+
},
|
1579 |
+
get: function (prefix) {
|
1580 |
+
return this.fields.get(prefix + '_country');
|
1581 |
+
}
|
1582 |
+
}
|
1583 |
+
}
|
1584 |
+
|
1585 |
+
wc_stripe.CheckoutFields.prototype.countryCode = function () {
|
1586 |
+
return wc_stripe.CheckoutFields.prototype.country.apply(this, arguments);
|
1587 |
+
}
|
1588 |
+
|
1589 |
+
wc_stripe.CheckoutFields.prototype.address1 = function () {
|
1590 |
+
return {
|
1591 |
+
set: function (v, prefix) {
|
1592 |
+
this.fields.set(prefix + '_address_1', v);
|
1593 |
+
},
|
1594 |
+
get: function (prefix) {
|
1595 |
+
return this.fields.get(prefix + '_address_1');
|
1596 |
+
}
|
1597 |
+
}
|
1598 |
+
}
|
1599 |
+
|
1600 |
+
wc_stripe.CheckoutFields.prototype.address2 = function () {
|
1601 |
+
return {
|
1602 |
+
set: function (v, prefix) {
|
1603 |
+
this.fields.set(prefix + '_address_2', v);
|
1604 |
+
},
|
1605 |
+
get: function (prefix) {
|
1606 |
+
this.fields.get(prefix + '_address_2');
|
1607 |
+
}
|
1608 |
+
}
|
1609 |
+
}
|
1610 |
+
|
1611 |
+
wc_stripe.CheckoutFields.prototype.line1 = function () {
|
1612 |
+
return wc_stripe.CheckoutFields.prototype.address1.apply(this, arguments);
|
1613 |
+
}
|
1614 |
+
|
1615 |
+
wc_stripe.CheckoutFields.prototype.line2 = function () {
|
1616 |
+
return wc_stripe.CheckoutFields.prototype.address2.apply(this, arguments);
|
1617 |
+
}
|
1618 |
+
|
1619 |
+
wc_stripe.CheckoutFields.prototype.addressLine = function () {
|
1620 |
+
return {
|
1621 |
+
set: function (v, prefix) {
|
1622 |
+
if (v.length > 0) {
|
1623 |
+
this.fields.set(prefix + '_address_1', v[0]);
|
1624 |
+
}
|
1625 |
+
if (v.length > 1) {
|
1626 |
+
this.fields.set(prefix + '_address_2', v[1]);
|
1627 |
+
}
|
1628 |
+
},
|
1629 |
+
get: function (prefix) {
|
1630 |
+
return [
|
1631 |
+
this.fields.get(prefix + '_address_1'),
|
1632 |
+
this.fields.get(prefix + '_address_2')
|
1633 |
+
]
|
1634 |
+
}
|
1635 |
+
}
|
1636 |
+
}
|
1637 |
+
|
1638 |
+
wc_stripe.CheckoutFields.prototype.state = function () {
|
1639 |
+
return {
|
1640 |
+
set: function (v, prefix) {
|
1641 |
+
this.fields.set(prefix + '_state', v);
|
1642 |
+
},
|
1643 |
+
get: function (prefix) {
|
1644 |
+
return this.fields.get(prefix + '_state');
|
1645 |
+
}
|
1646 |
+
}
|
1647 |
+
}
|
1648 |
+
|
1649 |
+
wc_stripe.CheckoutFields.prototype.region = function () {
|
1650 |
+
return wc_stripe.CheckoutFields.prototype.state.apply(this, arguments);
|
1651 |
+
}
|
1652 |
+
|
1653 |
+
wc_stripe.CheckoutFields.prototype.administrativeArea = function () {
|
1654 |
+
return wc_stripe.CheckoutFields.prototype.state.apply(this, arguments);
|
1655 |
+
}
|
1656 |
+
|
1657 |
+
wc_stripe.CheckoutFields.prototype.city = function () {
|
1658 |
+
return {
|
1659 |
+
set: function (v, prefix) {
|
1660 |
+
this.fields.set(prefix + '_city', v);
|
1661 |
+
},
|
1662 |
+
get: function (prefix) {
|
1663 |
+
this.fields.get(prefix + '_city');
|
1664 |
+
}
|
1665 |
+
}
|
1666 |
+
}
|
1667 |
+
|
1668 |
+
wc_stripe.CheckoutFields.prototype.locality = function () {
|
1669 |
+
return wc_stripe.CheckoutFields.prototype.city.apply(this, arguments);
|
1670 |
+
}
|
1671 |
+
|
1672 |
+
wc_stripe.CheckoutFields.prototype.postal_code = function () {
|
1673 |
+
return {
|
1674 |
+
set: function (v, prefix) {
|
1675 |
+
this.fields.set(prefix + '_postcode', v);
|
1676 |
+
},
|
1677 |
+
get: function (prefix) {
|
1678 |
+
this.fields.get(prefix + '_postcode');
|
1679 |
+
}
|
1680 |
+
}
|
1681 |
+
}
|
1682 |
+
|
1683 |
+
wc_stripe.CheckoutFields.prototype.postalCode = function () {
|
1684 |
+
return wc_stripe.CheckoutFields.prototype.postal_code.apply(this, arguments);
|
1685 |
+
}
|
1686 |
+
|
1687 |
+
/**
|
1688 |
+
* Serialize the fields into an expected format
|
1689 |
+
*/
|
1690 |
+
wc_stripe.CheckoutFields.prototype.toJson = function () {
|
1691 |
+
var data = {};
|
1692 |
+
this.fields.forEach(function (value, key) {
|
1693 |
+
data[key] = value;
|
1694 |
+
});
|
1695 |
+
return data;
|
1696 |
+
}
|
1697 |
+
|
1698 |
+
/**
|
1699 |
+
* Assign the field values to form field values
|
1700 |
+
*/
|
1701 |
+
wc_stripe.CheckoutFields.prototype.toFormFields = function () {
|
1702 |
+
this.fields.forEach(function (value, key) {
|
1703 |
+
key = '[name="' + key + '"]';
|
1704 |
+
if ($(key).length && value !== '') {
|
1705 |
+
$(key).val(value);
|
1706 |
+
}
|
1707 |
+
});
|
1708 |
+
}
|
1709 |
+
|
1710 |
try {
|
1711 |
+
stripe = Stripe(wc_stripe_params_v3.api_key, {stripeAccount: wc_stripe_params_v3.account});
|
1712 |
} catch (error) {
|
1713 |
window.alert(error);
|
1714 |
console.log(error);
|
assets/js/frontend/wc-stripe.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(t,e){t.wc_stripe={};var i=null;wc_stripe.BaseGateway=function(t){this.params=t,this.gateway_id=this.params.gateway_id,this.token_selector=this.params.token_selector,this.saved_method_selector=this.params.saved_method_selector,this.payment_intent_selector=this.params.payment_intent_selector,this.payment_token_received=!1,this.stripe=i,this.elements=i.elements(e.extend({},{locale:"auto"},this.get_element_options())),this.initialize()},wc_stripe.BaseGateway.prototype.get_page=function(){return wc_stripe_params_v3.page},wc_stripe.BaseGateway.prototype.set_nonce=function(t){e(this.token_selector).val(t)},wc_stripe.BaseGateway.prototype.get_element_options=function(){return{}},wc_stripe.BaseGateway.prototype.initialize=function(){},wc_stripe.BaseGateway.prototype.create_button=function(){},wc_stripe.BaseGateway.prototype.is_gateway_selected=function(){return e('[name="payment_method"]:checked').val()===this.gateway_id},wc_stripe.BaseGateway.prototype.is_saved_method_selected=function(){return this.is_gateway_selected()&&"saved"===e('[name="'+this.gateway_id+'_payment_type_key"]:checked').val()},wc_stripe.BaseGateway.prototype.has_checkout_error=function(){return e("#wc_stripe_checkout_error").length>0&&this.is_gateway_selected()},wc_stripe.BaseGateway.prototype.submit_error=function(t){-1==(t=this.get_error_message(t)).indexOf("</ul>")&&(t='<div class="woocommerce-error">'+t+"</div>"),this.submit_message(t)},wc_stripe.BaseGateway.prototype.submit_error_code=function(t){},wc_stripe.BaseGateway.prototype.get_error_message=function(t){return"object"==typeof t&&t.code&&(t=wc_stripe_messages[t.code]?wc_stripe_messages[t.code]:t.message),t},wc_stripe.BaseGateway.prototype.submit_message=function(t){e(".woocommerce-error, .woocommerce-message, .woocommerce-info").remove();var i=e(this.message_container);i.closest("form").length&&(i=i.closest("form")),i.prepend(t),i.removeClass("processing").unblock(),i.find(".input-text, select, input:checkbox").blur(),e.scroll_to_notices?e.scroll_to_notices(i):e("html, body").animate({scrollTop:i.offset().top-100},1e3)},wc_stripe.BaseGateway.prototype.get_first_name=function(t){return e("#"+t+"_first_name").val()},wc_stripe.BaseGateway.prototype.get_last_name=function(t){return e("#"+t+"_last_name").val()},wc_stripe.BaseGateway.prototype.should_save_method=function(){return e("#"+this.gateway_id+"_save_source_key").is(":checked")},wc_stripe.BaseGateway.prototype.is_add_payment_method_page=function(){return e(document.body).hasClass("woocommerce-add-payment-method")},wc_stripe.BaseGateway.prototype.get_selected_payment_method=function(){return e(this.saved_method_selector).val()},wc_stripe.BaseGateway.prototype.needs_shipping=function(){return"1"===this.params.needs_shipping},wc_stripe.BaseGateway.prototype.get_currency=function(){return e("#wc_stripe_currency").val()},wc_stripe.BaseGateway.prototype.get_country=function(){return e("#wc_stripe_country").val()},wc_stripe.BaseGateway.prototype.get_customer_name=function(t){return e(t+"_first_name").val()+" "+e(t+"_last_name").val()},wc_stripe.BaseGateway.prototype.get_customer_email=function(){return e("#billing_email").val()},wc_stripe.BaseGateway.prototype.get_address_field_hash=function(t){for(var i=["_first_name","_last_name","_address_1","_address_2","_postcode","_city","_state","_country"],a="",n=0;n<i.length;n++)a+=e(t+i[n]).val()+"_";return a},wc_stripe.BaseGateway.prototype.block=function(){e.blockUI({message:null,overlayCSS:{background:"#fff",opacity:.6}})},wc_stripe.BaseGateway.prototype.unblock=function(){e.unblockUI()},wc_stripe.BaseGateway.prototype.get_form=function(){return e(this.token_selector).closest("form")},wc_stripe.BaseGateway.prototype.get_total_price=function(){return e("#wc_stripe_order_total").data("amount")},wc_stripe.BaseGateway.prototype.get_total_price_cents=function(){return e("#wc_stripe_order_total_cents").data("amount")},wc_stripe.BaseGateway.prototype.set_total_price=function(t){e("#wc_stripe_order_total").data("amount",t)},wc_stripe.BaseGateway.prototype.set_total_price_cents=function(t){e("#wc_stripe_order_total_cents").data("amount",t)},wc_stripe.BaseGateway.prototype.set_payment_method=function(t){e('[name="payment_method"][value="'+t+'"]').prop("checked",!0).trigger("click")},wc_stripe.BaseGateway.prototype.set_selected_shipping_methods=function(t){if(t&&e('[name^="shipping_method"]').length)for(var i in t){var a=t[i];e('[name="shipping_method['+i+']"][value="'+a+'"]').prop("checked",!0).trigger("change")}},wc_stripe.BaseGateway.prototype.on_token_received=function(t){this.payment_token_received=!0,e(this.token_selector).val(t.id),this.process_checkout()},wc_stripe.BaseGateway.prototype.createPaymentRequest=function(){try{this.paymentRequest=i.paymentRequest(this.get_payment_request_options())}catch(t){return void this.submit_error(t.message)}this.needs_shipping()&&(this.paymentRequest.on("shippingaddresschange",this.update_shipping_address.bind(this)),this.paymentRequest.on("shippingoptionchange",this.update_shipping_method.bind(this))),this.paymentRequest.on("paymentmethod",this.on_payment_method_received.bind(this))},wc_stripe.BaseGateway.prototype.get_payment_request_options=function(){var t={country:this.params.country_code,currency:this.get_currency().toLowerCase(),total:{amount:this.get_total_price_cents(),label:this.params.total_label,pending:!0},requestPayerName:!0,requestPayerEmail:e("#billing_email").length>0,requestPayerPhone:e("#billing_phone").length>0,requestShipping:this.needs_shipping()},i=this.get_display_items(),a=this.get_shipping_options();return i&&(t.displayItems=i),this.needs_shipping()&&a&&(t.shippingOptions=a),t},wc_stripe.BaseGateway.prototype.get_payment_request_update=function(t){var i={currency:this.get_currency().toLowerCase(),total:{amount:parseInt(this.get_total_price_cents()),label:this.params.total_label,pending:!0}},a=this.get_display_items(),n=this.get_shipping_options();return a&&(i.displayItems=a),this.needs_shipping()&&n&&(i.shippingOptions=n),t&&(i=e.extend(!0,{},i,t)),i},wc_stripe.BaseGateway.prototype.get_display_items=function(){return e("#wc_stripe_display_items").data("items")},wc_stripe.BaseGateway.prototype.set_display_items=function(t){e("#wc_stripe_display_items").data("items",t)},wc_stripe.BaseGateway.prototype.get_shipping_options=function(){return e("#wc_stripe_shipping_options").data("items")},wc_stripe.BaseGateway.prototype.set_shipping_options=function(t){e("#wc_stripe_shipping_options").data("items",t)},wc_stripe.BaseGateway.prototype.map_address=function(t){return{city:t.city,postcode:t.postalCode,state:t.region,country:t.country}},wc_stripe.BaseGateway.prototype.on_payment_method_received=function(e){try{this.payment_response=e,this.populate_checkout_fields(e),e.complete("success"),this.on_token_received(e.paymentMethod)}catch(e){t.alert(e)}},wc_stripe.BaseGateway.prototype.populate_checkout_fields=function(t){e(this.token_selector).val(t.paymentMethod.id),this.populate_address_fields(t)},wc_stripe.BaseGateway.prototype.populate_address_fields=function(t){var i=this.address_mappings();if(t.payerName&&i.payerName.set(t.payerName),t.payerEmail&&i.payerEmail.set(t.payerEmail),t.payerPhone&&i.payerPhone.set(t.payerPhone),t.shippingAddress){var a=t.shippingAddress;for(var n in a)i[n]&&i[n].set.call(this,a[n],"#shipping")}if(t.paymentMethod.billing_details.address){a=t.paymentMethod.billing_details.address;for(var n in a)i[n]&&i[n].set.call(this,a[n],"#billing")}this.maybe_set_ship_to_different(),e('[name="billing_country"]').trigger("change")},wc_stripe.BaseGateway.prototype.address_mappings=function(){return{payerName:{set:function(t,i){var a=t.split(" ");a.length>0&&e("#billing_first_name").val(a[0]),a.length>1&&e("#billing_last_name").val(a[1])},get:function(t){return e("#billing_first_name").val()+" "+e("#billing_last_name").val()}},payerEmail:{set:function(t){e("#billing_email").val(t)},get:function(){return e("#billing_email").val()}},payerPhone:{set:function(t){e("#billing_phone").val(t)},get:function(){return e("#billing_phone").val()}},recipient:{set:function(t,i){var a=t.split(" ");a.length>0&&e(i+"_first_name").val(a[0]),a.length>1&&e(i+"_last_name").val(a[1])},get:function(t){return e(t+"_first_name").val()+" "+e(t+"_last_name").val()}},country:{set:function(t,i){e(i+"_country").val(t)},get:function(t){return e(t+"_country").val()}},addressLine:{set:function(t,i){t.length>0&&e(i+"_address_1").val(t[0]),t.length>1&&e(i+"_address_2").val(t[1])},get:function(t){return[e(t+"_address_1").val(),e(t+"_address_2").val()]}},line1:{set:function(t,i){e(i+"_address_1").val(t)},get:function(t){return e(t+"_address_1").val()}},line2:{set:function(t,i){e(i+"_address_2").val(t)},get:function(t){return e(t+"_address_2").val()}},region:{set:function(t,i){e(i+"_state").val(t)},get:function(t){e(t+"_state").val()}},state:{set:function(t,i){e(i+"_state").val(t)},get:function(t){e(t+"_state").val()}},city:{set:function(t,i){e(i+"_city").val(t)},get:function(t){e(t+"_city").val()}},postalCode:{set:function(t,i){e(i+"_postcode").val(t)},get:function(t){e(t+"_postcode").val()}},postal_code:{set:function(t,i){e(i+"_postcode").val(t)},get:function(t){e(t+"_postcode").val()}}}},wc_stripe.BaseGateway.prototype.process_checkout=function(){return new Promise(function(i,a){this.block(),e.ajax({url:this.params.routes.checkout,method:"POST",dataType:"json",data:e.extend({},this.serialize_form(this.get_form()),{payment_method:this.gateway_id,page_id:this.get_page()}),beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",this.params.rest_nonce)}.bind(this)}).done(function(e){e.reload?t.location.reload():"success"===e.result?t.location=e.redirect:(e.messages&&this.submit_error(e.messages),this.unblock())}.bind(this)).fail(function(t,e,i){this.unblock(),this.submit_error(i)}.bind(this))}.bind(this))},wc_stripe.BaseGateway.prototype.serialize_form=function(t){var i=t.find("input").filter(function(t,i){return!e(i).is('[name^="add-to-cart"]')}.bind(this)).serializeArray(),a={};for(var n in i){var s=i[n];a[s.name]=s.value}return a.payment_method=this.gateway_id,a},wc_stripe.BaseGateway.prototype.map_shipping_methods=function(t){var e={};if("default"!==t){var i=t.match(/^(\d):(.+)$/);i.length>1&&(e[i[1]]=i[2])}return e},wc_stripe.BaseGateway.prototype.maybe_set_ship_to_different=function(){e('[name="ship_to_different_address"]').length&&e('[name="ship_to_different_address"]').prop("checked",this.get_address_field_hash("#billing")!==this.get_address_field_hash("#shipping")).trigger("change")},wc_stripe.BaseGateway.prototype.update_shipping_address=function(t){return new Promise(function(i,a){e.ajax({url:this.params.routes.shipping_address,method:"POST",dataType:"json",data:{address:this.map_address(t.shippingAddress),payment_method:this.gateway_id,page_id:this.get_page()},beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",this.params.rest_nonce)}.bind(this)}).done(function(e){e.code?(t.updateWith(e.data.newData),a(e.data)):(t.updateWith(e.data.newData),i(e.data))}.bind(this)).fail(function(t,e,i){}.bind(this))}.bind(this))},wc_stripe.BaseGateway.prototype.update_shipping_method=function(t){return new Promise(function(i,a){e.ajax({url:this.params.routes.shipping_method,method:"POST",dataType:"json",data:{shipping_methods:this.map_shipping_methods(t.shippingOption.id),payment_method:this.gateway_id,page_id:this.get_page()},beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",this.params.rest_nonce)}.bind(this)}).done(function(e){e.code?(t.updateWith(e.data.newData),a(e.data)):(this.set_selected_shipping_methods(e.data.shipping_methods),t.updateWith(e.data.newData),i(e.data))}.bind(this)).fail(function(t,e,i){this.submit_error(i)}.bind(this))}.bind(this))},wc_stripe.CheckoutGateway=function(){this.container=this.message_container="li.payment_method_"+this.gateway_id,this.banner_container="li.banner_payment_method_"+this.gateway_id,e(document.body).on("update_checkout",this.update_checkout.bind(this)),e(document.body).on("updated_checkout",this.updated_checkout.bind(this)),e(document.body).on("checkout_error",this.checkout_error.bind(this)),e(this.token_selector).closest("form").on("checkout_place_order_"+this.gateway_id,this.checkout_place_order.bind(this)),e(document.body).on("wc_stripe_new_method_"+this.gateway_id,this.on_show_new_methods.bind(this)),e(document.body).on("wc_stripe_saved_method_"+this.gateway_id,this.on_show_saved_methods.bind(this)),e(document.body).on("wc_stripe_payment_method_selected",this.on_payment_method_selected.bind(this)),this.banner_enabled()&&e(".woocommerce-billing-fields").length&&e(".wc-stripe-banner-checkout").css("max-width",e(".woocommerce-billing-fields").outerWidth(!0)),this.order_review()},wc_stripe.CheckoutGateway.prototype.order_review=function(){var e=t.location.href.match(/order_review.+payment_method=([\w]+).+payment_nonce=(.+)/);if(e&&e.length>1){var i=e[1],a=e[2];this.gateway_id===i&&(this.payment_token_received=!0,this.set_nonce(a),this.set_use_new_option(!0))}},wc_stripe.CheckoutGateway.prototype.updated_checkout=function(){},wc_stripe.CheckoutGateway.prototype.update_checkout=function(){},wc_stripe.CheckoutGateway.prototype.checkout_error=function(){this.has_checkout_error()&&(this.payment_token_received=!1,this.payment_response=null,this.show_payment_button(),this.hide_place_order())},wc_stripe.CheckoutGateway.prototype.is_valid_checkout=function(){return!(e('[name="terms"]').length&&!e('[name="terms"]').is(":checked"))},wc_stripe.CheckoutGateway.prototype.get_payment_method=function(){return e('[name="payment_method"]:checked').val()},wc_stripe.CheckoutGateway.prototype.set_use_new_option=function(t){e("#"+this.gateway_id+"_use_new").prop("checked",t).trigger("change")},wc_stripe.CheckoutGateway.prototype.checkout_place_order=function(){return this.is_valid_checkout()?!!this.is_saved_method_selected()||this.payment_token_received:(this.submit_error(this.params.messages.terms),!1)},wc_stripe.CheckoutGateway.prototype.on_token_received=function(t){this.payment_token_received=!0,e(this.token_selector).val(t.id),this.hide_payment_button(),this.show_place_order()},wc_stripe.CheckoutGateway.prototype.block=function(){e("form.checkout").block({message:null,overlayCSS:{background:"#fff",opacity:.6}})},wc_stripe.CheckoutGateway.prototype.unblock=function(){e("form.checkout").unblock()},wc_stripe.CheckoutGateway.prototype.hide_place_order=function(){e("#place_order").addClass("wc-stripe-hide")},wc_stripe.CheckoutGateway.prototype.show_place_order=function(){e("#place_order").removeClass("wc-stripe-hide")},wc_stripe.CheckoutGateway.prototype.on_show_new_methods=function(){this.payment_token_received?(this.show_place_order(),this.hide_payment_button()):(this.hide_place_order(),this.show_payment_button())},wc_stripe.CheckoutGateway.prototype.on_show_saved_methods=function(){this.hide_payment_button(),this.show_place_order()},wc_stripe.CheckoutGateway.prototype.show_payment_button=function(){this.$button&&this.$button.show()},wc_stripe.CheckoutGateway.prototype.hide_payment_button=function(){this.$button&&this.$button.hide()},wc_stripe.CheckoutGateway.prototype.trigger_payment_method_selected=function(){this.on_payment_method_selected(null,e('[name="payment_method"]:checked').val())},wc_stripe.CheckoutGateway.prototype.on_payment_method_selected=function(t,e){e===this.gateway_id?this.payment_token_received||this.is_saved_method_selected()?(this.hide_payment_button(),this.show_place_order()):(this.show_payment_button(),this.hide_place_order()):(this.hide_payment_button(),e.indexOf("stripe_")<0&&this.show_place_order())},wc_stripe.CheckoutGateway.prototype.banner_enabled=function(){return"1"===this.params.banner_enabled},wc_stripe.CheckoutGateway.prototype.checkout_fields_valid=function(){if("undefined"==typeof wc_stripe_checkout_fields)return!0;var t=Object.keys(wc_stripe_checkout_fields.billing),i=Object.keys(wc_stripe_checkout_fields.shipping);function a(t,i){for(var a=0;a<t.length;a++){if(i[t[a]].required){var n=e("#"+t[a]).val();if(void 0===n||0==n.length)return void(valid=!1)}}}return valid=!0,a(t,wc_stripe_checkout_fields.billing),this.needs_shipping()&&e("#ship-to-different-address-checkbox").is(":checked")&&a(i,wc_stripe_checkout_fields.shipping),valid=this.is_valid_checkout(),valid},wc_stripe.ProductGateway=function(){this.container="li.payment_method_"+this.gateway_id,this.message_container="div.product",e(document.body).on("wc_stripe_updated_rest_nonce",this.set_rest_nonce.bind(this)),e("form.cart").on("found_variation",this.found_variation.bind(this)),e("form.cart").on("reset_data",this.reset_variation_data.bind(this)),this.buttonWidth=e("div.quantity").outerWidth(!0)+e(".single_add_to_cart_button").outerWidth(),(marginLeft=e(".single_add_to_cart_button").css("marginLeft"))&&(this.buttonWidth+=parseInt(marginLeft.replace("px",""))),e(this.container).css("max-width",this.buttonWidth+"px")},wc_stripe.ProductGateway.prototype.get_quantity=function(){return parseInt(e('[name="quantity"]').val())},wc_stripe.ProductGateway.prototype.set_rest_nonce=function(t,e){this.params.rest_nonce=e},wc_stripe.ProductGateway.prototype.found_variation=function(t,e){var i=this.get_product_data();i.price=e.display_price,i.needs_shipping=!e.is_virtual,i.variation=e,this.set_product_data(i),this.enable_payment_button()},wc_stripe.ProductGateway.prototype.reset_variation_data=function(){this.disable_payment_button()},wc_stripe.ProductGateway.prototype.disable_payment_button=function(){this.$button&&this.get_button().prop("disabled",!0).addClass("disabled")},wc_stripe.ProductGateway.prototype.enable_payment_button=function(){this.$button&&this.get_button().prop("disabled",!1).removeClass("disabled")},wc_stripe.ProductGateway.prototype.get_button=function(){return this.$button},wc_stripe.ProductGateway.prototype.is_variable_product=function(){return e('[name="variation_id"]').length>0},wc_stripe.ProductGateway.prototype.needs_shipping=function(){return this.get_product_data().needs_shipping},wc_stripe.ProductGateway.prototype.get_product_data=function(){return e("#wc_stripe_product_data").data("product")},wc_stripe.ProductGateway.prototype.set_product_data=function(t){e("#wc_stripe_product_data").data("product",t)},wc_stripe.ProductGateway.prototype.add_to_cart=function(){return new Promise(function(t,i){this.block(),e.ajax({url:this.params.routes.add_to_cart,method:"POST",dataType:"json",data:{product_id:e("#product_id").val(),variation_id:this.is_variable_product()?e('[name="variation_id"]').val():0,qty:e('[name="quantity"]').val(),payment_method:this.gateway_id,page_id:this.get_page()},beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",this.params.rest_nonce)}.bind(this)}).done(function(a,n,s){this.unblock(),e(document.body).triggerHandler("wc_stripe_updated_rest_nonce",s.getResponseHeader("X-WP-Nonce")),a.code?(this.submit_error(a.message),i(a)):(this.set_total_price(a.data.total),this.set_total_price_cents(a.data.totalCents),this.set_display_items(a.data.displayItems),t(a.data))}.bind(this)).fail(function(t,e,i){this.unblock(),this.submit_error(i)}.bind(this))}.bind(this))},wc_stripe.ProductGateway.prototype.cart_calculation=function(t){return new Promise(function(i,a){e.ajax({url:this.params.routes.cart_calculation,method:"POST",dataType:"json",data:{product_id:e("#product_id").val(),variation_id:this.is_variable_product()&&t?t:0,qty:e('[name="quantity"]').val(),payment_method:this.gateway_id},beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",this.params.rest_nonce)}.bind(this)}).done(function(t,a,n){e(document.body).triggerHandler("wc_stripe_updated_rest_nonce",n.getResponseHeader("X-WP-Nonce")),t.code?this.cart_calculation_error=!0:(this.set_total_price(t.data.total),this.set_total_price_cents(t.data.totalCents),this.set_display_items(t.data.displayItems),i(t.data))}.bind(this)).fail(function(t,e,i){}.bind(this))}.bind(this))},wc_stripe.CartGateway=function(){this.container="li.payment_method_"+this.gateway_id,this.message_container="div.woocommerce",e(document.body).on("updated_wc_div",this.updated_html.bind(this)),e(document.body).on("updated_cart_totals",this.updated_html.bind(this)),e(document.body).on("wc_cart_emptied",this.cart_emptied.bind(this))},wc_stripe.CartGateway.prototype.needs_shipping=function(){return 1===e("#wc_stripe_needs_shipping").data("value")},wc_stripe.CartGateway.prototype.submit_error=function(t){this.submit_message(this.get_error_message(t))},wc_stripe.CartGateway.prototype.updated_html=function(t){},wc_stripe.CartGateway.prototype.cart_emptied=function(t){},wc_stripe.CartGateway.prototype.add_cart_totals_class=function(){e(".cart_totals").addClass("stripe_cart_gateway_active")},wc_stripe.GooglePay=function(){};const a={apiVersion:2,apiVersionMinor:0},n={type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY"],allowedCardNetworks:["AMEX","DISCOVER","INTERAC","JCB","MASTERCARD","VISA"]}};wc_stripe.GooglePay.prototype.address_mappings=function(t){return{name:{set:function(t,i){var a=t.split(" ");e(i+"_first_name").val(a[0]),e(i+"_last_name").val(a[1])},get:function(t){return e(t+"_first_name").val()+e(t+"_last_name").val()}},postalCode:{set:function(t,i){e(i+"_postcode").val(t)},get:function(t){return e(t+"_postcode").val()}},countryCode:{set:function(t,i){e(i+"_country").val(t)},get:function(t){return e(t+"_country").val()}},phoneNumber:{set:function(t,i){e("#billing_phone").val(t)},get:function(){return"#billing_phone".val()}},address1:{set:function(t,i){e(i+"_address_1").val(t)},get:function(t){return e(t+"_address_1").val()}},address2:{set:function(t,i){e(i+"_address_2").val(t)},get:function(t){return e(t+"_address_2").val()}},locality:{set:function(t,i){e(i+"_city").val(t)},get:function(t){return e(t+"_city").val()}},administrativeArea:{set:function(t,i){e(i+"_state").val(t)},get:function(t){return e(t+"_state").val()}}}},wc_stripe.GooglePay.prototype.serialize_form=function(t){return e.extend({},wc_stripe.BaseGateway.prototype.serialize_form.apply(this,arguments),{order_review:!this.dynamic_price_enabled()})},wc_stripe.GooglePay.prototype.populate_address_fields=function(t){var i=t.paymentMethodData.info.billingAddress,a=this.address_mappings();for(var n in i)a[n]&&a[n].set.call(this,i[n],"#billing");if(t.shippingAddress)for(var n in t.shippingAddress)a[n]&&a[n].set.call(this,t.shippingAddress[n],"#shipping");t.email&&e("#billing_email").val(t.email),this.maybe_set_ship_to_different(),e('[name="billing_country"]').trigger("change")},wc_stripe.GooglePay.prototype.map_address=function(t){return{city:t.locality,postcode:t.postalCode,state:t.administrativeArea,country:t.countryCode}},wc_stripe.GooglePay.prototype.update_payment_data=function(t){return new Promise(function(i,a){e.when(e.ajax({url:this.params.routes.payment_data,dataType:"json",method:"POST",data:{shipping_address:this.map_address(t.shippingAddress),shipping_methods:this.map_shipping_methods(t.shippingOptionData.id),shipping_method_id:t.shippingOptionData.id,page_id:this.get_page()},beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",this.params.rest_nonce)}.bind(this)})).done(function(t){t.code?a(t.data.data):i(t.data)}.bind(this)).fail(function(){a()}.bind(this))}.bind(this))},wc_stripe.GooglePay.prototype.on_payment_data_changed=function(t){return new Promise(function(e,i){this.update_payment_data(t).then(function(i){e(i.paymentRequestUpdate),this.set_selected_shipping_methods(i.shipping_methods),this.payment_data_updated(i,t)}.bind(this)).catch(function(t){e(t)}.bind(this))}.bind(this))},wc_stripe.GooglePay.prototype.payment_data_updated=function(t){},wc_stripe.GooglePay.prototype.get_googlepay_display_items=function(){return e("#googlepay_display_items").data("items")},wc_stripe.GooglePay.prototype.set_googlepay_display_items=function(t){e("#googlepay_display_items").data("items",t)},wc_stripe.GooglePay.prototype.get_shipping_options=function(){return e("#googlepay_shipping_options").data("items")},wc_stripe.GooglePay.prototype.get_merchant_info=function(){var t={merchantId:this.params.merchant_id,merchantName:this.params.merchant_name};return"TEST"===this.params.environment&&delete t.merchantId,t},wc_stripe.GooglePay.prototype.dynamic_price_enabled=function(){return"1"===this.params.dynamic_price},wc_stripe.GooglePay.prototype.get_payment_options=function(){var t={environment:this.params.environment,merchantInfo:this.get_merchant_info()};return this.dynamic_price_enabled()&&(this.needs_shipping()&&this.get_total_price_cents()>0?t.paymentDataCallbacks={onPaymentDataChanged:this.on_payment_data_changed.bind(this),onPaymentAuthorized:function(t){return new Promise(function(t,e){t({transactionState:"SUCCESS"})}.bind(this))}.bind(this)}:t.paymentDataCallbacks={onPaymentAuthorized:function(t){return new Promise(function(t,e){t({transactionState:"SUCCESS"})}.bind(this))}}),t},wc_stripe.GooglePay.prototype.build_payment_request=function(){var t=e.extend({},a,{emailRequired:!0,merchantInfo:this.get_merchant_info(),allowedPaymentMethods:[e.extend({type:"CARD",tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:"stripe","stripe:version":"2018-10-31","stripe:publishableKey":this.params.api_key}}},n)],shippingAddressRequired:this.needs_shipping()&&this.get_total_price_cents()>0,transactionInfo:{currencyCode:this.get_currency(),totalPriceStatus:"ESTIMATED",totalPrice:this.get_total_price().toString(),displayItems:this.get_googlepay_display_items(),totalPriceLabel:this.params.total_price_label}});return t.allowedPaymentMethods[0].parameters.billingAddressRequired=!0,t.allowedPaymentMethods[0].parameters.billingAddressParameters={format:"FULL",phoneNumberRequired:e("#billing_phone").length>0},this.dynamic_price_enabled()&&(this.needs_shipping()&&this.get_total_price_cents()>0?(t.shippingAddressParameters={},t.shippingOptionRequired=!0,t.shippingOptionParameters={shippingOptions:this.get_shipping_options()},t.callbackIntents=["SHIPPING_ADDRESS","SHIPPING_OPTION","PAYMENT_AUTHORIZATION"]):t.callbackIntents=["PAYMENT_AUTHORIZATION"]),t},wc_stripe.GooglePay.prototype.createPaymentsClient=function(){this.paymentsClient=new google.payments.api.PaymentsClient(this.get_payment_options())},wc_stripe.GooglePay.prototype.isReadyToPay=function(){return new Promise(function(t){var i=e.extend({},a);i.allowedPaymentMethods=[n],this.paymentsClient.isReadyToPay(i).then(function(){this.can_pay=!0,this.create_button(),t()}.bind(this)).catch(function(t){this.submit_error(t)}.bind(this))}.bind(this))},wc_stripe.GooglePay.prototype.create_button=function(){this.$button&&this.$button.remove(),this.$button=e(this.paymentsClient.createButton({onClick:this.start.bind(this),buttonColor:this.params.button_color,buttonType:this.params.button_style})),this.$button.addClass("gpay-button-container")},wc_stripe.GooglePay.prototype.start=function(){this.createPaymentsClient(),this.paymentsClient.loadPaymentData(this.build_payment_request()).then(function(t){var e=JSON.parse(t.paymentMethodData.tokenizationData.token);this.populate_address_fields(t),this.on_token_received(e)}.bind(this)).catch(function(t){"CANCELED"!==t.statusCode&&(t.statusMessage&&t.statusMessage.indexOf("paymentDataRequest.callbackIntent")>-1?this.submit_error_code("DEVELOPER_ERROR_WHITELIST"):this.submit_error(t.statusMessage))}.bind(this))},wc_stripe.ApplePay=function(){},wc_stripe.ApplePay.prototype.initialize=function(){e(document.body).on("click",".apple-pay-button",this.start.bind(this)),this.createPaymentRequest(),this.canMakePayment()},wc_stripe.ApplePay.prototype.create_button=function(){this.$button&&this.$button.remove(),this.$button=e(this.params.button),this.append_button()},wc_stripe.ApplePay.prototype.canMakePayment=function(){return new Promise(function(t,i){this.paymentRequest.canMakePayment().then(function(i){i&&i.applePay&&(this.can_pay=!0,this.create_button(),e(this.container).show(),t(i))}.bind(this))}.bind(this))},wc_stripe.ApplePay.prototype.start=function(t){t.preventDefault(),this.paymentRequest.update(this.get_payment_request_update({total:{pending:!1}})),this.paymentRequest.show()},wc_stripe.PaymentRequest=function(){},wc_stripe.PaymentRequest.prototype.initialize=function(){this.createPaymentRequest(),this.canMakePayment(),this.paymentRequestButton=this.createPaymentRequestButton(),this.paymentRequestButton.on("click",this.button_click.bind(this))},wc_stripe.PaymentRequest.prototype.button_click=function(t){},wc_stripe.PaymentRequest.prototype.createPaymentRequestButton=function(){return this.elements.create("paymentRequestButton",{paymentRequest:this.paymentRequest,style:{paymentRequestButton:{type:this.params.button.type,theme:this.params.button.theme,height:this.params.button.height}}})},wc_stripe.PaymentRequest.prototype.canMakePayment=function(){return new Promise(function(t,i){this.paymentRequest.canMakePayment().then(function(i){i&&!i.applePay&&(this.can_pay=!0,this.create_button(),e(this.container).show(),t(i))}.bind(this))}.bind(this))},wc_stripe.PaymentRequest.prototype.create_button=function(){this.paymentRequestButton.mount("#wc-stripe-payment-request-container")};try{i=Stripe(wc_stripe_params_v3.api_key,{stripeAccount:wc_stripe_params_v3.account})}catch(e){return t.alert(e),void console.log(e)}}(window,jQuery);
|
1 |
+
!function(t,e){t.wc_stripe={};var i=null;"undefined"==typeof wc_stripe_checkout_fields&&(wc_stripe_checkout_fields=[]),wc_stripe.BaseGateway=function(t){this.params=t,this.gateway_id=this.params.gateway_id,this.container="li.payment_method_"+this.gateway_id,this.token_selector=this.params.token_selector,this.saved_method_selector=this.params.saved_method_selector,this.payment_token_received=!1,this.stripe=i,this.elements=i.elements(e.extend({},{locale:"auto"},this.get_element_options())),this.mappings=new wc_stripe.CheckoutFields(wc_stripe_checkout_fields),this.initialize()},wc_stripe.BaseGateway.prototype.get_page=function(){return wc_stripe_params_v3.page},wc_stripe.BaseGateway.prototype.set_nonce=function(t){this.mappings.set(this.gateway_id+"_token_key",t),e(this.token_selector).val(t)},wc_stripe.BaseGateway.prototype.get_element_options=function(){return{}},wc_stripe.BaseGateway.prototype.initialize=function(){},wc_stripe.BaseGateway.prototype.create_button=function(){},wc_stripe.BaseGateway.prototype.is_gateway_selected=function(){return e('[name="payment_method"]:checked').val()===this.gateway_id},wc_stripe.BaseGateway.prototype.is_saved_method_selected=function(){return this.is_gateway_selected()&&"saved"===e('[name="'+this.gateway_id+'_payment_type_key"]:checked').val()},wc_stripe.BaseGateway.prototype.has_checkout_error=function(){return e("#wc_stripe_checkout_error").length>0&&this.is_gateway_selected()},wc_stripe.BaseGateway.prototype.submit_error=function(t){-1==(t=this.get_error_message(t)).indexOf("</ul>")&&(t='<div class="woocommerce-error">'+t+"</div>"),this.submit_message(t)},wc_stripe.BaseGateway.prototype.submit_error_code=function(t){},wc_stripe.BaseGateway.prototype.get_error_message=function(t){return"object"==typeof t&&t.code&&(t=wc_stripe_messages[t.code]?wc_stripe_messages[t.code]:t.message),t},wc_stripe.BaseGateway.prototype.submit_message=function(t){e(".woocommerce-error, .woocommerce-message, .woocommerce-info").remove();var i=e(this.message_container);i.closest("form").length&&(i=i.closest("form")),i.prepend(t),i.removeClass("processing").unblock(),i.find(".input-text, select, input:checkbox").blur(),e.scroll_to_notices?e.scroll_to_notices(i):e("html, body").animate({scrollTop:i.offset().top-100},1e3)},wc_stripe.BaseGateway.prototype.get_first_name=function(t){return e("#"+t+"_first_name").val()},wc_stripe.BaseGateway.prototype.get_last_name=function(t){return e("#"+t+"_last_name").val()},wc_stripe.BaseGateway.prototype.should_save_method=function(){return e("#"+this.gateway_id+"_save_source_key").is(":checked")},wc_stripe.BaseGateway.prototype.is_add_payment_method_page=function(){return"add_payment_method"===this.get_page()||e(document.body).hasClass("woocommerce-add-payment-method")},wc_stripe.BaseGateway.prototype.is_change_payment_method=function(){return"change_payment_method"===this.get_page()},wc_stripe.BaseGateway.prototype.get_selected_payment_method=function(){return e(this.saved_method_selector).val()},wc_stripe.BaseGateway.prototype.needs_shipping=function(){return this.get_gateway_data().needs_shipping},wc_stripe.BaseGateway.prototype.get_currency=function(){return this.get_gateway_data().currency},wc_stripe.BaseGateway.prototype.get_gateway_data=function(){return e("#"+this.gateway_id+"_"+this.get_page()+"_data").data("gateway")},wc_stripe.BaseGateway.prototype.set_gateway_data=function(t){e("#"+this.gateway_id+"_"+this.get_page()+"_data").data("gateway",t)},wc_stripe.BaseGateway.prototype.get_customer_name=function(t){return e(t+"_first_name").val()+" "+e(t+"_last_name").val()},wc_stripe.BaseGateway.prototype.get_customer_email=function(){return e("#billing_email").val()},wc_stripe.BaseGateway.prototype.get_address_field_hash=function(t){for(var e=["_first_name","_last_name","_address_1","_address_2","_postcode","_city","_state","_country"],i="",s=0;s<e.length;s++)i+=this.mappings.get(t+e[s])+"_";return i},wc_stripe.BaseGateway.prototype.block=function(){e.blockUI({message:null,overlayCSS:{background:"#fff",opacity:.6}})},wc_stripe.BaseGateway.prototype.unblock=function(){e.unblockUI()},wc_stripe.BaseGateway.prototype.get_form=function(){return e(this.token_selector).closest("form")},wc_stripe.BaseGateway.prototype.get_total_price=function(){return this.get_gateway_data().total},wc_stripe.BaseGateway.prototype.get_total_price_cents=function(){return this.get_gateway_data().total_cents},wc_stripe.BaseGateway.prototype.set_total_price=function(t){var e=this.get_gateway_data();e.total=t,this.set_gateway_data(e)},wc_stripe.BaseGateway.prototype.set_total_price_cents=function(t){var e=this.get_gateway_data();e.total_cents=t,this.set_gateway_data(e)},wc_stripe.BaseGateway.prototype.set_payment_method=function(t){e('[name="payment_method"][value="'+t+'"]').prop("checked",!0).trigger("click")},wc_stripe.BaseGateway.prototype.set_selected_shipping_methods=function(t){if(t&&e('[name^="shipping_method"]').length)for(var i in t){var s=t[i];e('[name="shipping_method['+i+']"][value="'+s+'"]').prop("checked",!0).trigger("change")}},wc_stripe.BaseGateway.prototype.on_token_received=function(t){this.payment_token_received=!0,this.set_nonce(t.id),this.process_checkout()},wc_stripe.BaseGateway.prototype.createPaymentRequest=function(){try{this.paymentRequest=i.paymentRequest(this.get_payment_request_options())}catch(t){return void this.submit_error(t.message)}this.needs_shipping()&&(this.paymentRequest.on("shippingaddresschange",this.update_shipping_address.bind(this)),this.paymentRequest.on("shippingoptionchange",this.update_shipping_method.bind(this))),this.paymentRequest.on("paymentmethod",this.on_payment_method_received.bind(this))},wc_stripe.BaseGateway.prototype.get_payment_request_options=function(){var t={country:this.params.country_code,currency:this.get_currency().toLowerCase(),total:{amount:this.get_total_price_cents(),label:this.params.total_label,pending:!0},requestPayerName:!0,requestPayerEmail:this.mappings.required("billing_email"),requestPayerPhone:this.mappings.required("billing_phone"),requestShipping:this.needs_shipping()},e=this.get_display_items(),i=this.get_shipping_options();return e&&(t.displayItems=e),this.needs_shipping()&&i&&(t.shippingOptions=i),t},wc_stripe.BaseGateway.prototype.get_payment_request_update=function(t){var i={currency:this.get_currency().toLowerCase(),total:{amount:parseInt(this.get_total_price_cents()),label:this.params.total_label,pending:!0}},s=this.get_display_items(),a=this.get_shipping_options();return s&&(i.displayItems=s),this.needs_shipping()&&a&&(i.shippingOptions=a),t&&(i=e.extend(!0,{},i,t)),i},wc_stripe.BaseGateway.prototype.get_display_items=function(){return this.get_gateway_data().items},wc_stripe.BaseGateway.prototype.set_display_items=function(t){var e=this.get_gateway_data();e.items=t,this.set_gateway_data(e)},wc_stripe.BaseGateway.prototype.get_shipping_options=function(){return this.get_gateway_data().shipping_options},wc_stripe.BaseGateway.prototype.set_shipping_options=function(t){var e=this.get_gateway_data();e.shipping_options=t,this.set_gateway_data(e)},wc_stripe.BaseGateway.prototype.map_address=function(t){return{city:t.city,postcode:t.postalCode,state:t.region,country:t.country}},wc_stripe.BaseGateway.prototype.on_payment_method_received=function(e){try{this.payment_response=e,this.populate_checkout_fields(e),e.complete("success"),this.on_token_received(e.paymentMethod)}catch(e){t.alert(e)}},wc_stripe.BaseGateway.prototype.populate_checkout_fields=function(t){this.set_nonce(t.paymentMethod.id),this.populate_address_fields(t)},wc_stripe.BaseGateway.prototype.populate_address_fields=function(t){if(t.payerName&&this.mappings.set("name",t.payerName,"billing"),t.payerEmail&&this.mappings.set("email",t.payerEmail,"billing"),t.payerPhone&&this.mappings.set("phone",t.payerPhone,"billing"),t.shippingAddress){var i=t.shippingAddress;for(var s in i)this.mappings.set(s,i[s],"shipping")}if(t.paymentMethod.billing_details.address){i=t.paymentMethod.billing_details.address;for(var s in i)this.mappings.set(s,i[s],"billing")}"checkout"===this.get_page()&&(this.maybe_set_ship_to_different(),this.mappings.toFormFields(),e('[name="billing_country"]').trigger("change"))},wc_stripe.BaseGateway.prototype.address_mappings=function(){return new wc_stripe.CheckoutFields},wc_stripe.BaseGateway.prototype.ajax_before_send=function(t){this.params.user_id>0&&t.setRequestHeader("X-WP-Nonce",this.params.rest_nonce)},wc_stripe.BaseGateway.prototype.process_checkout=function(){return new Promise(function(i,s){this.block(),e.ajax({url:this.params.routes.checkout,method:"POST",dataType:"json",data:e.extend({},this.serialize_fields(),{payment_method:this.gateway_id,page_id:this.get_page()}),beforeSend:this.ajax_before_send.bind(this)}).done(function(e){e.reload?t.location.reload():"success"===e.result?t.location=e.redirect:(e.messages&&this.submit_error(e.messages),this.unblock())}.bind(this)).fail(function(t,e,i){this.unblock(),this.submit_error(i)}.bind(this))}.bind(this))},wc_stripe.BaseGateway.prototype.serialize_form=function(t){var i=t.find("input").filter(function(t,i){return!e(i).is('[name^="add-to-cart"]')}.bind(this)).serializeArray(),s={};for(var a in i){var n=i[a];s[n.name]=n.value}return s.payment_method=this.gateway_id,s},wc_stripe.BaseGateway.prototype.serialize_fields=function(){return this.mappings.toJson()},wc_stripe.BaseGateway.prototype.map_shipping_methods=function(t){var e={};if("default"!==t){var i=t.match(/^([\w+]):(.+)$/);i.length>1&&(e[i[1]]=i[2])}return e},wc_stripe.BaseGateway.prototype.maybe_set_ship_to_different=function(){e('[name="ship_to_different_address"]').length&&e('[name="ship_to_different_address"]').prop("checked",this.get_address_field_hash("billing")!==this.get_address_field_hash("shipping")).trigger("change")},wc_stripe.BaseGateway.prototype.update_shipping_address=function(t){return new Promise(function(i,s){e.ajax({url:this.params.routes.shipping_address,method:"POST",dataType:"json",data:{address:this.map_address(t.shippingAddress),payment_method:this.gateway_id,page_id:this.get_page()},beforeSend:this.ajax_before_send.bind(this)}).done(function(e){e.code?(t.updateWith(e.data.newData),s(e.data)):(t.updateWith(e.data.newData),i(e.data))}.bind(this)).fail(function(t,e,i){}.bind(this))}.bind(this))},wc_stripe.BaseGateway.prototype.update_shipping_method=function(t){return new Promise(function(i,s){e.ajax({url:this.params.routes.shipping_method,method:"POST",dataType:"json",data:{shipping_method:t.shippingOption.id,payment_method:this.gateway_id,page_id:this.get_page()},beforeSend:this.ajax_before_send.bind(this)}).done(function(e){e.code?(t.updateWith(e.data.newData),s(e.data)):(this.set_selected_shipping_methods(e.data.shipping_methods),t.updateWith(e.data.newData),i(e.data))}.bind(this)).fail(function(t,e,i){this.submit_error(i)}.bind(this))}.bind(this))},wc_stripe.CheckoutGateway=function(){this.message_container="li.payment_method_"+this.gateway_id,this.banner_container="li.banner_payment_method_"+this.gateway_id,e(document.body).on("update_checkout",this.update_checkout.bind(this)),e(document.body).on("updated_checkout",this.updated_checkout.bind(this)),e(document.body).on("checkout_error",this.checkout_error.bind(this)),e(this.token_selector).closest("form").on("checkout_place_order_"+this.gateway_id,this.checkout_place_order.bind(this)),e(document.body).on("wc_stripe_new_method_"+this.gateway_id,this.on_show_new_methods.bind(this)),e(document.body).on("wc_stripe_saved_method_"+this.gateway_id,this.on_show_saved_methods.bind(this)),e(document.body).on("wc_stripe_payment_method_selected",this.on_payment_method_selected.bind(this)),this.banner_enabled()&&e(".woocommerce-billing-fields").length&&e(".wc-stripe-banner-checkout").css("max-width",e(".woocommerce-billing-fields").outerWidth(!0)),this.order_review()},wc_stripe.CheckoutGateway.prototype.order_review=function(){var e=t.location.href.match(/order_review.+payment_method=([\w]+).+payment_nonce=(.+)/);if(e&&e.length>1){var i=e[1],s=e[2];this.gateway_id===i&&(this.payment_token_received=!0,this.set_nonce(s),this.set_use_new_option(!0))}},wc_stripe.CheckoutGateway.prototype.updated_checkout=function(){},wc_stripe.CheckoutGateway.prototype.update_checkout=function(){},wc_stripe.CheckoutGateway.prototype.checkout_error=function(){this.has_checkout_error()&&(this.payment_token_received=!1,this.payment_response=null,this.show_payment_button(),this.hide_place_order())},wc_stripe.CheckoutGateway.prototype.is_valid_checkout=function(){return!(e('[name="terms"]').length&&!e('[name="terms"]').is(":checked"))},wc_stripe.CheckoutGateway.prototype.get_payment_method=function(){return e('[name="payment_method"]:checked').val()},wc_stripe.CheckoutGateway.prototype.set_use_new_option=function(t){e("#"+this.gateway_id+"_use_new").prop("checked",t).trigger("change")},wc_stripe.CheckoutGateway.prototype.checkout_place_order=function(){return this.is_valid_checkout()?!!this.is_saved_method_selected()||this.payment_token_received:(this.submit_error(this.params.messages.terms),!1)},wc_stripe.CheckoutGateway.prototype.on_token_received=function(t){this.payment_token_received=!0,this.set_nonce(t.id),this.hide_payment_button(),this.show_place_order()},wc_stripe.CheckoutGateway.prototype.block=function(){e("form.checkout").block({message:null,overlayCSS:{background:"#fff",opacity:.6}})},wc_stripe.CheckoutGateway.prototype.unblock=function(){e("form.checkout").unblock()},wc_stripe.CheckoutGateway.prototype.hide_place_order=function(){e("#place_order").addClass("wc-stripe-hide")},wc_stripe.CheckoutGateway.prototype.show_place_order=function(){e("#place_order").removeClass("wc-stripe-hide")},wc_stripe.CheckoutGateway.prototype.on_show_new_methods=function(){this.payment_token_received?(this.show_place_order(),this.hide_payment_button()):(this.hide_place_order(),this.show_payment_button())},wc_stripe.CheckoutGateway.prototype.on_show_saved_methods=function(){this.hide_payment_button(),this.show_place_order()},wc_stripe.CheckoutGateway.prototype.show_payment_button=function(){this.$button&&this.$button.show()},wc_stripe.CheckoutGateway.prototype.hide_payment_button=function(){this.$button&&this.$button.hide()},wc_stripe.CheckoutGateway.prototype.trigger_payment_method_selected=function(){this.on_payment_method_selected(null,e('[name="payment_method"]:checked').val())},wc_stripe.CheckoutGateway.prototype.on_payment_method_selected=function(t,e){e===this.gateway_id?this.payment_token_received||this.is_saved_method_selected()?(this.hide_payment_button(),this.show_place_order()):(this.show_payment_button(),this.hide_place_order()):(this.hide_payment_button(),e.indexOf("stripe_")<0&&this.show_place_order())},wc_stripe.CheckoutGateway.prototype.banner_enabled=function(){return"1"===this.params.banner_enabled},wc_stripe.CheckoutGateway.prototype.checkout_fields_valid=function(){if("undefined"==typeof wc_stripe_checkout_fields||"checkout"!==this.get_page())return!0;function t(t,i){for(var s in i){var a=i[s];if(s.indexOf(t)>-1&&a.required&&e("#"+s).length){var n=e("#"+s).val();if(void 0===n||0==n.length)return void(valid=!1)}}}return valid=!0,t("billing",wc_stripe_checkout_fields),this.needs_shipping()&&e("#ship-to-different-address-checkbox").is(":checked")&&t("shipping",wc_stripe_checkout_fields),valid&&(valid=this.is_valid_checkout()),valid},wc_stripe.ProductGateway=function(){this.message_container="div.product",e("form.cart").on("found_variation",this.found_variation.bind(this)),e("form.cart").on("reset_data",this.reset_variation_data.bind(this)),this.buttonWidth=e("div.quantity").outerWidth(!0)+e(".single_add_to_cart_button").outerWidth();var t=e(".single_add_to_cart_button").css("marginLeft");t&&(this.buttonWidth+=parseInt(t.replace("px",""))),e(this.container).css("max-width",this.buttonWidth+"px")},wc_stripe.ProductGateway.prototype.get_quantity=function(){return parseInt(e('[name="quantity"]').val())},wc_stripe.ProductGateway.prototype.set_rest_nonce=function(t,e){this.params.rest_nonce=e},wc_stripe.ProductGateway.prototype.found_variation=function(t,e){var i=this.get_gateway_data();i.product.price=e.display_price,i.needs_shipping=!e.is_virtual,i.product.variation=e,this.set_gateway_data(i),this.enable_payment_button()},wc_stripe.ProductGateway.prototype.reset_variation_data=function(){var t=this.get_product_data();t.variation=!1,this.set_product_data(t),this.disable_payment_button()},wc_stripe.ProductGateway.prototype.disable_payment_button=function(){this.$button&&this.get_button().prop("disabled",!0).addClass("disabled")},wc_stripe.ProductGateway.prototype.enable_payment_button=function(){this.$button&&this.get_button().prop("disabled",!1).removeClass("disabled")},wc_stripe.ProductGateway.prototype.get_button=function(){return this.$button},wc_stripe.ProductGateway.prototype.is_variable_product=function(){return e('[name="variation_id"]').length>0},wc_stripe.ProductGateway.prototype.variable_product_selected=function(){return!1!==this.get_product_data().variation},wc_stripe.ProductGateway.prototype.get_product_data=function(){return this.get_gateway_data().product},wc_stripe.ProductGateway.prototype.set_product_data=function(t){var e=this.get_gateway_data();e.product=t,this.set_gateway_data(e)},wc_stripe.ProductGateway.prototype.add_to_cart=function(){return new Promise(function(t,i){this.block(),e.ajax({url:this.params.routes.add_to_cart,method:"POST",dataType:"json",data:{product_id:this.get_product_data().id,variation_id:this.is_variable_product()?e('[name="variation_id"]').val():0,qty:e('[name="quantity"]').val(),payment_method:this.gateway_id,page_id:this.get_page()},beforeSend:this.ajax_before_send.bind(this)}).done(function(e,s,a){this.unblock(),e.code?(this.submit_error(e.message),i(e)):(this.set_total_price(e.data.total),this.set_total_price_cents(e.data.totalCents),this.set_display_items(e.data.displayItems),t(e.data))}.bind(this)).fail(function(t,e,i){this.unblock(),this.submit_error(i)}.bind(this))}.bind(this))},wc_stripe.ProductGateway.prototype.cart_calculation=function(t){return new Promise(function(i,s){e.ajax({url:this.params.routes.cart_calculation,method:"POST",dataType:"json",data:{product_id:this.get_product_data().id,variation_id:this.is_variable_product()&&t?t:0,qty:e('[name="quantity"]').val(),payment_method:this.gateway_id},beforeSend:this.ajax_before_send.bind(this)}).done(function(t,e,a){t.code?(this.cart_calculation_error=!0,s(t)):(this.set_total_price(t.data.total),this.set_total_price_cents(t.data.totalCents),this.set_display_items(t.data.displayItems),i(t.data))}.bind(this)).fail(function(t,e,i){}.bind(this))}.bind(this))},wc_stripe.CartGateway=function(){this.message_container="div.woocommerce",e(document.body).on("updated_wc_div",this.updated_html.bind(this)),e(document.body).on("updated_cart_totals",this.updated_html.bind(this)),e(document.body).on("wc_cart_emptied",this.cart_emptied.bind(this))},wc_stripe.CartGateway.prototype.submit_error=function(t){this.submit_message(this.get_error_message(t))},wc_stripe.CartGateway.prototype.updated_html=function(t){},wc_stripe.CartGateway.prototype.cart_emptied=function(t){},wc_stripe.CartGateway.prototype.add_cart_totals_class=function(){e(".cart_totals").addClass("stripe_cart_gateway_active")},wc_stripe.GooglePay=function(){};const s={apiVersion:2,apiVersionMinor:0},a={type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY"],allowedCardNetworks:["AMEX","DISCOVER","INTERAC","JCB","MASTERCARD","VISA"]}};wc_stripe.GooglePay.prototype.populate_address_fields=function(t){var i=t.paymentMethodData.info.billingAddress;for(var s in i)this.mappings.set(s,i[s],"billing");if(t.shippingAddress)for(var s in t.shippingAddress)this.mappings.set(s,t.shippingAddress[s],"shipping");t.email&&this.mappings.set("email",t.email,"billing"),"checkout"===this.get_page()&&(this.maybe_set_ship_to_different(),this.mappings.toFormFields(),e('[name="billing_country"]').trigger("change"))},wc_stripe.GooglePay.prototype.map_address=function(t){return{city:t.locality,postcode:t.postalCode,state:t.administrativeArea,country:t.countryCode}},wc_stripe.GooglePay.prototype.update_payment_data=function(t){return new Promise(function(i,s){var a="default"==t.shippingOptionData.id?null:t.shippingOptionData.id;e.when(e.ajax({url:this.params.routes.payment_data,dataType:"json",method:"POST",data:{shipping_address:this.map_address(t.shippingAddress),shipping_method:a,page_id:this.get_page()},beforeSend:this.ajax_before_send.bind(this)})).done(function(t){t.code?s(t.data.data):i(t.data)}.bind(this)).fail(function(){s()}.bind(this))}.bind(this))},wc_stripe.GooglePay.prototype.on_payment_data_changed=function(t){return new Promise(function(e,i){this.update_payment_data(t).then(function(i){e(i.paymentRequestUpdate),this.set_selected_shipping_methods(i.shipping_methods),this.payment_data_updated(i,t)}.bind(this)).catch(function(t){e(t)}.bind(this))}.bind(this))},wc_stripe.GooglePay.prototype.payment_data_updated=function(t){},wc_stripe.GooglePay.prototype.get_merchant_info=function(){var t={merchantId:this.params.merchant_id,merchantName:this.params.merchant_name};return"TEST"===this.params.environment&&delete t.merchantId,t},wc_stripe.GooglePay.prototype.get_payment_options=function(){var t={environment:this.params.environment,merchantInfo:this.get_merchant_info()};return this.needs_shipping()&&this.get_total_price_cents()>0?t.paymentDataCallbacks={onPaymentDataChanged:this.on_payment_data_changed.bind(this),onPaymentAuthorized:function(t){return new Promise(function(t,e){t({transactionState:"SUCCESS"})}.bind(this))}.bind(this)}:t.paymentDataCallbacks={onPaymentAuthorized:function(t){return new Promise(function(t,e){t({transactionState:"SUCCESS"})}.bind(this))}},t},wc_stripe.GooglePay.prototype.build_payment_request=function(){var t=e.extend({},s,{emailRequired:this.mappings.required("billing_email"),merchantInfo:this.get_merchant_info(),allowedPaymentMethods:[e.extend({type:"CARD",tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:"stripe","stripe:version":"2018-10-31","stripe:publishableKey":this.params.api_key}}},a)],shippingAddressRequired:this.needs_shipping()&&this.get_total_price_cents()>0,transactionInfo:{currencyCode:this.get_currency(),totalPriceStatus:"ESTIMATED",totalPrice:this.get_total_price().toString(),displayItems:this.get_display_items(),totalPriceLabel:this.params.total_price_label}});return t.allowedPaymentMethods[0].parameters.billingAddressRequired=!0,t.allowedPaymentMethods[0].parameters.billingAddressParameters={format:"FULL",phoneNumberRequired:this.mappings.required("billing_phone")},this.needs_shipping()&&this.get_total_price_cents()>0?(t.shippingAddressParameters={},t.shippingOptionRequired=!0,t.shippingOptionParameters={shippingOptions:this.get_shipping_options()},t.callbackIntents=["SHIPPING_ADDRESS","SHIPPING_OPTION","PAYMENT_AUTHORIZATION"]):t.callbackIntents=["PAYMENT_AUTHORIZATION"],t},wc_stripe.GooglePay.prototype.createPaymentsClient=function(){this.paymentsClient=new google.payments.api.PaymentsClient(this.get_payment_options())},wc_stripe.GooglePay.prototype.isReadyToPay=function(){return new Promise(function(t){var i=e.extend({},s);i.allowedPaymentMethods=[a],this.paymentsClient.isReadyToPay(i).then(function(){this.can_pay=!0,this.create_button(),t()}.bind(this)).catch(function(t){this.submit_error(t)}.bind(this))}.bind(this))},wc_stripe.GooglePay.prototype.create_button=function(){this.$button&&this.$button.remove(),this.$button=e(this.paymentsClient.createButton({onClick:this.start.bind(this),buttonColor:this.params.button_color,buttonType:this.params.button_style})),this.$button.addClass("gpay-button-container")},wc_stripe.GooglePay.prototype.start=function(){this.createPaymentsClient(),this.paymentsClient.loadPaymentData(this.build_payment_request()).then(function(t){var e=JSON.parse(t.paymentMethodData.tokenizationData.token);this.populate_address_fields(t),this.on_token_received(e)}.bind(this)).catch(function(t){"CANCELED"!==t.statusCode&&(t.statusMessage&&t.statusMessage.indexOf("paymentDataRequest.callbackIntent")>-1?this.submit_error_code("DEVELOPER_ERROR_WHITELIST"):this.submit_error(t.statusMessage))}.bind(this))},wc_stripe.ApplePay=function(){},wc_stripe.ApplePay.prototype.initialize=function(){var t=".apple-pay-button";["checkout","order_pay"].indexOf(this.get_page())<0&&(t=this.container+" .apple-pay-button"),e(document.body).on("click",t,this.start.bind(this)),this.createPaymentRequest(),this.canMakePayment()},wc_stripe.ApplePay.prototype.create_button=function(){this.$button&&this.$button.remove(),this.$button=e(this.params.button),this.append_button()},wc_stripe.ApplePay.prototype.canMakePayment=function(){return new Promise(function(t,i){this.paymentRequest.canMakePayment().then(function(i){i&&i.applePay&&(this.can_pay=!0,this.create_button(),e(this.container).show(),t(i))}.bind(this))}.bind(this))},wc_stripe.ApplePay.prototype.start=function(t){t.preventDefault(),this.paymentRequest.update(this.get_payment_request_update({total:{pending:!1}})),this.paymentRequest.show()},wc_stripe.PaymentRequest=function(){},wc_stripe.PaymentRequest.prototype.initialize=function(){this.createPaymentRequest(),this.canMakePayment(),this.paymentRequestButton=this.createPaymentRequestButton(),this.paymentRequestButton.on("click",this.button_click.bind(this))},wc_stripe.PaymentRequest.prototype.button_click=function(t){},wc_stripe.PaymentRequest.prototype.createPaymentRequestButton=function(){return this.elements.create("paymentRequestButton",{paymentRequest:this.paymentRequest,style:{paymentRequestButton:{type:this.params.button.type,theme:this.params.button.theme,height:this.params.button.height}}})},wc_stripe.PaymentRequest.prototype.canMakePayment=function(){return new Promise(function(t,i){this.paymentRequest.canMakePayment().then(function(i){i&&!i.applePay&&(this.can_pay=!0,this.create_button(),e(this.container).show(),t(i))}.bind(this))}.bind(this))},wc_stripe.PaymentRequest.prototype.create_button=function(){this.paymentRequestButton.mount("#wc-stripe-payment-request-container")},wc_stripe.CheckoutFields=function(t){this.params=t,this.fields=new Map(Object.keys(this.params).map(function(t){return[t,this.params[t].value]}.bind(this)))},wc_stripe.CheckoutFields.prototype.set=function(t,e,i){this[t]&&"function"==typeof this[t]?this[t]().set.call(this,e,i):this.fields.set(t,e)},wc_stripe.CheckoutFields.prototype.get=function(t,e){return this[t]&&"function"==typeof this[t]?this[t]().get.call(this,v,e):this.fields.get(t)},wc_stripe.CheckoutFields.prototype.required=function(t){return this.params[t]&&this.params[t].required},wc_stripe.CheckoutFields.prototype.name=function(){return{set:function(t,e){var i=t.split(" ");this.fields.set(e+"_first_name",i[0]),this.fields.set(e+"_last_name",i[1])},get:function(t){return this.fields.get(t+"_first_name")+" "+this.fields.get(t+"_last_name")}}},wc_stripe.CheckoutFields.prototype.payerName=function(){return wc_stripe.CheckoutFields.prototype.name.apply(this,arguments)},wc_stripe.CheckoutFields.prototype.email=function(){return{set:function(t,e){this.fields.set(e+"_email",t)},get:function(t){return this.fields.get(t+"_email")}}},wc_stripe.CheckoutFields.prototype.payerEmail=function(){return wc_stripe.CheckoutFields.prototype.email.apply(this,arguments)},wc_stripe.CheckoutFields.prototype.phone=function(){return{set:function(t,e){this.fields.set(e+"_phone",t)},get:function(t){return this.fields.get(t+"_phone")}}},wc_stripe.CheckoutFields.prototype.payerPhone=function(){return wc_stripe.CheckoutFields.prototype.phone.apply(this,arguments)},wc_stripe.CheckoutFields.prototype.phoneNumber=function(){return wc_stripe.CheckoutFields.prototype.phone.apply(this,arguments)},wc_stripe.CheckoutFields.prototype.recipient=function(){return{set:function(t,e){var i=t.split(" ");i.length>0&&this.fields.set(e+"_first_name",i[0]),i.length>1&&this.fields.set(e+"_last_name",i[1])},get:function(t){return this.fields.get(t+"_first_name")+" "+this.fields.get(t+"_last_name")}}},wc_stripe.CheckoutFields.prototype.country=function(){return{set:function(t,e){this.fields.set(e+"_country",t)},get:function(t){return this.fields.get(t+"_country")}}},wc_stripe.CheckoutFields.prototype.countryCode=function(){return wc_stripe.CheckoutFields.prototype.country.apply(this,arguments)},wc_stripe.CheckoutFields.prototype.address1=function(){return{set:function(t,e){this.fields.set(e+"_address_1",t)},get:function(t){return this.fields.get(t+"_address_1")}}},wc_stripe.CheckoutFields.prototype.address2=function(){return{set:function(t,e){this.fields.set(e+"_address_2",t)},get:function(t){this.fields.get(t+"_address_2")}}},wc_stripe.CheckoutFields.prototype.line1=function(){return wc_stripe.CheckoutFields.prototype.address1.apply(this,arguments)},wc_stripe.CheckoutFields.prototype.line2=function(){return wc_stripe.CheckoutFields.prototype.address2.apply(this,arguments)},wc_stripe.CheckoutFields.prototype.addressLine=function(){return{set:function(t,e){t.length>0&&this.fields.set(e+"_address_1",t[0]),t.length>1&&this.fields.set(e+"_address_2",t[1])},get:function(t){return[this.fields.get(t+"_address_1"),this.fields.get(t+"_address_2")]}}},wc_stripe.CheckoutFields.prototype.state=function(){return{set:function(t,e){this.fields.set(e+"_state",t)},get:function(t){return this.fields.get(t+"_state")}}},wc_stripe.CheckoutFields.prototype.region=function(){return wc_stripe.CheckoutFields.prototype.state.apply(this,arguments)},wc_stripe.CheckoutFields.prototype.administrativeArea=function(){return wc_stripe.CheckoutFields.prototype.state.apply(this,arguments)},wc_stripe.CheckoutFields.prototype.city=function(){return{set:function(t,e){this.fields.set(e+"_city",t)},get:function(t){this.fields.get(t+"_city")}}},wc_stripe.CheckoutFields.prototype.locality=function(){return wc_stripe.CheckoutFields.prototype.city.apply(this,arguments)},wc_stripe.CheckoutFields.prototype.postal_code=function(){return{set:function(t,e){this.fields.set(e+"_postcode",t)},get:function(t){this.fields.get(t+"_postcode")}}},wc_stripe.CheckoutFields.prototype.postalCode=function(){return wc_stripe.CheckoutFields.prototype.postal_code.apply(this,arguments)},wc_stripe.CheckoutFields.prototype.toJson=function(){var t={};return this.fields.forEach(function(e,i){t[i]=e}),t},wc_stripe.CheckoutFields.prototype.toFormFields=function(){this.fields.forEach(function(t,i){e(i='[name="'+i+'"]').length&&""!==t&&e(i).val(t)})};try{i=Stripe(wc_stripe_params_v3.api_key,{stripeAccount:wc_stripe_params_v3.account})}catch(e){return t.alert(e),void console.log(e)}}(window,jQuery);
|
composer.json
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"require": {
|
3 |
+
"stripe/stripe-php": "^7.40"
|
4 |
+
}
|
5 |
+
}
|
composer.lock
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_readme": [
|
3 |
+
"This file locks the dependencies of your project to a known state",
|
4 |
+
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
5 |
+
"This file is @generated automatically"
|
6 |
+
],
|
7 |
+
"content-hash": "7a93059c67c14d8e5b78b3c9325b47e5",
|
8 |
+
"packages": [
|
9 |
+
{
|
10 |
+
"name": "stripe/stripe-php",
|
11 |
+
"version": "v7.45.0",
|
12 |
+
"source": {
|
13 |
+
"type": "git",
|
14 |
+
"url": "https://github.com/stripe/stripe-php.git",
|
15 |
+
"reference": "21e5001f5e0d787e4755c8bfc00e578dce9ae058"
|
16 |
+
},
|
17 |
+
"dist": {
|
18 |
+
"type": "zip",
|
19 |
+
"url": "https://api.github.com/repos/stripe/stripe-php/zipball/21e5001f5e0d787e4755c8bfc00e578dce9ae058",
|
20 |
+
"reference": "21e5001f5e0d787e4755c8bfc00e578dce9ae058",
|
21 |
+
"shasum": ""
|
22 |
+
},
|
23 |
+
"require": {
|
24 |
+
"ext-curl": "*",
|
25 |
+
"ext-json": "*",
|
26 |
+
"ext-mbstring": "*",
|
27 |
+
"php": ">=5.6.0"
|
28 |
+
},
|
29 |
+
"require-dev": {
|
30 |
+
"friendsofphp/php-cs-fixer": "2.16.1",
|
31 |
+
"php-coveralls/php-coveralls": "^2.1",
|
32 |
+
"phpunit/phpunit": "^5.7",
|
33 |
+
"squizlabs/php_codesniffer": "^3.3",
|
34 |
+
"symfony/process": "~3.4"
|
35 |
+
},
|
36 |
+
"type": "library",
|
37 |
+
"extra": {
|
38 |
+
"branch-alias": {
|
39 |
+
"dev-master": "2.0-dev"
|
40 |
+
}
|
41 |
+
},
|
42 |
+
"autoload": {
|
43 |
+
"psr-4": {
|
44 |
+
"Stripe\\": "lib/"
|
45 |
+
}
|
46 |
+
},
|
47 |
+
"notification-url": "https://packagist.org/downloads/",
|
48 |
+
"license": [
|
49 |
+
"MIT"
|
50 |
+
],
|
51 |
+
"authors": [
|
52 |
+
{
|
53 |
+
"name": "Stripe and contributors",
|
54 |
+
"homepage": "https://github.com/stripe/stripe-php/contributors"
|
55 |
+
}
|
56 |
+
],
|
57 |
+
"description": "Stripe PHP Library",
|
58 |
+
"homepage": "https://stripe.com/",
|
59 |
+
"keywords": [
|
60 |
+
"api",
|
61 |
+
"payment processing",
|
62 |
+
"stripe"
|
63 |
+
],
|
64 |
+
"time": "2020-07-29T04:29:52+00:00"
|
65 |
+
}
|
66 |
+
],
|
67 |
+
"packages-dev": [],
|
68 |
+
"aliases": [],
|
69 |
+
"minimum-stability": "stable",
|
70 |
+
"stability-flags": [],
|
71 |
+
"prefer-stable": false,
|
72 |
+
"prefer-lowest": false,
|
73 |
+
"platform": [],
|
74 |
+
"platform-dev": [],
|
75 |
+
"plugin-api-version": "1.1.0"
|
76 |
+
}
|
i18n/languages/woo-stripe-payment.pot
CHANGED
@@ -2,14 +2,14 @@
|
|
2 |
# This file is distributed under the same license as the Stripe For WooCommerce plugin.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: Stripe For WooCommerce 3.1.
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/woo-stripe-payment\n"
|
7 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
8 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
9 |
"MIME-Version: 1.0\n"
|
10 |
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
"Content-Transfer-Encoding: 8bit\n"
|
12 |
-
"POT-Creation-Date: 2020-
|
13 |
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
14 |
"X-Generator: WP-CLI 2.4.0\n"
|
15 |
"X-Domain: woo-stripe-payment\n"
|
@@ -30,7 +30,7 @@ msgstr ""
|
|
30 |
msgid "Payment Plugins, support@paymentplugins.com"
|
31 |
msgstr ""
|
32 |
|
33 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:
|
34 |
#: includes/admin/meta-boxes/views/html-product-data.php:14
|
35 |
#: includes/gateways/settings/ach-settings-v2.php:9
|
36 |
#: includes/gateways/settings/ach-settings.php:9
|
@@ -41,11 +41,11 @@ msgstr ""
|
|
41 |
msgid "Enabled"
|
42 |
msgstr ""
|
43 |
|
44 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:
|
45 |
msgid "If enabled, your site can accept %s payments through Stripe."
|
46 |
msgstr ""
|
47 |
|
48 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:
|
49 |
#: includes/gateways/settings/ach-settings-v2.php:64
|
50 |
#: includes/gateways/settings/ach-settings.php:73
|
51 |
#: includes/gateways/settings/applepay-settings.php:20
|
@@ -55,162 +55,162 @@ msgstr ""
|
|
55 |
msgid "General Settings"
|
56 |
msgstr ""
|
57 |
|
58 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:
|
59 |
#: includes/admin/meta-boxes/views/html-charge-data-subview.php:47
|
60 |
#: includes/gateways/settings/ach-settings-v2.php:68
|
61 |
#: includes/gateways/settings/ach-settings.php:77
|
62 |
#: includes/gateways/settings/applepay-settings.php:24
|
63 |
#: includes/gateways/settings/cc-settings.php:21
|
64 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
65 |
#: includes/gateways/settings/payment-request-settings.php:25
|
66 |
msgid "Title"
|
67 |
msgstr ""
|
68 |
|
69 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:
|
70 |
#: includes/gateways/settings/ach-settings-v2.php:74
|
71 |
#: includes/gateways/settings/ach-settings.php:83
|
72 |
#: includes/gateways/settings/applepay-settings.php:30
|
73 |
#: includes/gateways/settings/cc-settings.php:27
|
74 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
75 |
#: includes/gateways/settings/payment-request-settings.php:31
|
76 |
msgid "Description"
|
77 |
msgstr ""
|
78 |
|
79 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:
|
80 |
#: includes/gateways/settings/ach-settings-v2.php:77
|
81 |
#: includes/gateways/settings/ach-settings.php:86
|
82 |
#: includes/gateways/settings/applepay-settings.php:33
|
83 |
#: includes/gateways/settings/cc-settings.php:30
|
84 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
85 |
#: includes/gateways/settings/payment-request-settings.php:34
|
86 |
msgid "Leave blank if you don't want a description to show for the gateway."
|
87 |
msgstr ""
|
88 |
|
89 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:
|
90 |
msgid "Order %s"
|
91 |
msgstr ""
|
92 |
|
93 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:
|
94 |
msgid "Gateway will appear when store currency is <strong>%s</strong>"
|
95 |
msgstr ""
|
96 |
|
97 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:
|
98 |
msgid " & billing country is <strong>%s</strong>"
|
99 |
msgstr ""
|
100 |
|
101 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
102 |
-
#: includes/controllers/class-wc-stripe-controller-cart.php:
|
103 |
-
#: includes/controllers/class-wc-stripe-controller-cart.php:
|
104 |
-
#: includes/controllers/class-wc-stripe-controller-googlepay.php:
|
105 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:
|
106 |
msgid "Total"
|
107 |
msgstr ""
|
108 |
|
109 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
110 |
msgid "User must be logged in."
|
111 |
msgstr ""
|
112 |
|
113 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
114 |
msgid "Error saving your payment method. Reason: %s"
|
115 |
msgstr ""
|
116 |
|
117 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
118 |
msgid "Error saving payment method. Reason: %s"
|
119 |
msgstr ""
|
120 |
|
121 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
122 |
msgid "Order refunded in Stripe. Amount: %s"
|
123 |
msgstr ""
|
124 |
|
125 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
126 |
msgid "Order amount captured in Stripe. Amount: %s"
|
127 |
msgstr ""
|
128 |
|
129 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
130 |
msgid "Error capturing charge in Stripe. Reason: %s"
|
131 |
msgstr ""
|
132 |
|
133 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
134 |
msgid "Error voiding charge. Reason: %s"
|
135 |
msgstr ""
|
136 |
|
137 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
138 |
msgid "Charge voided in Stripe."
|
139 |
msgstr ""
|
140 |
|
141 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
142 |
msgid "n/a"
|
143 |
msgstr ""
|
144 |
|
145 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
146 |
#: includes/admin/meta-boxes/views/html-order-pay.php:42
|
147 |
msgid "New Card"
|
148 |
msgstr ""
|
149 |
|
150 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
151 |
#: includes/admin/meta-boxes/views/html-order-pay.php:30
|
152 |
msgid "Saved Cards"
|
153 |
msgstr ""
|
154 |
|
155 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
156 |
msgid "Attemp to save payment method failed. Reason: %s"
|
157 |
msgstr ""
|
158 |
|
159 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
160 |
msgid "We were not able to save your payment method. To prevent billing issues with your subscription, please add a payment method to the subscription."
|
161 |
msgstr ""
|
162 |
|
163 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
164 |
msgid "We were not able to save your payment method. Reason: %s"
|
165 |
msgstr ""
|
166 |
|
167 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
168 |
msgid "Payment Method Token"
|
169 |
msgstr ""
|
170 |
|
171 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
172 |
msgid "Recurring payment for order failed. Reason: %s"
|
173 |
msgstr ""
|
174 |
|
175 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
176 |
msgid "Recurring payment captured in Stripe. Payment method: %s"
|
177 |
msgstr ""
|
178 |
|
179 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
180 |
msgid "Recurring payment authorized in Stripe. Payment method: %s"
|
181 |
msgstr ""
|
182 |
|
183 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
184 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
185 |
msgid "Customer must manually complete payment for payment method %s"
|
186 |
msgstr ""
|
187 |
|
188 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
189 |
msgid "Error saving payment method for subscription. Reason: %s"
|
190 |
msgstr ""
|
191 |
|
192 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
193 |
#: includes/abstract/abstract-wc-stripe-payment.php:219
|
194 |
msgid "Order %1$s from %2$s"
|
195 |
msgstr ""
|
196 |
|
197 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
198 |
msgid "Pre-order payment for order failed. Reason: %s"
|
199 |
msgstr ""
|
200 |
|
201 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
202 |
msgid "Pre-order payment captured in Stripe. Payment method: %s"
|
203 |
msgstr ""
|
204 |
|
205 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
206 |
msgid "Pre-order payment authorized in Stripe. Payment method: %s"
|
207 |
msgstr ""
|
208 |
|
209 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
210 |
msgid "Cannot process payment"
|
211 |
msgstr ""
|
212 |
|
213 |
-
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:
|
214 |
msgid "Increase your conversion rate by offering %1$s on your Product and Cart pages, or at the top of the checkout page. <br/><strong>Note:</strong> you can control which products display %s by going to the product edit page."
|
215 |
msgstr ""
|
216 |
|
@@ -305,7 +305,7 @@ msgstr ""
|
|
305 |
#: includes/admin/meta-boxes/views/html-product-data.php:51
|
306 |
#: includes/gateways/settings/applepay-settings.php:52
|
307 |
#: includes/gateways/settings/cc-settings.php:49
|
308 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
309 |
#: includes/gateways/settings/payment-request-settings.php:53
|
310 |
msgid "Capture"
|
311 |
msgstr ""
|
@@ -349,7 +349,7 @@ msgstr ""
|
|
349 |
|
350 |
#: includes/admin/meta-boxes/views/html-charge-data-subview.php:51
|
351 |
#: includes/admin/views/html-ach-fee.php:12
|
352 |
-
#: includes/gateways/settings/payment-request-settings.php:
|
353 |
msgid "Type"
|
354 |
msgstr ""
|
355 |
|
@@ -431,7 +431,7 @@ msgstr ""
|
|
431 |
#: includes/admin/meta-boxes/views/html-product-data.php:15
|
432 |
#: includes/gateways/settings/applepay-settings.php:48
|
433 |
#: includes/gateways/settings/cc-settings.php:45
|
434 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
435 |
#: includes/gateways/settings/payment-request-settings.php:49
|
436 |
msgid "Charge Type"
|
437 |
msgstr ""
|
@@ -440,7 +440,7 @@ msgstr ""
|
|
440 |
#: includes/admin/meta-boxes/views/html-product-data.php:53
|
441 |
#: includes/gateways/settings/applepay-settings.php:53
|
442 |
#: includes/gateways/settings/cc-settings.php:50
|
443 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
444 |
#: includes/gateways/settings/payment-request-settings.php:54
|
445 |
msgid "Authorize"
|
446 |
msgstr ""
|
@@ -647,14 +647,18 @@ msgid "Error retrieving payment source. Reason: %s"
|
|
647 |
msgstr ""
|
648 |
|
649 |
#: includes/class-wc-stripe-redirect-handler.php:51
|
|
|
|
|
|
|
|
|
650 |
msgid "Payment authorization failed. Please select another payment method."
|
651 |
msgstr ""
|
652 |
|
653 |
-
#: includes/class-wc-stripe-redirect-handler.php:
|
654 |
msgid "Payment authorization failed."
|
655 |
msgstr ""
|
656 |
|
657 |
-
#: includes/class-wc-stripe-rest-api.php:
|
658 |
msgid "%1$s is an invalid controller name."
|
659 |
msgstr ""
|
660 |
|
@@ -662,15 +666,15 @@ msgstr ""
|
|
662 |
msgid "Thank you for updating Stripe for WooCommerce to version %1$s."
|
663 |
msgstr ""
|
664 |
|
665 |
-
#: includes/controllers/class-wc-stripe-controller-cart.php:
|
666 |
msgid "Quantity must be greater than zero."
|
667 |
msgstr ""
|
668 |
|
669 |
-
#: includes/controllers/class-wc-stripe-controller-checkout.php:
|
670 |
msgid "Some required fields were missing. Please click %1$shere%2$s to complete your payment."
|
671 |
msgstr ""
|
672 |
|
673 |
-
#: includes/controllers/class-wc-stripe-controller-checkout.php:
|
674 |
msgid "Please review your order details then click Place Order."
|
675 |
msgstr ""
|
676 |
|
@@ -707,24 +711,24 @@ msgstr ""
|
|
707 |
msgid "Connection test to Stripe was successful. Mode: %s."
|
708 |
msgstr ""
|
709 |
|
710 |
-
#: includes/controllers/class-wc-stripe-controller-googlepay.php:
|
711 |
msgid "Your shipping address is not serviceable."
|
712 |
msgstr ""
|
713 |
|
714 |
-
#: includes/controllers/class-wc-stripe-controller-order-actions.php:
|
715 |
msgid "Invalid amount entered."
|
716 |
msgstr ""
|
717 |
|
718 |
-
#: includes/controllers/class-wc-stripe-controller-order-actions.php:179
|
719 |
#: includes/controllers/class-wc-stripe-controller-order-actions.php:182
|
|
|
720 |
msgid "Order total must be greater than zero."
|
721 |
msgstr ""
|
722 |
|
723 |
-
#: includes/controllers/class-wc-stripe-controller-order-actions.php:
|
724 |
msgid "This order has already been processed. Transaction ID: %1$s. Payment method: %2$s"
|
725 |
msgstr ""
|
726 |
|
727 |
-
#: includes/controllers/class-wc-stripe-controller-order-actions.php:
|
728 |
msgid "Order customer Id and payment method customer Id do not match."
|
729 |
msgstr ""
|
730 |
|
@@ -802,12 +806,12 @@ msgstr ""
|
|
802 |
msgid "Apple Pay gateway that integrates with your Stripe account."
|
803 |
msgstr ""
|
804 |
|
805 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-applepay.php:
|
806 |
msgid "Please update you product quantity before using Apple Pay."
|
807 |
msgstr ""
|
808 |
|
809 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-applepay.php:
|
810 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-payment-request.php:
|
811 |
msgid "Please select a product option before updating quantity."
|
812 |
msgstr ""
|
813 |
|
@@ -884,7 +888,7 @@ msgid "Giropay gateway that integrates with your Stripe account."
|
|
884 |
msgstr ""
|
885 |
|
886 |
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:20
|
887 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
888 |
msgid "Google Pay"
|
889 |
msgstr ""
|
890 |
|
@@ -896,49 +900,59 @@ msgstr ""
|
|
896 |
msgid "Google Pay gateway that integrates with your Stripe account."
|
897 |
msgstr ""
|
898 |
|
899 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:
|
900 |
msgid "Please update you product quantity before using Google Pay."
|
901 |
msgstr ""
|
902 |
|
903 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:
|
904 |
msgid "Subscription"
|
905 |
msgstr ""
|
906 |
|
907 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:
|
908 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:
|
909 |
#: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:189
|
910 |
-
#: includes/wc-stripe-functions.php:
|
911 |
-
#: includes/wc-stripe-functions.php:
|
912 |
msgid "Shipping"
|
913 |
msgstr ""
|
914 |
|
915 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:
|
916 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:
|
917 |
#: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:199
|
918 |
-
#: includes/wc-stripe-functions.php:
|
919 |
-
#: includes/wc-stripe-functions.php:
|
920 |
msgid "Discount"
|
921 |
msgstr ""
|
922 |
|
923 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:
|
924 |
-
#: includes/wc-stripe-functions.php:
|
925 |
msgid "Fees"
|
926 |
msgstr ""
|
927 |
|
928 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:
|
929 |
#: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:221
|
930 |
-
#: includes/wc-stripe-functions.php:
|
931 |
msgid "Tax"
|
932 |
msgstr ""
|
933 |
|
934 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:
|
935 |
msgid "Waiting..."
|
936 |
msgstr ""
|
937 |
|
938 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:
|
939 |
msgid "loading shipping methods..."
|
940 |
msgstr ""
|
941 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
942 |
#: includes/gateways/class-wc-payment-gateway-stripe-ideal.php:25
|
943 |
#: includes/gateways/class-wc-payment-gateway-stripe-ideal.php:26
|
944 |
#: includes/gateways/class-wc-payment-gateway-stripe-ideal.php:29
|
@@ -1026,11 +1040,11 @@ msgstr ""
|
|
1026 |
msgid "Gateway that renders based on the user's browser. Chrome payment methods, Microsoft pay, etc."
|
1027 |
msgstr ""
|
1028 |
|
1029 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-payment-request.php:
|
1030 |
msgid "Please update you product quantity before paying."
|
1031 |
msgstr ""
|
1032 |
|
1033 |
-
#: includes/gateways/class-wc-payment-gateway-stripe-payment-request.php:
|
1034 |
msgid "Adding to cart..."
|
1035 |
msgstr ""
|
1036 |
|
@@ -1233,7 +1247,7 @@ msgstr ""
|
|
1233 |
|
1234 |
#: includes/gateways/settings/applepay-settings.php:37
|
1235 |
#: includes/gateways/settings/cc-settings.php:34
|
1236 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1237 |
#: includes/gateways/settings/payment-request-settings.php:38
|
1238 |
msgid "Credit Card Display"
|
1239 |
msgstr ""
|
@@ -1245,97 +1259,103 @@ msgid "This option determines whether the customer's funds are captured immediat
|
|
1245 |
msgstr ""
|
1246 |
|
1247 |
#: includes/gateways/settings/applepay-settings.php:60
|
1248 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1249 |
#: includes/gateways/settings/payment-request-settings.php:61
|
1250 |
msgid "Payment Sections"
|
1251 |
msgstr ""
|
1252 |
|
1253 |
#: includes/gateways/settings/applepay-settings.php:63
|
1254 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1255 |
#: includes/gateways/settings/payment-request-settings.php:64
|
1256 |
msgid "Product Page"
|
1257 |
msgstr ""
|
1258 |
|
1259 |
#: includes/gateways/settings/applepay-settings.php:64
|
1260 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1261 |
#: includes/gateways/settings/payment-request-settings.php:65
|
1262 |
msgid "Cart Page"
|
1263 |
msgstr ""
|
1264 |
|
1265 |
#: includes/gateways/settings/applepay-settings.php:65
|
1266 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1267 |
#: includes/gateways/settings/payment-request-settings.php:66
|
|
|
|
|
|
|
|
|
|
|
|
|
1268 |
msgid "Top of Checkout"
|
1269 |
msgstr ""
|
1270 |
|
1271 |
-
#: includes/gateways/settings/applepay-settings.php:
|
1272 |
#: includes/gateways/settings/cc-settings.php:57
|
1273 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1274 |
-
#: includes/gateways/settings/payment-request-settings.php:
|
1275 |
msgid "Order Status"
|
1276 |
msgstr ""
|
1277 |
|
1278 |
-
#: includes/gateways/settings/applepay-settings.php:
|
1279 |
#: includes/gateways/settings/cc-settings.php:60
|
1280 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1281 |
-
#: includes/gateways/settings/payment-request-settings.php:
|
1282 |
msgid "Default"
|
1283 |
msgstr ""
|
1284 |
|
1285 |
-
#: includes/gateways/settings/applepay-settings.php:
|
1286 |
#: includes/gateways/settings/cc-settings.php:62
|
1287 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1288 |
-
#: includes/gateways/settings/payment-request-settings.php:
|
1289 |
msgid "This is the status of the order once payment is complete. If <b>Default</b> is selected, then WooCommerce will set the order status automatically based on internal logic which states if a product is virtual and downloadable then status is set to complete. Products that require shipping are set to Processing. Default is the recommended setting as it allows standard WooCommerce code to process the order status."
|
1290 |
msgstr ""
|
1291 |
|
1292 |
-
#: includes/gateways/settings/applepay-settings.php:
|
1293 |
-
#: includes/gateways/settings/payment-request-settings.php:
|
1294 |
msgid "Button Settings"
|
1295 |
msgstr ""
|
1296 |
|
1297 |
-
#: includes/gateways/settings/applepay-settings.php:
|
1298 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1299 |
msgid "Button Design"
|
1300 |
msgstr ""
|
1301 |
|
1302 |
-
#: includes/gateways/settings/applepay-settings.php:
|
1303 |
msgid "Black Button"
|
1304 |
msgstr ""
|
1305 |
|
1306 |
-
#: includes/gateways/settings/applepay-settings.php:
|
1307 |
msgid "White With Black Line"
|
1308 |
msgstr ""
|
1309 |
|
1310 |
-
#: includes/gateways/settings/applepay-settings.php:
|
1311 |
msgid "White Button"
|
1312 |
msgstr ""
|
1313 |
|
1314 |
-
#: includes/gateways/settings/applepay-settings.php:
|
1315 |
msgid "This is the style for all Apple Pay buttons presented on your store."
|
1316 |
msgstr ""
|
1317 |
|
1318 |
-
#: includes/gateways/settings/applepay-settings.php:
|
1319 |
msgid "Checkout button type"
|
1320 |
msgstr ""
|
1321 |
|
1322 |
-
#: includes/gateways/settings/applepay-settings.php:99
|
1323 |
-
#: includes/gateways/settings/applepay-settings.php:109
|
1324 |
-
#: includes/gateways/settings/applepay-settings.php:119
|
1325 |
-
msgid "Standard Button"
|
1326 |
-
msgstr ""
|
1327 |
-
|
1328 |
#: includes/gateways/settings/applepay-settings.php:100
|
1329 |
#: includes/gateways/settings/applepay-settings.php:110
|
1330 |
#: includes/gateways/settings/applepay-settings.php:120
|
|
|
|
|
|
|
|
|
|
|
|
|
1331 |
msgid "Buy with Apple Pay"
|
1332 |
msgstr ""
|
1333 |
|
1334 |
-
#: includes/gateways/settings/applepay-settings.php:
|
1335 |
msgid "Cart button type"
|
1336 |
msgstr ""
|
1337 |
|
1338 |
-
#: includes/gateways/settings/applepay-settings.php:
|
1339 |
msgid "Product button type"
|
1340 |
msgstr ""
|
1341 |
|
@@ -1423,87 +1443,79 @@ msgstr ""
|
|
1423 |
msgid "If enabled, your site can accept Google Pay payments through Stripe."
|
1424 |
msgstr ""
|
1425 |
|
1426 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1427 |
-
msgid "Dynamic Price"
|
1428 |
-
msgstr ""
|
1429 |
-
|
1430 |
-
#: includes/gateways/settings/googlepay-settings.php:38
|
1431 |
-
msgid "If enabled, the Google Payment sheet will show the order line items. You must have Google whitelist you for callback intents."
|
1432 |
-
msgstr ""
|
1433 |
-
|
1434 |
-
#: includes/gateways/settings/googlepay-settings.php:42
|
1435 |
msgid "Merchant ID"
|
1436 |
msgstr ""
|
1437 |
|
1438 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1439 |
msgid "Your Google Merchant ID is given to you by the Google API team once you register for Google Pay. While testing in TEST mode you can leave this value blank and Google Pay will work."
|
1440 |
msgstr ""
|
1441 |
|
1442 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1443 |
msgid "This option determines whether the customer's funds are capture immediately or authorized and can be captured at a later date."
|
1444 |
msgstr ""
|
1445 |
|
1446 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1447 |
msgid "Merchant Name"
|
1448 |
msgstr ""
|
1449 |
|
1450 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1451 |
msgid "The name of your business as it appears on the Google Pay payment sheet."
|
1452 |
msgstr ""
|
1453 |
|
1454 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1455 |
msgid "Icon"
|
1456 |
msgstr ""
|
1457 |
|
1458 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1459 |
msgid "With Outline"
|
1460 |
msgstr ""
|
1461 |
|
1462 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1463 |
msgid "Standard"
|
1464 |
msgstr ""
|
1465 |
|
1466 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1467 |
msgid "This is the icon style that appears next to the gateway on the checkout page. Google's API team typically requires the With Outline option on the checkout page for branding purposes."
|
1468 |
msgstr ""
|
1469 |
|
1470 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1471 |
msgid "Button Options"
|
1472 |
msgstr ""
|
1473 |
|
1474 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1475 |
msgid "Button Color"
|
1476 |
msgstr ""
|
1477 |
|
1478 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1479 |
msgid "Black"
|
1480 |
msgstr ""
|
1481 |
|
1482 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1483 |
msgid "White"
|
1484 |
msgstr ""
|
1485 |
|
1486 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1487 |
msgid "The button color of the GPay button."
|
1488 |
msgstr ""
|
1489 |
|
1490 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1491 |
msgid "Button Style"
|
1492 |
msgstr ""
|
1493 |
|
1494 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1495 |
msgid "Long"
|
1496 |
msgstr ""
|
1497 |
|
1498 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1499 |
msgid "Short"
|
1500 |
msgstr ""
|
1501 |
|
1502 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1503 |
msgid "The button style of the GPay button."
|
1504 |
msgstr ""
|
1505 |
|
1506 |
-
#: includes/gateways/settings/googlepay-settings.php:
|
1507 |
msgid "If you can't see the Google Pay button, try switching to a Chrome browser."
|
1508 |
msgstr ""
|
1509 |
|
@@ -1517,43 +1529,43 @@ msgstr ""
|
|
1517 |
msgid "Browser Payments"
|
1518 |
msgstr ""
|
1519 |
|
1520 |
-
#: includes/gateways/settings/payment-request-settings.php:
|
1521 |
msgid "default"
|
1522 |
msgstr ""
|
1523 |
|
1524 |
-
#: includes/gateways/settings/payment-request-settings.php:
|
1525 |
msgid "buy"
|
1526 |
msgstr ""
|
1527 |
|
1528 |
-
#: includes/gateways/settings/payment-request-settings.php:
|
1529 |
msgid "This defines the type of button that will display."
|
1530 |
msgstr ""
|
1531 |
|
1532 |
-
#: includes/gateways/settings/payment-request-settings.php:
|
1533 |
msgid "Theme"
|
1534 |
msgstr ""
|
1535 |
|
1536 |
-
#: includes/gateways/settings/payment-request-settings.php:
|
1537 |
msgid "dark"
|
1538 |
msgstr ""
|
1539 |
|
1540 |
-
#: includes/gateways/settings/payment-request-settings.php:
|
1541 |
msgid "light"
|
1542 |
msgstr ""
|
1543 |
|
1544 |
-
#: includes/gateways/settings/payment-request-settings.php:
|
1545 |
msgid "light-outline"
|
1546 |
msgstr ""
|
1547 |
|
1548 |
-
#: includes/gateways/settings/payment-request-settings.php:
|
1549 |
msgid "This defines the color scheme for the button."
|
1550 |
msgstr ""
|
1551 |
|
1552 |
-
#: includes/gateways/settings/payment-request-settings.php:
|
1553 |
msgid "Height"
|
1554 |
msgstr ""
|
1555 |
|
1556 |
-
#: includes/gateways/settings/payment-request-settings.php:
|
1557 |
msgid "The height of the button. Max height is 64"
|
1558 |
msgstr ""
|
1559 |
|
@@ -1603,6 +1615,10 @@ msgstr ""
|
|
1603 |
msgid "Gateway Title"
|
1604 |
msgstr ""
|
1605 |
|
|
|
|
|
|
|
|
|
1606 |
#: includes/updates/update-3.1.0.php:28
|
1607 |
#: includes/updates/update-3.1.0.php:55
|
1608 |
msgid "Stripe For WooCommerce Update"
|
2 |
# This file is distributed under the same license as the Stripe For WooCommerce plugin.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: Stripe For WooCommerce 3.1.8\n"
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/woo-stripe-payment\n"
|
7 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
8 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
9 |
"MIME-Version: 1.0\n"
|
10 |
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
"Content-Transfer-Encoding: 8bit\n"
|
12 |
+
"POT-Creation-Date: 2020-08-12T01:31:30+00:00\n"
|
13 |
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
14 |
"X-Generator: WP-CLI 2.4.0\n"
|
15 |
"X-Domain: woo-stripe-payment\n"
|
30 |
msgid "Payment Plugins, support@paymentplugins.com"
|
31 |
msgstr ""
|
32 |
|
33 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:105
|
34 |
#: includes/admin/meta-boxes/views/html-product-data.php:14
|
35 |
#: includes/gateways/settings/ach-settings-v2.php:9
|
36 |
#: includes/gateways/settings/ach-settings.php:9
|
41 |
msgid "Enabled"
|
42 |
msgstr ""
|
43 |
|
44 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:110
|
45 |
msgid "If enabled, your site can accept %s payments through Stripe."
|
46 |
msgstr ""
|
47 |
|
48 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:114
|
49 |
#: includes/gateways/settings/ach-settings-v2.php:64
|
50 |
#: includes/gateways/settings/ach-settings.php:73
|
51 |
#: includes/gateways/settings/applepay-settings.php:20
|
55 |
msgid "General Settings"
|
56 |
msgstr ""
|
57 |
|
58 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:118
|
59 |
#: includes/admin/meta-boxes/views/html-charge-data-subview.php:47
|
60 |
#: includes/gateways/settings/ach-settings-v2.php:68
|
61 |
#: includes/gateways/settings/ach-settings.php:77
|
62 |
#: includes/gateways/settings/applepay-settings.php:24
|
63 |
#: includes/gateways/settings/cc-settings.php:21
|
64 |
+
#: includes/gateways/settings/googlepay-settings.php:41
|
65 |
#: includes/gateways/settings/payment-request-settings.php:25
|
66 |
msgid "Title"
|
67 |
msgstr ""
|
68 |
|
69 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:124
|
70 |
#: includes/gateways/settings/ach-settings-v2.php:74
|
71 |
#: includes/gateways/settings/ach-settings.php:83
|
72 |
#: includes/gateways/settings/applepay-settings.php:30
|
73 |
#: includes/gateways/settings/cc-settings.php:27
|
74 |
+
#: includes/gateways/settings/googlepay-settings.php:47
|
75 |
#: includes/gateways/settings/payment-request-settings.php:31
|
76 |
msgid "Description"
|
77 |
msgstr ""
|
78 |
|
79 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:127
|
80 |
#: includes/gateways/settings/ach-settings-v2.php:77
|
81 |
#: includes/gateways/settings/ach-settings.php:86
|
82 |
#: includes/gateways/settings/applepay-settings.php:33
|
83 |
#: includes/gateways/settings/cc-settings.php:30
|
84 |
+
#: includes/gateways/settings/googlepay-settings.php:50
|
85 |
#: includes/gateways/settings/payment-request-settings.php:34
|
86 |
msgid "Leave blank if you don't want a description to show for the gateway."
|
87 |
msgstr ""
|
88 |
|
89 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:179
|
90 |
msgid "Order %s"
|
91 |
msgstr ""
|
92 |
|
93 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:264
|
94 |
msgid "Gateway will appear when store currency is <strong>%s</strong>"
|
95 |
msgstr ""
|
96 |
|
97 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:267
|
98 |
msgid " & billing country is <strong>%s</strong>"
|
99 |
msgstr ""
|
100 |
|
101 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:423
|
102 |
+
#: includes/controllers/class-wc-stripe-controller-cart.php:132
|
103 |
+
#: includes/controllers/class-wc-stripe-controller-cart.php:195
|
104 |
+
#: includes/controllers/class-wc-stripe-controller-googlepay.php:133
|
105 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:103
|
106 |
msgid "Total"
|
107 |
msgstr ""
|
108 |
|
109 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:483
|
110 |
msgid "User must be logged in."
|
111 |
msgstr ""
|
112 |
|
113 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:495
|
114 |
msgid "Error saving your payment method. Reason: %s"
|
115 |
msgstr ""
|
116 |
|
117 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:510
|
118 |
msgid "Error saving payment method. Reason: %s"
|
119 |
msgstr ""
|
120 |
|
121 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:529
|
122 |
msgid "Order refunded in Stripe. Amount: %s"
|
123 |
msgstr ""
|
124 |
|
125 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:567
|
126 |
msgid "Order amount captured in Stripe. Amount: %s"
|
127 |
msgstr ""
|
128 |
|
129 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:577
|
130 |
msgid "Error capturing charge in Stripe. Reason: %s"
|
131 |
msgstr ""
|
132 |
|
133 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:598
|
134 |
msgid "Error voiding charge. Reason: %s"
|
135 |
msgstr ""
|
136 |
|
137 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:600
|
138 |
msgid "Charge voided in Stripe."
|
139 |
msgstr ""
|
140 |
|
141 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:770
|
142 |
msgid "n/a"
|
143 |
msgstr ""
|
144 |
|
145 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:798
|
146 |
#: includes/admin/meta-boxes/views/html-order-pay.php:42
|
147 |
msgid "New Card"
|
148 |
msgstr ""
|
149 |
|
150 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:802
|
151 |
#: includes/admin/meta-boxes/views/html-order-pay.php:30
|
152 |
msgid "Saved Cards"
|
153 |
msgstr ""
|
154 |
|
155 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:987
|
156 |
msgid "Attemp to save payment method failed. Reason: %s"
|
157 |
msgstr ""
|
158 |
|
159 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:1009
|
160 |
msgid "We were not able to save your payment method. To prevent billing issues with your subscription, please add a payment method to the subscription."
|
161 |
msgstr ""
|
162 |
|
163 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:1011
|
164 |
msgid "We were not able to save your payment method. Reason: %s"
|
165 |
msgstr ""
|
166 |
|
167 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:1045
|
168 |
msgid "Payment Method Token"
|
169 |
msgstr ""
|
170 |
|
171 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:1065
|
172 |
msgid "Recurring payment for order failed. Reason: %s"
|
173 |
msgstr ""
|
174 |
|
175 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:1078
|
176 |
msgid "Recurring payment captured in Stripe. Payment method: %s"
|
177 |
msgstr ""
|
178 |
|
179 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:1080
|
180 |
msgid "Recurring payment authorized in Stripe. Payment method: %s"
|
181 |
msgstr ""
|
182 |
|
183 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:1083
|
184 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:1342
|
185 |
msgid "Customer must manually complete payment for payment method %s"
|
186 |
msgstr ""
|
187 |
|
188 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:1099
|
189 |
msgid "Error saving payment method for subscription. Reason: %s"
|
190 |
msgstr ""
|
191 |
|
192 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:1160
|
193 |
#: includes/abstract/abstract-wc-stripe-payment.php:219
|
194 |
msgid "Order %1$s from %2$s"
|
195 |
msgstr ""
|
196 |
|
197 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:1329
|
198 |
msgid "Pre-order payment for order failed. Reason: %s"
|
199 |
msgstr ""
|
200 |
|
201 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:1337
|
202 |
msgid "Pre-order payment captured in Stripe. Payment method: %s"
|
203 |
msgstr ""
|
204 |
|
205 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:1339
|
206 |
msgid "Pre-order payment authorized in Stripe. Payment method: %s"
|
207 |
msgstr ""
|
208 |
|
209 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:1411
|
210 |
msgid "Cannot process payment"
|
211 |
msgstr ""
|
212 |
|
213 |
+
#: includes/abstract/abstract-wc-payment-gateway-stripe.php:1419
|
214 |
msgid "Increase your conversion rate by offering %1$s on your Product and Cart pages, or at the top of the checkout page. <br/><strong>Note:</strong> you can control which products display %s by going to the product edit page."
|
215 |
msgstr ""
|
216 |
|
305 |
#: includes/admin/meta-boxes/views/html-product-data.php:51
|
306 |
#: includes/gateways/settings/applepay-settings.php:52
|
307 |
#: includes/gateways/settings/cc-settings.php:49
|
308 |
+
#: includes/gateways/settings/googlepay-settings.php:69
|
309 |
#: includes/gateways/settings/payment-request-settings.php:53
|
310 |
msgid "Capture"
|
311 |
msgstr ""
|
349 |
|
350 |
#: includes/admin/meta-boxes/views/html-charge-data-subview.php:51
|
351 |
#: includes/admin/views/html-ach-fee.php:12
|
352 |
+
#: includes/gateways/settings/payment-request-settings.php:87
|
353 |
msgid "Type"
|
354 |
msgstr ""
|
355 |
|
431 |
#: includes/admin/meta-boxes/views/html-product-data.php:15
|
432 |
#: includes/gateways/settings/applepay-settings.php:48
|
433 |
#: includes/gateways/settings/cc-settings.php:45
|
434 |
+
#: includes/gateways/settings/googlepay-settings.php:65
|
435 |
#: includes/gateways/settings/payment-request-settings.php:49
|
436 |
msgid "Charge Type"
|
437 |
msgstr ""
|
440 |
#: includes/admin/meta-boxes/views/html-product-data.php:53
|
441 |
#: includes/gateways/settings/applepay-settings.php:53
|
442 |
#: includes/gateways/settings/cc-settings.php:50
|
443 |
+
#: includes/gateways/settings/googlepay-settings.php:70
|
444 |
#: includes/gateways/settings/payment-request-settings.php:54
|
445 |
msgid "Authorize"
|
446 |
msgstr ""
|
647 |
msgstr ""
|
648 |
|
649 |
#: includes/class-wc-stripe-redirect-handler.php:51
|
650 |
+
msgid "Payment for order was not completed."
|
651 |
+
msgstr ""
|
652 |
+
|
653 |
+
#: includes/class-wc-stripe-redirect-handler.php:55
|
654 |
msgid "Payment authorization failed. Please select another payment method."
|
655 |
msgstr ""
|
656 |
|
657 |
+
#: includes/class-wc-stripe-redirect-handler.php:61
|
658 |
msgid "Payment authorization failed."
|
659 |
msgstr ""
|
660 |
|
661 |
+
#: includes/class-wc-stripe-rest-api.php:37
|
662 |
msgid "%1$s is an invalid controller name."
|
663 |
msgstr ""
|
664 |
|
666 |
msgid "Thank you for updating Stripe for WooCommerce to version %1$s."
|
667 |
msgstr ""
|
668 |
|
669 |
+
#: includes/controllers/class-wc-stripe-controller-cart.php:88
|
670 |
msgid "Quantity must be greater than zero."
|
671 |
msgstr ""
|
672 |
|
673 |
+
#: includes/controllers/class-wc-stripe-controller-checkout.php:231
|
674 |
msgid "Some required fields were missing. Please click %1$shere%2$s to complete your payment."
|
675 |
msgstr ""
|
676 |
|
677 |
+
#: includes/controllers/class-wc-stripe-controller-checkout.php:280
|
678 |
msgid "Please review your order details then click Place Order."
|
679 |
msgstr ""
|
680 |
|
711 |
msgid "Connection test to Stripe was successful. Mode: %s."
|
712 |
msgstr ""
|
713 |
|
714 |
+
#: includes/controllers/class-wc-stripe-controller-googlepay.php:86
|
715 |
msgid "Your shipping address is not serviceable."
|
716 |
msgstr ""
|
717 |
|
718 |
+
#: includes/controllers/class-wc-stripe-controller-order-actions.php:127
|
719 |
msgid "Invalid amount entered."
|
720 |
msgstr ""
|
721 |
|
|
|
722 |
#: includes/controllers/class-wc-stripe-controller-order-actions.php:182
|
723 |
+
#: includes/controllers/class-wc-stripe-controller-order-actions.php:185
|
724 |
msgid "Order total must be greater than zero."
|
725 |
msgstr ""
|
726 |
|
727 |
+
#: includes/controllers/class-wc-stripe-controller-order-actions.php:195
|
728 |
msgid "This order has already been processed. Transaction ID: %1$s. Payment method: %2$s"
|
729 |
msgstr ""
|
730 |
|
731 |
+
#: includes/controllers/class-wc-stripe-controller-order-actions.php:204
|
732 |
msgid "Order customer Id and payment method customer Id do not match."
|
733 |
msgstr ""
|
734 |
|
806 |
msgid "Apple Pay gateway that integrates with your Stripe account."
|
807 |
msgstr ""
|
808 |
|
809 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-applepay.php:84
|
810 |
msgid "Please update you product quantity before using Apple Pay."
|
811 |
msgstr ""
|
812 |
|
813 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-applepay.php:85
|
814 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-payment-request.php:80
|
815 |
msgid "Please select a product option before updating quantity."
|
816 |
msgstr ""
|
817 |
|
888 |
msgstr ""
|
889 |
|
890 |
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:20
|
891 |
+
#: includes/gateways/settings/googlepay-settings.php:42
|
892 |
msgid "Google Pay"
|
893 |
msgstr ""
|
894 |
|
900 |
msgid "Google Pay gateway that integrates with your Stripe account."
|
901 |
msgstr ""
|
902 |
|
903 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:105
|
904 |
msgid "Please update you product quantity before using Google Pay."
|
905 |
msgstr ""
|
906 |
|
907 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:125
|
908 |
msgid "Subscription"
|
909 |
msgstr ""
|
910 |
|
911 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:154
|
912 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:217
|
913 |
#: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:189
|
914 |
+
#: includes/wc-stripe-functions.php:403
|
915 |
+
#: includes/wc-stripe-functions.php:468
|
916 |
msgid "Shipping"
|
917 |
msgstr ""
|
918 |
|
919 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:162
|
920 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:239
|
921 |
#: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:199
|
922 |
+
#: includes/wc-stripe-functions.php:420
|
923 |
+
#: includes/wc-stripe-functions.php:476
|
924 |
msgid "Discount"
|
925 |
msgstr ""
|
926 |
|
927 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:173
|
928 |
+
#: includes/wc-stripe-functions.php:487
|
929 |
msgid "Fees"
|
930 |
msgstr ""
|
931 |
|
932 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:253
|
933 |
#: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:221
|
934 |
+
#: includes/wc-stripe-functions.php:428
|
935 |
msgid "Tax"
|
936 |
msgstr ""
|
937 |
|
938 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:290
|
939 |
msgid "Waiting..."
|
940 |
msgstr ""
|
941 |
|
942 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:291
|
943 |
msgid "loading shipping methods..."
|
944 |
msgstr ""
|
945 |
|
946 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-grabpay.php:25
|
947 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-grabpay.php:26
|
948 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-grabpay.php:29
|
949 |
+
msgid "GrabPay"
|
950 |
+
msgstr ""
|
951 |
+
|
952 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-grabpay.php:27
|
953 |
+
msgid "GrabPay gateway that integrates with your Stripe account."
|
954 |
+
msgstr ""
|
955 |
+
|
956 |
#: includes/gateways/class-wc-payment-gateway-stripe-ideal.php:25
|
957 |
#: includes/gateways/class-wc-payment-gateway-stripe-ideal.php:26
|
958 |
#: includes/gateways/class-wc-payment-gateway-stripe-ideal.php:29
|
1040 |
msgid "Gateway that renders based on the user's browser. Chrome payment methods, Microsoft pay, etc."
|
1041 |
msgstr ""
|
1042 |
|
1043 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-payment-request.php:78
|
1044 |
msgid "Please update you product quantity before paying."
|
1045 |
msgstr ""
|
1046 |
|
1047 |
+
#: includes/gateways/class-wc-payment-gateway-stripe-payment-request.php:79
|
1048 |
msgid "Adding to cart..."
|
1049 |
msgstr ""
|
1050 |
|
1247 |
|
1248 |
#: includes/gateways/settings/applepay-settings.php:37
|
1249 |
#: includes/gateways/settings/cc-settings.php:34
|
1250 |
+
#: includes/gateways/settings/googlepay-settings.php:54
|
1251 |
#: includes/gateways/settings/payment-request-settings.php:38
|
1252 |
msgid "Credit Card Display"
|
1253 |
msgstr ""
|
1259 |
msgstr ""
|
1260 |
|
1261 |
#: includes/gateways/settings/applepay-settings.php:60
|
1262 |
+
#: includes/gateways/settings/googlepay-settings.php:77
|
1263 |
#: includes/gateways/settings/payment-request-settings.php:61
|
1264 |
msgid "Payment Sections"
|
1265 |
msgstr ""
|
1266 |
|
1267 |
#: includes/gateways/settings/applepay-settings.php:63
|
1268 |
+
#: includes/gateways/settings/googlepay-settings.php:80
|
1269 |
#: includes/gateways/settings/payment-request-settings.php:64
|
1270 |
msgid "Product Page"
|
1271 |
msgstr ""
|
1272 |
|
1273 |
#: includes/gateways/settings/applepay-settings.php:64
|
1274 |
+
#: includes/gateways/settings/googlepay-settings.php:81
|
1275 |
#: includes/gateways/settings/payment-request-settings.php:65
|
1276 |
msgid "Cart Page"
|
1277 |
msgstr ""
|
1278 |
|
1279 |
#: includes/gateways/settings/applepay-settings.php:65
|
1280 |
+
#: includes/gateways/settings/googlepay-settings.php:82
|
1281 |
#: includes/gateways/settings/payment-request-settings.php:66
|
1282 |
+
msgid "Mini Cart"
|
1283 |
+
msgstr ""
|
1284 |
+
|
1285 |
+
#: includes/gateways/settings/applepay-settings.php:66
|
1286 |
+
#: includes/gateways/settings/googlepay-settings.php:83
|
1287 |
+
#: includes/gateways/settings/payment-request-settings.php:67
|
1288 |
msgid "Top of Checkout"
|
1289 |
msgstr ""
|
1290 |
|
1291 |
+
#: includes/gateways/settings/applepay-settings.php:73
|
1292 |
#: includes/gateways/settings/cc-settings.php:57
|
1293 |
+
#: includes/gateways/settings/googlepay-settings.php:90
|
1294 |
+
#: includes/gateways/settings/payment-request-settings.php:74
|
1295 |
msgid "Order Status"
|
1296 |
msgstr ""
|
1297 |
|
1298 |
+
#: includes/gateways/settings/applepay-settings.php:76
|
1299 |
#: includes/gateways/settings/cc-settings.php:60
|
1300 |
+
#: includes/gateways/settings/googlepay-settings.php:93
|
1301 |
+
#: includes/gateways/settings/payment-request-settings.php:77
|
1302 |
msgid "Default"
|
1303 |
msgstr ""
|
1304 |
|
1305 |
+
#: includes/gateways/settings/applepay-settings.php:78
|
1306 |
#: includes/gateways/settings/cc-settings.php:62
|
1307 |
+
#: includes/gateways/settings/googlepay-settings.php:95
|
1308 |
+
#: includes/gateways/settings/payment-request-settings.php:79
|
1309 |
msgid "This is the status of the order once payment is complete. If <b>Default</b> is selected, then WooCommerce will set the order status automatically based on internal logic which states if a product is virtual and downloadable then status is set to complete. Products that require shipping are set to Processing. Default is the recommended setting as it allows standard WooCommerce code to process the order status."
|
1310 |
msgstr ""
|
1311 |
|
1312 |
+
#: includes/gateways/settings/applepay-settings.php:82
|
1313 |
+
#: includes/gateways/settings/payment-request-settings.php:83
|
1314 |
msgid "Button Settings"
|
1315 |
msgstr ""
|
1316 |
|
1317 |
+
#: includes/gateways/settings/applepay-settings.php:86
|
1318 |
+
#: includes/gateways/settings/googlepay-settings.php:143
|
1319 |
msgid "Button Design"
|
1320 |
msgstr ""
|
1321 |
|
1322 |
+
#: includes/gateways/settings/applepay-settings.php:90
|
1323 |
msgid "Black Button"
|
1324 |
msgstr ""
|
1325 |
|
1326 |
+
#: includes/gateways/settings/applepay-settings.php:91
|
1327 |
msgid "White With Black Line"
|
1328 |
msgstr ""
|
1329 |
|
1330 |
+
#: includes/gateways/settings/applepay-settings.php:92
|
1331 |
msgid "White Button"
|
1332 |
msgstr ""
|
1333 |
|
1334 |
+
#: includes/gateways/settings/applepay-settings.php:94
|
1335 |
msgid "This is the style for all Apple Pay buttons presented on your store."
|
1336 |
msgstr ""
|
1337 |
|
1338 |
+
#: includes/gateways/settings/applepay-settings.php:97
|
1339 |
msgid "Checkout button type"
|
1340 |
msgstr ""
|
1341 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1342 |
#: includes/gateways/settings/applepay-settings.php:100
|
1343 |
#: includes/gateways/settings/applepay-settings.php:110
|
1344 |
#: includes/gateways/settings/applepay-settings.php:120
|
1345 |
+
msgid "Standard Button"
|
1346 |
+
msgstr ""
|
1347 |
+
|
1348 |
+
#: includes/gateways/settings/applepay-settings.php:101
|
1349 |
+
#: includes/gateways/settings/applepay-settings.php:111
|
1350 |
+
#: includes/gateways/settings/applepay-settings.php:121
|
1351 |
msgid "Buy with Apple Pay"
|
1352 |
msgstr ""
|
1353 |
|
1354 |
+
#: includes/gateways/settings/applepay-settings.php:107
|
1355 |
msgid "Cart button type"
|
1356 |
msgstr ""
|
1357 |
|
1358 |
+
#: includes/gateways/settings/applepay-settings.php:117
|
1359 |
msgid "Product button type"
|
1360 |
msgstr ""
|
1361 |
|
1443 |
msgid "If enabled, your site can accept Google Pay payments through Stripe."
|
1444 |
msgstr ""
|
1445 |
|
1446 |
+
#: includes/gateways/settings/googlepay-settings.php:35
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1447 |
msgid "Merchant ID"
|
1448 |
msgstr ""
|
1449 |
|
1450 |
+
#: includes/gateways/settings/googlepay-settings.php:37
|
1451 |
msgid "Your Google Merchant ID is given to you by the Google API team once you register for Google Pay. While testing in TEST mode you can leave this value blank and Google Pay will work."
|
1452 |
msgstr ""
|
1453 |
|
1454 |
+
#: includes/gateways/settings/googlepay-settings.php:73
|
1455 |
msgid "This option determines whether the customer's funds are capture immediately or authorized and can be captured at a later date."
|
1456 |
msgstr ""
|
1457 |
|
1458 |
+
#: includes/gateways/settings/googlepay-settings.php:99
|
1459 |
msgid "Merchant Name"
|
1460 |
msgstr ""
|
1461 |
|
1462 |
+
#: includes/gateways/settings/googlepay-settings.php:101
|
1463 |
msgid "The name of your business as it appears on the Google Pay payment sheet."
|
1464 |
msgstr ""
|
1465 |
|
1466 |
+
#: includes/gateways/settings/googlepay-settings.php:105
|
1467 |
msgid "Icon"
|
1468 |
msgstr ""
|
1469 |
|
1470 |
+
#: includes/gateways/settings/googlepay-settings.php:108
|
1471 |
msgid "With Outline"
|
1472 |
msgstr ""
|
1473 |
|
1474 |
+
#: includes/gateways/settings/googlepay-settings.php:109
|
1475 |
msgid "Standard"
|
1476 |
msgstr ""
|
1477 |
|
1478 |
+
#: includes/gateways/settings/googlepay-settings.php:113
|
1479 |
msgid "This is the icon style that appears next to the gateway on the checkout page. Google's API team typically requires the With Outline option on the checkout page for branding purposes."
|
1480 |
msgstr ""
|
1481 |
|
1482 |
+
#: includes/gateways/settings/googlepay-settings.php:117
|
1483 |
msgid "Button Options"
|
1484 |
msgstr ""
|
1485 |
|
1486 |
+
#: includes/gateways/settings/googlepay-settings.php:120
|
1487 |
msgid "Button Color"
|
1488 |
msgstr ""
|
1489 |
|
1490 |
+
#: includes/gateways/settings/googlepay-settings.php:124
|
1491 |
msgid "Black"
|
1492 |
msgstr ""
|
1493 |
|
1494 |
+
#: includes/gateways/settings/googlepay-settings.php:125
|
1495 |
msgid "White"
|
1496 |
msgstr ""
|
1497 |
|
1498 |
+
#: includes/gateways/settings/googlepay-settings.php:128
|
1499 |
msgid "The button color of the GPay button."
|
1500 |
msgstr ""
|
1501 |
|
1502 |
+
#: includes/gateways/settings/googlepay-settings.php:131
|
1503 |
msgid "Button Style"
|
1504 |
msgstr ""
|
1505 |
|
1506 |
+
#: includes/gateways/settings/googlepay-settings.php:135
|
1507 |
msgid "Long"
|
1508 |
msgstr ""
|
1509 |
|
1510 |
+
#: includes/gateways/settings/googlepay-settings.php:136
|
1511 |
msgid "Short"
|
1512 |
msgstr ""
|
1513 |
|
1514 |
+
#: includes/gateways/settings/googlepay-settings.php:139
|
1515 |
msgid "The button style of the GPay button."
|
1516 |
msgstr ""
|
1517 |
|
1518 |
+
#: includes/gateways/settings/googlepay-settings.php:145
|
1519 |
msgid "If you can't see the Google Pay button, try switching to a Chrome browser."
|
1520 |
msgstr ""
|
1521 |
|
1529 |
msgid "Browser Payments"
|
1530 |
msgstr ""
|
1531 |
|
1532 |
+
#: includes/gateways/settings/payment-request-settings.php:89
|
1533 |
msgid "default"
|
1534 |
msgstr ""
|
1535 |
|
1536 |
+
#: includes/gateways/settings/payment-request-settings.php:91
|
1537 |
msgid "buy"
|
1538 |
msgstr ""
|
1539 |
|
1540 |
+
#: includes/gateways/settings/payment-request-settings.php:95
|
1541 |
msgid "This defines the type of button that will display."
|
1542 |
msgstr ""
|
1543 |
|
1544 |
+
#: includes/gateways/settings/payment-request-settings.php:99
|
1545 |
msgid "Theme"
|
1546 |
msgstr ""
|
1547 |
|
1548 |
+
#: includes/gateways/settings/payment-request-settings.php:101
|
1549 |
msgid "dark"
|
1550 |
msgstr ""
|
1551 |
|
1552 |
+
#: includes/gateways/settings/payment-request-settings.php:102
|
1553 |
msgid "light"
|
1554 |
msgstr ""
|
1555 |
|
1556 |
+
#: includes/gateways/settings/payment-request-settings.php:103
|
1557 |
msgid "light-outline"
|
1558 |
msgstr ""
|
1559 |
|
1560 |
+
#: includes/gateways/settings/payment-request-settings.php:107
|
1561 |
msgid "This defines the color scheme for the button."
|
1562 |
msgstr ""
|
1563 |
|
1564 |
+
#: includes/gateways/settings/payment-request-settings.php:111
|
1565 |
msgid "Height"
|
1566 |
msgstr ""
|
1567 |
|
1568 |
+
#: includes/gateways/settings/payment-request-settings.php:114
|
1569 |
msgid "The height of the button. Max height is 64"
|
1570 |
msgstr ""
|
1571 |
|
1615 |
msgid "Gateway Title"
|
1616 |
msgstr ""
|
1617 |
|
1618 |
+
#: includes/traits/wc-stripe-controller-traits.php:39
|
1619 |
+
msgid "Invalid shipping method format. Expected: index:id"
|
1620 |
+
msgstr ""
|
1621 |
+
|
1622 |
#: includes/updates/update-3.1.0.php:28
|
1623 |
#: includes/updates/update-3.1.0.php:55
|
1624 |
msgid "Stripe For WooCommerce Update"
|
includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php
CHANGED
@@ -18,7 +18,6 @@ abstract class WC_Payment_Gateway_Stripe_Local_Payment extends WC_Payment_Gatewa
|
|
18 |
|
19 |
/**
|
20 |
* Currencies this gateway accepts
|
21 |
-
*get_source_args
|
22 |
* @var array
|
23 |
*/
|
24 |
protected $currencies = array();
|
@@ -81,13 +80,10 @@ abstract class WC_Payment_Gateway_Stripe_Local_Payment extends WC_Payment_Gatewa
|
|
81 |
$result = parent::process_payment( $order_id );
|
82 |
|
83 |
if ( defined( WC_Stripe_Constants::WOOCOMMERCE_STRIPE_ORDER_PAY ) && $result['result'] == 'success' ) {
|
84 |
-
wp_send_json(
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
),
|
89 |
-
200
|
90 |
-
);
|
91 |
exit();
|
92 |
}
|
93 |
|
@@ -176,17 +172,26 @@ abstract class WC_Payment_Gateway_Stripe_Local_Payment extends WC_Payment_Gatewa
|
|
176 |
* @param WC_Order $order
|
177 |
*/
|
178 |
public function get_source_args( $order ) {
|
179 |
-
|
180 |
'type' => $this->local_payment_type,
|
181 |
'amount' => wc_stripe_add_number_precision( $order->get_total(), $order->get_currency() ),
|
182 |
'currency' => $order->get_currency(),
|
183 |
'statement_descriptor' => sprintf( __( 'Order %s', 'woo-stripe-payment' ), $order->get_order_number() ),
|
184 |
'owner' => array(
|
185 |
-
'name'
|
186 |
-
'email' => $order->get_billing_email(),
|
187 |
),
|
188 |
'redirect' => array( 'return_url' => $this->get_local_payment_return_url( $order ) ),
|
189 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
190 |
}
|
191 |
|
192 |
/**
|
18 |
|
19 |
/**
|
20 |
* Currencies this gateway accepts
|
|
|
21 |
* @var array
|
22 |
*/
|
23 |
protected $currencies = array();
|
80 |
$result = parent::process_payment( $order_id );
|
81 |
|
82 |
if ( defined( WC_Stripe_Constants::WOOCOMMERCE_STRIPE_ORDER_PAY ) && $result['result'] == 'success' ) {
|
83 |
+
wp_send_json( array(
|
84 |
+
'success' => true,
|
85 |
+
'redirect' => $result['redirect']
|
86 |
+
), 200 );
|
|
|
|
|
|
|
87 |
exit();
|
88 |
}
|
89 |
|
172 |
* @param WC_Order $order
|
173 |
*/
|
174 |
public function get_source_args( $order ) {
|
175 |
+
$args = array(
|
176 |
'type' => $this->local_payment_type,
|
177 |
'amount' => wc_stripe_add_number_precision( $order->get_total(), $order->get_currency() ),
|
178 |
'currency' => $order->get_currency(),
|
179 |
'statement_descriptor' => sprintf( __( 'Order %s', 'woo-stripe-payment' ), $order->get_order_number() ),
|
180 |
'owner' => array(
|
181 |
+
'name' => $this->payment_object->get_name_from_order( $order, 'billing' )
|
|
|
182 |
),
|
183 |
'redirect' => array( 'return_url' => $this->get_local_payment_return_url( $order ) ),
|
184 |
);
|
185 |
+
if ( ( $email = $order->get_billing_email() ) ) {
|
186 |
+
$args['owner']['email'] = $email;
|
187 |
+
}
|
188 |
+
|
189 |
+
/**
|
190 |
+
* @param $args
|
191 |
+
*
|
192 |
+
* @since 3.1.8
|
193 |
+
*/
|
194 |
+
return apply_filters( 'wc_stripe_get_source_args', $args );
|
195 |
}
|
196 |
|
197 |
/**
|
includes/abstract/abstract-wc-payment-gateway-stripe.php
CHANGED
@@ -28,6 +28,12 @@ abstract class WC_Payment_Gateway_Stripe extends WC_Payment_Gateway {
|
|
28 |
*/
|
29 |
public $payment_object;
|
30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
/**
|
32 |
*
|
33 |
* @var string
|
@@ -151,6 +157,11 @@ abstract class WC_Payment_Gateway_Stripe extends WC_Payment_Gateway {
|
|
151 |
add_action( 'woocommerce_subscription_payment_method_updated_to_' . $this->id, array( $this, 'subscription_payment_method_updated' ) );
|
152 |
}
|
153 |
add_action( 'wc_pre_orders_process_pre_order_completion_payment_' . $this->id, array( $this, 'process_pre_order_payment' ) );
|
|
|
|
|
|
|
|
|
|
|
154 |
}
|
155 |
|
156 |
public function init_supports() {
|
@@ -177,8 +188,7 @@ abstract class WC_Payment_Gateway_Stripe extends WC_Payment_Gateway {
|
|
177 |
$this->form_fields = include wc_stripe()->plugin_path() . 'includes/gateways/settings/' . str_replace( array( 'stripe_', '_' ), array(
|
178 |
'',
|
179 |
'-'
|
180 |
-
), $this->id ) .
|
181 |
-
'-settings.php';
|
182 |
$this->form_fields = apply_filters( 'wc_stripe_form_fields_' . $this->id, $this->form_fields );
|
183 |
}
|
184 |
|
@@ -204,6 +214,9 @@ abstract class WC_Payment_Gateway_Stripe extends WC_Payment_Gateway {
|
|
204 |
$this->enqueue_frontend_scripts();
|
205 |
wc_stripe_token_field( $this );
|
206 |
wc_stripe_payment_intent_field( $this );
|
|
|
|
|
|
|
207 |
wc_stripe_get_template(
|
208 |
'checkout/stripe-payment-method.php',
|
209 |
array(
|
@@ -219,6 +232,7 @@ abstract class WC_Payment_Gateway_Stripe extends WC_Payment_Gateway {
|
|
219 |
public function product_fields() {
|
220 |
global $product;
|
221 |
$this->enqueue_frontend_scripts( 'product' );
|
|
|
222 |
wc_stripe_token_field( $this );
|
223 |
wc_stripe_get_template(
|
224 |
'product/' . $this->template_name,
|
@@ -232,9 +246,16 @@ abstract class WC_Payment_Gateway_Stripe extends WC_Payment_Gateway {
|
|
232 |
public function cart_fields() {
|
233 |
$this->enqueue_frontend_scripts( 'cart' );
|
234 |
wc_stripe_token_field( $this );
|
|
|
235 |
wc_stripe_get_template( 'cart/' . $this->template_name, array( 'gateway' => $this ) );
|
236 |
}
|
237 |
|
|
|
|
|
|
|
|
|
|
|
|
|
238 |
/**
|
239 |
* Enqueue scripts needed by the gateway on the frontend of the WC shop.
|
240 |
*
|
@@ -249,6 +270,8 @@ abstract class WC_Payment_Gateway_Stripe extends WC_Payment_Gateway {
|
|
249 |
$this->enqueue_cart_scripts( wc_stripe()->scripts() );
|
250 |
} elseif ( 'checkout' === $page ) {
|
251 |
$this->enqueue_checkout_scripts( wc_stripe()->scripts() );
|
|
|
|
|
252 |
} else {
|
253 |
$this->enqueue_frontend_scripts();
|
254 |
}
|
@@ -305,6 +328,18 @@ abstract class WC_Payment_Gateway_Stripe extends WC_Payment_Gateway {
|
|
305 |
public function enqueue_product_scripts( $scripts ) {
|
306 |
}
|
307 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
308 |
/**
|
309 |
*
|
310 |
* {@inheritDoc}
|
@@ -368,13 +403,12 @@ abstract class WC_Payment_Gateway_Stripe extends WC_Payment_Gateway {
|
|
368 |
*/
|
369 |
public function get_localized_params() {
|
370 |
return array(
|
371 |
-
'gateway_id'
|
372 |
-
'api_key'
|
373 |
-
'saved_method_selector'
|
374 |
-
'token_selector'
|
375 |
-
'
|
376 |
-
'
|
377 |
-
'routes' => array(
|
378 |
'setup_intent' => wc_stripe()->rest_api->payment_intent->rest_url( 'setup-intent' ),
|
379 |
'sync_intent' => wc_stripe()->rest_api->payment_intent->rest_url( 'sync-payment-intent' ),
|
380 |
'add_to_cart' => wc_stripe()->rest_api->cart->rest_url( 'add-to-cart' ),
|
@@ -383,12 +417,12 @@ abstract class WC_Payment_Gateway_Stripe extends WC_Payment_Gateway {
|
|
383 |
'shipping_address' => wc_stripe()->rest_api->cart->rest_url( 'shipping-address' ),
|
384 |
'checkout' => wc_stripe()->rest_api->checkout->rest_url( 'checkout' ),
|
385 |
),
|
386 |
-
'rest_nonce'
|
387 |
-
'
|
388 |
-
'
|
389 |
-
'
|
390 |
-
'
|
391 |
-
'
|
392 |
);
|
393 |
}
|
394 |
|
@@ -849,11 +883,12 @@ abstract class WC_Payment_Gateway_Stripe extends WC_Payment_Gateway {
|
|
849 |
/**
|
850 |
* Returns a formatted array of items for display in the payment gateway's payment sheet.
|
851 |
*
|
852 |
-
* @param
|
853 |
*
|
854 |
* @return []
|
855 |
*/
|
856 |
-
public function get_display_items( $
|
|
|
857 |
}
|
858 |
|
859 |
/**
|
@@ -864,7 +899,8 @@ abstract class WC_Payment_Gateway_Stripe extends WC_Payment_Gateway {
|
|
864 |
*
|
865 |
* @return []
|
866 |
*/
|
867 |
-
public function get_shipping_methods(
|
|
|
868 |
}
|
869 |
|
870 |
/**
|
@@ -885,6 +921,16 @@ abstract class WC_Payment_Gateway_Stripe extends WC_Payment_Gateway {
|
|
885 |
return in_array( 'cart', $this->get_option( 'payment_sections', array() ) );
|
886 |
}
|
887 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
888 |
/**
|
889 |
* Return true if checkout page banner is enabled for this gateway
|
890 |
*
|
@@ -976,7 +1022,7 @@ abstract class WC_Payment_Gateway_Stripe extends WC_Payment_Gateway {
|
|
976 |
* @return null|WC_Payment_Token_Stripe_CC
|
977 |
*/
|
978 |
public function get_token( $token_id, $user_id ) {
|
979 |
-
$tokens = WC_Payment_Tokens::
|
980 |
foreach ( $tokens as $token ) {
|
981 |
if ( $token_id === $token->get_token() ) {
|
982 |
return $token;
|
@@ -1075,7 +1121,9 @@ abstract class WC_Payment_Gateway_Stripe extends WC_Payment_Gateway {
|
|
1075 |
|
1076 |
// update the meta data needed by the gateway to process a subscription payment.
|
1077 |
$subscription->update_meta_data( WC_Stripe_Constants::PAYMENT_METHOD_TOKEN, $this->payment_method_token );
|
1078 |
-
|
|
|
|
|
1079 |
$subscription->save();
|
1080 |
}
|
1081 |
|
@@ -1370,4 +1418,57 @@ abstract class WC_Payment_Gateway_Stripe extends WC_Payment_Gateway {
|
|
1370 |
private function get_payment_section_description() {
|
1371 |
return sprintf( __( 'Increase your conversion rate by offering %1$s on your Product and Cart pages, or at the top of the checkout page. <br/><strong>Note:</strong> you can control which products display %s by going to the product edit page.', 'woo-stripe-payment' ), $this->get_method_title() );
|
1372 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1373 |
}
|
28 |
*/
|
29 |
public $payment_object;
|
30 |
|
31 |
+
/**
|
32 |
+
* @var bool
|
33 |
+
* @since 3.1.8
|
34 |
+
*/
|
35 |
+
protected $has_digital_wallet = false;
|
36 |
+
|
37 |
/**
|
38 |
*
|
39 |
* @var string
|
157 |
add_action( 'woocommerce_subscription_payment_method_updated_to_' . $this->id, array( $this, 'subscription_payment_method_updated' ) );
|
158 |
}
|
159 |
add_action( 'wc_pre_orders_process_pre_order_completion_payment_' . $this->id, array( $this, 'process_pre_order_payment' ) );
|
160 |
+
|
161 |
+
/**
|
162 |
+
* @since 3.1.8
|
163 |
+
*/
|
164 |
+
add_filter( 'wc_stripe_mini_cart_dependencies', array( $this, 'get_mini_cart_dependencies' ), 10, 2 );
|
165 |
}
|
166 |
|
167 |
public function init_supports() {
|
188 |
$this->form_fields = include wc_stripe()->plugin_path() . 'includes/gateways/settings/' . str_replace( array( 'stripe_', '_' ), array(
|
189 |
'',
|
190 |
'-'
|
191 |
+
), $this->id ) . '-settings.php';
|
|
|
192 |
$this->form_fields = apply_filters( 'wc_stripe_form_fields_' . $this->id, $this->form_fields );
|
193 |
}
|
194 |
|
214 |
$this->enqueue_frontend_scripts();
|
215 |
wc_stripe_token_field( $this );
|
216 |
wc_stripe_payment_intent_field( $this );
|
217 |
+
if ( $this->has_digital_wallet ) {
|
218 |
+
$this->output_display_items( 'checkout' );
|
219 |
+
}
|
220 |
wc_stripe_get_template(
|
221 |
'checkout/stripe-payment-method.php',
|
222 |
array(
|
232 |
public function product_fields() {
|
233 |
global $product;
|
234 |
$this->enqueue_frontend_scripts( 'product' );
|
235 |
+
$this->output_display_items( 'product' );
|
236 |
wc_stripe_token_field( $this );
|
237 |
wc_stripe_get_template(
|
238 |
'product/' . $this->template_name,
|
246 |
public function cart_fields() {
|
247 |
$this->enqueue_frontend_scripts( 'cart' );
|
248 |
wc_stripe_token_field( $this );
|
249 |
+
$this->output_display_items( 'cart' );
|
250 |
wc_stripe_get_template( 'cart/' . $this->template_name, array( 'gateway' => $this ) );
|
251 |
}
|
252 |
|
253 |
+
public function mini_cart_fields() {
|
254 |
+
wc_stripe_token_field( $this );
|
255 |
+
$this->output_display_items( 'cart' );
|
256 |
+
wc_stripe_get_template( 'mini-cart/' . $this->template_name, array( 'gateway' => $this ) );
|
257 |
+
}
|
258 |
+
|
259 |
/**
|
260 |
* Enqueue scripts needed by the gateway on the frontend of the WC shop.
|
261 |
*
|
270 |
$this->enqueue_cart_scripts( wc_stripe()->scripts() );
|
271 |
} elseif ( 'checkout' === $page ) {
|
272 |
$this->enqueue_checkout_scripts( wc_stripe()->scripts() );
|
273 |
+
} elseif ( 'mini_cart' === $page ) {
|
274 |
+
$this->enqueue_mini_cart_scripts( wc_stripe()->scripts() );
|
275 |
} else {
|
276 |
$this->enqueue_frontend_scripts();
|
277 |
}
|
328 |
public function enqueue_product_scripts( $scripts ) {
|
329 |
}
|
330 |
|
331 |
+
/**
|
332 |
+
* @param WC_Stripe_Frontend_Scripts $scripts
|
333 |
+
*
|
334 |
+
* @since 3.1.8
|
335 |
+
*/
|
336 |
+
public function enqueue_mini_cart_scripts( $scripts ) {
|
337 |
+
if ( ! wp_script_is( $scripts->get_handle( 'mini-cart' ) ) ) {
|
338 |
+
$scripts->enqueue_script( 'mini-cart', $scripts->assets_url( 'js/frontend/mini-cart.js' ), apply_filters( 'wc_stripe_mini_cart_dependencies', array( $scripts->get_handle( 'wc-stripe' ) ), $scripts ) );
|
339 |
+
}
|
340 |
+
$scripts->localize_script( 'mini-cart', $this->get_localized_params(), 'wc_' . $this->id . '_mini_cart_params' );
|
341 |
+
}
|
342 |
+
|
343 |
/**
|
344 |
*
|
345 |
* {@inheritDoc}
|
403 |
*/
|
404 |
public function get_localized_params() {
|
405 |
return array(
|
406 |
+
'gateway_id' => $this->id,
|
407 |
+
'api_key' => wc_stripe_get_publishable_key(),
|
408 |
+
'saved_method_selector' => '[name="' . $this->saved_method_key . '"]',
|
409 |
+
'token_selector' => '[name="' . $this->token_key . '"]',
|
410 |
+
'messages' => array( 'terms' => __( 'Please read and accept the terms and conditions to proceed with your order.', 'woocommerce' ) ),
|
411 |
+
'routes' => array(
|
|
|
412 |
'setup_intent' => wc_stripe()->rest_api->payment_intent->rest_url( 'setup-intent' ),
|
413 |
'sync_intent' => wc_stripe()->rest_api->payment_intent->rest_url( 'sync-payment-intent' ),
|
414 |
'add_to_cart' => wc_stripe()->rest_api->cart->rest_url( 'add-to-cart' ),
|
417 |
'shipping_address' => wc_stripe()->rest_api->cart->rest_url( 'shipping-address' ),
|
418 |
'checkout' => wc_stripe()->rest_api->checkout->rest_url( 'checkout' ),
|
419 |
),
|
420 |
+
'rest_nonce' => wp_create_nonce( 'wp_rest' ),
|
421 |
+
'banner_enabled' => $this->banner_checkout_enabled(),
|
422 |
+
'currency' => get_woocommerce_currency(),
|
423 |
+
'total_label' => __( 'Total', 'woo-stripe-payment' ),
|
424 |
+
'country_code' => wc_get_base_location()['country'],
|
425 |
+
'user_id' => get_current_user_id()
|
426 |
);
|
427 |
}
|
428 |
|
883 |
/**
|
884 |
* Returns a formatted array of items for display in the payment gateway's payment sheet.
|
885 |
*
|
886 |
+
* @param stirng $page
|
887 |
*
|
888 |
* @return []
|
889 |
*/
|
890 |
+
public function get_display_items( $page = 'checkout', $order = null ) {
|
891 |
+
return wc_stripe_get_display_items( $page, $order );
|
892 |
}
|
893 |
|
894 |
/**
|
899 |
*
|
900 |
* @return []
|
901 |
*/
|
902 |
+
public function get_shipping_methods() {
|
903 |
+
return wc_stripe_get_shipping_options();
|
904 |
}
|
905 |
|
906 |
/**
|
921 |
return in_array( 'cart', $this->get_option( 'payment_sections', array() ) );
|
922 |
}
|
923 |
|
924 |
+
/**
|
925 |
+
* Return true if mini-cart checkout is enabled for this gateway
|
926 |
+
*
|
927 |
+
* @return bool
|
928 |
+
* @since 3.1.8
|
929 |
+
*/
|
930 |
+
public function mini_cart_enabled() {
|
931 |
+
return in_array( 'mini_cart', $this->get_option( 'payment_sections', array() ) );
|
932 |
+
}
|
933 |
+
|
934 |
/**
|
935 |
* Return true if checkout page banner is enabled for this gateway
|
936 |
*
|
1022 |
* @return null|WC_Payment_Token_Stripe_CC
|
1023 |
*/
|
1024 |
public function get_token( $token_id, $user_id ) {
|
1025 |
+
$tokens = WC_Payment_Tokens::get_tokens( array( 'user_id' => $user_id, 'gateway_id' => $this->id, 'limit' => 20 ) );
|
1026 |
foreach ( $tokens as $token ) {
|
1027 |
if ( $token_id === $token->get_token() ) {
|
1028 |
return $token;
|
1121 |
|
1122 |
// update the meta data needed by the gateway to process a subscription payment.
|
1123 |
$subscription->update_meta_data( WC_Stripe_Constants::PAYMENT_METHOD_TOKEN, $this->payment_method_token );
|
1124 |
+
if ( $token ) {
|
1125 |
+
$subscription->set_payment_method_title( $token->get_payment_method_title() );
|
1126 |
+
}
|
1127 |
$subscription->save();
|
1128 |
}
|
1129 |
|
1418 |
private function get_payment_section_description() {
|
1419 |
return sprintf( __( 'Increase your conversion rate by offering %1$s on your Product and Cart pages, or at the top of the checkout page. <br/><strong>Note:</strong> you can control which products display %s by going to the product edit page.', 'woo-stripe-payment' ), $this->get_method_title() );
|
1420 |
}
|
1421 |
+
|
1422 |
+
/**
|
1423 |
+
* Outputs fields required by Google Pay to render the payment wallet.
|
1424 |
+
*/
|
1425 |
+
public function output_display_items( $page = 'checkout' ) {
|
1426 |
+
global $wp;
|
1427 |
+
$order = null;
|
1428 |
+
$data = array(
|
1429 |
+
'items' => $this->get_display_items( $page ),
|
1430 |
+
'shipping_options' => $this->get_shipping_methods(),
|
1431 |
+
'total' => WC()->cart->total,
|
1432 |
+
'total_cents' => wc_stripe_add_number_precision( WC()->cart->total, get_woocommerce_currency() ),
|
1433 |
+
'currency' => get_woocommerce_currency()
|
1434 |
+
);
|
1435 |
+
if ( ! empty( $wp->query_vars['order-pay'] ) ) {
|
1436 |
+
$order = wc_get_order( absint( $wp->query_vars['order-pay'] ) );
|
1437 |
+
$page = 'order_pay';
|
1438 |
+
$data['needs_shipping'] = false;
|
1439 |
+
$data['items'] = $this->get_display_items( $page, $order );
|
1440 |
+
$data['total'] = $order->get_total();
|
1441 |
+
$data['total_cents'] = wc_stripe_add_number_precision( $order->get_total(), $order->get_currency() );
|
1442 |
+
$data['currency'] = $order->get_currency();
|
1443 |
+
} elseif ( 'product' === $page ) {
|
1444 |
+
global $product;
|
1445 |
+
$data['needs_shipping'] = $product->needs_shipping();
|
1446 |
+
$data['product'] = array(
|
1447 |
+
'id' => $product->get_id(),
|
1448 |
+
'price' => $product->get_price(),
|
1449 |
+
'variation' => false
|
1450 |
+
);
|
1451 |
+
} elseif ( in_array( $page, array( 'checkout', 'cart' ) ) ) {
|
1452 |
+
$data['needs_shipping'] = WC()->cart->needs_shipping();
|
1453 |
+
}
|
1454 |
+
/**
|
1455 |
+
* @param array $data
|
1456 |
+
* @param string $page
|
1457 |
+
* @param WC_Payment_Gateway_Stripe $this
|
1458 |
+
*
|
1459 |
+
* @since 3.1.8
|
1460 |
+
*/
|
1461 |
+
$data = apply_filters( 'wc_stripe_output_display_items', $data, $page, $this );
|
1462 |
+
printf( '<input type="hidden" id="%1$s" data-gateway="%2$s"/>', "{$this->id}_{$page}_data", htmlspecialchars( wp_json_encode( $data ) ) );
|
1463 |
+
}
|
1464 |
+
|
1465 |
+
/**
|
1466 |
+
* @param array $deps
|
1467 |
+
* @param $scripts
|
1468 |
+
*
|
1469 |
+
* @since 3.1.8
|
1470 |
+
*/
|
1471 |
+
public function get_mini_cart_dependencies( $deps, $scripts ) {
|
1472 |
+
return $deps;
|
1473 |
+
}
|
1474 |
}
|
includes/class-stripe.php
CHANGED
@@ -25,7 +25,7 @@ class WC_Stripe_Manager {
|
|
25 |
*
|
26 |
* @var string
|
27 |
*/
|
28 |
-
public $version = '3.1.
|
29 |
|
30 |
/**
|
31 |
*
|
@@ -151,7 +151,7 @@ class WC_Stripe_Manager {
|
|
151 |
|
152 |
// traits
|
153 |
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/traits/wc-stripe-settings-trait.php';
|
154 |
-
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/traits/wc-stripe-controller-
|
155 |
|
156 |
// load factories
|
157 |
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/class-wc-stripe-payment-factory.php';
|
@@ -177,6 +177,7 @@ class WC_Stripe_Manager {
|
|
177 |
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/gateways/class-wc-payment-gateway-stripe-fpx.php';
|
178 |
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/gateways/class-wc-payment-gateway-stripe-alipay.php';
|
179 |
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/gateways/class-wc-payment-gateway-stripe-becs.php';
|
|
|
180 |
|
181 |
// tokens
|
182 |
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/abstract/abstract-wc-payment-token-stripe.php';
|
@@ -228,6 +229,7 @@ class WC_Stripe_Manager {
|
|
228 |
'WC_Payment_Gateway_Stripe_FPX',
|
229 |
'WC_Payment_Gateway_Stripe_BECS',
|
230 |
'WC_Payment_Gateway_Stripe_Alipay',
|
|
|
231 |
)
|
232 |
);
|
233 |
|
25 |
*
|
26 |
* @var string
|
27 |
*/
|
28 |
+
public $version = '3.1.8';
|
29 |
|
30 |
/**
|
31 |
*
|
151 |
|
152 |
// traits
|
153 |
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/traits/wc-stripe-settings-trait.php';
|
154 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/traits/wc-stripe-controller-traits.php';
|
155 |
|
156 |
// load factories
|
157 |
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/class-wc-stripe-payment-factory.php';
|
177 |
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/gateways/class-wc-payment-gateway-stripe-fpx.php';
|
178 |
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/gateways/class-wc-payment-gateway-stripe-alipay.php';
|
179 |
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/gateways/class-wc-payment-gateway-stripe-becs.php';
|
180 |
+
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/gateways/class-wc-payment-gateway-stripe-grabpay.php';
|
181 |
|
182 |
// tokens
|
183 |
include_once WC_STRIPE_PLUGIN_FILE_PATH . 'includes/abstract/abstract-wc-payment-token-stripe.php';
|
229 |
'WC_Payment_Gateway_Stripe_FPX',
|
230 |
'WC_Payment_Gateway_Stripe_BECS',
|
231 |
'WC_Payment_Gateway_Stripe_Alipay',
|
232 |
+
//'WC_Payment_Gateway_Stripe_GrabPay'
|
233 |
)
|
234 |
);
|
235 |
|
includes/class-wc-stripe-field-manager.php
CHANGED
@@ -22,8 +22,7 @@ class WC_Stripe_Field_Manager {
|
|
22 |
add_action( 'init', array( __CLASS__, 'init_action' ) );
|
23 |
add_action( 'woocommerce_review_order_after_order_total', array( __CLASS__, 'output_checkout_fields' ) );
|
24 |
add_action( 'before_woocommerce_add_payment_method', array( __CLASS__, 'add_payment_method_fields' ) );
|
25 |
-
add_action( '
|
26 |
-
add_action( 'woocommerce_pay_order_after_submit', array( __CLASS__, 'pay_order_fields' ) );
|
27 |
}
|
28 |
|
29 |
public static function init_action() {
|
@@ -44,17 +43,6 @@ class WC_Stripe_Field_Manager {
|
|
44 |
}
|
45 |
|
46 |
public static function output_checkout_fields() {
|
47 |
-
self::output_required_fields( 'checkout' );
|
48 |
-
|
49 |
-
wp_localize_script(
|
50 |
-
'wc-checkout',
|
51 |
-
'wc_stripe_checkout_fields',
|
52 |
-
array(
|
53 |
-
'billing' => WC()->checkout()->get_checkout_fields( 'billing' ),
|
54 |
-
'shipping' => WC()->checkout()->get_checkout_fields( 'shipping' ),
|
55 |
-
)
|
56 |
-
);
|
57 |
-
|
58 |
do_action( 'wc_stripe_output_checkout_fields' );
|
59 |
}
|
60 |
|
@@ -98,9 +86,6 @@ class WC_Stripe_Field_Manager {
|
|
98 |
ksort( $gateways );
|
99 |
|
100 |
if ( count( $gateways ) > 0 ) {
|
101 |
-
|
102 |
-
self::output_required_fields( 'product' );
|
103 |
-
|
104 |
wc_stripe_get_template(
|
105 |
'product/payment-methods.php',
|
106 |
array(
|
@@ -125,8 +110,6 @@ class WC_Stripe_Field_Manager {
|
|
125 |
if ( ! empty( $gateways ) ) {
|
126 |
echo '<form id="wc-stripe-cart-form">';
|
127 |
|
128 |
-
self::output_required_fields( 'cart' );
|
129 |
-
|
130 |
wc_stripe_get_template(
|
131 |
'cart/payment-methods.php',
|
132 |
array(
|
@@ -139,18 +122,43 @@ class WC_Stripe_Field_Manager {
|
|
139 |
}
|
140 |
}
|
141 |
|
142 |
-
public static function
|
143 |
-
|
144 |
-
|
145 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
}
|
147 |
}
|
148 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
public static function add_payment_method_fields() {
|
150 |
wc_stripe_hidden_field( 'billing_first_name', '', WC()->customer->get_first_name() );
|
151 |
wc_stripe_hidden_field( 'billing_last_name', '', WC()->customer->get_last_name() );
|
152 |
}
|
153 |
|
|
|
|
|
|
|
154 |
public static function pay_order_fields() {
|
155 |
global $wp;
|
156 |
$order = wc_get_order( absint( $wp->query_vars['order-pay'] ) );
|
@@ -162,21 +170,13 @@ class WC_Stripe_Field_Manager {
|
|
162 |
* @param WC_Order $order
|
163 |
*/
|
164 |
public static function output_required_fields( $page, $order = null ) {
|
165 |
-
printf( '<input type="hidden" id="%1$s" value="%2$s"/>', 'wc_stripe_currency', $order ? $order->get_currency() : get_woocommerce_currency() );
|
166 |
-
printf( '<input type="hidden" id="%1$s" data-amount="%2$s"/>', 'wc_stripe_order_total', $order ? $order->get_total() : WC()->cart->total );
|
167 |
if ( in_array( $page, array( 'cart', 'checkout' ) ) ) {
|
168 |
-
printf( '<input type="hidden" id="wc_stripe_display_items" data-items="%s"/>', wc_stripe_get_display_items( true, $order ) );
|
169 |
-
printf( '<input type="hidden" id="wc_stripe_shipping_options" data-items="%s"/>', wc_stripe_get_shipping_options( true, $order ) );
|
170 |
-
printf( '<input type="hidden" id="wc_stripe_order_total_cents" data-amount="%s"/>', wc_stripe_add_number_precision( ( $order ? $order->get_total() : WC()->cart->total ), ( $order ? $order->get_currency() : '' ) ) );
|
171 |
|
172 |
if ( 'cart' === $page ) {
|
173 |
self::output_fields( 'billing' );
|
174 |
|
175 |
if ( WC()->cart->needs_shipping() ) {
|
176 |
-
self::output_needs_shipping( true );
|
177 |
self::output_fields( 'shipping' );
|
178 |
-
} else {
|
179 |
-
self::output_needs_shipping( false );
|
180 |
}
|
181 |
}
|
182 |
|
@@ -188,36 +188,6 @@ class WC_Stripe_Field_Manager {
|
|
188 |
if ( $product->needs_shipping() ) {
|
189 |
self::output_fields( 'shipping' );
|
190 |
}
|
191 |
-
printf( '<input type="hidden" id="product_id" name="product_id", value="%s"/>', $product->get_id() );
|
192 |
-
printf(
|
193 |
-
'<input type="hidden" id="wc_stripe_product_data" data-product="%s"/>',
|
194 |
-
htmlspecialchars(
|
195 |
-
wp_json_encode(
|
196 |
-
array(
|
197 |
-
'product_id' => $product->get_id(),
|
198 |
-
'price' => $product->get_price(),
|
199 |
-
'needs_shipping' => $product->needs_shipping(),
|
200 |
-
)
|
201 |
-
)
|
202 |
-
)
|
203 |
-
);
|
204 |
-
printf(
|
205 |
-
'<input type="hidden" id="wc_stripe_display_items" data-items="%s"/>',
|
206 |
-
htmlspecialchars(
|
207 |
-
wp_json_encode(
|
208 |
-
array(
|
209 |
-
array(
|
210 |
-
'amount' => wc_stripe_add_number_precision( $product->get_price() ),
|
211 |
-
'label' => esc_attr( $product->get_name() ),
|
212 |
-
'pending' => true,
|
213 |
-
),
|
214 |
-
)
|
215 |
-
)
|
216 |
-
)
|
217 |
-
);
|
218 |
-
printf( '<input type="hidden" id="wc_stripe_shipping_options" data-items="%s"/>', htmlspecialchars( wp_json_encode( array() ) ) );
|
219 |
-
printf( '<input type="hidden" id="wc_stripe_order_total_cents" data-amount="%s"/>', wc_stripe_add_number_precision( $product->get_price() ) );
|
220 |
-
|
221 |
}
|
222 |
}
|
223 |
|
@@ -228,28 +198,13 @@ class WC_Stripe_Field_Manager {
|
|
228 |
}
|
229 |
}
|
230 |
|
231 |
-
public static function output_needs_shipping( $needs_shipping ) {
|
232 |
-
printf( '<input type="hidden" id="wc_stripe_needs_shipping" data-value="%s" />', $needs_shipping );
|
233 |
-
}
|
234 |
-
|
235 |
/**
|
236 |
-
*
|
237 |
-
* @param array $args
|
238 |
*
|
239 |
* @deprecated
|
240 |
-
*
|
241 |
*/
|
242 |
-
public static function
|
243 |
-
if ( is_product() ) {
|
244 |
-
foreach ( WC()->payment_gateways()->get_available_payment_gateways() as $id => $gateway ) {
|
245 |
-
if ( $gateway->supports( 'wc_stripe_product_checkout' ) ) {
|
246 |
-
$args['min_value'] = 0;
|
247 |
-
break;
|
248 |
-
}
|
249 |
-
}
|
250 |
-
}
|
251 |
|
252 |
-
return $args;
|
253 |
}
|
254 |
}
|
255 |
|
22 |
add_action( 'init', array( __CLASS__, 'init_action' ) );
|
23 |
add_action( 'woocommerce_review_order_after_order_total', array( __CLASS__, 'output_checkout_fields' ) );
|
24 |
add_action( 'before_woocommerce_add_payment_method', array( __CLASS__, 'add_payment_method_fields' ) );
|
25 |
+
add_action( 'woocommerce_widget_shopping_cart_buttons', array( __CLASS__, 'mini_cart_buttons' ), 5 );
|
|
|
26 |
}
|
27 |
|
28 |
public static function init_action() {
|
43 |
}
|
44 |
|
45 |
public static function output_checkout_fields() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
do_action( 'wc_stripe_output_checkout_fields' );
|
47 |
}
|
48 |
|
86 |
ksort( $gateways );
|
87 |
|
88 |
if ( count( $gateways ) > 0 ) {
|
|
|
|
|
|
|
89 |
wc_stripe_get_template(
|
90 |
'product/payment-methods.php',
|
91 |
array(
|
110 |
if ( ! empty( $gateways ) ) {
|
111 |
echo '<form id="wc-stripe-cart-form">';
|
112 |
|
|
|
|
|
113 |
wc_stripe_get_template(
|
114 |
'cart/payment-methods.php',
|
115 |
array(
|
122 |
}
|
123 |
}
|
124 |
|
125 |
+
public static function mini_cart_buttons() {
|
126 |
+
$gateways = array();
|
127 |
+
foreach ( WC()->payment_gateways()->get_available_payment_gateways() as $id => $gateway ) {
|
128 |
+
/**
|
129 |
+
*
|
130 |
+
* @var WC_Payment_Gateway_Stripe $gateway
|
131 |
+
*/
|
132 |
+
if ( $gateway->supports( 'wc_stripe_mini_cart_checkout' ) && $gateway->mini_cart_enabled() ) {
|
133 |
+
$gateways[ $gateway->id ] = $gateway;
|
134 |
+
}
|
135 |
+
}
|
136 |
+
if ( ! empty( $gateways ) ) {
|
137 |
+
|
138 |
+
wc_stripe_get_template(
|
139 |
+
'mini-cart/payment-methods.php',
|
140 |
+
array(
|
141 |
+
'gateways' => $gateways
|
142 |
+
)
|
143 |
+
);
|
144 |
}
|
145 |
}
|
146 |
|
147 |
+
/**
|
148 |
+
* @deprecated 3.1.8
|
149 |
+
*/
|
150 |
+
public static function change_payment_request() {
|
151 |
+
|
152 |
+
}
|
153 |
+
|
154 |
public static function add_payment_method_fields() {
|
155 |
wc_stripe_hidden_field( 'billing_first_name', '', WC()->customer->get_first_name() );
|
156 |
wc_stripe_hidden_field( 'billing_last_name', '', WC()->customer->get_last_name() );
|
157 |
}
|
158 |
|
159 |
+
/**
|
160 |
+
* @deprecated 3.1.8
|
161 |
+
*/
|
162 |
public static function pay_order_fields() {
|
163 |
global $wp;
|
164 |
$order = wc_get_order( absint( $wp->query_vars['order-pay'] ) );
|
170 |
* @param WC_Order $order
|
171 |
*/
|
172 |
public static function output_required_fields( $page, $order = null ) {
|
|
|
|
|
173 |
if ( in_array( $page, array( 'cart', 'checkout' ) ) ) {
|
|
|
|
|
|
|
174 |
|
175 |
if ( 'cart' === $page ) {
|
176 |
self::output_fields( 'billing' );
|
177 |
|
178 |
if ( WC()->cart->needs_shipping() ) {
|
|
|
179 |
self::output_fields( 'shipping' );
|
|
|
|
|
180 |
}
|
181 |
}
|
182 |
|
188 |
if ( $product->needs_shipping() ) {
|
189 |
self::output_fields( 'shipping' );
|
190 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
191 |
}
|
192 |
}
|
193 |
|
198 |
}
|
199 |
}
|
200 |
|
|
|
|
|
|
|
|
|
201 |
/**
|
202 |
+
* @param bool $needs_shipping
|
|
|
203 |
*
|
204 |
* @deprecated
|
|
|
205 |
*/
|
206 |
+
public static function output_needs_shipping( $needs_shipping ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
207 |
|
|
|
208 |
}
|
209 |
}
|
210 |
|
includes/class-wc-stripe-frontend-scripts.php
CHANGED
@@ -70,6 +70,17 @@ class WC_Stripe_Frontend_Scripts {
|
|
70 |
);
|
71 |
|
72 |
$this->localize_script( 'wc-stripe', wc_stripe_get_error_messages(), 'wc_stripe_messages' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
}
|
74 |
|
75 |
public function enqueue_checkout_scripts() {
|
@@ -148,6 +159,7 @@ class WC_Stripe_Frontend_Scripts {
|
|
148 |
}
|
149 |
|
150 |
private function get_page_id() {
|
|
|
151 |
if ( is_product() ) {
|
152 |
return 'product';
|
153 |
}
|
@@ -155,6 +167,10 @@ class WC_Stripe_Frontend_Scripts {
|
|
155 |
return 'cart';
|
156 |
}
|
157 |
if ( is_checkout() ) {
|
|
|
|
|
|
|
|
|
158 |
return 'checkout';
|
159 |
}
|
160 |
if ( is_add_payment_method_page() ) {
|
70 |
);
|
71 |
|
72 |
$this->localize_script( 'wc-stripe', wc_stripe_get_error_messages(), 'wc_stripe_messages' );
|
73 |
+
|
74 |
+
$this->localize_script( 'wc-stripe', wc_stripe_get_checkout_fields(), 'wc_stripe_checkout_fields' );
|
75 |
+
|
76 |
+
// mini cart is not relevant on cart and checkout page.
|
77 |
+
if ( ! is_checkout() && ! is_cart() ) {
|
78 |
+
foreach ( WC()->payment_gateways()->payment_gateways() as $gateway ) {
|
79 |
+
if ( $gateway instanceof WC_Payment_Gateway_Stripe && $gateway->is_available() && $gateway->mini_cart_enabled() ) {
|
80 |
+
$gateway->enqueue_frontend_scripts( 'mini_cart' );
|
81 |
+
}
|
82 |
+
}
|
83 |
+
}
|
84 |
}
|
85 |
|
86 |
public function enqueue_checkout_scripts() {
|
159 |
}
|
160 |
|
161 |
private function get_page_id() {
|
162 |
+
global $wp;
|
163 |
if ( is_product() ) {
|
164 |
return 'product';
|
165 |
}
|
167 |
return 'cart';
|
168 |
}
|
169 |
if ( is_checkout() ) {
|
170 |
+
if ( ! empty( $wp->query_vars['order-pay'] ) ) {
|
171 |
+
return 'order_pay';
|
172 |
+
}
|
173 |
+
|
174 |
return 'checkout';
|
175 |
}
|
176 |
if ( is_add_payment_method_page() ) {
|
includes/class-wc-stripe-payment-intent.php
CHANGED
@@ -232,6 +232,11 @@ class WC_Stripe_Payment_Intent extends WC_Stripe_Payment {
|
|
232 |
|
233 |
$this->payment_method->add_stripe_order_args( $args, $order );
|
234 |
|
|
|
|
|
|
|
|
|
|
|
235 |
return apply_filters( 'wc_stripe_payment_intent_args', $args, $order, $this );
|
236 |
}
|
237 |
|
232 |
|
233 |
$this->payment_method->add_stripe_order_args( $args, $order );
|
234 |
|
235 |
+
/**
|
236 |
+
* @param array $args
|
237 |
+
* @param WC_Order $order
|
238 |
+
* @param WC_Stripe_Payment_Intent $this
|
239 |
+
*/
|
240 |
return apply_filters( 'wc_stripe_payment_intent_args', $args, $order, $this );
|
241 |
}
|
242 |
|
includes/class-wc-stripe-redirect-handler.php
CHANGED
@@ -47,7 +47,11 @@ class WC_Stripe_Redirect_Handler {
|
|
47 |
$payment_method = WC()->payment_gateways()->payment_gateways()[ $order->get_payment_method() ];
|
48 |
$redirect = $order->get_checkout_order_received_url();
|
49 |
|
50 |
-
if (
|
|
|
|
|
|
|
|
|
51 |
wc_add_notice( __( 'Payment authorization failed. Please select another payment method.', 'woo-stripe-payment' ), 'error' );
|
52 |
if ( $result instanceof \Stripe\PaymentIntent ) {
|
53 |
$order->update_meta_data( WC_Stripe_Constants::PAYMENT_INTENT, $result->jsonSerialize() );
|
@@ -61,7 +65,6 @@ class WC_Stripe_Redirect_Handler {
|
|
61 |
if ( ! $payment_method->has_order_lock( $order ) && ! $order->get_transaction_id() ) {
|
62 |
$payment_method->set_order_lock( $order );
|
63 |
$payment_method->set_new_source_token( $result->id );
|
64 |
-
wc_stripe_log_info( 'processing from redirect handler.' );
|
65 |
$result = $payment_method->process_payment( $order_id );
|
66 |
// we don't release the order lock so there aren't conflicts with the source.chargeable webhook
|
67 |
if ( $result['result'] === 'success' ) {
|
47 |
$payment_method = WC()->payment_gateways()->payment_gateways()[ $order->get_payment_method() ];
|
48 |
$redirect = $order->get_checkout_order_received_url();
|
49 |
|
50 |
+
if ( in_array( $result->status, array( 'requires_action', 'pending' ) ) ) {
|
51 |
+
wc_add_notice( __( 'Payment for order was not completed.', 'woo-stripe-payment' ), 'error' );
|
52 |
+
|
53 |
+
return;
|
54 |
+
} elseif ( in_array( $result->status, array( 'requires_payment_method', 'failed' ) ) ) {
|
55 |
wc_add_notice( __( 'Payment authorization failed. Please select another payment method.', 'woo-stripe-payment' ), 'error' );
|
56 |
if ( $result instanceof \Stripe\PaymentIntent ) {
|
57 |
$order->update_meta_data( WC_Stripe_Constants::PAYMENT_INTENT, $result->jsonSerialize() );
|
65 |
if ( ! $payment_method->has_order_lock( $order ) && ! $order->get_transaction_id() ) {
|
66 |
$payment_method->set_order_lock( $order );
|
67 |
$payment_method->set_new_source_token( $result->id );
|
|
|
68 |
$result = $payment_method->process_payment( $order_id );
|
69 |
// we don't release the order lock so there aren't conflicts with the source.chargeable webhook
|
70 |
if ( $result['result'] === 'success' ) {
|
includes/class-wc-stripe-rest-api.php
CHANGED
@@ -27,10 +27,6 @@ class WC_Stripe_Rest_API {
|
|
27 |
add_action( 'rest_api_init', array( $this, 'register_routes' ) );
|
28 |
}
|
29 |
|
30 |
-
public static function init() {
|
31 |
-
add_filter( 'woocommerce_is_rest_api_request', array( __CLASS__, 'is_rest_api_request' ) );
|
32 |
-
}
|
33 |
-
|
34 |
/**
|
35 |
*
|
36 |
* @param WC_Stripe_Rest_Controller $key
|
@@ -68,10 +64,11 @@ class WC_Stripe_Rest_API {
|
|
68 |
}
|
69 |
|
70 |
public function register_routes() {
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
|
|
75 |
}
|
76 |
}
|
77 |
}
|
@@ -89,29 +86,38 @@ class WC_Stripe_Rest_API {
|
|
89 |
'product_data' => 'WC_Stripe_Controller_Product_Data',
|
90 |
);
|
91 |
|
|
|
|
|
|
|
92 |
return apply_filters( 'wc_stripe_api_controllers', $controllers );
|
93 |
}
|
94 |
|
|
|
|
|
|
|
95 |
public function rest_url() {
|
96 |
return wc_stripe()->rest_url();
|
97 |
}
|
98 |
|
|
|
|
|
|
|
99 |
public function rest_uri() {
|
100 |
return wc_stripe()->rest_uri();
|
101 |
}
|
102 |
|
103 |
/**
|
104 |
-
*
|
105 |
-
*
|
106 |
-
* @param bool $bool
|
107 |
*/
|
108 |
-
public static function is_rest_api_request(
|
|
|
|
|
|
|
|
|
109 |
if ( ! empty( $_SERVER['REQUEST_URI'] ) && strpos( $_SERVER['REQUEST_URI'], wc_stripe()->rest_uri() ) !== false ) {
|
110 |
-
|
111 |
}
|
112 |
|
113 |
-
return
|
114 |
}
|
115 |
}
|
116 |
-
|
117 |
-
WC_Stripe_Rest_API::init();
|
27 |
add_action( 'rest_api_init', array( $this, 'register_routes' ) );
|
28 |
}
|
29 |
|
|
|
|
|
|
|
|
|
30 |
/**
|
31 |
*
|
32 |
* @param WC_Stripe_Rest_Controller $key
|
64 |
}
|
65 |
|
66 |
public function register_routes() {
|
67 |
+
if ( self::is_rest_api_request() ) {
|
68 |
+
foreach ( $this->controllers as $key => $controller ) {
|
69 |
+
if ( is_callable( array( $controller, 'register_routes' ) ) ) {
|
70 |
+
$controller->register_routes();
|
71 |
+
}
|
72 |
}
|
73 |
}
|
74 |
}
|
86 |
'product_data' => 'WC_Stripe_Controller_Product_Data',
|
87 |
);
|
88 |
|
89 |
+
/**
|
90 |
+
* @param string[] $controllers
|
91 |
+
*/
|
92 |
return apply_filters( 'wc_stripe_api_controllers', $controllers );
|
93 |
}
|
94 |
|
95 |
+
/**
|
96 |
+
* @return string
|
97 |
+
*/
|
98 |
public function rest_url() {
|
99 |
return wc_stripe()->rest_url();
|
100 |
}
|
101 |
|
102 |
+
/**
|
103 |
+
* @return string
|
104 |
+
*/
|
105 |
public function rest_uri() {
|
106 |
return wc_stripe()->rest_uri();
|
107 |
}
|
108 |
|
109 |
/**
|
110 |
+
* @return bool
|
|
|
|
|
111 |
*/
|
112 |
+
public static function is_rest_api_request() {
|
113 |
+
global $wp;
|
114 |
+
if ( ! empty( $wp->query_vars['rest_route'] ) && strpos( $wp->query_vars['rest_route'], wc_stripe()->rest_uri() ) !== false ) {
|
115 |
+
return true;
|
116 |
+
}
|
117 |
if ( ! empty( $_SERVER['REQUEST_URI'] ) && strpos( $_SERVER['REQUEST_URI'], wc_stripe()->rest_uri() ) !== false ) {
|
118 |
+
return true;
|
119 |
}
|
120 |
|
121 |
+
return false;
|
122 |
}
|
123 |
}
|
|
|
|
includes/controllers/class-wc-stripe-controller-cart.php
CHANGED
@@ -11,6 +11,7 @@ defined( 'ABSPATH' ) || exit();
|
|
11 |
class WC_Stripe_Controller_Cart extends WC_Stripe_Rest_Controller {
|
12 |
|
13 |
use WC_Stripe_Controller_Cart_Trait;
|
|
|
14 |
|
15 |
protected $namespace = 'cart';
|
16 |
|
@@ -22,8 +23,8 @@ class WC_Stripe_Controller_Cart extends WC_Stripe_Rest_Controller {
|
|
22 |
'methods' => WP_REST_Server::CREATABLE,
|
23 |
'callback' => array( $this, 'update_shipping_method' ),
|
24 |
'args' => array(
|
25 |
-
'
|
26 |
-
'payment_method'
|
27 |
),
|
28 |
)
|
29 |
);
|
@@ -86,6 +87,7 @@ class WC_Stripe_Controller_Cart extends WC_Stripe_Rest_Controller {
|
|
86 |
if ( $qty == 0 ) {
|
87 |
return $this->add_validation_error( new WP_Error( 'cart-error', __( 'Quantity must be greater than zero.', 'woo-stripe-payment' ) ) );
|
88 |
}
|
|
|
89 |
return true;
|
90 |
}
|
91 |
|
@@ -95,16 +97,18 @@ class WC_Stripe_Controller_Cart extends WC_Stripe_Rest_Controller {
|
|
95 |
* @param WP_REST_Request $request
|
96 |
*/
|
97 |
public function update_shipping_method( $request ) {
|
|
|
98 |
wc_maybe_define_constant( 'WOOCOMMERCE_CART', true );
|
99 |
-
|
100 |
-
|
|
|
101 |
/**
|
102 |
*
|
103 |
* @var WC_Payment_Gateway_Stripe $gateway
|
104 |
*/
|
105 |
$gateway = WC()->payment_gateways()->payment_gateways()[ $payment_method ];
|
106 |
|
107 |
-
wc_stripe_update_shipping_methods( $
|
108 |
|
109 |
$this->add_ready_to_calc_shipping();
|
110 |
|
@@ -143,6 +147,7 @@ class WC_Stripe_Controller_Cart extends WC_Stripe_Rest_Controller {
|
|
143 |
if ( 'product' == $request->get_param( 'page_id' ) ) {
|
144 |
wc_stripe_restore_cart( WC()->cart );
|
145 |
}
|
|
|
146 |
return $response;
|
147 |
}
|
148 |
|
@@ -151,7 +156,10 @@ class WC_Stripe_Controller_Cart extends WC_Stripe_Rest_Controller {
|
|
151 |
* @param WP_REST_Request $request
|
152 |
*/
|
153 |
public function update_shipping_address( $request ) {
|
|
|
154 |
wc_maybe_define_constant( 'WOOCOMMERCE_CART', true );
|
|
|
|
|
155 |
$address = $request->get_param( 'address' );
|
156 |
$payment_method = $request->get_param( 'payment_method' );
|
157 |
/**
|
@@ -208,16 +216,22 @@ class WC_Stripe_Controller_Cart extends WC_Stripe_Rest_Controller {
|
|
208 |
if ( 'product' == $request->get_param( 'page_id' ) ) {
|
209 |
wc_stripe_restore_cart( WC()->cart );
|
210 |
}
|
|
|
211 |
return $response;
|
212 |
}
|
213 |
|
214 |
/**
|
215 |
*
|
216 |
* @param WP_REST_Request $request
|
|
|
|
|
217 |
*/
|
218 |
public function add_to_cart( $request ) {
|
|
|
219 |
// WC 3.0.0 requires WOOCOMMERCE_CART to be defined.
|
220 |
wc_maybe_define_constant( 'WOOCOMMERCE_CART', true );
|
|
|
|
|
221 |
$payment_method = $request->get_param( 'payment_method' );
|
222 |
/**
|
223 |
*
|
@@ -235,20 +249,17 @@ class WC_Stripe_Controller_Cart extends WC_Stripe_Rest_Controller {
|
|
235 |
if ( WC()->cart->add_to_cart( $product_id, $qty, $variation_id ) == false ) {
|
236 |
return new WP_Error( 'cart-error', $this->get_error_messages(), array( 'status' => 200 ) );
|
237 |
} else {
|
238 |
-
// add to cart was successful. Send a new X-WP-Nonce since it will be different now that a WC session
|
239 |
-
// exists.
|
240 |
-
rest_get_server()->send_header( 'X-WP-Nonce', wp_create_nonce( 'wp_rest' ) );
|
241 |
$response = rest_ensure_response(
|
242 |
apply_filters(
|
243 |
'wc_stripe_add_to_cart_response',
|
244 |
array(
|
245 |
'data' => $gateway->add_to_cart_response(
|
246 |
array(
|
247 |
-
'total' => WC()->cart->total,
|
248 |
-
'subtotal' => WC()->cart->subtotal,
|
249 |
'totalCents' => wc_stripe_add_number_precision( WC()->cart->total ),
|
250 |
-
'displayItems' =>
|
251 |
-
'shippingOptions' =>
|
252 |
)
|
253 |
),
|
254 |
),
|
@@ -260,6 +271,7 @@ class WC_Stripe_Controller_Cart extends WC_Stripe_Rest_Controller {
|
|
260 |
wc_stripe_stash_product_cart( WC()->cart );
|
261 |
// put cart contents back to how they were before.
|
262 |
wc_stripe_restore_cart( WC()->cart );
|
|
|
263 |
return $response;
|
264 |
}
|
265 |
}
|
@@ -270,8 +282,11 @@ class WC_Stripe_Controller_Cart extends WC_Stripe_Rest_Controller {
|
|
270 |
* @param WP_REST_Request $request
|
271 |
*/
|
272 |
public function cart_calculation( $request ) {
|
|
|
273 |
// WC 3.0.0 requires WOOCOMMERCE_CART to be defined.
|
274 |
wc_maybe_define_constant( 'WOOCOMMERCE_CART', true );
|
|
|
|
|
275 |
$product_id = $request->get_param( 'product_id' );
|
276 |
$qty = $request->get_param( 'qty' );
|
277 |
$variation_id = $request->get_param( 'variation_id' ) == null ? 0 : $request->get_param( 'variation_id' );
|
@@ -291,11 +306,11 @@ class WC_Stripe_Controller_Cart extends WC_Stripe_Rest_Controller {
|
|
291 |
array(
|
292 |
'data' => $gateway->add_to_cart_response(
|
293 |
array(
|
294 |
-
'total' => WC()->cart->total,
|
295 |
-
'subtotal' => WC()->cart->subtotal,
|
296 |
'totalCents' => wc_stripe_add_number_precision( WC()->cart->total ),
|
297 |
-
'displayItems' =>
|
298 |
-
'shippingOptions' =>
|
299 |
)
|
300 |
),
|
301 |
),
|
@@ -309,8 +324,7 @@ class WC_Stripe_Controller_Cart extends WC_Stripe_Rest_Controller {
|
|
309 |
wc_stripe_stash_product_cart( WC()->cart );
|
310 |
wc_stripe_restore_cart( WC()->cart );
|
311 |
wc_clear_notices();
|
312 |
-
|
313 |
-
rest_get_server()->send_header( 'X-WP-Nonce', wp_create_nonce( 'wp_rest' ) );
|
314 |
return $response;
|
315 |
}
|
316 |
|
@@ -353,6 +367,7 @@ class WC_Stripe_Controller_Cart extends WC_Stripe_Rest_Controller {
|
|
353 |
return true;
|
354 |
}
|
355 |
}
|
|
|
356 |
return false;
|
357 |
}
|
358 |
}
|
11 |
class WC_Stripe_Controller_Cart extends WC_Stripe_Rest_Controller {
|
12 |
|
13 |
use WC_Stripe_Controller_Cart_Trait;
|
14 |
+
use WC_Stripe_Controller_Frontend_Trait;
|
15 |
|
16 |
protected $namespace = 'cart';
|
17 |
|
23 |
'methods' => WP_REST_Server::CREATABLE,
|
24 |
'callback' => array( $this, 'update_shipping_method' ),
|
25 |
'args' => array(
|
26 |
+
'shipping_method' => array( 'required' => true ),
|
27 |
+
'payment_method' => array( 'required' => true ),
|
28 |
),
|
29 |
)
|
30 |
);
|
87 |
if ( $qty == 0 ) {
|
88 |
return $this->add_validation_error( new WP_Error( 'cart-error', __( 'Quantity must be greater than zero.', 'woo-stripe-payment' ) ) );
|
89 |
}
|
90 |
+
|
91 |
return true;
|
92 |
}
|
93 |
|
97 |
* @param WP_REST_Request $request
|
98 |
*/
|
99 |
public function update_shipping_method( $request ) {
|
100 |
+
$this->cart_includes();
|
101 |
wc_maybe_define_constant( 'WOOCOMMERCE_CART', true );
|
102 |
+
wc_maybe_define_constant( 'DOING_AJAX', true );
|
103 |
+
|
104 |
+
$payment_method = $request->get_param( 'payment_method' );
|
105 |
/**
|
106 |
*
|
107 |
* @var WC_Payment_Gateway_Stripe $gateway
|
108 |
*/
|
109 |
$gateway = WC()->payment_gateways()->payment_gateways()[ $payment_method ];
|
110 |
|
111 |
+
wc_stripe_update_shipping_methods( $this->get_shipping_method_from_request( $request ) );
|
112 |
|
113 |
$this->add_ready_to_calc_shipping();
|
114 |
|
147 |
if ( 'product' == $request->get_param( 'page_id' ) ) {
|
148 |
wc_stripe_restore_cart( WC()->cart );
|
149 |
}
|
150 |
+
|
151 |
return $response;
|
152 |
}
|
153 |
|
156 |
* @param WP_REST_Request $request
|
157 |
*/
|
158 |
public function update_shipping_address( $request ) {
|
159 |
+
$this->cart_includes();
|
160 |
wc_maybe_define_constant( 'WOOCOMMERCE_CART', true );
|
161 |
+
wc_maybe_define_constant( 'DOING_AJAX', true );
|
162 |
+
|
163 |
$address = $request->get_param( 'address' );
|
164 |
$payment_method = $request->get_param( 'payment_method' );
|
165 |
/**
|
216 |
if ( 'product' == $request->get_param( 'page_id' ) ) {
|
217 |
wc_stripe_restore_cart( WC()->cart );
|
218 |
}
|
219 |
+
|
220 |
return $response;
|
221 |
}
|
222 |
|
223 |
/**
|
224 |
*
|
225 |
* @param WP_REST_Request $request
|
226 |
+
*
|
227 |
+
* @return WP_REST_Response
|
228 |
*/
|
229 |
public function add_to_cart( $request ) {
|
230 |
+
$this->cart_includes();
|
231 |
// WC 3.0.0 requires WOOCOMMERCE_CART to be defined.
|
232 |
wc_maybe_define_constant( 'WOOCOMMERCE_CART', true );
|
233 |
+
wc_maybe_define_constant( 'DOING_AJAX', true );
|
234 |
+
|
235 |
$payment_method = $request->get_param( 'payment_method' );
|
236 |
/**
|
237 |
*
|
249 |
if ( WC()->cart->add_to_cart( $product_id, $qty, $variation_id ) == false ) {
|
250 |
return new WP_Error( 'cart-error', $this->get_error_messages(), array( 'status' => 200 ) );
|
251 |
} else {
|
|
|
|
|
|
|
252 |
$response = rest_ensure_response(
|
253 |
apply_filters(
|
254 |
'wc_stripe_add_to_cart_response',
|
255 |
array(
|
256 |
'data' => $gateway->add_to_cart_response(
|
257 |
array(
|
258 |
+
'total' => round( WC()->cart->total, 2 ),
|
259 |
+
'subtotal' => round( WC()->cart->subtotal, 2 ),
|
260 |
'totalCents' => wc_stripe_add_number_precision( WC()->cart->total ),
|
261 |
+
'displayItems' => $gateway->get_display_items( 'cart' ),
|
262 |
+
'shippingOptions' => $gateway->get_shipping_methods(),
|
263 |
)
|
264 |
),
|
265 |
),
|
271 |
wc_stripe_stash_product_cart( WC()->cart );
|
272 |
// put cart contents back to how they were before.
|
273 |
wc_stripe_restore_cart( WC()->cart );
|
274 |
+
|
275 |
return $response;
|
276 |
}
|
277 |
}
|
282 |
* @param WP_REST_Request $request
|
283 |
*/
|
284 |
public function cart_calculation( $request ) {
|
285 |
+
$this->cart_includes();
|
286 |
// WC 3.0.0 requires WOOCOMMERCE_CART to be defined.
|
287 |
wc_maybe_define_constant( 'WOOCOMMERCE_CART', true );
|
288 |
+
wc_maybe_define_constant( 'DOING_AJAX', true );
|
289 |
+
|
290 |
$product_id = $request->get_param( 'product_id' );
|
291 |
$qty = $request->get_param( 'qty' );
|
292 |
$variation_id = $request->get_param( 'variation_id' ) == null ? 0 : $request->get_param( 'variation_id' );
|
306 |
array(
|
307 |
'data' => $gateway->add_to_cart_response(
|
308 |
array(
|
309 |
+
'total' => round( WC()->cart->total, 2 ),
|
310 |
+
'subtotal' => round( WC()->cart->subtotal, 2 ),
|
311 |
'totalCents' => wc_stripe_add_number_precision( WC()->cart->total ),
|
312 |
+
'displayItems' => $gateway->get_display_items( 'cart' ),
|
313 |
+
'shippingOptions' => $gateway->get_shipping_methods(),
|
314 |
)
|
315 |
),
|
316 |
),
|
324 |
wc_stripe_stash_product_cart( WC()->cart );
|
325 |
wc_stripe_restore_cart( WC()->cart );
|
326 |
wc_clear_notices();
|
327 |
+
|
|
|
328 |
return $response;
|
329 |
}
|
330 |
|
367 |
return true;
|
368 |
}
|
369 |
}
|
370 |
+
|
371 |
return false;
|
372 |
}
|
373 |
}
|
includes/controllers/class-wc-stripe-controller-checkout.php
CHANGED
@@ -13,6 +13,8 @@ if ( ! class_exists( 'WC_Stripe_Rest_Controller' ) ) {
|
|
13 |
*/
|
14 |
class WC_Stripe_Controller_Checkout extends WC_Stripe_Rest_Controller {
|
15 |
|
|
|
|
|
16 |
protected $namespace = '';
|
17 |
|
18 |
private $order_review = false;
|
@@ -64,6 +66,7 @@ class WC_Stripe_Controller_Checkout extends WC_Stripe_Rest_Controller {
|
|
64 |
* @return WP_REST_Response
|
65 |
*/
|
66 |
public function process_checkout( $request ) {
|
|
|
67 |
wc_maybe_define_constant( 'DOING_AJAX', true );
|
68 |
$this->actions();
|
69 |
$checkout = WC()->checkout();
|
@@ -74,10 +77,6 @@ class WC_Stripe_Controller_Checkout extends WC_Stripe_Rest_Controller {
|
|
74 |
*/
|
75 |
$this->gateway = $gateway = WC()->payment_gateways()->payment_gateways()[ $payment_method ];
|
76 |
|
77 |
-
$this->required_post_data();
|
78 |
-
|
79 |
-
$this->order_review = ! is_null( $request->get_param( 'order_review' ) ) && 'true' === $request->get_param( 'order_review' );
|
80 |
-
|
81 |
try {
|
82 |
do_action( 'wc_stripe_rest_process_checkout', $request, $gateway );
|
83 |
if ( ! is_user_logged_in() ) {
|
@@ -89,18 +88,14 @@ class WC_Stripe_Controller_Checkout extends WC_Stripe_Rest_Controller {
|
|
89 |
if ( 'product' == $request->get_param( 'page_id' ) ) {
|
90 |
wc_stripe_stash_cart( WC()->cart );
|
91 |
$gateway->set_post_payment_process( array( $this, 'post_payment_processes' ) );
|
92 |
-
add_filter(
|
93 |
-
'
|
94 |
-
|
95 |
-
return add_query_arg( 'wc_stripe_product_checkout', $order->get_payment_method(), $url );
|
96 |
-
},
|
97 |
-
10,
|
98 |
-
2
|
99 |
-
);
|
100 |
|
101 |
$option = new WC_Stripe_Product_Gateway_Option( current( WC()->cart->get_cart() )['data'], $gateway );
|
102 |
$gateway->settings['charge_type'] = $option->get_option( 'charge_type' );
|
103 |
}
|
|
|
104 |
$checkout->process_checkout();
|
105 |
} catch ( Exception $e ) {
|
106 |
wc_add_notice( $e->getMessage(), 'error' );
|
@@ -120,6 +115,8 @@ class WC_Stripe_Controller_Checkout extends WC_Stripe_Rest_Controller {
|
|
120 |
* @since 3.1.8
|
121 |
*/
|
122 |
public function process_order_pay( $request ) {
|
|
|
|
|
123 |
global $wp;
|
124 |
|
125 |
$wp->query_vars['order-pay'] = $request->get_param( 'order_id' );
|
@@ -147,6 +144,7 @@ class WC_Stripe_Controller_Checkout extends WC_Stripe_Rest_Controller {
|
|
147 |
* @since 3.1.7
|
148 |
*/
|
149 |
public function delete_source( $request ) {
|
|
|
150 |
$order_id = WC()->session->get( 'order_awaiting_payment', null );
|
151 |
if ( $order_id ) {
|
152 |
$order = wc_get_order( $order_id );
|
13 |
*/
|
14 |
class WC_Stripe_Controller_Checkout extends WC_Stripe_Rest_Controller {
|
15 |
|
16 |
+
use WC_Stripe_Controller_Frontend_Trait;
|
17 |
+
|
18 |
protected $namespace = '';
|
19 |
|
20 |
private $order_review = false;
|
66 |
* @return WP_REST_Response
|
67 |
*/
|
68 |
public function process_checkout( $request ) {
|
69 |
+
$this->frontend_includes();
|
70 |
wc_maybe_define_constant( 'DOING_AJAX', true );
|
71 |
$this->actions();
|
72 |
$checkout = WC()->checkout();
|
77 |
*/
|
78 |
$this->gateway = $gateway = WC()->payment_gateways()->payment_gateways()[ $payment_method ];
|
79 |
|
|
|
|
|
|
|
|
|
80 |
try {
|
81 |
do_action( 'wc_stripe_rest_process_checkout', $request, $gateway );
|
82 |
if ( ! is_user_logged_in() ) {
|
88 |
if ( 'product' == $request->get_param( 'page_id' ) ) {
|
89 |
wc_stripe_stash_cart( WC()->cart );
|
90 |
$gateway->set_post_payment_process( array( $this, 'post_payment_processes' ) );
|
91 |
+
add_filter( 'woocommerce_get_checkout_order_received_url', function ( $url, $order ) {
|
92 |
+
return add_query_arg( 'wc_stripe_product_checkout', $order->get_payment_method(), $url );
|
93 |
+
}, 10, 2 );
|
|
|
|
|
|
|
|
|
|
|
94 |
|
95 |
$option = new WC_Stripe_Product_Gateway_Option( current( WC()->cart->get_cart() )['data'], $gateway );
|
96 |
$gateway->settings['charge_type'] = $option->get_option( 'charge_type' );
|
97 |
}
|
98 |
+
$this->required_post_data();
|
99 |
$checkout->process_checkout();
|
100 |
} catch ( Exception $e ) {
|
101 |
wc_add_notice( $e->getMessage(), 'error' );
|
115 |
* @since 3.1.8
|
116 |
*/
|
117 |
public function process_order_pay( $request ) {
|
118 |
+
$this->frontend_includes();
|
119 |
+
|
120 |
global $wp;
|
121 |
|
122 |
$wp->query_vars['order-pay'] = $request->get_param( 'order_id' );
|
144 |
* @since 3.1.7
|
145 |
*/
|
146 |
public function delete_source( $request ) {
|
147 |
+
$this->frontend_includes();
|
148 |
$order_id = WC()->session->get( 'order_awaiting_payment', null );
|
149 |
if ( $order_id ) {
|
150 |
$order = wc_get_order( $order_id );
|
includes/controllers/class-wc-stripe-controller-googlepay.php
CHANGED
@@ -13,6 +13,7 @@ if ( ! class_exists( 'WC_Stripe_Rest_Controller' ) ) {
|
|
13 |
class WC_Stripe_Controller_GooglePay extends WC_Stripe_Rest_Controller {
|
14 |
|
15 |
use WC_Stripe_Controller_Cart_Trait;
|
|
|
16 |
|
17 |
protected $namespace = 'googlepay';
|
18 |
|
@@ -28,12 +29,6 @@ class WC_Stripe_Controller_GooglePay extends WC_Stripe_Rest_Controller {
|
|
28 |
*/
|
29 |
private $shipping_method_id;
|
30 |
|
31 |
-
/**
|
32 |
-
*
|
33 |
-
* @var array
|
34 |
-
*/
|
35 |
-
private $shipping_methods = array();
|
36 |
-
|
37 |
/**
|
38 |
*
|
39 |
* @var string
|
@@ -48,9 +43,8 @@ class WC_Stripe_Controller_GooglePay extends WC_Stripe_Rest_Controller {
|
|
48 |
'methods' => WP_REST_Server::CREATABLE,
|
49 |
'callback' => array( $this, 'update_shipping_data' ),
|
50 |
'args' => array(
|
51 |
-
'shipping_address'
|
52 |
-
'
|
53 |
-
'shipping_method_id' => array( 'required' => true ),
|
54 |
),
|
55 |
)
|
56 |
);
|
@@ -62,23 +56,26 @@ class WC_Stripe_Controller_GooglePay extends WC_Stripe_Rest_Controller {
|
|
62 |
* @param WP_REST_Request $request
|
63 |
*/
|
64 |
public function update_shipping_data( $request ) {
|
|
|
65 |
wc_maybe_define_constant( 'WOOCOMMERCE_CART', true );
|
|
|
|
|
66 |
$address = $request->get_param( 'shipping_address' );
|
67 |
-
$this->
|
68 |
-
$this->shipping_methods = null == $this->shipping_methods ? array() : $this->shipping_methods;
|
69 |
-
$this->shipping_method_id = $request->get_param( 'shipping_method_id' );
|
70 |
|
71 |
$this->gateway = WC()->payment_gateways()->payment_gateways()['stripe_googlepay'];
|
72 |
|
73 |
$this->add_ready_to_calc_shipping();
|
74 |
|
75 |
try {
|
|
|
|
|
|
|
|
|
|
|
76 |
if ( 'product' == $request->get_param( 'page_id' ) ) {
|
77 |
wc_stripe_stash_cart( WC()->cart );
|
78 |
}
|
79 |
-
wc_stripe_update_customer_location( $address );
|
80 |
-
|
81 |
-
wc_stripe_update_shipping_methods( $this->shipping_methods );
|
82 |
|
83 |
// update the WC cart with the new shipping options
|
84 |
WC()->cart->calculate_totals();
|
@@ -103,6 +100,7 @@ class WC_Stripe_Controller_GooglePay extends WC_Stripe_Rest_Controller {
|
|
103 |
if ( 'product' == $request->get_param( 'page_id' ) ) {
|
104 |
wc_stripe_restore_cart( WC()->cart );
|
105 |
}
|
|
|
106 |
return $response;
|
107 |
} catch ( Exception $e ) {
|
108 |
return new WP_Error(
|
@@ -130,7 +128,7 @@ class WC_Stripe_Controller_GooglePay extends WC_Stripe_Rest_Controller {
|
|
130 |
'newTransactionInfo' => array(
|
131 |
'currencyCode' => get_woocommerce_currency(),
|
132 |
'totalPriceStatus' => 'FINAL',
|
133 |
-
'totalPrice' => strval( WC()->cart->total ),
|
134 |
'displayItems' => $this->gateway->get_display_items(),
|
135 |
'totalPriceLabel' => __( 'Total', 'woo-stripe-payment' ),
|
136 |
),
|
@@ -153,8 +151,12 @@ class WC_Stripe_Controller_GooglePay extends WC_Stripe_Rest_Controller {
|
|
153 |
private function get_default_shipping_method() {
|
154 |
$chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods', array() );
|
155 |
if ( ! empty( $chosen_shipping_methods ) ) {
|
156 |
-
|
|
|
|
|
|
|
157 |
}
|
|
|
158 |
return $this->shipping_method_id;
|
159 |
}
|
160 |
}
|
13 |
class WC_Stripe_Controller_GooglePay extends WC_Stripe_Rest_Controller {
|
14 |
|
15 |
use WC_Stripe_Controller_Cart_Trait;
|
16 |
+
use WC_Stripe_Controller_Frontend_Trait;
|
17 |
|
18 |
protected $namespace = 'googlepay';
|
19 |
|
29 |
*/
|
30 |
private $shipping_method_id;
|
31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
/**
|
33 |
*
|
34 |
* @var string
|
43 |
'methods' => WP_REST_Server::CREATABLE,
|
44 |
'callback' => array( $this, 'update_shipping_data' ),
|
45 |
'args' => array(
|
46 |
+
'shipping_address' => array( 'required' => true ),
|
47 |
+
'shipping_method' => array( 'required' => false )
|
|
|
48 |
),
|
49 |
)
|
50 |
);
|
56 |
* @param WP_REST_Request $request
|
57 |
*/
|
58 |
public function update_shipping_data( $request ) {
|
59 |
+
$this->cart_includes();
|
60 |
wc_maybe_define_constant( 'WOOCOMMERCE_CART', true );
|
61 |
+
wc_maybe_define_constant( 'DOING_AJAX', true );
|
62 |
+
|
63 |
$address = $request->get_param( 'shipping_address' );
|
64 |
+
$this->shipping_method_id = ( ( $method_id = $request->get_param( 'shipping_method' ) ) ? $method_id : 'default' );
|
|
|
|
|
65 |
|
66 |
$this->gateway = WC()->payment_gateways()->payment_gateways()['stripe_googlepay'];
|
67 |
|
68 |
$this->add_ready_to_calc_shipping();
|
69 |
|
70 |
try {
|
71 |
+
|
72 |
+
wc_stripe_update_customer_location( $address );
|
73 |
+
|
74 |
+
wc_stripe_update_shipping_methods( $this->get_shipping_method_from_request( $request ) );
|
75 |
+
|
76 |
if ( 'product' == $request->get_param( 'page_id' ) ) {
|
77 |
wc_stripe_stash_cart( WC()->cart );
|
78 |
}
|
|
|
|
|
|
|
79 |
|
80 |
// update the WC cart with the new shipping options
|
81 |
WC()->cart->calculate_totals();
|
100 |
if ( 'product' == $request->get_param( 'page_id' ) ) {
|
101 |
wc_stripe_restore_cart( WC()->cart );
|
102 |
}
|
103 |
+
|
104 |
return $response;
|
105 |
} catch ( Exception $e ) {
|
106 |
return new WP_Error(
|
128 |
'newTransactionInfo' => array(
|
129 |
'currencyCode' => get_woocommerce_currency(),
|
130 |
'totalPriceStatus' => 'FINAL',
|
131 |
+
'totalPrice' => strval( round( WC()->cart->total, 2 ) ),
|
132 |
'displayItems' => $this->gateway->get_display_items(),
|
133 |
'totalPriceLabel' => __( 'Total', 'woo-stripe-payment' ),
|
134 |
),
|
151 |
private function get_default_shipping_method() {
|
152 |
$chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods', array() );
|
153 |
if ( ! empty( $chosen_shipping_methods ) ) {
|
154 |
+
reset( $chosen_shipping_methods );
|
155 |
+
$key = key( $chosen_shipping_methods );
|
156 |
+
|
157 |
+
return sprintf( '%s:%s', $key, $chosen_shipping_methods[ $key ] );
|
158 |
}
|
159 |
+
|
160 |
return $this->shipping_method_id;
|
161 |
}
|
162 |
}
|
includes/controllers/class-wc-stripe-controller-order-actions.php
CHANGED
@@ -9,6 +9,8 @@ defined( 'ABSPATH' ) || exit();
|
|
9 |
*/
|
10 |
class WC_Stripe_Controller_Order_Actions extends WC_Stripe_Rest_Controller {
|
11 |
|
|
|
|
|
12 |
protected $namespace = 'order~action';
|
13 |
|
14 |
public function register_routes() {
|
@@ -168,6 +170,7 @@ class WC_Stripe_Controller_Order_Actions extends WC_Stripe_Rest_Controller {
|
|
168 |
* @param WP_REST_Request $request
|
169 |
*/
|
170 |
public function process_payment( $request ) {
|
|
|
171 |
$order_id = $request->get_param( 'order_id' );
|
172 |
$payment_type = $request->get_param( 'payment_type' );
|
173 |
$order = wc_get_order( $order_id );
|
@@ -219,15 +222,12 @@ class WC_Stripe_Controller_Order_Actions extends WC_Stripe_Rest_Controller {
|
|
219 |
}
|
220 |
|
221 |
// set intent attribute off_session. Stripe requires confirm to be true to use off session.
|
222 |
-
add_filter(
|
223 |
-
'
|
224 |
-
|
225 |
-
$args['confirm'] = true;
|
226 |
-
$args['off_session'] = true;
|
227 |
|
228 |
-
|
229 |
-
|
230 |
-
);
|
231 |
|
232 |
$result = $gateway->process_payment( $order_id );
|
233 |
|
9 |
*/
|
10 |
class WC_Stripe_Controller_Order_Actions extends WC_Stripe_Rest_Controller {
|
11 |
|
12 |
+
use WC_Stripe_Controller_Frontend_Trait;
|
13 |
+
|
14 |
protected $namespace = 'order~action';
|
15 |
|
16 |
public function register_routes() {
|
170 |
* @param WP_REST_Request $request
|
171 |
*/
|
172 |
public function process_payment( $request ) {
|
173 |
+
$this->frontend_includes();
|
174 |
$order_id = $request->get_param( 'order_id' );
|
175 |
$payment_type = $request->get_param( 'payment_type' );
|
176 |
$order = wc_get_order( $order_id );
|
222 |
}
|
223 |
|
224 |
// set intent attribute off_session. Stripe requires confirm to be true to use off session.
|
225 |
+
add_filter( 'wc_stripe_payment_intent_args', function ( $args ) {
|
226 |
+
$args['confirm'] = true;
|
227 |
+
$args['off_session'] = true;
|
|
|
|
|
228 |
|
229 |
+
return $args;
|
230 |
+
} );
|
|
|
231 |
|
232 |
$result = $gateway->process_payment( $order_id );
|
233 |
|
includes/controllers/class-wc-stripe-controller-payment-intent.php
CHANGED
@@ -46,7 +46,7 @@ class WC_Stripe_Controller_Payment_Intent extends WC_Stripe_Rest_Controller {
|
|
46 |
$intent = WC_Stripe_Gateway::load()->setupIntents->create( array( 'usage' => 'off_session' ) );
|
47 |
try {
|
48 |
if ( is_wp_error( $intent ) ) {
|
49 |
-
throw new Exception( $
|
50 |
}
|
51 |
|
52 |
return rest_ensure_response( array( 'intent' => array( 'client_secret' => $intent->client_secret ) ) );
|
46 |
$intent = WC_Stripe_Gateway::load()->setupIntents->create( array( 'usage' => 'off_session' ) );
|
47 |
try {
|
48 |
if ( is_wp_error( $intent ) ) {
|
49 |
+
throw new Exception( $intent->get_error_message() );
|
50 |
}
|
51 |
|
52 |
return rest_ensure_response( array( 'intent' => array( 'client_secret' => $intent->client_secret ) ) );
|
includes/gateways/class-wc-payment-gateway-stripe-applepay.php
CHANGED
@@ -24,6 +24,7 @@ class WC_Payment_Gateway_Stripe_ApplePay extends WC_Payment_Gateway_Stripe {
|
|
24 |
$this->token_type = 'Stripe_ApplePay';
|
25 |
$this->method_title = __( 'Stripe Apple Pay', 'woo-stripe-payment' );
|
26 |
$this->method_description = __( 'Apple Pay gateway that integrates with your Stripe account.', 'woo-stripe-payment' );
|
|
|
27 |
parent::__construct();
|
28 |
$this->icon = wc_stripe()->assets_url( 'img/applepay.svg' );
|
29 |
}
|
@@ -33,6 +34,7 @@ class WC_Payment_Gateway_Stripe_ApplePay extends WC_Payment_Gateway_Stripe {
|
|
33 |
$this->supports[] = 'wc_stripe_cart_checkout';
|
34 |
$this->supports[] = 'wc_stripe_product_checkout';
|
35 |
$this->supports[] = 'wc_stripe_banner_checkout';
|
|
|
36 |
}
|
37 |
|
38 |
public function enqueue_product_scripts( $scripts ) {
|
@@ -40,8 +42,7 @@ class WC_Payment_Gateway_Stripe_ApplePay extends WC_Payment_Gateway_Stripe {
|
|
40 |
'applepay-product',
|
41 |
$scripts->assets_url( 'js/frontend/applepay-product.js' ),
|
42 |
array(
|
43 |
-
$scripts->get_handle( 'wc-stripe' )
|
44 |
-
$scripts->get_handle( 'external' ),
|
45 |
),
|
46 |
wc_stripe()->version(),
|
47 |
true
|
@@ -54,8 +55,7 @@ class WC_Payment_Gateway_Stripe_ApplePay extends WC_Payment_Gateway_Stripe {
|
|
54 |
'applepay-cart',
|
55 |
$scripts->assets_url( 'js/frontend/applepay-cart.js' ),
|
56 |
array(
|
57 |
-
$scripts->get_handle( 'wc-stripe' )
|
58 |
-
$scripts->get_handle( 'external' ),
|
59 |
),
|
60 |
wc_stripe()->version(),
|
61 |
true
|
@@ -68,8 +68,7 @@ class WC_Payment_Gateway_Stripe_ApplePay extends WC_Payment_Gateway_Stripe {
|
|
68 |
'applepay-checkout',
|
69 |
$scripts->assets_url( 'js/frontend/applepay-checkout.js' ),
|
70 |
array(
|
71 |
-
$scripts->get_handle( 'wc-stripe' )
|
72 |
-
$scripts->get_handle( 'external' ),
|
73 |
),
|
74 |
wc_stripe()->version(),
|
75 |
true
|
24 |
$this->token_type = 'Stripe_ApplePay';
|
25 |
$this->method_title = __( 'Stripe Apple Pay', 'woo-stripe-payment' );
|
26 |
$this->method_description = __( 'Apple Pay gateway that integrates with your Stripe account.', 'woo-stripe-payment' );
|
27 |
+
$this->has_digital_wallet = true;
|
28 |
parent::__construct();
|
29 |
$this->icon = wc_stripe()->assets_url( 'img/applepay.svg' );
|
30 |
}
|
34 |
$this->supports[] = 'wc_stripe_cart_checkout';
|
35 |
$this->supports[] = 'wc_stripe_product_checkout';
|
36 |
$this->supports[] = 'wc_stripe_banner_checkout';
|
37 |
+
$this->supports[] = 'wc_stripe_mini_cart_checkout';
|
38 |
}
|
39 |
|
40 |
public function enqueue_product_scripts( $scripts ) {
|
42 |
'applepay-product',
|
43 |
$scripts->assets_url( 'js/frontend/applepay-product.js' ),
|
44 |
array(
|
45 |
+
$scripts->get_handle( 'wc-stripe' )
|
|
|
46 |
),
|
47 |
wc_stripe()->version(),
|
48 |
true
|
55 |
'applepay-cart',
|
56 |
$scripts->assets_url( 'js/frontend/applepay-cart.js' ),
|
57 |
array(
|
58 |
+
$scripts->get_handle( 'wc-stripe' )
|
|
|
59 |
),
|
60 |
wc_stripe()->version(),
|
61 |
true
|
68 |
'applepay-checkout',
|
69 |
$scripts->assets_url( 'js/frontend/applepay-checkout.js' ),
|
70 |
array(
|
71 |
+
$scripts->get_handle( 'wc-stripe' )
|
|
|
72 |
),
|
73 |
wc_stripe()->version(),
|
74 |
true
|
includes/gateways/class-wc-payment-gateway-stripe-fpx.php
CHANGED
@@ -20,7 +20,7 @@ class WC_Payment_Gateway_Stripe_FPX extends WC_Payment_Gateway_Stripe_Local_Paym
|
|
20 |
public function __construct() {
|
21 |
$this->local_payment_type = 'fpx';
|
22 |
$this->currencies = array( 'MYR' );
|
23 |
-
$this->countries = array(
|
24 |
$this->id = 'stripe_fpx';
|
25 |
$this->tab_title = __( 'FPX', 'woo-stripe-payment' );
|
26 |
$this->method_title = __( 'FPX', 'woo-stripe-payment' );
|
@@ -33,6 +33,7 @@ class WC_Payment_Gateway_Stripe_FPX extends WC_Payment_Gateway_Stripe_Local_Paym
|
|
33 |
public function get_element_params() {
|
34 |
$params = parent::get_element_params();
|
35 |
$params['accountHolderType'] = 'individual';
|
|
|
36 |
return $params;
|
37 |
}
|
38 |
}
|
20 |
public function __construct() {
|
21 |
$this->local_payment_type = 'fpx';
|
22 |
$this->currencies = array( 'MYR' );
|
23 |
+
$this->countries = array();
|
24 |
$this->id = 'stripe_fpx';
|
25 |
$this->tab_title = __( 'FPX', 'woo-stripe-payment' );
|
26 |
$this->method_title = __( 'FPX', 'woo-stripe-payment' );
|
33 |
public function get_element_params() {
|
34 |
$params = parent::get_element_params();
|
35 |
$params['accountHolderType'] = 'individual';
|
36 |
+
|
37 |
return $params;
|
38 |
}
|
39 |
}
|
includes/gateways/class-wc-payment-gateway-stripe-googlepay.php
CHANGED
@@ -22,6 +22,7 @@ class WC_Payment_Gateway_Stripe_GooglePay extends WC_Payment_Gateway_Stripe {
|
|
22 |
$this->token_type = 'Stripe_GooglePay';
|
23 |
$this->method_title = __( 'Stripe Google Pay', 'woo-stripe-payment' );
|
24 |
$this->method_description = __( 'Google Pay gateway that integrates with your Stripe account.', 'woo-stripe-payment' );
|
|
|
25 |
parent::__construct();
|
26 |
$this->icon = wc_stripe()->assets_url( 'img/' . $this->get_option( 'icon' ) . '.svg' );
|
27 |
}
|
@@ -31,6 +32,7 @@ class WC_Payment_Gateway_Stripe_GooglePay extends WC_Payment_Gateway_Stripe {
|
|
31 |
$this->supports[] = 'wc_stripe_cart_checkout';
|
32 |
$this->supports[] = 'wc_stripe_product_checkout';
|
33 |
$this->supports[] = 'wc_stripe_banner_checkout';
|
|
|
34 |
}
|
35 |
|
36 |
public function enqueue_checkout_scripts( $scripts ) {
|
@@ -100,17 +102,23 @@ class WC_Payment_Gateway_Stripe_GooglePay extends WC_Payment_Gateway_Stripe {
|
|
100 |
'button_style' => $this->get_option( 'button_style' ),
|
101 |
'total_price_label' => __( 'Total', 'woo-stripe-payment' ),
|
102 |
'routes' => array( 'payment_data' => wc_stripe()->rest_api->googlepay->rest_url( 'shipping-data' ) ),
|
103 |
-
'messages' => array( 'invalid_amount' => __( 'Please update you product quantity before using Google Pay.', 'woo-stripe-payment' ) )
|
104 |
-
'dynamic_price' => $this->is_active( 'dynamic_price' ),
|
105 |
)
|
106 |
);
|
107 |
|
108 |
return $data;
|
109 |
}
|
110 |
|
111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
$items = array();
|
113 |
global $wp;
|
|
|
114 |
if ( wcs_stripe_active() && WC_Subscriptions_Change_Payment_Gateway::$is_request_to_change_payment ) {
|
115 |
$subscription = wcs_get_subscription( absint( $_GET['change_payment_method'] ) );
|
116 |
$items[] = array(
|
@@ -118,15 +126,14 @@ class WC_Payment_Gateway_Stripe_GooglePay extends WC_Payment_Gateway_Stripe {
|
|
118 |
'type' => 'SUBTOTAL',
|
119 |
'price' => strval( $subscription->get_total() ),
|
120 |
);
|
121 |
-
} elseif (
|
122 |
global $product;
|
123 |
$items[] = array(
|
124 |
'label' => esc_attr( $product->get_name() ),
|
125 |
'type' => 'LINE_ITEM',
|
126 |
'price' => strval( $product->get_price() ),
|
127 |
);
|
128 |
-
} elseif (
|
129 |
-
$order = wc_get_order( absint( $wp->query_vars['order-pay'] ) );
|
130 |
// add all order items
|
131 |
foreach ( $order->get_items() as $item ) {
|
132 |
/**
|
@@ -138,7 +145,7 @@ class WC_Payment_Gateway_Stripe_GooglePay extends WC_Payment_Gateway_Stripe {
|
|
138 |
$items[] = array(
|
139 |
'label' => $qty > 1 ? sprintf( '%s X %s', $item->get_name(), $qty ) : $item->get_name(),
|
140 |
'type' => 'LINE_ITEM',
|
141 |
-
'price' => strval( $item->get_subtotal() ),
|
142 |
);
|
143 |
}
|
144 |
// shipping total
|
@@ -146,7 +153,7 @@ class WC_Payment_Gateway_Stripe_GooglePay extends WC_Payment_Gateway_Stripe {
|
|
146 |
$items[] = array(
|
147 |
'label' => __( 'Shipping', 'woo-stripe-payment' ),
|
148 |
'type' => 'LINE_ITEM',
|
149 |
-
'price' => strval( $order->get_shipping_total() ),
|
150 |
);
|
151 |
}
|
152 |
// discount total
|
@@ -154,7 +161,7 @@ class WC_Payment_Gateway_Stripe_GooglePay extends WC_Payment_Gateway_Stripe {
|
|
154 |
$items[] = array(
|
155 |
'label' => __( 'Discount', 'woo-stripe-payment' ),
|
156 |
'type' => 'LINE_ITEM',
|
157 |
-
'price' => strval( $order->get_total_discount() ),
|
158 |
);
|
159 |
}
|
160 |
if ( $order->get_fees() ) {
|
@@ -165,7 +172,7 @@ class WC_Payment_Gateway_Stripe_GooglePay extends WC_Payment_Gateway_Stripe {
|
|
165 |
$items[] = array(
|
166 |
'label' => __( 'Fees', 'woo-stripe-payment' ),
|
167 |
'type' => 'LINE_ITEM',
|
168 |
-
'price' => strval( $fee_total ),
|
169 |
);
|
170 |
}
|
171 |
// tax total
|
@@ -173,14 +180,14 @@ class WC_Payment_Gateway_Stripe_GooglePay extends WC_Payment_Gateway_Stripe {
|
|
173 |
$items[] = array(
|
174 |
'label' => __( 'Tax', 'woocommerce' ),
|
175 |
'type' => 'TAX',
|
176 |
-
'price' => strval( $order->get_total_tax() ),
|
177 |
);
|
178 |
}
|
179 |
-
}
|
180 |
$this->get_cart_display_items( $items );
|
181 |
}
|
182 |
|
183 |
-
return $
|
184 |
}
|
185 |
|
186 |
/**
|
@@ -227,7 +234,7 @@ class WC_Payment_Gateway_Stripe_GooglePay extends WC_Payment_Gateway_Stripe {
|
|
227 |
}
|
228 |
|
229 |
// coupons
|
230 |
-
if ( WC()->cart->discount_cart
|
231 |
$items[] = array(
|
232 |
'label' => __( 'Discount', 'woo-stripe-payment' ),
|
233 |
'type' => 'LINE_ITEM',
|
@@ -257,7 +264,7 @@ class WC_Payment_Gateway_Stripe_GooglePay extends WC_Payment_Gateway_Stripe {
|
|
257 |
}
|
258 |
}
|
259 |
|
260 |
-
public function get_shipping_methods(
|
261 |
if ( wcs_stripe_active() && WC_Subscriptions_Change_Payment_Gateway::$is_request_to_change_payment ) {
|
262 |
$methods = array();
|
263 |
} else {
|
@@ -286,7 +293,7 @@ class WC_Payment_Gateway_Stripe_GooglePay extends WC_Payment_Gateway_Stripe {
|
|
286 |
}
|
287 |
}
|
288 |
|
289 |
-
return $
|
290 |
}
|
291 |
|
292 |
/**
|
@@ -329,10 +336,16 @@ class WC_Payment_Gateway_Stripe_GooglePay extends WC_Payment_Gateway_Stripe {
|
|
329 |
}
|
330 |
|
331 |
/**
|
332 |
-
*
|
|
|
|
|
|
|
333 |
*/
|
334 |
-
public function
|
335 |
-
|
336 |
-
|
|
|
|
|
|
|
337 |
}
|
338 |
}
|
22 |
$this->token_type = 'Stripe_GooglePay';
|
23 |
$this->method_title = __( 'Stripe Google Pay', 'woo-stripe-payment' );
|
24 |
$this->method_description = __( 'Google Pay gateway that integrates with your Stripe account.', 'woo-stripe-payment' );
|
25 |
+
$this->has_digital_wallet = true;
|
26 |
parent::__construct();
|
27 |
$this->icon = wc_stripe()->assets_url( 'img/' . $this->get_option( 'icon' ) . '.svg' );
|
28 |
}
|
32 |
$this->supports[] = 'wc_stripe_cart_checkout';
|
33 |
$this->supports[] = 'wc_stripe_product_checkout';
|
34 |
$this->supports[] = 'wc_stripe_banner_checkout';
|
35 |
+
$this->supports[] = 'wc_stripe_mini_cart_checkout';
|
36 |
}
|
37 |
|
38 |
public function enqueue_checkout_scripts( $scripts ) {
|
102 |
'button_style' => $this->get_option( 'button_style' ),
|
103 |
'total_price_label' => __( 'Total', 'woo-stripe-payment' ),
|
104 |
'routes' => array( 'payment_data' => wc_stripe()->rest_api->googlepay->rest_url( 'shipping-data' ) ),
|
105 |
+
'messages' => array( 'invalid_amount' => __( 'Please update you product quantity before using Google Pay.', 'woo-stripe-payment' ) )
|
|
|
106 |
)
|
107 |
);
|
108 |
|
109 |
return $data;
|
110 |
}
|
111 |
|
112 |
+
/**
|
113 |
+
* @param string $page
|
114 |
+
* @param null $order
|
115 |
+
*
|
116 |
+
* @return array|mixed|void
|
117 |
+
*/
|
118 |
+
public function get_display_items( $page = 'checkout', $order = null ) {
|
119 |
$items = array();
|
120 |
global $wp;
|
121 |
+
$decimals = ( ( $decimals = wc_get_price_decimals() ) < 2 ? $decimals : 2 );
|
122 |
if ( wcs_stripe_active() && WC_Subscriptions_Change_Payment_Gateway::$is_request_to_change_payment ) {
|
123 |
$subscription = wcs_get_subscription( absint( $_GET['change_payment_method'] ) );
|
124 |
$items[] = array(
|
126 |
'type' => 'SUBTOTAL',
|
127 |
'price' => strval( $subscription->get_total() ),
|
128 |
);
|
129 |
+
} elseif ( 'product' === $page ) {
|
130 |
global $product;
|
131 |
$items[] = array(
|
132 |
'label' => esc_attr( $product->get_name() ),
|
133 |
'type' => 'LINE_ITEM',
|
134 |
'price' => strval( $product->get_price() ),
|
135 |
);
|
136 |
+
} elseif ( 'order_pay' === $page ) {
|
|
|
137 |
// add all order items
|
138 |
foreach ( $order->get_items() as $item ) {
|
139 |
/**
|
145 |
$items[] = array(
|
146 |
'label' => $qty > 1 ? sprintf( '%s X %s', $item->get_name(), $qty ) : $item->get_name(),
|
147 |
'type' => 'LINE_ITEM',
|
148 |
+
'price' => strval( round( $item->get_subtotal(), $decimals ) ),
|
149 |
);
|
150 |
}
|
151 |
// shipping total
|
153 |
$items[] = array(
|
154 |
'label' => __( 'Shipping', 'woo-stripe-payment' ),
|
155 |
'type' => 'LINE_ITEM',
|
156 |
+
'price' => strval( round( $order->get_shipping_total(), $decimals ) ),
|
157 |
);
|
158 |
}
|
159 |
// discount total
|
161 |
$items[] = array(
|
162 |
'label' => __( 'Discount', 'woo-stripe-payment' ),
|
163 |
'type' => 'LINE_ITEM',
|
164 |
+
'price' => strval( - 1 * $order->get_total_discount() ),
|
165 |
);
|
166 |
}
|
167 |
if ( $order->get_fees() ) {
|
172 |
$items[] = array(
|
173 |
'label' => __( 'Fees', 'woo-stripe-payment' ),
|
174 |
'type' => 'LINE_ITEM',
|
175 |
+
'price' => strval( round( $fee_total, $decimals ) ),
|
176 |
);
|
177 |
}
|
178 |
// tax total
|
180 |
$items[] = array(
|
181 |
'label' => __( 'Tax', 'woocommerce' ),
|
182 |
'type' => 'TAX',
|
183 |
+
'price' => strval( round( $order->get_total_tax(), $decimals ) ),
|
184 |
);
|
185 |
}
|
186 |
+
} elseif ( in_array( $page, array( 'cart', 'checkout' ) ) ) {
|
187 |
$this->get_cart_display_items( $items );
|
188 |
}
|
189 |
|
190 |
+
return $items;
|
191 |
}
|
192 |
|
193 |
/**
|
234 |
}
|
235 |
|
236 |
// coupons
|
237 |
+
if ( 0 < WC()->cart->discount_cart ) {
|
238 |
$items[] = array(
|
239 |
'label' => __( 'Discount', 'woo-stripe-payment' ),
|
240 |
'type' => 'LINE_ITEM',
|
264 |
}
|
265 |
}
|
266 |
|
267 |
+
public function get_shipping_methods() {
|
268 |
if ( wcs_stripe_active() && WC_Subscriptions_Change_Payment_Gateway::$is_request_to_change_payment ) {
|
269 |
$methods = array();
|
270 |
} else {
|
293 |
}
|
294 |
}
|
295 |
|
296 |
+
return $methods;
|
297 |
}
|
298 |
|
299 |
/**
|
336 |
}
|
337 |
|
338 |
/**
|
339 |
+
* @param array $deps
|
340 |
+
* @param $scripts
|
341 |
+
*
|
342 |
+
* @return array
|
343 |
*/
|
344 |
+
public function get_mini_cart_dependencies( $deps, $scripts ) {
|
345 |
+
if ( $this->mini_cart_enabled() ) {
|
346 |
+
$deps[] = $scripts->get_handle( 'gpay' );
|
347 |
+
}
|
348 |
+
|
349 |
+
return $deps;
|
350 |
}
|
351 |
}
|
includes/gateways/class-wc-payment-gateway-stripe-grabpay.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
if ( ! class_exists( 'WC_Payment_Gateway_Stripe_Local_Payment' ) ) {
|
5 |
+
return;
|
6 |
+
}
|
7 |
+
|
8 |
+
/**
|
9 |
+
*
|
10 |
+
* @package Stripe/Gateways
|
11 |
+
* @author PaymentPlugins
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
class WC_Payment_Gateway_Stripe_GrabPay extends WC_Payment_Gateway_Stripe_Local_Payment {
|
15 |
+
|
16 |
+
protected $payment_method_type = 'grabpay';
|
17 |
+
|
18 |
+
use WC_Stripe_Local_Payment_Intent_Trait;
|
19 |
+
|
20 |
+
public function __construct() {
|
21 |
+
$this->local_payment_type = 'grabpay';
|
22 |
+
$this->currencies = array( 'SGD' );
|
23 |
+
$this->countries = array();
|
24 |
+
$this->id = 'stripe_grabpay';
|
25 |
+
$this->tab_title = __( 'GrabPay', 'woo-stripe-payment' );
|
26 |
+
$this->method_title = __( 'GrabPay', 'woo-stripe-payment' );
|
27 |
+
$this->method_description = __( 'GrabPay gateway that integrates with your Stripe account.', 'woo-stripe-payment' );
|
28 |
+
$this->icon = wc_stripe()->assets_url( 'img/grabpay.svg' );
|
29 |
+
$this->order_button_text = $this->get_order_button_text( __( 'GrabPay', 'woo-stripe-payment' ) );
|
30 |
+
parent::__construct();
|
31 |
+
}
|
32 |
+
}
|
includes/gateways/class-wc-payment-gateway-stripe-payment-request.php
CHANGED
@@ -25,6 +25,7 @@ class WC_Payment_Gateway_Stripe_Payment_Request extends WC_Payment_Gateway_Strip
|
|
25 |
$this->token_type = 'Stripe_CC';
|
26 |
$this->method_title = __( 'Stripe Payment Request', 'woo-stripe-payment' );
|
27 |
$this->method_description = __( 'Gateway that renders based on the user\'s browser. Chrome payment methods, Microsoft pay, etc.', 'woo-stripe-payment' );
|
|
|
28 |
parent::__construct();
|
29 |
}
|
30 |
|
@@ -33,6 +34,7 @@ class WC_Payment_Gateway_Stripe_Payment_Request extends WC_Payment_Gateway_Strip
|
|
33 |
$this->supports[] = 'wc_stripe_cart_checkout';
|
34 |
$this->supports[] = 'wc_stripe_product_checkout';
|
35 |
$this->supports[] = 'wc_stripe_banner_checkout';
|
|
|
36 |
}
|
37 |
|
38 |
public function get_icon() {
|
@@ -75,18 +77,16 @@ class WC_Payment_Gateway_Stripe_Payment_Request extends WC_Payment_Gateway_Strip
|
|
75 |
'messages' => array(
|
76 |
'invalid_amount' => __( 'Please update you product quantity before paying.', 'woo-stripe-payment' ),
|
77 |
'add_to_cart' => __( 'Adding to cart...', 'woo-stripe-payment' ),
|
78 |
-
'choose_product' => __(
|
79 |
-
'Please select a product option before updating quantity.',
|
80 |
-
'woo-stripe-payment'
|
81 |
-
),
|
82 |
),
|
83 |
)
|
84 |
);
|
85 |
}
|
86 |
|
87 |
private function get_button_height() {
|
88 |
-
$value
|
89 |
$value .= strpos( $value, 'px' ) === false ? 'px' : '';
|
|
|
90 |
return $value;
|
91 |
}
|
92 |
|
25 |
$this->token_type = 'Stripe_CC';
|
26 |
$this->method_title = __( 'Stripe Payment Request', 'woo-stripe-payment' );
|
27 |
$this->method_description = __( 'Gateway that renders based on the user\'s browser. Chrome payment methods, Microsoft pay, etc.', 'woo-stripe-payment' );
|
28 |
+
$this->has_digital_wallet = true;
|
29 |
parent::__construct();
|
30 |
}
|
31 |
|
34 |
$this->supports[] = 'wc_stripe_cart_checkout';
|
35 |
$this->supports[] = 'wc_stripe_product_checkout';
|
36 |
$this->supports[] = 'wc_stripe_banner_checkout';
|
37 |
+
$this->supports[] = 'wc_stripe_mini_cart_checkout';
|
38 |
}
|
39 |
|
40 |
public function get_icon() {
|
77 |
'messages' => array(
|
78 |
'invalid_amount' => __( 'Please update you product quantity before paying.', 'woo-stripe-payment' ),
|
79 |
'add_to_cart' => __( 'Adding to cart...', 'woo-stripe-payment' ),
|
80 |
+
'choose_product' => __( 'Please select a product option before updating quantity.', 'woo-stripe-payment' ),
|
|
|
|
|
|
|
81 |
),
|
82 |
)
|
83 |
);
|
84 |
}
|
85 |
|
86 |
private function get_button_height() {
|
87 |
+
$value = $this->get_option( 'button_height' );
|
88 |
$value .= strpos( $value, 'px' ) === false ? 'px' : '';
|
89 |
+
|
90 |
return $value;
|
91 |
}
|
92 |
|
includes/gateways/settings/applepay-settings.php
CHANGED
@@ -3,9 +3,9 @@ return array(
|
|
3 |
'desc' => array(
|
4 |
'type' => 'description',
|
5 |
'description' => sprintf( '<div class="wc-stripe-register-domain"><button class="button button-secondary api-register-domain">%s</button></div><p>%s</p>', __( 'Register Domain', 'woo-stripe-payment' ), sprintf( __( 'This plugin attemps to add the domain association file to your server automatically when you click the Register Domain button. If that fails due to file permssions, you must add the <strong>%1$s.well-known/apple-developer-merchantid-domain-association%2$s</strong> file to your domain and register your domain within the Stripe Dashboard.', 'woo-stripe-payment' ), '<a href="https://stripe.com/files/apple-pay/apple-developer-merchantid-domain-association">', '</a>' ) ) .
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
),
|
10 |
'enabled' => array(
|
11 |
'title' => __( 'Enabled', 'woo-stripe-payment' ),
|
@@ -62,6 +62,7 @@ return array(
|
|
62 |
'options' => array(
|
63 |
'product' => __( 'Product Page', 'woo-stripe-payment' ),
|
64 |
'cart' => __( 'Cart Page', 'woo-stripe-payment' ),
|
|
|
65 |
'checkout_banner' => __( 'Top of Checkout', 'woo-stripe-payment' ),
|
66 |
),
|
67 |
'default' => array( 'product', 'cart' ),
|
3 |
'desc' => array(
|
4 |
'type' => 'description',
|
5 |
'description' => sprintf( '<div class="wc-stripe-register-domain"><button class="button button-secondary api-register-domain">%s</button></div><p>%s</p>', __( 'Register Domain', 'woo-stripe-payment' ), sprintf( __( 'This plugin attemps to add the domain association file to your server automatically when you click the Register Domain button. If that fails due to file permssions, you must add the <strong>%1$s.well-known/apple-developer-merchantid-domain-association%2$s</strong> file to your domain and register your domain within the Stripe Dashboard.', 'woo-stripe-payment' ), '<a href="https://stripe.com/files/apple-pay/apple-developer-merchantid-domain-association">', '</a>' ) ) .
|
6 |
+
'<p>' .
|
7 |
+
__( 'In order for Apple Pay to display, you must test with an iOS device and have a payment method saved in the Apple Wallet.', 'woo-stripe-payment' ) .
|
8 |
+
'</p>',
|
9 |
),
|
10 |
'enabled' => array(
|
11 |
'title' => __( 'Enabled', 'woo-stripe-payment' ),
|
62 |
'options' => array(
|
63 |
'product' => __( 'Product Page', 'woo-stripe-payment' ),
|
64 |
'cart' => __( 'Cart Page', 'woo-stripe-payment' ),
|
65 |
+
'mini_cart' => __( 'Mini Cart', 'woo-stripe-payment' ),
|
66 |
'checkout_banner' => __( 'Top of Checkout', 'woo-stripe-payment' ),
|
67 |
),
|
68 |
'default' => array( 'product', 'cart' ),
|
includes/gateways/settings/googlepay-settings.php
CHANGED
@@ -3,8 +3,8 @@ return array(
|
|
3 |
'desc1' => array(
|
4 |
'type' => 'description',
|
5 |
'description' => '<p><a target="_blank" href="https://pay.google.com/business/console">' . __( 'GPay Business Console', 'woo-stripe-payment' ) .
|
6 |
-
|
7 |
-
|
8 |
),
|
9 |
'desc2' => array(
|
10 |
'type' => 'description',
|
@@ -30,13 +30,6 @@ return array(
|
|
30 |
'type' => 'title',
|
31 |
'title' => __( 'General Settings', 'woo-stripe-payment' ),
|
32 |
),
|
33 |
-
'dynamic_price' => array(
|
34 |
-
'title' => __( 'Dynamic Price', 'woo-stripe-payment' ),
|
35 |
-
'type' => 'checkbox',
|
36 |
-
'default' => 'yes',
|
37 |
-
'desc_tip' => true,
|
38 |
-
'description' => __( 'If enabled, the Google Payment sheet will show the order line items. You must have Google whitelist you for callback intents.', 'woo-stripe-payment' ),
|
39 |
-
),
|
40 |
'merchant_id' => array(
|
41 |
'type' => 'text',
|
42 |
'title' => __( 'Merchant ID', 'woo-stripe-payment' ),
|
@@ -86,6 +79,7 @@ return array(
|
|
86 |
'options' => array(
|
87 |
'product' => __( 'Product Page', 'woo-stripe-payment' ),
|
88 |
'cart' => __( 'Cart Page', 'woo-stripe-payment' ),
|
|
|
89 |
'checkout_banner' => __( 'Top of Checkout', 'woo-stripe-payment' ),
|
90 |
),
|
91 |
'default' => array( 'product', 'cart' ),
|
3 |
'desc1' => array(
|
4 |
'type' => 'description',
|
5 |
'description' => '<p><a target="_blank" href="https://pay.google.com/business/console">' . __( 'GPay Business Console', 'woo-stripe-payment' ) .
|
6 |
+
'</a></p>' .
|
7 |
+
__( 'When test mode is enabled, Google Pay will work without a merchant ID, allowing you to capture the necessary screenshots the Google API team needs to approve your integration request.', 'woo-stripe-payment' ),
|
8 |
),
|
9 |
'desc2' => array(
|
10 |
'type' => 'description',
|
30 |
'type' => 'title',
|
31 |
'title' => __( 'General Settings', 'woo-stripe-payment' ),
|
32 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
'merchant_id' => array(
|
34 |
'type' => 'text',
|
35 |
'title' => __( 'Merchant ID', 'woo-stripe-payment' ),
|
79 |
'options' => array(
|
80 |
'product' => __( 'Product Page', 'woo-stripe-payment' ),
|
81 |
'cart' => __( 'Cart Page', 'woo-stripe-payment' ),
|
82 |
+
'mini_cart' => __( 'Mini Cart', 'woo-stripe-payment' ),
|
83 |
'checkout_banner' => __( 'Top of Checkout', 'woo-stripe-payment' ),
|
84 |
),
|
85 |
'default' => array( 'product', 'cart' ),
|
includes/gateways/settings/payment-request-settings.php
CHANGED
@@ -63,6 +63,7 @@ return array(
|
|
63 |
'options' => array(
|
64 |
'product' => __( 'Product Page', 'woo-stripe-payment' ),
|
65 |
'cart' => __( 'Cart Page', 'woo-stripe-payment' ),
|
|
|
66 |
'checkout_banner' => __( 'Top of Checkout', 'woo-stripe-payment' ),
|
67 |
),
|
68 |
'default' => array( 'product', 'cart' ),
|
63 |
'options' => array(
|
64 |
'product' => __( 'Product Page', 'woo-stripe-payment' ),
|
65 |
'cart' => __( 'Cart Page', 'woo-stripe-payment' ),
|
66 |
+
'mini_cart' => __( 'Mini Cart', 'woo-stripe-payment' ),
|
67 |
'checkout_banner' => __( 'Top of Checkout', 'woo-stripe-payment' ),
|
68 |
),
|
69 |
'default' => array( 'product', 'cart' ),
|
includes/traits/wc-stripe-controller-cart-trait.php
DELETED
@@ -1,28 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
defined( 'ABSPATH' ) || exit();
|
3 |
-
|
4 |
-
/**
|
5 |
-
*
|
6 |
-
* @since 3.1.0
|
7 |
-
* @author Payment Plugins
|
8 |
-
*/
|
9 |
-
trait WC_Stripe_Controller_Cart_Trait {
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Method that hooks in to the woocommerce_cart_ready_to_calc_shipping filter.
|
13 |
-
* Purpose is to ensure
|
14 |
-
* true is returned so shipping packages are calculated. Some 3rd party plugins and themes return false
|
15 |
-
* if the current page is the cart because they don't want to display the shipping calculator.
|
16 |
-
*
|
17 |
-
* @since 3.1.0
|
18 |
-
*/
|
19 |
-
public function add_ready_to_calc_shipping() {
|
20 |
-
add_filter(
|
21 |
-
'woocommerce_cart_ready_to_calc_shipping',
|
22 |
-
function ( $show_shipping ) {
|
23 |
-
return true;
|
24 |
-
},
|
25 |
-
1000
|
26 |
-
);
|
27 |
-
}
|
28 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/traits/wc-stripe-controller-traits.php
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined( 'ABSPATH' ) || exit();
|
3 |
+
|
4 |
+
/**
|
5 |
+
*
|
6 |
+
* @since 3.1.0
|
7 |
+
* @author Payment Plugins
|
8 |
+
*/
|
9 |
+
trait WC_Stripe_Controller_Cart_Trait {
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Method that hooks in to the woocommerce_cart_ready_to_calc_shipping filter.
|
13 |
+
* Purpose is to ensure
|
14 |
+
* true is returned so shipping packages are calculated. Some 3rd party plugins and themes return false
|
15 |
+
* if the current page is the cart because they don't want to display the shipping calculator.
|
16 |
+
*
|
17 |
+
* @since 3.1.0
|
18 |
+
*/
|
19 |
+
public function add_ready_to_calc_shipping() {
|
20 |
+
add_filter(
|
21 |
+
'woocommerce_cart_ready_to_calc_shipping',
|
22 |
+
function ( $show_shipping ) {
|
23 |
+
return true;
|
24 |
+
},
|
25 |
+
1000
|
26 |
+
);
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @param WP_Rest_Request $request
|
31 |
+
*
|
32 |
+
* @return array
|
33 |
+
* @throws Exception
|
34 |
+
* @since 3.1.8
|
35 |
+
*/
|
36 |
+
private function get_shipping_method_from_request( $request ) {
|
37 |
+
if ( ( $method = $request->get_param( 'shipping_method' ) ) ) {
|
38 |
+
if ( ! preg_match( '/^(?P<index>[\w]+)\:(?P<id>.+)$/', $method, $shipping_method ) ) {
|
39 |
+
throw new Exception( __( 'Invalid shipping method format. Expected: index:id', 'woo-stripe-payment' ) );
|
40 |
+
}
|
41 |
+
|
42 |
+
return array( $shipping_method['index'] => $shipping_method['id'] );
|
43 |
+
}
|
44 |
+
|
45 |
+
return array();
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Trait WC_Stripe_Controller_Frontend_Trait
|
51 |
+
* @since 3.1.8
|
52 |
+
*/
|
53 |
+
trait WC_Stripe_Controller_Frontend_Trait {
|
54 |
+
|
55 |
+
protected function cart_includes() {
|
56 |
+
include_once WC_ABSPATH . 'includes/wc-cart-functions.php';
|
57 |
+
include_once WC_ABSPATH . 'includes/wc-notice-functions.php';
|
58 |
+
wc_load_cart();
|
59 |
+
// loads cart from session
|
60 |
+
WC()->cart->get_cart();
|
61 |
+
WC()->payment_gateways();
|
62 |
+
}
|
63 |
+
|
64 |
+
protected function frontend_includes() {
|
65 |
+
WC()->frontend_includes();
|
66 |
+
wc_load_cart();
|
67 |
+
WC()->cart->get_cart();
|
68 |
+
WC()->payment_gateways();
|
69 |
+
}
|
70 |
+
}
|
includes/wc-stripe-functions.php
CHANGED
@@ -364,15 +364,17 @@ function wc_stripe_shipping_address_serviceable() {
|
|
364 |
|
365 |
/**
|
366 |
*
|
367 |
-
* @param
|
368 |
* @param WC_Order $order
|
369 |
*
|
370 |
* @package Stripe/Functions
|
371 |
* @since 3.0.0
|
372 |
*/
|
373 |
-
function wc_stripe_get_display_items( $
|
|
|
|
|
374 |
$items = array();
|
375 |
-
if (
|
376 |
$cart = WC()->cart;
|
377 |
$incl_tax = wc_stripe_display_prices_including_tax();
|
378 |
|
@@ -413,7 +415,7 @@ function wc_stripe_get_display_items( $encode = false, $order = null ) {
|
|
413 |
);
|
414 |
}
|
415 |
// coupons
|
416 |
-
if ( $cart->discount_cart
|
417 |
$items[] = array(
|
418 |
'label' => __( 'Discount', 'woo-stripe-payment' ),
|
419 |
'pending' => false,
|
@@ -435,7 +437,16 @@ function wc_stripe_get_display_items( $encode = false, $order = null ) {
|
|
435 |
$items[] = $item;
|
436 |
}
|
437 |
}
|
438 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
439 |
$currency = $order->get_currency();
|
440 |
// add all order items
|
441 |
foreach ( $order->get_items() as $item ) {
|
@@ -452,7 +463,7 @@ function wc_stripe_get_display_items( $encode = false, $order = null ) {
|
|
452 |
);
|
453 |
}
|
454 |
// shipping total
|
455 |
-
if ( $order->get_shipping_total() ) {
|
456 |
$items[] = array(
|
457 |
'label' => __( 'Shipping', 'woo-stripe-payment' ),
|
458 |
'pending' => false,
|
@@ -460,14 +471,14 @@ function wc_stripe_get_display_items( $encode = false, $order = null ) {
|
|
460 |
);
|
461 |
}
|
462 |
// discount total
|
463 |
-
if ( $order->get_total_discount() ) {
|
464 |
$items[] = array(
|
465 |
'label' => __( 'Discount', 'woo-stripe-payment' ),
|
466 |
'pending' => false,
|
467 |
-
'amount' => wc_stripe_add_number_precision( $order->get_total_discount(), $currency ),
|
468 |
);
|
469 |
}
|
470 |
-
if ( $order->get_fees() ) {
|
471 |
$fee_total = 0;
|
472 |
foreach ( $order->get_fees() as $fee ) {
|
473 |
$fee_total += $fee->get_total();
|
@@ -479,7 +490,7 @@ function wc_stripe_get_display_items( $encode = false, $order = null ) {
|
|
479 |
);
|
480 |
}
|
481 |
// tax total
|
482 |
-
if ( $order->get_total_tax() ) {
|
483 |
$items[] = array(
|
484 |
'label' => __( 'Tax', 'woocommerce' ),
|
485 |
'pending' => false,
|
@@ -487,9 +498,12 @@ function wc_stripe_get_display_items( $encode = false, $order = null ) {
|
|
487 |
);
|
488 |
}
|
489 |
}
|
490 |
-
$items = apply_filters( 'wc_stripe_get_display_items', $items, $order );
|
491 |
|
492 |
-
|
|
|
|
|
|
|
|
|
493 |
}
|
494 |
|
495 |
/**
|
@@ -501,67 +515,53 @@ function wc_stripe_get_display_items( $encode = false, $order = null ) {
|
|
501 |
* @package Stripe/Functions
|
502 |
* @since 3.0.0
|
503 |
*/
|
504 |
-
function wc_stripe_get_shipping_options( $
|
505 |
-
$methods
|
506 |
-
$incl_tax
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
foreach ( $
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
$
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
if ( $
|
524 |
-
|
525 |
-
$method['detail'] = WC()->countries->inc_tax_or_vat();
|
526 |
-
}
|
527 |
-
} else {
|
528 |
-
if ( $rate->get_shipping_tax() > 0 && wc_prices_include_tax() ) {
|
529 |
-
$method['detail'] = WC()->countries->ex_tax_or_vat();
|
530 |
-
}
|
531 |
}
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
// Stripe always shows the first shipping option as selected. Make sure the chosen method
|
536 |
-
// is first in the array.
|
537 |
-
if ( isset( $chosen_shipping_methods[ $i ] ) ) {
|
538 |
-
$index = array_search( $chosen_shipping_methods[ $i ], $ids );
|
539 |
-
if ( $index != 0 ) {
|
540 |
-
$temp = $methods[0];
|
541 |
-
$methods[0] = $methods[ $index ];
|
542 |
-
$methods[ $index ] = $temp;
|
543 |
}
|
544 |
}
|
|
|
|
|
|
|
|
|
545 |
}
|
546 |
-
|
547 |
-
*
|
548 |
-
*
|
549 |
-
* $methods[] = [ 'id' => 'default',
|
550 |
-
* 'label' => __ ( 'Waiting...', 'woo-stripe-payment' ),
|
551 |
-
* 'detail' => __ ( 'loading shipping methods...', 'woo-stripe-payment' ),
|
552 |
-
* 'amount' => 0
|
553 |
-
* ];
|
554 |
-
* }
|
555 |
*/
|
|
|
|
|
|
|
556 |
}
|
|
|
557 |
/**
|
558 |
*
|
559 |
* @param array $methods
|
560 |
* @param WC_Order $orer
|
561 |
*/
|
562 |
-
|
563 |
-
|
564 |
-
return $encode ? htmlspecialchars( wp_json_encode( $methods ) ) : $methods;
|
565 |
}
|
566 |
|
567 |
/**
|
@@ -1243,3 +1243,23 @@ function wc_stripe_remove_order_locks() {
|
|
1243 |
}
|
1244 |
}
|
1245 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
364 |
|
365 |
/**
|
366 |
*
|
367 |
+
* @param string $page
|
368 |
* @param WC_Order $order
|
369 |
*
|
370 |
* @package Stripe/Functions
|
371 |
* @since 3.0.0
|
372 |
*/
|
373 |
+
function wc_stripe_get_display_items( $page = 'cart', $order = null ) {
|
374 |
+
// first argument used to be $encode param so make sure it's a string now
|
375 |
+
$page = false === $page ? 'cart' : $page;
|
376 |
$items = array();
|
377 |
+
if ( in_array( $page, array( 'cart', 'checkout' ) ) ) {
|
378 |
$cart = WC()->cart;
|
379 |
$incl_tax = wc_stripe_display_prices_including_tax();
|
380 |
|
415 |
);
|
416 |
}
|
417 |
// coupons
|
418 |
+
if ( 0 < $cart->discount_cart ) {
|
419 |
$items[] = array(
|
420 |
'label' => __( 'Discount', 'woo-stripe-payment' ),
|
421 |
'pending' => false,
|
437 |
$items[] = $item;
|
438 |
}
|
439 |
}
|
440 |
+
} elseif ( 'product' === $page ) {
|
441 |
+
global $product;
|
442 |
+
$items[] = array(
|
443 |
+
'amount' => wc_stripe_add_number_precision( $product->get_price() ),
|
444 |
+
'label' => esc_attr( $product->get_name() ),
|
445 |
+
'pending' => true,
|
446 |
+
);
|
447 |
+
} elseif ( 'order_pay' === $page ) {
|
448 |
+
global $wp;
|
449 |
+
$order = ! $order ? wc_get_order( absint( $wp->query_vars['order-pay'] ) ) : $order;
|
450 |
$currency = $order->get_currency();
|
451 |
// add all order items
|
452 |
foreach ( $order->get_items() as $item ) {
|
463 |
);
|
464 |
}
|
465 |
// shipping total
|
466 |
+
if ( 0 < $order->get_shipping_total() ) {
|
467 |
$items[] = array(
|
468 |
'label' => __( 'Shipping', 'woo-stripe-payment' ),
|
469 |
'pending' => false,
|
471 |
);
|
472 |
}
|
473 |
// discount total
|
474 |
+
if ( 0 < $order->get_total_discount() ) {
|
475 |
$items[] = array(
|
476 |
'label' => __( 'Discount', 'woo-stripe-payment' ),
|
477 |
'pending' => false,
|
478 |
+
'amount' => wc_stripe_add_number_precision( - 1 * $order->get_total_discount(), $currency ),
|
479 |
);
|
480 |
}
|
481 |
+
if ( 0 < $order->get_fees() ) {
|
482 |
$fee_total = 0;
|
483 |
foreach ( $order->get_fees() as $fee ) {
|
484 |
$fee_total += $fee->get_total();
|
490 |
);
|
491 |
}
|
492 |
// tax total
|
493 |
+
if ( 0 < $order->get_total_tax() ) {
|
494 |
$items[] = array(
|
495 |
'label' => __( 'Tax', 'woocommerce' ),
|
496 |
'pending' => false,
|
498 |
);
|
499 |
}
|
500 |
}
|
|
|
501 |
|
502 |
+
/**
|
503 |
+
* @param array $items
|
504 |
+
* @param WC_Order $order
|
505 |
+
*/
|
506 |
+
return apply_filters( 'wc_stripe_get_display_items', $items, $order );
|
507 |
}
|
508 |
|
509 |
/**
|
515 |
* @package Stripe/Functions
|
516 |
* @since 3.0.0
|
517 |
*/
|
518 |
+
function wc_stripe_get_shipping_options( $order = null ) {
|
519 |
+
$methods = array();
|
520 |
+
$incl_tax = wc_stripe_display_prices_including_tax();
|
521 |
+
$ids = array();
|
522 |
+
$chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods', array() );
|
523 |
+
$packages = WC()->shipping()->get_packages();
|
524 |
+
foreach ( $packages as $i => $package ) {
|
525 |
+
foreach ( $package['rates'] as $rate ) {
|
526 |
+
/**
|
527 |
+
*
|
528 |
+
* @var WC_Shipping_Rate $rate
|
529 |
+
*/
|
530 |
+
$method = array(
|
531 |
+
'id' => sprintf( '%s:%s', $i, $rate->id ),
|
532 |
+
'label' => sprintf( '%s', esc_attr( $rate->get_label() ) ),
|
533 |
+
'detail' => '',
|
534 |
+
'amount' => wc_stripe_add_number_precision( $incl_tax ? $rate->cost + $rate->get_shipping_tax() : $rate->cost ),
|
535 |
+
);
|
536 |
+
if ( $incl_tax ) {
|
537 |
+
if ( $rate->get_shipping_tax() > 0 && ! wc_prices_include_tax() ) {
|
538 |
+
$method['detail'] = WC()->countries->inc_tax_or_vat();
|
|
|
|
|
|
|
|
|
|
|
|
|
539 |
}
|
540 |
+
} else {
|
541 |
+
if ( $rate->get_shipping_tax() > 0 && wc_prices_include_tax() ) {
|
542 |
+
$method['detail'] = WC()->countries->ex_tax_or_vat();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
543 |
}
|
544 |
}
|
545 |
+
$methods[] = $method;
|
546 |
+
if ( isset( $chosen_shipping_methods[ $i ] ) && $chosen_shipping_methods[ $i ] === $rate->id ) {
|
547 |
+
$ids[] = $method['id'];
|
548 |
+
}
|
549 |
}
|
550 |
+
/**
|
551 |
+
* Sort the shipping methods so that the selected method is always first
|
552 |
+
* in the array.
|
|
|
|
|
|
|
|
|
|
|
|
|
553 |
*/
|
554 |
+
usort( $methods, function ( $a, $b ) use ( $ids ) {
|
555 |
+
return in_array( $a['id'], $ids ) ? - 1 : 1;
|
556 |
+
} );
|
557 |
}
|
558 |
+
|
559 |
/**
|
560 |
*
|
561 |
* @param array $methods
|
562 |
* @param WC_Order $orer
|
563 |
*/
|
564 |
+
return apply_filters( 'wc_stripe_get_shipping_options', $methods, $order );
|
|
|
|
|
565 |
}
|
566 |
|
567 |
/**
|
1243 |
}
|
1244 |
}
|
1245 |
}
|
1246 |
+
|
1247 |
+
/**
|
1248 |
+
* Returns an array of checkout fields needed to complete an order.
|
1249 |
+
* @return array
|
1250 |
+
* @since 3.1.8
|
1251 |
+
*/
|
1252 |
+
function wc_stripe_get_checkout_fields() {
|
1253 |
+
$fields = array();
|
1254 |
+
foreach ( array( 'billing', 'shipping' ) as $key ) {
|
1255 |
+
if ( ( $field_set = WC()->checkout()->get_checkout_fields( $key ) ) ) {
|
1256 |
+
$fields = array_merge( $fields, $field_set );
|
1257 |
+
}
|
1258 |
+
}
|
1259 |
+
// loop through fields and assign their value to the field.
|
1260 |
+
array_walk( $fields, function ( &$field, $key ) {
|
1261 |
+
$field['value'] = WC()->checkout()->get_value( $key );
|
1262 |
+
} );
|
1263 |
+
|
1264 |
+
return $fields;
|
1265 |
+
}
|
includes/wc-stripe-webhook-functions.php
CHANGED
@@ -119,7 +119,7 @@ function wc_stripe_process_payment_intent_succeeded( $intent, $request ) {
|
|
119 |
sleep( 1 );
|
120 |
|
121 |
if ( $payment_method->has_order_lock( $order ) || ( $transaction_id = $order->get_transaction_id() ) ) {
|
122 |
-
wc_stripe_log_info( sprintf( 'payment_intent.succeeded event received. Intent has been completed
|
123 |
|
124 |
return;
|
125 |
}
|
119 |
sleep( 1 );
|
120 |
|
121 |
if ( $payment_method->has_order_lock( $order ) || ( $transaction_id = $order->get_transaction_id() ) ) {
|
122 |
+
wc_stripe_log_info( sprintf( 'payment_intent.succeeded event received. Intent has been completed for order %s. Event exited.', $order->get_id() ) );
|
123 |
|
124 |
return;
|
125 |
}
|
readme.txt
CHANGED
@@ -2,9 +2,9 @@
|
|
2 |
Contributors: mr.clayton
|
3 |
Tags: stripe, ach, klarna, credit card, apple pay, google pay, ideal, sepa, sofort
|
4 |
Requires at least: 3.0.1
|
5 |
-
Tested up to: 5.
|
6 |
Requires PHP: 5.6
|
7 |
-
Stable tag: 3.1.
|
8 |
Copyright: Payment Plugins
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
@@ -58,6 +58,14 @@ If you're site is not loading over https, then Stripe won't render the Payment R
|
|
58 |
8. Edit payment gateways on the product page
|
59 |
|
60 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
= 3.1.7 =
|
62 |
* Fixed - SEPA payment flow
|
63 |
* Added - BECS payment method
|
2 |
Contributors: mr.clayton
|
3 |
Tags: stripe, ach, klarna, credit card, apple pay, google pay, ideal, sepa, sofort
|
4 |
Requires at least: 3.0.1
|
5 |
+
Tested up to: 5.5
|
6 |
Requires PHP: 5.6
|
7 |
+
Stable tag: 3.1.8
|
8 |
Copyright: Payment Plugins
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
58 |
8. Edit payment gateways on the product page
|
59 |
|
60 |
== Changelog ==
|
61 |
+
= 3.1.8 =
|
62 |
+
* Fixed - Do not redirect to order received page if customer has not completed local payment process
|
63 |
+
* Fixed - Disable Apple Pay button on variation product when no default product is selected
|
64 |
+
* Added - Mini-cart integration for GPay and Apple Pay.
|
65 |
+
* Added - Filter wc_stripe_get_source_args added
|
66 |
+
* Added - Email validation for local payment methods
|
67 |
+
* Added - WC tested up to: 4.3.2
|
68 |
+
* Updated - Stripe PHP lib version 7.45.0
|
69 |
= 3.1.7 =
|
70 |
* Fixed - SEPA payment flow
|
71 |
* Added - BECS payment method
|
stripe-payments.php
CHANGED
@@ -3,30 +3,31 @@
|
|
3 |
* Plugin Name: Stripe For WooCommerce
|
4 |
* Plugin URI: https://docs.paymentplugins.com/wc-stripe/config/
|
5 |
* Description: Accept credit cards, Google Pay, Apple Pay, ACH, Klarna and more using Stripe.
|
6 |
-
* Version: 3.1.
|
7 |
* Author: Payment Plugins, support@paymentplugins.com
|
8 |
* Text Domain: woo-stripe-payment
|
9 |
* Domain Path: /i18n/languages/
|
10 |
-
* Tested up to: 5.
|
11 |
* WC requires at least: 3.0.0
|
12 |
-
* WC tested up to: 4.3.
|
13 |
*/
|
14 |
-
defined
|
15 |
|
16 |
function wc_stripe_php_version_notice() {
|
17 |
-
$message = sprintf
|
18 |
echo '<div class="notice notice-error"><p style="font-size: 16px">' . $message . '</p></div>';
|
19 |
}
|
20 |
|
21 |
-
if (version_compare
|
22 |
-
add_action
|
|
|
23 |
return;
|
24 |
}
|
25 |
|
26 |
-
define
|
27 |
-
define
|
28 |
-
define
|
29 |
-
|
30 |
// include main plugin file.
|
31 |
-
require_once
|
32 |
-
require_once
|
3 |
* Plugin Name: Stripe For WooCommerce
|
4 |
* Plugin URI: https://docs.paymentplugins.com/wc-stripe/config/
|
5 |
* Description: Accept credit cards, Google Pay, Apple Pay, ACH, Klarna and more using Stripe.
|
6 |
+
* Version: 3.1.8
|
7 |
* Author: Payment Plugins, support@paymentplugins.com
|
8 |
* Text Domain: woo-stripe-payment
|
9 |
* Domain Path: /i18n/languages/
|
10 |
+
* Tested up to: 5.5
|
11 |
* WC requires at least: 3.0.0
|
12 |
+
* WC tested up to: 4.3.2
|
13 |
*/
|
14 |
+
defined( 'ABSPATH' ) || exit ();
|
15 |
|
16 |
function wc_stripe_php_version_notice() {
|
17 |
+
$message = sprintf( __( 'Your PHP version is %s but Stripe requires version 5.6+.', 'woo-stripe-payment' ), PHP_VERSION );
|
18 |
echo '<div class="notice notice-error"><p style="font-size: 16px">' . $message . '</p></div>';
|
19 |
}
|
20 |
|
21 |
+
if ( version_compare( PHP_VERSION, '5.6', '<' ) ) {
|
22 |
+
add_action( 'admin_init', 'wc_stripe_php_version_notice' );
|
23 |
+
|
24 |
return;
|
25 |
}
|
26 |
|
27 |
+
define( 'WC_STRIPE_PLUGIN_FILE_PATH', plugin_dir_path( __FILE__ ) );
|
28 |
+
define( 'WC_STRIPE_ASSETS', plugin_dir_url( __FILE__ ) . 'assets/' );
|
29 |
+
define( 'WC_STRIPE_PLUGIN_NAME', plugin_basename( __FILE__ ) );
|
30 |
+
|
31 |
// include main plugin file.
|
32 |
+
require_once( WC_STRIPE_PLUGIN_FILE_PATH . 'includes/class-stripe.php' );
|
33 |
+
require_once( WC_STRIPE_PLUGIN_FILE_PATH . 'vendor/autoload.php' );
|
templates/cart/googlepay.php
CHANGED
@@ -4,6 +4,4 @@
|
|
4 |
* @var WC_Payment_Gateway_Stripe $gateway
|
5 |
*/
|
6 |
?>
|
7 |
-
<div id="wc-stripe-googlepay-container">
|
8 |
-
<?php $gateway->output_display_items()?>
|
9 |
-
</div>
|
4 |
* @var WC_Payment_Gateway_Stripe $gateway
|
5 |
*/
|
6 |
?>
|
7 |
+
<div id="wc-stripe-googlepay-container"></div>
|
|
|
|
templates/cart/payment-methods.php
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
*/
|
7 |
?>
|
8 |
<div class="wc-stripe-cart-checkout-container" <?php if($cart_total == 0){?>style="display: none"<?php }?>>
|
9 |
-
<ul class="wc_stripe_cart_payment_methods">
|
10 |
<?php if($after):?>
|
11 |
<li class="wc-stripe-payment-method or">
|
12 |
<p class="wc-stripe-cart-or">
|
@@ -19,7 +19,7 @@
|
|
19 |
class="wc-stripe-payment-method payment_method_<?php echo esc_attr($gateway->id)?>">
|
20 |
<div class="payment-box">
|
21 |
<?php $gateway->cart_fields()?>
|
22 |
-
|
23 |
</li>
|
24 |
<?php endforeach;?>
|
25 |
<?php if(!$after):?>
|
6 |
*/
|
7 |
?>
|
8 |
<div class="wc-stripe-cart-checkout-container" <?php if($cart_total == 0){?>style="display: none"<?php }?>>
|
9 |
+
<ul class="wc_stripe_cart_payment_methods" style="list-style: none">
|
10 |
<?php if($after):?>
|
11 |
<li class="wc-stripe-payment-method or">
|
12 |
<p class="wc-stripe-cart-or">
|
19 |
class="wc-stripe-payment-method payment_method_<?php echo esc_attr($gateway->id)?>">
|
20 |
<div class="payment-box">
|
21 |
<?php $gateway->cart_fields()?>
|
22 |
+
</div>
|
23 |
</li>
|
24 |
<?php endforeach;?>
|
25 |
<?php if(!$after):?>
|
templates/checkout/checkout-banner.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
?>
|
8 |
<div class="wc-stripe-banner-checkout">
|
9 |
<span class="banner-title"><?php _e('Express Checkout', 'woo-stripe-payment')?></span>
|
10 |
-
<ul class="wc_stripe_checkout_banner_gateways">
|
11 |
<?php foreach($gateways as $gateway):?>
|
12 |
<li class="wc-stripe-checkout-banner-gateway banner_payment_method_<?php echo $gateway->id?>">
|
13 |
|
7 |
?>
|
8 |
<div class="wc-stripe-banner-checkout">
|
9 |
<span class="banner-title"><?php _e('Express Checkout', 'woo-stripe-payment')?></span>
|
10 |
+
<ul class="wc_stripe_checkout_banner_gateways" style="list-style: none">
|
11 |
<?php foreach($gateways as $gateway):?>
|
12 |
<li class="wc-stripe-checkout-banner-gateway banner_payment_method_<?php echo $gateway->id?>">
|
13 |
|
templates/checkout/googlepay.php
CHANGED
@@ -4,6 +4,4 @@
|
|
4 |
* @var WC_Payment_Gateway_Stripe $gateway
|
5 |
*/
|
6 |
?>
|
7 |
-
<div id="wc-stripe-googlepay-container">
|
8 |
-
<?php $gateway->output_display_items()?>
|
9 |
-
</div>
|
4 |
* @var WC_Payment_Gateway_Stripe $gateway
|
5 |
*/
|
6 |
?>
|
7 |
+
<div id="wc-stripe-googlepay-container"></div>
|
|
|
|
templates/mini-cart/applepay.php
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @version 3.1.8
|
4 |
+
*
|
5 |
+
* @var WC_Payment_Gateway_Stripe $gateway
|
6 |
+
*/
|
7 |
+
?>
|
8 |
+
<div class="wc-stripe-applepay-mini-cart"></div>
|
templates/mini-cart/googlepay.php
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @version 3.1.8
|
4 |
+
*/
|
5 |
+
?>
|
6 |
+
<div class="wc-stripe-gpay-mini-cart"></div>
|
templates/mini-cart/payment-methods.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @version 3.1.8
|
4 |
+
* @var WC_Payment_Gateway_Stripe[] $gateways
|
5 |
+
*/
|
6 |
+
?>
|
7 |
+
<ul class="wc-stripe-mini-cart-payment-methods">
|
8 |
+
<?php foreach ( $gateways as $gateway ) : ?>
|
9 |
+
<li class="payment_method_<?php echo $gateway->id ?>">
|
10 |
+
<?php $gateway->mini_cart_fields() ?>
|
11 |
+
</li>
|
12 |
+
<?php endforeach; ?>
|
13 |
+
</ul>
|
14 |
+
|
15 |
+
|
templates/mini-cart/payment-request.php
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @version 3.1.8
|
4 |
+
*/
|
5 |
+
?>
|
6 |
+
<div class="wc-stripe-payment-request-mini-cart"></div>
|
templates/product/googlepay.php
CHANGED
@@ -4,6 +4,4 @@
|
|
4 |
* @var WC_Payment_Gateway_Stripe_GooglePay $gateway
|
5 |
*/
|
6 |
?>
|
7 |
-
<div id="wc-stripe-googlepay-container">
|
8 |
-
<?php $gateway->output_display_items()?>
|
9 |
-
</div>
|
4 |
* @var WC_Payment_Gateway_Stripe_GooglePay $gateway
|
5 |
*/
|
6 |
?>
|
7 |
+
<div id="wc-stripe-googlepay-container"></div>
|
|
|
|
templates/product/payment-methods.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
?>
|
6 |
<div class="wc-stripe-clear"></div>
|
7 |
<div class="wc-stripe-product-checkout-container <?php echo $position?>">
|
8 |
-
<ul class="wc_stripe_product_payment_methods">
|
9 |
<?php foreach($gateways as $gateway):?>
|
10 |
<li class="payment_method_<?php echo esc_attr($gateway->id)?>">
|
11 |
<div class="payment-box">
|
5 |
?>
|
6 |
<div class="wc-stripe-clear"></div>
|
7 |
<div class="wc-stripe-product-checkout-container <?php echo $position?>">
|
8 |
+
<ul class="wc_stripe_product_payment_methods" style="list-style: none">
|
9 |
<?php foreach($gateways as $gateway):?>
|
10 |
<li class="payment_method_<?php echo esc_attr($gateway->id)?>">
|
11 |
<div class="payment-box">
|
vendor/composer/installed.json
CHANGED
@@ -1,17 +1,17 @@
|
|
1 |
[
|
2 |
{
|
3 |
"name": "stripe/stripe-php",
|
4 |
-
"version": "v7.
|
5 |
-
"version_normalized": "7.
|
6 |
"source": {
|
7 |
"type": "git",
|
8 |
"url": "https://github.com/stripe/stripe-php.git",
|
9 |
-
"reference": "
|
10 |
},
|
11 |
"dist": {
|
12 |
"type": "zip",
|
13 |
-
"url": "https://api.github.com/repos/stripe/stripe-php/zipball/
|
14 |
-
"reference": "
|
15 |
"shasum": ""
|
16 |
},
|
17 |
"require": {
|
@@ -27,7 +27,7 @@
|
|
27 |
"squizlabs/php_codesniffer": "^3.3",
|
28 |
"symfony/process": "~3.4"
|
29 |
},
|
30 |
-
"time": "2020-07-
|
31 |
"type": "library",
|
32 |
"extra": {
|
33 |
"branch-alias": {
|
1 |
[
|
2 |
{
|
3 |
"name": "stripe/stripe-php",
|
4 |
+
"version": "v7.45.0",
|
5 |
+
"version_normalized": "7.45.0.0",
|
6 |
"source": {
|
7 |
"type": "git",
|
8 |
"url": "https://github.com/stripe/stripe-php.git",
|
9 |
+
"reference": "21e5001f5e0d787e4755c8bfc00e578dce9ae058"
|
10 |
},
|
11 |
"dist": {
|
12 |
"type": "zip",
|
13 |
+
"url": "https://api.github.com/repos/stripe/stripe-php/zipball/21e5001f5e0d787e4755c8bfc00e578dce9ae058",
|
14 |
+
"reference": "21e5001f5e0d787e4755c8bfc00e578dce9ae058",
|
15 |
"shasum": ""
|
16 |
},
|
17 |
"require": {
|
27 |
"squizlabs/php_codesniffer": "^3.3",
|
28 |
"symfony/process": "~3.4"
|
29 |
},
|
30 |
+
"time": "2020-07-29T04:29:52+00:00",
|
31 |
"type": "library",
|
32 |
"extra": {
|
33 |
"branch-alias": {
|
vendor/stripe/stripe-php/CHANGELOG.md
CHANGED
@@ -1,5 +1,23 @@
|
|
1 |
# Changelog
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
## 7.40.0 - 2020-07-06
|
4 |
* [#964](https://github.com/stripe/stripe-php/pull/964) Add OAuthService
|
5 |
|
1 |
# Changelog
|
2 |
|
3 |
+
## 7.45.0 - 2020-07-28
|
4 |
+
* [#981](https://github.com/stripe/stripe-php/pull/981) PHPdoc updates
|
5 |
+
|
6 |
+
## 7.44.0 - 2020-07-20
|
7 |
+
* [#948](https://github.com/stripe/stripe-php/pull/948) Add `first()` and `last()` functions to `Collection`
|
8 |
+
|
9 |
+
## 7.43.0 - 2020-07-17
|
10 |
+
* [#975](https://github.com/stripe/stripe-php/pull/975) Add support for `political_exposure` on `Person`
|
11 |
+
|
12 |
+
## 7.42.0 - 2020-07-15
|
13 |
+
* [#974](https://github.com/stripe/stripe-php/pull/974) Add new constants for `purpose` on `File`
|
14 |
+
|
15 |
+
## 7.41.1 - 2020-07-15
|
16 |
+
* [#973](https://github.com/stripe/stripe-php/pull/973) Multiple PHPDoc fixes
|
17 |
+
|
18 |
+
## 7.41.0 - 2020-07-14
|
19 |
+
* [#971](https://github.com/stripe/stripe-php/pull/971) Adds enum values for `billing_address_collection` on Checkout `Session`
|
20 |
+
|
21 |
## 7.40.0 - 2020-07-06
|
22 |
* [#964](https://github.com/stripe/stripe-php/pull/964) Add OAuthService
|
23 |
|
vendor/stripe/stripe-php/VERSION
CHANGED
@@ -1 +1 @@
|
|
1 |
-
7.
|
1 |
+
7.45.0
|
vendor/stripe/stripe-php/lib/Card.php
CHANGED
@@ -37,7 +37,7 @@ namespace Stripe;
|
|
37 |
* @property \Stripe\StripeObject $metadata Set of <a href="https://stripe.com/docs/api/metadata">key-value pairs</a> that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
|
38 |
* @property null|string $name Cardholder name.
|
39 |
* @property null|string|\Stripe\Recipient $recipient The recipient that this card belongs to. This attribute will not be in the card object if the card belongs to a customer or account instead.
|
40 |
-
* @property null|string $tokenization_method If the card number is tokenized, this is the method that was used. Can be <code>
|
41 |
*/
|
42 |
class Card extends ApiResource
|
43 |
{
|
37 |
* @property \Stripe\StripeObject $metadata Set of <a href="https://stripe.com/docs/api/metadata">key-value pairs</a> that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
|
38 |
* @property null|string $name Cardholder name.
|
39 |
* @property null|string|\Stripe\Recipient $recipient The recipient that this card belongs to. This attribute will not be in the card object if the card belongs to a customer or account instead.
|
40 |
+
* @property null|string $tokenization_method If the card number is tokenized, this is the method that was used. Can be <code>android_pay</code> (includes Google Pay), <code>apple_pay</code>, <code>masterpass</code>, <code>visa_checkout</code>, or null.
|
41 |
*/
|
42 |
class Card extends ApiResource
|
43 |
{
|
vendor/stripe/stripe-php/lib/Checkout/Session.php
CHANGED
@@ -22,9 +22,12 @@ namespace Stripe\Checkout;
|
|
22 |
*
|
23 |
* @property string $id Unique identifier for the object. Used to pass to <code>redirectToCheckout</code> in Stripe.js.
|
24 |
* @property string $object String representing the object's type. Objects of the same type share the same value.
|
25 |
-
* @property null|
|
|
|
|
|
26 |
* @property string $cancel_url The URL the customer will be directed to if they decide to cancel payment and return to your website.
|
27 |
* @property null|string $client_reference_id A unique string to reference the Checkout Session. This can be a customer ID, a cart ID, or similar, and can be used to reconcile the session with your internal systems.
|
|
|
28 |
* @property null|string|\Stripe\Customer $customer The ID of the customer for this session. For Checkout Sessions in <code>payment</code> or <code>subscription</code> mode, Checkout will create a new customer object based on information provided during the session unless an existing customer was provided when the session was created.
|
29 |
* @property null|string $customer_email If provided, this value will be used when the Customer object is created. If not provided, customers will be asked to enter their email address. Use this parameter to prefill customer data if you already have an email on file. To access information about the customer once a session is complete, use the <code>customer</code> attribute.
|
30 |
* @property \Stripe\StripeObject[] $display_items The line items, plans, or SKUs purchased by the customer. Prefer using <code>line_items</code>.
|
@@ -41,6 +44,7 @@ namespace Stripe\Checkout;
|
|
41 |
* @property null|string $submit_type Describes the type of transaction being performed by Checkout in order to customize relevant text on the page, such as the submit button. <code>submit_type</code> can only be specified on Checkout Sessions in <code>payment</code> mode, but not Checkout Sessions in <code>subscription</code> or <code>setup</code> mode.
|
42 |
* @property null|string|\Stripe\Subscription $subscription The ID of the subscription for Checkout Sessions in <code>subscription</code> mode.
|
43 |
* @property string $success_url The URL the customer will be directed to after the payment or subscription creation is successful.
|
|
|
44 |
*/
|
45 |
class Session extends \Stripe\ApiResource
|
46 |
{
|
@@ -51,6 +55,9 @@ class Session extends \Stripe\ApiResource
|
|
51 |
use \Stripe\ApiOperations\NestedResource;
|
52 |
use \Stripe\ApiOperations\Retrieve;
|
53 |
|
|
|
|
|
|
|
54 |
const SUBMIT_TYPE_AUTO = 'auto';
|
55 |
const SUBMIT_TYPE_BOOK = 'book';
|
56 |
const SUBMIT_TYPE_DONATE = 'donate';
|
22 |
*
|
23 |
* @property string $id Unique identifier for the object. Used to pass to <code>redirectToCheckout</code> in Stripe.js.
|
24 |
* @property string $object String representing the object's type. Objects of the same type share the same value.
|
25 |
+
* @property null|int $amount_subtotal Total of all items before discounts or taxes are applied.
|
26 |
+
* @property null|int $amount_total Total of all items after discounts and taxes are applied.
|
27 |
+
* @property null|string $billing_address_collection Describes whether Checkout should collect the customer's billing address.
|
28 |
* @property string $cancel_url The URL the customer will be directed to if they decide to cancel payment and return to your website.
|
29 |
* @property null|string $client_reference_id A unique string to reference the Checkout Session. This can be a customer ID, a cart ID, or similar, and can be used to reconcile the session with your internal systems.
|
30 |
+
* @property null|string $currency Three-letter <a href="https://www.iso.org/iso-4217-currency-codes.html">ISO currency code</a>, in lowercase. Must be a <a href="https://stripe.com/docs/currencies">supported currency</a>.
|
31 |
* @property null|string|\Stripe\Customer $customer The ID of the customer for this session. For Checkout Sessions in <code>payment</code> or <code>subscription</code> mode, Checkout will create a new customer object based on information provided during the session unless an existing customer was provided when the session was created.
|
32 |
* @property null|string $customer_email If provided, this value will be used when the Customer object is created. If not provided, customers will be asked to enter their email address. Use this parameter to prefill customer data if you already have an email on file. To access information about the customer once a session is complete, use the <code>customer</code> attribute.
|
33 |
* @property \Stripe\StripeObject[] $display_items The line items, plans, or SKUs purchased by the customer. Prefer using <code>line_items</code>.
|
44 |
* @property null|string $submit_type Describes the type of transaction being performed by Checkout in order to customize relevant text on the page, such as the submit button. <code>submit_type</code> can only be specified on Checkout Sessions in <code>payment</code> mode, but not Checkout Sessions in <code>subscription</code> or <code>setup</code> mode.
|
45 |
* @property null|string|\Stripe\Subscription $subscription The ID of the subscription for Checkout Sessions in <code>subscription</code> mode.
|
46 |
* @property string $success_url The URL the customer will be directed to after the payment or subscription creation is successful.
|
47 |
+
* @property null|\Stripe\StripeObject $total_details Tax and discount details for the computed total amount.
|
48 |
*/
|
49 |
class Session extends \Stripe\ApiResource
|
50 |
{
|
55 |
use \Stripe\ApiOperations\NestedResource;
|
56 |
use \Stripe\ApiOperations\Retrieve;
|
57 |
|
58 |
+
const BILLING_ADDRESS_COLLECTION_AUTO = 'auto';
|
59 |
+
const BILLING_ADDRESS_COLLECTION_REQUIRED = 'required';
|
60 |
+
|
61 |
const SUBMIT_TYPE_AUTO = 'auto';
|
62 |
const SUBMIT_TYPE_BOOK = 'book';
|
63 |
const SUBMIT_TYPE_DONATE = 'donate';
|
vendor/stripe/stripe-php/lib/Collection.php
CHANGED
@@ -241,6 +241,26 @@ class Collection extends StripeObject implements \Countable, \IteratorAggregate
|
|
241 |
return $this->all($params, $opts);
|
242 |
}
|
243 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
244 |
private function extractPathAndUpdateParams($params)
|
245 |
{
|
246 |
$url = \parse_url($this->url);
|
241 |
return $this->all($params, $opts);
|
242 |
}
|
243 |
|
244 |
+
/**
|
245 |
+
* Gets the first item from the current page. Returns `null` if the current page is empty.
|
246 |
+
*
|
247 |
+
* @return null|\Stripe\StripeObject
|
248 |
+
*/
|
249 |
+
public function first()
|
250 |
+
{
|
251 |
+
return \count($this->data) > 0 ? $this->data[0] : null;
|
252 |
+
}
|
253 |
+
|
254 |
+
/**
|
255 |
+
* Gets the last item from the current page. Returns `null` if the current page is empty.
|
256 |
+
*
|
257 |
+
* @return null|\Stripe\StripeObject
|
258 |
+
*/
|
259 |
+
public function last()
|
260 |
+
{
|
261 |
+
return \count($this->data) > 0 ? $this->data[\count($this->data) - 1] : null;
|
262 |
+
}
|
263 |
+
|
264 |
private function extractPathAndUpdateParams($params)
|
265 |
{
|
266 |
$url = \parse_url($this->url);
|
vendor/stripe/stripe-php/lib/CreditNote.php
CHANGED
@@ -16,7 +16,8 @@ namespace Stripe;
|
|
16 |
* @property string $currency Three-letter <a href="https://www.iso.org/iso-4217-currency-codes.html">ISO currency code</a>, in lowercase. Must be a <a href="https://stripe.com/docs/currencies">supported currency</a>.
|
17 |
* @property string|\Stripe\Customer $customer ID of the customer.
|
18 |
* @property null|string|\Stripe\CustomerBalanceTransaction $customer_balance_transaction Customer balance transaction related to this credit note.
|
19 |
-
* @property int $discount_amount The integer amount in <strong>%s</strong> representing the amount of
|
|
|
20 |
* @property string|\Stripe\Invoice $invoice ID of the invoice.
|
21 |
* @property \Stripe\Collection $lines Line items that make up the credit note
|
22 |
* @property bool $livemode Has the value <code>true</code> if the object exists in live mode or the value <code>false</code> if the object exists in test mode.
|
@@ -28,9 +29,9 @@ namespace Stripe;
|
|
28 |
* @property null|string $reason Reason for issuing this credit note, one of <code>duplicate</code>, <code>fraudulent</code>, <code>order_change</code>, or <code>product_unsatisfactory</code>
|
29 |
* @property null|string|\Stripe\Refund $refund Refund related to this credit note.
|
30 |
* @property string $status Status of this credit note, one of <code>issued</code> or <code>void</code>. Learn more about <a href="https://stripe.com/docs/billing/invoices/credit-notes#voiding">voiding credit notes</a>.
|
31 |
-
* @property int $subtotal The integer amount in <strong>%s</strong> representing the amount of the credit note, excluding tax and
|
32 |
* @property \Stripe\StripeObject[] $tax_amounts The aggregate amounts calculated per tax rate for all line items.
|
33 |
-
* @property int $total The integer amount in <strong>%s</strong> representing the total amount of the credit note, including tax and discount.
|
34 |
* @property string $type Type of this credit note, one of <code>pre_payment</code> or <code>post_payment</code>. A <code>pre_payment</code> credit note means it was issued when the invoice was open. A <code>post_payment</code> credit note means it was issued when the invoice was paid.
|
35 |
* @property null|int $voided_at The time that the credit note was voided.
|
36 |
*/
|
16 |
* @property string $currency Three-letter <a href="https://www.iso.org/iso-4217-currency-codes.html">ISO currency code</a>, in lowercase. Must be a <a href="https://stripe.com/docs/currencies">supported currency</a>.
|
17 |
* @property string|\Stripe\Customer $customer ID of the customer.
|
18 |
* @property null|string|\Stripe\CustomerBalanceTransaction $customer_balance_transaction Customer balance transaction related to this credit note.
|
19 |
+
* @property int $discount_amount The integer amount in <strong>%s</strong> representing the total amount of discount that was credited.
|
20 |
+
* @property \Stripe\StripeObject[] $discount_amounts The aggregate amounts calculated per discount for all line items.
|
21 |
* @property string|\Stripe\Invoice $invoice ID of the invoice.
|
22 |
* @property \Stripe\Collection $lines Line items that make up the credit note
|
23 |
* @property bool $livemode Has the value <code>true</code> if the object exists in live mode or the value <code>false</code> if the object exists in test mode.
|
29 |
* @property null|string $reason Reason for issuing this credit note, one of <code>duplicate</code>, <code>fraudulent</code>, <code>order_change</code>, or <code>product_unsatisfactory</code>
|
30 |
* @property null|string|\Stripe\Refund $refund Refund related to this credit note.
|
31 |
* @property string $status Status of this credit note, one of <code>issued</code> or <code>void</code>. Learn more about <a href="https://stripe.com/docs/billing/invoices/credit-notes#voiding">voiding credit notes</a>.
|
32 |
+
* @property int $subtotal The integer amount in <strong>%s</strong> representing the amount of the credit note, excluding tax and invoice level discounts.
|
33 |
* @property \Stripe\StripeObject[] $tax_amounts The aggregate amounts calculated per tax rate for all line items.
|
34 |
+
* @property int $total The integer amount in <strong>%s</strong> representing the total amount of the credit note, including tax and all discount.
|
35 |
* @property string $type Type of this credit note, one of <code>pre_payment</code> or <code>post_payment</code>. A <code>pre_payment</code> credit note means it was issued when the invoice was open. A <code>post_payment</code> credit note means it was issued when the invoice was paid.
|
36 |
* @property null|int $voided_at The time that the credit note was voided.
|
37 |
*/
|
vendor/stripe/stripe-php/lib/CreditNoteLineItem.php
CHANGED
@@ -8,6 +8,7 @@ namespace Stripe;
|
|
8 |
* @property int $amount The integer amount in <strong>%s</strong> representing the gross amount being credited for this line item, excluding (exclusive) tax and discounts.
|
9 |
* @property null|string $description Description of the item being credited.
|
10 |
* @property int $discount_amount The integer amount in <strong>%s</strong> representing the discount being credited for this line item.
|
|
|
11 |
* @property string $invoice_line_item ID of the invoice line item being credited
|
12 |
* @property bool $livemode Has the value <code>true</code> if the object exists in live mode or the value <code>false</code> if the object exists in test mode.
|
13 |
* @property null|int $quantity The number of units of product being credited.
|
8 |
* @property int $amount The integer amount in <strong>%s</strong> representing the gross amount being credited for this line item, excluding (exclusive) tax and discounts.
|
9 |
* @property null|string $description Description of the item being credited.
|
10 |
* @property int $discount_amount The integer amount in <strong>%s</strong> representing the discount being credited for this line item.
|
11 |
+
* @property \Stripe\StripeObject[] $discount_amounts The amount of discount calculated per discount for this line item
|
12 |
* @property string $invoice_line_item ID of the invoice line item being credited
|
13 |
* @property bool $livemode Has the value <code>true</code> if the object exists in live mode or the value <code>false</code> if the object exists in test mode.
|
14 |
* @property null|int $quantity The number of units of product being credited.
|
vendor/stripe/stripe-php/lib/Customer.php
CHANGED
@@ -33,7 +33,7 @@ namespace Stripe;
|
|
33 |
* @property null|string[] $preferred_locales The customer's preferred locales (languages), ordered by preference.
|
34 |
* @property null|\Stripe\StripeObject $shipping Mailing and shipping address for the customer. Appears on invoices emailed to this customer.
|
35 |
* @property \Stripe\Collection $sources The customer's payment sources, if any.
|
36 |
-
* @property
|
37 |
* @property null|string $tax_exempt Describes the customer's tax exemption status. One of <code>none</code>, <code>exempt</code>, or <code>reverse</code>. When set to <code>reverse</code>, invoice and receipt PDFs include the text <strong>"Reverse charge"</strong>.
|
38 |
* @property \Stripe\Collection $tax_ids The customer's tax IDs.
|
39 |
*/
|
33 |
* @property null|string[] $preferred_locales The customer's preferred locales (languages), ordered by preference.
|
34 |
* @property null|\Stripe\StripeObject $shipping Mailing and shipping address for the customer. Appears on invoices emailed to this customer.
|
35 |
* @property \Stripe\Collection $sources The customer's payment sources, if any.
|
36 |
+
* @property null|\Stripe\Collection $subscriptions The customer's current subscriptions, if any.
|
37 |
* @property null|string $tax_exempt Describes the customer's tax exemption status. One of <code>none</code>, <code>exempt</code>, or <code>reverse</code>. When set to <code>reverse</code>, invoice and receipt PDFs include the text <strong>"Reverse charge"</strong>.
|
38 |
* @property \Stripe\Collection $tax_ids The customer's tax IDs.
|
39 |
*/
|
vendor/stripe/stripe-php/lib/Event.php
CHANGED
@@ -24,7 +24,7 @@ namespace Stripe;
|
|
24 |
* We also have a separate <a
|
25 |
* href="http://en.wikipedia.org/wiki/Webhook">webhooks</a> system for sending the
|
26 |
* <code>Event</code> objects directly to an endpoint on your server. Webhooks are
|
27 |
-
* managed in your <a href="https://dashboard.stripe.com/account/webhooks
|
28 |
* settings</a>, and our <a href="https://stripe.com/docs/webhooks">Using
|
29 |
* Webhooks</a> guide will help you get set up.
|
30 |
*
|
24 |
* We also have a separate <a
|
25 |
* href="http://en.wikipedia.org/wiki/Webhook">webhooks</a> system for sending the
|
26 |
* <code>Event</code> objects directly to an endpoint on your server. Webhooks are
|
27 |
+
* managed in your <a href="https://dashboard.stripe.com/account/webhooks">account
|
28 |
* settings</a>, and our <a href="https://stripe.com/docs/webhooks">Using
|
29 |
* Webhooks</a> guide will help you get set up.
|
30 |
*
|
vendor/stripe/stripe-php/lib/File.php
CHANGED
@@ -18,7 +18,7 @@ namespace Stripe;
|
|
18 |
* @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
|
19 |
* @property null|string $filename A filename for the file, suitable for saving to a filesystem.
|
20 |
* @property null|\Stripe\Collection $links A list of <a href="https://stripe.com/docs/api#file_links">file links</a> that point at this file.
|
21 |
-
* @property string $purpose The
|
22 |
* @property int $size The size in bytes of the file object.
|
23 |
* @property null|string $title A user friendly title for the document.
|
24 |
* @property null|string $type The type of the file returned (e.g., <code>csv</code>, <code>pdf</code>, <code>jpg</code>, or <code>png</code>).
|
@@ -31,6 +31,15 @@ class File extends ApiResource
|
|
31 |
use ApiOperations\All;
|
32 |
use ApiOperations\Retrieve;
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
// This resource can have two different object names. In latter API
|
35 |
// versions, only `file` is used, but since stripe-php may be used with
|
36 |
// any API version, we need to support deserializing the older
|
18 |
* @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
|
19 |
* @property null|string $filename A filename for the file, suitable for saving to a filesystem.
|
20 |
* @property null|\Stripe\Collection $links A list of <a href="https://stripe.com/docs/api#file_links">file links</a> that point at this file.
|
21 |
+
* @property string $purpose The <a href="https://stripe.com/docs/file-upload#uploading-a-file">purpose</a> of the uploaded file.
|
22 |
* @property int $size The size in bytes of the file object.
|
23 |
* @property null|string $title A user friendly title for the document.
|
24 |
* @property null|string $type The type of the file returned (e.g., <code>csv</code>, <code>pdf</code>, <code>jpg</code>, or <code>png</code>).
|
31 |
use ApiOperations\All;
|
32 |
use ApiOperations\Retrieve;
|
33 |
|
34 |
+
const PURPOSE_ADDITIONAL_VERIFICATION = 'additional_verification';
|
35 |
+
const PURPOSE_BUSINESS_ICON = 'business_icon';
|
36 |
+
const PURPOSE_BUSINESS_LOGO = 'business_logo';
|
37 |
+
const PURPOSE_CUSTOMER_SIGNATURE = 'customer_signature';
|
38 |
+
const PURPOSE_DISPUTE_EVIDENCE = 'dispute_evidence';
|
39 |
+
const PURPOSE_IDENTITY_DOCUMENT = 'identity_document';
|
40 |
+
const PURPOSE_PCI_DOCUMENT = 'pci_document';
|
41 |
+
const PURPOSE_TAX_DOCUMENT_USER_UPLOAD = 'tax_document_user_upload';
|
42 |
+
|
43 |
// This resource can have two different object names. In latter API
|
44 |
// versions, only `file` is used, but since stripe-php may be used with
|
45 |
// any API version, we need to support deserializing the older
|
vendor/stripe/stripe-php/lib/Invoice.php
CHANGED
@@ -69,6 +69,7 @@ namespace Stripe;
|
|
69 |
* @property null|\Stripe\TaxRate[] $default_tax_rates The tax rates applied to this invoice, if any.
|
70 |
* @property null|string $description An arbitrary string attached to the object. Often useful for displaying to users. Referenced as 'memo' in the Dashboard.
|
71 |
* @property null|\Stripe\Discount $discount Describes the current discount applied to this invoice, if there is one.
|
|
|
72 |
* @property null|int $due_date The date on which payment for this invoice is due. This value will be <code>null</code> for invoices where <code>collection_method=charge_automatically</code>.
|
73 |
* @property null|int $ending_balance Ending customer balance after the invoice is finalized. Invoices are finalized approximately an hour after successful webhook delivery or when payment collection is attempted for the invoice. If the invoice has not been finalized yet, this will be null.
|
74 |
* @property null|string $footer Footer displayed on the invoice.
|
@@ -92,11 +93,12 @@ namespace Stripe;
|
|
92 |
* @property \Stripe\StripeObject $status_transitions
|
93 |
* @property null|string|\Stripe\Subscription $subscription The subscription that this invoice was prepared for, if any.
|
94 |
* @property int $subscription_proration_date Only set for upcoming invoices that preview prorations. The time used to calculate prorations.
|
95 |
-
* @property int $subtotal Total of all subscriptions, invoice items, and prorations on the invoice before any discount or tax is applied.
|
96 |
* @property null|int $tax The amount of tax on this invoice. This is the sum of all the tax amounts on this invoice.
|
97 |
* @property null|float $tax_percent This percentage of the subtotal has been added to the total amount of the invoice, including invoice line items and discounts. This field is inherited from the subscription's <code>tax_percent</code> field, but can be changed before the invoice is paid. This field defaults to null.
|
98 |
* @property \Stripe\StripeObject $threshold_reason
|
99 |
* @property int $total Total after discounts and taxes.
|
|
|
100 |
* @property null|\Stripe\StripeObject[] $total_tax_amounts The aggregate amounts calculated per tax rate for all line items.
|
101 |
* @property null|int $webhooks_delivered_at Invoices are automatically paid or sent 1 hour after webhooks are delivered, or until all webhook delivery attempts have <a href="https://stripe.com/docs/billing/webhooks#understand">been exhausted</a>. This field tracks the time when webhooks for this invoice were successfully delivered. If the invoice had no webhooks to deliver, this will be set while the invoice is being created.
|
102 |
*/
|
69 |
* @property null|\Stripe\TaxRate[] $default_tax_rates The tax rates applied to this invoice, if any.
|
70 |
* @property null|string $description An arbitrary string attached to the object. Often useful for displaying to users. Referenced as 'memo' in the Dashboard.
|
71 |
* @property null|\Stripe\Discount $discount Describes the current discount applied to this invoice, if there is one.
|
72 |
+
* @property null|(string|\Stripe\Discount)[] $discounts The discounts applied to the invoice. Line item discounts are applied before invoice discounts. Use <code>expand[]=discounts</code> to expand each discount.
|
73 |
* @property null|int $due_date The date on which payment for this invoice is due. This value will be <code>null</code> for invoices where <code>collection_method=charge_automatically</code>.
|
74 |
* @property null|int $ending_balance Ending customer balance after the invoice is finalized. Invoices are finalized approximately an hour after successful webhook delivery or when payment collection is attempted for the invoice. If the invoice has not been finalized yet, this will be null.
|
75 |
* @property null|string $footer Footer displayed on the invoice.
|
93 |
* @property \Stripe\StripeObject $status_transitions
|
94 |
* @property null|string|\Stripe\Subscription $subscription The subscription that this invoice was prepared for, if any.
|
95 |
* @property int $subscription_proration_date Only set for upcoming invoices that preview prorations. The time used to calculate prorations.
|
96 |
+
* @property int $subtotal Total of all subscriptions, invoice items, and prorations on the invoice before any invoice level discount or tax is applied. Item discounts are already incorporated
|
97 |
* @property null|int $tax The amount of tax on this invoice. This is the sum of all the tax amounts on this invoice.
|
98 |
* @property null|float $tax_percent This percentage of the subtotal has been added to the total amount of the invoice, including invoice line items and discounts. This field is inherited from the subscription's <code>tax_percent</code> field, but can be changed before the invoice is paid. This field defaults to null.
|
99 |
* @property \Stripe\StripeObject $threshold_reason
|
100 |
* @property int $total Total after discounts and taxes.
|
101 |
+
* @property null|\Stripe\StripeObject[] $total_discount_amounts The aggregate amounts calculated per discount across all line items.
|
102 |
* @property null|\Stripe\StripeObject[] $total_tax_amounts The aggregate amounts calculated per tax rate for all line items.
|
103 |
* @property null|int $webhooks_delivered_at Invoices are automatically paid or sent 1 hour after webhooks are delivered, or until all webhook delivery attempts have <a href="https://stripe.com/docs/billing/webhooks#understand">been exhausted</a>. This field tracks the time when webhooks for this invoice were successfully delivered. If the invoice had no webhooks to deliver, this will be set while the invoice is being created.
|
104 |
*/
|
vendor/stripe/stripe-php/lib/InvoiceItem.php
CHANGED
@@ -20,6 +20,7 @@ namespace Stripe;
|
|
20 |
* @property int $date Time at which the object was created. Measured in seconds since the Unix epoch.
|
21 |
* @property null|string $description An arbitrary string attached to the object. Often useful for displaying to users.
|
22 |
* @property bool $discountable If true, discounts will apply to this invoice item. Always false for prorations.
|
|
|
23 |
* @property null|string|\Stripe\Invoice $invoice The ID of the invoice this invoice item belongs to.
|
24 |
* @property bool $livemode Has the value <code>true</code> if the object exists in live mode or the value <code>false</code> if the object exists in test mode.
|
25 |
* @property \Stripe\StripeObject $metadata Set of <a href="https://stripe.com/docs/api/metadata">key-value pairs</a> that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
|
20 |
* @property int $date Time at which the object was created. Measured in seconds since the Unix epoch.
|
21 |
* @property null|string $description An arbitrary string attached to the object. Often useful for displaying to users.
|
22 |
* @property bool $discountable If true, discounts will apply to this invoice item. Always false for prorations.
|
23 |
+
* @property null|(string|\Stripe\Discount)[] $discounts The discounts which apply to the invoice item. Item discounts are applied before invoice discounts. Use <code>expand[]=discounts</code> to expand each discount.
|
24 |
* @property null|string|\Stripe\Invoice $invoice The ID of the invoice this invoice item belongs to.
|
25 |
* @property bool $livemode Has the value <code>true</code> if the object exists in live mode or the value <code>false</code> if the object exists in test mode.
|
26 |
* @property \Stripe\StripeObject $metadata Set of <a href="https://stripe.com/docs/api/metadata">key-value pairs</a> that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
|
vendor/stripe/stripe-php/lib/InvoiceLineItem.php
CHANGED
@@ -8,7 +8,9 @@ namespace Stripe;
|
|
8 |
* @property int $amount The amount, in %s.
|
9 |
* @property string $currency Three-letter <a href="https://www.iso.org/iso-4217-currency-codes.html">ISO currency code</a>, in lowercase. Must be a <a href="https://stripe.com/docs/currencies">supported currency</a>.
|
10 |
* @property null|string $description An arbitrary string attached to the object. Often useful for displaying to users.
|
|
|
11 |
* @property bool $discountable If true, discounts will apply to this line item. Always false for prorations.
|
|
|
12 |
* @property string $invoice_item The ID of the <a href="https://stripe.com/docs/api/invoiceitems">invoice item</a> associated with this line item if any.
|
13 |
* @property bool $livemode Has the value <code>true</code> if the object exists in live mode or the value <code>false</code> if the object exists in test mode.
|
14 |
* @property \Stripe\StripeObject $metadata Set of <a href="https://stripe.com/docs/api/metadata">key-value pairs</a> that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Note that for line items with <code>type=subscription</code> this will reflect the metadata of the subscription that caused the line item to be created.
|
8 |
* @property int $amount The amount, in %s.
|
9 |
* @property string $currency Three-letter <a href="https://www.iso.org/iso-4217-currency-codes.html">ISO currency code</a>, in lowercase. Must be a <a href="https://stripe.com/docs/currencies">supported currency</a>.
|
10 |
* @property null|string $description An arbitrary string attached to the object. Often useful for displaying to users.
|
11 |
+
* @property null|\Stripe\StripeObject[] $discount_amounts The amount of discount calculated per discount for this line item.
|
12 |
* @property bool $discountable If true, discounts will apply to this line item. Always false for prorations.
|
13 |
+
* @property null|(string|\Stripe\Discount)[] $discounts The discounts applied to the invoice line item. Line item discounts are applied before invoice discounts. Use <code>expand[]=discounts</code> to expand each discount.
|
14 |
* @property string $invoice_item The ID of the <a href="https://stripe.com/docs/api/invoiceitems">invoice item</a> associated with this line item if any.
|
15 |
* @property bool $livemode Has the value <code>true</code> if the object exists in live mode or the value <code>false</code> if the object exists in test mode.
|
16 |
* @property \Stripe\StripeObject $metadata Set of <a href="https://stripe.com/docs/api/metadata">key-value pairs</a> that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Note that for line items with <code>type=subscription</code> this will reflect the metadata of the subscription that caused the line item to be created.
|
vendor/stripe/stripe-php/lib/Issuing/Cardholder.php
CHANGED
@@ -22,7 +22,7 @@ namespace Stripe\Issuing;
|
|
22 |
* @property string $name The cardholder's name. This will be printed on cards issued to them.
|
23 |
* @property null|string $phone_number The cardholder's phone number.
|
24 |
* @property \Stripe\StripeObject $requirements
|
25 |
-
* @property null|\Stripe\StripeObject $spending_controls
|
26 |
* @property string $status Specifies whether to permit authorizations on this cardholder's cards.
|
27 |
* @property string $type One of <code>individual</code> or <code>company</code>.
|
28 |
*/
|
22 |
* @property string $name The cardholder's name. This will be printed on cards issued to them.
|
23 |
* @property null|string $phone_number The cardholder's phone number.
|
24 |
* @property \Stripe\StripeObject $requirements
|
25 |
+
* @property null|\Stripe\StripeObject $spending_controls Rules that control spending across this cardholder's cards. Refer to our <a href="https://stripe.com/docs/issuing/controls/spending-controls">documentation</a> for more details.
|
26 |
* @property string $status Specifies whether to permit authorizations on this cardholder's cards.
|
27 |
* @property string $type One of <code>individual</code> or <code>company</code>.
|
28 |
*/
|
vendor/stripe/stripe-php/lib/PaymentIntent.php
CHANGED
@@ -42,7 +42,7 @@ namespace Stripe;
|
|
42 |
* @property null|string|\Stripe\PaymentMethod $payment_method ID of the payment method used in this PaymentIntent.
|
43 |
* @property null|\Stripe\StripeObject $payment_method_options Payment-method-specific configuration for this PaymentIntent.
|
44 |
* @property string[] $payment_method_types The list of payment method types (e.g. card) that this PaymentIntent is allowed to use.
|
45 |
-
* @property null|string $receipt_email Email address that the receipt for the resulting payment will be sent to.
|
46 |
* @property null|string|\Stripe\Review $review ID of the review associated with this PaymentIntent, if any.
|
47 |
* @property null|string $setup_future_usage <p>Indicates that you intend to make future payments with this PaymentIntent's payment method.</p><p>Providing this parameter will <a href="https://stripe.com/docs/payments/save-during-payment">attach the payment method</a> to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be <a href="https://stripe.com/docs/api/payment_methods/attach">attached</a> to a Customer after the transaction completes.</p><p>When processing card payments, Stripe also uses <code>setup_future_usage</code> to dynamically optimize your payment flow and comply with regional legislation and network rules, such as <a href="https://stripe.com/docs/strong-customer-authentication">SCA</a>.</p>
|
48 |
* @property null|\Stripe\StripeObject $shipping Shipping information for this PaymentIntent.
|
42 |
* @property null|string|\Stripe\PaymentMethod $payment_method ID of the payment method used in this PaymentIntent.
|
43 |
* @property null|\Stripe\StripeObject $payment_method_options Payment-method-specific configuration for this PaymentIntent.
|
44 |
* @property string[] $payment_method_types The list of payment method types (e.g. card) that this PaymentIntent is allowed to use.
|
45 |
+
* @property null|string $receipt_email Email address that the receipt for the resulting payment will be sent to. If <code>receipt_email</code> is specified for a payment in live mode, a receipt will be sent regardless of your <a href="https://dashboard.stripe.com/account/emails">email settings</a>.
|
46 |
* @property null|string|\Stripe\Review $review ID of the review associated with this PaymentIntent, if any.
|
47 |
* @property null|string $setup_future_usage <p>Indicates that you intend to make future payments with this PaymentIntent's payment method.</p><p>Providing this parameter will <a href="https://stripe.com/docs/payments/save-during-payment">attach the payment method</a> to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be <a href="https://stripe.com/docs/api/payment_methods/attach">attached</a> to a Customer after the transaction completes.</p><p>When processing card payments, Stripe also uses <code>setup_future_usage</code> to dynamically optimize your payment flow and comply with regional legislation and network rules, such as <a href="https://stripe.com/docs/strong-customer-authentication">SCA</a>.</p>
|
48 |
* @property null|\Stripe\StripeObject $shipping Shipping information for this PaymentIntent.
|
vendor/stripe/stripe-php/lib/Person.php
CHANGED
@@ -29,6 +29,7 @@ namespace Stripe;
|
|
29 |
* @property null|string $maiden_name The person's maiden name.
|
30 |
* @property \Stripe\StripeObject $metadata Set of <a href="https://stripe.com/docs/api/metadata">key-value pairs</a> that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
|
31 |
* @property null|string $phone The person's phone number.
|
|
|
32 |
* @property \Stripe\StripeObject $relationship
|
33 |
* @property null|\Stripe\StripeObject $requirements Information about the requirements for this person, including what information needs to be collected, and by when.
|
34 |
* @property bool $ssn_last_4_provided Whether the last four digits of the person's Social Security number have been provided (U.S. only).
|
@@ -44,6 +45,9 @@ class Person extends ApiResource
|
|
44 |
const GENDER_FEMALE = 'female';
|
45 |
const GENDER_MALE = 'male';
|
46 |
|
|
|
|
|
|
|
47 |
const VERIFICATION_STATUS_PENDING = 'pending';
|
48 |
const VERIFICATION_STATUS_UNVERIFIED = 'unverified';
|
49 |
const VERIFICATION_STATUS_VERIFIED = 'verified';
|
29 |
* @property null|string $maiden_name The person's maiden name.
|
30 |
* @property \Stripe\StripeObject $metadata Set of <a href="https://stripe.com/docs/api/metadata">key-value pairs</a> that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
|
31 |
* @property null|string $phone The person's phone number.
|
32 |
+
* @property string $political_exposure Indicates if the person or any of their representatives, family members, or other closely related persons, declares that they hold or have held an important public job or function, in any jurisdiction.
|
33 |
* @property \Stripe\StripeObject $relationship
|
34 |
* @property null|\Stripe\StripeObject $requirements Information about the requirements for this person, including what information needs to be collected, and by when.
|
35 |
* @property bool $ssn_last_4_provided Whether the last four digits of the person's Social Security number have been provided (U.S. only).
|
45 |
const GENDER_FEMALE = 'female';
|
46 |
const GENDER_MALE = 'male';
|
47 |
|
48 |
+
const POLITICAL_EXPOSURE_EXISTING = 'existing';
|
49 |
+
const POLITICAL_EXPOSURE_NONE = 'none';
|
50 |
+
|
51 |
const VERIFICATION_STATUS_PENDING = 'pending';
|
52 |
const VERIFICATION_STATUS_UNVERIFIED = 'unverified';
|
53 |
const VERIFICATION_STATUS_VERIFIED = 'verified';
|
vendor/stripe/stripe-php/lib/Recipient.php
CHANGED
@@ -12,10 +12,7 @@ namespace Stripe;
|
|
12 |
* href="https://stripe.com/docs/connect">Connect</a>, specifically Connect's much
|
13 |
* more powerful <a href="https://stripe.com/docs/api#account">Account objects</a>.
|
14 |
* Stripe accounts that don't already use recipients can no longer begin doing so.
|
15 |
-
* Please use <code>Account</code> objects instead
|
16 |
-
* recipients, please see our <a
|
17 |
-
* href="https://stripe.com/docs/connect/recipient-account-migrations">migration
|
18 |
-
* guide</a> for more information.</strong>
|
19 |
*
|
20 |
* @property string $id Unique identifier for the object.
|
21 |
* @property string $object String representing the object's type. Objects of the same type share the same value.
|
12 |
* href="https://stripe.com/docs/connect">Connect</a>, specifically Connect's much
|
13 |
* more powerful <a href="https://stripe.com/docs/api#account">Account objects</a>.
|
14 |
* Stripe accounts that don't already use recipients can no longer begin doing so.
|
15 |
+
* Please use <code>Account</code> objects instead.</strong>
|
|
|
|
|
|
|
16 |
*
|
17 |
* @property string $id Unique identifier for the object.
|
18 |
* @property string $object String representing the object's type. Objects of the same type share the same value.
|
vendor/stripe/stripe-php/lib/Service/PaymentIntentService.php
CHANGED
@@ -22,7 +22,7 @@ class PaymentIntentService extends \Stripe\Service\AbstractService
|
|
22 |
/**
|
23 |
* A PaymentIntent object can be canceled when it is in one of these statuses:
|
24 |
* <code>requires_payment_method</code>, <code>requires_capture</code>,
|
25 |
-
* <code>requires_confirmation</code>, <code>requires_action</code>.
|
26 |
*
|
27 |
* Once canceled, no additional charges will be made by the PaymentIntent and any
|
28 |
* operations on the PaymentIntent will fail with an error. For PaymentIntents with
|
22 |
/**
|
23 |
* A PaymentIntent object can be canceled when it is in one of these statuses:
|
24 |
* <code>requires_payment_method</code>, <code>requires_capture</code>,
|
25 |
+
* <code>requires_confirmation</code>, or <code>requires_action</code>.
|
26 |
*
|
27 |
* Once canceled, no additional charges will be made by the PaymentIntent and any
|
28 |
* operations on the PaymentIntent will fail with an error. For PaymentIntents with
|
vendor/stripe/stripe-php/lib/Service/SetupIntentService.php
CHANGED
@@ -21,8 +21,8 @@ class SetupIntentService extends \Stripe\Service\AbstractService
|
|
21 |
|
22 |
/**
|
23 |
* A SetupIntent object can be canceled when it is in one of these statuses:
|
24 |
-
* <code>requires_payment_method</code>, <code>
|
25 |
-
* <code>
|
26 |
*
|
27 |
* Once canceled, setup is abandoned and any operations on the SetupIntent will
|
28 |
* fail with an error.
|
21 |
|
22 |
/**
|
23 |
* A SetupIntent object can be canceled when it is in one of these statuses:
|
24 |
+
* <code>requires_payment_method</code>, <code>requires_confirmation</code>, or
|
25 |
+
* <code>requires_action</code>.
|
26 |
*
|
27 |
* Once canceled, setup is abandoned and any operations on the SetupIntent will
|
28 |
* fail with an error.
|
vendor/stripe/stripe-php/lib/Service/SubscriptionItemService.php
CHANGED
@@ -23,7 +23,7 @@ class SubscriptionItemService extends \Stripe\Service\AbstractService
|
|
23 |
* For the specified subscription item, returns a list of summary objects. Each
|
24 |
* object in the list provides usage information that’s been summarized from
|
25 |
* multiple usage records and over a subscription billing period (e.g., 15 usage
|
26 |
-
* records in the
|
27 |
*
|
28 |
* The list is sorted in reverse-chronological order (newest first). The first list
|
29 |
* item represents the most current usage period that hasn’t ended yet. Since new
|
23 |
* For the specified subscription item, returns a list of summary objects. Each
|
24 |
* object in the list provides usage information that’s been summarized from
|
25 |
* multiple usage records and over a subscription billing period (e.g., 15 usage
|
26 |
+
* records in the month of September).
|
27 |
*
|
28 |
* The list is sorted in reverse-chronological order (newest first). The first list
|
29 |
* item represents the most current usage period that hasn’t ended yet. Since new
|
vendor/stripe/stripe-php/lib/Stripe.php
CHANGED
@@ -58,7 +58,7 @@ class Stripe
|
|
58 |
/** @var float Initial delay between retries, in seconds */
|
59 |
private static $initialNetworkRetryDelay = 0.5;
|
60 |
|
61 |
-
const VERSION = '7.
|
62 |
|
63 |
/**
|
64 |
* @return string the API key used for requests
|
58 |
/** @var float Initial delay between retries, in seconds */
|
59 |
private static $initialNetworkRetryDelay = 0.5;
|
60 |
|
61 |
+
const VERSION = '7.45.0';
|
62 |
|
63 |
/**
|
64 |
* @return string the API key used for requests
|
vendor/stripe/stripe-php/lib/Subscription.php
CHANGED
@@ -28,7 +28,7 @@ namespace Stripe;
|
|
28 |
* @property null|\Stripe\TaxRate[] $default_tax_rates The tax rates that will apply to any subscription item that does not have <code>tax_rates</code> set. Invoices created will have their <code>default_tax_rates</code> populated from the subscription.
|
29 |
* @property null|\Stripe\Discount $discount Describes the current discount applied to this subscription, if there is one. When billing, a discount applied to a subscription overrides a discount applied on a customer-wide basis.
|
30 |
* @property null|int $ended_at If the subscription has ended, the date the subscription ended.
|
31 |
-
* @property \Stripe\Collection $items List of subscription items, each with an attached
|
32 |
* @property null|string|\Stripe\Invoice $latest_invoice The most recent invoice this subscription has generated.
|
33 |
* @property bool $livemode Has the value <code>true</code> if the object exists in live mode or the value <code>false</code> if the object exists in test mode.
|
34 |
* @property \Stripe\StripeObject $metadata Set of <a href="https://stripe.com/docs/api/metadata">key-value pairs</a> that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
|
28 |
* @property null|\Stripe\TaxRate[] $default_tax_rates The tax rates that will apply to any subscription item that does not have <code>tax_rates</code> set. Invoices created will have their <code>default_tax_rates</code> populated from the subscription.
|
29 |
* @property null|\Stripe\Discount $discount Describes the current discount applied to this subscription, if there is one. When billing, a discount applied to a subscription overrides a discount applied on a customer-wide basis.
|
30 |
* @property null|int $ended_at If the subscription has ended, the date the subscription ended.
|
31 |
+
* @property \Stripe\Collection $items List of subscription items, each with an attached price.
|
32 |
* @property null|string|\Stripe\Invoice $latest_invoice The most recent invoice this subscription has generated.
|
33 |
* @property bool $livemode Has the value <code>true</code> if the object exists in live mode or the value <code>false</code> if the object exists in test mode.
|
34 |
* @property \Stripe\StripeObject $metadata Set of <a href="https://stripe.com/docs/api/metadata">key-value pairs</a> that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
|
vendor/stripe/stripe-php/lib/SubscriptionSchedule.php
CHANGED
@@ -18,7 +18,7 @@ namespace Stripe;
|
|
18 |
* @property null|\Stripe\StripeObject $current_phase Object representing the start and end dates for the current phase of the subscription schedule, if it is <code>active</code>.
|
19 |
* @property string|\Stripe\Customer $customer ID of the customer who owns the subscription schedule.
|
20 |
* @property \Stripe\StripeObject $default_settings
|
21 |
-
* @property string $end_behavior Behavior of the subscription schedule and underlying subscription when it ends.
|
22 |
* @property bool $livemode Has the value <code>true</code> if the object exists in live mode or the value <code>false</code> if the object exists in test mode.
|
23 |
* @property null|\Stripe\StripeObject $metadata Set of <a href="https://stripe.com/docs/api/metadata">key-value pairs</a> that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
|
24 |
* @property \Stripe\StripeObject[] $phases Configuration for the subscription schedule's phases.
|
18 |
* @property null|\Stripe\StripeObject $current_phase Object representing the start and end dates for the current phase of the subscription schedule, if it is <code>active</code>.
|
19 |
* @property string|\Stripe\Customer $customer ID of the customer who owns the subscription schedule.
|
20 |
* @property \Stripe\StripeObject $default_settings
|
21 |
+
* @property string $end_behavior Behavior of the subscription schedule and underlying subscription when it ends. Possible values are <code>release</code> and <code>cancel</code>.
|
22 |
* @property bool $livemode Has the value <code>true</code> if the object exists in live mode or the value <code>false</code> if the object exists in test mode.
|
23 |
* @property null|\Stripe\StripeObject $metadata Set of <a href="https://stripe.com/docs/api/metadata">key-value pairs</a> that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
|
24 |
* @property \Stripe\StripeObject[] $phases Configuration for the subscription schedule's phases.
|
vendor/stripe/stripe-php/lib/TaxId.php
CHANGED
@@ -14,11 +14,11 @@ namespace Stripe;
|
|
14 |
* @property string $object String representing the object's type. Objects of the same type share the same value.
|
15 |
* @property null|string $country Two-letter ISO code representing the country of the tax ID.
|
16 |
* @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
|
17 |
-
* @property string|\Stripe\Customer $customer ID of the customer.
|
18 |
* @property bool $livemode Has the value <code>true</code> if the object exists in live mode or the value <code>false</code> if the object exists in test mode.
|
19 |
* @property string $type Type of the tax ID, one of <code>ae_trn</code>, <code>au_abn</code>, <code>br_cnpj</code>, <code>br_cpf</code>, <code>ca_bn</code>, <code>ca_qst</code>, <code>ch_vat</code>, <code>cl_tin</code>, <code>es_cif</code>, <code>eu_vat</code>, <code>hk_br</code>, <code>id_npwp</code>, <code>in_gst</code>, <code>jp_cn</code>, <code>kr_brn</code>, <code>li_uid</code>, <code>mx_rfc</code>, <code>my_frp</code>, <code>my_itn</code>, <code>my_sst</code>, <code>no_vat</code>, <code>nz_gst</code>, <code>ru_inn</code>, <code>sa_vat</code>, <code>sg_gst</code>, <code>sg_uen</code>, <code>th_vat</code>, <code>tw_vat</code>, <code>us_ein</code>, or <code>za_vat</code>. Note that some legacy tax IDs have type <code>unknown</code>
|
20 |
* @property string $value Value of the tax ID.
|
21 |
-
* @property
|
22 |
*/
|
23 |
class TaxId extends ApiResource
|
24 |
{
|
14 |
* @property string $object String representing the object's type. Objects of the same type share the same value.
|
15 |
* @property null|string $country Two-letter ISO code representing the country of the tax ID.
|
16 |
* @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
|
17 |
+
* @property null|string|\Stripe\Customer $customer ID of the customer.
|
18 |
* @property bool $livemode Has the value <code>true</code> if the object exists in live mode or the value <code>false</code> if the object exists in test mode.
|
19 |
* @property string $type Type of the tax ID, one of <code>ae_trn</code>, <code>au_abn</code>, <code>br_cnpj</code>, <code>br_cpf</code>, <code>ca_bn</code>, <code>ca_qst</code>, <code>ch_vat</code>, <code>cl_tin</code>, <code>es_cif</code>, <code>eu_vat</code>, <code>hk_br</code>, <code>id_npwp</code>, <code>in_gst</code>, <code>jp_cn</code>, <code>kr_brn</code>, <code>li_uid</code>, <code>mx_rfc</code>, <code>my_frp</code>, <code>my_itn</code>, <code>my_sst</code>, <code>no_vat</code>, <code>nz_gst</code>, <code>ru_inn</code>, <code>sa_vat</code>, <code>sg_gst</code>, <code>sg_uen</code>, <code>th_vat</code>, <code>tw_vat</code>, <code>us_ein</code>, or <code>za_vat</code>. Note that some legacy tax IDs have type <code>unknown</code>
|
20 |
* @property string $value Value of the tax ID.
|
21 |
+
* @property null|\Stripe\StripeObject $verification Tax ID verification information.
|
22 |
*/
|
23 |
class TaxId extends ApiResource
|
24 |
{
|
vendor/stripe/stripe-php/lib/TaxRate.php
CHANGED
@@ -3,14 +3,19 @@
|
|
3 |
namespace Stripe;
|
4 |
|
5 |
/**
|
6 |
-
* Tax rates can be applied to
|
|
|
|
|
|
|
|
|
|
|
7 |
*
|
8 |
* Related guide: <a href="https://stripe.com/docs/billing/taxes/tax-rates">Tax
|
9 |
* Rates</a>.
|
10 |
*
|
11 |
* @property string $id Unique identifier for the object.
|
12 |
* @property string $object String representing the object's type. Objects of the same type share the same value.
|
13 |
-
* @property bool $active Defaults to <code>true</code>. When set to <code>false</code>, this tax rate cannot be
|
14 |
* @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
|
15 |
* @property null|string $description An arbitrary string attached to the tax rate for your internal use only. It will not be visible to your customers.
|
16 |
* @property string $display_name The display name of the tax rates as it will appear to your customer on their receipt email, PDF, and the hosted invoice page.
|
3 |
namespace Stripe;
|
4 |
|
5 |
/**
|
6 |
+
* Tax rates can be applied to <a
|
7 |
+
* href="https://stripe.com/docs/billing/invoices/tax-rates">invoices</a>, <a
|
8 |
+
* href="https://stripe.com/docs/billing/subscriptions/taxes">subscriptions</a> and
|
9 |
+
* <a
|
10 |
+
* href="https://stripe.com/docs/payments/checkout/set-up-a-subscription#tax-rates">Checkout
|
11 |
+
* Sessions</a> to collect tax.
|
12 |
*
|
13 |
* Related guide: <a href="https://stripe.com/docs/billing/taxes/tax-rates">Tax
|
14 |
* Rates</a>.
|
15 |
*
|
16 |
* @property string $id Unique identifier for the object.
|
17 |
* @property string $object String representing the object's type. Objects of the same type share the same value.
|
18 |
+
* @property bool $active Defaults to <code>true</code>. When set to <code>false</code>, this tax rate cannot be used with new applications or Checkout Sessions, but will still work for subscriptions and invoices that already have it set.
|
19 |
* @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
|
20 |
* @property null|string $description An arbitrary string attached to the tax rate for your internal use only. It will not be visible to your customers.
|
21 |
* @property string $display_name The display name of the tax rates as it will appear to your customer on their receipt email, PDF, and the hosted invoice page.
|
vendor/stripe/stripe-php/lib/UsageRecord.php
CHANGED
@@ -4,7 +4,7 @@ namespace Stripe;
|
|
4 |
|
5 |
/**
|
6 |
* Usage records allow you to report customer usage and metrics to Stripe for
|
7 |
-
* metered billing of subscription
|
8 |
*
|
9 |
* Related guide: <a
|
10 |
* href="https://stripe.com/docs/billing/subscriptions/metered-billing">Metered
|
4 |
|
5 |
/**
|
6 |
* Usage records allow you to report customer usage and metrics to Stripe for
|
7 |
+
* metered billing of subscription prices.
|
8 |
*
|
9 |
* Related guide: <a
|
10 |
* href="https://stripe.com/docs/billing/subscriptions/metered-billing">Metered
|