swell-js 4.2.6 → 5.1.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.mjs +15 -6
- package/dist/attributes.mjs +1 -1
- package/dist/cache.mjs +1 -1
- package/dist/card.mjs +1 -1
- package/dist/cart.mjs +1 -1
- package/dist/categories.mjs +1 -1
- package/dist/content.mjs +1 -1
- package/dist/cookie.mjs +1 -1
- package/dist/{index.a911a674.mjs → index.3c15c4d3.mjs} +1 -1
- package/dist/index.mjs +1 -1
- package/dist/payment.mjs +279 -14
- package/dist/products.mjs +1 -1
- package/dist/settings.mjs +1 -1
- package/dist/subscriptions.mjs +1 -1
- package/dist/swell.cjs +292 -18
- package/dist/swell.cjs.map +1 -1
- package/dist/swell.umd.min.js +292 -18
- package/dist/swell.umd.min.js.map +1 -1
- package/dist/utils/index.mjs +1 -1
- package/package.json +4 -2
- package/types/account/camel.ts +26 -0
- package/types/account/index.ts +26 -0
- package/types/account/{snake.d.ts → snake.ts} +8 -10
- package/types/attribute/camel.ts +15 -0
- package/types/attribute/index.ts +8 -0
- package/types/attribute/{snake.d.ts → snake.ts} +3 -4
- package/types/billing/camel.ts +39 -0
- package/types/billing/index.ts +21 -0
- package/types/billing/{snake.d.ts → snake.ts} +9 -18
- package/types/card/camel.ts +28 -0
- package/types/card/index.ts +26 -0
- package/types/card/{snake.d.ts → snake.ts} +6 -6
- package/types/cart/camel.ts +95 -0
- package/types/cart/index.ts +45 -0
- package/types/cart/{snake.d.ts → snake.ts} +20 -31
- package/types/category/camel.ts +21 -0
- package/types/category/index.ts +8 -0
- package/types/category/{snake.d.ts → snake.ts} +3 -5
- package/types/content/camel.ts +6 -0
- package/types/content/index.ts +8 -0
- package/types/content/{snake.d.ts → snake.ts} +3 -5
- package/types/coupon/camel.ts +15 -0
- package/types/coupon/index.ts +2 -0
- package/types/coupon/{snake.d.ts → snake.ts} +3 -3
- package/types/currency/camel.ts +14 -0
- package/types/currency/index.ts +34 -0
- package/types/currency/{snake.d.ts → snake.ts} +3 -3
- package/types/discount/camel.ts +32 -0
- package/types/discount/index.ts +7 -0
- package/types/discount/{snake.d.ts → snake.ts} +7 -9
- package/types/giftcard/camel.ts +30 -0
- package/types/giftcard/index.ts +2 -0
- package/types/giftcard/{snake.d.ts → snake.ts} +7 -9
- package/types/index.d.ts +407 -405
- package/types/invoice/camel.ts +37 -0
- package/types/invoice/index.ts +8 -0
- package/types/invoice/{snake.d.ts → snake.ts} +11 -11
- package/types/order/camel.ts +79 -0
- package/types/order/index.ts +32 -0
- package/types/order/{snake.d.ts → snake.ts} +18 -26
- package/types/payment/camel.ts +58 -0
- package/types/payment/index.ts +79 -0
- package/types/payment/{snake.d.ts → snake.ts} +16 -21
- package/types/product/camel.ts +86 -0
- package/types/product/index.ts +72 -0
- package/types/product/{snake.d.ts → snake.ts} +12 -23
- package/types/promotion/camel.ts +28 -0
- package/types/promotion/index.ts +2 -0
- package/types/promotion/{snake.d.ts → snake.ts} +6 -8
- package/types/purchase_link/camel.ts +21 -0
- package/types/purchase_link/index.ts +2 -0
- package/types/purchase_link/{snake.d.ts → snake.ts} +6 -6
- package/types/refund/camel.ts +19 -0
- package/types/refund/index.ts +2 -0
- package/types/refund/{snake.d.ts → snake.ts} +5 -5
- package/types/shipment_rating/camel.ts +15 -0
- package/types/shipment_rating/index.ts +2 -0
- package/types/shipment_rating/{snake.d.ts → snake.ts} +2 -4
- package/types/subscription/camel.ts +61 -0
- package/types/subscription/index.ts +28 -0
- package/types/subscription/{snake.d.ts → snake.ts} +14 -20
- package/types/utils.ts +10 -0
- package/types/account/camel.d.ts +0 -8
- package/types/account/index.d.ts +0 -9
- package/types/attribute/camel.d.ts +0 -4
- package/types/attribute/index.d.ts +0 -4
- package/types/billing/camel.d.ts +0 -25
- package/types/billing/index.d.ts +0 -38
- package/types/card/camel.d.ts +0 -9
- package/types/card/index.d.ts +0 -9
- package/types/cart/camel.d.ts +0 -32
- package/types/cart/index.d.ts +0 -46
- package/types/category/camel.d.ts +0 -4
- package/types/category/index.d.ts +0 -4
- package/types/content/camel.d.ts +0 -5
- package/types/content/index.d.ts +0 -8
- package/types/coupon/camel.d.ts +0 -4
- package/types/coupon/index.d.ts +0 -4
- package/types/currency/camel.d.ts +0 -15
- package/types/currency/index.d.ts +0 -21
- package/types/discount/camel.d.ts +0 -15
- package/types/discount/index.d.ts +0 -18
- package/types/giftcard/camel.d.ts +0 -6
- package/types/giftcard/index.d.ts +0 -5
- package/types/invoice/camel.d.ts +0 -4
- package/types/invoice/index.d.ts +0 -4
- package/types/order/camel.d.ts +0 -15
- package/types/order/index.d.ts +0 -20
- package/types/payment/camel.d.ts +0 -35
- package/types/payment/index.d.ts +0 -51
- package/types/product/camel.d.ts +0 -24
- package/types/product/index.d.ts +0 -49
- package/types/promotion/camel.d.ts +0 -7
- package/types/promotion/index.d.ts +0 -8
- package/types/purchase_link/camel.d.ts +0 -4
- package/types/purchase_link/index.d.ts +0 -4
- package/types/refund/camel.d.ts +0 -4
- package/types/refund/index.d.ts +0 -4
- package/types/shipment_rating/camel.d.ts +0 -7
- package/types/shipment_rating/index.d.ts +0 -10
- package/types/subscription/camel.d.ts +0 -15
- package/types/subscription/index.d.ts +0 -21
- /package/types/locale/{index.d.ts → index.ts} +0 -0
- /package/types/settings/{index.d.ts → index.ts} +0 -0
package/dist/api.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import methods$5 from './products.mjs';
|
|
|
7
7
|
import methods$6 from './categories.mjs';
|
|
8
8
|
import methods$7 from './attributes.mjs';
|
|
9
9
|
import methods$8 from './subscriptions.mjs';
|
|
10
|
-
import { d as defaultMethods,
|
|
10
|
+
import { d as defaultMethods, z as trimEnd, A as setOptions, B as utils, C as trimStart, D as trimBoth, t as toSnake, E as stringifyQuery, q as base64Encode, i as isServer, a as toCamel } from './index.3c15c4d3.mjs';
|
|
11
11
|
import methods$9 from './content.mjs';
|
|
12
12
|
import methods$a from './settings.mjs';
|
|
13
13
|
import PaymentController from './payment.mjs';
|
|
@@ -126,12 +126,21 @@ function methods(api, _opt) {
|
|
|
126
126
|
};
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
+
/** @typedef {import('../types').InitOptions} InitOptions */
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* @template {'snake' | 'camel'} C
|
|
133
|
+
* @typedef {import('../types').SwellClient<C>} SwellClient<C>
|
|
134
|
+
*/
|
|
135
|
+
|
|
129
136
|
/**
|
|
130
137
|
* Swell API client
|
|
131
|
-
*
|
|
132
|
-
* @
|
|
133
|
-
* @param {
|
|
134
|
-
* @
|
|
138
|
+
*
|
|
139
|
+
* @template {'snake' | 'camel'} C
|
|
140
|
+
* @param {string} [initStore] - Store name
|
|
141
|
+
* @param {string} [initKey] - API key
|
|
142
|
+
* @param {InitOptions} [initOptions] - Options
|
|
143
|
+
* @returns {SwellClient<C>} API client
|
|
135
144
|
*/
|
|
136
145
|
function swell(initStore = undefined, initKey, initOptions = {}) {
|
|
137
146
|
const options = {
|
|
@@ -145,7 +154,7 @@ function swell(initStore = undefined, initKey, initOptions = {}) {
|
|
|
145
154
|
const api = {};
|
|
146
155
|
|
|
147
156
|
Object.assign(api, {
|
|
148
|
-
version: '
|
|
157
|
+
version: '5.1.0',
|
|
149
158
|
options,
|
|
150
159
|
request,
|
|
151
160
|
|
package/dist/attributes.mjs
CHANGED
package/dist/cache.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { s as set, m as merge, a as toCamel, h as toCamelPath, j as getOptions } from './index.
|
|
1
|
+
import { s as set, m as merge, a as toCamel, h as toCamelPath, j as getOptions } from './index.3c15c4d3.mjs';
|
|
2
2
|
import { g as get } from './find.18f1ac6d.mjs';
|
|
3
3
|
import 'qs';
|
|
4
4
|
import './round.577a8441.mjs';
|
package/dist/card.mjs
CHANGED
package/dist/cart.mjs
CHANGED
package/dist/categories.mjs
CHANGED
package/dist/content.mjs
CHANGED
package/dist/cookie.mjs
CHANGED
|
@@ -1804,4 +1804,4 @@ const utils = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
|
1804
1804
|
vaultRequest
|
|
1805
1805
|
}, Symbol.toStringTag, { value: 'Module' }));
|
|
1806
1806
|
|
|
1807
|
-
export {
|
|
1807
|
+
export { setOptions as A, utils as B, trimStart as C, trimBoth as D, stringifyQuery as E, toLower as F, toCamel as a, isObject as b, cloneDeep as c, defaultMethods as d, camelCase as e, snakeCase as f, isEqual as g, toCamelPath as h, isServer as i, getOptions as j, isFunction as k, loadScript as l, merge as m, isEmpty as n, isLiveMode as o, pick$1 as p, base64Encode as q, reduce as r, set as s, toSnake as t, uniq as u, vaultRequest as v, map as w, getLocationParams as x, removeUrlParams as y, trimEnd as z };
|
package/dist/index.mjs
CHANGED
package/dist/payment.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import methods from './cart.mjs';
|
|
2
2
|
import methods$1 from './settings.mjs';
|
|
3
|
-
import { b as isObject, k as isFunction, l as loadScript, c as cloneDeep, t as toSnake, v as vaultRequest, p as pick, n as isEmpty, o as isLiveMode, q as map, r as reduce,
|
|
3
|
+
import { b as isObject, k as isFunction, l as loadScript, c as cloneDeep, t as toSnake, v as vaultRequest, p as pick, n as isEmpty, o as isLiveMode, q as base64Encode, w as map, r as reduce, x as getLocationParams, y as removeUrlParams, a as toCamel } from './index.3c15c4d3.mjs';
|
|
4
4
|
import { g as get, t as toNumber } from './find.18f1ac6d.mjs';
|
|
5
5
|
import 'qs';
|
|
6
6
|
import 'deepmerge';
|
|
@@ -1960,10 +1960,12 @@ class BraintreePaypalPayment extends Payment {
|
|
|
1960
1960
|
}
|
|
1961
1961
|
}
|
|
1962
1962
|
|
|
1963
|
-
const API_VERSION = 2;
|
|
1964
|
-
const API_MINOR_VERSION = 0;
|
|
1965
|
-
|
|
1966
|
-
const
|
|
1963
|
+
const API_VERSION$1 = 2;
|
|
1964
|
+
const API_MINOR_VERSION$1 = 0;
|
|
1965
|
+
|
|
1966
|
+
const ALLOWED_CARD_AUTH_METHODS$1 = ['PAN_ONLY', 'CRYPTOGRAM_3DS'];
|
|
1967
|
+
|
|
1968
|
+
const ALLOWED_CARD_NETWORKS$1 = [
|
|
1967
1969
|
'AMEX',
|
|
1968
1970
|
'DISCOVER',
|
|
1969
1971
|
'INTERAC',
|
|
@@ -2001,6 +2003,7 @@ class BraintreeGooglePayment extends Payment {
|
|
|
2001
2003
|
return window.google;
|
|
2002
2004
|
}
|
|
2003
2005
|
|
|
2006
|
+
/** @returns {google.payments.api.PaymentsClient} */
|
|
2004
2007
|
get googleClient() {
|
|
2005
2008
|
if (!BraintreeGooglePayment.googleClient) {
|
|
2006
2009
|
if (this.google) {
|
|
@@ -2021,12 +2024,13 @@ class BraintreeGooglePayment extends Payment {
|
|
|
2021
2024
|
BraintreeGooglePayment.googleClient = googleClient;
|
|
2022
2025
|
}
|
|
2023
2026
|
|
|
2027
|
+
/** @returns {google.payments.api.PaymentMethodSpecification} */
|
|
2024
2028
|
get cardPaymentMethod() {
|
|
2025
2029
|
return {
|
|
2026
2030
|
type: 'CARD',
|
|
2027
2031
|
parameters: {
|
|
2028
|
-
allowedAuthMethods: ALLOWED_CARD_AUTH_METHODS,
|
|
2029
|
-
allowedCardNetworks: ALLOWED_CARD_NETWORKS,
|
|
2032
|
+
allowedAuthMethods: ALLOWED_CARD_AUTH_METHODS$1,
|
|
2033
|
+
allowedCardNetworks: ALLOWED_CARD_NETWORKS$1,
|
|
2030
2034
|
billingAddressRequired: true,
|
|
2031
2035
|
billingAddressParameters: {
|
|
2032
2036
|
format: 'FULL',
|
|
@@ -2036,6 +2040,7 @@ class BraintreeGooglePayment extends Payment {
|
|
|
2036
2040
|
};
|
|
2037
2041
|
}
|
|
2038
2042
|
|
|
2043
|
+
/** @returns {google.payments.api.PaymentMethodSpecification[]} */
|
|
2039
2044
|
get allowedPaymentMethods() {
|
|
2040
2045
|
return [this.cardPaymentMethod];
|
|
2041
2046
|
}
|
|
@@ -2044,7 +2049,7 @@ class BraintreeGooglePayment extends Payment {
|
|
|
2044
2049
|
const {
|
|
2045
2050
|
elementId = 'googlepay-button',
|
|
2046
2051
|
locale = 'en',
|
|
2047
|
-
style: { color = 'black', type = '
|
|
2052
|
+
style: { color = 'black', type = 'plain', sizeMode = 'fill' } = {},
|
|
2048
2053
|
} = this.params;
|
|
2049
2054
|
|
|
2050
2055
|
if (!this.method.merchant_id) {
|
|
@@ -2055,8 +2060,8 @@ class BraintreeGooglePayment extends Payment {
|
|
|
2055
2060
|
await this.loadScripts(this.scripts);
|
|
2056
2061
|
|
|
2057
2062
|
const isReadyToPay = await this.googleClient.isReadyToPay({
|
|
2058
|
-
apiVersion: API_VERSION,
|
|
2059
|
-
apiVersionMinor: API_MINOR_VERSION,
|
|
2063
|
+
apiVersion: API_VERSION$1,
|
|
2064
|
+
apiVersionMinor: API_MINOR_VERSION$1,
|
|
2060
2065
|
allowedPaymentMethods: this.allowedPaymentMethods,
|
|
2061
2066
|
existingPaymentMethodRequired: true,
|
|
2062
2067
|
});
|
|
@@ -2071,7 +2076,7 @@ class BraintreeGooglePayment extends Payment {
|
|
|
2071
2076
|
const googlePayment = await this.braintree.googlePayment.create({
|
|
2072
2077
|
client: braintreeClient,
|
|
2073
2078
|
googleMerchantId: this.method.merchant_id,
|
|
2074
|
-
googlePayVersion: API_VERSION,
|
|
2079
|
+
googlePayVersion: API_VERSION$1,
|
|
2075
2080
|
});
|
|
2076
2081
|
const paymentRequestData = this._createPaymentRequestData(cart);
|
|
2077
2082
|
const paymentDataRequest =
|
|
@@ -2084,6 +2089,12 @@ class BraintreeGooglePayment extends Payment {
|
|
|
2084
2089
|
buttonLocale: locale,
|
|
2085
2090
|
onClick: this._onClick.bind(this, googlePayment, paymentDataRequest),
|
|
2086
2091
|
});
|
|
2092
|
+
|
|
2093
|
+
const button = this.element.querySelector('#gpay-button-online-api-id');
|
|
2094
|
+
|
|
2095
|
+
if (button) {
|
|
2096
|
+
button.style['min-width'] = 'auto';
|
|
2097
|
+
}
|
|
2087
2098
|
}
|
|
2088
2099
|
|
|
2089
2100
|
mountElements() {
|
|
@@ -2111,18 +2122,20 @@ class BraintreeGooglePayment extends Payment {
|
|
|
2111
2122
|
});
|
|
2112
2123
|
}
|
|
2113
2124
|
|
|
2125
|
+
/** @returns {google.payments.api.PaymentDataRequest} */
|
|
2114
2126
|
_createPaymentRequestData(cart) {
|
|
2115
2127
|
const {
|
|
2116
|
-
settings: { name },
|
|
2128
|
+
settings: { name, country },
|
|
2117
2129
|
capture_total,
|
|
2118
2130
|
currency,
|
|
2119
2131
|
} = cart;
|
|
2120
2132
|
const { require: { email, shipping, phone } = {} } = this.params;
|
|
2121
2133
|
|
|
2122
2134
|
return {
|
|
2123
|
-
apiVersion: API_VERSION,
|
|
2124
|
-
apiVersionMinor: API_MINOR_VERSION,
|
|
2135
|
+
apiVersion: API_VERSION$1,
|
|
2136
|
+
apiVersionMinor: API_MINOR_VERSION$1,
|
|
2125
2137
|
transactionInfo: {
|
|
2138
|
+
countryCode: country,
|
|
2126
2139
|
currencyCode: currency,
|
|
2127
2140
|
totalPrice: capture_total.toString(),
|
|
2128
2141
|
totalPriceStatus: 'ESTIMATED',
|
|
@@ -2140,6 +2153,10 @@ class BraintreeGooglePayment extends Payment {
|
|
|
2140
2153
|
};
|
|
2141
2154
|
}
|
|
2142
2155
|
|
|
2156
|
+
/**
|
|
2157
|
+
* @param {object} googlePayment
|
|
2158
|
+
* @param {google.payments.api.PaymentDataRequest} paymentDataRequest
|
|
2159
|
+
*/
|
|
2143
2160
|
async _onClick(googlePayment, paymentDataRequest) {
|
|
2144
2161
|
try {
|
|
2145
2162
|
const paymentData =
|
|
@@ -2153,6 +2170,10 @@ class BraintreeGooglePayment extends Payment {
|
|
|
2153
2170
|
}
|
|
2154
2171
|
}
|
|
2155
2172
|
|
|
2173
|
+
/**
|
|
2174
|
+
* @param {object} googlePayment
|
|
2175
|
+
* @param {google.payments.api.PaymentData} paymentData
|
|
2176
|
+
*/
|
|
2156
2177
|
async _submitPayment(googlePayment, paymentData) {
|
|
2157
2178
|
const { require: { shipping: requireShipping } = {} } = this.params;
|
|
2158
2179
|
const { nonce } = await googlePayment.parseResponse(paymentData);
|
|
@@ -2181,6 +2202,7 @@ class BraintreeGooglePayment extends Payment {
|
|
|
2181
2202
|
this.onSuccess();
|
|
2182
2203
|
}
|
|
2183
2204
|
|
|
2205
|
+
/** @param {google.payments.api.Address} address */
|
|
2184
2206
|
_mapAddress(address) {
|
|
2185
2207
|
return {
|
|
2186
2208
|
name: address.name,
|
|
@@ -2404,6 +2426,247 @@ class BraintreeApplePayment extends Payment {
|
|
|
2404
2426
|
}
|
|
2405
2427
|
}
|
|
2406
2428
|
|
|
2429
|
+
const API_VERSION = 2;
|
|
2430
|
+
const API_MINOR_VERSION = 0;
|
|
2431
|
+
|
|
2432
|
+
const ALLOWED_CARD_AUTH_METHODS = ['PAN_ONLY', 'CRYPTOGRAM_3DS'];
|
|
2433
|
+
|
|
2434
|
+
const ALLOWED_CARD_NETWORKS = [
|
|
2435
|
+
'AMEX',
|
|
2436
|
+
'DISCOVER',
|
|
2437
|
+
'INTERAC',
|
|
2438
|
+
'JCB',
|
|
2439
|
+
'MASTERCARD',
|
|
2440
|
+
'VISA',
|
|
2441
|
+
];
|
|
2442
|
+
|
|
2443
|
+
class AuthorizeNetGooglePayment extends Payment {
|
|
2444
|
+
constructor(api, options, params, methods) {
|
|
2445
|
+
if (!methods.card) {
|
|
2446
|
+
throw new PaymentMethodDisabledError('Credit cards');
|
|
2447
|
+
}
|
|
2448
|
+
|
|
2449
|
+
super(api, options, params, methods.google);
|
|
2450
|
+
}
|
|
2451
|
+
|
|
2452
|
+
get scripts() {
|
|
2453
|
+
return ['google-pay'];
|
|
2454
|
+
}
|
|
2455
|
+
|
|
2456
|
+
get google() {
|
|
2457
|
+
if (!window.google) {
|
|
2458
|
+
throw new LibraryNotLoadedError('Google');
|
|
2459
|
+
}
|
|
2460
|
+
|
|
2461
|
+
return window.google;
|
|
2462
|
+
}
|
|
2463
|
+
|
|
2464
|
+
/** @returns {google.payments.api.PaymentsClient} */
|
|
2465
|
+
get googleClient() {
|
|
2466
|
+
if (!AuthorizeNetGooglePayment.googleClient) {
|
|
2467
|
+
if (this.google) {
|
|
2468
|
+
AuthorizeNetGooglePayment.googleClient =
|
|
2469
|
+
new this.google.payments.api.PaymentsClient({
|
|
2470
|
+
environment: isLiveMode(this.method.mode) ? 'PRODUCTION' : 'TEST',
|
|
2471
|
+
});
|
|
2472
|
+
}
|
|
2473
|
+
|
|
2474
|
+
if (!AuthorizeNetGooglePayment.googleClient) {
|
|
2475
|
+
throw new LibraryNotLoadedError('Google client');
|
|
2476
|
+
}
|
|
2477
|
+
}
|
|
2478
|
+
|
|
2479
|
+
return AuthorizeNetGooglePayment.googleClient;
|
|
2480
|
+
}
|
|
2481
|
+
|
|
2482
|
+
/**
|
|
2483
|
+
* @param {boolean} [submit]
|
|
2484
|
+
* @returns {google.payments.api.PaymentMethodSpecification[]}
|
|
2485
|
+
*/
|
|
2486
|
+
_getCardPaymentMethod(submit = false) {
|
|
2487
|
+
return {
|
|
2488
|
+
type: 'CARD',
|
|
2489
|
+
parameters: {
|
|
2490
|
+
allowedAuthMethods: ALLOWED_CARD_AUTH_METHODS,
|
|
2491
|
+
allowedCardNetworks: ALLOWED_CARD_NETWORKS,
|
|
2492
|
+
billingAddressRequired: true,
|
|
2493
|
+
billingAddressParameters: {
|
|
2494
|
+
format: 'FULL',
|
|
2495
|
+
phoneNumberRequired: true,
|
|
2496
|
+
},
|
|
2497
|
+
},
|
|
2498
|
+
...(submit && {
|
|
2499
|
+
tokenizationSpecification: {
|
|
2500
|
+
type: 'PAYMENT_GATEWAY',
|
|
2501
|
+
parameters: {
|
|
2502
|
+
gateway: 'authorizenet',
|
|
2503
|
+
gatewayMerchantId: this.method.gateway_merchant_id,
|
|
2504
|
+
},
|
|
2505
|
+
},
|
|
2506
|
+
}),
|
|
2507
|
+
};
|
|
2508
|
+
}
|
|
2509
|
+
|
|
2510
|
+
/**
|
|
2511
|
+
* @param {boolean} [submit]
|
|
2512
|
+
* @returns {google.payments.api.PaymentMethodSpecification[]}
|
|
2513
|
+
*/
|
|
2514
|
+
_getAllowedPaymentMethods(submit = false) {
|
|
2515
|
+
return [this._getCardPaymentMethod(submit)];
|
|
2516
|
+
}
|
|
2517
|
+
|
|
2518
|
+
/**
|
|
2519
|
+
* @param {import('../../../types').Cart} cart
|
|
2520
|
+
* @returns {google.payments.api.PaymentDataRequest}
|
|
2521
|
+
*/
|
|
2522
|
+
_createPaymentRequestData(cart) {
|
|
2523
|
+
const {
|
|
2524
|
+
settings: { name, country },
|
|
2525
|
+
capture_total,
|
|
2526
|
+
currency,
|
|
2527
|
+
} = cart;
|
|
2528
|
+
|
|
2529
|
+
const { require: { email, shipping, phone } = {} } = this.params;
|
|
2530
|
+
|
|
2531
|
+
return {
|
|
2532
|
+
apiVersion: API_VERSION,
|
|
2533
|
+
apiVersionMinor: API_MINOR_VERSION,
|
|
2534
|
+
transactionInfo: {
|
|
2535
|
+
countryCode: country,
|
|
2536
|
+
currencyCode: currency,
|
|
2537
|
+
totalPrice: capture_total.toString(),
|
|
2538
|
+
totalPriceStatus: 'ESTIMATED',
|
|
2539
|
+
},
|
|
2540
|
+
allowedPaymentMethods: this._getAllowedPaymentMethods(true),
|
|
2541
|
+
emailRequired: Boolean(email),
|
|
2542
|
+
shippingAddressRequired: Boolean(shipping),
|
|
2543
|
+
shippingAddressParameters: {
|
|
2544
|
+
phoneNumberRequired: Boolean(phone),
|
|
2545
|
+
},
|
|
2546
|
+
merchantInfo: {
|
|
2547
|
+
merchantName: name,
|
|
2548
|
+
merchantId: this.method.merchant_id,
|
|
2549
|
+
},
|
|
2550
|
+
};
|
|
2551
|
+
}
|
|
2552
|
+
|
|
2553
|
+
/** @param {google.payments.api.Address} address */
|
|
2554
|
+
_mapAddress(address) {
|
|
2555
|
+
return {
|
|
2556
|
+
name: address.name,
|
|
2557
|
+
address1: address.address1,
|
|
2558
|
+
address2: address.address2,
|
|
2559
|
+
city: address.locality,
|
|
2560
|
+
state: address.administrativeArea,
|
|
2561
|
+
zip: address.postalCode,
|
|
2562
|
+
country: address.countryCode,
|
|
2563
|
+
phone: address.phoneNumber,
|
|
2564
|
+
};
|
|
2565
|
+
}
|
|
2566
|
+
|
|
2567
|
+
/** @param {google.payments.api.PaymentData} paymentData */
|
|
2568
|
+
async _submitPayment(paymentData) {
|
|
2569
|
+
const { require: { shipping: requireShipping } = {} } = this.params;
|
|
2570
|
+
const { email, shippingAddress, paymentMethodData } = paymentData;
|
|
2571
|
+
const {
|
|
2572
|
+
info: { billingAddress },
|
|
2573
|
+
tokenizationData: { token },
|
|
2574
|
+
} = paymentMethodData;
|
|
2575
|
+
|
|
2576
|
+
await this.updateCart({
|
|
2577
|
+
account: {
|
|
2578
|
+
email,
|
|
2579
|
+
},
|
|
2580
|
+
billing: {
|
|
2581
|
+
method: 'google',
|
|
2582
|
+
google: {
|
|
2583
|
+
gateway: 'authorizenet',
|
|
2584
|
+
token: base64Encode(token),
|
|
2585
|
+
},
|
|
2586
|
+
...this._mapAddress(billingAddress),
|
|
2587
|
+
},
|
|
2588
|
+
...(requireShipping && {
|
|
2589
|
+
shipping: this._mapAddress(shippingAddress),
|
|
2590
|
+
}),
|
|
2591
|
+
});
|
|
2592
|
+
|
|
2593
|
+
this.onSuccess();
|
|
2594
|
+
}
|
|
2595
|
+
|
|
2596
|
+
/**
|
|
2597
|
+
* @param {google.payments.api.PaymentDataRequest} paymentDataRequest
|
|
2598
|
+
*/
|
|
2599
|
+
async _onClick(paymentDataRequest) {
|
|
2600
|
+
try {
|
|
2601
|
+
const paymentData =
|
|
2602
|
+
await this.googleClient.loadPaymentData(paymentDataRequest);
|
|
2603
|
+
|
|
2604
|
+
if (paymentData) {
|
|
2605
|
+
await this._submitPayment(paymentData);
|
|
2606
|
+
}
|
|
2607
|
+
} catch (error) {
|
|
2608
|
+
this.onError(error);
|
|
2609
|
+
}
|
|
2610
|
+
}
|
|
2611
|
+
|
|
2612
|
+
/** @param {import('../../../types').Cart} cart */
|
|
2613
|
+
async createElements(cart) {
|
|
2614
|
+
const {
|
|
2615
|
+
elementId = 'googlepay-button',
|
|
2616
|
+
locale = 'en',
|
|
2617
|
+
style: { color = 'black', type = 'plain', sizeMode = 'fill' } = {},
|
|
2618
|
+
} = this.params;
|
|
2619
|
+
|
|
2620
|
+
if (!this.method.merchant_id) {
|
|
2621
|
+
throw new Error('Google merchant ID is not defined');
|
|
2622
|
+
}
|
|
2623
|
+
|
|
2624
|
+
this.setElementContainer(elementId);
|
|
2625
|
+
await this.loadScripts(this.scripts);
|
|
2626
|
+
|
|
2627
|
+
const isReadyToPay = await this.googleClient.isReadyToPay({
|
|
2628
|
+
apiVersion: API_VERSION,
|
|
2629
|
+
apiVersionMinor: API_MINOR_VERSION,
|
|
2630
|
+
allowedPaymentMethods: this._getAllowedPaymentMethods(false),
|
|
2631
|
+
existingPaymentMethodRequired: true,
|
|
2632
|
+
});
|
|
2633
|
+
|
|
2634
|
+
if (!isReadyToPay.result) {
|
|
2635
|
+
throw new Error(
|
|
2636
|
+
'This device is not capable of making Google Pay payments',
|
|
2637
|
+
);
|
|
2638
|
+
}
|
|
2639
|
+
|
|
2640
|
+
const paymentDataRequest = this._createPaymentRequestData(cart);
|
|
2641
|
+
|
|
2642
|
+
this.element = this.googleClient.createButton({
|
|
2643
|
+
buttonColor: color,
|
|
2644
|
+
buttonType: type,
|
|
2645
|
+
buttonSizeMode: sizeMode,
|
|
2646
|
+
buttonLocale: locale,
|
|
2647
|
+
allowedPaymentMethods: this._getAllowedPaymentMethods(false),
|
|
2648
|
+
onClick: this._onClick.bind(this, paymentDataRequest),
|
|
2649
|
+
});
|
|
2650
|
+
|
|
2651
|
+
const button = this.element.querySelector('#gpay-button-online-api-id');
|
|
2652
|
+
|
|
2653
|
+
if (button) {
|
|
2654
|
+
button.style['min-width'] = 'auto';
|
|
2655
|
+
}
|
|
2656
|
+
}
|
|
2657
|
+
|
|
2658
|
+
mountElements() {
|
|
2659
|
+
const { classes = {} } = this.params;
|
|
2660
|
+
const container = this.elementContainer;
|
|
2661
|
+
|
|
2662
|
+
container.appendChild(this.element);
|
|
2663
|
+
|
|
2664
|
+
if (classes.base) {
|
|
2665
|
+
container.classList.add(classes.base);
|
|
2666
|
+
}
|
|
2667
|
+
}
|
|
2668
|
+
}
|
|
2669
|
+
|
|
2407
2670
|
class QuickpayCardPayment extends Payment {
|
|
2408
2671
|
constructor(api, options, params, methods) {
|
|
2409
2672
|
super(api, options, params, methods.card);
|
|
@@ -3543,6 +3806,8 @@ class PaymentController {
|
|
|
3543
3806
|
return StripeGooglePayment;
|
|
3544
3807
|
case 'braintree':
|
|
3545
3808
|
return BraintreeGooglePayment;
|
|
3809
|
+
case 'authorizenet':
|
|
3810
|
+
return AuthorizeNetGooglePayment;
|
|
3546
3811
|
default:
|
|
3547
3812
|
return null;
|
|
3548
3813
|
}
|
package/dist/products.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as defaultMethods, r as reduce, t as toSnake, a as toCamel, f as snakeCase, u as uniq, g as isEqual } from './index.
|
|
1
|
+
import { d as defaultMethods, r as reduce, t as toSnake, a as toCamel, f as snakeCase, u as uniq, g as isEqual } from './index.3c15c4d3.mjs';
|
|
2
2
|
import cacheApi from './cache.mjs';
|
|
3
3
|
import methods$1 from './attributes.mjs';
|
|
4
4
|
import { g as get, f as find } from './find.18f1ac6d.mjs';
|
package/dist/settings.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { s as set, a as toCamel, m as merge, c as cloneDeep, b as isObject, e as camelCase } from './index.
|
|
1
|
+
import { s as set, a as toCamel, m as merge, c as cloneDeep, b as isObject, e as camelCase } from './index.3c15c4d3.mjs';
|
|
2
2
|
import { g as get, f as find } from './find.18f1ac6d.mjs';
|
|
3
3
|
import 'qs';
|
|
4
4
|
import './round.577a8441.mjs';
|
package/dist/subscriptions.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { cleanProductOptions } from './products.mjs';
|
|
2
|
-
import { d as defaultMethods } from './index.
|
|
2
|
+
import { d as defaultMethods } from './index.3c15c4d3.mjs';
|
|
3
3
|
import cacheApi from './cache.mjs';
|
|
4
4
|
import './attributes.mjs';
|
|
5
5
|
import './find.18f1ac6d.mjs';
|