@getopenpay/openpay-js-react 0.1.14 → 0.1.15-alpha.09caa9f

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 CHANGED
@@ -1,6 +1,20 @@
1
1
  import { FC } from 'react';
2
2
  import { z } from 'zod';
3
3
 
4
+ declare type AllCallbacks = {
5
+ onFocus?: (elementId: string, field: AllFieldNames) => void;
6
+ onBlur?: (elementId: string, field: AllFieldNames) => void;
7
+ onChange?: (elementId: string, field: AllFieldNames, errors?: string[]) => void;
8
+ onLoad?: (totalAmountAtoms?: number, currency?: string) => void;
9
+ onLoadError?: (message: string) => void;
10
+ onValidationError?: OnValidationError;
11
+ onCheckoutStarted?: OnCheckoutStarted;
12
+ onCheckoutSuccess?: OnCheckoutSuccess;
13
+ onSetupPaymentMethodSuccess?: OnSetupPaymentMethodSuccess;
14
+ onCheckoutError?: OnCheckoutError;
15
+ onPaymentRequestLoad?: (paymentRequests: PRStatuses) => void;
16
+ };
17
+
4
18
  declare const AllFieldNames = z.union([FieldNameEnum, PrivateFieldNameEnum]);
5
19
 
6
20
  declare type AllFieldNames = z.infer<typeof AllFieldNames>;
@@ -69,13 +83,13 @@ export declare type ElementProps<PlaceholderType extends z.ZodTypeAny = z.ZodStr
69
83
  declare type ElementsContextValue = {
70
84
  formId: string;
71
85
  formHeight: string;
72
- referer?: string;
86
+ referrer?: string;
73
87
  checkoutSecureToken?: string;
74
- registerIframe: (iframe: HTMLIFrameElement) => void;
88
+ registerIframe: (type: ElementTypeEnum, iframe: HTMLIFrameElement) => void;
75
89
  baseUrl: string;
76
90
  };
77
91
 
78
- export declare const ElementsForm: FC<ElementsFormProps>;
92
+ export declare const ElementsForm: FC<ElementsFormPropsReact>;
79
93
 
80
94
  export declare type ElementsFormChildrenProps = {
81
95
  submit: () => void;
@@ -105,6 +119,15 @@ export declare type ElementsFormProps = {
105
119
  customInitParams?: CustomInitParams;
106
120
  };
107
121
 
122
+ declare type ElementsFormPropsReact = {
123
+ className?: string;
124
+ checkoutSecureToken: string;
125
+ baseUrl?: string;
126
+ formTarget?: string;
127
+ customInitParams?: CustomInitParams;
128
+ children: (props: ElementsFormChildrenProps) => JSX.Element;
129
+ } & AllCallbacks;
130
+
108
131
  declare const ElementsStyle = <T extends z.ZodTypeAny>(placeholderType: T) =>
109
132
  BaseElementsStyle.extend({
110
133
  placeholder: placeholderType,
@@ -122,6 +145,13 @@ BaseElementsStyle.extend({
122
145
 
123
146
  declare type ElementsStyle<T extends z.ZodTypeAny> = z.infer<ReturnType<typeof ElementsStyle<T>>>;
124
147
 
148
+ declare enum ElementTypeEnum {
149
+ CARD = 'card',
150
+ CARD_NUMBER = 'card-number',
151
+ CARD_EXPIRY = 'card-expiry',
152
+ CARD_CVC = 'card-cvc',
153
+ }
154
+
125
155
  /**
126
156
  * Expected input fields
127
157
  */
@@ -140,6 +170,20 @@ export declare enum FieldName {
140
170
  PROMOTION_CODE = 'promotionCode',
141
171
  }
142
172
 
173
+ declare type OnCheckoutError = (message: string) => void;
174
+
175
+ declare type OnCheckoutStarted = () => void;
176
+
177
+ declare type OnCheckoutSuccess = (invoiceUrls: string[], subscriptionIds: string[], customerId: string) => void;
178
+
179
+ declare type OnSetupPaymentMethodSuccess = (paymentMethodId: string) => void;
180
+
181
+ declare type OnValidationError = (field: AllFieldNames, errors: string[], elementId?: string) => void;
182
+
183
+ declare const PaymentRequestProvider = z.enum(['apple_pay', 'google_pay']);
184
+
185
+ declare type PaymentRequestProvider = z.infer<typeof PaymentRequestProvider>;
186
+
143
187
  export declare type PaymentRequestStartParams = {
144
188
  overridePaymentRequest?: {
145
189
  amount: Amount;
@@ -153,6 +197,8 @@ export declare type PaymentRequestStatus = {
153
197
  startFlow: (params?: PaymentRequestStartParams) => Promise<void>;
154
198
  };
155
199
 
200
+ declare type PRStatuses = Record<PaymentRequestProvider, PaymentRequestStatus>;
201
+
156
202
  declare type StripeLinkController = {
157
203
  mountButton: () => void;
158
204
  dismountButton: () => void;