@kasuvia/sdk 0.0.8 → 0.0.9
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/README.md +42 -15
- package/dist/AddressAutocomplete-CjcqPElD.d.mts +46 -0
- package/dist/AddressAutocomplete-CvJHuRkf.d.ts +46 -0
- package/dist/components/index.d.mts +497 -0
- package/dist/components/index.d.ts +497 -0
- package/dist/components/index.js +4217 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/index.mjs +4194 -0
- package/dist/components/index.mjs.map +1 -0
- package/dist/config/server.d.mts +26 -0
- package/dist/config/server.d.ts +26 -0
- package/dist/config/server.js +38 -0
- package/dist/config/server.js.map +1 -0
- package/dist/config/server.mjs +13 -0
- package/dist/config/server.mjs.map +1 -0
- package/dist/hooks/index.d.mts +393 -160
- package/dist/hooks/index.d.ts +393 -160
- package/dist/hooks/index.js +2792 -2137
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +2734 -2121
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/index-CNW_LINy.d.mts +578 -0
- package/dist/index-CNW_LINy.d.ts +578 -0
- package/dist/{index-C1chUA3P.d.mts → index-F7N6UItS.d.mts} +1 -1
- package/dist/{index-C1chUA3P.d.ts → index-F7N6UItS.d.ts} +1 -1
- package/dist/index-NkI10J_E.d.mts +40 -0
- package/dist/index-NkI10J_E.d.ts +40 -0
- package/dist/index.d.mts +20437 -103
- package/dist/index.d.ts +20437 -103
- package/dist/index.js +2111 -1802
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2006 -1786
- package/dist/index.mjs.map +1 -1
- package/dist/media.service-Cx7dQjzX.d.mts +1393 -0
- package/dist/media.service-mrBFJ2UQ.d.ts +1393 -0
- package/dist/services/index.d.mts +908 -2
- package/dist/services/index.d.ts +908 -2
- package/dist/services/index.js +1492 -1686
- package/dist/services/index.js.map +1 -1
- package/dist/services/index.mjs +1431 -1670
- package/dist/services/index.mjs.map +1 -1
- package/package.json +46 -6
- package/src/components/bespoke/BespokeAvailabilityBadge.tsx +32 -0
- package/src/components/bespoke/BespokeProgressTracker.tsx +58 -0
- package/src/components/bespoke/index.ts +3 -0
- package/src/components/booking/SlotPicker.tsx +97 -0
- package/src/components/booking/index.ts +1 -0
- package/src/components/cart/CartItem.tsx +81 -0
- package/src/components/cart/CartSidebar.tsx +115 -0
- package/src/components/cart/CartTypeMismatchBanner.tsx +55 -0
- package/src/components/cart/index.ts +3 -0
- package/src/components/index.ts +8 -0
- package/src/components/orders/DeliverableReviewer.tsx +139 -0
- package/src/components/orders/index.ts +1 -0
- package/src/components/product/ProductCard.tsx +350 -0
- package/src/components/product/ProductGrid.tsx +84 -0
- package/src/components/product/index.ts +2 -0
- package/src/components/shared/AddressAutocomplete.tsx +212 -0
- package/src/components/shared/AnalyticsScripts.tsx +56 -0
- package/src/components/shared/CookieConsentBanner.tsx +98 -0
- package/src/components/shared/ImageEditorModal.tsx +1066 -0
- package/src/components/shared/ImageViewerModal.tsx +598 -0
- package/src/components/shared/LucideReactIcon.tsx +52 -0
- package/src/components/shared/MapPinDrop.tsx +101 -0
- package/src/components/shared/MultiSelectPicker.tsx +193 -0
- package/src/components/shared/OfflineBanner.tsx +46 -0
- package/src/components/shared/SearchableInput.tsx +153 -0
- package/src/components/shared/SearchablePopover.tsx +166 -0
- package/src/components/shared/SmartImage.tsx +311 -0
- package/src/components/shared/TruncatedValue.tsx +27 -0
- package/src/components/shared/UnsavedChangesGuard.tsx +138 -0
- package/src/components/shared/index.ts +15 -0
- package/src/components/skeletons/CardSkeleton.tsx +26 -0
- package/src/components/skeletons/CartItemSkeleton.tsx +26 -0
- package/src/components/skeletons/OrderItemSkeleton.tsx +26 -0
- package/src/components/skeletons/ProductCardSkeleton.tsx +26 -0
- package/src/components/skeletons/TableSkeleton.tsx +42 -0
- package/src/components/skeletons/index.ts +5 -0
- package/src/config/index.ts +22 -4
- package/src/config/server.ts +45 -0
- package/src/context/sdk-context.tsx +5 -2
- package/src/generated/auth-openapi.ts +2935 -0
- package/src/generated/cart-openapi.ts +652 -0
- package/src/generated/cms-openapi.ts +1668 -0
- package/src/generated/crm-openapi.ts +986 -0
- package/src/generated/graphql.ts +126 -0
- package/src/generated/index.ts +11 -0
- package/src/generated/media-openapi.ts +613 -0
- package/src/generated/notification-openapi.ts +862 -0
- package/src/generated/payment-openapi.ts +2713 -0
- package/src/generated/store-openapi.ts +9510 -0
- package/src/graphql/operations/collections.graphql +32 -0
- package/src/graphql/operations/products.graphql +197 -0
- package/src/graphql/operations/wishlist.graphql +25 -0
- package/src/hooks/index.ts +9 -2
- package/src/hooks/use-auth.ts +163 -69
- package/src/hooks/use-bespoke-availability.ts +39 -22
- package/src/hooks/use-business-config.ts +51 -0
- package/src/hooks/use-cart.ts +310 -238
- package/src/hooks/use-cms.ts +107 -127
- package/src/hooks/use-collections.ts +35 -55
- package/src/hooks/use-consultations.ts +9 -136
- package/src/hooks/use-countries.ts +19 -28
- package/src/hooks/use-currencies.ts +8 -20
- package/src/hooks/use-customer-address.ts +64 -0
- package/src/hooks/use-feedback.ts +34 -0
- package/src/hooks/use-languages.ts +26 -39
- package/src/hooks/use-media-upload.ts +23 -0
- package/src/hooks/use-notification-stream.ts +88 -0
- package/src/hooks/use-notifications.ts +163 -0
- package/src/hooks/use-order-stream.ts +29 -29
- package/src/hooks/use-orders.ts +91 -73
- package/src/hooks/use-payment.ts +116 -84
- package/src/hooks/use-products.ts +65 -269
- package/src/hooks/use-push-notifications.ts +122 -0
- package/src/hooks/use-reviews.ts +175 -0
- package/src/hooks/use-service-booking.ts +109 -132
- package/src/hooks/use-states.ts +16 -30
- package/src/hooks/use-wishlist.ts +44 -69
- package/src/index.ts +15 -11
- package/src/services/auth.service.ts +422 -132
- package/src/services/bespoke.service.ts +69 -10
- package/src/services/cart.service.ts +155 -186
- package/src/services/cms.service.ts +41 -50
- package/src/services/collection.service.ts +25 -63
- package/src/services/config.service.ts +10 -21
- package/src/services/consultation.service.ts +36 -93
- package/src/services/feedback.service.ts +76 -0
- package/src/services/index.ts +7 -1
- package/src/services/legal.service.ts +62 -0
- package/src/services/logistics.service.ts +235 -53
- package/src/services/media.service.ts +115 -0
- package/src/services/notifications.service.ts +204 -20
- package/src/services/order.service.ts +498 -127
- package/src/services/payment.service.ts +149 -100
- package/src/services/product.service.ts +157 -814
- package/src/services/review.service.ts +211 -0
- package/src/services/service-booking.service.ts +198 -99
- package/src/services/wishlist.service.ts +27 -74
- package/src/types/auth/index.ts +161 -18
- package/src/types/business/index.ts +9 -1
- package/src/types/cms/index.ts +91 -6
- package/src/types/cms/legal.ts +18 -0
- package/src/types/consultations/index.ts +60 -68
- package/src/types/index.ts +5 -3
- package/src/types/media/index.ts +35 -3
- package/src/types/payments/index.ts +80 -16
- package/src/types/reviews/index.ts +116 -0
- package/src/types/services/index.ts +113 -38
- package/src/types/store/checkout.ts +53 -0
- package/src/types/store/index.ts +273 -52
- package/src/types/store/invoice.ts +31 -0
- package/src/types/store/shipping.ts +84 -3
- package/src/types/ui/index.ts +1 -1
- package/src/utils/checkout.ts +19 -3
- package/src/utils/cookieConsent.ts +34 -0
- package/src/utils/format.ts +408 -0
- package/src/utils/geolocation.ts +134 -0
- package/src/utils/graphql-url.ts +47 -0
- package/src/utils/guest-session.ts +59 -0
- package/src/utils/http-client.ts +147 -0
- package/src/utils/index.ts +11 -4
- package/src/utils/status-colors.ts +79 -0
- package/src/utils/token-refresh.ts +115 -0
- package/src/utils/validators.ts +13 -0
- package/src/utils/youtube.ts +18 -0
- package/dist/index-C5YO9gTl.d.mts +0 -507
- package/dist/index-C5YO9gTl.d.ts +0 -507
- package/dist/index-CefG7_xq.d.mts +0 -793
- package/dist/index-DeHCf3zI.d.ts +0 -793
- package/src/graphql/collections.graphql.ts +0 -48
- package/src/graphql/index.ts +0 -7
- package/src/graphql/products.graphql.ts +0 -860
- package/src/graphql/wishlist.graphql.ts +0 -34
- package/src/hooks/use-consultation-stream.ts +0 -142
- package/src/types/bespoke/index.ts +0 -39
|
@@ -1,18 +1,55 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Payment Service
|
|
3
|
-
*
|
|
4
|
-
* Customer-facing payment API for payment initiation and verification
|
|
3
|
+
*
|
|
4
|
+
* Customer-facing payment API for payment initiation and verification via
|
|
5
|
+
* kasuvia-payment-system-go.
|
|
5
6
|
* Stateless - all configuration passed as parameters.
|
|
6
7
|
*/
|
|
7
8
|
import type { SdkConfig } from '../config'
|
|
8
9
|
import type {
|
|
9
|
-
ConversionQuote,
|
|
10
10
|
DVACreateRequest,
|
|
11
11
|
DVADetails,
|
|
12
|
+
GatewayMethods,
|
|
12
13
|
PaymentInitiateRequest,
|
|
13
14
|
PaymentInitiateResponse,
|
|
14
15
|
TransactionVerifyResponse,
|
|
16
|
+
WalletBalanceResponse,
|
|
17
|
+
WalletLedgerResponse,
|
|
15
18
|
} from '../types/payments/index'
|
|
19
|
+
import { apiRequest, storefrontHeaders, authHeaders, JSON_HEADERS } from '../utils/http-client'
|
|
20
|
+
|
|
21
|
+
function isValidUUID(str: string): boolean {
|
|
22
|
+
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(str)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Fetch available payment methods and gateways for a storefront region.
|
|
27
|
+
*
|
|
28
|
+
* REAL BUG FIXED (2026-09-22): `currency`/`countryCode` used to default to
|
|
29
|
+
* 'NGN'/'NG' as SDK-level JS defaults — an independent copy of a value the
|
|
30
|
+
* real backend already declares itself (`query:"currency" default:"NGN"` /
|
|
31
|
+
* `query:"country_code" default:"NG"`, kasuvia-payment-system-go's own real,
|
|
32
|
+
* documented default for this route). Duplicating it client-side risks the
|
|
33
|
+
* two silently drifting apart if the backend's real default is ever
|
|
34
|
+
* changed. Now optional with no client-side default at all — when omitted,
|
|
35
|
+
* the query param is left out entirely and the backend's own declared
|
|
36
|
+
* default applies, the single source of truth for what "unspecified"
|
|
37
|
+
* means here.
|
|
38
|
+
*/
|
|
39
|
+
export async function getAvailablePaymentMethods(
|
|
40
|
+
config: SdkConfig,
|
|
41
|
+
currency?: string,
|
|
42
|
+
countryCode?: string
|
|
43
|
+
): Promise<GatewayMethods[]> {
|
|
44
|
+
const params: Record<string, string> = {}
|
|
45
|
+
if (currency) params.currency = currency
|
|
46
|
+
if (countryCode) params.country_code = countryCode
|
|
47
|
+
const query = new URLSearchParams(params).toString()
|
|
48
|
+
return apiRequest<GatewayMethods[]>(`${config.backendUrls.payment}/payments/storefront/methods${query ? `?${query}` : ''}`, {
|
|
49
|
+
headers: storefrontHeaders(config),
|
|
50
|
+
fallbackErrorMessage: 'Failed to fetch available payment methods',
|
|
51
|
+
})
|
|
52
|
+
}
|
|
16
53
|
|
|
17
54
|
/**
|
|
18
55
|
* Create a Monnify Dedicated Virtual Account so the customer can pay via
|
|
@@ -21,77 +58,82 @@ import type {
|
|
|
21
58
|
*/
|
|
22
59
|
export async function createDedicatedAccount(
|
|
23
60
|
config: SdkConfig,
|
|
24
|
-
accessToken: string,
|
|
61
|
+
accessToken: string | null | undefined,
|
|
25
62
|
request: DVACreateRequest
|
|
26
63
|
): Promise<DVADetails> {
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
64
|
+
const origin = request.storefront_origin || (typeof window !== 'undefined' ? window.location.origin : '');
|
|
65
|
+
|
|
66
|
+
const headers: Record<string, string> = { ...JSON_HEADERS, ...storefrontHeaders(config) }
|
|
67
|
+
if (accessToken) {
|
|
68
|
+
headers["Authorization"] = `Bearer ${accessToken}`
|
|
69
|
+
}
|
|
70
|
+
if (origin) {
|
|
71
|
+
headers["Origin"] = origin
|
|
30
72
|
}
|
|
31
73
|
|
|
32
|
-
|
|
74
|
+
return apiRequest<DVADetails>(`${config.backendUrls.payment}/payments/storefront/dedicated-account`, {
|
|
33
75
|
method: 'POST',
|
|
34
|
-
headers
|
|
35
|
-
'Content-Type': 'application/json',
|
|
36
|
-
"Authorization": `Bearer ${accessToken}`,
|
|
37
|
-
"X-Storefront-Key": config.storefrontApiKey,
|
|
38
|
-
"X-Business-ID": config.businessId,
|
|
39
|
-
},
|
|
76
|
+
headers,
|
|
40
77
|
body: JSON.stringify({
|
|
41
78
|
order_id: request.order_id && isValidUUID(request.order_id) ? request.order_id : undefined,
|
|
42
79
|
amount: request.amount,
|
|
43
80
|
customer_email: request.customer_email,
|
|
44
81
|
customer_name: request.customer_name,
|
|
45
82
|
currency: request.currency,
|
|
83
|
+
gateway: request.gateway,
|
|
46
84
|
idempotency_key: request.idempotency_key,
|
|
47
85
|
}),
|
|
86
|
+
fallbackErrorMessage: 'Failed to create dedicated account',
|
|
48
87
|
})
|
|
49
|
-
if (!response.ok) throw new Error('Failed to create dedicated account')
|
|
50
|
-
const data = await response.json()
|
|
51
|
-
return data
|
|
52
88
|
}
|
|
53
89
|
|
|
54
90
|
/**
|
|
55
|
-
* Initiate a
|
|
56
|
-
* Routes to Monnify
|
|
91
|
+
* Initiate a payment (customer → business owner).
|
|
92
|
+
* Routes to Monnify, Flutterwave, or Paystack on the backend based on region/selection.
|
|
57
93
|
* Returns a checkout_url to redirect the customer to the gateway.
|
|
58
94
|
*/
|
|
59
95
|
export async function initiatePayment(
|
|
60
96
|
config: SdkConfig,
|
|
61
|
-
accessToken: string,
|
|
97
|
+
accessToken: string | null | undefined,
|
|
62
98
|
request: PaymentInitiateRequest
|
|
63
99
|
): Promise<PaymentInitiateResponse> {
|
|
64
|
-
const isValidUUID = (str: string) => {
|
|
65
|
-
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
66
|
-
return uuidRegex.test(str);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
100
|
const validOrderId = request.order_id && isValidUUID(request.order_id) ? request.order_id : undefined;
|
|
101
|
+
const origin = request.storefront_origin || (typeof window !== 'undefined' ? window.location.origin : '');
|
|
70
102
|
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
headers
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
103
|
+
const headers: Record<string, string> = { ...JSON_HEADERS, ...storefrontHeaders(config) }
|
|
104
|
+
if (accessToken) {
|
|
105
|
+
headers["Authorization"] = `Bearer ${accessToken}`
|
|
106
|
+
}
|
|
107
|
+
if (origin) {
|
|
108
|
+
headers["Origin"] = origin
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const data = await apiRequest<PaymentInitiateResponse & { metadata_json?: { checkout_url?: string } }>(
|
|
112
|
+
`${config.backendUrls.payment}/payments/storefront/initiate`,
|
|
113
|
+
{
|
|
114
|
+
method: 'POST',
|
|
115
|
+
headers,
|
|
116
|
+
body: JSON.stringify({
|
|
117
|
+
amount: request.amount,
|
|
118
|
+
currency: request.currency,
|
|
119
|
+
// Same real backend default as getAvailablePaymentMethods above
|
|
120
|
+
// (huma's own `default:"NG"` on this field) — omit rather than
|
|
121
|
+
// hardcode a client-side copy of it.
|
|
122
|
+
country_code: request.country_code,
|
|
123
|
+
gateway: request.gateway,
|
|
87
124
|
order_id: validOrderId,
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
125
|
+
quote_id: request.quote_id,
|
|
126
|
+
metadata_json: {
|
|
127
|
+
customer_email: request.customer_email,
|
|
128
|
+
customer_name: request.customer_name ?? '',
|
|
129
|
+
order_id: validOrderId,
|
|
130
|
+
...(request.metadata ?? {}),
|
|
131
|
+
},
|
|
132
|
+
idempotency_key: request.idempotency_key,
|
|
133
|
+
}),
|
|
134
|
+
fallbackErrorMessage: 'Failed to initiate payment',
|
|
135
|
+
}
|
|
136
|
+
)
|
|
95
137
|
|
|
96
138
|
return {
|
|
97
139
|
id: data.id,
|
|
@@ -103,80 +145,87 @@ export async function initiatePayment(
|
|
|
103
145
|
}
|
|
104
146
|
|
|
105
147
|
/**
|
|
106
|
-
*
|
|
148
|
+
* Verify a payment after the gateway redirects back to /checkout/verify.
|
|
107
149
|
*/
|
|
108
|
-
export async function
|
|
150
|
+
export async function verifyTransaction(
|
|
109
151
|
config: SdkConfig,
|
|
110
|
-
|
|
111
|
-
): Promise<
|
|
112
|
-
|
|
152
|
+
reference: string
|
|
153
|
+
): Promise<TransactionVerifyResponse> {
|
|
154
|
+
return apiRequest<TransactionVerifyResponse>(`${config.backendUrls.payment}/payments/verify/${reference}`, {
|
|
113
155
|
method: 'POST',
|
|
114
|
-
headers: {
|
|
115
|
-
|
|
116
|
-
"X-Storefront-Key": config.storefrontApiKey,
|
|
117
|
-
"X-Business-ID": config.businessId,
|
|
118
|
-
},
|
|
119
|
-
body: JSON.stringify({ amount }),
|
|
156
|
+
headers: { ...JSON_HEADERS, ...storefrontHeaders(config) },
|
|
157
|
+
fallbackErrorMessage: 'Failed to verify transaction',
|
|
120
158
|
})
|
|
121
|
-
if (!response.ok) throw new Error('Failed to request quote')
|
|
122
|
-
const data = await response.json()
|
|
123
|
-
return data
|
|
124
159
|
}
|
|
125
160
|
|
|
126
161
|
/**
|
|
127
|
-
*
|
|
162
|
+
* Poll transaction status by internal transaction ID.
|
|
128
163
|
*/
|
|
129
|
-
export async function
|
|
130
|
-
|
|
131
|
-
|
|
164
|
+
export async function getTransactionStatus(
|
|
165
|
+
config: SdkConfig,
|
|
166
|
+
transactionId: string
|
|
132
167
|
): Promise<TransactionVerifyResponse> {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
})
|
|
139
|
-
if (!response.ok) throw new Error('Failed to verify transaction')
|
|
140
|
-
return response.json()
|
|
141
|
-
}
|
|
168
|
+
return apiRequest<TransactionVerifyResponse>(`${config.backendUrls.payment}/payments/transactions/${transactionId}`, {
|
|
169
|
+
headers: storefrontHeaders(config),
|
|
170
|
+
fallbackErrorMessage: 'Failed to get transaction status',
|
|
171
|
+
})
|
|
172
|
+
}
|
|
142
173
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
174
|
+
/**
|
|
175
|
+
* Fetch authenticated customer's wallet balance.
|
|
176
|
+
*/
|
|
177
|
+
export async function getWalletBalance(
|
|
178
|
+
config: SdkConfig,
|
|
179
|
+
accessToken: string
|
|
180
|
+
): Promise<WalletBalanceResponse> {
|
|
181
|
+
return apiRequest<WalletBalanceResponse>(`${config.backendUrls.payment}/wallet/balance`, {
|
|
182
|
+
headers: authHeaders(config, accessToken),
|
|
183
|
+
fallbackErrorMessage: 'Failed to fetch wallet balance',
|
|
152
184
|
})
|
|
153
|
-
if (!response.ok) throw new Error('Failed to verify transaction')
|
|
154
|
-
const data = await response.json()
|
|
155
|
-
return data
|
|
156
185
|
}
|
|
157
186
|
|
|
158
187
|
/**
|
|
159
|
-
*
|
|
188
|
+
* Fetch authenticated customer's wallet ledger (transaction history).
|
|
160
189
|
*/
|
|
161
|
-
export async function
|
|
190
|
+
export async function getWalletLedger(
|
|
162
191
|
config: SdkConfig,
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
}
|
|
192
|
+
accessToken: string,
|
|
193
|
+
params?: { page?: number; page_size?: number }
|
|
194
|
+
): Promise<WalletLedgerResponse> {
|
|
195
|
+
const page = params?.page ?? 1
|
|
196
|
+
const pageSize = params?.page_size ?? 20
|
|
197
|
+
return apiRequest<WalletLedgerResponse>(
|
|
198
|
+
`${config.backendUrls.payment}/wallet/ledger?page=${page}&page_size=${pageSize}`,
|
|
199
|
+
{
|
|
200
|
+
headers: authHeaders(config, accessToken),
|
|
201
|
+
fallbackErrorMessage: 'Failed to fetch wallet ledger',
|
|
202
|
+
}
|
|
203
|
+
)
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Claim a pending guest wallet credit into the authenticated customer's wallet.
|
|
208
|
+
*/
|
|
209
|
+
export async function claimWalletCredit(
|
|
210
|
+
config: SdkConfig,
|
|
211
|
+
accessToken: string,
|
|
212
|
+
claimToken: string
|
|
213
|
+
): Promise<WalletBalanceResponse> {
|
|
214
|
+
return apiRequest<WalletBalanceResponse>(`${config.backendUrls.payment}/wallet/claim`, {
|
|
215
|
+
method: 'POST',
|
|
216
|
+
headers: { ...JSON_HEADERS, ...authHeaders(config, accessToken) },
|
|
217
|
+
body: JSON.stringify({ claim_token: claimToken }),
|
|
218
|
+
fallbackErrorMessage: 'Failed to claim wallet credit',
|
|
170
219
|
})
|
|
171
|
-
if (!response.ok) throw new Error('Failed to get transaction status')
|
|
172
|
-
const data = await response.json()
|
|
173
|
-
return data
|
|
174
220
|
}
|
|
175
221
|
|
|
176
222
|
export const paymentService = {
|
|
223
|
+
getAvailablePaymentMethods,
|
|
177
224
|
createDedicatedAccount,
|
|
178
225
|
initiatePayment,
|
|
179
|
-
requestQuote,
|
|
180
226
|
verifyTransaction,
|
|
181
227
|
getTransactionStatus,
|
|
228
|
+
getWalletBalance,
|
|
229
|
+
getWalletLedger,
|
|
230
|
+
claimWalletCredit,
|
|
182
231
|
} as const
|