swell-js 3.20.1 → 3.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{api-06903a1c.js → api-3ec9898d.js} +2 -2
- package/dist/api.js +2 -2
- package/dist/{index-1582746d.js → index-11e12022.js} +254 -28
- package/dist/index.js +2 -2
- package/dist/payment.js +1 -1
- package/dist/swell.cjs.js +255 -29
- package/dist/swell.cjs.js.map +1 -1
- package/dist/swell.umd.min.js +511 -310
- package/dist/swell.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/types/index.d.ts +4 -0
- package/types/payment/index.d.ts +76 -54
|
@@ -10,7 +10,7 @@ import { m as methods$6 } from './subscriptions-8044a530.js';
|
|
|
10
10
|
import { d as defaultMethods, n as trimEnd, K as utils, l as trimStart, k as trimBoth, j as toSnake, o as stringifyQuery, E as base64Encode, t as toCamel, e as setOptions } from './index-512fc30d.js';
|
|
11
11
|
import { m as methods$7 } from './content-0afdcb05.js';
|
|
12
12
|
import { m as methods$8 } from './settings-937b96f1.js';
|
|
13
|
-
import { P as PaymentController } from './index-
|
|
13
|
+
import { P as PaymentController } from './index-11e12022.js';
|
|
14
14
|
import { m as methods$9 } from './locale-4391bcf3.js';
|
|
15
15
|
import { m as methods$a } from './currency-842f76f2.js';
|
|
16
16
|
|
|
@@ -34,7 +34,7 @@ const options = {
|
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
const api = {
|
|
37
|
-
version: '3.
|
|
37
|
+
version: '3.21.0',
|
|
38
38
|
options,
|
|
39
39
|
request,
|
|
40
40
|
|
package/dist/api.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { a as default } from './api-
|
|
1
|
+
export { a as default } from './api-3ec9898d.js';
|
|
2
2
|
import './card-91071403.js';
|
|
3
3
|
import './index-512fc30d.js';
|
|
4
4
|
import 'qs';
|
|
@@ -14,6 +14,6 @@ import './categories-8f6a4584.js';
|
|
|
14
14
|
import './subscriptions-8044a530.js';
|
|
15
15
|
import './content-0afdcb05.js';
|
|
16
16
|
import './settings-937b96f1.js';
|
|
17
|
-
import './index-
|
|
17
|
+
import './index-11e12022.js';
|
|
18
18
|
import './locale-4391bcf3.js';
|
|
19
19
|
import './currency-842f76f2.js';
|
|
@@ -14,6 +14,7 @@ const SCRIPT_HANDLERS = {
|
|
|
14
14
|
'braintree-web-paypal-checkout': loadBraintreePaypalCheckout,
|
|
15
15
|
'braintree-google-payment': loadBraintreeGoogle,
|
|
16
16
|
'braintree-apple-payment': loadBraintreeApple,
|
|
17
|
+
'amazon-checkout': loadAmazonCheckout,
|
|
17
18
|
};
|
|
18
19
|
|
|
19
20
|
async function loadStripe() {
|
|
@@ -125,6 +126,19 @@ async function loadBraintreeApple() {
|
|
|
125
126
|
}
|
|
126
127
|
}
|
|
127
128
|
|
|
129
|
+
async function loadAmazonCheckout() {
|
|
130
|
+
if (!window.amazon) {
|
|
131
|
+
await loadScript(
|
|
132
|
+
'amazon-checkout',
|
|
133
|
+
'https://static-na.payments-amazon.com/checkout.js',
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (!window.amazon) {
|
|
138
|
+
console.error('Warning: Amazon Checkout was not loaded');
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
128
142
|
async function loadScripts(scripts) {
|
|
129
143
|
if (!scripts) {
|
|
130
144
|
return;
|
|
@@ -174,6 +188,14 @@ class Payment {
|
|
|
174
188
|
throw new Error('Cart not found');
|
|
175
189
|
}
|
|
176
190
|
|
|
191
|
+
if (!cart.settings) {
|
|
192
|
+
const settings = await this.getSettings();
|
|
193
|
+
|
|
194
|
+
cart.settings = {
|
|
195
|
+
...settings.store,
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
|
|
177
199
|
return toSnake(cart);
|
|
178
200
|
}
|
|
179
201
|
|
|
@@ -616,13 +638,27 @@ class UnableAuthenticatePaymentMethodError extends Error {
|
|
|
616
638
|
}
|
|
617
639
|
}
|
|
618
640
|
|
|
619
|
-
class
|
|
641
|
+
class LibraryNotLoadedError extends Error {
|
|
620
642
|
constructor(library) {
|
|
621
643
|
const message = `${library} was not loaded`;
|
|
622
644
|
super(message);
|
|
623
645
|
}
|
|
624
646
|
}
|
|
625
647
|
|
|
648
|
+
class MethodPropertyMissingError extends Error {
|
|
649
|
+
constructor(method, property) {
|
|
650
|
+
const message = `${method} ${property} is missing`;
|
|
651
|
+
super(message);
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
class DomElementNotFoundError extends Error {
|
|
656
|
+
constructor(elementId) {
|
|
657
|
+
const message = `DOM element with '${elementId}' ID not found`;
|
|
658
|
+
super(message);
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
|
|
626
662
|
class StripeCardPayment extends Payment {
|
|
627
663
|
constructor(request, options, params, methods) {
|
|
628
664
|
super(request, options, params, methods.card);
|
|
@@ -639,7 +675,7 @@ class StripeCardPayment extends Payment {
|
|
|
639
675
|
}
|
|
640
676
|
|
|
641
677
|
if (!StripeCardPayment.stripe) {
|
|
642
|
-
throw new
|
|
678
|
+
throw new LibraryNotLoadedError('Stripe');
|
|
643
679
|
}
|
|
644
680
|
}
|
|
645
681
|
|
|
@@ -805,7 +841,7 @@ class StripeIDealPayment extends Payment {
|
|
|
805
841
|
}
|
|
806
842
|
|
|
807
843
|
if (!StripeIDealPayment.stripe) {
|
|
808
|
-
throw new
|
|
844
|
+
throw new LibraryNotLoadedError('Stripe');
|
|
809
845
|
}
|
|
810
846
|
}
|
|
811
847
|
|
|
@@ -918,7 +954,7 @@ class StripeBancontactPayment extends Payment {
|
|
|
918
954
|
}
|
|
919
955
|
|
|
920
956
|
if (!StripeBancontactPayment.stripe) {
|
|
921
|
-
throw new
|
|
957
|
+
throw new LibraryNotLoadedError('Stripe');
|
|
922
958
|
}
|
|
923
959
|
}
|
|
924
960
|
|
|
@@ -975,7 +1011,7 @@ class StripeKlarnaPayment extends Payment {
|
|
|
975
1011
|
}
|
|
976
1012
|
|
|
977
1013
|
if (!StripeKlarnaPayment.stripe) {
|
|
978
|
-
throw new
|
|
1014
|
+
throw new LibraryNotLoadedError('Stripe');
|
|
979
1015
|
}
|
|
980
1016
|
}
|
|
981
1017
|
|
|
@@ -988,13 +1024,9 @@ class StripeKlarnaPayment extends Payment {
|
|
|
988
1024
|
|
|
989
1025
|
async tokenize() {
|
|
990
1026
|
const cart = await this.getCart();
|
|
991
|
-
const settings = await this.getSettings();
|
|
992
1027
|
const { source, error: sourceError } = await createKlarnaSource(
|
|
993
1028
|
this.stripe,
|
|
994
|
-
|
|
995
|
-
...cart,
|
|
996
|
-
settings: settings.store,
|
|
997
|
-
},
|
|
1029
|
+
cart,
|
|
998
1030
|
);
|
|
999
1031
|
|
|
1000
1032
|
if (sourceError) {
|
|
@@ -1044,7 +1076,7 @@ class StripeGooglePayment extends Payment {
|
|
|
1044
1076
|
|
|
1045
1077
|
get google() {
|
|
1046
1078
|
if (!window.google) {
|
|
1047
|
-
throw new
|
|
1079
|
+
throw new LibraryNotLoadedError('Google');
|
|
1048
1080
|
}
|
|
1049
1081
|
|
|
1050
1082
|
return window.google;
|
|
@@ -1059,7 +1091,7 @@ class StripeGooglePayment extends Payment {
|
|
|
1059
1091
|
}
|
|
1060
1092
|
|
|
1061
1093
|
if (!StripeGooglePayment.googleClient) {
|
|
1062
|
-
throw new
|
|
1094
|
+
throw new LibraryNotLoadedError('Google client');
|
|
1063
1095
|
}
|
|
1064
1096
|
}
|
|
1065
1097
|
|
|
@@ -1171,7 +1203,7 @@ class StripeGooglePayment extends Payment {
|
|
|
1171
1203
|
const container = document.getElementById(elementId);
|
|
1172
1204
|
|
|
1173
1205
|
if (!container) {
|
|
1174
|
-
throw new
|
|
1206
|
+
throw new DomElementNotFoundError(elementId);
|
|
1175
1207
|
}
|
|
1176
1208
|
|
|
1177
1209
|
if (classes.base) {
|
|
@@ -1277,7 +1309,7 @@ class StripeApplePayment extends Payment {
|
|
|
1277
1309
|
}
|
|
1278
1310
|
|
|
1279
1311
|
if (!StripeApplePayment.stripe) {
|
|
1280
|
-
throw new
|
|
1312
|
+
throw new LibraryNotLoadedError('Stripe');
|
|
1281
1313
|
}
|
|
1282
1314
|
}
|
|
1283
1315
|
|
|
@@ -1353,7 +1385,7 @@ class StripeApplePayment extends Payment {
|
|
|
1353
1385
|
const container = document.getElementById(elementId);
|
|
1354
1386
|
|
|
1355
1387
|
if (!container) {
|
|
1356
|
-
throw new
|
|
1388
|
+
throw new DomElementNotFoundError(elementId);
|
|
1357
1389
|
}
|
|
1358
1390
|
|
|
1359
1391
|
const button = this.stripe.elements().create('paymentRequestButton', {
|
|
@@ -1546,7 +1578,7 @@ class BraintreePaypalPayment extends Payment {
|
|
|
1546
1578
|
|
|
1547
1579
|
get paypal() {
|
|
1548
1580
|
if (!window.paypal) {
|
|
1549
|
-
throw new
|
|
1581
|
+
throw new LibraryNotLoadedError('PayPal');
|
|
1550
1582
|
}
|
|
1551
1583
|
|
|
1552
1584
|
return window.paypal;
|
|
@@ -1554,7 +1586,7 @@ class BraintreePaypalPayment extends Payment {
|
|
|
1554
1586
|
|
|
1555
1587
|
get braintree() {
|
|
1556
1588
|
if (!window.braintree) {
|
|
1557
|
-
throw new
|
|
1589
|
+
throw new LibraryNotLoadedError('Braintree');
|
|
1558
1590
|
}
|
|
1559
1591
|
|
|
1560
1592
|
return window.braintree;
|
|
@@ -1562,7 +1594,7 @@ class BraintreePaypalPayment extends Payment {
|
|
|
1562
1594
|
|
|
1563
1595
|
get braintreePaypalCheckout() {
|
|
1564
1596
|
if (!this.braintree.paypalCheckout) {
|
|
1565
|
-
throw new
|
|
1597
|
+
throw new LibraryNotLoadedError('Braintree PayPal Checkout');
|
|
1566
1598
|
}
|
|
1567
1599
|
|
|
1568
1600
|
return this.braintree.paypalCheckout;
|
|
@@ -1650,7 +1682,7 @@ class BraintreeGooglePayment extends Payment {
|
|
|
1650
1682
|
|
|
1651
1683
|
get braintree() {
|
|
1652
1684
|
if (!window.braintree) {
|
|
1653
|
-
throw new
|
|
1685
|
+
throw new LibraryNotLoadedError('Braintree');
|
|
1654
1686
|
}
|
|
1655
1687
|
|
|
1656
1688
|
return window.braintree;
|
|
@@ -1658,7 +1690,7 @@ class BraintreeGooglePayment extends Payment {
|
|
|
1658
1690
|
|
|
1659
1691
|
get google() {
|
|
1660
1692
|
if (!window.google) {
|
|
1661
|
-
throw new
|
|
1693
|
+
throw new LibraryNotLoadedError('Google');
|
|
1662
1694
|
}
|
|
1663
1695
|
|
|
1664
1696
|
return window.google;
|
|
@@ -1673,7 +1705,7 @@ class BraintreeGooglePayment extends Payment {
|
|
|
1673
1705
|
}
|
|
1674
1706
|
|
|
1675
1707
|
if (!BraintreeGooglePayment.googleClient) {
|
|
1676
|
-
throw new
|
|
1708
|
+
throw new LibraryNotLoadedError('Google client');
|
|
1677
1709
|
}
|
|
1678
1710
|
}
|
|
1679
1711
|
|
|
@@ -1789,7 +1821,7 @@ class BraintreeGooglePayment extends Payment {
|
|
|
1789
1821
|
const container = document.getElementById(elementId);
|
|
1790
1822
|
|
|
1791
1823
|
if (!container) {
|
|
1792
|
-
throw new
|
|
1824
|
+
throw new DomElementNotFoundError(elementId);
|
|
1793
1825
|
}
|
|
1794
1826
|
|
|
1795
1827
|
if (classes.base) {
|
|
@@ -1886,7 +1918,7 @@ class BraintreeApplePayment extends Payment {
|
|
|
1886
1918
|
|
|
1887
1919
|
get braintree() {
|
|
1888
1920
|
if (!window.braintree) {
|
|
1889
|
-
throw new
|
|
1921
|
+
throw new LibraryNotLoadedError('Braintree');
|
|
1890
1922
|
}
|
|
1891
1923
|
|
|
1892
1924
|
return window.braintree;
|
|
@@ -1894,7 +1926,7 @@ class BraintreeApplePayment extends Payment {
|
|
|
1894
1926
|
|
|
1895
1927
|
get ApplePaySession() {
|
|
1896
1928
|
if (!window.ApplePaySession) {
|
|
1897
|
-
throw new
|
|
1929
|
+
throw new LibraryNotLoadedError('Apple');
|
|
1898
1930
|
}
|
|
1899
1931
|
|
|
1900
1932
|
return window.ApplePaySession;
|
|
@@ -1926,7 +1958,7 @@ class BraintreeApplePayment extends Payment {
|
|
|
1926
1958
|
const container = document.getElementById(elementId);
|
|
1927
1959
|
|
|
1928
1960
|
if (!container) {
|
|
1929
|
-
throw new
|
|
1961
|
+
throw new DomElementNotFoundError(elementId);
|
|
1930
1962
|
}
|
|
1931
1963
|
|
|
1932
1964
|
if (classes.base) {
|
|
@@ -2391,7 +2423,7 @@ class PaypalDirectPayment extends Payment {
|
|
|
2391
2423
|
|
|
2392
2424
|
get paypal() {
|
|
2393
2425
|
if (!window.paypal) {
|
|
2394
|
-
throw new
|
|
2426
|
+
throw new LibraryNotLoadedError('PayPal');
|
|
2395
2427
|
}
|
|
2396
2428
|
|
|
2397
2429
|
return window.paypal;
|
|
@@ -2472,6 +2504,187 @@ class PaypalDirectPayment extends Payment {
|
|
|
2472
2504
|
}
|
|
2473
2505
|
}
|
|
2474
2506
|
|
|
2507
|
+
class AmazonDirectPayment extends Payment {
|
|
2508
|
+
constructor(request, options, params, methods) {
|
|
2509
|
+
super(request, options, params, methods.amazon);
|
|
2510
|
+
}
|
|
2511
|
+
|
|
2512
|
+
get scripts() {
|
|
2513
|
+
return ['amazon-checkout'];
|
|
2514
|
+
}
|
|
2515
|
+
|
|
2516
|
+
get amazon() {
|
|
2517
|
+
if (!window.amazon) {
|
|
2518
|
+
throw new LibraryNotLoadedError('Amazon');
|
|
2519
|
+
}
|
|
2520
|
+
|
|
2521
|
+
return window.amazon;
|
|
2522
|
+
}
|
|
2523
|
+
|
|
2524
|
+
get merchantId() {
|
|
2525
|
+
const merchantId = this.method.merchant_id;
|
|
2526
|
+
|
|
2527
|
+
if (!merchantId) {
|
|
2528
|
+
throw new MethodPropertyMissingError('Amazon', 'merchant_id');
|
|
2529
|
+
}
|
|
2530
|
+
|
|
2531
|
+
return merchantId;
|
|
2532
|
+
}
|
|
2533
|
+
|
|
2534
|
+
get publicKeyId() {
|
|
2535
|
+
const publicKeyId = this.method.public_key_id;
|
|
2536
|
+
|
|
2537
|
+
if (!publicKeyId) {
|
|
2538
|
+
throw new MethodPropertyMissingError('Amazon', 'public_key_id');
|
|
2539
|
+
}
|
|
2540
|
+
|
|
2541
|
+
return publicKeyId;
|
|
2542
|
+
}
|
|
2543
|
+
|
|
2544
|
+
get returnUrl() {
|
|
2545
|
+
return `${
|
|
2546
|
+
window.location.origin + window.location.pathname
|
|
2547
|
+
}?gateway=amazon`;
|
|
2548
|
+
}
|
|
2549
|
+
|
|
2550
|
+
async createElements() {
|
|
2551
|
+
const cart = await this.getCart();
|
|
2552
|
+
const returnUrl = this.returnUrl;
|
|
2553
|
+
const isSubscription = Boolean(cart.subscription_delivery);
|
|
2554
|
+
const session = await this.authorizeGateway({
|
|
2555
|
+
gateway: 'amazon',
|
|
2556
|
+
params: {
|
|
2557
|
+
chargePermissionType: isSubscription ? 'Recurring' : 'OneTime',
|
|
2558
|
+
...(isSubscription
|
|
2559
|
+
? {
|
|
2560
|
+
recurringMetadata: {
|
|
2561
|
+
frequency: {
|
|
2562
|
+
unit: 'Variable',
|
|
2563
|
+
value: '0',
|
|
2564
|
+
},
|
|
2565
|
+
},
|
|
2566
|
+
}
|
|
2567
|
+
: {}),
|
|
2568
|
+
webCheckoutDetails: {
|
|
2569
|
+
checkoutReviewReturnUrl: `${returnUrl}&redirect_status=succeeded`,
|
|
2570
|
+
checkoutCancelUrl: `${returnUrl}&redirect_status=canceled`,
|
|
2571
|
+
},
|
|
2572
|
+
},
|
|
2573
|
+
});
|
|
2574
|
+
|
|
2575
|
+
this._renderButton(cart, session);
|
|
2576
|
+
}
|
|
2577
|
+
|
|
2578
|
+
async tokenize() {
|
|
2579
|
+
const cart = await this.getCart();
|
|
2580
|
+
const returnUrl = this.returnUrl;
|
|
2581
|
+
const checkoutSessionId = get(cart, 'billing.amazon.checkout_session_id');
|
|
2582
|
+
|
|
2583
|
+
if (!checkoutSessionId) {
|
|
2584
|
+
throw new Error(
|
|
2585
|
+
'Missing Amazon Pay checkout session ID (billing.amazon.checkout_session_id)',
|
|
2586
|
+
);
|
|
2587
|
+
}
|
|
2588
|
+
|
|
2589
|
+
const intent = await this.createIntent({
|
|
2590
|
+
gateway: 'amazon',
|
|
2591
|
+
intent: {
|
|
2592
|
+
checkoutSessionId,
|
|
2593
|
+
webCheckoutDetails: {
|
|
2594
|
+
checkoutResultReturnUrl: `${returnUrl}&confirm=true&redirect_status=succeeded`,
|
|
2595
|
+
checkoutCancelUrl: `${returnUrl}&redirect_status=canceled`,
|
|
2596
|
+
},
|
|
2597
|
+
paymentDetails:
|
|
2598
|
+
cart.capture_total > 0
|
|
2599
|
+
? {
|
|
2600
|
+
paymentIntent: 'Authorize',
|
|
2601
|
+
canHandlePendingAuthorization: true,
|
|
2602
|
+
chargeAmount: {
|
|
2603
|
+
amount: cart.capture_total,
|
|
2604
|
+
currencyCode: cart.currency,
|
|
2605
|
+
},
|
|
2606
|
+
}
|
|
2607
|
+
: {
|
|
2608
|
+
// Just confirm payment to save payment details when capture total amount is 0.
|
|
2609
|
+
// e.g. trial subscription, 100% discount or items.price = 0
|
|
2610
|
+
paymentIntent: 'Confirm',
|
|
2611
|
+
},
|
|
2612
|
+
},
|
|
2613
|
+
});
|
|
2614
|
+
|
|
2615
|
+
return window.location.replace(intent.redirect_url);
|
|
2616
|
+
}
|
|
2617
|
+
|
|
2618
|
+
async handleRedirect(queryParams) {
|
|
2619
|
+
const { redirect_status } = queryParams;
|
|
2620
|
+
|
|
2621
|
+
switch (redirect_status) {
|
|
2622
|
+
case 'succeeded':
|
|
2623
|
+
return this._handleSuccessfulRedirect(queryParams);
|
|
2624
|
+
case 'canceled':
|
|
2625
|
+
throw new UnableAuthenticatePaymentMethodError();
|
|
2626
|
+
default:
|
|
2627
|
+
throw new Error(`Unknown redirect status: ${redirect_status}`);
|
|
2628
|
+
}
|
|
2629
|
+
}
|
|
2630
|
+
|
|
2631
|
+
_renderButton(cart, session) {
|
|
2632
|
+
const amazon = this.amazon;
|
|
2633
|
+
const merchantId = this.merchantId;
|
|
2634
|
+
const publicKeyId = this.publicKeyId;
|
|
2635
|
+
const { payload: payloadJSON, signature } = session;
|
|
2636
|
+
const {
|
|
2637
|
+
elementId = 'amazonpay-button',
|
|
2638
|
+
locale = 'en_US',
|
|
2639
|
+
placement = 'Checkout',
|
|
2640
|
+
style: { color = 'Gold' } = {},
|
|
2641
|
+
require: { shipping: requireShipping } = {},
|
|
2642
|
+
classes = {},
|
|
2643
|
+
} = this.params;
|
|
2644
|
+
|
|
2645
|
+
const container = document.getElementById(elementId);
|
|
2646
|
+
|
|
2647
|
+
if (!container) {
|
|
2648
|
+
throw new DomElementNotFoundError(elementId);
|
|
2649
|
+
}
|
|
2650
|
+
|
|
2651
|
+
amazon.Pay.renderButton(`#${elementId}`, {
|
|
2652
|
+
ledgerCurrency: cart.currency,
|
|
2653
|
+
checkoutLanguage: locale,
|
|
2654
|
+
productType: Boolean(requireShipping) ? 'PayAndShip' : 'PayOnly',
|
|
2655
|
+
buttonColor: color,
|
|
2656
|
+
placement,
|
|
2657
|
+
merchantId,
|
|
2658
|
+
publicKeyId,
|
|
2659
|
+
createCheckoutSessionConfig: {
|
|
2660
|
+
payloadJSON,
|
|
2661
|
+
signature,
|
|
2662
|
+
},
|
|
2663
|
+
});
|
|
2664
|
+
|
|
2665
|
+
if (classes.base) {
|
|
2666
|
+
container.classList.add(classes.base);
|
|
2667
|
+
}
|
|
2668
|
+
}
|
|
2669
|
+
|
|
2670
|
+
async _handleSuccessfulRedirect(queryParams) {
|
|
2671
|
+
const { confirm, amazonCheckoutSessionId } = queryParams;
|
|
2672
|
+
|
|
2673
|
+
if (!confirm) {
|
|
2674
|
+
await this.updateCart({
|
|
2675
|
+
billing: {
|
|
2676
|
+
method: 'amazon',
|
|
2677
|
+
amazon: {
|
|
2678
|
+
checkout_session_id: amazonCheckoutSessionId,
|
|
2679
|
+
},
|
|
2680
|
+
},
|
|
2681
|
+
});
|
|
2682
|
+
}
|
|
2683
|
+
|
|
2684
|
+
this.onSuccess();
|
|
2685
|
+
}
|
|
2686
|
+
}
|
|
2687
|
+
|
|
2475
2688
|
class PaymentController {
|
|
2476
2689
|
constructor(request, options) {
|
|
2477
2690
|
this.request = request;
|
|
@@ -2513,14 +2726,18 @@ class PaymentController {
|
|
|
2513
2726
|
}
|
|
2514
2727
|
|
|
2515
2728
|
async handleRedirect(params = this.params) {
|
|
2729
|
+
const queryParams = getLocationParams(window.location);
|
|
2730
|
+
|
|
2731
|
+
if (!queryParams || !queryParams.gateway) {
|
|
2732
|
+
return;
|
|
2733
|
+
}
|
|
2734
|
+
|
|
2516
2735
|
this.params = params;
|
|
2517
2736
|
|
|
2518
2737
|
if (!params) {
|
|
2519
2738
|
throw new Error('Redirect parameters are not provided');
|
|
2520
2739
|
}
|
|
2521
2740
|
|
|
2522
|
-
const queryParams = getLocationParams(window.location);
|
|
2523
|
-
|
|
2524
2741
|
removeUrlParams();
|
|
2525
2742
|
this._performPaymentAction('handleRedirect', queryParams);
|
|
2526
2743
|
}
|
|
@@ -2686,6 +2903,8 @@ class PaymentController {
|
|
|
2686
2903
|
return this._getGooglePaymentClass(gateway);
|
|
2687
2904
|
case 'apple':
|
|
2688
2905
|
return this._getApplePaymentClass(gateway);
|
|
2906
|
+
case 'amazon':
|
|
2907
|
+
return this._getAmazonPaymentClass(gateway);
|
|
2689
2908
|
default:
|
|
2690
2909
|
return null;
|
|
2691
2910
|
}
|
|
@@ -2768,6 +2987,13 @@ class PaymentController {
|
|
|
2768
2987
|
return null;
|
|
2769
2988
|
}
|
|
2770
2989
|
}
|
|
2990
|
+
|
|
2991
|
+
_getAmazonPaymentClass(gateway) {
|
|
2992
|
+
switch (gateway) {
|
|
2993
|
+
default:
|
|
2994
|
+
return AmazonDirectPayment;
|
|
2995
|
+
}
|
|
2996
|
+
}
|
|
2771
2997
|
}
|
|
2772
2998
|
|
|
2773
2999
|
export { PaymentController as P };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { a as default } from './api-
|
|
1
|
+
export { a as default } from './api-3ec9898d.js';
|
|
2
2
|
import './card-91071403.js';
|
|
3
3
|
import './index-512fc30d.js';
|
|
4
4
|
import 'qs';
|
|
@@ -14,6 +14,6 @@ import './categories-8f6a4584.js';
|
|
|
14
14
|
import './subscriptions-8044a530.js';
|
|
15
15
|
import './content-0afdcb05.js';
|
|
16
16
|
import './settings-937b96f1.js';
|
|
17
|
-
import './index-
|
|
17
|
+
import './index-11e12022.js';
|
|
18
18
|
import './locale-4391bcf3.js';
|
|
19
19
|
import './currency-842f76f2.js';
|
package/dist/payment.js
CHANGED