pay-sdk-react 1.1.13 → 1.2.0

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.
Files changed (194) hide show
  1. package/README.md +465 -84
  2. package/README.zh-CN.md +466 -85
  3. package/dist/css/index.css +86 -6
  4. package/dist/css/index.min.css +1 -1
  5. package/dist/es/Airwallex/airwallex-button.js +48 -16
  6. package/dist/es/Airwallex/airwallex-checkout-button.d.ts +4 -0
  7. package/dist/es/Airwallex/airwallex-checkout-button.js +73 -0
  8. package/dist/es/Airwallex/airwallex-managed.d.ts +4 -0
  9. package/dist/es/Airwallex/airwallex-managed.js +87 -0
  10. package/dist/es/Airwallex/airwallex-modal.js +7 -3
  11. package/dist/es/Airwallex/airwallex-popup.js +7 -3
  12. package/dist/es/Airwallex/airwallex.d.ts +1 -3
  13. package/dist/es/Airwallex/airwallex.js +10 -1
  14. package/dist/es/Airwallex/hooks/useAirwallexCheckout.d.ts +7 -0
  15. package/dist/es/Airwallex/hooks/useAirwallexCheckout.js +155 -0
  16. package/dist/es/Airwallex/index.d.ts +4 -0
  17. package/dist/es/Airwallex/index.js +5 -1
  18. package/dist/es/Airwallex/interface.d.ts +146 -0
  19. package/dist/es/Airwallex/style/index.css +2 -2
  20. package/dist/es/Airwallex/style/index.min.css +1 -1
  21. package/dist/es/Alipay/alipay-button.js +26 -7
  22. package/dist/es/Alipay/alipay.js +39 -12
  23. package/dist/es/Alipay/interface.d.ts +26 -1
  24. package/dist/es/Alipay/style/index.css +2 -2
  25. package/dist/es/Alipay/style/index.min.css +1 -1
  26. package/dist/es/MAlipay/style/index.css +2 -2
  27. package/dist/es/MAlipay/style/index.min.css +1 -1
  28. package/dist/es/MPix/index.d.ts +2 -0
  29. package/dist/es/MPix/index.js +2 -0
  30. package/dist/es/MPix/interface.d.ts +44 -0
  31. package/dist/es/MPix/interface.js +1 -0
  32. package/dist/es/MPix/m-pix-button.d.ts +6 -0
  33. package/dist/es/MPix/m-pix-button.js +159 -0
  34. package/dist/es/MPix/style/index.css +256 -0
  35. package/dist/es/MPix/style/index.d.ts +1 -0
  36. package/dist/es/MPix/style/index.js +1 -0
  37. package/dist/es/MPix/style/index.min.css +1 -0
  38. package/dist/es/MWeChat/style/index.css +2 -2
  39. package/dist/es/MWeChat/style/index.min.css +1 -1
  40. package/dist/es/PayButton/index.js +12 -0
  41. package/dist/es/PayButton/interface.d.ts +28 -2
  42. package/dist/es/Paypal/index.d.ts +2 -0
  43. package/dist/es/Paypal/index.js +3 -1
  44. package/dist/es/Paypal/interface.d.ts +40 -0
  45. package/dist/es/Paypal/paypal-button.js +24 -3
  46. package/dist/es/Paypal/paypal-smart-button.d.ts +4 -0
  47. package/dist/es/Paypal/paypal-smart-button.js +48 -0
  48. package/dist/es/Payssion/interface.d.ts +7 -0
  49. package/dist/es/Payssion/payssion-button.js +25 -4
  50. package/dist/es/Pix/index.d.ts +11 -0
  51. package/dist/es/Pix/index.js +10 -0
  52. package/dist/es/Pix/interface.d.ts +147 -0
  53. package/dist/es/Pix/interface.js +1 -0
  54. package/dist/es/Pix/pix-button.d.ts +6 -0
  55. package/dist/es/Pix/pix-button.js +99 -0
  56. package/dist/es/Pix/pix-enhanced.d.ts +4 -0
  57. package/dist/es/Pix/pix-enhanced.js +182 -0
  58. package/dist/es/Pix/pix-modal.d.ts +6 -0
  59. package/dist/es/Pix/pix-modal.js +57 -0
  60. package/dist/es/Pix/pix.d.ts +4 -0
  61. package/dist/es/Pix/pix.js +125 -0
  62. package/dist/es/Pix/style/index.css +80 -0
  63. package/dist/es/Pix/style/index.d.ts +1 -0
  64. package/dist/es/Pix/style/index.js +1 -0
  65. package/dist/es/Pix/style/index.min.css +1 -0
  66. package/dist/es/Stripe/hooks/useStripeCheckout.d.ts +7 -0
  67. package/dist/es/Stripe/hooks/useStripeCheckout.js +86 -0
  68. package/dist/es/Stripe/index.d.ts +4 -0
  69. package/dist/es/Stripe/index.js +5 -1
  70. package/dist/es/Stripe/interface.d.ts +120 -0
  71. package/dist/es/Stripe/stripe-button.js +32 -10
  72. package/dist/es/Stripe/stripe-checkout-button.d.ts +4 -0
  73. package/dist/es/Stripe/stripe-checkout-button.js +70 -0
  74. package/dist/es/Stripe/stripe-modal.js +19 -2
  75. package/dist/es/Stripe/stripe-popup.js +13 -2
  76. package/dist/es/Stripe/stripe.js +38 -4
  77. package/dist/es/Stripe/style/index.css +2 -2
  78. package/dist/es/Stripe/style/index.min.css +1 -1
  79. package/dist/es/Wechat/interface.d.ts +13 -0
  80. package/dist/es/Wechat/style/index.css +2 -2
  81. package/dist/es/Wechat/style/index.min.css +1 -1
  82. package/dist/es/Wechat/wechat-button.js +26 -7
  83. package/dist/es/Wechat/wechat-content.d.ts +4 -0
  84. package/dist/es/Wechat/wechat-content.js +61 -0
  85. package/dist/es/Wechat/wechat.d.ts +1 -1
  86. package/dist/es/Wechat/wechat.js +5 -1
  87. package/dist/es/confirm-modal/style/index.css +2 -2
  88. package/dist/es/confirm-modal/style/index.min.css +1 -1
  89. package/dist/es/hooks/useLatestCallback.d.ts +1 -0
  90. package/dist/es/hooks/useLatestCallback.js +8 -0
  91. package/dist/es/hooks/useManagedOrder.d.ts +8 -0
  92. package/dist/es/hooks/useManagedOrder.js +67 -0
  93. package/dist/es/hooks/usePaymentExecution.d.ts +13 -0
  94. package/dist/es/hooks/usePaymentExecution.js +176 -0
  95. package/dist/es/hooks/usePaymentQr.d.ts +6 -0
  96. package/dist/es/hooks/usePaymentQr.js +52 -0
  97. package/dist/es/hooks/usePaymentRedirect.d.ts +5 -0
  98. package/dist/es/hooks/usePaymentRedirect.js +83 -0
  99. package/dist/es/icons/IconCheck/index.d.ts +4 -0
  100. package/dist/es/icons/IconCheck/index.js +22 -0
  101. package/dist/es/icons/IconCopy/index.d.ts +4 -0
  102. package/dist/es/icons/IconCopy/index.js +27 -0
  103. package/dist/es/icons/IconPix/index.d.ts +4 -0
  104. package/dist/es/icons/IconPix/index.js +33 -0
  105. package/dist/es/icons/index.d.ts +3 -0
  106. package/dist/es/icons/index.js +4 -1
  107. package/dist/es/index.d.ts +50 -6
  108. package/dist/es/index.js +28 -1
  109. package/dist/es/pay-modal/interface.d.ts +22 -2
  110. package/dist/es/pay-modal/pay-modal.js +36 -16
  111. package/dist/es/pay-modal/style/index.css +2 -2
  112. package/dist/es/pay-modal/style/index.min.css +1 -1
  113. package/dist/es/shared/entitys/payment.d.ts +227 -0
  114. package/dist/es/shared/entitys/payment.js +75 -0
  115. package/dist/es/shared/enums/index.d.ts +1 -78
  116. package/dist/es/shared/enums/index.js +1 -81
  117. package/dist/es/shared/enums/payment.d.ts +162 -0
  118. package/dist/es/shared/enums/payment.js +168 -0
  119. package/dist/es/shared/index.d.ts +2 -0
  120. package/dist/es/shared/index.js +2 -1
  121. package/dist/lib/Airwallex/airwallex-button.js +31 -10
  122. package/dist/lib/Airwallex/airwallex-checkout-button.js +52 -0
  123. package/dist/lib/Airwallex/airwallex-managed.js +86 -0
  124. package/dist/lib/Airwallex/airwallex-modal.js +4 -2
  125. package/dist/lib/Airwallex/airwallex-popup.js +4 -2
  126. package/dist/lib/Airwallex/airwallex.js +9 -1
  127. package/dist/lib/Airwallex/hooks/useAirwallexCheckout.js +83 -0
  128. package/dist/lib/Airwallex/index.js +18 -1
  129. package/dist/lib/Airwallex/style/index.css +2 -2
  130. package/dist/lib/Airwallex/style/index.min.css +1 -1
  131. package/dist/lib/Alipay/alipay-button.js +21 -6
  132. package/dist/lib/Alipay/alipay.js +36 -9
  133. package/dist/lib/Alipay/style/index.css +2 -2
  134. package/dist/lib/Alipay/style/index.min.css +1 -1
  135. package/dist/lib/MAlipay/style/index.css +2 -2
  136. package/dist/lib/MAlipay/style/index.min.css +1 -1
  137. package/dist/lib/MPix/index.js +28 -0
  138. package/dist/lib/MPix/interface.js +5 -0
  139. package/dist/lib/MPix/m-pix-button.js +127 -0
  140. package/dist/lib/MPix/style/index.css +256 -0
  141. package/dist/lib/MPix/style/index.js +3 -0
  142. package/dist/lib/MPix/style/index.min.css +1 -0
  143. package/dist/lib/MWeChat/style/index.css +2 -2
  144. package/dist/lib/MWeChat/style/index.min.css +1 -1
  145. package/dist/lib/PayButton/index.js +12 -0
  146. package/dist/lib/Paypal/index.js +17 -1
  147. package/dist/lib/Paypal/paypal-button.js +19 -2
  148. package/dist/lib/Paypal/paypal-smart-button.js +45 -0
  149. package/dist/lib/Payssion/payssion-button.js +20 -3
  150. package/dist/lib/Pix/index.js +43 -0
  151. package/dist/lib/Pix/interface.js +5 -0
  152. package/dist/lib/Pix/pix-button.js +83 -0
  153. package/dist/lib/Pix/pix-enhanced.js +143 -0
  154. package/dist/lib/Pix/pix-modal.js +50 -0
  155. package/dist/lib/Pix/pix.js +97 -0
  156. package/dist/lib/Pix/style/index.css +80 -0
  157. package/dist/lib/Pix/style/index.js +3 -0
  158. package/dist/lib/Pix/style/index.min.css +1 -0
  159. package/dist/lib/Stripe/hooks/useStripeCheckout.js +41 -0
  160. package/dist/lib/Stripe/index.js +18 -1
  161. package/dist/lib/Stripe/stripe-button.js +28 -10
  162. package/dist/lib/Stripe/stripe-checkout-button.js +50 -0
  163. package/dist/lib/Stripe/stripe-modal.js +12 -1
  164. package/dist/lib/Stripe/stripe-popup.js +12 -1
  165. package/dist/lib/Stripe/stripe.js +30 -1
  166. package/dist/lib/Stripe/style/index.css +2 -2
  167. package/dist/lib/Stripe/style/index.min.css +1 -1
  168. package/dist/lib/Wechat/style/index.css +2 -2
  169. package/dist/lib/Wechat/style/index.min.css +1 -1
  170. package/dist/lib/Wechat/wechat-button.js +21 -6
  171. package/dist/lib/Wechat/wechat-content.js +65 -0
  172. package/dist/lib/Wechat/wechat.js +3 -1
  173. package/dist/lib/confirm-modal/style/index.css +2 -2
  174. package/dist/lib/confirm-modal/style/index.min.css +1 -1
  175. package/dist/lib/hooks/useLatestCallback.js +13 -0
  176. package/dist/lib/hooks/useManagedOrder.js +29 -0
  177. package/dist/lib/hooks/usePaymentExecution.js +113 -0
  178. package/dist/lib/hooks/usePaymentQr.js +51 -0
  179. package/dist/lib/hooks/usePaymentRedirect.js +87 -0
  180. package/dist/lib/icons/IconCheck/index.js +27 -0
  181. package/dist/lib/icons/IconCopy/index.js +32 -0
  182. package/dist/lib/icons/IconPix/index.js +38 -0
  183. package/dist/lib/icons/index.js +25 -1
  184. package/dist/lib/index.js +86 -1
  185. package/dist/lib/pay-modal/pay-modal.js +33 -16
  186. package/dist/lib/pay-modal/style/index.css +2 -2
  187. package/dist/lib/pay-modal/style/index.min.css +1 -1
  188. package/dist/lib/shared/entitys/payment.js +61 -0
  189. package/dist/lib/shared/enums/index.js +11 -81
  190. package/dist/lib/shared/enums/payment.js +172 -0
  191. package/dist/lib/shared/index.js +12 -1
  192. package/dist/umd/pay-sdk-react.umd.js +10455 -11463
  193. package/dist/umd/pay-sdk-react.umd.js.map +1 -1
  194. package/package.json +44 -25
