@kiva/kv-shop 1.1.1 → 1.1.3
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/basket.spec.cjs +17 -0
- package/dist/basket.spec.d.ts +2 -0
- package/dist/basket.spec.js +17 -0
- package/package.json +6 -3
- package/dist/basket.cjs +0 -40
- package/dist/basket.d.ts +0 -4
- package/dist/basket.js +0 -8
- package/dist/basketItems.cjs +0 -116
- package/dist/basketItems.d.ts +0 -7
- package/dist/basketItems.js +0 -8
- package/dist/chunk-26OKISW3.js +0 -51
- package/dist/chunk-AEVGXKI6.js +0 -16
- package/dist/chunk-H35VQXDR.js +0 -31
- package/dist/chunk-M4CJOCIQ.js +0 -26
- package/dist/chunk-R27YZQKP.js +0 -160
- package/dist/chunk-V2I7V4QJ.js +0 -104
- package/dist/index.cjs +0 -409
- package/dist/index.d.ts +0 -8
- package/dist/index.js +0 -38
- package/dist/oneTimeCheckout.cjs +0 -50
- package/dist/oneTimeCheckout.d.ts +0 -13
- package/dist/oneTimeCheckout.js +0 -8
- package/dist/shopError.cjs +0 -55
- package/dist/shopError.d.ts +0 -12
- package/dist/shopError.js +0 -8
- package/dist/subscriptionCheckout.cjs +0 -152
- package/dist/subscriptionCheckout.d.ts +0 -13
- package/dist/subscriptionCheckout.js +0 -9
- package/dist/useBraintreeDropIn.cjs +0 -218
- package/dist/useBraintreeDropIn.d.ts +0 -25
- package/dist/useBraintreeDropIn.js +0 -11
package/dist/index.cjs
DELETED
|
@@ -1,409 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
|
|
29
|
-
// src/index.ts
|
|
30
|
-
var src_exports = {};
|
|
31
|
-
__export(src_exports, {
|
|
32
|
-
ShopError: () => ShopError,
|
|
33
|
-
checkSubscriptionStatus: () => checkSubscriptionStatus,
|
|
34
|
-
defaultPaymentTypes: () => defaultPaymentTypes,
|
|
35
|
-
executeNewSubscriptionCheckout: () => executeNewSubscriptionCheckout,
|
|
36
|
-
executeOneTimeCheckout: () => executeOneTimeCheckout,
|
|
37
|
-
getBasketID: () => getBasketID,
|
|
38
|
-
getClientToken: () => getClientToken,
|
|
39
|
-
parseShopError: () => parseShopError,
|
|
40
|
-
setBasketID: () => setBasketID,
|
|
41
|
-
setTipDonation: () => setTipDonation,
|
|
42
|
-
useBraintreeDropIn: () => useBraintreeDropIn,
|
|
43
|
-
waitOnTransaction: () => waitOnTransaction
|
|
44
|
-
});
|
|
45
|
-
module.exports = __toCommonJS(src_exports);
|
|
46
|
-
|
|
47
|
-
// src/basket.ts
|
|
48
|
-
var getCookieValue = (name) => {
|
|
49
|
-
if (typeof document !== void 0) {
|
|
50
|
-
return document.cookie.match(`(^|;)\\s*${name}\\s*=\\s*([^;]+)/`)?.pop() || "";
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
function getBasketID() {
|
|
54
|
-
return getCookieValue("kvbskt");
|
|
55
|
-
}
|
|
56
|
-
function setBasketID(basketId) {
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// src/basketItems.ts
|
|
60
|
-
var import_core = require("@apollo/client/core");
|
|
61
|
-
var import_numeral = __toESM(require("numeral"), 1);
|
|
62
|
-
|
|
63
|
-
// src/shopError.ts
|
|
64
|
-
var ShopError = class extends Error {
|
|
65
|
-
constructor({ code, original }, ...params) {
|
|
66
|
-
super(...params);
|
|
67
|
-
if (Error.captureStackTrace) {
|
|
68
|
-
Error.captureStackTrace(this, ShopError);
|
|
69
|
-
}
|
|
70
|
-
this.name = "ShopError";
|
|
71
|
-
this.code = code;
|
|
72
|
-
this.original = original;
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
function parseShopError(error) {
|
|
76
|
-
const errorCode = error?.code ?? error?.name ?? "";
|
|
77
|
-
const errorMessage = typeof error === "string" ? error : error?.message ?? "";
|
|
78
|
-
if (errorCode === "invalidMethodParameter" && errorMessage.includes("paymentMethod.create")) {
|
|
79
|
-
return new ShopError({
|
|
80
|
-
code: "paymentMethod.create.invalidMethodParameter",
|
|
81
|
-
original: error
|
|
82
|
-
}, "There was a problem validating your payment information. Please double-check the details and try again.");
|
|
83
|
-
}
|
|
84
|
-
return new ShopError({
|
|
85
|
-
code: "shop.unknown",
|
|
86
|
-
original: error
|
|
87
|
-
}, "An unknown error occurred.");
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// src/basketItems.ts
|
|
91
|
-
async function setTipDonation({ amount, apollo }) {
|
|
92
|
-
let data;
|
|
93
|
-
let error;
|
|
94
|
-
try {
|
|
95
|
-
const result = await apollo.mutate({
|
|
96
|
-
mutation: import_core.gql`mutation setTipDonation($price: Money!, $basketId: String) {
|
|
97
|
-
shop (basketId: $basketId) {
|
|
98
|
-
id
|
|
99
|
-
updateDonation (donation: {
|
|
100
|
-
price: $price,
|
|
101
|
-
isTip: true
|
|
102
|
-
})
|
|
103
|
-
{
|
|
104
|
-
id
|
|
105
|
-
price
|
|
106
|
-
isTip
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}`,
|
|
110
|
-
variables: {
|
|
111
|
-
price: (0, import_numeral.default)(amount).format("0.00"),
|
|
112
|
-
basketId: getBasketID()
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
if (result.error || result.errors.length) {
|
|
116
|
-
error = result.error ?? result.errors[0];
|
|
117
|
-
} else {
|
|
118
|
-
data = result.data;
|
|
119
|
-
}
|
|
120
|
-
} catch (e) {
|
|
121
|
-
error = e;
|
|
122
|
-
}
|
|
123
|
-
if (error) {
|
|
124
|
-
throw parseShopError(error);
|
|
125
|
-
}
|
|
126
|
-
return data?.shop?.updateDonation;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// src/oneTimeCheckout.ts
|
|
130
|
-
var import_core2 = require("@apollo/client/core");
|
|
131
|
-
async function executeOneTimeCheckout({ apollo }) {
|
|
132
|
-
}
|
|
133
|
-
async function waitOnTransaction({ apollo, transactionId }) {
|
|
134
|
-
const result = await apollo.query({
|
|
135
|
-
query: import_core2.gql`
|
|
136
|
-
query checkoutStatus($transactionId: String!, $visitorId: string) {
|
|
137
|
-
checkoutStatus(transactionId: $transactionId, visitorId: $visitorId) {
|
|
138
|
-
errorCode
|
|
139
|
-
errorMessage
|
|
140
|
-
status
|
|
141
|
-
transactionId
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
`,
|
|
145
|
-
variables: {
|
|
146
|
-
transactionId
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
// src/subscriptionCheckout.ts
|
|
152
|
-
var import_core3 = require("@apollo/client/core");
|
|
153
|
-
async function checkSubscriptionStatus(apollo) {
|
|
154
|
-
const { data: subsData } = await apollo.query({
|
|
155
|
-
query: import_core3.gql`query subscriptionStatus{
|
|
156
|
-
my {
|
|
157
|
-
id
|
|
158
|
-
subscriptions {
|
|
159
|
-
totalCount
|
|
160
|
-
}
|
|
161
|
-
autoDeposit {
|
|
162
|
-
id
|
|
163
|
-
isSubscriber
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}`
|
|
167
|
-
});
|
|
168
|
-
if (!subsData?.my?.id) {
|
|
169
|
-
throw new ShopError({ code: "api.authenticationRequired" }, "You must be logged in to continue.");
|
|
170
|
-
}
|
|
171
|
-
if ((subsData?.my?.subscriptions?.totalCount ?? 0) > 0 || subsData?.my?.autoDeposit?.isSubscriber) {
|
|
172
|
-
throw new ShopError({ code: "shop.subscriptionExists" }, "You already have an existing Monthly Good subscription. Changes can be made in your subscription settings.");
|
|
173
|
-
}
|
|
174
|
-
if (subsData?.my?.autoDeposit?.id) {
|
|
175
|
-
throw new ShopError({ code: "shop.autoDepositExists" }, "You already have existing Auto Deposit settings. Changes can be made in your subscription settings.");
|
|
176
|
-
}
|
|
177
|
-
return true;
|
|
178
|
-
}
|
|
179
|
-
async function executeNewSubscriptionCheckout({
|
|
180
|
-
amount,
|
|
181
|
-
apollo,
|
|
182
|
-
dayOfMonth = (/* @__PURE__ */ new Date()).getDate(),
|
|
183
|
-
donateAmount,
|
|
184
|
-
paymentMethod
|
|
185
|
-
}) {
|
|
186
|
-
const amountRegex = new RegExp(/^\d+\.\d{2}$/);
|
|
187
|
-
if (!amountRegex.test(amount) || !amountRegex.test(donateAmount)) {
|
|
188
|
-
throw new ShopError({
|
|
189
|
-
code: "api.invalidMethodParameter"
|
|
190
|
-
}, "Please check that the amount is correct and try again.");
|
|
191
|
-
}
|
|
192
|
-
await checkSubscriptionStatus(apollo);
|
|
193
|
-
const { deviceData, nonce } = paymentMethod;
|
|
194
|
-
let data;
|
|
195
|
-
let error;
|
|
196
|
-
try {
|
|
197
|
-
const result = await apollo.query({
|
|
198
|
-
variables: {
|
|
199
|
-
dayOfMonth,
|
|
200
|
-
deviceData,
|
|
201
|
-
nonce
|
|
202
|
-
},
|
|
203
|
-
query: import_core3.gql`mutation createAutoDepositSubscription(
|
|
204
|
-
$nonce: String!,
|
|
205
|
-
$deviceData: String,
|
|
206
|
-
$amount: Money!,
|
|
207
|
-
$donateAmount: Money!,
|
|
208
|
-
$dayOfMonth: Int!
|
|
209
|
-
) {
|
|
210
|
-
my {
|
|
211
|
-
createAutoDeposit (
|
|
212
|
-
autoDeposit: {
|
|
213
|
-
amount: $amount,
|
|
214
|
-
donateAmount: $donateAmount,
|
|
215
|
-
dayOfMonth: $dayOfMonth,
|
|
216
|
-
},
|
|
217
|
-
deviceData: $deviceData,
|
|
218
|
-
paymentMethodNonce: $nonce
|
|
219
|
-
) {
|
|
220
|
-
id amount donateAmount dayOfMonth status
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}`
|
|
224
|
-
});
|
|
225
|
-
if (result.error || result.errors.length) {
|
|
226
|
-
error = result.error ?? result.errors[0];
|
|
227
|
-
} else {
|
|
228
|
-
data = result.data;
|
|
229
|
-
}
|
|
230
|
-
} catch (e) {
|
|
231
|
-
error = e;
|
|
232
|
-
}
|
|
233
|
-
if (error) {
|
|
234
|
-
const parsed = parseShopError(error);
|
|
235
|
-
if (parsed.code === "shop.unknown") {
|
|
236
|
-
throw new ShopError({
|
|
237
|
-
code: "shop.createAutoDepositError",
|
|
238
|
-
original: parsed
|
|
239
|
-
}, "There was a problem trying to setup your monthly deposit.");
|
|
240
|
-
}
|
|
241
|
-
throw parsed;
|
|
242
|
-
}
|
|
243
|
-
return data?.my?.createAutoDeposit;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
// src/useBraintreeDropIn.ts
|
|
247
|
-
var import_core4 = require("@apollo/client/core");
|
|
248
|
-
var import_numeral2 = __toESM(require("numeral"), 1);
|
|
249
|
-
var import_vue_demi = require("vue-demi");
|
|
250
|
-
var defaultPaymentTypes = ["paypal", "card", "applePay", "googlePay"];
|
|
251
|
-
async function getClientToken(apollo) {
|
|
252
|
-
const { data, error, errors } = await apollo.query({
|
|
253
|
-
query: import_core4.gql`query getClientToken {
|
|
254
|
-
shop {
|
|
255
|
-
id
|
|
256
|
-
getClientToken(useCustomerId: true)
|
|
257
|
-
}
|
|
258
|
-
}`
|
|
259
|
-
});
|
|
260
|
-
if (error || errors.length) {
|
|
261
|
-
throw parseShopError(error ?? errors[0]);
|
|
262
|
-
}
|
|
263
|
-
return data?.shop?.getClientToken;
|
|
264
|
-
}
|
|
265
|
-
function useBraintreeDropIn() {
|
|
266
|
-
let instance;
|
|
267
|
-
let formattedAmount = "";
|
|
268
|
-
const paymentMethodRequestable = (0, import_vue_demi.ref)(false);
|
|
269
|
-
function getApplePaymentRequest(amount) {
|
|
270
|
-
return {
|
|
271
|
-
countryCode: "US",
|
|
272
|
-
currencyCode: "USD",
|
|
273
|
-
// merchantCapabilities: ['supports3DS'], // TODO: confirm/update
|
|
274
|
-
requiredBillingContactFields: ["postalAddress"],
|
|
275
|
-
// supportedNetworks: ['amex', 'discover', 'interac', 'jcb', 'masterCard', 'visa'], // TODO: confirm/update
|
|
276
|
-
total: {
|
|
277
|
-
label: "Kiva",
|
|
278
|
-
amount
|
|
279
|
-
}
|
|
280
|
-
};
|
|
281
|
-
}
|
|
282
|
-
function getGoogleTransactionInfo(amount) {
|
|
283
|
-
return {
|
|
284
|
-
totalPriceStatus: "FINAL",
|
|
285
|
-
totalPrice: amount,
|
|
286
|
-
currencyCode: "USD",
|
|
287
|
-
countryCode: "US"
|
|
288
|
-
};
|
|
289
|
-
}
|
|
290
|
-
function initDropInActions() {
|
|
291
|
-
if (instance.isPaymentMethodRequestable()) {
|
|
292
|
-
paymentMethodRequestable.value = true;
|
|
293
|
-
}
|
|
294
|
-
instance.on("paymentMethodRequestable", (event) => {
|
|
295
|
-
paymentMethodRequestable.value = true;
|
|
296
|
-
});
|
|
297
|
-
instance.on("noPaymentMethodRequestable", () => {
|
|
298
|
-
paymentMethodRequestable.value = false;
|
|
299
|
-
});
|
|
300
|
-
}
|
|
301
|
-
async function initDropIn({
|
|
302
|
-
amount,
|
|
303
|
-
authToken,
|
|
304
|
-
container,
|
|
305
|
-
googlePayMerchantId,
|
|
306
|
-
paymentTypes = [...defaultPaymentTypes],
|
|
307
|
-
preselectVaultedPaymentMethod = true,
|
|
308
|
-
paypalFlow = "checkout"
|
|
309
|
-
}) {
|
|
310
|
-
formattedAmount = (0, import_numeral2.default)(amount).format("0.00");
|
|
311
|
-
const { default: DropIn } = await import("braintree-web-drop-in");
|
|
312
|
-
try {
|
|
313
|
-
instance = await DropIn.create({
|
|
314
|
-
authorization: authToken,
|
|
315
|
-
container,
|
|
316
|
-
dataCollector: {
|
|
317
|
-
kount: true
|
|
318
|
-
// Required if Kount fraud data collection is enabled
|
|
319
|
-
},
|
|
320
|
-
// vaultManager: true, - Useful for testing and removing payment methods easily.
|
|
321
|
-
paymentOptionPriority: paymentTypes,
|
|
322
|
-
preselectVaultedPaymentMethod,
|
|
323
|
-
card: {
|
|
324
|
-
vault: {
|
|
325
|
-
allowVaultCardOverride: true
|
|
326
|
-
}
|
|
327
|
-
},
|
|
328
|
-
paypal: {
|
|
329
|
-
flow: paypalFlow,
|
|
330
|
-
amount: formattedAmount,
|
|
331
|
-
currency: "USD",
|
|
332
|
-
buttonStyle: {
|
|
333
|
-
// @ts-ignore
|
|
334
|
-
color: "gold",
|
|
335
|
-
// @ts-ignore
|
|
336
|
-
shape: "rect",
|
|
337
|
-
// @ts-ignore
|
|
338
|
-
size: "responsive"
|
|
339
|
-
}
|
|
340
|
-
},
|
|
341
|
-
googlePay: {
|
|
342
|
-
googlePayVersion: 2,
|
|
343
|
-
merchantId: googlePayMerchantId,
|
|
344
|
-
transactionInfo: getGoogleTransactionInfo(formattedAmount),
|
|
345
|
-
button: {
|
|
346
|
-
allowedPaymentMethods: [{
|
|
347
|
-
type: "CARD",
|
|
348
|
-
// @ts-ignore
|
|
349
|
-
parameters: {
|
|
350
|
-
// allowedAuthMethods: ['PAN_ONLY', 'CRYPTOGRAM_3DS'], // TODO: confirm/update
|
|
351
|
-
// allowedCardNetworks: ['AMEX', 'DISCOVER', 'INTERAC', 'JCB', 'MASTERCARD', 'VISA'], // TODO: confirm/update
|
|
352
|
-
billingAddressRequired: true,
|
|
353
|
-
billingAddressParameters: {
|
|
354
|
-
format: "FULL"
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
}]
|
|
358
|
-
}
|
|
359
|
-
},
|
|
360
|
-
applePay: {
|
|
361
|
-
displayName: "Kiva",
|
|
362
|
-
paymentRequest: getApplePaymentRequest(formattedAmount)
|
|
363
|
-
}
|
|
364
|
-
});
|
|
365
|
-
initDropInActions();
|
|
366
|
-
} catch (e) {
|
|
367
|
-
throw new ShopError({
|
|
368
|
-
code: "shop.braintreeDropinInitError",
|
|
369
|
-
original: e
|
|
370
|
-
}, "An Error has occured. Please refresh the page and try again.");
|
|
371
|
-
}
|
|
372
|
-
return instance;
|
|
373
|
-
}
|
|
374
|
-
async function requestPaymentMethod() {
|
|
375
|
-
if (instance.isPaymentMethodRequestable()) {
|
|
376
|
-
return instance.requestPaymentMethod();
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
function updateAmount(amount) {
|
|
380
|
-
const newAmount = (0, import_numeral2.default)(amount).format("0.00");
|
|
381
|
-
if (newAmount !== formattedAmount) {
|
|
382
|
-
formattedAmount = newAmount;
|
|
383
|
-
instance?.updateConfiguration("paypal", "amount", formattedAmount);
|
|
384
|
-
instance?.updateConfiguration("googlePay", "transactionInfo", getGoogleTransactionInfo(formattedAmount));
|
|
385
|
-
instance?.updateConfiguration?.("applePay", "paymentRequest", getApplePaymentRequest(formattedAmount));
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
return {
|
|
389
|
-
initDropIn,
|
|
390
|
-
paymentMethodRequestable,
|
|
391
|
-
requestPaymentMethod,
|
|
392
|
-
updateAmount
|
|
393
|
-
};
|
|
394
|
-
}
|
|
395
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
396
|
-
0 && (module.exports = {
|
|
397
|
-
ShopError,
|
|
398
|
-
checkSubscriptionStatus,
|
|
399
|
-
defaultPaymentTypes,
|
|
400
|
-
executeNewSubscriptionCheckout,
|
|
401
|
-
executeOneTimeCheckout,
|
|
402
|
-
getBasketID,
|
|
403
|
-
getClientToken,
|
|
404
|
-
parseShopError,
|
|
405
|
-
setBasketID,
|
|
406
|
-
setTipDonation,
|
|
407
|
-
useBraintreeDropIn,
|
|
408
|
-
waitOnTransaction
|
|
409
|
-
});
|
package/dist/index.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { getBasketID, setBasketID } from './basket.js';
|
|
2
|
-
export { SetTipDonationOptions, setTipDonation } from './basketItems.js';
|
|
3
|
-
export { OneTimeCheckoutOptions, WaitOnTransactionOptions, executeOneTimeCheckout, waitOnTransaction } from './oneTimeCheckout.js';
|
|
4
|
-
export { ShopError, ShopErrorOptions, parseShopError } from './shopError.js';
|
|
5
|
-
export { SubscriptionCheckoutOptions, checkSubscriptionStatus, executeNewSubscriptionCheckout } from './subscriptionCheckout.js';
|
|
6
|
-
export { DropInInitOptions, PayPalFlowType, PaymentType, defaultPaymentTypes, getClientToken, default as useBraintreeDropIn } from './useBraintreeDropIn.js';
|
|
7
|
-
import 'braintree-web-drop-in';
|
|
8
|
-
import '@vue/composition-api';
|
package/dist/index.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
setTipDonation
|
|
3
|
-
} from "./chunk-26OKISW3.js";
|
|
4
|
-
import {
|
|
5
|
-
getBasketID,
|
|
6
|
-
setBasketID
|
|
7
|
-
} from "./chunk-AEVGXKI6.js";
|
|
8
|
-
import {
|
|
9
|
-
executeOneTimeCheckout,
|
|
10
|
-
waitOnTransaction
|
|
11
|
-
} from "./chunk-M4CJOCIQ.js";
|
|
12
|
-
import {
|
|
13
|
-
checkSubscriptionStatus,
|
|
14
|
-
executeNewSubscriptionCheckout
|
|
15
|
-
} from "./chunk-V2I7V4QJ.js";
|
|
16
|
-
import {
|
|
17
|
-
defaultPaymentTypes,
|
|
18
|
-
getClientToken,
|
|
19
|
-
useBraintreeDropIn
|
|
20
|
-
} from "./chunk-R27YZQKP.js";
|
|
21
|
-
import {
|
|
22
|
-
ShopError,
|
|
23
|
-
parseShopError
|
|
24
|
-
} from "./chunk-H35VQXDR.js";
|
|
25
|
-
export {
|
|
26
|
-
ShopError,
|
|
27
|
-
checkSubscriptionStatus,
|
|
28
|
-
defaultPaymentTypes,
|
|
29
|
-
executeNewSubscriptionCheckout,
|
|
30
|
-
executeOneTimeCheckout,
|
|
31
|
-
getBasketID,
|
|
32
|
-
getClientToken,
|
|
33
|
-
parseShopError,
|
|
34
|
-
setBasketID,
|
|
35
|
-
setTipDonation,
|
|
36
|
-
useBraintreeDropIn,
|
|
37
|
-
waitOnTransaction
|
|
38
|
-
};
|
package/dist/oneTimeCheckout.cjs
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// src/oneTimeCheckout.ts
|
|
20
|
-
var oneTimeCheckout_exports = {};
|
|
21
|
-
__export(oneTimeCheckout_exports, {
|
|
22
|
-
executeOneTimeCheckout: () => executeOneTimeCheckout,
|
|
23
|
-
waitOnTransaction: () => waitOnTransaction
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(oneTimeCheckout_exports);
|
|
26
|
-
var import_core = require("@apollo/client/core");
|
|
27
|
-
async function executeOneTimeCheckout({ apollo }) {
|
|
28
|
-
}
|
|
29
|
-
async function waitOnTransaction({ apollo, transactionId }) {
|
|
30
|
-
const result = await apollo.query({
|
|
31
|
-
query: import_core.gql`
|
|
32
|
-
query checkoutStatus($transactionId: String!, $visitorId: string) {
|
|
33
|
-
checkoutStatus(transactionId: $transactionId, visitorId: $visitorId) {
|
|
34
|
-
errorCode
|
|
35
|
-
errorMessage
|
|
36
|
-
status
|
|
37
|
-
transactionId
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
`,
|
|
41
|
-
variables: {
|
|
42
|
-
transactionId
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
47
|
-
0 && (module.exports = {
|
|
48
|
-
executeOneTimeCheckout,
|
|
49
|
-
waitOnTransaction
|
|
50
|
-
});
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
interface OneTimeCheckoutOptions {
|
|
2
|
-
apollo: any;
|
|
3
|
-
basketId: string;
|
|
4
|
-
visitorId: string | null | undefined;
|
|
5
|
-
}
|
|
6
|
-
declare function executeOneTimeCheckout({ apollo }: OneTimeCheckoutOptions): Promise<void>;
|
|
7
|
-
interface WaitOnTransactionOptions {
|
|
8
|
-
apollo: any;
|
|
9
|
-
transactionId: string;
|
|
10
|
-
}
|
|
11
|
-
declare function waitOnTransaction({ apollo, transactionId }: WaitOnTransactionOptions): Promise<void>;
|
|
12
|
-
|
|
13
|
-
export { OneTimeCheckoutOptions, WaitOnTransactionOptions, executeOneTimeCheckout, waitOnTransaction };
|
package/dist/oneTimeCheckout.js
DELETED
package/dist/shopError.cjs
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// src/shopError.ts
|
|
20
|
-
var shopError_exports = {};
|
|
21
|
-
__export(shopError_exports, {
|
|
22
|
-
ShopError: () => ShopError,
|
|
23
|
-
parseShopError: () => parseShopError
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(shopError_exports);
|
|
26
|
-
var ShopError = class extends Error {
|
|
27
|
-
constructor({ code, original }, ...params) {
|
|
28
|
-
super(...params);
|
|
29
|
-
if (Error.captureStackTrace) {
|
|
30
|
-
Error.captureStackTrace(this, ShopError);
|
|
31
|
-
}
|
|
32
|
-
this.name = "ShopError";
|
|
33
|
-
this.code = code;
|
|
34
|
-
this.original = original;
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
function parseShopError(error) {
|
|
38
|
-
const errorCode = error?.code ?? error?.name ?? "";
|
|
39
|
-
const errorMessage = typeof error === "string" ? error : error?.message ?? "";
|
|
40
|
-
if (errorCode === "invalidMethodParameter" && errorMessage.includes("paymentMethod.create")) {
|
|
41
|
-
return new ShopError({
|
|
42
|
-
code: "paymentMethod.create.invalidMethodParameter",
|
|
43
|
-
original: error
|
|
44
|
-
}, "There was a problem validating your payment information. Please double-check the details and try again.");
|
|
45
|
-
}
|
|
46
|
-
return new ShopError({
|
|
47
|
-
code: "shop.unknown",
|
|
48
|
-
original: error
|
|
49
|
-
}, "An unknown error occurred.");
|
|
50
|
-
}
|
|
51
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
52
|
-
0 && (module.exports = {
|
|
53
|
-
ShopError,
|
|
54
|
-
parseShopError
|
|
55
|
-
});
|
package/dist/shopError.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
interface ShopErrorOptions {
|
|
2
|
-
code: string;
|
|
3
|
-
original?: object;
|
|
4
|
-
}
|
|
5
|
-
declare class ShopError extends Error {
|
|
6
|
-
code: string;
|
|
7
|
-
original?: object;
|
|
8
|
-
constructor({ code, original }: ShopErrorOptions, ...params: any[]);
|
|
9
|
-
}
|
|
10
|
-
declare function parseShopError(error: any): ShopError;
|
|
11
|
-
|
|
12
|
-
export { ShopError, ShopErrorOptions, parseShopError };
|