@commercengine/storefront-sdk 0.10.1 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{index.d.ts → index-C8nXwxS6.d.ts} +1527 -486
- package/dist/index.iife.js +298 -80
- package/dist/index.iife.js.map +1 -1
- package/dist/index.js +285 -66
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -392,15 +392,6 @@ var BaseAPIClient = class {
|
|
|
392
392
|
getDefaultHeaders() {
|
|
393
393
|
return this.config.defaultHeaders;
|
|
394
394
|
}
|
|
395
|
-
/**
|
|
396
|
-
* Add middleware to the client
|
|
397
|
-
* This allows SDK extensions to add custom middleware like authentication
|
|
398
|
-
*
|
|
399
|
-
* @param middleware - Middleware to add to the client
|
|
400
|
-
*/
|
|
401
|
-
use(middleware) {
|
|
402
|
-
this.client.use(middleware);
|
|
403
|
-
}
|
|
404
395
|
};
|
|
405
396
|
/**
|
|
406
397
|
* Generic URL utility functions for any SDK
|
|
@@ -461,9 +452,7 @@ function isTokenExpired(token, bufferSeconds = 30) {
|
|
|
461
452
|
try {
|
|
462
453
|
const payload = decodeJwt(token);
|
|
463
454
|
if (!payload.exp) return true;
|
|
464
|
-
|
|
465
|
-
const expiryTime = payload.exp;
|
|
466
|
-
return currentTime >= expiryTime - bufferSeconds;
|
|
455
|
+
return Math.floor(Date.now() / 1e3) >= payload.exp - bufferSeconds;
|
|
467
456
|
} catch (error) {
|
|
468
457
|
console.warn("Failed to decode JWT token:", error);
|
|
469
458
|
return true;
|
|
@@ -799,9 +788,8 @@ function createAuthMiddleware(config) {
|
|
|
799
788
|
* Helper function to create auth middleware with sensible defaults
|
|
800
789
|
*/
|
|
801
790
|
function createDefaultAuthMiddleware(options) {
|
|
802
|
-
const tokenStorage = options.tokenStorage || (typeof localStorage !== "undefined" ? new BrowserTokenStorage() : new MemoryTokenStorage());
|
|
803
791
|
return createAuthMiddleware({
|
|
804
|
-
tokenStorage,
|
|
792
|
+
tokenStorage: options.tokenStorage || (typeof localStorage !== "undefined" ? new BrowserTokenStorage() : new MemoryTokenStorage()),
|
|
805
793
|
apiKey: options.apiKey,
|
|
806
794
|
baseUrl: options.baseUrl,
|
|
807
795
|
onTokensUpdated: options.onTokensUpdated,
|
|
@@ -893,8 +881,7 @@ var StorefrontAPIClient = class extends BaseAPIClient {
|
|
|
893
881
|
config.refreshToken = void 0;
|
|
894
882
|
}
|
|
895
883
|
} else this.client.use({ onRequest: async ({ request }) => {
|
|
896
|
-
|
|
897
|
-
if (isAnonymousAuthEndpoint(pathname)) {
|
|
884
|
+
if (isAnonymousAuthEndpoint(getPathnameFromUrl(request.url))) {
|
|
898
885
|
if (config.apiKey) request.headers.set("X-Api-Key", config.apiKey);
|
|
899
886
|
if (config.accessToken) request.headers.set("Authorization", `Bearer ${config.accessToken}`);
|
|
900
887
|
return request;
|
|
@@ -1892,7 +1879,7 @@ var CartClient = class extends StorefrontAPIClient {
|
|
|
1892
1879
|
}));
|
|
1893
1880
|
}
|
|
1894
1881
|
/**
|
|
1895
|
-
* Update
|
|
1882
|
+
* Update fulfillment preference
|
|
1896
1883
|
*
|
|
1897
1884
|
* @param cartId - The ID of the cart
|
|
1898
1885
|
* @param body - The body of the request
|
|
@@ -2888,27 +2875,80 @@ var OrderClient = class extends StorefrontAPIClient {
|
|
|
2888
2875
|
* @returns Promise with order details
|
|
2889
2876
|
* @example
|
|
2890
2877
|
* ```typescript
|
|
2891
|
-
* //
|
|
2878
|
+
* // Juspay Hyper Checkout - Redirects to hosted payment page
|
|
2879
|
+
* const { data, error } = await sdk.order.createOrder({
|
|
2880
|
+
* cart_id: "cart_01H9XYZ12345ABCDE",
|
|
2881
|
+
* payment_method: {
|
|
2882
|
+
* payment_provider_slug: "juspay",
|
|
2883
|
+
* integration_type: "hyper-checkout",
|
|
2884
|
+
* gateway_reference_id: "gateway_ref_123",
|
|
2885
|
+
* return_url: "https://yourapp.com/payment/return",
|
|
2886
|
+
* action: "paymentPage"
|
|
2887
|
+
* }
|
|
2888
|
+
* });
|
|
2889
|
+
*
|
|
2890
|
+
* // Juspay Express Checkout - New Card
|
|
2892
2891
|
* const { data, error } = await sdk.order.createOrder({
|
|
2893
2892
|
* cart_id: "cart_01H9XYZ12345ABCDE",
|
|
2894
|
-
*
|
|
2895
|
-
*
|
|
2896
|
-
*
|
|
2897
|
-
*
|
|
2898
|
-
*
|
|
2893
|
+
* payment_method: {
|
|
2894
|
+
* payment_provider_slug: "juspay",
|
|
2895
|
+
* integration_type: "express-checkout",
|
|
2896
|
+
* gateway_reference_id: "gateway_ref_123",
|
|
2897
|
+
* return_url: "https://yourapp.com/payment/return",
|
|
2898
|
+
* payment_method_type: "CARD",
|
|
2899
|
+
* payment_method: "VISA",
|
|
2900
|
+
* auth_type: "OTP",
|
|
2901
|
+
* save_to_locker: true,
|
|
2902
|
+
* card_number: "4111111111111111",
|
|
2903
|
+
* card_exp_month: "12",
|
|
2904
|
+
* card_exp_year: "2025",
|
|
2905
|
+
* name_on_card: "John Doe",
|
|
2906
|
+
* card_security_code: "123"
|
|
2899
2907
|
* }
|
|
2900
2908
|
* });
|
|
2901
2909
|
*
|
|
2902
|
-
* //
|
|
2910
|
+
* // Juspay Express Checkout - Saved Card Token
|
|
2903
2911
|
* const { data, error } = await sdk.order.createOrder({
|
|
2904
2912
|
* cart_id: "cart_01H9XYZ12345ABCDE",
|
|
2905
|
-
*
|
|
2906
|
-
*
|
|
2907
|
-
*
|
|
2908
|
-
*
|
|
2909
|
-
*
|
|
2913
|
+
* payment_method: {
|
|
2914
|
+
* payment_provider_slug: "juspay",
|
|
2915
|
+
* integration_type: "express-checkout",
|
|
2916
|
+
* gateway_reference_id: "gateway_ref_123",
|
|
2917
|
+
* return_url: "https://yourapp.com/payment/return",
|
|
2918
|
+
* get_client_auth_token: true,
|
|
2919
|
+
* payment_method_type: "CARD",
|
|
2920
|
+
* payment_method: "VISA",
|
|
2921
|
+
* auth_type: "OTP",
|
|
2922
|
+
* save_to_locker: false,
|
|
2923
|
+
* card_token: "token_abc123",
|
|
2924
|
+
* card_security_code: "123"
|
|
2925
|
+
* }
|
|
2926
|
+
* });
|
|
2927
|
+
*
|
|
2928
|
+
* // Juspay Express Checkout - UPI Collect
|
|
2929
|
+
* const { data, error } = await sdk.order.createOrder({
|
|
2930
|
+
* cart_id: "cart_01H9XYZ12345ABCDE",
|
|
2931
|
+
* payment_method: {
|
|
2932
|
+
* payment_provider_slug: "juspay",
|
|
2933
|
+
* integration_type: "express-checkout",
|
|
2934
|
+
* gateway_reference_id: "gateway_ref_123",
|
|
2935
|
+
* return_url: "https://yourapp.com/payment/return",
|
|
2936
|
+
* payment_method_type: "UPI",
|
|
2937
|
+
* payment_method: "UPI_COLLECT",
|
|
2938
|
+
* upi_vpa: "user@upi"
|
|
2939
|
+
* }
|
|
2940
|
+
* });
|
|
2941
|
+
*
|
|
2942
|
+
* // Juspay Express Checkout - Net Banking
|
|
2943
|
+
* const { data, error } = await sdk.order.createOrder({
|
|
2944
|
+
* cart_id: "cart_01H9XYZ12345ABCDE",
|
|
2945
|
+
* payment_method: {
|
|
2946
|
+
* payment_provider_slug: "juspay",
|
|
2947
|
+
* integration_type: "express-checkout",
|
|
2948
|
+
* gateway_reference_id: "gateway_ref_123",
|
|
2910
2949
|
* return_url: "https://yourapp.com/payment/return",
|
|
2911
|
-
*
|
|
2950
|
+
* payment_method_type: "NB",
|
|
2951
|
+
* payment_method: "NB_HDFC"
|
|
2912
2952
|
* }
|
|
2913
2953
|
* });
|
|
2914
2954
|
*
|
|
@@ -2918,6 +2958,17 @@ var OrderClient = class extends StorefrontAPIClient {
|
|
|
2918
2958
|
* console.log("Order created:", data.order.id);
|
|
2919
2959
|
* console.log("Payment required:", data.payment_required);
|
|
2920
2960
|
* console.log("Payment info:", data.payment_info);
|
|
2961
|
+
*
|
|
2962
|
+
* // For hyper-checkout, redirect to payment page
|
|
2963
|
+
* if ("payment_links" in data.payment_info) {
|
|
2964
|
+
* window.location.href = data.payment_info.payment_links?.web;
|
|
2965
|
+
* }
|
|
2966
|
+
*
|
|
2967
|
+
* // For express-checkout with OTP authentication
|
|
2968
|
+
* if ("payment" in data.payment_info && data.payment_info.payment?.authentication?.params) {
|
|
2969
|
+
* const { id: txn_id, challenge_id } = data.payment_info.payment.authentication.params;
|
|
2970
|
+
* // Use txn_id and challenge_id with sdk.payments.authenticateDirectOtp()
|
|
2971
|
+
* }
|
|
2921
2972
|
* }
|
|
2922
2973
|
* ```
|
|
2923
2974
|
*/
|
|
@@ -3105,28 +3156,32 @@ var OrderClient = class extends StorefrontAPIClient {
|
|
|
3105
3156
|
* @returns Promise with payment information
|
|
3106
3157
|
* @example
|
|
3107
3158
|
* ```typescript
|
|
3108
|
-
* //
|
|
3159
|
+
* // Juspay Hyper Checkout - Redirects to hosted payment page
|
|
3109
3160
|
* const { data, error } = await sdk.order.retryOrderPayment(
|
|
3110
3161
|
* { order_number: "ORD-2024-001" },
|
|
3111
3162
|
* {
|
|
3112
|
-
*
|
|
3113
|
-
*
|
|
3114
|
-
*
|
|
3115
|
-
*
|
|
3163
|
+
* payment_method: {
|
|
3164
|
+
* payment_provider_slug: "juspay",
|
|
3165
|
+
* integration_type: "hyper-checkout",
|
|
3166
|
+
* gateway_reference_id: "gateway_ref_123",
|
|
3167
|
+
* return_url: "https://yourapp.com/payment/return",
|
|
3168
|
+
* action: "paymentPage"
|
|
3116
3169
|
* }
|
|
3117
3170
|
* }
|
|
3118
3171
|
* );
|
|
3119
3172
|
*
|
|
3120
|
-
* //
|
|
3173
|
+
* // Juspay Express Checkout - UPI Collect
|
|
3121
3174
|
* const { data, error } = await sdk.order.retryOrderPayment(
|
|
3122
3175
|
* { order_number: "ORD-2024-001" },
|
|
3123
3176
|
* {
|
|
3124
|
-
*
|
|
3125
|
-
*
|
|
3126
|
-
*
|
|
3127
|
-
*
|
|
3177
|
+
* payment_method: {
|
|
3178
|
+
* payment_provider_slug: "juspay",
|
|
3179
|
+
* integration_type: "express-checkout",
|
|
3180
|
+
* gateway_reference_id: "gateway_ref_123",
|
|
3128
3181
|
* return_url: "https://yourapp.com/payment/return",
|
|
3129
|
-
*
|
|
3182
|
+
* payment_method_type: "UPI",
|
|
3183
|
+
* payment_method: "UPI_COLLECT",
|
|
3184
|
+
* upi_vpa: "user@upi"
|
|
3130
3185
|
* }
|
|
3131
3186
|
* }
|
|
3132
3187
|
* );
|
|
@@ -3136,7 +3191,11 @@ var OrderClient = class extends StorefrontAPIClient {
|
|
|
3136
3191
|
* } else {
|
|
3137
3192
|
* console.log("Payment retry initiated");
|
|
3138
3193
|
* console.log("Payment info:", data.payment_info);
|
|
3139
|
-
*
|
|
3194
|
+
*
|
|
3195
|
+
* // For hyper-checkout, redirect to payment page
|
|
3196
|
+
* if ("payment_links" in data.payment_info) {
|
|
3197
|
+
* window.location.href = data.payment_info.payment_links?.web;
|
|
3198
|
+
* }
|
|
3140
3199
|
* }
|
|
3141
3200
|
* ```
|
|
3142
3201
|
*/
|
|
@@ -3149,45 +3208,131 @@ var OrderClient = class extends StorefrontAPIClient {
|
|
|
3149
3208
|
};
|
|
3150
3209
|
|
|
3151
3210
|
//#endregion
|
|
3152
|
-
//#region src/lib/
|
|
3211
|
+
//#region src/lib/payments.ts
|
|
3153
3212
|
/**
|
|
3154
|
-
* Client for interacting with
|
|
3213
|
+
* Client for interacting with payment endpoints
|
|
3155
3214
|
*/
|
|
3156
|
-
var
|
|
3215
|
+
var PaymentsClient = class extends StorefrontAPIClient {
|
|
3157
3216
|
/**
|
|
3158
|
-
*
|
|
3217
|
+
* List all available payment methods
|
|
3159
3218
|
*
|
|
3160
|
-
* @
|
|
3161
|
-
* @returns Promise with shipping options
|
|
3219
|
+
* @returns Promise with list of payment methods
|
|
3162
3220
|
* @example
|
|
3163
3221
|
* ```typescript
|
|
3164
|
-
* const { data, error } = await sdk.
|
|
3165
|
-
*
|
|
3166
|
-
*
|
|
3222
|
+
* const { data, error } = await sdk.payments.listPaymentMethods();
|
|
3223
|
+
*
|
|
3224
|
+
* if (error) {
|
|
3225
|
+
* console.error("Failed to list payment methods:", error.message);
|
|
3226
|
+
* } else {
|
|
3227
|
+
* console.log("Payment methods:", data.payment_methods);
|
|
3228
|
+
*
|
|
3229
|
+
* data.payment_methods?.forEach(method => {
|
|
3230
|
+
* console.log("Payment method:", method.name);
|
|
3231
|
+
* console.log("Gateway:", method.payment_gateway);
|
|
3232
|
+
* });
|
|
3233
|
+
* }
|
|
3234
|
+
* ```
|
|
3235
|
+
*/
|
|
3236
|
+
async listPaymentMethods() {
|
|
3237
|
+
return this.executeRequest(() => this.client.GET("/payments/payment-methods", {}));
|
|
3238
|
+
}
|
|
3239
|
+
/**
|
|
3240
|
+
* Verify a UPI Virtual Payment Address (VPA)
|
|
3241
|
+
*
|
|
3242
|
+
* @description The Virtual Payment Address or VPA is a unique ID given to an individual
|
|
3243
|
+
* using the Unified Payment Interface (UPI) service to send or receive money.
|
|
3244
|
+
* Validating the VPA helps reduce payment failure rates due to incorrect VPA.
|
|
3245
|
+
*
|
|
3246
|
+
* @param queryParams - Query parameters containing the VPA to verify
|
|
3247
|
+
* @returns Promise with VPA verification result
|
|
3248
|
+
* @example
|
|
3249
|
+
* ```typescript
|
|
3250
|
+
* const { data, error } = await sdk.payments.verifyVpa({
|
|
3251
|
+
* vpa: "user@upi"
|
|
3167
3252
|
* });
|
|
3168
3253
|
*
|
|
3169
3254
|
* if (error) {
|
|
3170
|
-
* console.error("Failed to
|
|
3255
|
+
* console.error("Failed to verify VPA:", error.message);
|
|
3171
3256
|
* } else {
|
|
3172
|
-
* console.log("
|
|
3173
|
-
* console.log("
|
|
3257
|
+
* console.log("VPA:", data.vpa);
|
|
3258
|
+
* console.log("Status:", data.status);
|
|
3174
3259
|
*
|
|
3175
|
-
* data.
|
|
3176
|
-
* console.log(
|
|
3177
|
-
*
|
|
3178
|
-
* console.log(
|
|
3260
|
+
* if (data.status === "VALID") {
|
|
3261
|
+
* console.log("VPA is valid and can be used for UPI payments");
|
|
3262
|
+
* } else {
|
|
3263
|
+
* console.log("VPA is invalid, please check and try again");
|
|
3264
|
+
* }
|
|
3265
|
+
* }
|
|
3266
|
+
* ```
|
|
3267
|
+
*/
|
|
3268
|
+
async verifyVpa(queryParams) {
|
|
3269
|
+
return this.executeRequest(() => this.client.GET("/payments/verify-vpa", { params: { query: queryParams } }));
|
|
3270
|
+
}
|
|
3271
|
+
/**
|
|
3272
|
+
* Authenticate a direct OTP for payment verification
|
|
3179
3273
|
*
|
|
3180
|
-
*
|
|
3181
|
-
*
|
|
3182
|
-
*
|
|
3183
|
-
*
|
|
3184
|
-
*
|
|
3274
|
+
* @description Used to authenticate OTP during payment flows that require 2FA verification.
|
|
3275
|
+
* The txn_id and challenge_id can be obtained from the create order API response
|
|
3276
|
+
* under the payment_info.authentication.params object.
|
|
3277
|
+
*
|
|
3278
|
+
* @param body - OTP authentication request body
|
|
3279
|
+
* @returns Promise with authentication result
|
|
3280
|
+
* @example
|
|
3281
|
+
* ```typescript
|
|
3282
|
+
* // After creating an order, if OTP authentication is required:
|
|
3283
|
+
* const { data, error } = await sdk.payments.authenticateDirectOtp({
|
|
3284
|
+
* txn_id: "txn_01H9XYZ12345ABCDE",
|
|
3285
|
+
* challenge_id: "challenge_01H9XYZ12345ABCDE",
|
|
3286
|
+
* otp: "123456"
|
|
3287
|
+
* });
|
|
3288
|
+
*
|
|
3289
|
+
* if (error) {
|
|
3290
|
+
* console.error("OTP authentication failed:", error.message);
|
|
3291
|
+
* } else {
|
|
3292
|
+
* console.log("Authentication success:", data.success);
|
|
3293
|
+
* console.log("Message:", data.message);
|
|
3185
3294
|
* }
|
|
3186
3295
|
* ```
|
|
3187
3296
|
*/
|
|
3188
|
-
async
|
|
3189
|
-
return this.executeRequest(() => this.client.POST("/
|
|
3297
|
+
async authenticateDirectOtp(body) {
|
|
3298
|
+
return this.executeRequest(() => this.client.POST("/payments/authenticate-direct-otp", { body }));
|
|
3190
3299
|
}
|
|
3300
|
+
/**
|
|
3301
|
+
* Resend a direct OTP for payment verification
|
|
3302
|
+
*
|
|
3303
|
+
* @description Used to resend OTP during payment flows that require 2FA verification.
|
|
3304
|
+
* The txn_id and challenge_id can be obtained from the create order API response
|
|
3305
|
+
* under the payment_info.authentication.params object.
|
|
3306
|
+
*
|
|
3307
|
+
* @param body - OTP resend request body
|
|
3308
|
+
* @returns Promise with new payment info containing updated OTP challenge
|
|
3309
|
+
* @example
|
|
3310
|
+
* ```typescript
|
|
3311
|
+
* // If user didn't receive OTP or it expired:
|
|
3312
|
+
* const { data, error } = await sdk.payments.resendDirectOtp({
|
|
3313
|
+
* txn_id: "txn_01H9XYZ12345ABCDE",
|
|
3314
|
+
* challenge_id: "challenge_01H9XYZ12345ABCDE"
|
|
3315
|
+
* });
|
|
3316
|
+
*
|
|
3317
|
+
* if (error) {
|
|
3318
|
+
* console.error("Failed to resend OTP:", error.message);
|
|
3319
|
+
* } else {
|
|
3320
|
+
* console.log("OTP resent successfully");
|
|
3321
|
+
* console.log("New payment info:", data.payment_info);
|
|
3322
|
+
* }
|
|
3323
|
+
* ```
|
|
3324
|
+
*/
|
|
3325
|
+
async resendDirectOtp(body) {
|
|
3326
|
+
return this.executeRequest(() => this.client.POST("/payments/resend-direct-otp", { body }));
|
|
3327
|
+
}
|
|
3328
|
+
};
|
|
3329
|
+
|
|
3330
|
+
//#endregion
|
|
3331
|
+
//#region src/lib/shipping.ts
|
|
3332
|
+
/**
|
|
3333
|
+
* Client for interacting with shipping endpoints
|
|
3334
|
+
*/
|
|
3335
|
+
var ShippingClient = class extends StorefrontAPIClient {
|
|
3191
3336
|
/**
|
|
3192
3337
|
* Check pincode deliverability
|
|
3193
3338
|
*
|
|
@@ -3215,6 +3360,47 @@ var ShippingClient = class extends StorefrontAPIClient {
|
|
|
3215
3360
|
async checkPincodeDeliverability(pathParams) {
|
|
3216
3361
|
return this.executeRequest(() => this.client.GET("/shipping/serviceability/{pincode}", { params: { path: pathParams } }));
|
|
3217
3362
|
}
|
|
3363
|
+
/**
|
|
3364
|
+
* Get fulfillment options for an order
|
|
3365
|
+
*
|
|
3366
|
+
* @param body - Fulfillment options body containing cart_id and delivery_pincode
|
|
3367
|
+
* @returns Promise with fulfillment options including collect and delivery methods
|
|
3368
|
+
* @example
|
|
3369
|
+
* ```typescript
|
|
3370
|
+
* const { data, error } = await sdk.shipping.getFulfillmentOptions({
|
|
3371
|
+
* cart_id: "cart_01H9XYZ12345ABCDE",
|
|
3372
|
+
* delivery_pincode: "400001"
|
|
3373
|
+
* });
|
|
3374
|
+
*
|
|
3375
|
+
* if (error) {
|
|
3376
|
+
* console.error("Failed to get fulfillment options:", error.message);
|
|
3377
|
+
* } else {
|
|
3378
|
+
* // Check summary information
|
|
3379
|
+
* console.log("Collect available:", data.summary.collect_available);
|
|
3380
|
+
* console.log("Deliver available:", data.summary.deliver_available);
|
|
3381
|
+
* console.log("Recommended fulfillment type:", data.summary.recommended_fulfillment_type);
|
|
3382
|
+
*
|
|
3383
|
+
* // Access collect options
|
|
3384
|
+
* if (data.collect && data.collect.length > 0) {
|
|
3385
|
+
* console.log("Available stores for collection:");
|
|
3386
|
+
* data.collect.forEach(store => {
|
|
3387
|
+
* console.log(`${store.name} - ${store.distance_km}km away, ETA: ${store.collect_eta_minutes} minutes`);
|
|
3388
|
+
* });
|
|
3389
|
+
* }
|
|
3390
|
+
*
|
|
3391
|
+
* // Access delivery options
|
|
3392
|
+
* if (data.deliver && data.deliver.is_serviceable) {
|
|
3393
|
+
* console.log("Available shipping methods:");
|
|
3394
|
+
* data.deliver.shipping_methods.forEach(method => {
|
|
3395
|
+
* console.log(`${method.name} - ${method.shipping_amount}, ${method.estimated_delivery_days} days`);
|
|
3396
|
+
* });
|
|
3397
|
+
* }
|
|
3398
|
+
* }
|
|
3399
|
+
* ```
|
|
3400
|
+
*/
|
|
3401
|
+
async getFulfillmentOptions(body) {
|
|
3402
|
+
return this.executeRequest(() => this.client.POST("/shipping/fulfillment-options", { body }));
|
|
3403
|
+
}
|
|
3218
3404
|
};
|
|
3219
3405
|
|
|
3220
3406
|
//#endregion
|
|
@@ -3651,6 +3837,29 @@ var CustomerClient = class extends StorefrontAPIClient {
|
|
|
3651
3837
|
async listCustomerReviews(pathParams) {
|
|
3652
3838
|
return this.executeRequest(() => this.client.GET("/customers/{user_id}/reviews", { params: { path: pathParams } }));
|
|
3653
3839
|
}
|
|
3840
|
+
/**
|
|
3841
|
+
* List all saved payment methods for a customer
|
|
3842
|
+
*
|
|
3843
|
+
* @param pathParams - Path parameters
|
|
3844
|
+
* @returns Promise with payment methods
|
|
3845
|
+
*
|
|
3846
|
+
* @example
|
|
3847
|
+
* ```typescript
|
|
3848
|
+
* const { data, error } = await sdk.customer.listSavedPaymentMethods({
|
|
3849
|
+
* customer_id: "customer_123"
|
|
3850
|
+
* });
|
|
3851
|
+
*
|
|
3852
|
+
* if (error) {
|
|
3853
|
+
* console.error("Failed to list saved payment methods:", error);
|
|
3854
|
+
* return;
|
|
3855
|
+
* }
|
|
3856
|
+
*
|
|
3857
|
+
* console.log("Saved payment methods:", data.saved_payment_methods);
|
|
3858
|
+
* ```
|
|
3859
|
+
*/
|
|
3860
|
+
async listSavedPaymentMethods(pathParams) {
|
|
3861
|
+
return this.executeRequest(() => this.client.GET("/customers/{customer_id}/payment-methods", { params: { path: pathParams } }));
|
|
3862
|
+
}
|
|
3654
3863
|
};
|
|
3655
3864
|
|
|
3656
3865
|
//#endregion
|
|
@@ -3721,6 +3930,10 @@ var StorefrontSDK = class {
|
|
|
3721
3930
|
*/
|
|
3722
3931
|
order;
|
|
3723
3932
|
/**
|
|
3933
|
+
* Client for payment-related endpoints
|
|
3934
|
+
*/
|
|
3935
|
+
payments;
|
|
3936
|
+
/**
|
|
3724
3937
|
* Client for store config-related endpoints
|
|
3725
3938
|
*/
|
|
3726
3939
|
store;
|
|
@@ -3757,6 +3970,7 @@ var StorefrontSDK = class {
|
|
|
3757
3970
|
this.helpers = new HelpersClient(config);
|
|
3758
3971
|
this.shipping = new ShippingClient(config);
|
|
3759
3972
|
this.order = new OrderClient(config);
|
|
3973
|
+
this.payments = new PaymentsClient(config);
|
|
3760
3974
|
this.store = new StoreConfigClient(config);
|
|
3761
3975
|
}
|
|
3762
3976
|
/**
|
|
@@ -3777,6 +3991,7 @@ var StorefrontSDK = class {
|
|
|
3777
3991
|
await this.helpers.setTokens(accessToken, refreshToken);
|
|
3778
3992
|
await this.shipping.setTokens(accessToken, refreshToken);
|
|
3779
3993
|
await this.order.setTokens(accessToken, refreshToken);
|
|
3994
|
+
await this.payments.setTokens(accessToken, refreshToken);
|
|
3780
3995
|
await this.store.setTokens(accessToken, refreshToken);
|
|
3781
3996
|
}
|
|
3782
3997
|
/**
|
|
@@ -3794,6 +4009,7 @@ var StorefrontSDK = class {
|
|
|
3794
4009
|
await this.helpers.clearTokens();
|
|
3795
4010
|
await this.shipping.clearTokens();
|
|
3796
4011
|
await this.order.clearTokens();
|
|
4012
|
+
await this.payments.clearTokens();
|
|
3797
4013
|
await this.store.clearTokens();
|
|
3798
4014
|
}
|
|
3799
4015
|
/**
|
|
@@ -3809,6 +4025,7 @@ var StorefrontSDK = class {
|
|
|
3809
4025
|
this.helpers.setApiKey(apiKey);
|
|
3810
4026
|
this.shipping.setApiKey(apiKey);
|
|
3811
4027
|
this.order.setApiKey(apiKey);
|
|
4028
|
+
this.payments.setApiKey(apiKey);
|
|
3812
4029
|
this.store.setApiKey(apiKey);
|
|
3813
4030
|
}
|
|
3814
4031
|
/**
|
|
@@ -3822,6 +4039,7 @@ var StorefrontSDK = class {
|
|
|
3822
4039
|
this.helpers.clearApiKey();
|
|
3823
4040
|
this.shipping.clearApiKey();
|
|
3824
4041
|
this.order.clearApiKey();
|
|
4042
|
+
this.payments.clearApiKey();
|
|
3825
4043
|
this.store.clearApiKey();
|
|
3826
4044
|
}
|
|
3827
4045
|
/**
|
|
@@ -3900,6 +4118,7 @@ var StorefrontSDK = class {
|
|
|
3900
4118
|
this.helpers.setDefaultHeaders(headers);
|
|
3901
4119
|
this.shipping.setDefaultHeaders(headers);
|
|
3902
4120
|
this.order.setDefaultHeaders(headers);
|
|
4121
|
+
this.payments.setDefaultHeaders(headers);
|
|
3903
4122
|
this.store.setDefaultHeaders(headers);
|
|
3904
4123
|
}
|
|
3905
4124
|
/**
|
|
@@ -3914,5 +4133,5 @@ var StorefrontSDK = class {
|
|
|
3914
4133
|
var src_default = StorefrontSDK;
|
|
3915
4134
|
|
|
3916
4135
|
//#endregion
|
|
3917
|
-
export { AuthClient, BrowserTokenStorage, CartClient, CatalogClient, CookieTokenStorage, CustomerClient, Environment, HelpersClient, MemoryTokenStorage, OrderClient, ResponseUtils, ShippingClient, StoreConfigClient, StorefrontAPIClient, StorefrontSDK, src_default as default };
|
|
4136
|
+
export { AuthClient, BrowserTokenStorage, CartClient, CatalogClient, CookieTokenStorage, CustomerClient, Environment, HelpersClient, MemoryTokenStorage, OrderClient, PaymentsClient, ResponseUtils, ShippingClient, StoreConfigClient, StorefrontAPIClient, StorefrontSDK, src_default as default };
|
|
3918
4137
|
//# sourceMappingURL=index.js.map
|