@clickaroo/checkout-ui 0.0.1-beta
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/CHANGELOG.md +43 -0
- package/LICENSE +21 -0
- package/README.md +39 -0
- package/dist/index.css +1192 -0
- package/dist/index.d.ts +274 -0
- package/dist/index.js +19375 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +19362 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +85 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { OnCheckoutInitCallback, OnPaymentInfoCompleteCallback, OnOrderSubmitCallback, OnOrderSuccessCallback } from '@/types/callback';
|
|
3
|
+
import { CartItem as CartItem$1 } from '@/types/cartItem';
|
|
4
|
+
import React, { ReactNode } from 'react';
|
|
5
|
+
import z from 'zod/v4';
|
|
6
|
+
import { CustomerInfo as CustomerInfo$1, DeliveryAddress as DeliveryAddress$2 } from '@/contexts/CheckoutContext';
|
|
7
|
+
import { OrderDetail as OrderDetail$1 } from '@/types/order';
|
|
8
|
+
|
|
9
|
+
interface CheckoutProps {
|
|
10
|
+
cart: CartItem$1[];
|
|
11
|
+
onCheckoutInit?: OnCheckoutInitCallback;
|
|
12
|
+
onPaymentInfoComplete?: OnPaymentInfoCompleteCallback;
|
|
13
|
+
onOrderSubmit?: OnOrderSubmitCallback;
|
|
14
|
+
onOrderSuccess?: OnOrderSuccessCallback;
|
|
15
|
+
googleApiKey?: string;
|
|
16
|
+
}
|
|
17
|
+
declare const CheckoutPage: (props: CheckoutProps) => react_jsx_runtime.JSX.Element;
|
|
18
|
+
|
|
19
|
+
declare const SubmitButton: React.FC;
|
|
20
|
+
|
|
21
|
+
interface CustomInfoProps {
|
|
22
|
+
showTitle?: boolean;
|
|
23
|
+
}
|
|
24
|
+
declare const CustomInfo: React.FC<CustomInfoProps>;
|
|
25
|
+
|
|
26
|
+
interface DeliveryAddressProps {
|
|
27
|
+
showTitle?: boolean;
|
|
28
|
+
}
|
|
29
|
+
declare const DeliveryAddress$1: React.FC<DeliveryAddressProps>;
|
|
30
|
+
|
|
31
|
+
interface PaymentMethodsProps {
|
|
32
|
+
showText?: boolean;
|
|
33
|
+
}
|
|
34
|
+
declare const PaymentMethods: React.FC<PaymentMethodsProps>;
|
|
35
|
+
|
|
36
|
+
declare const CustomerInfoSchema: z.ZodObject<{
|
|
37
|
+
firstName: z.ZodString;
|
|
38
|
+
lastName: z.ZodString;
|
|
39
|
+
email: z.ZodString;
|
|
40
|
+
phone: z.ZodString;
|
|
41
|
+
}, z.core.$strip>;
|
|
42
|
+
type CustomerInfo = z.infer<typeof CustomerInfoSchema>;
|
|
43
|
+
declare const AddressSchema: z.ZodObject<{
|
|
44
|
+
country: z.ZodString;
|
|
45
|
+
address: z.ZodString;
|
|
46
|
+
address2: z.ZodOptional<z.ZodString>;
|
|
47
|
+
city: z.ZodString;
|
|
48
|
+
state: z.ZodString;
|
|
49
|
+
zipCode: z.ZodString;
|
|
50
|
+
}, z.core.$strip>;
|
|
51
|
+
type DeliveryAddress = z.infer<typeof AddressSchema>;
|
|
52
|
+
interface CheckoutProviderProps {
|
|
53
|
+
children: ReactNode;
|
|
54
|
+
cart: CartItem$1[];
|
|
55
|
+
onCheckoutInit?: OnCheckoutInitCallback;
|
|
56
|
+
onPaymentInfoComplete?: OnPaymentInfoCompleteCallback;
|
|
57
|
+
onOrderSubmit?: OnOrderSubmitCallback;
|
|
58
|
+
onOrderSuccess?: OnOrderSuccessCallback;
|
|
59
|
+
googleApiKey?: string;
|
|
60
|
+
}
|
|
61
|
+
declare const CheckoutProvider: React.FC<CheckoutProviderProps>;
|
|
62
|
+
|
|
63
|
+
interface CartItem {
|
|
64
|
+
sku: string;
|
|
65
|
+
offerPricePoint: string;
|
|
66
|
+
[key: string]: unknown;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
interface UseCheckoutContextPublic {
|
|
70
|
+
isFormValid: () => boolean;
|
|
71
|
+
customerInfo: CustomerInfo$1;
|
|
72
|
+
deliveryAddress: DeliveryAddress$2;
|
|
73
|
+
isPaymentComplete: boolean;
|
|
74
|
+
cart: CartItem$1[];
|
|
75
|
+
updateCustomerInfo: (info: Partial<CustomerInfo$1>) => void;
|
|
76
|
+
updateDeliveryAddress: (address: Partial<DeliveryAddress$2>) => void;
|
|
77
|
+
}
|
|
78
|
+
declare const useCheckoutContextPublic: () => UseCheckoutContextPublic;
|
|
79
|
+
|
|
80
|
+
interface OrderSubmissionResult {
|
|
81
|
+
success: boolean;
|
|
82
|
+
message: string;
|
|
83
|
+
orderCode?: string;
|
|
84
|
+
tradeCode?: string;
|
|
85
|
+
}
|
|
86
|
+
declare const useOrderSubmission: () => {
|
|
87
|
+
isSubmitting: boolean;
|
|
88
|
+
submitOrder: () => Promise<OrderSubmissionResult>;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
interface UseOrderDetailReturn {
|
|
92
|
+
orderDetail: OrderDetail$1 | null;
|
|
93
|
+
loading: boolean;
|
|
94
|
+
error: string | null;
|
|
95
|
+
refetch: () => void;
|
|
96
|
+
}
|
|
97
|
+
declare const useOrderDetail: (orderCode: string | null) => UseOrderDetailReturn;
|
|
98
|
+
|
|
99
|
+
declare enum OrderPaymentStatus {
|
|
100
|
+
PENDING = "pending",
|
|
101
|
+
PAID = "paid",
|
|
102
|
+
PARTIALLY_PAID = "partially_paid",
|
|
103
|
+
FAILED = "failed"
|
|
104
|
+
}
|
|
105
|
+
interface OrderCustomerInfo {
|
|
106
|
+
name: string;
|
|
107
|
+
email: string;
|
|
108
|
+
phone: string;
|
|
109
|
+
}
|
|
110
|
+
interface OrderShippingAddress {
|
|
111
|
+
country: string;
|
|
112
|
+
state: string;
|
|
113
|
+
city: string;
|
|
114
|
+
address1: string;
|
|
115
|
+
address2?: string;
|
|
116
|
+
zip: string;
|
|
117
|
+
}
|
|
118
|
+
interface OrderPaymentData {
|
|
119
|
+
confirmation_token_id: string;
|
|
120
|
+
payment_method_types: string[];
|
|
121
|
+
}
|
|
122
|
+
interface OrderPayment {
|
|
123
|
+
type: 'stripe';
|
|
124
|
+
data: OrderPaymentData;
|
|
125
|
+
}
|
|
126
|
+
interface CreateOrderItem {
|
|
127
|
+
sku: string;
|
|
128
|
+
price_point_code: string;
|
|
129
|
+
}
|
|
130
|
+
interface OrderMetadata {
|
|
131
|
+
sku?: string;
|
|
132
|
+
[key: string]: unknown;
|
|
133
|
+
}
|
|
134
|
+
interface CreateOrderRequest {
|
|
135
|
+
clickaroo_token: string | null;
|
|
136
|
+
price_point_code?: string;
|
|
137
|
+
items?: CreateOrderItem[];
|
|
138
|
+
customer_info: OrderCustomerInfo;
|
|
139
|
+
shipping_address: OrderShippingAddress;
|
|
140
|
+
source_url: string;
|
|
141
|
+
remark: string;
|
|
142
|
+
metadata: OrderMetadata;
|
|
143
|
+
payment: OrderPayment;
|
|
144
|
+
}
|
|
145
|
+
interface CreateOrderResponse {
|
|
146
|
+
order_code: string;
|
|
147
|
+
payment_status: OrderPaymentStatus;
|
|
148
|
+
payment_result: Record<string, unknown>;
|
|
149
|
+
order_trade_code: string;
|
|
150
|
+
}
|
|
151
|
+
interface OrderApiError {
|
|
152
|
+
message: string;
|
|
153
|
+
code?: string;
|
|
154
|
+
details?: Record<string, unknown>;
|
|
155
|
+
}
|
|
156
|
+
declare enum OrderStatus {
|
|
157
|
+
PENDING = "pending",
|
|
158
|
+
CONFIRMED = "confirmed",
|
|
159
|
+
PROCESSING = "processing",
|
|
160
|
+
SHIPPED = "shipped",
|
|
161
|
+
DELIVERED = "delivered",
|
|
162
|
+
CANCELLED = "cancelled"
|
|
163
|
+
}
|
|
164
|
+
declare enum RefundStatus {
|
|
165
|
+
NO_REFUND = "no_refund",
|
|
166
|
+
PARTIAL_REFUND = "partial_refund",
|
|
167
|
+
FULL_REFUND = "full_refund"
|
|
168
|
+
}
|
|
169
|
+
declare enum FulfillmentStatus {
|
|
170
|
+
PENDING = "pending",
|
|
171
|
+
PROCESSING = "processing",
|
|
172
|
+
SHIPPED = "shipped",
|
|
173
|
+
DELIVERED = "delivered"
|
|
174
|
+
}
|
|
175
|
+
interface OrderCustomer {
|
|
176
|
+
customer_code: string;
|
|
177
|
+
name: string;
|
|
178
|
+
email: string;
|
|
179
|
+
phone: string;
|
|
180
|
+
}
|
|
181
|
+
interface OrderAddress {
|
|
182
|
+
zip: string;
|
|
183
|
+
city: string;
|
|
184
|
+
state: string;
|
|
185
|
+
country: string;
|
|
186
|
+
address1: string;
|
|
187
|
+
address2?: string;
|
|
188
|
+
}
|
|
189
|
+
interface OrderItem {
|
|
190
|
+
item_code: string;
|
|
191
|
+
name: string;
|
|
192
|
+
quantity: number;
|
|
193
|
+
price: string;
|
|
194
|
+
total: string;
|
|
195
|
+
}
|
|
196
|
+
interface OrderDetailMetadata {
|
|
197
|
+
sku?: string;
|
|
198
|
+
product_id?: string;
|
|
199
|
+
purchase_type?: string;
|
|
200
|
+
shipping_method?: string;
|
|
201
|
+
product_title?: string;
|
|
202
|
+
product_checkout_subtitle?: string;
|
|
203
|
+
product_image?: string;
|
|
204
|
+
original_price?: string;
|
|
205
|
+
current_price?: string;
|
|
206
|
+
[key: string]: unknown;
|
|
207
|
+
}
|
|
208
|
+
interface OrderDetail {
|
|
209
|
+
order_code: string;
|
|
210
|
+
customer: OrderCustomer;
|
|
211
|
+
billing_address: OrderAddress;
|
|
212
|
+
shipping_address: OrderAddress;
|
|
213
|
+
status: OrderStatus;
|
|
214
|
+
payment_status: OrderPaymentStatus;
|
|
215
|
+
refund_status: RefundStatus;
|
|
216
|
+
fulfillment_status: FulfillmentStatus;
|
|
217
|
+
remark: string;
|
|
218
|
+
total_amount: string;
|
|
219
|
+
currency: string;
|
|
220
|
+
items: OrderItem[];
|
|
221
|
+
metadata?: OrderDetailMetadata;
|
|
222
|
+
created_at: string;
|
|
223
|
+
updated_at: string;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
declare const createOrderWithToken: (orderData: Omit<CreateOrderRequest, "clickaroo_token">) => Promise<{
|
|
227
|
+
success: boolean;
|
|
228
|
+
data?: CreateOrderResponse;
|
|
229
|
+
error?: OrderApiError;
|
|
230
|
+
}>;
|
|
231
|
+
declare const getOrderDetail: (orderCode: string) => Promise<{
|
|
232
|
+
success: boolean;
|
|
233
|
+
data?: OrderDetail;
|
|
234
|
+
error?: OrderApiError;
|
|
235
|
+
}>;
|
|
236
|
+
|
|
237
|
+
interface ClickarooInfo {
|
|
238
|
+
offer_code: string;
|
|
239
|
+
type: "one_off" | "subscription_schedules";
|
|
240
|
+
payment: {
|
|
241
|
+
type: "stripe";
|
|
242
|
+
data: ClickarooPaymentStripe;
|
|
243
|
+
};
|
|
244
|
+
subscription_schedules?: {
|
|
245
|
+
phase: number;
|
|
246
|
+
price_in_cents: number;
|
|
247
|
+
currency: string;
|
|
248
|
+
quantity: number;
|
|
249
|
+
period: string;
|
|
250
|
+
}[];
|
|
251
|
+
one_off?: {
|
|
252
|
+
price_in_cents: number;
|
|
253
|
+
currency: string;
|
|
254
|
+
quantity: number;
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
interface ClickarooPaymentStripe {
|
|
258
|
+
publishable_key: string;
|
|
259
|
+
account_id: string;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
interface PricePointApiError {
|
|
263
|
+
message: string;
|
|
264
|
+
code?: string;
|
|
265
|
+
details?: unknown;
|
|
266
|
+
}
|
|
267
|
+
declare const getPricePointInfo: (offerPricePoints: string | string[]) => Promise<{
|
|
268
|
+
success: boolean;
|
|
269
|
+
data?: ClickarooInfo | Record<string, ClickarooInfo>;
|
|
270
|
+
error?: PricePointApiError;
|
|
271
|
+
}>;
|
|
272
|
+
|
|
273
|
+
export { SubmitButton as ButtonGroup, CheckoutPage, CheckoutProvider, CustomInfo as CustomerInfo, DeliveryAddress$1 as DeliveryAddress, PaymentMethods, createOrderWithToken as createOrder, getOrderDetail, getPricePointInfo, useCheckoutContextPublic as useCheckoutContext, useOrderDetail, useOrderSubmission };
|
|
274
|
+
export type { CartItem, CustomerInfo as CustomerInfoType, DeliveryAddress as DeliveryAddressType, UseCheckoutContextPublic as UseCheckoutContext };
|