@commercengine/storefront-sdk 0.10.2 → 0.11.1
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/{index.d.ts → index.d.mts} +1242 -382
- package/dist/index.iife.js +249 -44
- package/dist/index.iife.js.map +1 -1
- package/dist/{index.js → index.mjs} +234 -28
- package/dist/index.mjs.map +1 -0
- package/package.json +14 -14
- package/dist/index.js.map +0 -1
package/dist/index.iife.js
CHANGED
|
@@ -2,7 +2,7 @@ var CE_SDK = (function(exports) {
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
//#region ../../node_modules/.pnpm/openapi-fetch@0.14.
|
|
5
|
+
//#region ../../node_modules/.pnpm/openapi-fetch@0.14.1/node_modules/openapi-fetch/dist/index.mjs
|
|
6
6
|
const PATH_PARAM_RE = /\{[^{}]+\}/g;
|
|
7
7
|
const supportsRequestInitExt = () => {
|
|
8
8
|
return typeof process === "object" && Number.parseInt(process?.versions?.node?.substring(0, 2)) >= 18 && process.versions.undici;
|
|
@@ -11,12 +11,12 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
11
11
|
return Math.random().toString(36).slice(2, 11);
|
|
12
12
|
}
|
|
13
13
|
function createClient(clientOptions) {
|
|
14
|
-
let { baseUrl = "", Request: CustomRequest = globalThis.Request, fetch: baseFetch = globalThis.fetch, querySerializer: globalQuerySerializer, bodySerializer: globalBodySerializer, headers: baseHeaders, requestInitExt = void 0
|
|
14
|
+
let { baseUrl = "", Request: CustomRequest = globalThis.Request, fetch: baseFetch = globalThis.fetch, querySerializer: globalQuerySerializer, bodySerializer: globalBodySerializer, headers: baseHeaders, requestInitExt = void 0, ...baseOptions } = { ...clientOptions };
|
|
15
15
|
requestInitExt = supportsRequestInitExt() ? requestInitExt : void 0;
|
|
16
16
|
baseUrl = removeTrailingSlash(baseUrl);
|
|
17
17
|
const middlewares = [];
|
|
18
18
|
async function coreFetch(schemaPath, fetchOptions) {
|
|
19
|
-
const { baseUrl: localBaseUrl, fetch: fetch$1 = baseFetch, Request: Request$1 = CustomRequest, headers, params = {}, parseAs = "json", querySerializer: requestQuerySerializer, bodySerializer = globalBodySerializer ?? defaultBodySerializer, body
|
|
19
|
+
const { baseUrl: localBaseUrl, fetch: fetch$1 = baseFetch, Request: Request$1 = CustomRequest, headers, params = {}, parseAs = "json", querySerializer: requestQuerySerializer, bodySerializer = globalBodySerializer ?? defaultBodySerializer, body, ...init } = fetchOptions || {};
|
|
20
20
|
let finalBaseUrl = baseUrl;
|
|
21
21
|
if (localBaseUrl) finalBaseUrl = removeTrailingSlash(localBaseUrl) ?? baseUrl;
|
|
22
22
|
let querySerializer = typeof globalQuerySerializer === "function" ? globalQuerySerializer : createQuerySerializer(globalQuerySerializer);
|
|
@@ -35,7 +35,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
35
35
|
};
|
|
36
36
|
let id;
|
|
37
37
|
let options;
|
|
38
|
-
let request = new
|
|
38
|
+
let request = new Request$1(createFinalURL(schemaPath, {
|
|
39
39
|
baseUrl: finalBaseUrl,
|
|
40
40
|
params,
|
|
41
41
|
querySerializer
|
|
@@ -59,7 +59,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
59
59
|
options,
|
|
60
60
|
id
|
|
61
61
|
});
|
|
62
|
-
if (result) if (result instanceof
|
|
62
|
+
if (result) if (result instanceof Request$1) request = result;
|
|
63
63
|
else if (result instanceof Response) {
|
|
64
64
|
response = result;
|
|
65
65
|
break;
|
|
@@ -371,7 +371,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
371
371
|
}
|
|
372
372
|
|
|
373
373
|
//#endregion
|
|
374
|
-
//#region ../sdk-core/dist/index.
|
|
374
|
+
//#region ../sdk-core/dist/index.mjs
|
|
375
375
|
/**
|
|
376
376
|
* Response utilities for debugging and working with Response objects
|
|
377
377
|
*/
|
|
@@ -678,6 +678,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
678
678
|
}
|
|
679
679
|
}
|
|
680
680
|
/**
|
|
681
|
+
* Base API client for Commerce Engine SDKs
|
|
682
|
+
* Provides common functionality without token management
|
|
683
|
+
*/
|
|
684
|
+
/**
|
|
681
685
|
* Generic base API client that all Commerce Engine SDKs can extend
|
|
682
686
|
* Handles common functionality like middleware setup, request execution, and header management
|
|
683
687
|
* Does NOT include token management - that's SDK-specific
|
|
@@ -779,13 +783,13 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
779
783
|
}
|
|
780
784
|
|
|
781
785
|
//#endregion
|
|
782
|
-
//#region ../../node_modules/.pnpm/jose@6.1.
|
|
786
|
+
//#region ../../node_modules/.pnpm/jose@6.1.3/node_modules/jose/dist/webapi/lib/buffer_utils.js
|
|
783
787
|
const encoder = new TextEncoder();
|
|
784
788
|
const decoder = new TextDecoder();
|
|
785
789
|
const MAX_INT32 = 2 ** 32;
|
|
786
790
|
|
|
787
791
|
//#endregion
|
|
788
|
-
//#region ../../node_modules/.pnpm/jose@6.1.
|
|
792
|
+
//#region ../../node_modules/.pnpm/jose@6.1.3/node_modules/jose/dist/webapi/lib/base64.js
|
|
789
793
|
function decodeBase64(encoded) {
|
|
790
794
|
if (Uint8Array.fromBase64) return Uint8Array.fromBase64(encoded);
|
|
791
795
|
const binary = atob(encoded);
|
|
@@ -795,12 +799,12 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
795
799
|
}
|
|
796
800
|
|
|
797
801
|
//#endregion
|
|
798
|
-
//#region ../../node_modules/.pnpm/jose@6.1.
|
|
802
|
+
//#region ../../node_modules/.pnpm/jose@6.1.3/node_modules/jose/dist/webapi/util/base64url.js
|
|
799
803
|
function decode(input) {
|
|
800
804
|
if (Uint8Array.fromBase64) return Uint8Array.fromBase64(typeof input === "string" ? input : decoder.decode(input), { alphabet: "base64url" });
|
|
801
805
|
let encoded = input;
|
|
802
806
|
if (encoded instanceof Uint8Array) encoded = decoder.decode(encoded);
|
|
803
|
-
encoded = encoded.replace(/-/g, "+").replace(/_/g, "/")
|
|
807
|
+
encoded = encoded.replace(/-/g, "+").replace(/_/g, "/");
|
|
804
808
|
try {
|
|
805
809
|
return decodeBase64(encoded);
|
|
806
810
|
} catch {
|
|
@@ -809,7 +813,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
809
813
|
}
|
|
810
814
|
|
|
811
815
|
//#endregion
|
|
812
|
-
//#region ../../node_modules/.pnpm/jose@6.1.
|
|
816
|
+
//#region ../../node_modules/.pnpm/jose@6.1.3/node_modules/jose/dist/webapi/util/errors.js
|
|
813
817
|
var JOSEError = class extends Error {
|
|
814
818
|
static code = "ERR_JOSE_GENERIC";
|
|
815
819
|
code = "ERR_JOSE_GENERIC";
|
|
@@ -833,20 +837,18 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
833
837
|
};
|
|
834
838
|
|
|
835
839
|
//#endregion
|
|
836
|
-
//#region ../../node_modules/.pnpm/jose@6.1.
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
}
|
|
840
|
-
var is_object_default = (input) => {
|
|
840
|
+
//#region ../../node_modules/.pnpm/jose@6.1.3/node_modules/jose/dist/webapi/lib/is_object.js
|
|
841
|
+
const isObjectLike = (value) => typeof value === "object" && value !== null;
|
|
842
|
+
function isObject(input) {
|
|
841
843
|
if (!isObjectLike(input) || Object.prototype.toString.call(input) !== "[object Object]") return false;
|
|
842
844
|
if (Object.getPrototypeOf(input) === null) return true;
|
|
843
845
|
let proto = input;
|
|
844
846
|
while (Object.getPrototypeOf(proto) !== null) proto = Object.getPrototypeOf(proto);
|
|
845
847
|
return Object.getPrototypeOf(input) === proto;
|
|
846
|
-
}
|
|
848
|
+
}
|
|
847
849
|
|
|
848
850
|
//#endregion
|
|
849
|
-
//#region ../../node_modules/.pnpm/jose@6.1.
|
|
851
|
+
//#region ../../node_modules/.pnpm/jose@6.1.3/node_modules/jose/dist/webapi/util/decode_jwt.js
|
|
850
852
|
function decodeJwt(jwt) {
|
|
851
853
|
if (typeof jwt !== "string") throw new JWTInvalid("JWTs must use Compact JWS serialization, JWT must be a string");
|
|
852
854
|
const { 1: payload, length } = jwt.split(".");
|
|
@@ -865,7 +867,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
865
867
|
} catch {
|
|
866
868
|
throw new JWTInvalid("Failed to parse the decoded payload as JSON");
|
|
867
869
|
}
|
|
868
|
-
if (!
|
|
870
|
+
if (!isObject(result)) throw new JWTInvalid("Invalid JWT Claims Set");
|
|
869
871
|
return result;
|
|
870
872
|
}
|
|
871
873
|
|
|
@@ -3336,27 +3338,80 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
3336
3338
|
* @returns Promise with order details
|
|
3337
3339
|
* @example
|
|
3338
3340
|
* ```typescript
|
|
3339
|
-
* //
|
|
3341
|
+
* // Juspay Hyper Checkout - Redirects to hosted payment page
|
|
3340
3342
|
* const { data, error } = await sdk.order.createOrder({
|
|
3341
3343
|
* cart_id: "cart_01H9XYZ12345ABCDE",
|
|
3342
|
-
*
|
|
3343
|
-
*
|
|
3344
|
-
*
|
|
3345
|
-
*
|
|
3346
|
-
*
|
|
3344
|
+
* payment_method: {
|
|
3345
|
+
* payment_provider_slug: "juspay",
|
|
3346
|
+
* integration_type: "hyper-checkout",
|
|
3347
|
+
* gateway_reference_id: "gateway_ref_123",
|
|
3348
|
+
* return_url: "https://yourapp.com/payment/return",
|
|
3349
|
+
* action: "paymentPage"
|
|
3347
3350
|
* }
|
|
3348
3351
|
* });
|
|
3349
3352
|
*
|
|
3350
|
-
* //
|
|
3353
|
+
* // Juspay Express Checkout - New Card
|
|
3351
3354
|
* const { data, error } = await sdk.order.createOrder({
|
|
3352
3355
|
* cart_id: "cart_01H9XYZ12345ABCDE",
|
|
3353
|
-
*
|
|
3354
|
-
*
|
|
3355
|
-
*
|
|
3356
|
-
*
|
|
3357
|
-
* integration_type: "hyper-checkout",
|
|
3356
|
+
* payment_method: {
|
|
3357
|
+
* payment_provider_slug: "juspay",
|
|
3358
|
+
* integration_type: "express-checkout",
|
|
3359
|
+
* gateway_reference_id: "gateway_ref_123",
|
|
3358
3360
|
* return_url: "https://yourapp.com/payment/return",
|
|
3359
|
-
*
|
|
3361
|
+
* payment_method_type: "CARD",
|
|
3362
|
+
* payment_method: "VISA",
|
|
3363
|
+
* auth_type: "OTP",
|
|
3364
|
+
* save_to_locker: true,
|
|
3365
|
+
* card_number: "4111111111111111",
|
|
3366
|
+
* card_exp_month: "12",
|
|
3367
|
+
* card_exp_year: "2025",
|
|
3368
|
+
* name_on_card: "John Doe",
|
|
3369
|
+
* card_security_code: "123"
|
|
3370
|
+
* }
|
|
3371
|
+
* });
|
|
3372
|
+
*
|
|
3373
|
+
* // Juspay Express Checkout - Saved Card Token
|
|
3374
|
+
* const { data, error } = await sdk.order.createOrder({
|
|
3375
|
+
* cart_id: "cart_01H9XYZ12345ABCDE",
|
|
3376
|
+
* payment_method: {
|
|
3377
|
+
* payment_provider_slug: "juspay",
|
|
3378
|
+
* integration_type: "express-checkout",
|
|
3379
|
+
* gateway_reference_id: "gateway_ref_123",
|
|
3380
|
+
* return_url: "https://yourapp.com/payment/return",
|
|
3381
|
+
* get_client_auth_token: true,
|
|
3382
|
+
* payment_method_type: "CARD",
|
|
3383
|
+
* payment_method: "VISA",
|
|
3384
|
+
* auth_type: "OTP",
|
|
3385
|
+
* save_to_locker: false,
|
|
3386
|
+
* card_token: "token_abc123",
|
|
3387
|
+
* card_security_code: "123"
|
|
3388
|
+
* }
|
|
3389
|
+
* });
|
|
3390
|
+
*
|
|
3391
|
+
* // Juspay Express Checkout - UPI Collect
|
|
3392
|
+
* const { data, error } = await sdk.order.createOrder({
|
|
3393
|
+
* cart_id: "cart_01H9XYZ12345ABCDE",
|
|
3394
|
+
* payment_method: {
|
|
3395
|
+
* payment_provider_slug: "juspay",
|
|
3396
|
+
* integration_type: "express-checkout",
|
|
3397
|
+
* gateway_reference_id: "gateway_ref_123",
|
|
3398
|
+
* return_url: "https://yourapp.com/payment/return",
|
|
3399
|
+
* payment_method_type: "UPI",
|
|
3400
|
+
* payment_method: "UPI_COLLECT",
|
|
3401
|
+
* upi_vpa: "user@upi"
|
|
3402
|
+
* }
|
|
3403
|
+
* });
|
|
3404
|
+
*
|
|
3405
|
+
* // Juspay Express Checkout - Net Banking
|
|
3406
|
+
* const { data, error } = await sdk.order.createOrder({
|
|
3407
|
+
* cart_id: "cart_01H9XYZ12345ABCDE",
|
|
3408
|
+
* payment_method: {
|
|
3409
|
+
* payment_provider_slug: "juspay",
|
|
3410
|
+
* integration_type: "express-checkout",
|
|
3411
|
+
* gateway_reference_id: "gateway_ref_123",
|
|
3412
|
+
* return_url: "https://yourapp.com/payment/return",
|
|
3413
|
+
* payment_method_type: "NB",
|
|
3414
|
+
* payment_method: "NB_HDFC"
|
|
3360
3415
|
* }
|
|
3361
3416
|
* });
|
|
3362
3417
|
*
|
|
@@ -3366,6 +3421,17 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
3366
3421
|
* console.log("Order created:", data.order.id);
|
|
3367
3422
|
* console.log("Payment required:", data.payment_required);
|
|
3368
3423
|
* console.log("Payment info:", data.payment_info);
|
|
3424
|
+
*
|
|
3425
|
+
* // For hyper-checkout, redirect to payment page
|
|
3426
|
+
* if ("payment_links" in data.payment_info) {
|
|
3427
|
+
* window.location.href = data.payment_info.payment_links?.web;
|
|
3428
|
+
* }
|
|
3429
|
+
*
|
|
3430
|
+
* // For express-checkout with OTP authentication
|
|
3431
|
+
* if ("payment" in data.payment_info && data.payment_info.payment?.authentication?.params) {
|
|
3432
|
+
* const { id: txn_id, challenge_id } = data.payment_info.payment.authentication.params;
|
|
3433
|
+
* // Use txn_id and challenge_id with sdk.payments.authenticateDirectOtp()
|
|
3434
|
+
* }
|
|
3369
3435
|
* }
|
|
3370
3436
|
* ```
|
|
3371
3437
|
*/
|
|
@@ -3553,28 +3619,32 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
3553
3619
|
* @returns Promise with payment information
|
|
3554
3620
|
* @example
|
|
3555
3621
|
* ```typescript
|
|
3556
|
-
* //
|
|
3622
|
+
* // Juspay Hyper Checkout - Redirects to hosted payment page
|
|
3557
3623
|
* const { data, error } = await sdk.order.retryOrderPayment(
|
|
3558
3624
|
* { order_number: "ORD-2024-001" },
|
|
3559
3625
|
* {
|
|
3560
|
-
*
|
|
3561
|
-
*
|
|
3562
|
-
*
|
|
3563
|
-
*
|
|
3626
|
+
* payment_method: {
|
|
3627
|
+
* payment_provider_slug: "juspay",
|
|
3628
|
+
* integration_type: "hyper-checkout",
|
|
3629
|
+
* gateway_reference_id: "gateway_ref_123",
|
|
3630
|
+
* return_url: "https://yourapp.com/payment/return",
|
|
3631
|
+
* action: "paymentPage"
|
|
3564
3632
|
* }
|
|
3565
3633
|
* }
|
|
3566
3634
|
* );
|
|
3567
3635
|
*
|
|
3568
|
-
* //
|
|
3636
|
+
* // Juspay Express Checkout - UPI Collect
|
|
3569
3637
|
* const { data, error } = await sdk.order.retryOrderPayment(
|
|
3570
3638
|
* { order_number: "ORD-2024-001" },
|
|
3571
3639
|
* {
|
|
3572
|
-
*
|
|
3573
|
-
*
|
|
3574
|
-
*
|
|
3575
|
-
*
|
|
3640
|
+
* payment_method: {
|
|
3641
|
+
* payment_provider_slug: "juspay",
|
|
3642
|
+
* integration_type: "express-checkout",
|
|
3643
|
+
* gateway_reference_id: "gateway_ref_123",
|
|
3576
3644
|
* return_url: "https://yourapp.com/payment/return",
|
|
3577
|
-
*
|
|
3645
|
+
* payment_method_type: "UPI",
|
|
3646
|
+
* payment_method: "UPI_COLLECT",
|
|
3647
|
+
* upi_vpa: "user@upi"
|
|
3578
3648
|
* }
|
|
3579
3649
|
* }
|
|
3580
3650
|
* );
|
|
@@ -3584,7 +3654,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
3584
3654
|
* } else {
|
|
3585
3655
|
* console.log("Payment retry initiated");
|
|
3586
3656
|
* console.log("Payment info:", data.payment_info);
|
|
3587
|
-
*
|
|
3657
|
+
*
|
|
3658
|
+
* // For hyper-checkout, redirect to payment page
|
|
3659
|
+
* if ("payment_links" in data.payment_info) {
|
|
3660
|
+
* window.location.href = data.payment_info.payment_links?.web;
|
|
3661
|
+
* }
|
|
3588
3662
|
* }
|
|
3589
3663
|
* ```
|
|
3590
3664
|
*/
|
|
@@ -3596,6 +3670,126 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
3596
3670
|
}
|
|
3597
3671
|
};
|
|
3598
3672
|
|
|
3673
|
+
//#endregion
|
|
3674
|
+
//#region src/lib/payments.ts
|
|
3675
|
+
/**
|
|
3676
|
+
* Client for interacting with payment endpoints
|
|
3677
|
+
*/
|
|
3678
|
+
var PaymentsClient = class extends StorefrontAPIClient {
|
|
3679
|
+
/**
|
|
3680
|
+
* List all available payment methods
|
|
3681
|
+
*
|
|
3682
|
+
* @returns Promise with list of payment methods
|
|
3683
|
+
* @example
|
|
3684
|
+
* ```typescript
|
|
3685
|
+
* const { data, error } = await sdk.payments.listPaymentMethods();
|
|
3686
|
+
*
|
|
3687
|
+
* if (error) {
|
|
3688
|
+
* console.error("Failed to list payment methods:", error.message);
|
|
3689
|
+
* } else {
|
|
3690
|
+
* console.log("Payment methods:", data.payment_methods);
|
|
3691
|
+
*
|
|
3692
|
+
* data.payment_methods?.forEach(method => {
|
|
3693
|
+
* console.log("Payment method:", method.name);
|
|
3694
|
+
* console.log("Gateway:", method.payment_gateway);
|
|
3695
|
+
* });
|
|
3696
|
+
* }
|
|
3697
|
+
* ```
|
|
3698
|
+
*/
|
|
3699
|
+
async listPaymentMethods() {
|
|
3700
|
+
return this.executeRequest(() => this.client.GET("/payments/payment-methods", {}));
|
|
3701
|
+
}
|
|
3702
|
+
/**
|
|
3703
|
+
* Verify a UPI Virtual Payment Address (VPA)
|
|
3704
|
+
*
|
|
3705
|
+
* @description The Virtual Payment Address or VPA is a unique ID given to an individual
|
|
3706
|
+
* using the Unified Payment Interface (UPI) service to send or receive money.
|
|
3707
|
+
* Validating the VPA helps reduce payment failure rates due to incorrect VPA.
|
|
3708
|
+
*
|
|
3709
|
+
* @param queryParams - Query parameters containing the VPA to verify
|
|
3710
|
+
* @returns Promise with VPA verification result
|
|
3711
|
+
* @example
|
|
3712
|
+
* ```typescript
|
|
3713
|
+
* const { data, error } = await sdk.payments.verifyVpa({
|
|
3714
|
+
* vpa: "user@upi"
|
|
3715
|
+
* });
|
|
3716
|
+
*
|
|
3717
|
+
* if (error) {
|
|
3718
|
+
* console.error("Failed to verify VPA:", error.message);
|
|
3719
|
+
* } else {
|
|
3720
|
+
* console.log("VPA:", data.vpa);
|
|
3721
|
+
* console.log("Status:", data.status);
|
|
3722
|
+
*
|
|
3723
|
+
* if (data.status === "VALID") {
|
|
3724
|
+
* console.log("VPA is valid and can be used for UPI payments");
|
|
3725
|
+
* } else {
|
|
3726
|
+
* console.log("VPA is invalid, please check and try again");
|
|
3727
|
+
* }
|
|
3728
|
+
* }
|
|
3729
|
+
* ```
|
|
3730
|
+
*/
|
|
3731
|
+
async verifyVpa(queryParams) {
|
|
3732
|
+
return this.executeRequest(() => this.client.GET("/payments/verify-vpa", { params: { query: queryParams } }));
|
|
3733
|
+
}
|
|
3734
|
+
/**
|
|
3735
|
+
* Authenticate a direct OTP for payment verification
|
|
3736
|
+
*
|
|
3737
|
+
* @description Used to authenticate OTP during payment flows that require 2FA verification.
|
|
3738
|
+
* The txn_id and challenge_id can be obtained from the create order API response
|
|
3739
|
+
* under the payment_info.authentication.params object.
|
|
3740
|
+
*
|
|
3741
|
+
* @param body - OTP authentication request body
|
|
3742
|
+
* @returns Promise with authentication result
|
|
3743
|
+
* @example
|
|
3744
|
+
* ```typescript
|
|
3745
|
+
* // After creating an order, if OTP authentication is required:
|
|
3746
|
+
* const { data, error } = await sdk.payments.authenticateDirectOtp({
|
|
3747
|
+
* txn_id: "txn_01H9XYZ12345ABCDE",
|
|
3748
|
+
* challenge_id: "challenge_01H9XYZ12345ABCDE",
|
|
3749
|
+
* otp: "123456"
|
|
3750
|
+
* });
|
|
3751
|
+
*
|
|
3752
|
+
* if (error) {
|
|
3753
|
+
* console.error("OTP authentication failed:", error.message);
|
|
3754
|
+
* } else {
|
|
3755
|
+
* console.log("Authentication success:", data.success);
|
|
3756
|
+
* console.log("Message:", data.message);
|
|
3757
|
+
* }
|
|
3758
|
+
* ```
|
|
3759
|
+
*/
|
|
3760
|
+
async authenticateDirectOtp(body) {
|
|
3761
|
+
return this.executeRequest(() => this.client.POST("/payments/authenticate-direct-otp", { body }));
|
|
3762
|
+
}
|
|
3763
|
+
/**
|
|
3764
|
+
* Resend a direct OTP for payment verification
|
|
3765
|
+
*
|
|
3766
|
+
* @description Used to resend OTP during payment flows that require 2FA verification.
|
|
3767
|
+
* The txn_id and challenge_id can be obtained from the create order API response
|
|
3768
|
+
* under the payment_info.authentication.params object.
|
|
3769
|
+
*
|
|
3770
|
+
* @param body - OTP resend request body
|
|
3771
|
+
* @returns Promise with new payment info containing updated OTP challenge
|
|
3772
|
+
* @example
|
|
3773
|
+
* ```typescript
|
|
3774
|
+
* // If user didn't receive OTP or it expired:
|
|
3775
|
+
* const { data, error } = await sdk.payments.resendDirectOtp({
|
|
3776
|
+
* txn_id: "txn_01H9XYZ12345ABCDE",
|
|
3777
|
+
* challenge_id: "challenge_01H9XYZ12345ABCDE"
|
|
3778
|
+
* });
|
|
3779
|
+
*
|
|
3780
|
+
* if (error) {
|
|
3781
|
+
* console.error("Failed to resend OTP:", error.message);
|
|
3782
|
+
* } else {
|
|
3783
|
+
* console.log("OTP resent successfully");
|
|
3784
|
+
* console.log("New payment info:", data.payment_info);
|
|
3785
|
+
* }
|
|
3786
|
+
* ```
|
|
3787
|
+
*/
|
|
3788
|
+
async resendDirectOtp(body) {
|
|
3789
|
+
return this.executeRequest(() => this.client.POST("/payments/resend-direct-otp", { body }));
|
|
3790
|
+
}
|
|
3791
|
+
};
|
|
3792
|
+
|
|
3599
3793
|
//#endregion
|
|
3600
3794
|
//#region src/lib/shipping.ts
|
|
3601
3795
|
/**
|
|
@@ -4199,6 +4393,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4199
4393
|
*/
|
|
4200
4394
|
order;
|
|
4201
4395
|
/**
|
|
4396
|
+
* Client for payment-related endpoints
|
|
4397
|
+
*/
|
|
4398
|
+
payments;
|
|
4399
|
+
/**
|
|
4202
4400
|
* Client for store config-related endpoints
|
|
4203
4401
|
*/
|
|
4204
4402
|
store;
|
|
@@ -4235,6 +4433,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4235
4433
|
this.helpers = new HelpersClient(config);
|
|
4236
4434
|
this.shipping = new ShippingClient(config);
|
|
4237
4435
|
this.order = new OrderClient(config);
|
|
4436
|
+
this.payments = new PaymentsClient(config);
|
|
4238
4437
|
this.store = new StoreConfigClient(config);
|
|
4239
4438
|
}
|
|
4240
4439
|
/**
|
|
@@ -4255,6 +4454,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4255
4454
|
await this.helpers.setTokens(accessToken, refreshToken);
|
|
4256
4455
|
await this.shipping.setTokens(accessToken, refreshToken);
|
|
4257
4456
|
await this.order.setTokens(accessToken, refreshToken);
|
|
4457
|
+
await this.payments.setTokens(accessToken, refreshToken);
|
|
4258
4458
|
await this.store.setTokens(accessToken, refreshToken);
|
|
4259
4459
|
}
|
|
4260
4460
|
/**
|
|
@@ -4272,6 +4472,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4272
4472
|
await this.helpers.clearTokens();
|
|
4273
4473
|
await this.shipping.clearTokens();
|
|
4274
4474
|
await this.order.clearTokens();
|
|
4475
|
+
await this.payments.clearTokens();
|
|
4275
4476
|
await this.store.clearTokens();
|
|
4276
4477
|
}
|
|
4277
4478
|
/**
|
|
@@ -4287,6 +4488,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4287
4488
|
this.helpers.setApiKey(apiKey);
|
|
4288
4489
|
this.shipping.setApiKey(apiKey);
|
|
4289
4490
|
this.order.setApiKey(apiKey);
|
|
4491
|
+
this.payments.setApiKey(apiKey);
|
|
4290
4492
|
this.store.setApiKey(apiKey);
|
|
4291
4493
|
}
|
|
4292
4494
|
/**
|
|
@@ -4300,6 +4502,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4300
4502
|
this.helpers.clearApiKey();
|
|
4301
4503
|
this.shipping.clearApiKey();
|
|
4302
4504
|
this.order.clearApiKey();
|
|
4505
|
+
this.payments.clearApiKey();
|
|
4303
4506
|
this.store.clearApiKey();
|
|
4304
4507
|
}
|
|
4305
4508
|
/**
|
|
@@ -4378,6 +4581,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4378
4581
|
this.helpers.setDefaultHeaders(headers);
|
|
4379
4582
|
this.shipping.setDefaultHeaders(headers);
|
|
4380
4583
|
this.order.setDefaultHeaders(headers);
|
|
4584
|
+
this.payments.setDefaultHeaders(headers);
|
|
4381
4585
|
this.store.setDefaultHeaders(headers);
|
|
4382
4586
|
}
|
|
4383
4587
|
/**
|
|
@@ -4402,6 +4606,7 @@ exports.Environment = Environment;
|
|
|
4402
4606
|
exports.HelpersClient = HelpersClient;
|
|
4403
4607
|
exports.MemoryTokenStorage = MemoryTokenStorage;
|
|
4404
4608
|
exports.OrderClient = OrderClient;
|
|
4609
|
+
exports.PaymentsClient = PaymentsClient;
|
|
4405
4610
|
exports.ResponseUtils = ResponseUtils;
|
|
4406
4611
|
exports.ShippingClient = ShippingClient;
|
|
4407
4612
|
exports.StoreConfigClient = StoreConfigClient;
|