@getopenpay/openpay-js 0.1.1-alpha.1 → 0.1.1-alpha.3
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 +161 -7
- package/dist/index.es.js +2937 -4590
- package/dist/index.umd.js +55 -17
- package/package.json +6 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,52 @@
|
|
|
1
|
-
import { CdeConnection } from '@getopenpay/utils';
|
|
2
|
-
import { CheckoutPaymentMethod } from '@getopenpay/utils';
|
|
3
|
-
import { ElementProps } from '@getopenpay/utils';
|
|
4
|
-
import { ElementsFormProps } from '@getopenpay/utils';
|
|
5
|
-
import { FieldName } from '@getopenpay/utils';
|
|
6
1
|
import { PaymentRequestPaymentMethodEvent } from '@stripe/stripe-js';
|
|
7
|
-
import {
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
declare const AllFieldNames: z.ZodUnion<[z.ZodNativeEnum<typeof FieldName>, z.ZodNativeEnum<typeof PrivateFieldName>]>;
|
|
5
|
+
|
|
6
|
+
declare type AllFieldNames = z.infer<typeof AllFieldNames>;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Payment requests
|
|
10
|
+
*/
|
|
11
|
+
declare const Amount: z.ZodObject<{
|
|
12
|
+
amountAtom: z.ZodNumber;
|
|
13
|
+
currency: z.ZodString;
|
|
14
|
+
}, "strip", z.ZodTypeAny, {
|
|
15
|
+
currency: string;
|
|
16
|
+
amountAtom: number;
|
|
17
|
+
}, {
|
|
18
|
+
currency: string;
|
|
19
|
+
amountAtom: number;
|
|
20
|
+
}>;
|
|
21
|
+
|
|
22
|
+
declare type Amount = z.infer<typeof Amount>;
|
|
23
|
+
|
|
24
|
+
declare type CdeConnection = {
|
|
25
|
+
send: (data: CdeMessage) => Promise<unknown>;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
declare type CdeMessage = {
|
|
29
|
+
type: string;
|
|
30
|
+
} & Record<string, unknown>;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Core models
|
|
34
|
+
*/
|
|
35
|
+
declare const CheckoutPaymentMethod: z.ZodObject<{
|
|
36
|
+
provider: z.ZodString;
|
|
37
|
+
processor_name: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
38
|
+
metadata: z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
39
|
+
}, "strip", z.ZodTypeAny, {
|
|
40
|
+
provider: string;
|
|
41
|
+
processor_name?: string | null | undefined;
|
|
42
|
+
metadata?: Record<string, any> | null | undefined;
|
|
43
|
+
}, {
|
|
44
|
+
provider: string;
|
|
45
|
+
processor_name?: string | null | undefined;
|
|
46
|
+
metadata?: Record<string, any> | null | undefined;
|
|
47
|
+
}>;
|
|
48
|
+
|
|
49
|
+
declare type CheckoutPaymentMethod = z.infer<typeof CheckoutPaymentMethod>;
|
|
8
50
|
|
|
9
51
|
export declare type Config = Omit<ElementsFormProps, 'children'> & {
|
|
10
52
|
formTarget?: string;
|
|
@@ -18,9 +60,105 @@ declare class ConnectionManager {
|
|
|
18
60
|
getConnection(): CdeConnection;
|
|
19
61
|
}
|
|
20
62
|
|
|
63
|
+
declare type ElementProps<PlaceholderType extends z.ZodTypeAny = z.ZodString> = {
|
|
64
|
+
styles?: ElementsStyle<z.ZodOptional<PlaceholderType>>;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
declare type ElementsFormChildrenProps = {
|
|
68
|
+
submit: () => void;
|
|
69
|
+
applePay: PaymentRequestStatus;
|
|
70
|
+
googlePay: PaymentRequestStatus;
|
|
71
|
+
loaded: boolean;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
declare type ElementsFormProps = {
|
|
75
|
+
className?: string;
|
|
76
|
+
checkoutSecureToken: string;
|
|
77
|
+
children: (props: ElementsFormChildrenProps) => JSX.Element;
|
|
78
|
+
onFocus?: (elementId: string) => void;
|
|
79
|
+
onBlur?: (elementId: string) => void;
|
|
80
|
+
onChange?: (elementId: string) => void;
|
|
81
|
+
onLoad?: (totalAmountAtoms?: number, currency?: string) => void;
|
|
82
|
+
onLoadError?: (message: string) => void;
|
|
83
|
+
onValidationError?: (field: AllFieldNames, errors: string[], elementId?: string) => void;
|
|
84
|
+
onCheckoutStarted?: () => void;
|
|
85
|
+
onCheckoutSuccess?: (invoiceUrls: string[], subscriptionIds: string[], customerId: string) => void;
|
|
86
|
+
onSetupPaymentMethodSuccess?: (paymentMethodId: string) => void;
|
|
87
|
+
onCheckoutError?: (message: string) => void;
|
|
88
|
+
baseUrl?: string;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
declare const ElementsStyle: <T extends z.ZodTypeAny>(placeholderType: T) => z.ZodObject<z.objectUtil.extendShape<{
|
|
92
|
+
backgroundColor: z.ZodOptional<z.ZodString>;
|
|
93
|
+
color: z.ZodOptional<z.ZodString>;
|
|
94
|
+
fontFamily: z.ZodOptional<z.ZodString>;
|
|
95
|
+
fontSize: z.ZodOptional<z.ZodString>;
|
|
96
|
+
fontWeight: z.ZodOptional<z.ZodString>;
|
|
97
|
+
margin: z.ZodOptional<z.ZodString>;
|
|
98
|
+
padding: z.ZodOptional<z.ZodString>;
|
|
99
|
+
}, {
|
|
100
|
+
placeholder: T;
|
|
101
|
+
}>, "strip", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<z.objectUtil.extendShape<{
|
|
102
|
+
backgroundColor: z.ZodOptional<z.ZodString>;
|
|
103
|
+
color: z.ZodOptional<z.ZodString>;
|
|
104
|
+
fontFamily: z.ZodOptional<z.ZodString>;
|
|
105
|
+
fontSize: z.ZodOptional<z.ZodString>;
|
|
106
|
+
fontWeight: z.ZodOptional<z.ZodString>;
|
|
107
|
+
margin: z.ZodOptional<z.ZodString>;
|
|
108
|
+
padding: z.ZodOptional<z.ZodString>;
|
|
109
|
+
}, {
|
|
110
|
+
placeholder: T;
|
|
111
|
+
}>>, any> extends infer T_1 ? { [k in keyof T_1]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<z.objectUtil.extendShape<{
|
|
112
|
+
backgroundColor: z.ZodOptional<z.ZodString>;
|
|
113
|
+
color: z.ZodOptional<z.ZodString>;
|
|
114
|
+
fontFamily: z.ZodOptional<z.ZodString>;
|
|
115
|
+
fontSize: z.ZodOptional<z.ZodString>;
|
|
116
|
+
fontWeight: z.ZodOptional<z.ZodString>;
|
|
117
|
+
margin: z.ZodOptional<z.ZodString>;
|
|
118
|
+
padding: z.ZodOptional<z.ZodString>;
|
|
119
|
+
}, {
|
|
120
|
+
placeholder: T;
|
|
121
|
+
}>>, any>[k]; } : never, z.baseObjectInputType<z.objectUtil.extendShape<{
|
|
122
|
+
backgroundColor: z.ZodOptional<z.ZodString>;
|
|
123
|
+
color: z.ZodOptional<z.ZodString>;
|
|
124
|
+
fontFamily: z.ZodOptional<z.ZodString>;
|
|
125
|
+
fontSize: z.ZodOptional<z.ZodString>;
|
|
126
|
+
fontWeight: z.ZodOptional<z.ZodString>;
|
|
127
|
+
margin: z.ZodOptional<z.ZodString>;
|
|
128
|
+
padding: z.ZodOptional<z.ZodString>;
|
|
129
|
+
}, {
|
|
130
|
+
placeholder: T;
|
|
131
|
+
}>> extends infer T_2 ? { [k_1 in keyof T_2]: z.baseObjectInputType<z.objectUtil.extendShape<{
|
|
132
|
+
backgroundColor: z.ZodOptional<z.ZodString>;
|
|
133
|
+
color: z.ZodOptional<z.ZodString>;
|
|
134
|
+
fontFamily: z.ZodOptional<z.ZodString>;
|
|
135
|
+
fontSize: z.ZodOptional<z.ZodString>;
|
|
136
|
+
fontWeight: z.ZodOptional<z.ZodString>;
|
|
137
|
+
margin: z.ZodOptional<z.ZodString>;
|
|
138
|
+
padding: z.ZodOptional<z.ZodString>;
|
|
139
|
+
}, {
|
|
140
|
+
placeholder: T;
|
|
141
|
+
}>>[k_1]; } : never>;
|
|
142
|
+
|
|
143
|
+
declare type ElementsStyle<T extends z.ZodTypeAny> = z.infer<ReturnType<typeof ElementsStyle<T>>>;
|
|
144
|
+
|
|
21
145
|
export declare type ElementType = 'card' | 'card-number' | 'card-expiry' | 'card-cvc';
|
|
22
146
|
|
|
23
|
-
|
|
147
|
+
/**
|
|
148
|
+
* Expected input fields
|
|
149
|
+
*/
|
|
150
|
+
export declare enum FieldName {
|
|
151
|
+
FIRST_NAME = "firstName",
|
|
152
|
+
LAST_NAME = "lastName",
|
|
153
|
+
EMAIL = "email",
|
|
154
|
+
ZIP_CODE = "zipCode",
|
|
155
|
+
CITY = "city",
|
|
156
|
+
STATE = "state",
|
|
157
|
+
COUNTRY = "country",
|
|
158
|
+
ADDRESS = "address",
|
|
159
|
+
PHONE = "phone",
|
|
160
|
+
PROMOTION_CODE = "promotionCode"
|
|
161
|
+
}
|
|
24
162
|
|
|
25
163
|
export declare class OpenPayForm {
|
|
26
164
|
config: Config;
|
|
@@ -55,4 +193,20 @@ export declare class OpenPayForm {
|
|
|
55
193
|
destroy(): void;
|
|
56
194
|
}
|
|
57
195
|
|
|
196
|
+
declare type PaymentRequestStartParams = {
|
|
197
|
+
amountToDisplayForSetupMode?: Amount;
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
declare type PaymentRequestStatus = {
|
|
201
|
+
isLoading: boolean;
|
|
202
|
+
isAvailable: boolean;
|
|
203
|
+
startFlow: (params?: PaymentRequestStartParams) => Promise<void>;
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
declare enum PrivateFieldName {
|
|
207
|
+
CARD_NUMBER = "cardNumber",
|
|
208
|
+
CARD_EXPIRY = "cardExpiry",
|
|
209
|
+
CARD_CVC = "cardCvc"
|
|
210
|
+
}
|
|
211
|
+
|
|
58
212
|
export { }
|