@getopenpay/openpay-js-react 0.0.2-alpha.9971440 → 0.0.2
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 +8 -62
- package/package.json +1 -1
- package/dist/index.d.ts +0 -103
- package/dist/index.js +0 -3145
package/README.md
CHANGED
|
@@ -1,68 +1,14 @@
|
|
|
1
1
|
# openpay-js-react
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
React components for OpenPay.JS
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
npm install @getopenpay/openpay-js-react
|
|
7
|
-
```
|
|
5
|
+
## Development
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
1. Install dependencies using `make install`
|
|
8
|
+
2. Run `make dev` to start Vite in watch mode
|
|
9
|
+
3. In another terminal, `cd` into the `example` directory and run `make dev` to start the example app
|
|
10
|
+
4. Open [http://localhost:3032](http://localhost:3032) to see the example app
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
pnpm add @getopenpay/openpay-js-react
|
|
15
|
-
```
|
|
12
|
+
When you make changes to the library, Vite will automatically recompile it and NextJS will automatically reload the page.
|
|
16
13
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
See example usage here ([example usages](https://dash.readme.com/go/getopenpay?redirect=%2Fv1.0%2Fdocs%2Fexamples))
|
|
20
|
-
|
|
21
|
-
## Concepts
|
|
22
|
-
|
|
23
|
-
### Elements
|
|
24
|
-
|
|
25
|
-
Elements are the embeds of secure web pages hosted on our servers. Elements must be used within the provider,`<ElementsForm />`, which provides context required by the elements.
|
|
26
|
-
|
|
27
|
-
`<ElementsForm />` needs `checkoutSecureToken` which can be generated by creating a checkout session via OpenPay Python SDK. [Create Checkout Session](ref:create_checkout_session)
|
|
28
|
-
|
|
29
|
-
The library provides separate card elements (Card number, expiry, CVV) and a combination these elements in a single line input field.
|
|
30
|
-
|
|
31
|
-
- `<CardNumberElement />`
|
|
32
|
-
- `<CardExpiryElement />`
|
|
33
|
-
- `<CardCvcElement />`
|
|
34
|
-
- `<CardElement />` (Combined)
|
|
35
|
-
|
|
36
|
-
### Billing information
|
|
37
|
-
|
|
38
|
-
Customer billing information is required to proceed checkout. You can implement the input fields for billing information in your own way. Since you're in control of these fields, you can perform custom validations, custom styling and auto-fill with user account information.
|
|
39
|
-
For OpenPay to access the input fields, please include `data-opid` attribute with predefined field names which can be accessed via `FieldName`.
|
|
40
|
-
|
|
41
|
-
Available field names:
|
|
42
|
-
|
|
43
|
-
- `FieldName.FIRST_NAME`
|
|
44
|
-
- `FieldName.LAST_NAME`
|
|
45
|
-
- `FieldName.EMAIL`
|
|
46
|
-
- `FieldName.ZIP_CODE`
|
|
47
|
-
- `FieldName.CITY`
|
|
48
|
-
- `FieldName.STATE`
|
|
49
|
-
- `FieldName.COUNTRY`
|
|
50
|
-
- `FieldName.ADDRESS`
|
|
51
|
-
- `FieldName.PHONE`
|
|
52
|
-
|
|
53
|
-
### Styling
|
|
54
|
-
|
|
55
|
-
By default, the elements provided are "Unstyled". They will have transparent background and text color adaptive to system's color scheme. You can wrap an element inside a container to which you can apply customized styling ([Examples](doc:examples)).
|
|
56
|
-
|
|
57
|
-
If you want to customize the styling of the element itself you can apply via the optional `styles` prop. The following are supported properties. These support any valid CSS values.
|
|
58
|
-
|
|
59
|
-
- `backgroundColor`
|
|
60
|
-
- `color`
|
|
61
|
-
- `fontFamily`
|
|
62
|
-
- `fontSize`
|
|
63
|
-
- `fontWeight`
|
|
64
|
-
- `margin`
|
|
65
|
-
- `padding`
|
|
66
|
-
What’s Next
|
|
67
|
-
Tell your users what they should do after they've finished this page
|
|
68
|
-
Examples
|
|
14
|
+
If NextJS doesn't reload, you can try manually refreshing the page, or reinstalling the library using `npm install ../` in the `example` directory.
|
package/package.json
CHANGED
package/dist/index.d.ts
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
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
|
-
export declare const CardCvcElement: FC<ElementProps>;
|
|
9
|
-
|
|
10
|
-
export declare const CardElement: FC<ElementProps>;
|
|
11
|
-
|
|
12
|
-
export declare const CardExpiryElement: FC<ElementProps>;
|
|
13
|
-
|
|
14
|
-
export declare const CardNumberElement: FC<ElementProps>;
|
|
15
|
-
|
|
16
|
-
export declare type ElementProps = {
|
|
17
|
-
styles?: ElementsStyle;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
declare type ElementsContextValue = {
|
|
21
|
-
formId: string;
|
|
22
|
-
formHeight: string;
|
|
23
|
-
referer?: string;
|
|
24
|
-
checkoutSecureToken?: string;
|
|
25
|
-
registerIframe: (iframe: HTMLIFrameElement) => void;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export declare const ElementsForm: FC<ElementsFormProps>;
|
|
29
|
-
|
|
30
|
-
declare type ElementsFormChildrenProps = {
|
|
31
|
-
submit: () => void;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export declare type ElementsFormProps = {
|
|
35
|
-
className?: string;
|
|
36
|
-
checkoutSecureToken?: string;
|
|
37
|
-
children: (props: ElementsFormChildrenProps) => JSX.Element;
|
|
38
|
-
onFocus?: (elementId: string) => void;
|
|
39
|
-
onBlur?: (elementId: string) => void;
|
|
40
|
-
onChange?: (elementId: string) => void;
|
|
41
|
-
onLoad?: (totalAmountAtoms: number, currency?: string) => void;
|
|
42
|
-
onLoadError?: (message: string) => void;
|
|
43
|
-
onValidationError?: (field: AllFieldNames, errors: string[], elementId?: string) => void;
|
|
44
|
-
onCheckoutStarted?: () => void;
|
|
45
|
-
onCheckoutSuccess?: (invoiceUrls: string[]) => void;
|
|
46
|
-
onCheckoutError?: (message: string) => void;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Styles
|
|
51
|
-
*/
|
|
52
|
-
declare const ElementsStyle: z.ZodObject<{
|
|
53
|
-
backgroundColor: z.ZodOptional<z.ZodString>;
|
|
54
|
-
color: z.ZodOptional<z.ZodString>;
|
|
55
|
-
fontFamily: z.ZodOptional<z.ZodString>;
|
|
56
|
-
fontSize: z.ZodOptional<z.ZodString>;
|
|
57
|
-
fontWeight: z.ZodOptional<z.ZodString>;
|
|
58
|
-
margin: z.ZodOptional<z.ZodString>;
|
|
59
|
-
padding: z.ZodOptional<z.ZodString>;
|
|
60
|
-
}, "strip", z.ZodTypeAny, {
|
|
61
|
-
backgroundColor?: string | undefined;
|
|
62
|
-
color?: string | undefined;
|
|
63
|
-
fontFamily?: string | undefined;
|
|
64
|
-
fontSize?: string | undefined;
|
|
65
|
-
fontWeight?: string | undefined;
|
|
66
|
-
margin?: string | undefined;
|
|
67
|
-
padding?: string | undefined;
|
|
68
|
-
}, {
|
|
69
|
-
backgroundColor?: string | undefined;
|
|
70
|
-
color?: string | undefined;
|
|
71
|
-
fontFamily?: string | undefined;
|
|
72
|
-
fontSize?: string | undefined;
|
|
73
|
-
fontWeight?: string | undefined;
|
|
74
|
-
margin?: string | undefined;
|
|
75
|
-
padding?: string | undefined;
|
|
76
|
-
}>;
|
|
77
|
-
|
|
78
|
-
declare type ElementsStyle = z.infer<typeof ElementsStyle>;
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Expected input fields
|
|
82
|
-
*/
|
|
83
|
-
export declare enum FieldName {
|
|
84
|
-
FIRST_NAME = "firstName",
|
|
85
|
-
LAST_NAME = "lastName",
|
|
86
|
-
EMAIL = "email",
|
|
87
|
-
ZIP_CODE = "zipCode",
|
|
88
|
-
CITY = "city",
|
|
89
|
-
STATE = "state",
|
|
90
|
-
COUNTRY = "country",
|
|
91
|
-
ADDRESS = "address",
|
|
92
|
-
PHONE = "phone"
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
declare enum PrivateFieldName {
|
|
96
|
-
CARD_NUMBER = "cardNumber",
|
|
97
|
-
CARD_EXPIRY = "cardExpiry",
|
|
98
|
-
CARD_CVC = "cardCvc"
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export declare const useOpenPayElements: () => ElementsContextValue;
|
|
102
|
-
|
|
103
|
-
export { }
|