@getopenpay/openpay-js 0.1.4 → 0.1.6-alpha.720e7c5
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 +238 -224
- package/dist/index.es.js +1478 -3667
- package/dist/index.umd.js +18 -81
- package/package.json +6 -18
package/dist/index.d.ts
CHANGED
|
@@ -1,23 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PaymentRequest as PaymentRequest_2 } from '@stripe/stripe-js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
|
|
4
|
-
declare const AllFieldNames
|
|
4
|
+
declare const AllFieldNames = z.union([FieldNameEnum, PrivateFieldNameEnum]);
|
|
5
5
|
|
|
6
6
|
declare type AllFieldNames = z.infer<typeof AllFieldNames>;
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Payment requests
|
|
10
10
|
*/
|
|
11
|
-
declare const Amount
|
|
12
|
-
amountAtom: z.
|
|
13
|
-
currency:
|
|
14
|
-
}
|
|
15
|
-
currency: string;
|
|
16
|
-
amountAtom: number;
|
|
17
|
-
}, {
|
|
18
|
-
currency: string;
|
|
19
|
-
amountAtom: number;
|
|
20
|
-
}>;
|
|
11
|
+
declare const Amount = z.object({
|
|
12
|
+
amountAtom: z.number(),
|
|
13
|
+
currency: RequiredString,
|
|
14
|
+
});
|
|
21
15
|
|
|
22
16
|
declare type Amount = z.infer<typeof Amount>;
|
|
23
17
|
|
|
@@ -32,19 +26,11 @@ declare type CdeMessage = {
|
|
|
32
26
|
/**
|
|
33
27
|
* Core models
|
|
34
28
|
*/
|
|
35
|
-
declare const CheckoutPaymentMethod
|
|
36
|
-
provider: z.
|
|
37
|
-
processor_name: z.
|
|
38
|
-
metadata: z.
|
|
39
|
-
}
|
|
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
|
-
}>;
|
|
29
|
+
declare const CheckoutPaymentMethod = z.object({
|
|
30
|
+
provider: z.string(),
|
|
31
|
+
processor_name: nullOrUndefOr(z.string()),
|
|
32
|
+
metadata: nullOrUndefOr(z.record(z.string(), z.any())),
|
|
33
|
+
});
|
|
48
34
|
|
|
49
35
|
declare type CheckoutPaymentMethod = z.infer<typeof CheckoutPaymentMethod>;
|
|
50
36
|
|
|
@@ -55,8 +41,9 @@ export declare type Config = ElementsFormProps & {
|
|
|
55
41
|
declare class ConnectionManager {
|
|
56
42
|
private connections;
|
|
57
43
|
constructor();
|
|
58
|
-
addConnection(id:
|
|
44
|
+
addConnection(id: ElementType, connection: CdeConnection): void;
|
|
59
45
|
getConnection(): CdeConnection;
|
|
46
|
+
getAllConnections(): Map<ElementType, CdeConnection>;
|
|
60
47
|
}
|
|
61
48
|
|
|
62
49
|
declare type ElementProps<PlaceholderType extends z.ZodTypeAny = z.ZodString> = {
|
|
@@ -78,234 +65,263 @@ export declare type ElementsFormProps = {
|
|
|
78
65
|
onCheckoutError?: (message: string) => void;
|
|
79
66
|
baseUrl?: string;
|
|
80
67
|
formTarget?: string;
|
|
81
|
-
onPaymentRequestLoad?: (paymentRequests: Record<
|
|
68
|
+
onPaymentRequestLoad?: (paymentRequests: Record<PaymentRequestProvider, PaymentRequestStatus>) => void;
|
|
82
69
|
};
|
|
83
70
|
|
|
84
|
-
declare const ElementsStyle
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
fontSize: z.ZodOptional<z.ZodString>;
|
|
99
|
-
fontWeight: z.ZodOptional<z.ZodString>;
|
|
100
|
-
fontFamily: z.ZodOptional<z.ZodString>;
|
|
101
|
-
letterSpacing: z.ZodOptional<z.ZodString>;
|
|
102
|
-
lineHeight: z.ZodOptional<z.ZodString>;
|
|
103
|
-
}, "strip", z.ZodTypeAny, {
|
|
104
|
-
color?: string | undefined;
|
|
105
|
-
fontFamily?: string | undefined;
|
|
106
|
-
fontSize?: string | undefined;
|
|
107
|
-
fontWeight?: string | undefined;
|
|
108
|
-
letterSpacing?: string | undefined;
|
|
109
|
-
lineHeight?: string | undefined;
|
|
110
|
-
}, {
|
|
111
|
-
color?: string | undefined;
|
|
112
|
-
fontFamily?: string | undefined;
|
|
113
|
-
fontSize?: string | undefined;
|
|
114
|
-
fontWeight?: string | undefined;
|
|
115
|
-
letterSpacing?: string | undefined;
|
|
116
|
-
lineHeight?: string | undefined;
|
|
117
|
-
}>>;
|
|
118
|
-
}>, "strip", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<z.objectUtil.extendShape<{
|
|
119
|
-
backgroundColor: z.ZodOptional<z.ZodString>;
|
|
120
|
-
color: z.ZodOptional<z.ZodString>;
|
|
121
|
-
fontFamily: z.ZodOptional<z.ZodString>;
|
|
122
|
-
fontSize: z.ZodOptional<z.ZodString>;
|
|
123
|
-
fontWeight: z.ZodOptional<z.ZodString>;
|
|
124
|
-
margin: z.ZodOptional<z.ZodString>;
|
|
125
|
-
padding: z.ZodOptional<z.ZodString>;
|
|
126
|
-
letterSpacing: z.ZodOptional<z.ZodString>;
|
|
127
|
-
lineHeight: z.ZodOptional<z.ZodString>;
|
|
128
|
-
}, {
|
|
129
|
-
placeholder: T;
|
|
130
|
-
placeholderStyle: z.ZodOptional<z.ZodObject<{
|
|
131
|
-
color: z.ZodOptional<z.ZodString>;
|
|
132
|
-
fontSize: z.ZodOptional<z.ZodString>;
|
|
133
|
-
fontWeight: z.ZodOptional<z.ZodString>;
|
|
134
|
-
fontFamily: z.ZodOptional<z.ZodString>;
|
|
135
|
-
letterSpacing: z.ZodOptional<z.ZodString>;
|
|
136
|
-
lineHeight: z.ZodOptional<z.ZodString>;
|
|
137
|
-
}, "strip", z.ZodTypeAny, {
|
|
138
|
-
color?: string | undefined;
|
|
139
|
-
fontFamily?: string | undefined;
|
|
140
|
-
fontSize?: string | undefined;
|
|
141
|
-
fontWeight?: string | undefined;
|
|
142
|
-
letterSpacing?: string | undefined;
|
|
143
|
-
lineHeight?: string | undefined;
|
|
144
|
-
}, {
|
|
145
|
-
color?: string | undefined;
|
|
146
|
-
fontFamily?: string | undefined;
|
|
147
|
-
fontSize?: string | undefined;
|
|
148
|
-
fontWeight?: string | undefined;
|
|
149
|
-
letterSpacing?: string | undefined;
|
|
150
|
-
lineHeight?: string | undefined;
|
|
151
|
-
}>>;
|
|
152
|
-
}>>, any> extends infer T_1 ? { [k in keyof T_1]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<z.objectUtil.extendShape<{
|
|
153
|
-
backgroundColor: z.ZodOptional<z.ZodString>;
|
|
154
|
-
color: z.ZodOptional<z.ZodString>;
|
|
155
|
-
fontFamily: z.ZodOptional<z.ZodString>;
|
|
156
|
-
fontSize: z.ZodOptional<z.ZodString>;
|
|
157
|
-
fontWeight: z.ZodOptional<z.ZodString>;
|
|
158
|
-
margin: z.ZodOptional<z.ZodString>;
|
|
159
|
-
padding: z.ZodOptional<z.ZodString>;
|
|
160
|
-
letterSpacing: z.ZodOptional<z.ZodString>;
|
|
161
|
-
lineHeight: z.ZodOptional<z.ZodString>;
|
|
162
|
-
}, {
|
|
163
|
-
placeholder: T;
|
|
164
|
-
placeholderStyle: z.ZodOptional<z.ZodObject<{
|
|
165
|
-
color: z.ZodOptional<z.ZodString>;
|
|
166
|
-
fontSize: z.ZodOptional<z.ZodString>;
|
|
167
|
-
fontWeight: z.ZodOptional<z.ZodString>;
|
|
168
|
-
fontFamily: z.ZodOptional<z.ZodString>;
|
|
169
|
-
letterSpacing: z.ZodOptional<z.ZodString>;
|
|
170
|
-
lineHeight: z.ZodOptional<z.ZodString>;
|
|
171
|
-
}, "strip", z.ZodTypeAny, {
|
|
172
|
-
color?: string | undefined;
|
|
173
|
-
fontFamily?: string | undefined;
|
|
174
|
-
fontSize?: string | undefined;
|
|
175
|
-
fontWeight?: string | undefined;
|
|
176
|
-
letterSpacing?: string | undefined;
|
|
177
|
-
lineHeight?: string | undefined;
|
|
178
|
-
}, {
|
|
179
|
-
color?: string | undefined;
|
|
180
|
-
fontFamily?: string | undefined;
|
|
181
|
-
fontSize?: string | undefined;
|
|
182
|
-
fontWeight?: string | undefined;
|
|
183
|
-
letterSpacing?: string | undefined;
|
|
184
|
-
lineHeight?: string | undefined;
|
|
185
|
-
}>>;
|
|
186
|
-
}>>, any>[k]; } : never, z.baseObjectInputType<z.objectUtil.extendShape<{
|
|
187
|
-
backgroundColor: z.ZodOptional<z.ZodString>;
|
|
188
|
-
color: z.ZodOptional<z.ZodString>;
|
|
189
|
-
fontFamily: z.ZodOptional<z.ZodString>;
|
|
190
|
-
fontSize: z.ZodOptional<z.ZodString>;
|
|
191
|
-
fontWeight: z.ZodOptional<z.ZodString>;
|
|
192
|
-
margin: z.ZodOptional<z.ZodString>;
|
|
193
|
-
padding: z.ZodOptional<z.ZodString>;
|
|
194
|
-
letterSpacing: z.ZodOptional<z.ZodString>;
|
|
195
|
-
lineHeight: z.ZodOptional<z.ZodString>;
|
|
196
|
-
}, {
|
|
197
|
-
placeholder: T;
|
|
198
|
-
placeholderStyle: z.ZodOptional<z.ZodObject<{
|
|
199
|
-
color: z.ZodOptional<z.ZodString>;
|
|
200
|
-
fontSize: z.ZodOptional<z.ZodString>;
|
|
201
|
-
fontWeight: z.ZodOptional<z.ZodString>;
|
|
202
|
-
fontFamily: z.ZodOptional<z.ZodString>;
|
|
203
|
-
letterSpacing: z.ZodOptional<z.ZodString>;
|
|
204
|
-
lineHeight: z.ZodOptional<z.ZodString>;
|
|
205
|
-
}, "strip", z.ZodTypeAny, {
|
|
206
|
-
color?: string | undefined;
|
|
207
|
-
fontFamily?: string | undefined;
|
|
208
|
-
fontSize?: string | undefined;
|
|
209
|
-
fontWeight?: string | undefined;
|
|
210
|
-
letterSpacing?: string | undefined;
|
|
211
|
-
lineHeight?: string | undefined;
|
|
212
|
-
}, {
|
|
213
|
-
color?: string | undefined;
|
|
214
|
-
fontFamily?: string | undefined;
|
|
215
|
-
fontSize?: string | undefined;
|
|
216
|
-
fontWeight?: string | undefined;
|
|
217
|
-
letterSpacing?: string | undefined;
|
|
218
|
-
lineHeight?: string | undefined;
|
|
219
|
-
}>>;
|
|
220
|
-
}>> extends infer T_2 ? { [k_1 in keyof T_2]: z.baseObjectInputType<z.objectUtil.extendShape<{
|
|
221
|
-
backgroundColor: z.ZodOptional<z.ZodString>;
|
|
222
|
-
color: z.ZodOptional<z.ZodString>;
|
|
223
|
-
fontFamily: z.ZodOptional<z.ZodString>;
|
|
224
|
-
fontSize: z.ZodOptional<z.ZodString>;
|
|
225
|
-
fontWeight: z.ZodOptional<z.ZodString>;
|
|
226
|
-
margin: z.ZodOptional<z.ZodString>;
|
|
227
|
-
padding: z.ZodOptional<z.ZodString>;
|
|
228
|
-
letterSpacing: z.ZodOptional<z.ZodString>;
|
|
229
|
-
lineHeight: z.ZodOptional<z.ZodString>;
|
|
230
|
-
}, {
|
|
231
|
-
placeholder: T;
|
|
232
|
-
placeholderStyle: z.ZodOptional<z.ZodObject<{
|
|
233
|
-
color: z.ZodOptional<z.ZodString>;
|
|
234
|
-
fontSize: z.ZodOptional<z.ZodString>;
|
|
235
|
-
fontWeight: z.ZodOptional<z.ZodString>;
|
|
236
|
-
fontFamily: z.ZodOptional<z.ZodString>;
|
|
237
|
-
letterSpacing: z.ZodOptional<z.ZodString>;
|
|
238
|
-
lineHeight: z.ZodOptional<z.ZodString>;
|
|
239
|
-
}, "strip", z.ZodTypeAny, {
|
|
240
|
-
color?: string | undefined;
|
|
241
|
-
fontFamily?: string | undefined;
|
|
242
|
-
fontSize?: string | undefined;
|
|
243
|
-
fontWeight?: string | undefined;
|
|
244
|
-
letterSpacing?: string | undefined;
|
|
245
|
-
lineHeight?: string | undefined;
|
|
246
|
-
}, {
|
|
247
|
-
color?: string | undefined;
|
|
248
|
-
fontFamily?: string | undefined;
|
|
249
|
-
fontSize?: string | undefined;
|
|
250
|
-
fontWeight?: string | undefined;
|
|
251
|
-
letterSpacing?: string | undefined;
|
|
252
|
-
lineHeight?: string | undefined;
|
|
253
|
-
}>>;
|
|
254
|
-
}>>[k_1]; } : never>;
|
|
71
|
+
declare const ElementsStyle = <T extends z.ZodTypeAny>(placeholderType: T) =>
|
|
72
|
+
BaseElementsStyle.extend({
|
|
73
|
+
placeholder: placeholderType,
|
|
74
|
+
placeholderStyle: z
|
|
75
|
+
.object({
|
|
76
|
+
color: OptionalString,
|
|
77
|
+
fontSize: OptionalString,
|
|
78
|
+
fontWeight: OptionalString,
|
|
79
|
+
fontFamily: OptionalString,
|
|
80
|
+
letterSpacing: OptionalString,
|
|
81
|
+
lineHeight: OptionalString,
|
|
82
|
+
})
|
|
83
|
+
.optional(),
|
|
84
|
+
});
|
|
255
85
|
|
|
256
86
|
declare type ElementsStyle<T extends z.ZodTypeAny> = z.infer<ReturnType<typeof ElementsStyle<T>>>;
|
|
257
87
|
|
|
258
|
-
|
|
88
|
+
declare const ElementType = z.nativeEnum(ElementTypeEnum);
|
|
89
|
+
|
|
90
|
+
declare type ElementType = z.infer<typeof ElementType>;
|
|
91
|
+
|
|
92
|
+
declare enum ElementTypeEnum {
|
|
93
|
+
CARD = 'card',
|
|
94
|
+
CARD_NUMBER = 'card-number',
|
|
95
|
+
CARD_EXPIRY = 'card-expiry',
|
|
96
|
+
CARD_CVC = 'card-cvc',
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
declare type ElementTypeEnumValue = ElementTypeEnum[keyof ElementTypeEnum];
|
|
259
100
|
|
|
260
101
|
/**
|
|
261
102
|
* Expected input fields
|
|
262
103
|
*/
|
|
104
|
+
|
|
105
|
+
// Supplied by the user
|
|
263
106
|
export declare enum FieldName {
|
|
264
|
-
FIRST_NAME =
|
|
265
|
-
LAST_NAME =
|
|
266
|
-
EMAIL =
|
|
267
|
-
ZIP_CODE =
|
|
268
|
-
CITY =
|
|
269
|
-
STATE =
|
|
270
|
-
COUNTRY =
|
|
271
|
-
ADDRESS =
|
|
272
|
-
PHONE =
|
|
273
|
-
PROMOTION_CODE =
|
|
107
|
+
FIRST_NAME = 'firstName',
|
|
108
|
+
LAST_NAME = 'lastName',
|
|
109
|
+
EMAIL = 'email',
|
|
110
|
+
ZIP_CODE = 'zipCode',
|
|
111
|
+
CITY = 'city',
|
|
112
|
+
STATE = 'state',
|
|
113
|
+
COUNTRY = 'country',
|
|
114
|
+
ADDRESS = 'address',
|
|
115
|
+
PHONE = 'phone',
|
|
116
|
+
PROMOTION_CODE = 'promotionCode',
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
declare type InitOjsFlow<T extends InitOjsFlowResult> = (params: InitOjsFlowParams) => Promise<T>;
|
|
120
|
+
|
|
121
|
+
declare type InitOjsFlowParams = {
|
|
122
|
+
/**
|
|
123
|
+
* Contains the context where OJS is run.
|
|
124
|
+
* Ideally this only contains "background" context (OJS-level objects), and not flow-level objects.
|
|
125
|
+
*/
|
|
126
|
+
context: OjsContext;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
declare type InitOjsFlowResult = {
|
|
130
|
+
isAvailable: boolean;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
declare type InitStripePrFlowResult =
|
|
134
|
+
| InitStripePrFlowSuccess
|
|
135
|
+
| {
|
|
136
|
+
isAvailable: false;
|
|
137
|
+
reason: string;
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
declare type InitStripePrFlowSuccess = {
|
|
141
|
+
isAvailable: true;
|
|
142
|
+
// Passed to RunFlow
|
|
143
|
+
pr: PaymentRequest_2;
|
|
144
|
+
// Passed to the user
|
|
145
|
+
availableProviders: {
|
|
146
|
+
applePay: boolean;
|
|
147
|
+
googlePay: boolean;
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
declare type Loadable<T> =
|
|
152
|
+
| {
|
|
153
|
+
status: 'loading';
|
|
154
|
+
}
|
|
155
|
+
| {
|
|
156
|
+
status: 'loaded';
|
|
157
|
+
result: T;
|
|
274
158
|
}
|
|
159
|
+
| {
|
|
160
|
+
status: 'error';
|
|
161
|
+
message: string;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
declare const LoadedEventPayload = z.object({
|
|
165
|
+
type: z.literal(EventType.enum.LOADED),
|
|
166
|
+
sessionId: RequiredString,
|
|
167
|
+
totalAmountAtoms: z.number(),
|
|
168
|
+
currency: OptionalString,
|
|
169
|
+
checkoutPaymentMethods: z.array(CheckoutPaymentMethod),
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
declare type LoadedEventPayload = z.infer<typeof LoadedEventPayload>;
|
|
173
|
+
|
|
174
|
+
declare type OjsContext = {
|
|
175
|
+
/**
|
|
176
|
+
* The form element for the OJS form (non-CDE form).
|
|
177
|
+
*/
|
|
178
|
+
formDiv: HTMLElement;
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* The elements/partial session ID.
|
|
182
|
+
*/
|
|
183
|
+
elementsSessionId: string;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* All the checkout payment methods available in the session.
|
|
187
|
+
*/
|
|
188
|
+
checkoutPaymentMethods: CheckoutPaymentMethod[];
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* All the CDE connection objects (one for each CDE iframe).
|
|
192
|
+
*/
|
|
193
|
+
cdeConnections: Map<ElementType, CdeConnection>;
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* The base URL of the CDE iframe.
|
|
197
|
+
*/
|
|
198
|
+
baseUrl: string;
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
declare type OjsFlow<T_PARAMS = unknown, T_INIT_RESULT extends InitOjsFlowResult = InitOjsFlowResult> = {
|
|
202
|
+
init?: InitOjsFlow<T_INIT_RESULT>;
|
|
203
|
+
run: RunOjsFlow<T_PARAMS, T_INIT_RESULT>;
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
declare type OjsFlowCallbacks = {
|
|
207
|
+
onCheckoutError: OnCheckoutError;
|
|
208
|
+
onCheckoutStarted: OnCheckoutStarted;
|
|
209
|
+
onCheckoutSuccess: OnCheckoutSuccess;
|
|
210
|
+
onSetupPaymentMethodSuccess: OnSetupPaymentMethodSuccess;
|
|
211
|
+
onValidationError: OnValidationError;
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
declare type OjsFlowParams<T_PARAMS = void, T_INIT_RESULT = void> = {
|
|
215
|
+
/**
|
|
216
|
+
* Contains the context where OJS is run.
|
|
217
|
+
* Ideally this only contains "background" context (OJS-level objects), and not flow-level objects.
|
|
218
|
+
*/
|
|
219
|
+
context: OjsContext;
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* The checkout payment method object to be used for the flow.
|
|
223
|
+
*/
|
|
224
|
+
checkoutPaymentMethod: CheckoutPaymentMethod;
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Inputs from non-CDE fields (i.e. those which are part of the OJS form, but not the sensitive CDE form).
|
|
228
|
+
*/
|
|
229
|
+
nonCdeFormInputs: Record<string, unknown>;
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Lifecycle callbacks for OJS flows.
|
|
233
|
+
*/
|
|
234
|
+
flowCallbacks: OjsFlowCallbacks;
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Custom parameters for the flow.
|
|
238
|
+
*/
|
|
239
|
+
customParams: T_PARAMS;
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* The result of the InitOjsFlow function.
|
|
243
|
+
*/
|
|
244
|
+
initResult: T_INIT_RESULT;
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
declare const OjsFlows = {
|
|
248
|
+
// ✋ Note: For flows that require initialization, please add them to `init-flows.ts`
|
|
249
|
+
|
|
250
|
+
// Stripe
|
|
251
|
+
commonCC: {
|
|
252
|
+
run: runCommonCcFlow,
|
|
253
|
+
},
|
|
254
|
+
stripePR: {
|
|
255
|
+
init: initStripePrFlow,
|
|
256
|
+
run: runStripePrFlow,
|
|
257
|
+
},
|
|
258
|
+
|
|
259
|
+
// 👉 Add more flows here
|
|
260
|
+
|
|
261
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
262
|
+
} satisfies Record<string, OjsFlow<any, any>>;
|
|
263
|
+
|
|
264
|
+
declare type OnCheckoutError = (message: string) => void;
|
|
265
|
+
|
|
266
|
+
declare type OnCheckoutStarted = () => void;
|
|
267
|
+
|
|
268
|
+
declare type OnCheckoutSuccess = (invoiceUrls: string[], subscriptionIds: string[], customerId: string) => void;
|
|
269
|
+
|
|
270
|
+
declare type OnSetupPaymentMethodSuccess = (paymentMethodId: string) => void;
|
|
271
|
+
|
|
272
|
+
declare type OnValidationError = (field: AllFieldNames, errors: string[], elementId?: string) => void;
|
|
275
273
|
|
|
276
274
|
export declare class OpenPayForm {
|
|
277
275
|
config: Config;
|
|
278
276
|
formId: string;
|
|
279
|
-
sessionId: null | string;
|
|
280
|
-
checkoutPaymentMethods: Array<CheckoutPaymentMethod>;
|
|
281
277
|
formTarget: string;
|
|
282
278
|
checkoutFired: boolean;
|
|
279
|
+
ojsVersion: string;
|
|
283
280
|
private referer;
|
|
284
281
|
private eventHandler;
|
|
285
282
|
private formProperties;
|
|
286
283
|
private connectionManager;
|
|
287
|
-
private
|
|
288
|
-
private
|
|
284
|
+
private ojsFlowsInitialization;
|
|
285
|
+
private cdeLoadedPayload;
|
|
289
286
|
private elements;
|
|
287
|
+
static ojsFlows: typeof OjsFlows;
|
|
290
288
|
constructor(config: Config);
|
|
291
|
-
|
|
289
|
+
/**
|
|
290
|
+
* Assign the instance to the window as a singleton
|
|
291
|
+
* @param form - The OpenPayForm instance
|
|
292
|
+
*/
|
|
293
|
+
static assignAsSingleton(form: OpenPayForm): void;
|
|
294
|
+
/**
|
|
295
|
+
* Get the singleton instance of OpenPayForm
|
|
296
|
+
* @returns The OpenPayForm instance
|
|
297
|
+
*/
|
|
298
|
+
static getInstance(): OpenPayForm | null;
|
|
292
299
|
getConnectionManager(): ConnectionManager;
|
|
293
300
|
setFormHeight(height: string): void;
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
301
|
+
tryInitOjsFlows: () => void;
|
|
302
|
+
onCdeLoaded: (payload: LoadedEventPayload) => void;
|
|
303
|
+
onStripePRStatusChange: (initStatus: Loadable<InitStripePrFlowResult>) => void;
|
|
304
|
+
createElement(elementValue: ElementTypeEnumValue, options?: ElementProps): {
|
|
305
|
+
type: ElementTypeEnum;
|
|
297
306
|
node: HTMLIFrameElement;
|
|
298
307
|
mount: (selector: string) => HTMLIFrameElement | undefined;
|
|
299
308
|
};
|
|
300
309
|
private buildQueryString;
|
|
301
310
|
private connectToElement;
|
|
311
|
+
private getFormDiv;
|
|
312
|
+
private createOjsFlowContext;
|
|
313
|
+
private getNonCdeFormInputs;
|
|
314
|
+
private createOjsFlowCallbacks;
|
|
302
315
|
submit(): void;
|
|
303
|
-
|
|
316
|
+
submitPaymentRequest: (provider: PaymentRequestProvider, initResult: InitStripePrFlowSuccess, params?: PaymentRequestStartParams) => Promise<void>;
|
|
304
317
|
onPaymentRequestError(errMsg: string): void;
|
|
305
|
-
private initializePaymentRequests;
|
|
306
318
|
destroy(): void;
|
|
307
319
|
}
|
|
308
320
|
|
|
321
|
+
declare const PaymentRequestProvider: z.ZodEnum<["apple_pay", "google_pay"]>;
|
|
322
|
+
|
|
323
|
+
declare type PaymentRequestProvider = z.infer<typeof PaymentRequestProvider>;
|
|
324
|
+
|
|
309
325
|
declare type PaymentRequestStartParams = {
|
|
310
326
|
overridePaymentRequest?: {
|
|
311
327
|
amount: Amount;
|
|
@@ -319,10 +335,8 @@ declare type PaymentRequestStatus = {
|
|
|
319
335
|
startFlow: (params?: PaymentRequestStartParams) => Promise<void>;
|
|
320
336
|
};
|
|
321
337
|
|
|
322
|
-
declare
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
CARD_CVC = "cardCvc"
|
|
326
|
-
}
|
|
338
|
+
declare type RunOjsFlow<T_PARAMS = undefined, T_INIT_RESULT = undefined> = (
|
|
339
|
+
params: OjsFlowParams<T_PARAMS, T_INIT_RESULT>
|
|
340
|
+
) => Promise<void>;
|
|
327
341
|
|
|
328
342
|
export { }
|