@kiva/kv-shop 1.1.3 → 1.1.4
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.cjs +42 -0
- package/dist/basket.d.ts +5 -0
- package/dist/basket.js +10 -0
- package/dist/basketItems.cjs +116 -0
- package/dist/basketItems.d.ts +7 -0
- package/dist/basketItems.js +8 -0
- package/dist/chunk-F6QCMBHV.js +17 -0
- package/dist/chunk-H35VQXDR.js +31 -0
- package/dist/chunk-KSEC5YWO.js +51 -0
- package/dist/chunk-M4CJOCIQ.js +26 -0
- package/dist/chunk-R27YZQKP.js +160 -0
- package/dist/chunk-V2I7V4QJ.js +104 -0
- package/dist/index.cjs +411 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +40 -0
- package/dist/oneTimeCheckout.cjs +50 -0
- package/dist/oneTimeCheckout.d.ts +13 -0
- package/dist/oneTimeCheckout.js +8 -0
- package/dist/shopError.cjs +55 -0
- package/dist/shopError.d.ts +12 -0
- package/dist/shopError.js +8 -0
- package/dist/subscriptionCheckout.cjs +152 -0
- package/dist/subscriptionCheckout.d.ts +13 -0
- package/dist/subscriptionCheckout.js +9 -0
- package/dist/useBraintreeDropIn.cjs +218 -0
- package/dist/useBraintreeDropIn.d.ts +25 -0
- package/dist/useBraintreeDropIn.js +11 -0
- package/package.json +3 -3
- package/dist/basket.spec.cjs +0 -17
- package/dist/basket.spec.d.ts +0 -2
- package/dist/basket.spec.js +0 -17
|
@@ -0,0 +1,152 @@
|
|
|
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/subscriptionCheckout.ts
|
|
20
|
+
var subscriptionCheckout_exports = {};
|
|
21
|
+
__export(subscriptionCheckout_exports, {
|
|
22
|
+
checkSubscriptionStatus: () => checkSubscriptionStatus,
|
|
23
|
+
executeNewSubscriptionCheckout: () => executeNewSubscriptionCheckout
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(subscriptionCheckout_exports);
|
|
26
|
+
var import_core = require("@apollo/client/core");
|
|
27
|
+
|
|
28
|
+
// src/shopError.ts
|
|
29
|
+
var ShopError = class extends Error {
|
|
30
|
+
constructor({ code, original }, ...params) {
|
|
31
|
+
super(...params);
|
|
32
|
+
if (Error.captureStackTrace) {
|
|
33
|
+
Error.captureStackTrace(this, ShopError);
|
|
34
|
+
}
|
|
35
|
+
this.name = "ShopError";
|
|
36
|
+
this.code = code;
|
|
37
|
+
this.original = original;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
function parseShopError(error) {
|
|
41
|
+
const errorCode = error?.code ?? error?.name ?? "";
|
|
42
|
+
const errorMessage = typeof error === "string" ? error : error?.message ?? "";
|
|
43
|
+
if (errorCode === "invalidMethodParameter" && errorMessage.includes("paymentMethod.create")) {
|
|
44
|
+
return new ShopError({
|
|
45
|
+
code: "paymentMethod.create.invalidMethodParameter",
|
|
46
|
+
original: error
|
|
47
|
+
}, "There was a problem validating your payment information. Please double-check the details and try again.");
|
|
48
|
+
}
|
|
49
|
+
return new ShopError({
|
|
50
|
+
code: "shop.unknown",
|
|
51
|
+
original: error
|
|
52
|
+
}, "An unknown error occurred.");
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// src/subscriptionCheckout.ts
|
|
56
|
+
async function checkSubscriptionStatus(apollo) {
|
|
57
|
+
const { data: subsData } = await apollo.query({
|
|
58
|
+
query: import_core.gql`query subscriptionStatus{
|
|
59
|
+
my {
|
|
60
|
+
id
|
|
61
|
+
subscriptions {
|
|
62
|
+
totalCount
|
|
63
|
+
}
|
|
64
|
+
autoDeposit {
|
|
65
|
+
id
|
|
66
|
+
isSubscriber
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}`
|
|
70
|
+
});
|
|
71
|
+
if (!subsData?.my?.id) {
|
|
72
|
+
throw new ShopError({ code: "api.authenticationRequired" }, "You must be logged in to continue.");
|
|
73
|
+
}
|
|
74
|
+
if ((subsData?.my?.subscriptions?.totalCount ?? 0) > 0 || subsData?.my?.autoDeposit?.isSubscriber) {
|
|
75
|
+
throw new ShopError({ code: "shop.subscriptionExists" }, "You already have an existing Monthly Good subscription. Changes can be made in your subscription settings.");
|
|
76
|
+
}
|
|
77
|
+
if (subsData?.my?.autoDeposit?.id) {
|
|
78
|
+
throw new ShopError({ code: "shop.autoDepositExists" }, "You already have existing Auto Deposit settings. Changes can be made in your subscription settings.");
|
|
79
|
+
}
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
async function executeNewSubscriptionCheckout({
|
|
83
|
+
amount,
|
|
84
|
+
apollo,
|
|
85
|
+
dayOfMonth = (/* @__PURE__ */ new Date()).getDate(),
|
|
86
|
+
donateAmount,
|
|
87
|
+
paymentMethod
|
|
88
|
+
}) {
|
|
89
|
+
const amountRegex = new RegExp(/^\d+\.\d{2}$/);
|
|
90
|
+
if (!amountRegex.test(amount) || !amountRegex.test(donateAmount)) {
|
|
91
|
+
throw new ShopError({
|
|
92
|
+
code: "api.invalidMethodParameter"
|
|
93
|
+
}, "Please check that the amount is correct and try again.");
|
|
94
|
+
}
|
|
95
|
+
await checkSubscriptionStatus(apollo);
|
|
96
|
+
const { deviceData, nonce } = paymentMethod;
|
|
97
|
+
let data;
|
|
98
|
+
let error;
|
|
99
|
+
try {
|
|
100
|
+
const result = await apollo.query({
|
|
101
|
+
variables: {
|
|
102
|
+
dayOfMonth,
|
|
103
|
+
deviceData,
|
|
104
|
+
nonce
|
|
105
|
+
},
|
|
106
|
+
query: import_core.gql`mutation createAutoDepositSubscription(
|
|
107
|
+
$nonce: String!,
|
|
108
|
+
$deviceData: String,
|
|
109
|
+
$amount: Money!,
|
|
110
|
+
$donateAmount: Money!,
|
|
111
|
+
$dayOfMonth: Int!
|
|
112
|
+
) {
|
|
113
|
+
my {
|
|
114
|
+
createAutoDeposit (
|
|
115
|
+
autoDeposit: {
|
|
116
|
+
amount: $amount,
|
|
117
|
+
donateAmount: $donateAmount,
|
|
118
|
+
dayOfMonth: $dayOfMonth,
|
|
119
|
+
},
|
|
120
|
+
deviceData: $deviceData,
|
|
121
|
+
paymentMethodNonce: $nonce
|
|
122
|
+
) {
|
|
123
|
+
id amount donateAmount dayOfMonth status
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}`
|
|
127
|
+
});
|
|
128
|
+
if (result.error || result.errors.length) {
|
|
129
|
+
error = result.error ?? result.errors[0];
|
|
130
|
+
} else {
|
|
131
|
+
data = result.data;
|
|
132
|
+
}
|
|
133
|
+
} catch (e) {
|
|
134
|
+
error = e;
|
|
135
|
+
}
|
|
136
|
+
if (error) {
|
|
137
|
+
const parsed = parseShopError(error);
|
|
138
|
+
if (parsed.code === "shop.unknown") {
|
|
139
|
+
throw new ShopError({
|
|
140
|
+
code: "shop.createAutoDepositError",
|
|
141
|
+
original: parsed
|
|
142
|
+
}, "There was a problem trying to setup your monthly deposit.");
|
|
143
|
+
}
|
|
144
|
+
throw parsed;
|
|
145
|
+
}
|
|
146
|
+
return data?.my?.createAutoDeposit;
|
|
147
|
+
}
|
|
148
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
149
|
+
0 && (module.exports = {
|
|
150
|
+
checkSubscriptionStatus,
|
|
151
|
+
executeNewSubscriptionCheckout
|
|
152
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PaymentMethodPayload } from 'braintree-web-drop-in';
|
|
2
|
+
|
|
3
|
+
declare function checkSubscriptionStatus(apollo: any): Promise<boolean>;
|
|
4
|
+
interface SubscriptionCheckoutOptions {
|
|
5
|
+
amount: string;
|
|
6
|
+
apollo: any;
|
|
7
|
+
dayOfMonth?: number;
|
|
8
|
+
donateAmount: string;
|
|
9
|
+
paymentMethod: PaymentMethodPayload;
|
|
10
|
+
}
|
|
11
|
+
declare function executeNewSubscriptionCheckout({ amount, apollo, dayOfMonth, donateAmount, paymentMethod, }: SubscriptionCheckoutOptions): Promise<any>;
|
|
12
|
+
|
|
13
|
+
export { SubscriptionCheckoutOptions, checkSubscriptionStatus, executeNewSubscriptionCheckout };
|
|
@@ -0,0 +1,218 @@
|
|
|
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/useBraintreeDropIn.ts
|
|
30
|
+
var useBraintreeDropIn_exports = {};
|
|
31
|
+
__export(useBraintreeDropIn_exports, {
|
|
32
|
+
default: () => useBraintreeDropIn,
|
|
33
|
+
defaultPaymentTypes: () => defaultPaymentTypes,
|
|
34
|
+
getClientToken: () => getClientToken
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(useBraintreeDropIn_exports);
|
|
37
|
+
var import_core = require("@apollo/client/core");
|
|
38
|
+
var import_numeral = __toESM(require("numeral"), 1);
|
|
39
|
+
var import_vue_demi = require("vue-demi");
|
|
40
|
+
|
|
41
|
+
// src/shopError.ts
|
|
42
|
+
var ShopError = class extends Error {
|
|
43
|
+
constructor({ code, original }, ...params) {
|
|
44
|
+
super(...params);
|
|
45
|
+
if (Error.captureStackTrace) {
|
|
46
|
+
Error.captureStackTrace(this, ShopError);
|
|
47
|
+
}
|
|
48
|
+
this.name = "ShopError";
|
|
49
|
+
this.code = code;
|
|
50
|
+
this.original = original;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
function parseShopError(error) {
|
|
54
|
+
const errorCode = error?.code ?? error?.name ?? "";
|
|
55
|
+
const errorMessage = typeof error === "string" ? error : error?.message ?? "";
|
|
56
|
+
if (errorCode === "invalidMethodParameter" && errorMessage.includes("paymentMethod.create")) {
|
|
57
|
+
return new ShopError({
|
|
58
|
+
code: "paymentMethod.create.invalidMethodParameter",
|
|
59
|
+
original: error
|
|
60
|
+
}, "There was a problem validating your payment information. Please double-check the details and try again.");
|
|
61
|
+
}
|
|
62
|
+
return new ShopError({
|
|
63
|
+
code: "shop.unknown",
|
|
64
|
+
original: error
|
|
65
|
+
}, "An unknown error occurred.");
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// src/useBraintreeDropIn.ts
|
|
69
|
+
var defaultPaymentTypes = ["paypal", "card", "applePay", "googlePay"];
|
|
70
|
+
async function getClientToken(apollo) {
|
|
71
|
+
const { data, error, errors } = await apollo.query({
|
|
72
|
+
query: import_core.gql`query getClientToken {
|
|
73
|
+
shop {
|
|
74
|
+
id
|
|
75
|
+
getClientToken(useCustomerId: true)
|
|
76
|
+
}
|
|
77
|
+
}`
|
|
78
|
+
});
|
|
79
|
+
if (error || errors.length) {
|
|
80
|
+
throw parseShopError(error ?? errors[0]);
|
|
81
|
+
}
|
|
82
|
+
return data?.shop?.getClientToken;
|
|
83
|
+
}
|
|
84
|
+
function useBraintreeDropIn() {
|
|
85
|
+
let instance;
|
|
86
|
+
let formattedAmount = "";
|
|
87
|
+
const paymentMethodRequestable = (0, import_vue_demi.ref)(false);
|
|
88
|
+
function getApplePaymentRequest(amount) {
|
|
89
|
+
return {
|
|
90
|
+
countryCode: "US",
|
|
91
|
+
currencyCode: "USD",
|
|
92
|
+
// merchantCapabilities: ['supports3DS'], // TODO: confirm/update
|
|
93
|
+
requiredBillingContactFields: ["postalAddress"],
|
|
94
|
+
// supportedNetworks: ['amex', 'discover', 'interac', 'jcb', 'masterCard', 'visa'], // TODO: confirm/update
|
|
95
|
+
total: {
|
|
96
|
+
label: "Kiva",
|
|
97
|
+
amount
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function getGoogleTransactionInfo(amount) {
|
|
102
|
+
return {
|
|
103
|
+
totalPriceStatus: "FINAL",
|
|
104
|
+
totalPrice: amount,
|
|
105
|
+
currencyCode: "USD",
|
|
106
|
+
countryCode: "US"
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function initDropInActions() {
|
|
110
|
+
if (instance.isPaymentMethodRequestable()) {
|
|
111
|
+
paymentMethodRequestable.value = true;
|
|
112
|
+
}
|
|
113
|
+
instance.on("paymentMethodRequestable", (event) => {
|
|
114
|
+
paymentMethodRequestable.value = true;
|
|
115
|
+
});
|
|
116
|
+
instance.on("noPaymentMethodRequestable", () => {
|
|
117
|
+
paymentMethodRequestable.value = false;
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
async function initDropIn({
|
|
121
|
+
amount,
|
|
122
|
+
authToken,
|
|
123
|
+
container,
|
|
124
|
+
googlePayMerchantId,
|
|
125
|
+
paymentTypes = [...defaultPaymentTypes],
|
|
126
|
+
preselectVaultedPaymentMethod = true,
|
|
127
|
+
paypalFlow = "checkout"
|
|
128
|
+
}) {
|
|
129
|
+
formattedAmount = (0, import_numeral.default)(amount).format("0.00");
|
|
130
|
+
const { default: DropIn } = await import("braintree-web-drop-in");
|
|
131
|
+
try {
|
|
132
|
+
instance = await DropIn.create({
|
|
133
|
+
authorization: authToken,
|
|
134
|
+
container,
|
|
135
|
+
dataCollector: {
|
|
136
|
+
kount: true
|
|
137
|
+
// Required if Kount fraud data collection is enabled
|
|
138
|
+
},
|
|
139
|
+
// vaultManager: true, - Useful for testing and removing payment methods easily.
|
|
140
|
+
paymentOptionPriority: paymentTypes,
|
|
141
|
+
preselectVaultedPaymentMethod,
|
|
142
|
+
card: {
|
|
143
|
+
vault: {
|
|
144
|
+
allowVaultCardOverride: true
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
paypal: {
|
|
148
|
+
flow: paypalFlow,
|
|
149
|
+
amount: formattedAmount,
|
|
150
|
+
currency: "USD",
|
|
151
|
+
buttonStyle: {
|
|
152
|
+
// @ts-ignore
|
|
153
|
+
color: "gold",
|
|
154
|
+
// @ts-ignore
|
|
155
|
+
shape: "rect",
|
|
156
|
+
// @ts-ignore
|
|
157
|
+
size: "responsive"
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
googlePay: {
|
|
161
|
+
googlePayVersion: 2,
|
|
162
|
+
merchantId: googlePayMerchantId,
|
|
163
|
+
transactionInfo: getGoogleTransactionInfo(formattedAmount),
|
|
164
|
+
button: {
|
|
165
|
+
allowedPaymentMethods: [{
|
|
166
|
+
type: "CARD",
|
|
167
|
+
// @ts-ignore
|
|
168
|
+
parameters: {
|
|
169
|
+
// allowedAuthMethods: ['PAN_ONLY', 'CRYPTOGRAM_3DS'], // TODO: confirm/update
|
|
170
|
+
// allowedCardNetworks: ['AMEX', 'DISCOVER', 'INTERAC', 'JCB', 'MASTERCARD', 'VISA'], // TODO: confirm/update
|
|
171
|
+
billingAddressRequired: true,
|
|
172
|
+
billingAddressParameters: {
|
|
173
|
+
format: "FULL"
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}]
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
applePay: {
|
|
180
|
+
displayName: "Kiva",
|
|
181
|
+
paymentRequest: getApplePaymentRequest(formattedAmount)
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
initDropInActions();
|
|
185
|
+
} catch (e) {
|
|
186
|
+
throw new ShopError({
|
|
187
|
+
code: "shop.braintreeDropinInitError",
|
|
188
|
+
original: e
|
|
189
|
+
}, "An Error has occured. Please refresh the page and try again.");
|
|
190
|
+
}
|
|
191
|
+
return instance;
|
|
192
|
+
}
|
|
193
|
+
async function requestPaymentMethod() {
|
|
194
|
+
if (instance.isPaymentMethodRequestable()) {
|
|
195
|
+
return instance.requestPaymentMethod();
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
function updateAmount(amount) {
|
|
199
|
+
const newAmount = (0, import_numeral.default)(amount).format("0.00");
|
|
200
|
+
if (newAmount !== formattedAmount) {
|
|
201
|
+
formattedAmount = newAmount;
|
|
202
|
+
instance?.updateConfiguration("paypal", "amount", formattedAmount);
|
|
203
|
+
instance?.updateConfiguration("googlePay", "transactionInfo", getGoogleTransactionInfo(formattedAmount));
|
|
204
|
+
instance?.updateConfiguration?.("applePay", "paymentRequest", getApplePaymentRequest(formattedAmount));
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return {
|
|
208
|
+
initDropIn,
|
|
209
|
+
paymentMethodRequestable,
|
|
210
|
+
requestPaymentMethod,
|
|
211
|
+
updateAmount
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
215
|
+
0 && (module.exports = {
|
|
216
|
+
defaultPaymentTypes,
|
|
217
|
+
getClientToken
|
|
218
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as braintree_web_drop_in from 'braintree-web-drop-in';
|
|
2
|
+
import { Dropin } from 'braintree-web-drop-in';
|
|
3
|
+
import * as _vue_composition_api from '@vue/composition-api';
|
|
4
|
+
|
|
5
|
+
declare type PaymentType = 'card' | 'paypal' | 'paypalCredit' | 'venmo' | 'applePay' | 'googlePay';
|
|
6
|
+
declare type PayPalFlowType = 'checkout' | 'vault';
|
|
7
|
+
declare const defaultPaymentTypes: readonly ["paypal", "card", "applePay", "googlePay"];
|
|
8
|
+
declare function getClientToken(apollo: any): Promise<any>;
|
|
9
|
+
interface DropInInitOptions {
|
|
10
|
+
amount: string | number;
|
|
11
|
+
authToken: string;
|
|
12
|
+
container: string | HTMLElement;
|
|
13
|
+
googlePayMerchantId: string;
|
|
14
|
+
paymentTypes?: PaymentType[];
|
|
15
|
+
preselectVaultedPaymentMethod?: boolean;
|
|
16
|
+
paypalFlow?: PayPalFlowType;
|
|
17
|
+
}
|
|
18
|
+
declare function useBraintreeDropIn(): {
|
|
19
|
+
initDropIn: ({ amount, authToken, container, googlePayMerchantId, paymentTypes, preselectVaultedPaymentMethod, paypalFlow, }: DropInInitOptions) => Promise<Dropin>;
|
|
20
|
+
paymentMethodRequestable: _vue_composition_api.Ref<boolean>;
|
|
21
|
+
requestPaymentMethod: () => Promise<braintree_web_drop_in.PaymentMethodPayload>;
|
|
22
|
+
updateAmount: (amount: string | number) => void;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export { DropInInitOptions, PayPalFlowType, PaymentType, useBraintreeDropIn as default, defaultPaymentTypes, getClientToken };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kiva/kv-shop",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"scripts": {
|
|
22
|
-
"build": "tsup src
|
|
22
|
+
"build": "tsup src/*.ts --format cjs,esm --dts --clean && cp -R src/components/ dist/components/",
|
|
23
23
|
"lint": "eslint --ext .ts,.vue ./src",
|
|
24
24
|
"test": "jest"
|
|
25
25
|
},
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"optional": true
|
|
54
54
|
}
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "2ad76dbc917ebd7ce1ef1278f8ce6164b8acfc57"
|
|
57
57
|
}
|
package/dist/basket.spec.cjs
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// src/basket.ts
|
|
2
|
-
var getCookieValue = (name) => {
|
|
3
|
-
if (typeof document !== void 0) {
|
|
4
|
-
return decodeURIComponent(document.cookie.match(`(^|;)\\s*${name}\\s*=\\s*([^;]+)`)?.pop() || "");
|
|
5
|
-
}
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
// src/tests/basket.spec.ts
|
|
9
|
-
describe("basket.ts", () => {
|
|
10
|
-
it("encoded token", () => {
|
|
11
|
-
const encodedToken = encodeURIComponent("tests==");
|
|
12
|
-
expect(encodedToken).toEqual("tests%3D%3D");
|
|
13
|
-
document.cookie = `encoded=${encodedToken}; Max-Age=5;`;
|
|
14
|
-
const decodedToken = getCookieValue("encoded");
|
|
15
|
-
expect(decodedToken).toEqual("tests==");
|
|
16
|
-
});
|
|
17
|
-
});
|
package/dist/basket.spec.d.ts
DELETED
package/dist/basket.spec.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// src/basket.ts
|
|
2
|
-
var getCookieValue = (name) => {
|
|
3
|
-
if (typeof document !== void 0) {
|
|
4
|
-
return decodeURIComponent(document.cookie.match(`(^|;)\\s*${name}\\s*=\\s*([^;]+)`)?.pop() || "");
|
|
5
|
-
}
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
// src/tests/basket.spec.ts
|
|
9
|
-
describe("basket.ts", () => {
|
|
10
|
-
it("encoded token", () => {
|
|
11
|
-
const encodedToken = encodeURIComponent("tests==");
|
|
12
|
-
expect(encodedToken).toEqual("tests%3D%3D");
|
|
13
|
-
document.cookie = `encoded=${encodedToken}; Max-Age=5;`;
|
|
14
|
-
const decodedToken = getCookieValue("encoded");
|
|
15
|
-
expect(decodedToken).toEqual("tests==");
|
|
16
|
-
});
|
|
17
|
-
});
|