@eetech-commerce/cart-react 0.6.0 → 0.6.2
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 +31 -1
- package/dist/index.js +49 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -678,6 +678,30 @@ type EmbeddedPaymentSessionResponseDto = {
|
|
|
678
678
|
*/
|
|
679
679
|
currency: string;
|
|
680
680
|
};
|
|
681
|
+
type CreatePaymentIntentDto = {
|
|
682
|
+
/**
|
|
683
|
+
* Cart session ID (nanoid format) to create payment intent for
|
|
684
|
+
*/
|
|
685
|
+
cartSessionId: string;
|
|
686
|
+
};
|
|
687
|
+
type PaymentIntentResponseDto = {
|
|
688
|
+
/**
|
|
689
|
+
* Unique payment session identifier
|
|
690
|
+
*/
|
|
691
|
+
paymentSessionId: string;
|
|
692
|
+
/**
|
|
693
|
+
* Stripe client secret for Elements/PaymentElement
|
|
694
|
+
*/
|
|
695
|
+
clientSecret: string;
|
|
696
|
+
/**
|
|
697
|
+
* Payment amount in cents
|
|
698
|
+
*/
|
|
699
|
+
amount: number;
|
|
700
|
+
/**
|
|
701
|
+
* Three-letter currency code (lowercase)
|
|
702
|
+
*/
|
|
703
|
+
currency: string;
|
|
704
|
+
};
|
|
681
705
|
|
|
682
706
|
interface MutationCallbacks<TData = unknown, TError = Error> {
|
|
683
707
|
onSuccess?: (data: TData) => void;
|
|
@@ -1264,6 +1288,12 @@ declare function useCreateEmbeddedCheckoutSession(): {
|
|
|
1264
1288
|
error: Error | null;
|
|
1265
1289
|
data: EmbeddedPaymentSessionResponseDto | undefined;
|
|
1266
1290
|
};
|
|
1291
|
+
declare function useCreatePaymentIntent(): {
|
|
1292
|
+
createPaymentIntent: (params: CreatePaymentIntentDto, callbacks?: MutationCallbacks<PaymentIntentResponseDto>) => void;
|
|
1293
|
+
isPending: boolean;
|
|
1294
|
+
error: Error | null;
|
|
1295
|
+
data: PaymentIntentResponseDto | undefined;
|
|
1296
|
+
};
|
|
1267
1297
|
declare function usePaymentSession(sessionId: string | null): _tanstack_react_query.UseQueryResult<PaymentSessionResponseDto, Error>;
|
|
1268
1298
|
|
|
1269
1299
|
declare const cartKeys: {
|
|
@@ -1293,4 +1323,4 @@ interface CartProviderProps {
|
|
|
1293
1323
|
}
|
|
1294
1324
|
declare function CartProvider({ children, tenantSlug, cartApiUrl, storageAdapter, autoInitialize, queryClient, }: CartProviderProps): react_jsx_runtime.JSX.Element;
|
|
1295
1325
|
|
|
1296
|
-
export { type CartContextValue, CartProvider, type CartProviderProps, type CartResponseDto, type CreateCheckoutDto, type CreateEmbeddedPaymentSessionDto, type EmbeddedPaymentSessionResponseDto, type LineItemResponseDto, type LoadStripeFn, type MutationCallbacks, type ShippingOptionDto, type ShippingRegionDto, type ShippingRegionsResponseDto, type ShippingSelectionDto, type StorageAdapter, type UpdateCheckoutDto, type VerificationResultDto, cartKeys, localStorageAdapter, paymentKeys, shippingKeys, useAddToCart, useCart, useCartContext, useClearCart, useCreateCart, useCreateCheckoutSession, useCreateEmbeddedCheckoutSession, useInitializeCart, usePaymentSession, useRemoveItem, useShippingOptions, useShippingRegions, useStripePromise, useUpdateCheckoutSession, useUpdateItemQty, useUpdateShippingSelections, useVerifyCart };
|
|
1326
|
+
export { type CartContextValue, CartProvider, type CartProviderProps, type CartResponseDto, type CreateCheckoutDto, type CreateEmbeddedPaymentSessionDto, type CreatePaymentIntentDto, type EmbeddedPaymentSessionResponseDto, type LineItemResponseDto, type LoadStripeFn, type MutationCallbacks, type PaymentIntentResponseDto, type ShippingOptionDto, type ShippingRegionDto, type ShippingRegionsResponseDto, type ShippingSelectionDto, type StorageAdapter, type UpdateCheckoutDto, type VerificationResultDto, cartKeys, localStorageAdapter, paymentKeys, shippingKeys, useAddToCart, useCart, useCartContext, useClearCart, useCreateCart, useCreateCheckoutSession, useCreateEmbeddedCheckoutSession, useCreatePaymentIntent, useInitializeCart, usePaymentSession, useRemoveItem, useShippingOptions, useShippingRegions, useStripePromise, useUpdateCheckoutSession, useUpdateItemQty, useUpdateShippingSelections, useVerifyCart };
|
package/dist/index.js
CHANGED
|
@@ -975,6 +975,16 @@ var paymentControllerCreateEmbeddedPaymentSessionV1 = (options) => {
|
|
|
975
975
|
}
|
|
976
976
|
});
|
|
977
977
|
};
|
|
978
|
+
var paymentControllerCreatePaymentIntentV1 = (options) => {
|
|
979
|
+
return (options.client ?? client).post({
|
|
980
|
+
url: "/v1/t/{tenantSlug}/payments/intents",
|
|
981
|
+
...options,
|
|
982
|
+
headers: {
|
|
983
|
+
"Content-Type": "application/json",
|
|
984
|
+
...options.headers
|
|
985
|
+
}
|
|
986
|
+
});
|
|
987
|
+
};
|
|
978
988
|
var paymentControllerGetPaymentSessionV1 = (options) => {
|
|
979
989
|
return (options.client ?? client).get({
|
|
980
990
|
url: "/v1/t/{tenantSlug}/payments/sessions/{id}",
|
|
@@ -1189,6 +1199,19 @@ var paymentControllerCreateEmbeddedPaymentSessionV1Mutation = (options) => {
|
|
|
1189
1199
|
};
|
|
1190
1200
|
return mutationOptions;
|
|
1191
1201
|
};
|
|
1202
|
+
var paymentControllerCreatePaymentIntentV1Mutation = (options) => {
|
|
1203
|
+
const mutationOptions = {
|
|
1204
|
+
mutationFn: async (fnOptions) => {
|
|
1205
|
+
const { data } = await paymentControllerCreatePaymentIntentV1({
|
|
1206
|
+
...options,
|
|
1207
|
+
...fnOptions,
|
|
1208
|
+
throwOnError: true
|
|
1209
|
+
});
|
|
1210
|
+
return data;
|
|
1211
|
+
}
|
|
1212
|
+
};
|
|
1213
|
+
return mutationOptions;
|
|
1214
|
+
};
|
|
1192
1215
|
var paymentControllerGetPaymentSessionV1QueryKey = (options) => createQueryKey("paymentControllerGetPaymentSessionV1", options);
|
|
1193
1216
|
var paymentControllerGetPaymentSessionV1Options = (options) => queryOptions({
|
|
1194
1217
|
queryFn: async ({ queryKey, signal }) => {
|
|
@@ -1640,6 +1663,31 @@ function useCreateEmbeddedCheckoutSession() {
|
|
|
1640
1663
|
data: mutation.data
|
|
1641
1664
|
};
|
|
1642
1665
|
}
|
|
1666
|
+
function useCreatePaymentIntent() {
|
|
1667
|
+
const { tenantSlug, cartApiUrl } = useCartContext();
|
|
1668
|
+
const mutation = useMutation3({
|
|
1669
|
+
...paymentControllerCreatePaymentIntentV1Mutation()
|
|
1670
|
+
});
|
|
1671
|
+
const createPaymentIntent = useCallback3(
|
|
1672
|
+
(params, callbacks) => {
|
|
1673
|
+
mutation.mutate(
|
|
1674
|
+
{
|
|
1675
|
+
path: { tenantSlug },
|
|
1676
|
+
body: params,
|
|
1677
|
+
baseUrl: cartApiUrl
|
|
1678
|
+
},
|
|
1679
|
+
callbacks
|
|
1680
|
+
);
|
|
1681
|
+
},
|
|
1682
|
+
[mutation, tenantSlug, cartApiUrl]
|
|
1683
|
+
);
|
|
1684
|
+
return {
|
|
1685
|
+
createPaymentIntent,
|
|
1686
|
+
isPending: mutation.isPending,
|
|
1687
|
+
error: mutation.error,
|
|
1688
|
+
data: mutation.data
|
|
1689
|
+
};
|
|
1690
|
+
}
|
|
1643
1691
|
function usePaymentSession(sessionId) {
|
|
1644
1692
|
const { tenantSlug, cartApiUrl } = useCartContext();
|
|
1645
1693
|
return useQuery3({
|
|
@@ -1759,6 +1807,7 @@ export {
|
|
|
1759
1807
|
useCreateCart,
|
|
1760
1808
|
useCreateCheckoutSession,
|
|
1761
1809
|
useCreateEmbeddedCheckoutSession,
|
|
1810
|
+
useCreatePaymentIntent,
|
|
1762
1811
|
useInitializeCart,
|
|
1763
1812
|
usePaymentSession,
|
|
1764
1813
|
useRemoveItem,
|