@finyxpay/react-ui 0.1.0 → 0.1.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 +78 -0
- package/package.json +4 -3
package/README.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# @finyxpay/react-ui
|
|
2
|
+
|
|
3
|
+
React components for the Finyx checkout UI. Wraps [`@finyxpay/ui`](https://www.npmjs.com/package/@finyxpay/ui). Payment methods render in the merchant page (not an iframe). Card PAN never touches merchant DOM — Adyen Web and Airwallex Elements own those fields.
|
|
4
|
+
|
|
5
|
+
Requires React 18+. `'use client'` is already applied for Next.js App Router.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @finyxpay/ui @finyxpay/react-ui
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { FinyxProvider, Checkout } from '@finyxpay/react-ui';
|
|
15
|
+
import '@finyxpay/react-ui/styles.css';
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Drop-in checkout
|
|
19
|
+
|
|
20
|
+
```tsx
|
|
21
|
+
<FinyxProvider apiKey="live.xxx" apiBase={optional}>
|
|
22
|
+
<Checkout
|
|
23
|
+
amount={25.5}
|
|
24
|
+
currency="SGD"
|
|
25
|
+
orderId="ord_123"
|
|
26
|
+
items={[{ productID: '1', productName: 'Mug', quantity: 1, price: 25.5 }]}
|
|
27
|
+
returnUrl={`${location.origin}/checkout/result`}
|
|
28
|
+
autoCapture
|
|
29
|
+
onSuccess={(result) => { /* navigate */ }}
|
|
30
|
+
onError={(err) => { /* show error */ }}
|
|
31
|
+
/>
|
|
32
|
+
</FinyxProvider>
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Custom composition
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
import {
|
|
39
|
+
FinyxProvider,
|
|
40
|
+
PaymentMethodList,
|
|
41
|
+
Card,
|
|
42
|
+
QRPay,
|
|
43
|
+
WalletPay,
|
|
44
|
+
Alipay,
|
|
45
|
+
RedirectPay,
|
|
46
|
+
PayNow,
|
|
47
|
+
WeChatPay,
|
|
48
|
+
ApplePay,
|
|
49
|
+
GooglePay,
|
|
50
|
+
AlipayCN,
|
|
51
|
+
AlipayHK,
|
|
52
|
+
} from '@finyxpay/react-ui';
|
|
53
|
+
import { resolveElementType } from '@finyxpay/ui';
|
|
54
|
+
import '@finyxpay/react-ui/styles.css';
|
|
55
|
+
|
|
56
|
+
<FinyxProvider apiKey="live.xxx">
|
|
57
|
+
<PaymentMethodList onSelect={setMethod} />
|
|
58
|
+
{resolveElementType(method?.type) === 'qr' && (
|
|
59
|
+
<QRPay {...payProps} paymentMethod={method} onSuccess={...} />
|
|
60
|
+
)}
|
|
61
|
+
{resolveElementType(method?.type) === 'alipay' && (
|
|
62
|
+
<Alipay {...payProps} paymentMethod={method} onSuccess={...} />
|
|
63
|
+
)}
|
|
64
|
+
|
|
65
|
+
{method?.type === 'paynow' && <PayNow {...payProps} paymentMethod={method} />}
|
|
66
|
+
{method?.type === 'alipaycn' && <AlipayCN {...payProps} paymentMethod={method} />}
|
|
67
|
+
</FinyxProvider>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Also exported: `Card`, `WalletPay`, `RedirectPay`, `PaymentResult`, `WeChatPay`, `ApplePay`, `GooglePay`, `AlipayHK`, plus `init`, `createElement`, `resolveApiBase`, and `resolveElementType` from `@finyxpay/ui`.
|
|
71
|
+
|
|
72
|
+
`useFinyx()` returns the initialized instance and must be used inside `FinyxProvider`.
|
|
73
|
+
|
|
74
|
+
Events: `onReady`, `onSelect` (list only), `onSuccess`, `onError`.
|
|
75
|
+
|
|
76
|
+
## License
|
|
77
|
+
|
|
78
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@finyxpay/react-ui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "React components for the Finyx checkout UI",
|
|
5
5
|
"author": "Finyx",
|
|
6
6
|
"license": "MIT",
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"module": "./dist/index.js",
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
11
11
|
"files": [
|
|
12
|
-
"dist"
|
|
12
|
+
"dist",
|
|
13
|
+
"README.md"
|
|
13
14
|
],
|
|
14
15
|
"sideEffects": [
|
|
15
16
|
"**/*.css"
|
|
@@ -29,7 +30,7 @@
|
|
|
29
30
|
"react-dom": ">=18"
|
|
30
31
|
},
|
|
31
32
|
"dependencies": {
|
|
32
|
-
"@finyxpay/ui": "0.1.
|
|
33
|
+
"@finyxpay/ui": "0.1.2"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
35
36
|
"@testing-library/react": "^16.3.0",
|