pay-sdk-react 1.1.13 → 1.1.14
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 +226 -8
- package/README.zh-CN.md +225 -8
- package/dist/css/index.css +75 -6
- package/dist/css/index.min.css +1 -1
- package/dist/es/Airwallex/style/index.css +2 -2
- package/dist/es/Airwallex/style/index.min.css +1 -1
- package/dist/es/Alipay/style/index.css +2 -2
- package/dist/es/Alipay/style/index.min.css +1 -1
- package/dist/es/MAlipay/style/index.css +2 -2
- package/dist/es/MAlipay/style/index.min.css +1 -1
- package/dist/es/MPix/index.d.ts +2 -0
- package/dist/es/MPix/index.js +2 -0
- package/dist/es/MPix/interface.d.ts +44 -0
- package/dist/es/MPix/interface.js +1 -0
- package/dist/es/MPix/m-pix-button.d.ts +6 -0
- package/dist/es/MPix/m-pix-button.js +159 -0
- package/dist/es/MPix/style/index.css +256 -0
- package/dist/es/MPix/style/index.d.ts +1 -0
- package/dist/es/MPix/style/index.js +1 -0
- package/dist/es/MPix/style/index.min.css +1 -0
- package/dist/es/MWeChat/style/index.css +2 -2
- package/dist/es/MWeChat/style/index.min.css +1 -1
- package/dist/es/PayButton/index.js +12 -0
- package/dist/es/PayButton/interface.d.ts +28 -2
- package/dist/es/Pix/index.d.ts +11 -0
- package/dist/es/Pix/index.js +10 -0
- package/dist/es/Pix/interface.d.ts +80 -0
- package/dist/es/Pix/interface.js +1 -0
- package/dist/es/Pix/pix-button.d.ts +6 -0
- package/dist/es/Pix/pix-button.js +80 -0
- package/dist/es/Pix/pix-modal.d.ts +6 -0
- package/dist/es/Pix/pix-modal.js +57 -0
- package/dist/es/Pix/pix.d.ts +4 -0
- package/dist/es/Pix/pix.js +120 -0
- package/dist/es/Pix/style/index.css +69 -0
- package/dist/es/Pix/style/index.d.ts +1 -0
- package/dist/es/Pix/style/index.js +1 -0
- package/dist/es/Pix/style/index.min.css +1 -0
- package/dist/es/Stripe/style/index.css +2 -2
- package/dist/es/Stripe/style/index.min.css +1 -1
- package/dist/es/Wechat/style/index.css +2 -2
- package/dist/es/Wechat/style/index.min.css +1 -1
- package/dist/es/confirm-modal/style/index.css +2 -2
- package/dist/es/confirm-modal/style/index.min.css +1 -1
- package/dist/es/icons/IconCheck/index.d.ts +4 -0
- package/dist/es/icons/IconCheck/index.js +22 -0
- package/dist/es/icons/IconCopy/index.d.ts +4 -0
- package/dist/es/icons/IconCopy/index.js +27 -0
- package/dist/es/icons/IconPix/index.d.ts +4 -0
- package/dist/es/icons/IconPix/index.js +33 -0
- package/dist/es/icons/index.d.ts +3 -0
- package/dist/es/icons/index.js +4 -1
- package/dist/es/index.d.ts +17 -0
- package/dist/es/index.js +9 -0
- package/dist/es/pay-modal/style/index.css +2 -2
- package/dist/es/pay-modal/style/index.min.css +1 -1
- package/dist/es/shared/enums/index.d.ts +11 -1
- package/dist/es/shared/enums/index.js +10 -0
- package/dist/lib/Airwallex/style/index.css +2 -2
- package/dist/lib/Airwallex/style/index.min.css +1 -1
- package/dist/lib/Alipay/style/index.css +2 -2
- package/dist/lib/Alipay/style/index.min.css +1 -1
- package/dist/lib/MAlipay/style/index.css +2 -2
- package/dist/lib/MAlipay/style/index.min.css +1 -1
- package/dist/lib/MPix/index.js +28 -0
- package/dist/lib/MPix/interface.js +5 -0
- package/dist/lib/MPix/m-pix-button.js +127 -0
- package/dist/lib/MPix/style/index.css +256 -0
- package/dist/lib/MPix/style/index.js +3 -0
- package/dist/lib/MPix/style/index.min.css +1 -0
- package/dist/lib/MWeChat/style/index.css +2 -2
- package/dist/lib/MWeChat/style/index.min.css +1 -1
- package/dist/lib/PayButton/index.js +12 -0
- package/dist/lib/Pix/index.js +43 -0
- package/dist/lib/Pix/interface.js +5 -0
- package/dist/lib/Pix/pix-button.js +68 -0
- package/dist/lib/Pix/pix-modal.js +50 -0
- package/dist/lib/Pix/pix.js +92 -0
- package/dist/lib/Pix/style/index.css +69 -0
- package/dist/lib/Pix/style/index.js +3 -0
- package/dist/lib/Pix/style/index.min.css +1 -0
- package/dist/lib/Stripe/style/index.css +2 -2
- package/dist/lib/Stripe/style/index.min.css +1 -1
- package/dist/lib/Wechat/style/index.css +2 -2
- package/dist/lib/Wechat/style/index.min.css +1 -1
- package/dist/lib/confirm-modal/style/index.css +2 -2
- package/dist/lib/confirm-modal/style/index.min.css +1 -1
- package/dist/lib/icons/IconCheck/index.js +27 -0
- package/dist/lib/icons/IconCopy/index.js +32 -0
- package/dist/lib/icons/IconPix/index.js +38 -0
- package/dist/lib/icons/index.js +25 -1
- package/dist/lib/index.js +29 -0
- package/dist/lib/pay-modal/style/index.css +2 -2
- package/dist/lib/pay-modal/style/index.min.css +1 -1
- package/dist/lib/shared/enums/index.js +10 -0
- package/dist/umd/pay-sdk-react.umd.js +304 -69
- package/dist/umd/pay-sdk-react.umd.js.map +1 -1
- package/package.json +29 -24
package/README.md
CHANGED
|
@@ -6,20 +6,24 @@ English | [简体中文](./README.zh-CN.md)
|
|
|
6
6
|
|
|
7
7
|
# Features
|
|
8
8
|
|
|
9
|
-
|
|
10
9
|
## Comprehensive
|
|
11
|
-
|
|
10
|
+
|
|
11
|
+
Supports mainstream payment methods such as Alipay, WeChat Pay, PayPal, Stripe, Payssion, Airwallex, and PIX, covering the vast majority of business scenarios.
|
|
12
12
|
|
|
13
13
|
## Cross-Platform Compatibility
|
|
14
|
+
|
|
14
15
|
Available for H5, PC, and App scenarios, adaptable to multiple platforms to meet diverse business needs.
|
|
15
16
|
|
|
16
17
|
## TypeScript Friendly
|
|
18
|
+
|
|
17
19
|
All components are written in TypeScript, ensuring type safety and an excellent development experience.
|
|
18
20
|
|
|
19
21
|
## Multiple Integration Forms
|
|
22
|
+
|
|
20
23
|
Supports payment buttons, modals, QR codes, forms, popups, modals, overlays, and more. Flexible combinations to suit various business scenarios.
|
|
21
24
|
|
|
22
25
|
# Install
|
|
26
|
+
|
|
23
27
|
[npm package](https://www.npmjs.com/package/pay-sdk-react)
|
|
24
28
|
|
|
25
29
|
```shell
|
|
@@ -53,6 +57,7 @@ ReactDOM.render(<App />, document.getElementById('app'));
|
|
|
53
57
|
```
|
|
54
58
|
|
|
55
59
|
### On-Demand Loading
|
|
60
|
+
|
|
56
61
|
Using babel-plugin-import
|
|
57
62
|
|
|
58
63
|
#### 1. Install
|
|
@@ -61,8 +66,8 @@ Using babel-plugin-import
|
|
|
61
66
|
npm i babel-plugin-import -D
|
|
62
67
|
```
|
|
63
68
|
|
|
64
|
-
|
|
65
69
|
#### 2. Add Configuration: Component and Style On-demand Import
|
|
70
|
+
|
|
66
71
|
Add the following to your babel config:
|
|
67
72
|
|
|
68
73
|
```js
|
|
@@ -82,9 +87,11 @@ plugins: [
|
|
|
82
87
|
# Payment Scenarios & Usage
|
|
83
88
|
|
|
84
89
|
## Alipay
|
|
90
|
+
|
|
85
91
|
### PC
|
|
86
92
|
|
|
87
93
|
#### Method 1: Use the provided Pay Button
|
|
94
|
+
|
|
88
95
|
Import the Pay Button, click to trigger a modal displaying the Alipay QR code. After the user scans the QR code to complete payment, Alipay will notify the business backend of the payment result.
|
|
89
96
|
|
|
90
97
|
```typescript
|
|
@@ -112,7 +119,9 @@ export default AlipayComponent;
|
|
|
112
119
|
```
|
|
113
120
|
|
|
114
121
|
#### Method 2: Use a Alipay button
|
|
122
|
+
|
|
115
123
|
Import Alipay, Alipay.Button click to trigger a modal displaying the Alipay QR code. After the user scans the QR code to complete payment, Alipay will notify the business backend of the payment result.
|
|
124
|
+
|
|
116
125
|
```typescript
|
|
117
126
|
import { Alipay } from 'pay-sdk-react';
|
|
118
127
|
|
|
@@ -135,8 +144,8 @@ const AlipayComponent = () => {
|
|
|
135
144
|
export default AlipayComponent;
|
|
136
145
|
```
|
|
137
146
|
|
|
138
|
-
|
|
139
147
|
#### Method 3: Use a custom button
|
|
148
|
+
|
|
140
149
|
Use your own button, and call the modal component to display the QR code. After the user scans the QR code to complete payment, Alipay will notify the business backend of the payment result.
|
|
141
150
|
|
|
142
151
|
```typescript
|
|
@@ -178,6 +187,7 @@ export default AlipayComponent;
|
|
|
178
187
|
```
|
|
179
188
|
|
|
180
189
|
#### Method 4: Custom integration
|
|
190
|
+
|
|
181
191
|
Directly import the QR code component and customize the integration and display timing. After the user scans the QR code to complete payment, Alipay will notify the business backend of the payment result.
|
|
182
192
|
|
|
183
193
|
```typescript
|
|
@@ -199,6 +209,7 @@ export default AlipayComponent;
|
|
|
199
209
|
### H5
|
|
200
210
|
|
|
201
211
|
#### Method 1: PayButton
|
|
212
|
+
|
|
202
213
|
Import the PayButton, click to trigger a waiting modal (or overlay), auto-submit the iframe form to launch the Alipay app, or open in browser if the app is not installed. After the user completes payment, Alipay will notify the business backend of the payment result. Result handling: supports both modal and overlay.
|
|
203
214
|
|
|
204
215
|
```typescript
|
|
@@ -230,6 +241,7 @@ export default MAlipayComponent;
|
|
|
230
241
|
```
|
|
231
242
|
|
|
232
243
|
#### Method 2: MAlipay.Button
|
|
244
|
+
|
|
233
245
|
Import MAlipay.Button, click to trigger a waiting modal (or overlay), auto-submit the iframe form to launch the Alipay app, or open in browser if the app is not installed. After the user completes payment, Alipay will notify the business backend of the payment result.
|
|
234
246
|
|
|
235
247
|
```typescript
|
|
@@ -260,8 +272,8 @@ const MAlipayComponent = () => {
|
|
|
260
272
|
export default MAlipayComponent;
|
|
261
273
|
```
|
|
262
274
|
|
|
263
|
-
|
|
264
275
|
#### Method 3: Custom form
|
|
276
|
+
|
|
265
277
|
Import the MAlipay form component and customize the trigger timing. After the user completes payment, Alipay will notify the business backend of the payment result.
|
|
266
278
|
|
|
267
279
|
```typescript
|
|
@@ -287,6 +299,7 @@ export default MAlipayComponent;
|
|
|
287
299
|
### PC
|
|
288
300
|
|
|
289
301
|
#### Method 1: PayButton
|
|
302
|
+
|
|
290
303
|
Import the PayButton, click to trigger a modal displaying the WeChat QR code. After the user scans the QR code to complete payment, WeChat will notify the business backend of the payment result.
|
|
291
304
|
|
|
292
305
|
```typescript
|
|
@@ -314,6 +327,7 @@ export default WechatComponent;
|
|
|
314
327
|
```
|
|
315
328
|
|
|
316
329
|
#### Method 2: Wechat.Button
|
|
330
|
+
|
|
317
331
|
Import Wechat.Button, click to trigger a modal displaying the WeChat QR code. After the user scans the QR code to complete payment, WeChat will notify the business backend of the payment result.
|
|
318
332
|
|
|
319
333
|
```typescript
|
|
@@ -339,6 +353,7 @@ export default WechatComponent;
|
|
|
339
353
|
```
|
|
340
354
|
|
|
341
355
|
#### Method 3: Use a custom button
|
|
356
|
+
|
|
342
357
|
Use your own button, and call the modal component to display the QR code. After the user scans the QR code to complete payment, WeChat will notify the business backend of the payment result.
|
|
343
358
|
|
|
344
359
|
```typescript
|
|
@@ -380,6 +395,7 @@ export default WechatComponent;
|
|
|
380
395
|
```
|
|
381
396
|
|
|
382
397
|
#### Method 4: Custom integration
|
|
398
|
+
|
|
383
399
|
Directly import the QR code component and customize the integration and display timing. After the user scans the QR code to complete payment, WeChat will notify the business backend of the payment result.
|
|
384
400
|
|
|
385
401
|
```typescript
|
|
@@ -402,6 +418,7 @@ export default WechatComponent;
|
|
|
402
418
|
### H5
|
|
403
419
|
|
|
404
420
|
#### Method 1: PayButton
|
|
421
|
+
|
|
405
422
|
Import the PayButton, click to trigger a waiting modal (or overlay), auto-open the WeChat payment link, and auto-trigger payment in the WeChat browser. After the user completes payment, WeChat will notify the business backend of the payment result. Result handling: supports both modal and overlay.
|
|
406
423
|
|
|
407
424
|
```typescript
|
|
@@ -437,6 +454,7 @@ export default MWechatComponent;
|
|
|
437
454
|
```
|
|
438
455
|
|
|
439
456
|
#### Method 2: MWechatButton
|
|
457
|
+
|
|
440
458
|
Import MWechatButton, click to trigger a waiting modal (or overlay), auto-open the WeChat payment link, and auto-trigger payment in the WeChat browser. After the user completes payment, WeChat will notify the business backend of the payment result.
|
|
441
459
|
|
|
442
460
|
```typescript
|
|
@@ -463,6 +481,7 @@ export default MWechatComponent;
|
|
|
463
481
|
Import the PayButton, click to trigger payment, auto-open the PayPal payment link, and show a waiting overlay. After PayPal payment is completed, PayPal will redirect to the business-specified result page, and the redirect address is passed in when the business backend service calls the PayPal official payment order creation API.
|
|
464
482
|
|
|
465
483
|
### Method 1: PayButton
|
|
484
|
+
|
|
466
485
|
Import the PayButton, click to trigger payment, auto-open the PayPal payment link, and show a waiting overlay. After the user completes payment, PayPal will redirect to the business-specified result page.
|
|
467
486
|
|
|
468
487
|
```typescript
|
|
@@ -499,6 +518,7 @@ export default PaypalComponent;
|
|
|
499
518
|
```
|
|
500
519
|
|
|
501
520
|
### Method 2: PaypalButton
|
|
521
|
+
|
|
502
522
|
Import PaypalButton, click to trigger payment, auto-open the PayPal payment link, and show a waiting overlay. After the user completes payment, PayPal will redirect to the business-specified result page.
|
|
503
523
|
|
|
504
524
|
```typescript
|
|
@@ -554,6 +574,7 @@ export default PaypalComponent;
|
|
|
554
574
|
Import payment components to use Stripe payment. After Stripe payment is completed, Stripe will redirect to the business-specified result page, and the redirect address is passed in when the business backend service calls the Stripe official payment order creation API.
|
|
555
575
|
|
|
556
576
|
### Method 1: PayButton
|
|
577
|
+
|
|
557
578
|
Import the PayButton, click to trigger payment modal or popup, display Stripe payment form. After the user completes payment, Stripe will redirect to the business-specified result page.
|
|
558
579
|
|
|
559
580
|
```typescript
|
|
@@ -580,6 +601,7 @@ export default StripeComponent;
|
|
|
580
601
|
```
|
|
581
602
|
|
|
582
603
|
### Method 2: Stripe.Button
|
|
604
|
+
|
|
583
605
|
Import Stripe.Button, click to trigger payment modal or popup, display Stripe payment form. After the user completes payment, Stripe will redirect to the business-specified result page.
|
|
584
606
|
|
|
585
607
|
```typescript
|
|
@@ -603,8 +625,8 @@ const StripeComponent = () => {
|
|
|
603
625
|
export default StripeComponent;
|
|
604
626
|
```
|
|
605
627
|
|
|
606
|
-
|
|
607
628
|
### Method 3: Custom trigger popup - Recommended for mobile
|
|
629
|
+
|
|
608
630
|
Use custom button to call Stripe.Popup component, display Stripe payment form. After the user completes payment, Stripe will redirect to the business-specified result page.
|
|
609
631
|
|
|
610
632
|
```typescript
|
|
@@ -648,6 +670,7 @@ export default StripeComponent;
|
|
|
648
670
|
```
|
|
649
671
|
|
|
650
672
|
### Method 4: Custom trigger modal - Recommended for PC
|
|
673
|
+
|
|
651
674
|
Use custom button to call Stripe.Modal component, display Stripe payment form. After the user completes payment, Stripe will redirect to the business-specified result page.
|
|
652
675
|
|
|
653
676
|
```typescript
|
|
@@ -692,6 +715,7 @@ export default StripeComponent;
|
|
|
692
715
|
```
|
|
693
716
|
|
|
694
717
|
### Method 5: Stripe Form
|
|
718
|
+
|
|
695
719
|
Import the Stripe form component and customize the integration and display timing. After the user completes payment, Stripe will redirect to the business-specified result page.
|
|
696
720
|
|
|
697
721
|
```typescript
|
|
@@ -719,6 +743,7 @@ export default StripeComponent;
|
|
|
719
743
|
Import payment components to use Airwallex payment. After Airwallex payment is completed, the Airwallex payment component will callback the onSuccess method, and the business executes subsequent logic.
|
|
720
744
|
|
|
721
745
|
### Method 1: PayButton
|
|
746
|
+
|
|
722
747
|
Import the PayButton, click to trigger a popup for the payment form (recommended for mobile), or a modal for PC. After the user completes payment, the Airwallex payment component will callback the onSuccess method, and the business executes subsequent logic.
|
|
723
748
|
|
|
724
749
|
```typescript
|
|
@@ -768,6 +793,7 @@ export default AirwallexComponent;
|
|
|
768
793
|
```
|
|
769
794
|
|
|
770
795
|
### Method 2: Custom trigger popup
|
|
796
|
+
|
|
771
797
|
Use custom button to call Airwallex.Popup component, display Airwallex payment form. After the user completes payment, the Airwallex payment component will callback the onSuccess method, and the business executes subsequent logic.
|
|
772
798
|
|
|
773
799
|
```typescript
|
|
@@ -846,6 +872,7 @@ export default AirwallexComponent;
|
|
|
846
872
|
```
|
|
847
873
|
|
|
848
874
|
### Method 3: Trigger modal
|
|
875
|
+
|
|
849
876
|
Use custom button to call Airwallex.Modal component, display Airwallex payment form. After the user completes payment, the Airwallex payment component will callback the onSuccess method, and the business executes subsequent logic.
|
|
850
877
|
|
|
851
878
|
```typescript
|
|
@@ -923,8 +950,8 @@ const AirwallexComponent = () => {
|
|
|
923
950
|
export default AirwallexComponent;
|
|
924
951
|
```
|
|
925
952
|
|
|
926
|
-
|
|
927
953
|
### Method 4: Custom integration
|
|
954
|
+
|
|
928
955
|
Import the Airwallex form component and customize the integration and display timing. After the user completes payment, the Airwallex payment component will callback the onSuccess method, and the business executes subsequent logic.
|
|
929
956
|
|
|
930
957
|
```typescript
|
|
@@ -965,6 +992,7 @@ export default AirwallexComponent;
|
|
|
965
992
|
```
|
|
966
993
|
|
|
967
994
|
### Method 5: Airwallex.Button
|
|
995
|
+
|
|
968
996
|
Import the Pay Button, click to open a third-party payment link and show a waiting overlay. After the user completes payment, Airwallex will redirect to the business-specified result page.
|
|
969
997
|
|
|
970
998
|
```typescript
|
|
@@ -991,11 +1019,200 @@ const AirwallexComponent = () => {
|
|
|
991
1019
|
export default AirwallexComponent;
|
|
992
1020
|
```
|
|
993
1021
|
|
|
1022
|
+
## PIX
|
|
1023
|
+
|
|
1024
|
+
Import payment components to use PIX payment (Brazilian instant payment system). After the user scans the PIX QR code and completes payment, the business backend will receive the payment notification.
|
|
1025
|
+
|
|
1026
|
+
### PC
|
|
1027
|
+
|
|
1028
|
+
#### Method 1: PayButton
|
|
1029
|
+
|
|
1030
|
+
Import the PayButton, click to trigger a modal displaying the PIX QR code. After the user scans the QR code to complete payment, the business backend will receive the payment notification.
|
|
1031
|
+
|
|
1032
|
+
```typescript
|
|
1033
|
+
import { PayButton, PaymentMethod } from 'pay-sdk-react';
|
|
1034
|
+
|
|
1035
|
+
const PixComponent = () => {
|
|
1036
|
+
const createOrder = async () => {
|
|
1037
|
+
const res = await fetch('/create-order', {
|
|
1038
|
+
method: 'POST',
|
|
1039
|
+
});
|
|
1040
|
+
return { pixCode: res.pixCode };
|
|
1041
|
+
};
|
|
1042
|
+
|
|
1043
|
+
return (
|
|
1044
|
+
<div className="pix-component">
|
|
1045
|
+
<h3>PayButton - Basic Usage</h3>
|
|
1046
|
+
<PayButton payMethod={PaymentMethod.PixPc} createOrder={createOrder}>
|
|
1047
|
+
Pay Button
|
|
1048
|
+
</PayButton>
|
|
1049
|
+
</div>
|
|
1050
|
+
);
|
|
1051
|
+
};
|
|
1052
|
+
|
|
1053
|
+
export default PixComponent;
|
|
1054
|
+
```
|
|
1055
|
+
|
|
1056
|
+
#### Method 2: Pix.Button
|
|
1057
|
+
|
|
1058
|
+
Import Pix.Button, click to trigger a modal displaying the PIX QR code. After the user scans the QR code to complete payment, the business backend will receive the payment notification.
|
|
1059
|
+
|
|
1060
|
+
```typescript
|
|
1061
|
+
import { Pix } from 'pay-sdk-react';
|
|
1062
|
+
|
|
1063
|
+
const PixComponent = () => {
|
|
1064
|
+
const createOrder = async () => {
|
|
1065
|
+
const res = await fetch('/create-order', {
|
|
1066
|
+
method: 'POST',
|
|
1067
|
+
});
|
|
1068
|
+
return { pixCode: res.pixCode };
|
|
1069
|
+
};
|
|
1070
|
+
|
|
1071
|
+
return (
|
|
1072
|
+
<div className="pix-component">
|
|
1073
|
+
<h3>Pix.Button - modal</h3>
|
|
1074
|
+
<Pix.Button createOrder={createOrder}>PIX Button</Pix.Button>
|
|
1075
|
+
</div>
|
|
1076
|
+
);
|
|
1077
|
+
};
|
|
1078
|
+
|
|
1079
|
+
export default PixComponent;
|
|
1080
|
+
```
|
|
1081
|
+
|
|
1082
|
+
#### Method 3: Custom button
|
|
1083
|
+
|
|
1084
|
+
Use your own button, and call the modal component to display the QR code. After the user scans the QR code to complete payment, the business backend will receive the payment notification.
|
|
1085
|
+
|
|
1086
|
+
```typescript
|
|
1087
|
+
import { useRef, useState } from 'react';
|
|
1088
|
+
import { Pix, PixModalRef } from 'pay-sdk-react';
|
|
1089
|
+
|
|
1090
|
+
const pixCode = '00020126580014br.gov.bcb.pix...';
|
|
1091
|
+
|
|
1092
|
+
const PixComponent = () => {
|
|
1093
|
+
const modalRef = useRef<PixModalRef>(null);
|
|
1094
|
+
|
|
1095
|
+
const [modalVisible, setModalVisible] = useState(false);
|
|
1096
|
+
|
|
1097
|
+
const createOrder = async () => {
|
|
1098
|
+
const res = await fetch('/create-order', {
|
|
1099
|
+
method: 'POST',
|
|
1100
|
+
});
|
|
1101
|
+
modalRef.current?.open({ pixCode: res.pixCode });
|
|
1102
|
+
};
|
|
1103
|
+
|
|
1104
|
+
return (
|
|
1105
|
+
<div className="pix-component">
|
|
1106
|
+
<h3>Custom Button - Trigger modal with visible prop</h3>
|
|
1107
|
+
<button onClick={() => setModalVisible(true)}>Custom Button</button>
|
|
1108
|
+
<Pix.Modal
|
|
1109
|
+
visible={modalVisible}
|
|
1110
|
+
onClose={() => setModalVisible(false)}
|
|
1111
|
+
pixProps={{ pixCode }}
|
|
1112
|
+
/>
|
|
1113
|
+
|
|
1114
|
+
<h3>Custom Button - Trigger modal with ref open method</h3>
|
|
1115
|
+
<button onClick={() => createOrder()}>Custom Button</button>
|
|
1116
|
+
<Pix.Modal ref={modalRef} />
|
|
1117
|
+
</div>
|
|
1118
|
+
);
|
|
1119
|
+
};
|
|
1120
|
+
|
|
1121
|
+
export default PixComponent;
|
|
1122
|
+
```
|
|
1123
|
+
|
|
1124
|
+
#### Method 4: Custom integration
|
|
1125
|
+
|
|
1126
|
+
Directly import the QR code component and customize the integration and display timing. After the user scans the QR code to complete payment, the business backend will receive the payment notification.
|
|
1127
|
+
|
|
1128
|
+
```typescript
|
|
1129
|
+
import { Pix } from 'pay-sdk-react';
|
|
1130
|
+
|
|
1131
|
+
const pixCode = '00020126580014br.gov.bcb.pix...';
|
|
1132
|
+
|
|
1133
|
+
const PixComponent = () => {
|
|
1134
|
+
return (
|
|
1135
|
+
<div className="pix-component">
|
|
1136
|
+
<h3>Pix Form - Custom integration</h3>
|
|
1137
|
+
<Pix pixCode={pixCode} />
|
|
1138
|
+
</div>
|
|
1139
|
+
);
|
|
1140
|
+
};
|
|
1141
|
+
|
|
1142
|
+
export default PixComponent;
|
|
1143
|
+
```
|
|
1144
|
+
|
|
1145
|
+
### H5
|
|
1146
|
+
|
|
1147
|
+
#### Method 1: PayButton
|
|
1148
|
+
|
|
1149
|
+
Import the PayButton, click to trigger a waiting modal (or overlay), auto-open the PIX payment link. After the user completes payment, the business backend will receive the payment notification.
|
|
1150
|
+
|
|
1151
|
+
```typescript
|
|
1152
|
+
import { PayButton, PaymentMethod } from 'pay-sdk-react';
|
|
1153
|
+
|
|
1154
|
+
const MPixComponent = () => {
|
|
1155
|
+
const createOrder = async () => {
|
|
1156
|
+
const res = await fetch('/create-order', {
|
|
1157
|
+
method: 'POST',
|
|
1158
|
+
});
|
|
1159
|
+
return { pixCode: res.pixCode };
|
|
1160
|
+
};
|
|
1161
|
+
|
|
1162
|
+
return (
|
|
1163
|
+
<div className="m-pix-component">
|
|
1164
|
+
<h3>PayButton - Basic Usage</h3>
|
|
1165
|
+
<PayButton payMethod={PaymentMethod.PixH5} createOrder={createOrder}>
|
|
1166
|
+
Pay Button
|
|
1167
|
+
</PayButton>
|
|
1168
|
+
<h3>PayButton - Mask</h3>
|
|
1169
|
+
<PayButton
|
|
1170
|
+
payMethod={PaymentMethod.PixH5}
|
|
1171
|
+
createOrder={createOrder}
|
|
1172
|
+
displayType="mask"
|
|
1173
|
+
>
|
|
1174
|
+
Pay Button
|
|
1175
|
+
</PayButton>
|
|
1176
|
+
</div>
|
|
1177
|
+
);
|
|
1178
|
+
};
|
|
1179
|
+
|
|
1180
|
+
export default MPixComponent;
|
|
1181
|
+
```
|
|
1182
|
+
|
|
1183
|
+
#### Method 2: MPix.Button
|
|
1184
|
+
|
|
1185
|
+
Import MPix.Button, click to trigger a waiting modal (or overlay), auto-open the PIX payment link. After the user completes payment, the business backend will receive the payment notification.
|
|
1186
|
+
|
|
1187
|
+
```typescript
|
|
1188
|
+
import { MPixButton } from 'pay-sdk-react';
|
|
1189
|
+
|
|
1190
|
+
const pixCode = '00020126580014br.gov.bcb.pix...';
|
|
1191
|
+
|
|
1192
|
+
const MPixComponent = () => {
|
|
1193
|
+
return (
|
|
1194
|
+
<div className="m-pix-component">
|
|
1195
|
+
<h3>PIX Button - Modal</h3>
|
|
1196
|
+
<MPixButton displayType="modal" pixCode={pixCode}>
|
|
1197
|
+
PIX Button
|
|
1198
|
+
</MPixButton>
|
|
1199
|
+
<h3>PIX Button - Mask</h3>
|
|
1200
|
+
<MPixButton displayType="mask" pixCode={pixCode}>
|
|
1201
|
+
PIX Button
|
|
1202
|
+
</MPixButton>
|
|
1203
|
+
</div>
|
|
1204
|
+
);
|
|
1205
|
+
};
|
|
1206
|
+
|
|
1207
|
+
export default MPixComponent;
|
|
1208
|
+
```
|
|
1209
|
+
|
|
994
1210
|
## Payssion
|
|
995
1211
|
|
|
996
1212
|
Import payment components to use Payssion payment. After Payssion payment is completed, Payssion will redirect to the business-specified result page, and the redirect address is passed in when the business backend service calls the Payssion official payment order creation API.
|
|
997
1213
|
|
|
998
1214
|
### Method 1: PayButton
|
|
1215
|
+
|
|
999
1216
|
Import the PayButton, click to open a third-party payment link and show a waiting overlay. After the user completes payment, Payssion will redirect to the business-specified result page.
|
|
1000
1217
|
|
|
1001
1218
|
```typescript
|
|
@@ -1031,6 +1248,7 @@ export default PayssionComponent;
|
|
|
1031
1248
|
```
|
|
1032
1249
|
|
|
1033
1250
|
### Method 2: PayssionButton
|
|
1251
|
+
|
|
1034
1252
|
Import PayssionButton, click to open a third-party payment link and show a waiting overlay. After the user completes payment, Payssion will redirect to the business-specified result page.
|
|
1035
1253
|
|
|
1036
1254
|
```typescript
|
|
@@ -1074,4 +1292,4 @@ const PayssionComponent = () => {
|
|
|
1074
1292
|
};
|
|
1075
1293
|
|
|
1076
1294
|
export default PayssionComponent;
|
|
1077
|
-
```
|
|
1295
|
+
```
|