@rechargeapps/storefront-client 1.70.2 → 1.70.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/cjs/api/auth.js +1 -1
- package/dist/cjs/api/bundleData.js +1 -1
- package/dist/cjs/api/paymentMethod.js +263 -0
- package/dist/cjs/api/paymentMethod.js.map +1 -1
- package/dist/cjs/index.js +1 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/utils/request.js +1 -1
- package/dist/esm/api/auth.js +1 -1
- package/dist/esm/api/bundleData.js +1 -1
- package/dist/esm/api/paymentMethod.js +263 -1
- package/dist/esm/api/paymentMethod.js.map +1 -1
- package/dist/esm/index.js +1 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/request.js +1 -1
- package/dist/index.d.ts +150 -152
- package/dist/umd/recharge-client.min.js +10 -10
- package/package.json +1 -1
- package/dist/cjs/api/paymentMethodForm.js +0 -270
- package/dist/cjs/api/paymentMethodForm.js.map +0 -1
- package/dist/esm/api/paymentMethodForm.js +0 -268
- package/dist/esm/api/paymentMethodForm.js.map +0 -1
package/dist/cjs/api/auth.js
CHANGED
|
@@ -181,7 +181,7 @@ async function rechargeAdminRequest(method, url, { id, query, data, headers } =
|
|
|
181
181
|
...storefrontAccessToken ? { "X-Recharge-Storefront-Access-Token": storefrontAccessToken } : {},
|
|
182
182
|
...appName ? { "X-Recharge-Sdk-App-Name": appName } : {},
|
|
183
183
|
...appVersion ? { "X-Recharge-Sdk-App-Version": appVersion } : {},
|
|
184
|
-
"X-Recharge-Sdk-Version": "1.70.
|
|
184
|
+
"X-Recharge-Sdk-Version": "1.70.3",
|
|
185
185
|
...headers ? headers : {}
|
|
186
186
|
};
|
|
187
187
|
return request.request(method, `${rechargeBaseUrl}${url}`, { id, query, data, headers: reqHeaders });
|
|
@@ -15,7 +15,7 @@ async function loadFromOnlineStore(id, country_code) {
|
|
|
15
15
|
const { appName, appVersion } = options.getOptions();
|
|
16
16
|
const headers = {
|
|
17
17
|
"X-Recharge-Sdk-Fn": "loadFromOnlineStore",
|
|
18
|
-
"X-Recharge-Sdk-Version": "1.70.
|
|
18
|
+
"X-Recharge-Sdk-Version": "1.70.3",
|
|
19
19
|
...appName ? { "X-Recharge-Sdk-App-Name": appName } : {},
|
|
20
20
|
...appVersion ? { "X-Recharge-Sdk-App-Version": appVersion } : {}
|
|
21
21
|
};
|
|
@@ -51,9 +51,272 @@ function listPaymentMethods(session, query) {
|
|
|
51
51
|
request.getInternalSession(session, "listPaymentMethods")
|
|
52
52
|
);
|
|
53
53
|
}
|
|
54
|
+
async function initFrictionlessPaymentV1(session, rechargePaymentMethodId) {
|
|
55
|
+
const intentResponse = await createFrictionlessPaymentIntentV1(session, rechargePaymentMethodId);
|
|
56
|
+
const environmentKey = intentResponse.external.environment_key;
|
|
57
|
+
const paymentMethodIntentId = intentResponse.payment_method_intent_id;
|
|
58
|
+
const externalCustomerId = intentResponse.external_customer_id.ecommerce;
|
|
59
|
+
const resourceUrl = intentResponse.external.resource_url;
|
|
60
|
+
const integrityHash = intentResponse.external.integrity_hash;
|
|
61
|
+
const externalPaymentMethodId = intentResponse.payment_method?.processor_payment_method_token;
|
|
62
|
+
await loadScript(resourceUrl, integrityHash);
|
|
63
|
+
let isInitialized = false;
|
|
64
|
+
let currentToken = null;
|
|
65
|
+
let tokenCallback = null;
|
|
66
|
+
let pendingSubmitOptions = null;
|
|
67
|
+
const controller = {
|
|
68
|
+
mount(config, handlers) {
|
|
69
|
+
if (typeof window === "undefined" || !window.Spreedly) {
|
|
70
|
+
throw new Error("Payment script failed to load");
|
|
71
|
+
}
|
|
72
|
+
window.Spreedly.init(environmentKey, {
|
|
73
|
+
numberEl: config.numberElementId,
|
|
74
|
+
cvvEl: config.cvvElementId
|
|
75
|
+
});
|
|
76
|
+
window.Spreedly.on("ready", () => {
|
|
77
|
+
isInitialized = true;
|
|
78
|
+
if (config.styles) {
|
|
79
|
+
window.Spreedly.setStyle("number", config.styles);
|
|
80
|
+
window.Spreedly.setStyle("cvv", config.styles);
|
|
81
|
+
}
|
|
82
|
+
if (config.numberLabel) {
|
|
83
|
+
window.Spreedly.setLabel("number", config.numberLabel);
|
|
84
|
+
}
|
|
85
|
+
if (config.cvvLabel) {
|
|
86
|
+
window.Spreedly.setLabel("cvv", config.cvvLabel);
|
|
87
|
+
}
|
|
88
|
+
if (config.numberPlaceholder) {
|
|
89
|
+
window.Spreedly.setPlaceholder("number", config.numberPlaceholder);
|
|
90
|
+
}
|
|
91
|
+
if (config.cvvPlaceholder) {
|
|
92
|
+
window.Spreedly.setPlaceholder("cvv", config.cvvPlaceholder);
|
|
93
|
+
}
|
|
94
|
+
if (config.numberFormat === "plainFormat") {
|
|
95
|
+
if (config.numberFieldType) {
|
|
96
|
+
window.Spreedly.setFieldType("number", config.numberFieldType);
|
|
97
|
+
}
|
|
98
|
+
if (config.cvvFieldType) {
|
|
99
|
+
window.Spreedly.setFieldType("cvv", config.cvvFieldType);
|
|
100
|
+
}
|
|
101
|
+
window.Spreedly.setNumberFormat("plainFormat");
|
|
102
|
+
} else if (config.numberFormat === "maskedFormat") {
|
|
103
|
+
window.Spreedly.setFieldType("cvv", "text");
|
|
104
|
+
window.Spreedly.setFieldType("number", "text");
|
|
105
|
+
window.Spreedly.setNumberFormat("maskedFormat");
|
|
106
|
+
} else if (config.numberFormat === "prettyFormat") {
|
|
107
|
+
if (config.numberFieldType === "text" || config.numberFieldType === "tel") {
|
|
108
|
+
window.Spreedly.setFieldType("number", config.numberFieldType);
|
|
109
|
+
} else {
|
|
110
|
+
window.Spreedly.setFieldType("number", "tel");
|
|
111
|
+
}
|
|
112
|
+
if (config.cvvFieldType === "text" || config.cvvFieldType === "tel") {
|
|
113
|
+
window.Spreedly.setFieldType("cvv", config.cvvFieldType);
|
|
114
|
+
} else {
|
|
115
|
+
window.Spreedly.setFieldType("cvv", "tel");
|
|
116
|
+
}
|
|
117
|
+
window.Spreedly.setNumberFormat("prettyFormat");
|
|
118
|
+
} else {
|
|
119
|
+
if (config.numberFieldType) {
|
|
120
|
+
window.Spreedly.setFieldType("number", config.numberFieldType);
|
|
121
|
+
}
|
|
122
|
+
if (config.cvvFieldType) {
|
|
123
|
+
window.Spreedly.setFieldType("cvv", config.cvvFieldType);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
handlers?.onReady?.();
|
|
127
|
+
});
|
|
128
|
+
window.Spreedly.on("fieldEvent", (name, eventType, activeElement, inputProperties) => {
|
|
129
|
+
handlers?.onFieldEvent?.(name, eventType, activeElement, inputProperties);
|
|
130
|
+
});
|
|
131
|
+
window.Spreedly.on("errors", (errors) => {
|
|
132
|
+
handlers?.onErrors?.(errors);
|
|
133
|
+
});
|
|
134
|
+
window.Spreedly.on("paymentMethod", (token, paymentMethod) => {
|
|
135
|
+
currentToken = token;
|
|
136
|
+
handlers?.onPaymentMethod?.(token, paymentMethod);
|
|
137
|
+
if (tokenCallback) {
|
|
138
|
+
tokenCallback(token);
|
|
139
|
+
tokenCallback = null;
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
},
|
|
143
|
+
tokenize(cardDetails) {
|
|
144
|
+
if (!isInitialized || !window.Spreedly) {
|
|
145
|
+
throw new Error("Payment form is not initialized");
|
|
146
|
+
}
|
|
147
|
+
let year = String(cardDetails.year);
|
|
148
|
+
if (year.length === 2) {
|
|
149
|
+
year = `20${year}`;
|
|
150
|
+
}
|
|
151
|
+
const month = String(cardDetails.month).padStart(2, "0");
|
|
152
|
+
if ("full_name" in cardDetails) {
|
|
153
|
+
window.Spreedly.tokenizeCreditCard({
|
|
154
|
+
full_name: cardDetails.full_name,
|
|
155
|
+
month,
|
|
156
|
+
year
|
|
157
|
+
});
|
|
158
|
+
} else {
|
|
159
|
+
window.Spreedly.tokenizeCreditCard({
|
|
160
|
+
first_name: cardDetails.first_name,
|
|
161
|
+
last_name: cardDetails.last_name,
|
|
162
|
+
month,
|
|
163
|
+
year
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
async submit(options) {
|
|
168
|
+
if (!isInitialized) {
|
|
169
|
+
throw new Error("Payment form is not initialized");
|
|
170
|
+
}
|
|
171
|
+
if (currentToken) {
|
|
172
|
+
const token = currentToken;
|
|
173
|
+
currentToken = null;
|
|
174
|
+
return submitFrictionlessPaymentMethodV1(session, token, options, {
|
|
175
|
+
external_payment_method_id: externalPaymentMethodId,
|
|
176
|
+
payment_method_intent_id: paymentMethodIntentId,
|
|
177
|
+
external_customer_id: externalCustomerId
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
return new Promise((resolve) => {
|
|
181
|
+
pendingSubmitOptions = options;
|
|
182
|
+
tokenCallback = async (token) => {
|
|
183
|
+
const result = await submitFrictionlessPaymentMethodV1(session, token, pendingSubmitOptions, {
|
|
184
|
+
external_payment_method_id: externalPaymentMethodId,
|
|
185
|
+
payment_method_intent_id: paymentMethodIntentId,
|
|
186
|
+
external_customer_id: externalCustomerId
|
|
187
|
+
});
|
|
188
|
+
pendingSubmitOptions = null;
|
|
189
|
+
resolve(result);
|
|
190
|
+
};
|
|
191
|
+
this.tokenize(options.card_details);
|
|
192
|
+
});
|
|
193
|
+
},
|
|
194
|
+
reset() {
|
|
195
|
+
if (window.Spreedly) {
|
|
196
|
+
window.Spreedly.reload();
|
|
197
|
+
}
|
|
198
|
+
currentToken = null;
|
|
199
|
+
tokenCallback = null;
|
|
200
|
+
pendingSubmitOptions = null;
|
|
201
|
+
},
|
|
202
|
+
unmount() {
|
|
203
|
+
if (window.Spreedly) {
|
|
204
|
+
window.Spreedly.removeHandlers();
|
|
205
|
+
}
|
|
206
|
+
isInitialized = false;
|
|
207
|
+
currentToken = null;
|
|
208
|
+
tokenCallback = null;
|
|
209
|
+
pendingSubmitOptions = null;
|
|
210
|
+
},
|
|
211
|
+
addEventHandlers(handlers) {
|
|
212
|
+
if (handlers.onReady) {
|
|
213
|
+
window.Spreedly.on("ready", handlers.onReady);
|
|
214
|
+
}
|
|
215
|
+
if (handlers.onFieldEvent) {
|
|
216
|
+
window.Spreedly.on("fieldEvent", handlers.onFieldEvent);
|
|
217
|
+
}
|
|
218
|
+
if (handlers.onErrors) {
|
|
219
|
+
window.Spreedly.on("errors", handlers.onErrors);
|
|
220
|
+
}
|
|
221
|
+
if (handlers.onPaymentMethod) {
|
|
222
|
+
window.Spreedly.on("paymentMethod", handlers.onPaymentMethod);
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
removeHandlers() {
|
|
226
|
+
if (window.Spreedly) {
|
|
227
|
+
window.Spreedly.removeHandlers();
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
setFieldType(name, type) {
|
|
231
|
+
window.Spreedly.setFieldType(name, type);
|
|
232
|
+
},
|
|
233
|
+
setLabel(name, label) {
|
|
234
|
+
window.Spreedly.setLabel(name, label);
|
|
235
|
+
},
|
|
236
|
+
setNumberFormat(format) {
|
|
237
|
+
window.Spreedly.setNumberFormat(format);
|
|
238
|
+
},
|
|
239
|
+
setPlaceholder(name, placeholder) {
|
|
240
|
+
window.Spreedly.setPlaceholder(name, placeholder);
|
|
241
|
+
},
|
|
242
|
+
setStyle(name, style) {
|
|
243
|
+
window.Spreedly.setStyle(name, style);
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
return controller;
|
|
247
|
+
}
|
|
248
|
+
async function loadScript(scriptSrc, integrity) {
|
|
249
|
+
if (typeof window !== "undefined" && window.Spreedly) {
|
|
250
|
+
return Promise.resolve();
|
|
251
|
+
}
|
|
252
|
+
return new Promise((resolve, reject) => {
|
|
253
|
+
if (typeof document === "undefined") {
|
|
254
|
+
reject(new Error("Document is not available. This function must be called in a browser environment."));
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
const existingScript = document.querySelector(`script[src="${scriptSrc}"]`);
|
|
258
|
+
if (existingScript) {
|
|
259
|
+
const checkLoaded = () => {
|
|
260
|
+
if (window.Spreedly) {
|
|
261
|
+
resolve();
|
|
262
|
+
} else {
|
|
263
|
+
setTimeout(checkLoaded, 50);
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
checkLoaded();
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
const script = document.createElement("script");
|
|
270
|
+
script.src = scriptSrc;
|
|
271
|
+
script.integrity = integrity;
|
|
272
|
+
script.crossOrigin = "anonymous";
|
|
273
|
+
script.addEventListener("load", () => {
|
|
274
|
+
const checkLoaded = () => {
|
|
275
|
+
if (window.Spreedly) {
|
|
276
|
+
resolve();
|
|
277
|
+
} else {
|
|
278
|
+
setTimeout(checkLoaded, 50);
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
checkLoaded();
|
|
282
|
+
});
|
|
283
|
+
script.addEventListener("error", () => {
|
|
284
|
+
reject(new Error("Failed to load payment iFrame script"));
|
|
285
|
+
});
|
|
286
|
+
document.head.appendChild(script);
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
async function createFrictionlessPaymentIntentV1(session, rechargePaymentMethodId) {
|
|
290
|
+
const id = session.customerId;
|
|
291
|
+
if (!id) {
|
|
292
|
+
throw new Error("Not logged in.");
|
|
293
|
+
}
|
|
294
|
+
const response = await request.rechargeApiRequest(
|
|
295
|
+
"post",
|
|
296
|
+
"/payment_method_intents",
|
|
297
|
+
{ data: { customer_id: id, payment_method_id: rechargePaymentMethodId } },
|
|
298
|
+
request.getInternalSession(session, "createFrictionlessPaymentIntentV1")
|
|
299
|
+
);
|
|
300
|
+
return response;
|
|
301
|
+
}
|
|
302
|
+
async function submitFrictionlessPaymentMethodV1(session, token, { billing_address, default_payment_method, address_ids }, { external_payment_method_id, payment_method_intent_id, external_customer_id }) {
|
|
303
|
+
const paymentMethod = await createPaymentMethod(request.getInternalSession(session, "submitFrictionlessPaymentMethodV1"), {
|
|
304
|
+
default: default_payment_method ?? false,
|
|
305
|
+
payment_type: "CREDIT_CARD",
|
|
306
|
+
processor_customer_token: external_customer_id.toString(),
|
|
307
|
+
processor_name: "frictionless",
|
|
308
|
+
processor_payment_method_token: token,
|
|
309
|
+
billing_address,
|
|
310
|
+
payment_method_intent_id,
|
|
311
|
+
address_ids,
|
|
312
|
+
external_payment_method_id
|
|
313
|
+
});
|
|
314
|
+
return paymentMethod;
|
|
315
|
+
}
|
|
54
316
|
|
|
55
317
|
exports.createPaymentMethod = createPaymentMethod;
|
|
56
318
|
exports.getPaymentMethod = getPaymentMethod;
|
|
319
|
+
exports.initFrictionlessPaymentV1 = initFrictionlessPaymentV1;
|
|
57
320
|
exports.listPaymentMethods = listPaymentMethods;
|
|
58
321
|
exports.updatePaymentMethod = updatePaymentMethod;
|
|
59
322
|
//# sourceMappingURL=paymentMethod.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paymentMethod.js","sources":["../../../src/api/paymentMethod.ts"],"sourcesContent":["import {\n CreatePaymentMethodRequest,\n GetPaymentMethodOptions,\n PaymentMethod,\n PaymentMethodListParams,\n PaymentMethodsResponse,\n UpdatePaymentMethodRequest,\n Session,\n} from '../types';\nimport { getInternalSession, rechargeApiRequest } from '../utils/request';\n\nexport async function getPaymentMethod(\n session: Session,\n id: string | number,\n options?: GetPaymentMethodOptions\n): Promise<PaymentMethod> {\n if (id === undefined || id === '') {\n throw new Error('ID is required');\n }\n const { payment_method } = await rechargeApiRequest<{ payment_method: PaymentMethod }>(\n 'get',\n `/payment_methods`,\n {\n id,\n query: { include: options?.include },\n },\n getInternalSession(session, 'getPaymentMethod')\n );\n return payment_method;\n}\n\n/**\n * Create a Payment Method\n *\n * Currently, `shopify_payments` is in read-only mode and can only be managed by Shopify.\n */\nexport async function createPaymentMethod(\n session: Session,\n createRequest: CreatePaymentMethodRequest\n): Promise<PaymentMethod> {\n const { payment_method } = await rechargeApiRequest<{ payment_method: PaymentMethod }>(\n 'post',\n `/payment_methods`,\n {\n data: { ...createRequest, customer_id: session.customerId },\n },\n getInternalSession(session, 'createPaymentMethod')\n );\n return payment_method;\n}\n\n/**\n * Modify an existing Payment Method\n *\n * Currently, `shopify_payments` is in read-only mode and can only be managed by Shopify.\n */\nexport async function updatePaymentMethod(\n session: Session,\n id: string | number,\n updateRequest: UpdatePaymentMethodRequest\n): Promise<PaymentMethod> {\n if (id === undefined || id === '') {\n throw new Error('ID is required');\n }\n const { payment_method } = await rechargeApiRequest<{ payment_method: PaymentMethod }>(\n 'put',\n `/payment_methods`,\n {\n id,\n data: updateRequest,\n },\n getInternalSession(session, 'updatePaymentMethod')\n );\n return payment_method;\n}\n\nexport function listPaymentMethods(session: Session, query?: PaymentMethodListParams): Promise<PaymentMethodsResponse> {\n return rechargeApiRequest<PaymentMethodsResponse>(\n 'get',\n `/payment_methods`,\n { query },\n getInternalSession(session, 'listPaymentMethods')\n );\n}\n"],"names":["rechargeApiRequest","getInternalSession"],"mappings":";;;;AAWsB,eAAA,gBAAA,CACpB,OACA,EAAA,EAAA,EACA,OACwB,EAAA;AACxB,EAAI,IAAA,EAAA,KAAO,KAAa,CAAA,IAAA,EAAA,KAAO,EAAI,EAAA;AACjC,IAAM,MAAA,IAAI,MAAM,gBAAgB,CAAA,CAAA;AAAA,GAClC;AACA,EAAM,MAAA,EAAE,cAAe,EAAA,GAAI,MAAMA,0BAAA;AAAA,IAC/B,KAAA;AAAA,IACA,CAAA,gBAAA,CAAA;AAAA,IACA;AAAA,MACE,EAAA;AAAA,MACA,KAAO,EAAA,EAAE,OAAS,EAAA,OAAA,EAAS,OAAQ,EAAA;AAAA,KACrC;AAAA,IACAC,0BAAA,CAAmB,SAAS,kBAAkB,CAAA;AAAA,GAChD,CAAA;AACA,EAAO,OAAA,cAAA,CAAA;AACT,CAAA;AAOsB,eAAA,mBAAA,CACpB,SACA,aACwB,EAAA;AACxB,EAAM,MAAA,EAAE,cAAe,EAAA,GAAI,MAAMD,0BAAA;AAAA,IAC/B,MAAA;AAAA,IACA,CAAA,gBAAA,CAAA;AAAA,IACA;AAAA,MACE,MAAM,EAAE,GAAG,aAAe,EAAA,WAAA,EAAa,QAAQ,UAAW,EAAA;AAAA,KAC5D;AAAA,IACAC,0BAAA,CAAmB,SAAS,qBAAqB,CAAA;AAAA,GACnD,CAAA;AACA,EAAO,OAAA,cAAA,CAAA;AACT,CAAA;AAOsB,eAAA,mBAAA,CACpB,OACA,EAAA,EAAA,EACA,aACwB,EAAA;AACxB,EAAI,IAAA,EAAA,KAAO,KAAa,CAAA,IAAA,EAAA,KAAO,EAAI,EAAA;AACjC,IAAM,MAAA,IAAI,MAAM,gBAAgB,CAAA,CAAA;AAAA,GAClC;AACA,EAAM,MAAA,EAAE,cAAe,EAAA,GAAI,MAAMD,0BAAA;AAAA,IAC/B,KAAA;AAAA,IACA,CAAA,gBAAA,CAAA;AAAA,IACA;AAAA,MACE,EAAA;AAAA,MACA,IAAM,EAAA,aAAA;AAAA,KACR;AAAA,IACAC,0BAAA,CAAmB,SAAS,qBAAqB,CAAA;AAAA,GACnD,CAAA;AACA,EAAO,OAAA,cAAA,CAAA;AACT,CAAA;AAEgB,SAAA,kBAAA,CAAmB,SAAkB,KAAkE,EAAA;AACrH,EAAO,OAAAD,0BAAA;AAAA,IACL,KAAA;AAAA,IACA,CAAA,gBAAA,CAAA;AAAA,IACA,EAAE,KAAM,EAAA;AAAA,IACRC,0BAAA,CAAmB,SAAS,oBAAoB,CAAA;AAAA,GAClD,CAAA;AACF;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"paymentMethod.js","sources":["../../../src/api/paymentMethod.ts"],"sourcesContent":["import {\n CardDetailsFirstNameLastName,\n CardDetailsFullName,\n CreatePaymentMethodRequest,\n GetPaymentMethodOptions,\n IsoDateString,\n PaymentFormConfig,\n PaymentFormController,\n PaymentFormEventHandlers,\n PaymentMethod,\n PaymentMethodFormOptions,\n PaymentMethodListParams,\n PaymentMethodsResponse,\n UpdatePaymentMethodRequest,\n Session,\n} from '../types';\nimport { getInternalSession, rechargeApiRequest } from '../utils/request';\n\nexport async function getPaymentMethod(\n session: Session,\n id: string | number,\n options?: GetPaymentMethodOptions\n): Promise<PaymentMethod> {\n if (id === undefined || id === '') {\n throw new Error('ID is required');\n }\n const { payment_method } = await rechargeApiRequest<{ payment_method: PaymentMethod }>(\n 'get',\n `/payment_methods`,\n {\n id,\n query: { include: options?.include },\n },\n getInternalSession(session, 'getPaymentMethod')\n );\n return payment_method;\n}\n\n/**\n * Create a Payment Method\n *\n * Currently, `shopify_payments` is in read-only mode and can only be managed by Shopify.\n */\nexport async function createPaymentMethod(\n session: Session,\n createRequest: CreatePaymentMethodRequest\n): Promise<PaymentMethod> {\n const { payment_method } = await rechargeApiRequest<{ payment_method: PaymentMethod }>(\n 'post',\n `/payment_methods`,\n {\n data: { ...createRequest, customer_id: session.customerId },\n },\n getInternalSession(session, 'createPaymentMethod')\n );\n return payment_method;\n}\n\n/**\n * Modify an existing Payment Method\n *\n * Currently, `shopify_payments` is in read-only mode and can only be managed by Shopify.\n */\nexport async function updatePaymentMethod(\n session: Session,\n id: string | number,\n updateRequest: UpdatePaymentMethodRequest\n): Promise<PaymentMethod> {\n if (id === undefined || id === '') {\n throw new Error('ID is required');\n }\n const { payment_method } = await rechargeApiRequest<{ payment_method: PaymentMethod }>(\n 'put',\n `/payment_methods`,\n {\n id,\n data: updateRequest,\n },\n getInternalSession(session, 'updatePaymentMethod')\n );\n return payment_method;\n}\n\nexport function listPaymentMethods(session: Session, query?: PaymentMethodListParams): Promise<PaymentMethodsResponse> {\n return rechargeApiRequest<PaymentMethodsResponse>(\n 'get',\n `/payment_methods`,\n { query },\n getInternalSession(session, 'listPaymentMethods')\n );\n}\n\n/** @internal */\nexport async function initFrictionlessPaymentV1(\n session: Session,\n rechargePaymentMethodId?: string\n): Promise<PaymentFormController> {\n // Initialize and get environment key\n const intentResponse = await createFrictionlessPaymentIntentV1(session, rechargePaymentMethodId);\n\n const environmentKey = intentResponse.external.environment_key;\n const paymentMethodIntentId = intentResponse.payment_method_intent_id;\n const externalCustomerId = intentResponse.external_customer_id.ecommerce;\n const resourceUrl = intentResponse.external.resource_url;\n const integrityHash = intentResponse.external.integrity_hash;\n const externalPaymentMethodId = intentResponse.payment_method?.processor_payment_method_token;\n\n // Load script\n await loadScript(resourceUrl, integrityHash);\n\n let isInitialized = false;\n let currentToken: string | null = null;\n let tokenCallback: ((token: string) => void) | null = null;\n let pendingSubmitOptions: PaymentMethodFormOptions | null = null;\n\n const controller: PaymentFormController = {\n mount(config: PaymentFormConfig, handlers?: PaymentFormEventHandlers): void {\n if (typeof window === 'undefined' || !window.Spreedly) {\n throw new Error('Payment script failed to load');\n }\n\n // Initialize Spreedly with element IDs\n window.Spreedly!.init(environmentKey, {\n numberEl: config.numberElementId,\n cvvEl: config.cvvElementId,\n });\n\n // Set up ready handler\n window.Spreedly!.on('ready', () => {\n isInitialized = true;\n\n // Apply styles\n if (config.styles) {\n window.Spreedly!.setStyle('number', config.styles);\n window.Spreedly!.setStyle('cvv', config.styles);\n }\n\n // Apply labels\n if (config.numberLabel) {\n window.Spreedly!.setLabel('number', config.numberLabel);\n }\n if (config.cvvLabel) {\n window.Spreedly!.setLabel('cvv', config.cvvLabel);\n }\n\n // Apply placeholders\n if (config.numberPlaceholder) {\n window.Spreedly!.setPlaceholder('number', config.numberPlaceholder);\n }\n if (config.cvvPlaceholder) {\n window.Spreedly!.setPlaceholder('cvv', config.cvvPlaceholder);\n }\n\n // Apply number format\n if (config.numberFormat === 'plainFormat') {\n // Apply field types\n if (config.numberFieldType) {\n window.Spreedly!.setFieldType('number', config.numberFieldType);\n }\n if (config.cvvFieldType) {\n window.Spreedly!.setFieldType('cvv', config.cvvFieldType);\n }\n // @ts-expect-error - SpreedlyNumberFormat doesn't match\n window.Spreedly!.setNumberFormat('plainFormat');\n } else if (config.numberFormat === 'maskedFormat') {\n window.Spreedly!.setFieldType('cvv', 'text');\n window.Spreedly!.setFieldType('number', 'text');\n window.Spreedly!.setNumberFormat('maskedFormat');\n } else if (config.numberFormat === 'prettyFormat') {\n // Apply field types\n if (config.numberFieldType === 'text' || config.numberFieldType === 'tel') {\n window.Spreedly!.setFieldType('number', config.numberFieldType);\n } else {\n window.Spreedly!.setFieldType('number', 'tel');\n }\n if (config.cvvFieldType === 'text' || config.cvvFieldType === 'tel') {\n window.Spreedly!.setFieldType('cvv', config.cvvFieldType);\n } else {\n window.Spreedly!.setFieldType('cvv', 'tel');\n }\n window.Spreedly!.setNumberFormat('prettyFormat');\n } else {\n // Apply field types\n if (config.numberFieldType) {\n window.Spreedly!.setFieldType('number', config.numberFieldType);\n }\n if (config.cvvFieldType) {\n window.Spreedly!.setFieldType('cvv', config.cvvFieldType);\n }\n }\n\n handlers?.onReady?.();\n });\n\n // Set up field event handler\n window.Spreedly!.on('fieldEvent', (name, eventType, activeElement, inputProperties) => {\n handlers?.onFieldEvent?.(name, eventType, activeElement, inputProperties);\n });\n\n // Set up error handler\n window.Spreedly!.on('errors', errors => {\n handlers?.onErrors?.(errors);\n });\n\n // Set up payment method handler\n window.Spreedly!.on('paymentMethod', (token, paymentMethod) => {\n currentToken = token;\n\n handlers?.onPaymentMethod?.(token, paymentMethod);\n\n // If there's a pending submit, execute it\n if (tokenCallback) {\n tokenCallback(token);\n tokenCallback = null;\n }\n });\n },\n\n tokenize(cardDetails: CardDetailsFirstNameLastName | CardDetailsFullName): void {\n if (!isInitialized || !window.Spreedly) {\n throw new Error('Payment form is not initialized');\n }\n\n // Normalize year to YYYY format\n let year = String(cardDetails.year);\n if (year.length === 2) {\n year = `20${year}`;\n }\n const month = String(cardDetails.month).padStart(2, '0');\n\n if ('full_name' in cardDetails) {\n window.Spreedly.tokenizeCreditCard({\n full_name: cardDetails.full_name,\n month,\n year,\n });\n } else {\n window.Spreedly.tokenizeCreditCard({\n first_name: cardDetails.first_name,\n last_name: cardDetails.last_name,\n month,\n year,\n });\n }\n },\n\n async submit(options: PaymentMethodFormOptions): Promise<PaymentMethod> {\n if (!isInitialized) {\n throw new Error('Payment form is not initialized');\n }\n\n // Check if we already have a token\n if (currentToken) {\n const token = currentToken;\n currentToken = null; // Clear the token after use\n return submitFrictionlessPaymentMethodV1(session, token, options, {\n external_payment_method_id: externalPaymentMethodId,\n payment_method_intent_id: paymentMethodIntentId,\n external_customer_id: externalCustomerId,\n });\n }\n\n // Need to tokenize first, then submit\n return new Promise(resolve => {\n pendingSubmitOptions = options;\n\n tokenCallback = async (token: string) => {\n const result = await submitFrictionlessPaymentMethodV1(session, token, pendingSubmitOptions!, {\n external_payment_method_id: externalPaymentMethodId,\n payment_method_intent_id: paymentMethodIntentId,\n external_customer_id: externalCustomerId,\n });\n pendingSubmitOptions = null;\n resolve(result);\n };\n\n // Trigger tokenization\n this.tokenize(options.card_details);\n });\n },\n\n reset(): void {\n if (window.Spreedly) {\n window.Spreedly.reload();\n }\n currentToken = null;\n tokenCallback = null;\n pendingSubmitOptions = null;\n },\n\n unmount(): void {\n if (window.Spreedly) {\n window.Spreedly.removeHandlers();\n }\n isInitialized = false;\n currentToken = null;\n tokenCallback = null;\n pendingSubmitOptions = null;\n },\n\n addEventHandlers(handlers: PaymentFormEventHandlers): void {\n if (handlers.onReady) {\n window.Spreedly!.on('ready', handlers.onReady);\n }\n if (handlers.onFieldEvent) {\n window.Spreedly!.on('fieldEvent', handlers.onFieldEvent);\n }\n if (handlers.onErrors) {\n window.Spreedly!.on('errors', handlers.onErrors);\n }\n if (handlers.onPaymentMethod) {\n window.Spreedly!.on('paymentMethod', handlers.onPaymentMethod);\n }\n },\n\n removeHandlers(): void {\n if (window.Spreedly) {\n window.Spreedly.removeHandlers();\n }\n },\n\n setFieldType(name: spreedly.SpreedlyField, type: spreedly.SpreedlyFieldType): void {\n window.Spreedly!.setFieldType(name, type);\n },\n\n setLabel(name: spreedly.SpreedlyField, label: string): void {\n window.Spreedly!.setLabel(name, label);\n },\n\n setNumberFormat(format: 'plainFormat' | 'prettyFormat' | 'maskedFormat'): void {\n // @ts-expect-error - SpreedlyNumberFormat doesn't match allowed values\n window.Spreedly!.setNumberFormat(format);\n },\n\n setPlaceholder(name: spreedly.SpreedlyField, placeholder: string): void {\n window.Spreedly!.setPlaceholder(name, placeholder);\n },\n\n setStyle(name: spreedly.SpreedlyField, style: string): void {\n window.Spreedly!.setStyle(name, style);\n },\n };\n\n return controller;\n}\n\nasync function loadScript(scriptSrc: string, integrity: string): Promise<void> {\n // Check if already loaded\n if (typeof window !== 'undefined' && window.Spreedly) {\n return Promise.resolve();\n }\n\n return new Promise((resolve, reject) => {\n if (typeof document === 'undefined') {\n reject(new Error('Document is not available. This function must be called in a browser environment.'));\n return;\n }\n\n // Check if script is already in the DOM\n const existingScript = document.querySelector(`script[src=\"${scriptSrc}\"]`);\n if (existingScript) {\n // Wait for it to load\n const checkLoaded = () => {\n if (window.Spreedly) {\n resolve();\n } else {\n setTimeout(checkLoaded, 50);\n }\n };\n checkLoaded();\n return;\n }\n\n const script = document.createElement('script');\n script.src = scriptSrc;\n script.integrity = integrity;\n script.crossOrigin = 'anonymous';\n\n script.addEventListener('load', () => {\n // Wait for payment script to be fully initialized\n const checkLoaded = () => {\n if (window.Spreedly) {\n resolve();\n } else {\n setTimeout(checkLoaded, 50);\n }\n };\n checkLoaded();\n });\n\n script.addEventListener('error', () => {\n reject(new Error('Failed to load payment iFrame script'));\n });\n\n document.head.appendChild(script);\n });\n}\n\n// defined here since this is only for internal use\ninterface PaymentMethodIntentResponse {\n payment_method_intent_id: string;\n customer_id: number;\n external_customer_id: {\n ecommerce: number;\n };\n external: {\n environment_key: string;\n resource_url: string;\n integrity_hash: string;\n };\n created_at: IsoDateString;\n expires_at: IsoDateString;\n payment_method?: PaymentMethod;\n}\n\nasync function createFrictionlessPaymentIntentV1(\n session: Session,\n rechargePaymentMethodId?: string\n): Promise<PaymentMethodIntentResponse> {\n const id = session.customerId;\n if (!id) {\n throw new Error('Not logged in.');\n }\n const response = await rechargeApiRequest<PaymentMethodIntentResponse>(\n 'post',\n '/payment_method_intents',\n { data: { customer_id: id, payment_method_id: rechargePaymentMethodId } },\n getInternalSession(session, 'createFrictionlessPaymentIntentV1')\n );\n return response;\n}\n\n// defined here since this is only for internal use\ninterface FrictionlessPaymentMethodRequest {\n /** ID of the payment method to update */\n external_payment_method_id?: string;\n payment_method_intent_id: string;\n external_customer_id: number;\n}\n\nasync function submitFrictionlessPaymentMethodV1(\n session: Session,\n token: string,\n { billing_address, default_payment_method, address_ids }: PaymentMethodFormOptions,\n { external_payment_method_id, payment_method_intent_id, external_customer_id }: FrictionlessPaymentMethodRequest\n): Promise<PaymentMethod> {\n const paymentMethod = await createPaymentMethod(getInternalSession(session, 'submitFrictionlessPaymentMethodV1'), {\n default: default_payment_method ?? false,\n payment_type: 'CREDIT_CARD',\n processor_customer_token: external_customer_id.toString(),\n processor_name: 'frictionless',\n processor_payment_method_token: token,\n billing_address,\n payment_method_intent_id,\n address_ids,\n external_payment_method_id,\n });\n return paymentMethod;\n}\n"],"names":["rechargeApiRequest","getInternalSession"],"mappings":";;;;AAkBsB,eAAA,gBAAA,CACpB,OACA,EAAA,EAAA,EACA,OACwB,EAAA;AACxB,EAAI,IAAA,EAAA,KAAO,KAAa,CAAA,IAAA,EAAA,KAAO,EAAI,EAAA;AACjC,IAAM,MAAA,IAAI,MAAM,gBAAgB,CAAA,CAAA;AAAA,GAClC;AACA,EAAM,MAAA,EAAE,cAAe,EAAA,GAAI,MAAMA,0BAAA;AAAA,IAC/B,KAAA;AAAA,IACA,CAAA,gBAAA,CAAA;AAAA,IACA;AAAA,MACE,EAAA;AAAA,MACA,KAAO,EAAA,EAAE,OAAS,EAAA,OAAA,EAAS,OAAQ,EAAA;AAAA,KACrC;AAAA,IACAC,0BAAA,CAAmB,SAAS,kBAAkB,CAAA;AAAA,GAChD,CAAA;AACA,EAAO,OAAA,cAAA,CAAA;AACT,CAAA;AAOsB,eAAA,mBAAA,CACpB,SACA,aACwB,EAAA;AACxB,EAAM,MAAA,EAAE,cAAe,EAAA,GAAI,MAAMD,0BAAA;AAAA,IAC/B,MAAA;AAAA,IACA,CAAA,gBAAA,CAAA;AAAA,IACA;AAAA,MACE,MAAM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AAA;AAUA,eAAe,iCACb,CAAA,OAAA,EACA,KACA,EAAA,EAAE,eAAiB,EAAA,sBAAA,EAAwB,WAAY,EAAA,EACvD,EAAE,0BAAA,EAA4B,wBAA0B,EAAA,oBAAA,EAChC,EAAA;AACxB,EAAA,MAAM,gBAAgB,MAAM,mBAAA,CAAoBA,0BAAmB,CAAA,OAAA,EAAS,mCAAmC,CAAG,EAAA;AAAA,IAChH,SAAS,sBAA0B,IAAA,KAAA;AAAA,IACnC,YAAc,EAAA,aAAA;AAAA,IACd,wBAAA,EAA0B,qBAAqB,QAAS,EAAA;AAAA,IACxD,cAAgB,EAAA,cAAA;AAAA,IAChB,8BAAgC,EAAA,KAAA;AAAA,IAChC,eAAA;AAAA,IACA,wBAAA;AAAA,IACA,WAAA;AAAA,IACA,0BAAA;AAAA,GACD,CAAA,CAAA;AACD,EAAO,OAAA,aAAA,CAAA;AACT;;;;;;;;"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -17,7 +17,6 @@ var metafield = require('./api/metafield.js');
|
|
|
17
17
|
var onetime = require('./api/onetime.js');
|
|
18
18
|
var order = require('./api/order.js');
|
|
19
19
|
var paymentMethod = require('./api/paymentMethod.js');
|
|
20
|
-
var paymentMethodForm = require('./api/paymentMethodForm.js');
|
|
21
20
|
var plan = require('./api/plan.js');
|
|
22
21
|
var product = require('./api/product.js');
|
|
23
22
|
var store = require('./api/store.js');
|
|
@@ -112,9 +111,9 @@ exports.getOrder = order.getOrder;
|
|
|
112
111
|
exports.listOrders = order.listOrders;
|
|
113
112
|
exports.createPaymentMethod = paymentMethod.createPaymentMethod;
|
|
114
113
|
exports.getPaymentMethod = paymentMethod.getPaymentMethod;
|
|
114
|
+
exports.initFrictionlessPaymentV1 = paymentMethod.initFrictionlessPaymentV1;
|
|
115
115
|
exports.listPaymentMethods = paymentMethod.listPaymentMethods;
|
|
116
116
|
exports.updatePaymentMethod = paymentMethod.updatePaymentMethod;
|
|
117
|
-
exports.createPaymentFormV1 = paymentMethodForm.createPaymentFormV1;
|
|
118
117
|
exports.getPlan = plan.getPlan;
|
|
119
118
|
exports.listPlans = plan.listPlans;
|
|
120
119
|
exports.productSearch = product.productSearch;
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -49,7 +49,7 @@ async function rechargeApiRequest(method, url, { id, query, data, headers } = {}
|
|
|
49
49
|
"X-Recharge-Sdk-Fn": session.internalFnCall,
|
|
50
50
|
...appName ? { "X-Recharge-Sdk-App-Name": appName } : {},
|
|
51
51
|
...appVersion ? { "X-Recharge-Sdk-App-Version": appVersion } : {},
|
|
52
|
-
"X-Recharge-Sdk-Version": "1.70.
|
|
52
|
+
"X-Recharge-Sdk-Version": "1.70.3",
|
|
53
53
|
"X-Request-Id": session.internalRequestId,
|
|
54
54
|
...session.tmp_fn_identifier ? { "X-Recharge-Sdk-Fn-Identifier": session.tmp_fn_identifier } : {},
|
|
55
55
|
...headers ? headers : {}
|
package/dist/esm/api/auth.js
CHANGED
|
@@ -179,7 +179,7 @@ async function rechargeAdminRequest(method, url, { id, query, data, headers } =
|
|
|
179
179
|
...storefrontAccessToken ? { "X-Recharge-Storefront-Access-Token": storefrontAccessToken } : {},
|
|
180
180
|
...appName ? { "X-Recharge-Sdk-App-Name": appName } : {},
|
|
181
181
|
...appVersion ? { "X-Recharge-Sdk-App-Version": appVersion } : {},
|
|
182
|
-
"X-Recharge-Sdk-Version": "1.70.
|
|
182
|
+
"X-Recharge-Sdk-Version": "1.70.3",
|
|
183
183
|
...headers ? headers : {}
|
|
184
184
|
};
|
|
185
185
|
return request(method, `${rechargeBaseUrl}${url}`, { id, query, data, headers: reqHeaders });
|
|
@@ -13,7 +13,7 @@ async function loadFromOnlineStore(id, country_code) {
|
|
|
13
13
|
const { appName, appVersion } = getOptions();
|
|
14
14
|
const headers = {
|
|
15
15
|
"X-Recharge-Sdk-Fn": "loadFromOnlineStore",
|
|
16
|
-
"X-Recharge-Sdk-Version": "1.70.
|
|
16
|
+
"X-Recharge-Sdk-Version": "1.70.3",
|
|
17
17
|
...appName ? { "X-Recharge-Sdk-App-Name": appName } : {},
|
|
18
18
|
...appVersion ? { "X-Recharge-Sdk-App-Version": appVersion } : {}
|
|
19
19
|
};
|