@eetech-commerce/cart-react 0.5.3 → 0.6.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/README.md +3 -0
- package/dist/index.d.ts +373 -2
- package/dist/index.js +81 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -92,6 +92,7 @@ function Shop() {
|
|
|
92
92
|
| `useCreateCheckoutSession()` | Create a checkout session |
|
|
93
93
|
| `useShippingOptions(cartSessionId)` | Fetch available shipping options |
|
|
94
94
|
| `useUpdateShippingSelections()` | Update selected shipping options |
|
|
95
|
+
| `useShippingRegions()` | Fetch available shipping countries and states |
|
|
95
96
|
|
|
96
97
|
### Payment Hooks
|
|
97
98
|
|
|
@@ -334,6 +335,8 @@ import type {
|
|
|
334
335
|
ShippingSelectionDto,
|
|
335
336
|
CreateEmbeddedPaymentSessionDto,
|
|
336
337
|
EmbeddedPaymentSessionResponseDto,
|
|
338
|
+
ShippingRegionsResponseDto,
|
|
339
|
+
ShippingRegionDto,
|
|
337
340
|
} from '@eetech-commerce/cart-react';
|
|
338
341
|
```
|
|
339
342
|
|
package/dist/index.d.ts
CHANGED
|
@@ -394,6 +394,22 @@ type VerificationResultDto = {
|
|
|
394
394
|
*/
|
|
395
395
|
verifiedAt: string;
|
|
396
396
|
};
|
|
397
|
+
type ShippingRegionDto = {
|
|
398
|
+
/**
|
|
399
|
+
* ISO country code
|
|
400
|
+
*/
|
|
401
|
+
countryCode: string;
|
|
402
|
+
/**
|
|
403
|
+
* Available state/province codes. Empty array means all states are valid.
|
|
404
|
+
*/
|
|
405
|
+
states: Array<string>;
|
|
406
|
+
};
|
|
407
|
+
type ShippingRegionsResponseDto = {
|
|
408
|
+
/**
|
|
409
|
+
* Available shipping regions grouped by country
|
|
410
|
+
*/
|
|
411
|
+
shippingRegions: Array<ShippingRegionDto>;
|
|
412
|
+
};
|
|
397
413
|
type AddressDto = {
|
|
398
414
|
/**
|
|
399
415
|
* Name of the recipient
|
|
@@ -662,6 +678,30 @@ type EmbeddedPaymentSessionResponseDto = {
|
|
|
662
678
|
*/
|
|
663
679
|
currency: string;
|
|
664
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
|
+
};
|
|
665
705
|
|
|
666
706
|
interface MutationCallbacks<TData = unknown, TError = Error> {
|
|
667
707
|
onSuccess?: (data: TData) => void;
|
|
@@ -897,7 +937,332 @@ declare function useUpdateCheckoutSession(): {
|
|
|
897
937
|
isPending: boolean;
|
|
898
938
|
error: Error | null;
|
|
899
939
|
};
|
|
900
|
-
declare function useShippingOptions(cartSessionId: string | null):
|
|
940
|
+
declare function useShippingOptions(cartSessionId: string | null): {
|
|
941
|
+
error: Error;
|
|
942
|
+
isError: true;
|
|
943
|
+
isPending: false;
|
|
944
|
+
isLoading: false;
|
|
945
|
+
isLoadingError: false;
|
|
946
|
+
isRefetchError: true;
|
|
947
|
+
isSuccess: false;
|
|
948
|
+
isPlaceholderData: false;
|
|
949
|
+
status: "error";
|
|
950
|
+
dataUpdatedAt: number;
|
|
951
|
+
errorUpdatedAt: number;
|
|
952
|
+
failureCount: number;
|
|
953
|
+
failureReason: Error | null;
|
|
954
|
+
errorUpdateCount: number;
|
|
955
|
+
isFetched: boolean;
|
|
956
|
+
isFetchedAfterMount: boolean;
|
|
957
|
+
isFetching: boolean;
|
|
958
|
+
isInitialLoading: boolean;
|
|
959
|
+
isPaused: boolean;
|
|
960
|
+
isRefetching: boolean;
|
|
961
|
+
isStale: boolean;
|
|
962
|
+
isEnabled: boolean;
|
|
963
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<ShippingOptionsResponse, Error>>;
|
|
964
|
+
fetchStatus: _tanstack_query_core.FetchStatus;
|
|
965
|
+
promise: Promise<ShippingOptionsResponse>;
|
|
966
|
+
shippingOptions: ShippingOptionsResponse | undefined;
|
|
967
|
+
} | {
|
|
968
|
+
error: null;
|
|
969
|
+
isError: false;
|
|
970
|
+
isPending: false;
|
|
971
|
+
isLoading: false;
|
|
972
|
+
isLoadingError: false;
|
|
973
|
+
isRefetchError: false;
|
|
974
|
+
isSuccess: true;
|
|
975
|
+
isPlaceholderData: false;
|
|
976
|
+
status: "success";
|
|
977
|
+
dataUpdatedAt: number;
|
|
978
|
+
errorUpdatedAt: number;
|
|
979
|
+
failureCount: number;
|
|
980
|
+
failureReason: Error | null;
|
|
981
|
+
errorUpdateCount: number;
|
|
982
|
+
isFetched: boolean;
|
|
983
|
+
isFetchedAfterMount: boolean;
|
|
984
|
+
isFetching: boolean;
|
|
985
|
+
isInitialLoading: boolean;
|
|
986
|
+
isPaused: boolean;
|
|
987
|
+
isRefetching: boolean;
|
|
988
|
+
isStale: boolean;
|
|
989
|
+
isEnabled: boolean;
|
|
990
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<ShippingOptionsResponse, Error>>;
|
|
991
|
+
fetchStatus: _tanstack_query_core.FetchStatus;
|
|
992
|
+
promise: Promise<ShippingOptionsResponse>;
|
|
993
|
+
shippingOptions: ShippingOptionsResponse | undefined;
|
|
994
|
+
} | {
|
|
995
|
+
error: Error;
|
|
996
|
+
isError: true;
|
|
997
|
+
isPending: false;
|
|
998
|
+
isLoading: false;
|
|
999
|
+
isLoadingError: true;
|
|
1000
|
+
isRefetchError: false;
|
|
1001
|
+
isSuccess: false;
|
|
1002
|
+
isPlaceholderData: false;
|
|
1003
|
+
status: "error";
|
|
1004
|
+
dataUpdatedAt: number;
|
|
1005
|
+
errorUpdatedAt: number;
|
|
1006
|
+
failureCount: number;
|
|
1007
|
+
failureReason: Error | null;
|
|
1008
|
+
errorUpdateCount: number;
|
|
1009
|
+
isFetched: boolean;
|
|
1010
|
+
isFetchedAfterMount: boolean;
|
|
1011
|
+
isFetching: boolean;
|
|
1012
|
+
isInitialLoading: boolean;
|
|
1013
|
+
isPaused: boolean;
|
|
1014
|
+
isRefetching: boolean;
|
|
1015
|
+
isStale: boolean;
|
|
1016
|
+
isEnabled: boolean;
|
|
1017
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<ShippingOptionsResponse, Error>>;
|
|
1018
|
+
fetchStatus: _tanstack_query_core.FetchStatus;
|
|
1019
|
+
promise: Promise<ShippingOptionsResponse>;
|
|
1020
|
+
shippingOptions: ShippingOptionsResponse | undefined;
|
|
1021
|
+
} | {
|
|
1022
|
+
error: null;
|
|
1023
|
+
isError: false;
|
|
1024
|
+
isPending: true;
|
|
1025
|
+
isLoading: true;
|
|
1026
|
+
isLoadingError: false;
|
|
1027
|
+
isRefetchError: false;
|
|
1028
|
+
isSuccess: false;
|
|
1029
|
+
isPlaceholderData: false;
|
|
1030
|
+
status: "pending";
|
|
1031
|
+
dataUpdatedAt: number;
|
|
1032
|
+
errorUpdatedAt: number;
|
|
1033
|
+
failureCount: number;
|
|
1034
|
+
failureReason: Error | null;
|
|
1035
|
+
errorUpdateCount: number;
|
|
1036
|
+
isFetched: boolean;
|
|
1037
|
+
isFetchedAfterMount: boolean;
|
|
1038
|
+
isFetching: boolean;
|
|
1039
|
+
isInitialLoading: boolean;
|
|
1040
|
+
isPaused: boolean;
|
|
1041
|
+
isRefetching: boolean;
|
|
1042
|
+
isStale: boolean;
|
|
1043
|
+
isEnabled: boolean;
|
|
1044
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<ShippingOptionsResponse, Error>>;
|
|
1045
|
+
fetchStatus: _tanstack_query_core.FetchStatus;
|
|
1046
|
+
promise: Promise<ShippingOptionsResponse>;
|
|
1047
|
+
shippingOptions: ShippingOptionsResponse | undefined;
|
|
1048
|
+
} | {
|
|
1049
|
+
error: null;
|
|
1050
|
+
isError: false;
|
|
1051
|
+
isPending: true;
|
|
1052
|
+
isLoadingError: false;
|
|
1053
|
+
isRefetchError: false;
|
|
1054
|
+
isSuccess: false;
|
|
1055
|
+
isPlaceholderData: false;
|
|
1056
|
+
status: "pending";
|
|
1057
|
+
dataUpdatedAt: number;
|
|
1058
|
+
errorUpdatedAt: number;
|
|
1059
|
+
failureCount: number;
|
|
1060
|
+
failureReason: Error | null;
|
|
1061
|
+
errorUpdateCount: number;
|
|
1062
|
+
isFetched: boolean;
|
|
1063
|
+
isFetchedAfterMount: boolean;
|
|
1064
|
+
isFetching: boolean;
|
|
1065
|
+
isLoading: boolean;
|
|
1066
|
+
isInitialLoading: boolean;
|
|
1067
|
+
isPaused: boolean;
|
|
1068
|
+
isRefetching: boolean;
|
|
1069
|
+
isStale: boolean;
|
|
1070
|
+
isEnabled: boolean;
|
|
1071
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<ShippingOptionsResponse, Error>>;
|
|
1072
|
+
fetchStatus: _tanstack_query_core.FetchStatus;
|
|
1073
|
+
promise: Promise<ShippingOptionsResponse>;
|
|
1074
|
+
shippingOptions: ShippingOptionsResponse | undefined;
|
|
1075
|
+
} | {
|
|
1076
|
+
isError: false;
|
|
1077
|
+
error: null;
|
|
1078
|
+
isPending: false;
|
|
1079
|
+
isLoading: false;
|
|
1080
|
+
isLoadingError: false;
|
|
1081
|
+
isRefetchError: false;
|
|
1082
|
+
isSuccess: true;
|
|
1083
|
+
isPlaceholderData: true;
|
|
1084
|
+
status: "success";
|
|
1085
|
+
dataUpdatedAt: number;
|
|
1086
|
+
errorUpdatedAt: number;
|
|
1087
|
+
failureCount: number;
|
|
1088
|
+
failureReason: Error | null;
|
|
1089
|
+
errorUpdateCount: number;
|
|
1090
|
+
isFetched: boolean;
|
|
1091
|
+
isFetchedAfterMount: boolean;
|
|
1092
|
+
isFetching: boolean;
|
|
1093
|
+
isInitialLoading: boolean;
|
|
1094
|
+
isPaused: boolean;
|
|
1095
|
+
isRefetching: boolean;
|
|
1096
|
+
isStale: boolean;
|
|
1097
|
+
isEnabled: boolean;
|
|
1098
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<ShippingOptionsResponse, Error>>;
|
|
1099
|
+
fetchStatus: _tanstack_query_core.FetchStatus;
|
|
1100
|
+
promise: Promise<ShippingOptionsResponse>;
|
|
1101
|
+
shippingOptions: ShippingOptionsResponse | undefined;
|
|
1102
|
+
};
|
|
1103
|
+
declare function useShippingRegions(): {
|
|
1104
|
+
error: Error;
|
|
1105
|
+
isError: true;
|
|
1106
|
+
isPending: false;
|
|
1107
|
+
isLoading: false;
|
|
1108
|
+
isLoadingError: false;
|
|
1109
|
+
isRefetchError: true;
|
|
1110
|
+
isSuccess: false;
|
|
1111
|
+
isPlaceholderData: false;
|
|
1112
|
+
status: "error";
|
|
1113
|
+
dataUpdatedAt: number;
|
|
1114
|
+
errorUpdatedAt: number;
|
|
1115
|
+
failureCount: number;
|
|
1116
|
+
failureReason: Error | null;
|
|
1117
|
+
errorUpdateCount: number;
|
|
1118
|
+
isFetched: boolean;
|
|
1119
|
+
isFetchedAfterMount: boolean;
|
|
1120
|
+
isFetching: boolean;
|
|
1121
|
+
isInitialLoading: boolean;
|
|
1122
|
+
isPaused: boolean;
|
|
1123
|
+
isRefetching: boolean;
|
|
1124
|
+
isStale: boolean;
|
|
1125
|
+
isEnabled: boolean;
|
|
1126
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<ShippingRegionsResponseDto, Error>>;
|
|
1127
|
+
fetchStatus: _tanstack_query_core.FetchStatus;
|
|
1128
|
+
promise: Promise<ShippingRegionsResponseDto>;
|
|
1129
|
+
shippingRegions: ShippingRegionsResponseDto | undefined;
|
|
1130
|
+
} | {
|
|
1131
|
+
error: null;
|
|
1132
|
+
isError: false;
|
|
1133
|
+
isPending: false;
|
|
1134
|
+
isLoading: false;
|
|
1135
|
+
isLoadingError: false;
|
|
1136
|
+
isRefetchError: false;
|
|
1137
|
+
isSuccess: true;
|
|
1138
|
+
isPlaceholderData: false;
|
|
1139
|
+
status: "success";
|
|
1140
|
+
dataUpdatedAt: number;
|
|
1141
|
+
errorUpdatedAt: number;
|
|
1142
|
+
failureCount: number;
|
|
1143
|
+
failureReason: Error | null;
|
|
1144
|
+
errorUpdateCount: number;
|
|
1145
|
+
isFetched: boolean;
|
|
1146
|
+
isFetchedAfterMount: boolean;
|
|
1147
|
+
isFetching: boolean;
|
|
1148
|
+
isInitialLoading: boolean;
|
|
1149
|
+
isPaused: boolean;
|
|
1150
|
+
isRefetching: boolean;
|
|
1151
|
+
isStale: boolean;
|
|
1152
|
+
isEnabled: boolean;
|
|
1153
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<ShippingRegionsResponseDto, Error>>;
|
|
1154
|
+
fetchStatus: _tanstack_query_core.FetchStatus;
|
|
1155
|
+
promise: Promise<ShippingRegionsResponseDto>;
|
|
1156
|
+
shippingRegions: ShippingRegionsResponseDto | undefined;
|
|
1157
|
+
} | {
|
|
1158
|
+
error: Error;
|
|
1159
|
+
isError: true;
|
|
1160
|
+
isPending: false;
|
|
1161
|
+
isLoading: false;
|
|
1162
|
+
isLoadingError: true;
|
|
1163
|
+
isRefetchError: false;
|
|
1164
|
+
isSuccess: false;
|
|
1165
|
+
isPlaceholderData: false;
|
|
1166
|
+
status: "error";
|
|
1167
|
+
dataUpdatedAt: number;
|
|
1168
|
+
errorUpdatedAt: number;
|
|
1169
|
+
failureCount: number;
|
|
1170
|
+
failureReason: Error | null;
|
|
1171
|
+
errorUpdateCount: number;
|
|
1172
|
+
isFetched: boolean;
|
|
1173
|
+
isFetchedAfterMount: boolean;
|
|
1174
|
+
isFetching: boolean;
|
|
1175
|
+
isInitialLoading: boolean;
|
|
1176
|
+
isPaused: boolean;
|
|
1177
|
+
isRefetching: boolean;
|
|
1178
|
+
isStale: boolean;
|
|
1179
|
+
isEnabled: boolean;
|
|
1180
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<ShippingRegionsResponseDto, Error>>;
|
|
1181
|
+
fetchStatus: _tanstack_query_core.FetchStatus;
|
|
1182
|
+
promise: Promise<ShippingRegionsResponseDto>;
|
|
1183
|
+
shippingRegions: ShippingRegionsResponseDto | undefined;
|
|
1184
|
+
} | {
|
|
1185
|
+
error: null;
|
|
1186
|
+
isError: false;
|
|
1187
|
+
isPending: true;
|
|
1188
|
+
isLoading: true;
|
|
1189
|
+
isLoadingError: false;
|
|
1190
|
+
isRefetchError: false;
|
|
1191
|
+
isSuccess: false;
|
|
1192
|
+
isPlaceholderData: false;
|
|
1193
|
+
status: "pending";
|
|
1194
|
+
dataUpdatedAt: number;
|
|
1195
|
+
errorUpdatedAt: number;
|
|
1196
|
+
failureCount: number;
|
|
1197
|
+
failureReason: Error | null;
|
|
1198
|
+
errorUpdateCount: number;
|
|
1199
|
+
isFetched: boolean;
|
|
1200
|
+
isFetchedAfterMount: boolean;
|
|
1201
|
+
isFetching: boolean;
|
|
1202
|
+
isInitialLoading: boolean;
|
|
1203
|
+
isPaused: boolean;
|
|
1204
|
+
isRefetching: boolean;
|
|
1205
|
+
isStale: boolean;
|
|
1206
|
+
isEnabled: boolean;
|
|
1207
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<ShippingRegionsResponseDto, Error>>;
|
|
1208
|
+
fetchStatus: _tanstack_query_core.FetchStatus;
|
|
1209
|
+
promise: Promise<ShippingRegionsResponseDto>;
|
|
1210
|
+
shippingRegions: ShippingRegionsResponseDto | undefined;
|
|
1211
|
+
} | {
|
|
1212
|
+
error: null;
|
|
1213
|
+
isError: false;
|
|
1214
|
+
isPending: true;
|
|
1215
|
+
isLoadingError: false;
|
|
1216
|
+
isRefetchError: false;
|
|
1217
|
+
isSuccess: false;
|
|
1218
|
+
isPlaceholderData: false;
|
|
1219
|
+
status: "pending";
|
|
1220
|
+
dataUpdatedAt: number;
|
|
1221
|
+
errorUpdatedAt: number;
|
|
1222
|
+
failureCount: number;
|
|
1223
|
+
failureReason: Error | null;
|
|
1224
|
+
errorUpdateCount: number;
|
|
1225
|
+
isFetched: boolean;
|
|
1226
|
+
isFetchedAfterMount: boolean;
|
|
1227
|
+
isFetching: boolean;
|
|
1228
|
+
isLoading: boolean;
|
|
1229
|
+
isInitialLoading: boolean;
|
|
1230
|
+
isPaused: boolean;
|
|
1231
|
+
isRefetching: boolean;
|
|
1232
|
+
isStale: boolean;
|
|
1233
|
+
isEnabled: boolean;
|
|
1234
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<ShippingRegionsResponseDto, Error>>;
|
|
1235
|
+
fetchStatus: _tanstack_query_core.FetchStatus;
|
|
1236
|
+
promise: Promise<ShippingRegionsResponseDto>;
|
|
1237
|
+
shippingRegions: ShippingRegionsResponseDto | undefined;
|
|
1238
|
+
} | {
|
|
1239
|
+
isError: false;
|
|
1240
|
+
error: null;
|
|
1241
|
+
isPending: false;
|
|
1242
|
+
isLoading: false;
|
|
1243
|
+
isLoadingError: false;
|
|
1244
|
+
isRefetchError: false;
|
|
1245
|
+
isSuccess: true;
|
|
1246
|
+
isPlaceholderData: true;
|
|
1247
|
+
status: "success";
|
|
1248
|
+
dataUpdatedAt: number;
|
|
1249
|
+
errorUpdatedAt: number;
|
|
1250
|
+
failureCount: number;
|
|
1251
|
+
failureReason: Error | null;
|
|
1252
|
+
errorUpdateCount: number;
|
|
1253
|
+
isFetched: boolean;
|
|
1254
|
+
isFetchedAfterMount: boolean;
|
|
1255
|
+
isFetching: boolean;
|
|
1256
|
+
isInitialLoading: boolean;
|
|
1257
|
+
isPaused: boolean;
|
|
1258
|
+
isRefetching: boolean;
|
|
1259
|
+
isStale: boolean;
|
|
1260
|
+
isEnabled: boolean;
|
|
1261
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<ShippingRegionsResponseDto, Error>>;
|
|
1262
|
+
fetchStatus: _tanstack_query_core.FetchStatus;
|
|
1263
|
+
promise: Promise<ShippingRegionsResponseDto>;
|
|
1264
|
+
shippingRegions: ShippingRegionsResponseDto | undefined;
|
|
1265
|
+
};
|
|
901
1266
|
interface UpdateShippingSelectionsParams {
|
|
902
1267
|
selections: ShippingSelectionDto[];
|
|
903
1268
|
}
|
|
@@ -923,6 +1288,12 @@ declare function useCreateEmbeddedCheckoutSession(): {
|
|
|
923
1288
|
error: Error | null;
|
|
924
1289
|
data: EmbeddedPaymentSessionResponseDto | undefined;
|
|
925
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
|
+
};
|
|
926
1297
|
declare function usePaymentSession(sessionId: string | null): _tanstack_react_query.UseQueryResult<PaymentSessionResponseDto, Error>;
|
|
927
1298
|
|
|
928
1299
|
declare const cartKeys: {
|
|
@@ -952,4 +1323,4 @@ interface CartProviderProps {
|
|
|
952
1323
|
}
|
|
953
1324
|
declare function CartProvider({ children, tenantSlug, cartApiUrl, storageAdapter, autoInitialize, queryClient, }: CartProviderProps): react_jsx_runtime.JSX.Element;
|
|
954
1325
|
|
|
955
|
-
export { type CartContextValue, CartProvider, type CartProviderProps, type CartResponseDto, type CreateCheckoutDto, type CreateEmbeddedPaymentSessionDto, type EmbeddedPaymentSessionResponseDto, type LineItemResponseDto, type LoadStripeFn, type MutationCallbacks, type ShippingOptionDto, type ShippingSelectionDto, type StorageAdapter, type UpdateCheckoutDto, type VerificationResultDto, cartKeys, localStorageAdapter, paymentKeys, shippingKeys, useAddToCart, useCart, useCartContext, useClearCart, useCreateCart, useCreateCheckoutSession, useCreateEmbeddedCheckoutSession, useInitializeCart, usePaymentSession, useRemoveItem, useShippingOptions, 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
|
@@ -917,6 +917,12 @@ var checkoutControllerVerifyCartV1 = (options) => {
|
|
|
917
917
|
}
|
|
918
918
|
});
|
|
919
919
|
};
|
|
920
|
+
var checkoutControllerGetShippingRegionsV1 = (options) => {
|
|
921
|
+
return (options.client ?? client).get({
|
|
922
|
+
url: "/v1/t/{tenantSlug}/checkout/shipping-regions",
|
|
923
|
+
...options
|
|
924
|
+
});
|
|
925
|
+
};
|
|
920
926
|
var checkoutControllerUpdateCheckoutSessionV1 = (options) => {
|
|
921
927
|
return (options.client ?? client).patch({
|
|
922
928
|
url: "/v1/t/{tenantSlug}/checkout/{cartSessionId}",
|
|
@@ -969,6 +975,16 @@ var paymentControllerCreateEmbeddedPaymentSessionV1 = (options) => {
|
|
|
969
975
|
}
|
|
970
976
|
});
|
|
971
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
|
+
};
|
|
972
988
|
var paymentControllerGetPaymentSessionV1 = (options) => {
|
|
973
989
|
return (options.client ?? client).get({
|
|
974
990
|
url: "/v1/t/{tenantSlug}/payments/sessions/{id}",
|
|
@@ -1092,6 +1108,19 @@ var checkoutControllerVerifyCartV1Mutation = (options) => {
|
|
|
1092
1108
|
};
|
|
1093
1109
|
return mutationOptions;
|
|
1094
1110
|
};
|
|
1111
|
+
var checkoutControllerGetShippingRegionsV1QueryKey = (options) => createQueryKey("checkoutControllerGetShippingRegionsV1", options);
|
|
1112
|
+
var checkoutControllerGetShippingRegionsV1Options = (options) => queryOptions({
|
|
1113
|
+
queryFn: async ({ queryKey, signal }) => {
|
|
1114
|
+
const { data } = await checkoutControllerGetShippingRegionsV1({
|
|
1115
|
+
...options,
|
|
1116
|
+
...queryKey[0],
|
|
1117
|
+
signal,
|
|
1118
|
+
throwOnError: true
|
|
1119
|
+
});
|
|
1120
|
+
return data;
|
|
1121
|
+
},
|
|
1122
|
+
queryKey: checkoutControllerGetShippingRegionsV1QueryKey(options)
|
|
1123
|
+
});
|
|
1095
1124
|
var checkoutControllerUpdateCheckoutSessionV1Mutation = (options) => {
|
|
1096
1125
|
const mutationOptions = {
|
|
1097
1126
|
mutationFn: async (fnOptions) => {
|
|
@@ -1170,6 +1199,19 @@ var paymentControllerCreateEmbeddedPaymentSessionV1Mutation = (options) => {
|
|
|
1170
1199
|
};
|
|
1171
1200
|
return mutationOptions;
|
|
1172
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
|
+
};
|
|
1173
1215
|
var paymentControllerGetPaymentSessionV1QueryKey = (options) => createQueryKey("paymentControllerGetPaymentSessionV1", options);
|
|
1174
1216
|
var paymentControllerGetPaymentSessionV1Options = (options) => queryOptions({
|
|
1175
1217
|
queryFn: async ({ queryKey, signal }) => {
|
|
@@ -1523,7 +1565,7 @@ function useUpdateCheckoutSession() {
|
|
|
1523
1565
|
}
|
|
1524
1566
|
function useShippingOptions(cartSessionId) {
|
|
1525
1567
|
const { tenantSlug, cartApiUrl } = useCartContext();
|
|
1526
|
-
|
|
1568
|
+
const { data, ...rest } = useQuery2({
|
|
1527
1569
|
...checkoutControllerGetShippingOptionsV1Options({
|
|
1528
1570
|
path: {
|
|
1529
1571
|
tenantSlug,
|
|
@@ -1533,6 +1575,17 @@ function useShippingOptions(cartSessionId) {
|
|
|
1533
1575
|
}),
|
|
1534
1576
|
enabled: !!cartSessionId
|
|
1535
1577
|
});
|
|
1578
|
+
return { shippingOptions: data, ...rest };
|
|
1579
|
+
}
|
|
1580
|
+
function useShippingRegions() {
|
|
1581
|
+
const { tenantSlug, cartApiUrl } = useCartContext();
|
|
1582
|
+
const { data, ...rest } = useQuery2({
|
|
1583
|
+
...checkoutControllerGetShippingRegionsV1Options({
|
|
1584
|
+
path: { tenantSlug },
|
|
1585
|
+
baseUrl: cartApiUrl
|
|
1586
|
+
})
|
|
1587
|
+
});
|
|
1588
|
+
return { shippingRegions: data, ...rest };
|
|
1536
1589
|
}
|
|
1537
1590
|
function useUpdateShippingSelections() {
|
|
1538
1591
|
const { tenantSlug, cartApiUrl, cartSessionId } = useCartContext();
|
|
@@ -1610,6 +1663,31 @@ function useCreateEmbeddedCheckoutSession() {
|
|
|
1610
1663
|
data: mutation.data
|
|
1611
1664
|
};
|
|
1612
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
|
+
}
|
|
1613
1691
|
function usePaymentSession(sessionId) {
|
|
1614
1692
|
const { tenantSlug, cartApiUrl } = useCartContext();
|
|
1615
1693
|
return useQuery3({
|
|
@@ -1729,10 +1807,12 @@ export {
|
|
|
1729
1807
|
useCreateCart,
|
|
1730
1808
|
useCreateCheckoutSession,
|
|
1731
1809
|
useCreateEmbeddedCheckoutSession,
|
|
1810
|
+
useCreatePaymentIntent,
|
|
1732
1811
|
useInitializeCart,
|
|
1733
1812
|
usePaymentSession,
|
|
1734
1813
|
useRemoveItem,
|
|
1735
1814
|
useShippingOptions,
|
|
1815
|
+
useShippingRegions,
|
|
1736
1816
|
useStripePromise,
|
|
1737
1817
|
useUpdateCheckoutSession,
|
|
1738
1818
|
useUpdateItemQty,
|