package/README.zh-CN.md CHANGED
@@ -6,20 +6,24 @@
6
6
 
7
7
  # 特征
8
8
 
9
-
10
9
  ## 全面
11
- 支持支付宝、微信、PayPal、Stripe、Payssion、空中云汇(Airwallex)等主流支付方式,覆盖绝大部分业务场景。
10
+
11
+ 支持支付宝、微信、PayPal、Stripe、Payssion、空中云汇(Airwallex)、PIX(巴西即时支付)等主流支付方式,覆盖绝大部分业务场景。
12
12
 
13
13
  ## 跨端适配
14
+
14
15
  H5、PC、App跨端 场景均可用,适配多端,满足多样化业务需求。
15
16
 
16
17
  ## TypeScript 友好
18
+
17
19
  所有组件均由 TypeScript 编写,类型安全,开发体验优秀。
18
20
 
19
21
  ## 多种承接形式
22
+
20
23
  支持支付按钮、弹窗、二维码、表单、popup、modal、蒙层等多种支付承接方式,灵活组合,满足不同业务场景。
21
24
 
22
25
  # 安装
26
+
23
27
  [npm package](https://www.npmjs.com/package/pay-sdk-react)
24
28
 
25
29
  ```shell
@@ -45,7 +49,7 @@ import 'pay-sdk-react/dist/css/index.min.css';
45
49
 
46
50
  function App() {
47
51
  return (
48
- <PayButton payMethod={PaymentMethod.PaypalH5} paypalUrl={''}, />
52
+ <PayButton payMethod={PaymentMethod.PaypalH5} paypalUrl={''} />
49
53
  );
50
54
  }
51
55
 
@@ -53,6 +57,7 @@ ReactDOM.render(<App />, document.getElementById('app'));
53
57
  ```
54
58
 
55
59
  ### 按需加载
60
+
56
61
  使用 babel-plugin-import
57
62
 
58
63
  #### 1. 安装
@@ -61,8 +66,8 @@ ReactDOM.render(<App />, document.getElementById('app'));
61
66
  npm i babel-plugin-import -D
62
67
  ```
63
68
 
64
-
65
69
  #### 2. 添加配置:组件和样式的按需加载
70
+
66
71
  在 babel 配置中加入:
67
72
 
68
73
  ```js
@@ -82,9 +87,11 @@ plugins: [
82
87
  # 支付场景与用法
83
88
 
84
89
  ## 支付宝
90
+
85
91
  ### PC 端
86
92
 
87
93
  #### 方式一:使用 PayButton
94
+
88
95
  引入 PayButton 按钮,点击唤起支付弹窗,展示支付宝二维码。用户扫码完成支付后,支付宝会通知业务后端支付结果。
89
96
 
90
97
  ```typescript
@@ -113,6 +120,7 @@ export default AlipayComponent;
113
120
  ```
114
121
 
115
122
  #### 方式二:Alipay.Button
123
+
116
124
  引入 Alipay,Alipay.Button 点击唤起支付弹窗,展示支付宝二维码。用户扫码完成支付后,支付宝会通知业务后端支付结果。
117
125
 
118
126
  ```typescript
@@ -137,49 +145,14 @@ const AlipayComponent = () => {
137
145
  export default AlipayComponent;
138
146
  ```
139
147
 
148
+ #### 方式三:按钮样式与弹窗配置
140
149
 
141
- #### 方式三:自定义按钮
142
- 使用自定义按钮,调用支付弹窗组件,展示二维码。用户扫码完成支付后,支付宝会通知业务后端支付结果。
143
-
144
- ```typescript
145
- import { useRef, useState } from 'react';
146
- import { Alipay, AlipayModalRef } from 'pay-sdk-react';
147
-
148
- const formHtml = '<form ... />';
149
-
150
- const AlipayComponent = () => {
151
- const modalRef = useRef<AlipayModalRef>(null);
152
-
153
- const [modalVisible, setModalVisible] = useState(false);
154
-
155
- const createOrder = async () => {
156
- const res = await fetch('/create-order', {
157
- method: 'POST',
158
- });
159
- modalRef.current?.open({ formHtml: res.htmlStr });
160
- };
161
-
162
- return (
163
- <div className="alipay-component">
164
- <h3>自定义 Button - visible 参数唤起 modal</h3>
165
- <button onClick={() => setModalVisible(true)}>自定义 Button</button>
166
- <Alipay.Modal
167
- visible={modalVisible}
168
- onClose={() => setModalVisible(false)}
169
- alipayProps={{ formHtml }}
170
- />
171
- <h3>自定义 Button - ref open 方法唤起 modal</h3>
172
- <button onClick={() => createOrder()}>自定义 Button</button>
173
- <Alipay.Modal ref={modalRef} />
174
- </div>
175
- );
176
- };
177
-
178
- export default AlipayComponent;
150
+ 使用 `Alipay.Button`,通过 `children`、`className`、`style` 定制按钮,通过 `modalProps` 配置内置扫码弹窗。可通过按钮 ref 的 `openModal` / `closeModal` 主动开关。
179
151
 
180
- ```
152
+ 如果业务已有自定义触发器,可继续使用 `Alipay.Modal` 或直接导入 `AlipayModal`,通过 `visible` 或 ref 控制打开与关闭。
181
153
 
182
154
  #### 方式四:自定义承接
155
+
183
156
  直接引入二维码组件,自定义承接方式&展示时机。用户扫码完成支付后,支付宝会通知业务后端支付结果。
184
157
 
185
158
  ```typescript
@@ -201,6 +174,7 @@ export default AlipayComponent;
201
174
  ### H5 端
202
175
 
203
176
  #### 方式一:PayButton
177
+
204
178
  引入支付按钮,点击唤起等待支付弹窗(或蒙层),自动提交 iframe 表单唤起支付宝 App,无 App 时跳转浏览器。用户完成支付后,支付宝会通知业务后端支付结果。等待结果承接:支持弹窗和蒙层两种方式。
205
179
 
206
180
  ```typescript
@@ -232,6 +206,7 @@ export default MAlipayComponent;
232
206
  ```
233
207
 
234
208
  #### 方式二:MAlipay.Button
209
+
235
210
  引入 MAlipay.Button 按钮,点击唤起等待支付弹窗(或蒙层),自动提交 iframe 表单唤起支付宝 App,无 App 时跳转浏览器。用户完成支付后,支付宝会通知业务后端支付结果。
236
211
 
237
212
  ```typescript
@@ -262,8 +237,8 @@ const MAlipayComponent = () => {
262
237
  export default MAlipayComponent;
263
238
  ```
264
239
 
265
-
266
240
  #### 方式三:自定义表单
241
+
267
242
  引入 MAlipay 表单组件,自定义触发表单时机。用户完成支付后,支付宝会通知业务后端支付结果。
268
243
 
269
244
  ```typescript
@@ -289,6 +264,7 @@ export default MAlipayComponent;
289
264
  ### PC 端
290
265
 
291
266
  #### 方式一:PayButton
267
+
292
268
  引入支付按钮,点击唤起支付弹窗,展示微信二维码。用户扫码完成支付后,微信会通知业务后端支付结果。
293
269
 
294
270
  ```typescript
@@ -316,6 +292,7 @@ export default WechatComponent;
316
292
  ```
317
293
 
318
294
  #### 方式二:Wechat.Button
295
+
319
296
  引入 Wechat.Button 按钮,点击唤起支付弹窗,展示微信二维码。用户扫码完成支付后,微信会通知业务后端支付结果。
320
297
 
321
298
  ```typescript
@@ -340,48 +317,14 @@ const WechatComponent = () => {
340
317
  export default WechatComponent;
341
318
  ```
342
319
 
343
- #### 方式三:自定义按钮
344
- 使用自定义按钮,调用支付弹窗组件,展示二维码。用户扫码完成支付后,微信会通知业务后端支付结果。
320
+ #### 方式三:按钮样式与弹窗配置
345
321
 
346
- ```typescript
347
- import { useRef, useState } from 'react';
348
- import { Wechat, WechatModalRef } from 'pay-sdk-react';
322
+ 使用 `Wechat.Button`,通过 `children`、`className`、`style` 定制按钮,通过 `modalProps` 配置内置扫码弹窗。可通过按钮 ref 的 `openModal` / `closeModal` 主动开关。
349
323
 
350
- const wechatUrl = 'weixin://wxpay...';
351
-
352
- const WechatComponent = () => {
353
- const modalRef = useRef<WechatModalRef>(null);
354
-
355
- const [modalVisible, setModalVisible] = useState(false);
356
-
357
- const createOrder = async () => {
358
- const res = await fetch('/create-order', {
359
- method: 'POST',
360
- });
361
- modalRef.current?.open({ wechatUrl: res.url });
362
- };
363
-
364
- return (
365
- <div className="wechat-component">
366
- <h3>自定义 Button - visible 参数唤起 modal</h3>
367
- <button onClick={() => setModalVisible(true)}>自定义 Button</button>
368
- <Wechat.Modal
369
- visible={modalVisible}
370
- onClose={() => setModalVisible(false)}
371
- wechatProps={{ wechatUrl }}
372
- />
373
-
374
- <h3>自定义 Button - ref open 方法唤起 modal</h3>
375
- <button onClick={() => createOrder()}>自定义 Button</button>
376
- <Wechat.Modal ref={modalRef} />
377
- </div>
378
- );
379
- };
380
-
381
- export default WechatComponent;
382
- ```
324
+ 如果业务已有自定义触发器,可继续使用 `Wechat.Modal` 或直接导入 `WechatModal`,通过 `visible` 或 ref 控制打开与关闭。
383
325
 
384
326
  #### 方式四:自定义承接
327
+
385
328
  直接引入二维码组件,自定义承接和唤起方式。用户扫码完成支付后,微信会通知业务后端支付结果。
386
329
 
387
330
  ```typescript
@@ -404,6 +347,7 @@ export default WechatComponent;
404
347
  ### H5 端
405
348
 
406
349
  #### 方式一:PayButton
350
+
407
351
  引入支付按钮,点击唤起等待支付弹窗(或蒙层),自动打开微信支付链接,微信内浏览器自动唤起支付。用户完成支付后,微信会通知业务后端支付结果。等待结果承接:支持弹窗和蒙层两种方式。
408
352
 
409
353
  ```typescript
@@ -439,6 +383,7 @@ export default MWechatComponent;
439
383
  ```
440
384
 
441
385
  #### 方式二:MWechatButton
386
+
442
387
  引入 MWechatButton 按钮,点击唤起等待支付弹窗(或蒙层),自动打开微信支付链接,微信内浏览器自动唤起支付。用户完成支付后,微信会通知业务后端支付结果。
443
388
 
444
389
  ```typescript
@@ -465,6 +410,7 @@ export default MWechatComponent;
465
410
  引入支付按钮,点击唤起支付,自动打开 PayPal 支付链接,同时展示等待支付结果蒙层。PayPal 支付完成后,PayPal 官方会重定向到业务指定的结果页面,重定向地址由业务后端服务调用 PayPal 官方创建支付订单 API 时传入。
466
411
 
467
412
  ### 方式一:PayButton
413
+
468
414
  引入支付按钮,点击唤起支付,自动打开 PayPal 支付链接,同时展示等待支付结果蒙层。用户完成支付后,PayPal 会重定向到业务指定的结果页面。
469
415
 
470
416
  ```typescript
@@ -501,6 +447,7 @@ export default PaypalComponent;
501
447
  ```
502
448
 
503
449
  ### 方式二:PaypalButton
450
+
504
451
  引入 PaypalButton 按钮,点击唤起支付,自动打开 PayPal 支付链接,同时展示等待支付结果蒙层。用户完成支付后,PayPal 会重定向到业务指定的结果页面。
505
452
 
506
453
  ```typescript
@@ -556,6 +503,7 @@ export default PaypalComponent;
556
503
  引入支付组件,使用 Stripe 支付。Stripe 支付完成后,Stripe 官方会重定向到业务指定的结果页面,重定向地址由业务后端服务调用 Stripe 官方创建支付订单 API 时传入。
557
504
 
558
505
  ### 方式一:PayButton
506
+
559
507
  引入支付按钮,点击唤起支付 modal 或 popup,展示 Stripe 支付表单。用户完成支付后,Stripe 会重定向到业务指定的结果页面。
560
508
 
561
509
  ```typescript
@@ -582,6 +530,7 @@ export default StripeComponent;
582
530
  ```
583
531
 
584
532
  ### 方式二:Stripe.Button
533
+
585
534
  引入 Stripe.Button 按钮,点击唤起支付 modal 或 popup,展示 Stripe 支付表单。用户完成支付后,Stripe 会重定向到业务指定的结果页面。
586
535
 
587
536
  ```typescript
@@ -605,8 +554,8 @@ const StripeComponent = () => {
605
554
  export default StripeComponent;
606
555
  ```
607
556
 
608
-
609
557
  ### 方式三:自定义唤起 popup - 推荐 移动端 使用
558
+
610
559
  使用自定义按钮,调用 Stripe.Popup 组件,展示 Stripe 支付表单。用户完成支付后,Stripe 会重定向到业务指定的结果页面。
611
560
 
612
561
  ```typescript
@@ -650,6 +599,7 @@ export default StripeComponent;
650
599
  ```
651
600
 
652
601
  ### 方式四:自定义唤起 modal - 推荐 PC 端使用
602
+
653
603
  使用自定义按钮,调用 Stripe.Modal 组件,展示 Stripe 支付表单。用户完成支付后,Stripe 会重定向到业务指定的结果页面。
654
604
 
655
605
  ```typescript
@@ -694,6 +644,7 @@ export default StripeComponent;
694
644
  ```
695
645
 
696
646
  ### 方式五:Stripe 表单
647
+
697
648
  引入 Stripe 表单组件,自定义承接和展示时机。用户完成支付后,Stripe 会重定向到业务指定的结果页面。
698
649
 
699
650
  ```typescript
@@ -721,6 +672,7 @@ export default StripeComponent;
721
672
  引入支付组件,使用空中云汇支付。空中云汇支付完成后,空中云汇支付组件会回调 onSuccess 方法,业务执行后续逻辑。
722
673
 
723
674
  ### 方式一:PayButton
675
+
724
676
  引入支付按钮,点击唤起 popup 承接表单(推荐移动端),PC 端推荐唤起 modal。用户完成支付后,空中云汇支付组件会回调 onSuccess 方法,业务执行后续逻辑。
725
677
 
726
678
  ```typescript
@@ -770,6 +722,7 @@ export default AirwallexComponent;
770
722
  ```
771
723
 
772
724
  ### 方式二:自定义唤起 popup
725
+
773
726
  使用自定义按钮,调用 Airwallex.Popup 组件,展示空中云汇支付表单。用户完成支付后,空中云汇支付组件会回调 onSuccess 方法,业务执行后续逻辑。
774
727
 
775
728
  ```typescript
@@ -848,6 +801,7 @@ export default AirwallexComponent;
848
801
  ```
849
802
 
850
803
  ### 方式三:唤起 modal
804
+
851
805
  使用自定义按钮,调用 Airwallex.Modal 组件,展示空中云汇支付表单。用户完成支付后,空中云汇支付组件会回调 onSuccess 方法,业务执行后续逻辑。
852
806
 
853
807
  ```typescript
@@ -925,8 +879,8 @@ const AirwallexComponent = () => {
925
879
  export default AirwallexComponent;
926
880
  ```
927
881
 
928
-
929
882
  ### 方式四:自定义承接
883
+
930
884
  引入 Airwallex 表单组件,自定义承接和展示时机。用户完成支付后,空中云汇支付组件会回调 onSuccess 方法,业务执行后续逻辑。
931
885
 
932
886
  ```typescript
@@ -967,6 +921,7 @@ export default AirwallexComponent;
967
921
  ```
968
922
 
969
923
  ### 方式五:Airwallex.Button
924
+
970
925
  引入支付按钮,点击打开第三方支付链接,同时唤起等待支付结果蒙层。用户完成支付后,空中云汇会重定向到业务指定的结果页面。
971
926
 
972
927
  ```typescript
@@ -993,11 +948,200 @@ const AirwallexComponent = () => {
993
948
  export default AirwallexComponent;
994
949
  ```
995
950
 
951
+ ## PIX(巴西即时支付)
952
+
953
+ 引入支付组件,使用 PIX 巴西即时支付。用户扫码完成支付后,业务后端会收到支付通知。
954
+
955
+ ### PC 端
956
+
957
+ #### 方式一:PayButton
958
+
959
+ 引入 PayButton 按钮,点击唤起支付弹窗,展示 PIX 二维码。用户扫码完成支付后,业务后端会收到支付通知。
960
+
961
+ ```typescript
962
+ import { PayButton, PaymentMethod } from 'pay-sdk-react';
963
+
964
+ const PixComponent = () => {
965
+ const createOrder = async () => {
966
+ const res = await fetch('/create-order', {
967
+ method: 'POST',
968
+ });
969
+ return { pixCode: res.pixCode };
970
+ };
971
+
972
+ return (
973
+ <div className="pix-component">
974
+ <h3>PayButton-基础用法</h3>
975
+ <PayButton payMethod={PaymentMethod.PixPc} createOrder={createOrder}>
976
+ Pay Button
977
+ </PayButton>
978
+ </div>
979
+ );
980
+ };
981
+
982
+ export default PixComponent;
983
+ ```
984
+
985
+ #### 方式二:Pix.Button
986
+
987
+ 引入 Pix.Button,点击唤起支付弹窗,展示 PIX 二维码。用户扫码完成支付后,业务后端会收到支付通知。
988
+
989
+ ```typescript
990
+ import { Pix } from 'pay-sdk-react';
991
+
992
+ const PixComponent = () => {
993
+ const createOrder = async () => {
994
+ const res = await fetch('/create-order', {
995
+ method: 'POST',
996
+ });
997
+ return { pixCode: res.pixCode };
998
+ };
999
+
1000
+ return (
1001
+ <div className="pix-component">
1002
+ <h3>Pix.Button - modal</h3>
1003
+ <Pix.Button createOrder={createOrder}>PIX Button</Pix.Button>
1004
+ </div>
1005
+ );
1006
+ };
1007
+
1008
+ export default PixComponent;
1009
+ ```
1010
+
1011
+ #### 方式三:自定义按钮
1012
+
1013
+ 使用自定义按钮,调用支付弹窗组件,展示 PIX 二维码。用户扫码完成支付后,业务后端会收到支付通知。
1014
+
1015
+ ```typescript
1016
+ import { useRef, useState } from 'react';
1017
+ import { Pix, PixModalRef } from 'pay-sdk-react';
1018
+
1019
+ const pixCode = '00020126580014br.gov.bcb.pix...';
1020
+
1021
+ const PixComponent = () => {
1022
+ const modalRef = useRef<PixModalRef>(null);
1023
+
1024
+ const [modalVisible, setModalVisible] = useState(false);
1025
+
1026
+ const createOrder = async () => {
1027
+ const res = await fetch('/create-order', {
1028
+ method: 'POST',
1029
+ });
1030
+ modalRef.current?.open({ pixCode: res.pixCode });
1031
+ };
1032
+
1033
+ return (
1034
+ <div className="pix-component">
1035
+ <h3>自定义 Button - visible 参数唤起 modal</h3>
1036
+ <button onClick={() => setModalVisible(true)}>自定义 Button</button>
1037
+ <Pix.Modal
1038
+ visible={modalVisible}
1039
+ onClose={() => setModalVisible(false)}
1040
+ pixProps={{ pixCode }}
1041
+ />
1042
+
1043
+ <h3>自定义 Button - ref open 方法唤起 modal</h3>
1044
+ <button onClick={() => createOrder()}>自定义 Button</button>
1045
+ <Pix.Modal ref={modalRef} />
1046
+ </div>
1047
+ );
1048
+ };
1049
+
1050
+ export default PixComponent;
1051
+ ```
1052
+
1053
+ #### 方式四:自定义承接
1054
+
1055
+ 直接引入 PIX 二维码组件,自定义承接方式&展示时机。用户扫码完成支付后,业务后端会收到支付通知。
1056
+
1057
+ ```typescript
1058
+ import { Pix } from 'pay-sdk-react';
1059
+
1060
+ const pixCode = '00020126580014br.gov.bcb.pix...';
1061
+
1062
+ const PixComponent = () => {
1063
+ return (
1064
+ <div className="pix-component">
1065
+ <h3>Pix 表单 - 自定义承接</h3>
1066
+ <Pix pixCode={pixCode} />
1067
+ </div>
1068
+ );
1069
+ };
1070
+
1071
+ export default PixComponent;
1072
+ ```
1073
+
1074
+ ### H5 端
1075
+
1076
+ #### 方式一:PayButton
1077
+
1078
+ 引入支付按钮,点击唤起等待支付弹窗(或蒙层),自动打开 PIX 支付链接。用户完成支付后,业务后端会收到支付通知。
1079
+
1080
+ ```typescript
1081
+ import { PayButton, PaymentMethod } from 'pay-sdk-react';
1082
+
1083
+ const MPixComponent = () => {
1084
+ const createOrder = async () => {
1085
+ const res = await fetch('/create-order', {
1086
+ method: 'POST',
1087
+ });
1088
+ return { pixCode: res.pixCode };
1089
+ };
1090
+
1091
+ return (
1092
+ <div className="m-pix-component">
1093
+ <h3>PayButton - 基础用法</h3>
1094
+ <PayButton payMethod={PaymentMethod.PixH5} createOrder={createOrder}>
1095
+ Pay Button
1096
+ </PayButton>
1097
+ <h3>PayButton - mask</h3>
1098
+ <PayButton
1099
+ payMethod={PaymentMethod.PixH5}
1100
+ createOrder={createOrder}
1101
+ displayType="mask"
1102
+ >
1103
+ Pay Button
1104
+ </PayButton>
1105
+ </div>
1106
+ );
1107
+ };
1108
+
1109
+ export default MPixComponent;
1110
+ ```
1111
+
1112
+ #### 方式二:MPix.Button
1113
+
1114
+ 引入 MPix.Button 按钮,点击唤起等待支付弹窗(或蒙层),自动打开 PIX 支付链接。用户完成支付后,业务后端会收到支付通知。
1115
+
1116
+ ```typescript
1117
+ import { MPixButton } from 'pay-sdk-react';
1118
+
1119
+ const pixCode = '00020126580014br.gov.bcb.pix...';
1120
+
1121
+ const MPixComponent = () => {
1122
+ return (
1123
+ <div className="m-pix-component">
1124
+ <h3>PIX Button - modal</h3>
1125
+ <MPixButton displayType="modal" pixCode={pixCode}>
1126
+ PIX Button
1127
+ </MPixButton>
1128
+ <h3>PIX Button - mask</h3>
1129
+ <MPixButton displayType="mask" pixCode={pixCode}>
1130
+ PIX Button
1131
+ </MPixButton>
1132
+ </div>
1133
+ );
1134
+ };
1135
+
1136
+ export default MPixComponent;
1137
+ ```
1138
+
996
1139
  ## Payssion
997
1140
 
998
1141
  引入支付组件,使用 Payssion 支付。Payssion 支付完成后,Payssion 官方会重定向到业务指定的结果页面,重定向地址由业务后端服务调用 Payssion 官方创建支付订单 API 时传入。
999
1142
 
1000
1143
  ### 方式一:PayButton
1144
+
1001
1145
  引入支付按钮,点击打开第三方支付链接,同时唤起等待支付结果蒙层。用户完成支付后,Payssion 会重定向到业务指定的结果页面。
1002
1146
 
1003
1147
  ```typescript
@@ -1033,6 +1177,7 @@ export default PayssionComponent;
1033
1177
  ```
1034
1178
 
1035
1179
  ### 方式二:PayssionButton
1180
+
1036
1181
  引入 PayssionButton 按钮,点击打开第三方支付链接,同时唤起等待支付结果蒙层。用户完成支付后,Payssion 会重定向到业务指定的结果页面。
1037
1182
 
1038
1183
  ```typescript
@@ -1076,4 +1221,240 @@ const PayssionComponent = () => {
1076
1221
  };
1077
1222
 
1078
1223
  export default PayssionComponent;
1079
- ```
1224
+ ```
1225
+
1226
+ # 开发与维护规范
1227
+
1228
+ 维护本 SDK 前请阅读 [AGENTS.md](./AGENTS.md)。Agent 开发与评审流程见 [pay-sdk-development Skill](./.agents/skills/pay-sdk-development/SKILL.md)。
1229
+
1230
+ 所有变更应保持现有公开 API 的兼容性,并同步维护中英文 README、对应 Storybook 场景和版本记录。新增公开 API 使用 `@since` 记录首次支持版本;明确弃用时使用 `@deprecated` 说明替代方案。版本遵循 [SemVer 2.0.0](https://semver.org/spec/v2.0.0.html)。
1231
+
1232
+ ## 支付执行扩展(1.2.0)
1233
+
1234
+ 本节扩展在 1.2.0 引入。新 API 与属性使用 `@since 1.2.0` 记录。
1235
+
1236
+ 原 PC 扫码入口 `WechatModal`、`AlipayModal`、`Wechat.Modal` 和 `Alipay.Modal`,以及 `WechatModalRef`、`AlipayModalRef` 类型继续可用。也可以通过 `WechatButton` 或 `AlipayButton` 的 `modalProps` 配置按钮内置弹窗。
1237
+
1238
+ SDK 执行跳转、二维码、可信支付 HTML、Stripe 内嵌、Airwallex 内嵌/托管,以及对应的加载、取消、错误和资源清理。地区身份、可用渠道、创建订单、一次性/订阅业务选择、最终支付状态和权益由调用方负责。`completed`、`onOpen`、第三方 `onComplete` 与窗口关闭均不能代替后端订单确认。
1239
+
1240
+ ### 新入口与兼容关系
1241
+
1242
+ | 入口/属性 | 能力与兼容关系 | 首次支持 |
1243
+ | ------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------- | ---------------------- |
1244
+ | `useStripeCheckout`、`Stripe.CheckoutButton`、`StripeCheckoutButton` | 使用业务后端返回的 Checkout URL;不需要 Stripe 公钥。旧 `Stripe` / `Stripe.Button` 继续使用 EmbeddedCheckout | 1.2.0 |
1245
+ | `useAirwallexCheckout`、`Airwallex.CheckoutButton`、`AirwallexCheckoutButton` | URL 跳转,或使用官方 `@airwallex/components-sdk` 凭证执行托管 Checkout。旧内嵌组件与 URL 按钮保留 | 1.2.0 |
1246
+ | `Paypal.SmartButton`、`PaypalSmartButton`、`Paypal.Provider`、`PaypalProvider` | 封装官方 React PayPal Buttons / ScriptProvider。旧 `PaypalButton` 以及新增命名空间中的 `Paypal.Button` 继续按 URL 执行 | 1.2.0 |
1247
+ | 七种 PC 按钮的 `executionOptions` | 显式启用受管理的 **createOrder** 流程;不传保持旧执行分支。适用于 Wechat、Alipay、Pix、Stripe、Airwallex、PaypalButton、PayssionButton | 1.2.0 |
1248
+ | `Wechat.qrProps`、`Pix.qrProps`、Pix 操作属性、Alipay 区域配置 | 可选展示配置,不内置业务渠道、Logo 地址或国际化框架 | 1.2.0 |
1249
+ | `PayModalProps.title` 扩展为 `ReactNode` | 原字符串标题继续有效;Wechat / Alipay / Pix / Stripe / Airwallex 的 Modal 透传公共弹窗属性 | 1.2.0(类型扩展) |
1250
+
1251
+ Hook 通过主入口 named export,模块内部实现位于 `components/Stripe/hooks/` 和 `components/Airwallex/hooks/`;按钮复用同一 Hook。Hook 本身不渲染 DOM,也不在挂载时自动下单或跳转。公开导入只使用 `pay-sdk-react` 及 exports 中声明的 CSS 入口,不使用 `pay-sdk-react/es/...` 内部路径。
1252
+
1253
+ ```tsx
1254
+ import {
1255
+ useStripeCheckout,
1256
+ Stripe,
1257
+ Airwallex,
1258
+ OpenPayUrlMode,
1259
+ } from 'pay-sdk-react';
1260
+ import 'pay-sdk-react/css/index.css';
1261
+
1262
+ // 业务自备按钮:Hook 不占页面位置。
1263
+ const Checkout = () => {
1264
+ const { openCheckout, closeCheckout, loading, error } = useStripeCheckout({
1265
+ redirectOptions: { openMode: OpenPayUrlMode.Href },
1266
+ });
1267
+ return (
1268
+ <>
1269
+ <button
1270
+ disabled={loading}
1271
+ onClick={() =>
1272
+ openCheckout(async (signal) => {
1273
+ const response = await fetch('/your-api/create-stripe-checkout', {
1274
+ method: 'POST',
1275
+ signal,
1276
+ });
1277
+ if (!response.ok) throw new Error('Unable to create checkout');
1278
+ const data = await response.json();
1279
+ return { url: data.checkoutUrl };
1280
+ })
1281
+ }
1282
+ >
1283
+ 前往支付
1284
+ </button>
1285
+ <button onClick={closeCheckout}>取消本次前端执行</button>
1286
+ {error ? <span>{error.code}</span> : null}
1287
+ </>
1288
+ );
1289
+ };
1290
+
1291
+ // SDK 按钮:createOrder 优先于直接 url / target。
1292
+ <Stripe.CheckoutButton
1293
+ url={checkoutUrl}
1294
+ redirectOptions={{ openMode: OpenPayUrlMode.Href }}
1295
+ />;
1296
+ <Airwallex.CheckoutButton
1297
+ initOptions={{ env: 'demo' }}
1298
+ target={{
1299
+ checkout: {
1300
+ mode: 'payment',
1301
+ intent_id: paymentIntentId,
1302
+ client_secret: clientSecret,
1303
+ currency: 'USD',
1304
+ successUrl: returnUrl,
1305
+ },
1306
+ }}
1307
+ />;
1308
+ ```
1309
+
1310
+ 示例里的地址、URL 和支付凭证由调用方提供;必须与后端建立的会话模式对应。Airwallex 订阅传 `mode: 'recurring'`、`customer_id`、`client_secret`、`currency` 及官方支持的 `recurringOptions`;SDK 完整透传,不生成订阅计划。同页官方 SDK 的环境及初始化配置应保持一致。
1311
+
1312
+ ### Checkout 与公共执行 API
1313
+
1314
+ 以下均首次支持于 **1.2.0**。除明确标为必填外均可选。
1315
+
1316
+ | 名称 | 类型 | 必填/默认 | 说明 |
1317
+ | ------------------------------- | ---------------------------------------------------------------- | --------------------- | ---------------------------------------------------------------------------------------------------------------------- |
1318
+ | `openCheckout(source)` | `CheckoutSource<T> => Promise<PaymentExecutionResult>` | 方法参数必填 | `T` 是 Stripe 的 `{url}` 或 Airwallex 的 `{url} / {checkout}`;回调接收 `AbortSignal`,可以返回目标、Promise 或 `null` |
1319
+ | `closeCheckout()` | `() => void` | — | 取消待执行流程并关闭当前实例拥有的支付窗口 |
1320
+ | `cancel()` | `() => void` | — | 取消当前前端异步执行;不关闭已打开窗口、不撤销业务订单 |
1321
+ | `loading / status / error` | `boolean / PaymentExecutionStatus / PaymentExecutionError或null` | `false / Idle / null` | 当前实例执行状态;错误不包含原始凭证或订单 HTML |
1322
+ | 返回值 `status / value / error` | `PaymentExecutionStatus / 可选执行值 / 可选错误` | `status` 必填 | `Idle`、`Pending`、`Completed`、`Cancelled`、`Failed`;均为前端阶段,Checkout 不提供业务支付成功值 |
1323
+ | `beforePay` | `() => boolean或Promise<boolean>` | 默认继续 | 返回 false 中止,且不会调用 createOrder |
1324
+ | `onLoadingChange` | `(loading: boolean) => void` | 无 | 从执行前校验、createOrder 到初始化/发起跳转;不覆盖后续第三方支付等待时间 |
1325
+ | `onPaymentError` | `(error: PaymentExecutionError) => void` | 无 | 与 Promise 返回的 Failed 结果表示同一次失败;SDK 不主动抛出该执行错误 |
1326
+ | `onCancel` | `() => void` | 无 | 显式取消、beforePay false 或 source 返回 null;卸载仅静默清理 |
1327
+ | `redirectOptions` | `PaymentRedirectOptions` | 见下表 | URL 分支的打开方式和窗口管理;不用于官方凭证分支 |
1328
+ | Airwallex `initOptions` | `Omit<SDKOptions,'enabledElements'>` | 官方默认 | 官方初始化;SDK 设置 enabledElements 为 payments;建议显式指定环境 |
1329
+ | Stripe 按钮 `url` | `string` | 无 | HTTP(S) 地址;可用 createOrder 代替 |
1330
+ | Airwallex 按钮 `target` | `AirwallexCheckoutTarget` | 无 | URL 与官方凭证互斥;可用 createOrder 代替 |
1331
+ | 两种按钮 `createOrder` | `(signal) => Promise<T或null>` | 无 | 点击触发、优先于直接目标。可传旧 Button 的 disabled/loading/children 等基础属性 |
1332
+
1333
+ 同一实例执行中再次调用返回 `Pending`,不会重复创建订单。取消或卸载后会 abort 信号并忽略迟到结果;业务请求是否真正停止取决于调用方是否使用 signal。取消立即更新可观察状态;未响应 abort 的业务 Promise 仍需自身结束,SDK 不会替业务中断网络或第三方扣款。消费者事件回调自行避免抛错。
1334
+
1335
+ `PaymentErrorCode` 包含 `InvalidParameters`、`BrowserUnavailable`、`WindowBlocked`、`InitializationFailed`、`ExecutionFailed`。失败后可重新调用。URL 只允许 HTTP(S),支持相对地址;移动端 App 协议继续使用原 H5 组件。
1336
+
1337
+ | `PaymentRedirectOptions` 字段 | 类型 | 必填/默认 | 说明(均 1.2.0) |
1338
+ | ----------------------------- | ---------------------------------- | -------------------------- | -------------------------------------------------------------------------------------------------- |
1339
+ | `openMode` | `OpenPayUrlMode` | `Href` | URL 支持 Href / Replace / Window。Airwallex **凭证**托管仅支持当前页跳转;配置其他模式返回参数错误 |
1340
+ | `windowName / windowFeatures` | `string` | 每实例独立名称/浏览器默认 | 仅 Window;自定义相同 name 可能由浏览器复用窗口,建议保持默认 |
1341
+ | `closeWindowOnUnmount` | `boolean` | `true` | 卸载时只关闭当前实例拥有的窗口;设 false 保留第三方窗口 |
1342
+ | `onOpen` | `(url: string) => void` | 无 | URL 已发起打开,非支付成功;凭证分支不发此事件 |
1343
+ | `onWindowClose` | `() => void` | 无 | 轮询观察到用户关闭窗口;主动 closeCheckout 和卸载不发送此事件 |
1344
+ | `allowedMessageOrigins` | `string[]` | 无 | 与 messageValidator 同时配置才接收跨窗口消息 |
1345
+ | `messageValidator` | `(event: MessageEvent) => boolean` | 无 | 在 source、origin 验证后,由业务核验当前订单标识/nonce,不仅匹配固定文字 |
1346
+ | `onMessage` | `(event: MessageEvent) => void` | 无 | 只接收当前实例窗口的可信且通过校验消息,仍需后端确认订单 |
1347
+
1348
+ 新窗口可能被浏览器拦截,尤其异步创建订单耗时较长时;通过 WindowBlocked 提供当前页重试。普通重渲染不重开窗口;再次打开前会关闭本实例原窗口。同页跳转后原页面不能继续观察第三方界面。
1349
+
1350
+ ### 扫码、HTML、弹窗和品牌配置
1351
+
1352
+ 下列新增属性均为可选、首次支持 **1.2.0**,不传保留旧默认。
1353
+
1354
+ | 对象/字段 | 类型 | 默认 | 说明 |
1355
+ | ------------------------------------- | --------------------------------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
1356
+ | Wechat / Pix `qrProps` | `PaymentQrAppearance` | 无 | `size?:number`、`overlay?:ReactNode`、`loadingContent/errorContent?:ReactNode`、`onQrReady?:(imageUrl)=>void`、`onQrError?:()=>void` |
1357
+ | `qrProps.classNames / styles` | 区域映射 | 无 | `root/container/image/tip/overlay`;size 保持正方形,overlay 尺寸由调用方控制,避免遮盖过多二维码 |
1358
+ | Pix `showCode` | `boolean` | `false` | 显示完整支付码;原 showCopyButton 仍只控制复制按钮 |
1359
+ | Pix `copyText / copiedText` | `ReactNode` | 原文案 | 复制前/后内容,可传业务翻译;复制失败不显示成功 |
1360
+ | Pix `onCopy / onCopyError` | `() => void` | 无 | 分别为成功和失败通知;剪贴板失败尝试兼容复制并清理临时 DOM |
1361
+ | Pix `confirmText / onConfirm` | `ReactNode / ()=>void` | 无 | 提供 confirmText 显示确认按钮,只表达用户操作意图 |
1362
+ | Pix `actionClassNames / actionStyles` | 区域映射 | 无 | `code/copy/confirm` |
1363
+ | Alipay `classNames / styles` | 区域映射 | 无 | `root/iframe/tip`;样式优先于 wrapperStyle / iframeStyle;无法修改第三方 iframe 内部页面 |
1364
+ | Alipay `loadingContent` | `ReactNode` | 原加载组件 | 显式配置时 HTML 更新重新进入加载,iframe load 后移除 |
1365
+ | Alipay `onFrameLoad / onFrameError` | `()=>void` | 无 | 页面加载/浏览器能观测的加载失败,非支付结果;跨域 iframe 错误观测受浏览器限制 |
1366
+ | Modal `title` | `ReactNode` | 原默认 | 字符串或复杂标题,原调用不必迁移 |
1367
+ | Modal `classNames / styles` | 区域映射 | 无 | `root/mask/content/close/icon/title/description/body/footer`;新 styles 在对应旧 style/contentStyle 之后合并 |
1368
+ | Modal `closeIcon / closeLabel` | `ReactNode / string` | `× / 关闭` | 关闭图标及无障碍名称,仍受 showClose 控制 |
1369
+ | Payssion `children` | `ReactNode` | Payssion 图文 | 调用方提供完整图文。null、空字符串和 0 会按传入值渲染。蒙层标题用 `maskProps.title` 设置。 |
1370
+
1371
+ ```tsx
1372
+ import { Wechat, Pix, PayssionButton } from 'pay-sdk-react';
1373
+ <Wechat.Button
1374
+ modalProps={{
1375
+ title: <strong>微信扫码支付</strong>,
1376
+ styles: { content: { width: 420 }, title: { color: '#1677ff' } },
1377
+ wechatProps: {
1378
+ wechatUrl: code,
1379
+ qrProps: { size: 220, overlay: <BrandIcon /> },
1380
+ },
1381
+ }}
1382
+ />;
1383
+ <Pix
1384
+ pixCode={pixCode}
1385
+ showCode
1386
+ copyText="复制支付码"
1387
+ copiedText="已复制"
1388
+ confirmText="查询订单"
1389
+ onConfirm={checkBusinessOrder}
1390
+ qrProps={{ size: 220 }}
1391
+ />;
1392
+ <PayssionButton payssionUrl={paymentUrl} maskProps={{ title: 'OXXO' }}>
1393
+ <img src={logoUrl} alt="" width={80} height={24} />
1394
+ 使用 OXXO 支付
1395
+ </PayssionButton>;
1396
+ ```
1397
+
1398
+ `executionOptions` 仅增强旧 PC 按钮的异步 createOrder:同步重复点击锁、加载、取消后忽略响应、错误通知及失败重试;不改旧 PayMask 的窗口协议。新 URL 窗口管理使用 Checkout Hook。调用旧 ref 的 closeModal/closePopup/closePayment 会取消待处理创建流程。没有 createOrder 时仍使用旧直接参数/ref 路径;beforePay 不拦截这条路径。新流程的 onClick 先执行,preventDefault 可阻止创建;不传 executionOptions 时保持旧回调顺序。
1399
+
1400
+ ### 内嵌事件与 PayPal 官方按钮
1401
+
1402
+ 下列新增项首次支持 **1.2.0**。
1403
+
1404
+ | 对象/字段 | 类型 | 必填/默认 | 说明 |
1405
+ | ---------------------------------------------------------------------------------------------- | --------------------------- | ------------- | ---------------------------------------------------------------------------------------------------- |
1406
+ | Stripe `checkoutEvents.onInitialized / onInitializationError` | `()=>void` | 无 | Stripe.js 初始化完成/失败;不表示内嵌 iframe 已可见 |
1407
+ | Stripe `checkoutEvents.onComplete` | `()=>void` | 无 | 官方 EmbeddedCheckout 完成通知,业务仍需验证订单 |
1408
+ | Stripe `instanceKey` | `string` | 无 | 显式替换 Provider 会话;更换 clientSecret 时同时更换 instanceKey |
1409
+ | Stripe Modal / Popup `closeOnComplete` | `boolean` | `false` | 完成后请求关闭;受控 visible 仍由调用方更新 |
1410
+ | Airwallex `instanceOptions` | `{containerId?:string}` | 无 | `{}` 显式启用独立 DOM 容器、监听和卸载管理;不传走原实现。containerId 可选 |
1411
+ | Airwallex Modal / Popup `closeOnSuccess / closeOnError` | `boolean` | `true / true` | 可关闭非受控弹层的自动关闭;受控调用方监听 onSuccess/onError 更新 visible |
1412
+ | `PaypalSmartButton.scriptOptions` | 官方 ScriptProvider options | 无 | 有配置时组件提供 Provider;不传时必须已有 Paypal.Provider,不能两者都缺失。同页优先共用一个 Provider |
1413
+ | `loadingContent / errorContent` | `ReactNode` | 官方行为 | 脚本加载/加载失败内容 |
1414
+ | `onScriptError` | `()=>void` | 无 | 官方脚本失败通知,与 PayPalButtons 的 onError 分开 |
1415
+ | 官方 `createOrder / createSubscription / onApprove / onCancel / onError / style / disabled` 等 | 官方 PayPalButtonsProps | 遵循官方 | 完整透传,创建、批准、capture、订阅确认由业务回调处理;SDK 不默认 capture |
1416
+
1417
+ ```tsx
1418
+ import { Paypal } from 'pay-sdk-react';
1419
+ <Paypal.Provider options={{ clientId: paypalClientId, currency: 'USD' }}>
1420
+ <Paypal.SmartButton
1421
+ createOrder={createPaypalOrder}
1422
+ onApprove={approveAndConfirmOrder}
1423
+ onCancel={onUserCancel}
1424
+ onError={showExecutionError}
1425
+ />
1426
+ </Paypal.Provider>;
1427
+ // 订阅需使用官方 vault / intent 配置及 createSubscription,不能混用订单模式。
1428
+ ```
1429
+
1430
+ ### Storybook 与验证
1431
+
1432
+ 支付示例按 `Components/{支付方式}/{入口}` 归类,覆盖原有 PC/H5 及新增 Checkout、SmartButton。查看[参数与场景矩阵](./docs/payment-storybook-matrix.md)和[可检查的场景清单](./docs/payment-storybook-coverage.json)。Storybook 使用本地第三方、窗口、二维码与剪贴板模拟,发布 SDK 使用真实实现。
1433
+
1434
+ - `pnpm test`:Vitest / jsdom 回归,覆盖重复调用、取消/卸载后响应、可信消息、窗口拦截、StrictMode、多实例与展示兼容。
1435
+ - `pnpm run test-storybook --url http://localhost:6006`:用户启动 Storybook 后执行带 sdk-test 标签的浏览器场景;不自动启动服务。
1436
+ - `pnpm run build-storybook`:构建示例;不能代替上述 play 执行,也不代表真实支付验证。
1437
+ - [场景与验证对应表](./docs/checkout-verification.md) 说明浏览器原生行为及真实第三方沙箱的验证边界。
1438
+
1439
+ 浏览器 Runner 默认使用 Playwright 管理的 Chromium;可用 `PAY_SDK_CHROMIUM_PATH=/绝对路径/Chromium` 指定已有可执行文件,无需修改仓库配置。
1440
+
1441
+ 构建后运行 `pnpm run test:package`,验证 CommonJS 入口、SSR 渲染、新命名空间、无需 Node 全局的 UMD、类型及 CSS 文件。此检查不创建订单。
1442
+
1443
+ `scriptOptions` 用于官方脚本初始化。更换 PayPal 的 clientId、currency 或 intent 时,显式更换组件/Provider 的 key,或使用官方共享 Provider 的 resetOptions;不要假定普通重渲染会重新加载脚本。
1444
+
1445
+ ### Storybook 场景位置与维护
1446
+
1447
+ `components/shared/` 下的支付枚举放在 `enums/payment.ts`,共享类型与支付执行错误类放在 `entitys/payment.ts`。业务侧从包根导入公开名称。
1448
+
1449
+ 公开 API 的 JSDoc 统一使用多行块,`/**` 与 `*/` 各占一行,`@zh`、`@en`、`@since` 等标签分别成行,放在对应声明或字段上方。格式整理保留已有说明与首次支持版本,不改变类型、默认值或执行行为。
1450
+
1451
+ 示例显示名统一为“分类|具体场景”,按需追加参数来源、PC/H5、Modal/Popup/Mask 或验证行为。例如“基础|支付宝 H5|直接传入表单|确认弹窗”和“异步|受管理下单慢响应与重复点击锁”。基础演示与自动交互回归明确区分;不再依赖导出名生成含义不明的数字后缀。只改显示名,原 Story ID、链接与执行行为保留。命名检查覆盖全部 529 个示例,登记清单的名称同步校验;详见[命名规则与对照](./docs/payment-storybook-matrix.md#场景命名)。
1452
+
1453
+ 原有 Button、Form、Modal、Popup 的新参数场景直接补在原节点。新增入口位于 `Components/Stripe/CheckoutButton`、`Components/Stripe/CheckoutHook`、对应的 Airwallex 节点,以及 `Components/Paypal/SmartButton`。Payssion 的八个渠道示例通过 children 传入图文,由调用方设置尺寸、样式和蒙层标题。
1454
+
1455
+ - `pnpm run typecheck:stories`:检查全部示例和辅助演示代码的类型。
1456
+ - `pnpm run test:story-coverage`:检查场景登记、目录归类、显式 play、PaymentMethod 支持边界、Airwallex Element 类型及 SDK 字段签名变化。
1457
+ - `pnpm run test-storybook --url http://localhost:6006`:执行全部 sdk-test 场景;必须先由维护者启动 Storybook。
1458
+ - 定向排查可设置 `PAY_SDK_STORY_FILES='Pix.stories.tsx;Wechat.stories.tsx'`,不设置则运行全部登记场景。
1459
+
1460
+ 覆盖以 SDK 已实现的执行分支、业务参数、默认与定制、异步及资源状态为单位;不声称穷举第三方任意 options、CSS 取值或真实商户环境。仅渲染的外观画廊、交互断言、原生指针验证和沙箱支付分别记录。