pay-sdk-react 1.1.14 → 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 (119) hide show
  1. package/README.md +241 -78
  2. package/README.zh-CN.md +243 -79
  3. package/dist/css/index.css +11 -0
  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/Alipay/alipay-button.js +26 -7
  20. package/dist/es/Alipay/alipay.js +39 -12
  21. package/dist/es/Alipay/interface.d.ts +26 -1
  22. package/dist/es/Paypal/index.d.ts +2 -0
  23. package/dist/es/Paypal/index.js +3 -1
  24. package/dist/es/Paypal/interface.d.ts +40 -0
  25. package/dist/es/Paypal/paypal-button.js +24 -3
  26. package/dist/es/Paypal/paypal-smart-button.d.ts +4 -0
  27. package/dist/es/Paypal/paypal-smart-button.js +48 -0
  28. package/dist/es/Payssion/interface.d.ts +7 -0
  29. package/dist/es/Payssion/payssion-button.js +25 -4
  30. package/dist/es/Pix/interface.d.ts +67 -0
  31. package/dist/es/Pix/pix-button.js +26 -7
  32. package/dist/es/Pix/pix-enhanced.d.ts +4 -0
  33. package/dist/es/Pix/pix-enhanced.js +182 -0
  34. package/dist/es/Pix/pix.d.ts +1 -1
  35. package/dist/es/Pix/pix.js +6 -1
  36. package/dist/es/Pix/style/index.css +11 -0
  37. package/dist/es/Pix/style/index.min.css +1 -1
  38. package/dist/es/Stripe/hooks/useStripeCheckout.d.ts +7 -0
  39. package/dist/es/Stripe/hooks/useStripeCheckout.js +86 -0
  40. package/dist/es/Stripe/index.d.ts +4 -0
  41. package/dist/es/Stripe/index.js +5 -1
  42. package/dist/es/Stripe/interface.d.ts +120 -0
  43. package/dist/es/Stripe/stripe-button.js +32 -10
  44. package/dist/es/Stripe/stripe-checkout-button.d.ts +4 -0
  45. package/dist/es/Stripe/stripe-checkout-button.js +70 -0
  46. package/dist/es/Stripe/stripe-modal.js +19 -2
  47. package/dist/es/Stripe/stripe-popup.js +13 -2
  48. package/dist/es/Stripe/stripe.js +38 -4
  49. package/dist/es/Wechat/interface.d.ts +13 -0
  50. package/dist/es/Wechat/wechat-button.js +26 -7
  51. package/dist/es/Wechat/wechat-content.d.ts +4 -0
  52. package/dist/es/Wechat/wechat-content.js +61 -0
  53. package/dist/es/Wechat/wechat.d.ts +1 -1
  54. package/dist/es/Wechat/wechat.js +5 -1
  55. package/dist/es/hooks/useLatestCallback.d.ts +1 -0
  56. package/dist/es/hooks/useLatestCallback.js +8 -0
  57. package/dist/es/hooks/useManagedOrder.d.ts +8 -0
  58. package/dist/es/hooks/useManagedOrder.js +67 -0
  59. package/dist/es/hooks/usePaymentExecution.d.ts +13 -0
  60. package/dist/es/hooks/usePaymentExecution.js +176 -0
  61. package/dist/es/hooks/usePaymentQr.d.ts +6 -0
  62. package/dist/es/hooks/usePaymentQr.js +52 -0
  63. package/dist/es/hooks/usePaymentRedirect.d.ts +5 -0
  64. package/dist/es/hooks/usePaymentRedirect.js +83 -0
  65. package/dist/es/index.d.ts +33 -6
  66. package/dist/es/index.js +19 -1
  67. package/dist/es/pay-modal/interface.d.ts +22 -2
  68. package/dist/es/pay-modal/pay-modal.js +36 -16
  69. package/dist/es/shared/entitys/payment.d.ts +227 -0
  70. package/dist/es/shared/entitys/payment.js +75 -0
  71. package/dist/es/shared/enums/index.d.ts +1 -88
  72. package/dist/es/shared/enums/index.js +1 -91
  73. package/dist/es/shared/enums/payment.d.ts +162 -0
  74. package/dist/es/shared/enums/payment.js +168 -0
  75. package/dist/es/shared/index.d.ts +2 -0
  76. package/dist/es/shared/index.js +2 -1
  77. package/dist/lib/Airwallex/airwallex-button.js +31 -10
  78. package/dist/lib/Airwallex/airwallex-checkout-button.js +52 -0
  79. package/dist/lib/Airwallex/airwallex-managed.js +86 -0
  80. package/dist/lib/Airwallex/airwallex-modal.js +4 -2
  81. package/dist/lib/Airwallex/airwallex-popup.js +4 -2
  82. package/dist/lib/Airwallex/airwallex.js +9 -1
  83. package/dist/lib/Airwallex/hooks/useAirwallexCheckout.js +83 -0
  84. package/dist/lib/Airwallex/index.js +18 -1
  85. package/dist/lib/Alipay/alipay-button.js +21 -6
  86. package/dist/lib/Alipay/alipay.js +36 -9
  87. package/dist/lib/Paypal/index.js +17 -1
  88. package/dist/lib/Paypal/paypal-button.js +19 -2
  89. package/dist/lib/Paypal/paypal-smart-button.js +45 -0
  90. package/dist/lib/Payssion/payssion-button.js +20 -3
  91. package/dist/lib/Pix/pix-button.js +21 -6
  92. package/dist/lib/Pix/pix-enhanced.js +143 -0
  93. package/dist/lib/Pix/pix.js +6 -1
  94. package/dist/lib/Pix/style/index.css +11 -0
  95. package/dist/lib/Pix/style/index.min.css +1 -1
  96. package/dist/lib/Stripe/hooks/useStripeCheckout.js +41 -0
  97. package/dist/lib/Stripe/index.js +18 -1
  98. package/dist/lib/Stripe/stripe-button.js +28 -10
  99. package/dist/lib/Stripe/stripe-checkout-button.js +50 -0
  100. package/dist/lib/Stripe/stripe-modal.js +12 -1
  101. package/dist/lib/Stripe/stripe-popup.js +12 -1
  102. package/dist/lib/Stripe/stripe.js +30 -1
  103. package/dist/lib/Wechat/wechat-button.js +21 -6
  104. package/dist/lib/Wechat/wechat-content.js +65 -0
  105. package/dist/lib/Wechat/wechat.js +3 -1
  106. package/dist/lib/hooks/useLatestCallback.js +13 -0
  107. package/dist/lib/hooks/useManagedOrder.js +29 -0
  108. package/dist/lib/hooks/usePaymentExecution.js +113 -0
  109. package/dist/lib/hooks/usePaymentQr.js +51 -0
  110. package/dist/lib/hooks/usePaymentRedirect.js +87 -0
  111. package/dist/lib/index.js +57 -1
  112. package/dist/lib/pay-modal/pay-modal.js +33 -16
  113. package/dist/lib/shared/entitys/payment.js +61 -0
  114. package/dist/lib/shared/enums/index.js +11 -91
  115. package/dist/lib/shared/enums/payment.js +172 -0
  116. package/dist/lib/shared/index.js +12 -1
  117. package/dist/umd/pay-sdk-react.umd.js +6488 -7731
  118. package/dist/umd/pay-sdk-react.umd.js.map +1 -1
  119. package/package.json +17 -3
package/README.zh-CN.md CHANGED
@@ -49,7 +49,7 @@ import 'pay-sdk-react/dist/css/index.min.css';
49
49
 
50
50
  function App() {
51
51
  return (
52
- <PayButton payMethod={PaymentMethod.PaypalH5} paypalUrl={''}, />
52
+ <PayButton payMethod={PaymentMethod.PaypalH5} paypalUrl={''} />
53
53
  );
54
54
  }
55
55
 
@@ -145,47 +145,11 @@ const AlipayComponent = () => {
145
145
  export default AlipayComponent;
146
146
  ```
147
147
 
148
- #### 方式三:自定义按钮
149
-
150
- 使用自定义按钮,调用支付弹窗组件,展示二维码。用户扫码完成支付后,支付宝会通知业务后端支付结果。
148
+ #### 方式三:按钮样式与弹窗配置
151
149
 
152
- ```typescript
153
- import { useRef, useState } from 'react';
154
- import { Alipay, AlipayModalRef } from 'pay-sdk-react';
150
+ 使用 `Alipay.Button`,通过 `children`、`className`、`style` 定制按钮,通过 `modalProps` 配置内置扫码弹窗。可通过按钮 ref 的 `openModal` / `closeModal` 主动开关。
155
151
 
156
- const formHtml = '<form ... />';
157
-
158
- const AlipayComponent = () => {
159
- const modalRef = useRef<AlipayModalRef>(null);
160
-
161
- const [modalVisible, setModalVisible] = useState(false);
162
-
163
- const createOrder = async () => {
164
- const res = await fetch('/create-order', {
165
- method: 'POST',
166
- });
167
- modalRef.current?.open({ formHtml: res.htmlStr });
168
- };
169
-
170
- return (
171
- <div className="alipay-component">
172
- <h3>自定义 Button - visible 参数唤起 modal</h3>
173
- <button onClick={() => setModalVisible(true)}>自定义 Button</button>
174
- <Alipay.Modal
175
- visible={modalVisible}
176
- onClose={() => setModalVisible(false)}
177
- alipayProps={{ formHtml }}
178
- />
179
- <h3>自定义 Button - ref open 方法唤起 modal</h3>
180
- <button onClick={() => createOrder()}>自定义 Button</button>
181
- <Alipay.Modal ref={modalRef} />
182
- </div>
183
- );
184
- };
185
-
186
- export default AlipayComponent;
187
-
188
- ```
152
+ 如果业务已有自定义触发器,可继续使用 `Alipay.Modal` 或直接导入 `AlipayModal`,通过 `visible` 或 ref 控制打开与关闭。
189
153
 
190
154
  #### 方式四:自定义承接
191
155
 
@@ -353,47 +317,11 @@ const WechatComponent = () => {
353
317
  export default WechatComponent;
354
318
  ```
355
319
 
356
- #### 方式三:自定义按钮
320
+ #### 方式三:按钮样式与弹窗配置
357
321
 
358
- 使用自定义按钮,调用支付弹窗组件,展示二维码。用户扫码完成支付后,微信会通知业务后端支付结果。
322
+ 使用 `Wechat.Button`,通过 `children`、`className`、`style` 定制按钮,通过 `modalProps` 配置内置扫码弹窗。可通过按钮 ref 的 `openModal` / `closeModal` 主动开关。
359
323
 
360
- ```typescript
361
- import { useRef, useState } from 'react';
362
- import { Wechat, WechatModalRef } from 'pay-sdk-react';
363
-
364
- const wechatUrl = 'weixin://wxpay...';
365
-
366
- const WechatComponent = () => {
367
- const modalRef = useRef<WechatModalRef>(null);
368
-
369
- const [modalVisible, setModalVisible] = useState(false);
370
-
371
- const createOrder = async () => {
372
- const res = await fetch('/create-order', {
373
- method: 'POST',
374
- });
375
- modalRef.current?.open({ wechatUrl: res.url });
376
- };
377
-
378
- return (
379
- <div className="wechat-component">
380
- <h3>自定义 Button - visible 参数唤起 modal</h3>
381
- <button onClick={() => setModalVisible(true)}>自定义 Button</button>
382
- <Wechat.Modal
383
- visible={modalVisible}
384
- onClose={() => setModalVisible(false)}
385
- wechatProps={{ wechatUrl }}
386
- />
387
-
388
- <h3>自定义 Button - ref open 方法唤起 modal</h3>
389
- <button onClick={() => createOrder()}>自定义 Button</button>
390
- <Wechat.Modal ref={modalRef} />
391
- </div>
392
- );
393
- };
394
-
395
- export default WechatComponent;
396
- ```
324
+ 如果业务已有自定义触发器,可继续使用 `Wechat.Modal` 或直接导入 `WechatModal`,通过 `visible` 或 ref 控制打开与关闭。
397
325
 
398
326
  #### 方式四:自定义承接
399
327
 
@@ -1294,3 +1222,239 @@ const PayssionComponent = () => {
1294
1222
 
1295
1223
  export default PayssionComponent;
1296
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 取值或真实商户环境。仅渲染的外观画廊、交互断言、原生指针验证和沙箱支付分别记录。
@@ -774,3 +774,14 @@
774
774
  height: 16px;
775
775
  flex-shrink: 0;
776
776
  }
777
+ .pay-pix-qrcode__code {
778
+ display: block;
779
+ max-width: 100%;
780
+ overflow-wrap: anywhere;
781
+ padding: 8px;
782
+ }
783
+ .pay-pix-qrcode__confirm-btn {
784
+ cursor: pointer;
785
+ margin-top: 12px;
786
+ padding: 8px 16px;
787
+ }
@@ -1 +1 @@
1
- .pay-dot-loading{display:inline-block}.pay-fullscreen-loading{position:fixed;z-index:9999;left:0;top:0;right:0;bottom:0;background:hsla(0,0%,100%,.8);display:flex;align-items:center;justify-content:center;pointer-events:auto;user-select:none}.pay-fullscreen-loading__center{display:flex;flex-direction:column;align-items:center;justify-content:center}.pay-fullscreen-loading__spinner-box{display:flex;flex-direction:column;align-items:center;justify-content:center;background-color:rgba(17,17,17,.8);border-radius:16px;transition:width .2s,height .2s;box-sizing:border-box;padding:8px}.pay-fullscreen-loading__spinner-box--no-text{padding:4px}.pay-fullscreen-loading__spinner{margin-bottom:8px}.pay-fullscreen-loading__spinner-box--no-text .pay-fullscreen-loading__spinner{margin-bottom:0}.pay-fullscreen-loading__circle{border:3px solid rgba(255,255,255,.3);border-top-color:#fff;border-radius:50%;animation:1.2s linear infinite spin}.pay-fullscreen-loading__text{color:#fff;font-weight:600;letter-spacing:.25px;text-align:center;width:100%;word-break:break-all;line-height:1.2;overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.pay-fullscreen-loading__dots{display:flex;align-items:center;gap:10px}.pay-fullscreen-loading__dot{background:#fff;border-radius:50%;animation:.5s ease-in-out infinite bounce}.pay-fullscreen-loading__dot:nth-child(2){animation-delay:.1s}.pay-fullscreen-loading__dot:nth-child(3){animation-delay:.2s}.pay-fullscreen-loading__spin-dots{position:relative;animation:1.2s steps(12) infinite spin}.pay-fullscreen-loading__spin-dot{position:absolute;top:0;left:50%;background:#fff;border-radius:50%}.pay-fullscreen-loading--small .pay-fullscreen-loading__spinner-box{width:88px;height:88px}.pay-fullscreen-loading--small .pay-fullscreen-loading__spinner-box--no-text{width:48px;height:48px}.pay-fullscreen-loading--small .pay-fullscreen-loading__circle{width:24px;height:24px;border-width:3px}.pay-fullscreen-loading--small .pay-fullscreen-loading__text{font-size:14px}.pay-fullscreen-loading--small .pay-fullscreen-loading__dot{width:6px;height:6px}.pay-fullscreen-loading--small .pay-fullscreen-loading__spin-dots{width:28px;height:28px}.pay-fullscreen-loading--small .pay-fullscreen-loading__spin-dot{width:3.5px;height:3.5px;margin-left:-1.75px;transform-origin:50% 14px}.pay-fullscreen-loading--medium .pay-fullscreen-loading__spinner-box{width:112px;height:112px}.pay-fullscreen-loading--medium .pay-fullscreen-loading__spinner-box--no-text{width:62px;height:62px}.pay-fullscreen-loading--medium .pay-fullscreen-loading__circle{width:36px;height:36px;border-width:4px}.pay-fullscreen-loading--medium .pay-fullscreen-loading__text{font-size:16px}.pay-fullscreen-loading--medium .pay-fullscreen-loading__dot{width:10px;height:10px}.pay-fullscreen-loading--medium .pay-fullscreen-loading__spin-dots{width:40px;height:40px}.pay-fullscreen-loading--medium .pay-fullscreen-loading__spin-dot{width:4.5px;height:4.5px;margin-left:-2.25px;transform-origin:50% 20px}.pay-fullscreen-loading--large .pay-fullscreen-loading__spinner-box{width:144px;height:144px}.pay-fullscreen-loading--large .pay-fullscreen-loading__spinner-box--no-text{width:80px;height:80px}.pay-fullscreen-loading--large .pay-fullscreen-loading__circle{width:42px;height:42px;border-width:5px}.pay-fullscreen-loading--large .pay-fullscreen-loading__text{font-size:18px}.pay-fullscreen-loading--large .pay-fullscreen-loading__dot{width:12px;height:12px}.pay-fullscreen-loading--large .pay-fullscreen-loading__spin-dots{width:48px;height:48px}.pay-fullscreen-loading--large .pay-fullscreen-loading__spin-dot{width:5.5px;height:5.5px;margin-left:-2.75px;transform-origin:50% 24px}.pay-fullscreen-loading--default .pay-fullscreen-loading__spinner-box{width:100px;height:100px}.pay-fullscreen-loading--default .pay-fullscreen-loading__spinner-box--no-text{width:56px;height:56px}.pay-fullscreen-loading--default .pay-fullscreen-loading__circle{width:32px;height:32px;border-width:4px}.pay-fullscreen-loading--default .pay-fullscreen-loading__text{font-size:16px}.pay-fullscreen-loading--default .pay-fullscreen-loading__dot{width:9px;height:9px}.pay-fullscreen-loading--default .pay-fullscreen-loading__spin-dots{width:32px;height:32px}.pay-fullscreen-loading--default .pay-fullscreen-loading__spin-dot{width:4px;height:4px;margin-left:-2px;transform-origin:50% 16px}.pay-fullscreen-loading__container{position:relative;display:block}.pay-fullscreen-loading__mask{position:absolute;left:0;top:0;right:0;bottom:0;background:hsla(0,0%,100%,.8);z-index:10;display:flex;align-items:center;justify-content:center}@keyframes spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}@keyframes bounce{0%,100%{transform:translateY(0)}50%{transform:translateY(-12px)}}.pay-button{display:inline-block;padding:7px 12px;font-size:16px;border-radius:4px;border:1px solid #eee;background:#fff;color:#333;cursor:pointer;transition:.2s;user-select:none;position:relative;text-align:center}.pay-button-content{display:flex;align-items:center;justify-content:center;gap:6px}.pay-button-block{display:block;width:100%}.pay-button-disabled{opacity:.4;cursor:not-allowed}.pay-button-loading{cursor:wait}.pay-button-loading-wrapper{display:flex;align-items:center;justify-content:center;gap:6px}.pay-button-primary{background:#1677ff;border-color:#1677ff;color:#fff}.pay-button-primary:hover{background:#409eff}.pay-button-success{background:#00b578;border-color:#00b578;color:#fff}.pay-button-danger{background:#ff3141;border-color:#ff3141;color:#fff}.pay-button-warning{background:#ff8f1f;border-color:#ff8f1f;color:#fff}.pay-button-default{background:#fff;border-color:#eee;color:#333}.pay-button-fill-outline{background:0 0;color:inherit}.pay-button-fill-none{background:0 0;border:none;color:inherit}.pay-button-mini{font-size:12px;padding:2px 8px}.pay-button-small{font-size:14px;padding:4px 10px}.pay-button-large{font-size:18px;padding:10px 18px}.pay-button-shape-rounded{border-radius:1000px}.pay-button-shape-rectangular{border-radius:0}.pay-popup{position:fixed;z-index:1001}.pay-popup-body{position:fixed;display:flex;flex-direction:column;background-color:#fff;z-index:1010;box-sizing:border-box}.pay-popup-body.pay-popup-body-position-bottom{width:100%;left:0;bottom:0}.pay-popup-body.pay-popup-body-position-top{width:100%;left:0;top:0}.pay-popup-body.pay-popup-body-position-left{height:100%;width:80vw;left:0;top:0}.pay-popup-body.pay-popup-body-position-right{height:100%;width:80vw;right:0;top:0}.pay-popup-body.pay-popup-body-round.pay-popup-body-position-bottom{border-radius:16px 16px 0 0}.pay-popup-body.pay-popup-body-round.pay-popup-body-position-top{border-radius:0 0 16px 16px}.pay-popup-body.pay-popup-body-round.pay-popup-body-position-left{border-radius:0 16px 16px 0}.pay-popup-body.pay-popup-body-round.pay-popup-body-position-right{border-radius:16px 0 0 16px}.pay-popup-close-icon{position:absolute;z-index:1;cursor:pointer;padding:4px;font-size:18px;line-height:1;color:#999}.pay-popup-body.pay-popup-body-position-bottom .pay-popup-close-icon,.pay-popup-body.pay-popup-body-position-left .pay-popup-close-icon{top:8px;right:8px}.pay-popup-body.pay-popup-body-position-top .pay-popup-close-icon{bottom:8px;right:8px}.pay-popup-body.pay-popup-body-position-right .pay-popup-close-icon{top:8px;left:8px}.pay-popup-content{flex:1;overflow-y:auto;-webkit-overflow-scrolling:touch}.pay-popup-body.pay-popup-body-with-close.pay-popup-body-position-bottom .pay-popup-content,.pay-popup-body.pay-popup-body-with-close.pay-popup-body-position-left .pay-popup-content{padding-top:40px}.pay-popup-body.pay-popup-body-with-close.pay-popup-body-position-right .pay-popup-content{padding-top:40px}.pay-popup-body.pay-popup-body-with-close.pay-popup-body-position-top .pay-popup-content{padding-bottom:40px}.pay-mask-content{position:relative;width:100%;height:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:0 88px}.pay-mask-close{position:absolute;right:12px;top:12px;background:0 0;border:none;font-size:28px;color:#fff;cursor:pointer;z-index:1}.pay-mask-title{display:flex;align-items:center;gap:4px;font-weight:700;font-size:28px;color:#fff;margin-bottom:16px;text-shadow:0 2px 8px #000}.pay-mask-title>.pay-icon-paypal-white{width:36px;height:36px}.pay-mask-desc{color:#fff;text-align:center;margin-bottom:24px;line-height:1.5;white-space:pre-line}.pay-mask-continue{color:#fff;font-weight:700;text-decoration:underline;text-underline-offset:4px;cursor:pointer;text-align:center;font-size:18px}.pay-icon{display:inline-block;color:inherit;width:16px;vertical-align:-2px;stroke:currentColor}.pay-icon[fill=currentColor]{fill:currentColor;stroke:none}.pay-icon[stroke=currentColor]{stroke:currentColor;fill:none}.pay-icon[fill=currentColor][stroke=currentColor]{fill:currentColor;stroke:currentColor}.pay-icon-paypal-text{width:64px;height:26px;max-width:72px;max-height:32px}.pay-icon-close{width:18px;height:18px}.pay-icon-stripe-text{width:24px;height:24px}.pay-icon-alipay{width:20px;height:20px}.pay-icon-wechat-pay{width:20px;height:20px}.pay-icon-payssion-pay{width:36px;height:20px}.pay-mask{position:fixed;z-index:1000;left:0;top:0;right:0;bottom:0;display:flex;align-items:center;justify-content:center}.pay-modal{position:fixed;z-index:9999;left:0;top:0;right:0;bottom:0;display:flex;align-items:center;justify-content:center}.pay-modal__mask{position:absolute;left:0;top:0;right:0;bottom:0;background:rgba(0,0,0,.55);z-index:0}.pay-modal__content{position:relative;z-index:1;background:#fff;border-radius:16px;padding:42px 20px 20px;min-width:280px;max-width:80vw;box-shadow:0 4px 24px #0001;text-align:center;max-height:80vh;display:flex;flex-direction:column}.pay-modal__close{position:absolute;right:12px;top:12px;background:0 0;border:none;font-size:32px;font-weight:500;line-height:32px;cursor:pointer;text-align:left}.pay-modal__icon{display:flex;justify-content:center;margin-bottom:8px;font-size:40px}.pay-modal__title{font-size:20px;font-weight:700;color:#222;margin-bottom:12px}.pay-modal__desc{color:#222;font-size:15px;margin-bottom:24px;line-height:1.7;text-align:left}.pay-modal__content-wrapper{position:relative;z-index:1;text-align:center;overflow-y:auto;flex:0 1 auto;min-height:0}.pay-modal__actions{display:flex;justify-content:center;gap:16px;margin-top:16px}.pay-modal__btn{min-width:96px;padding:8px 0;border-radius:24px;border:none;font-size:15px;font-weight:600;cursor:pointer;transition:background .2s}.pay-modal__btn--retry{background:#fff;color:#f25a5a;border:1.5px solid #f25a5a}.pay-modal__btn--finish{background:#f25a5a;color:#fff;border:none}.pay-paypal-btn.pay-button>span{display:flex;align-items:center;gap:.5rem}@media (min-width:576px){.pay-stripe-modal.pay-modal .pay-modal__content{width:72%}}@media (min-width:768px){.pay-stripe-modal.pay-modal .pay-modal__content{width:50%}}@media (min-width:992px){.pay-stripe-modal.pay-modal .pay-modal__content{width:40%}}@media (min-width:1200px){.pay-stripe-modal.pay-modal .pay-modal__content{width:27%}}@media (min-width:1600px){.pay-stripe-modal.pay-modal .pay-modal__content{width:26%}}@media (min-width:2000px){.pay-stripe-modal.pay-modal .pay-modal__content{width:20%}}.pay-alipay-qr-iframe{display:flex;flex-direction:column;align-items:center}.pay-alipay-qr-iframe__iframe{border:none;width:180px;height:180px;margin-top:10px;margin-bottom:8px}.pay-alipay-qr-iframe__tip{text-align:center;color:#333;font-size:14px;line-height:20px}.pay-wechat-qrcode{display:flex;flex-direction:column;align-items:center}.pay-wechat-qrcode__container{background-color:#fff;border-radius:8px;display:flex;justify-content:center;align-items:center;width:180px;height:180px}.pay-wechat-qrcode__image{width:100%;height:100%;object-fit:cover}.pay-wechat-qrcode__tip{text-align:center;color:#333;font-size:14px;line-height:20px}.pay-pix-qrcode{display:flex;flex-direction:column;align-items:center}.pay-pix-qrcode__container{background-color:#fff;border-radius:8px;display:flex;justify-content:center;align-items:center;width:180px;height:180px}.pay-pix-qrcode__image{width:100%;height:100%;object-fit:cover}.pay-pix-qrcode__tip{text-align:center;color:#333;font-size:14px;line-height:20px;margin-top:12px}.pay-pix-qrcode__code-section{width:100%;max-width:320px;margin-top:16px}.pay-pix-qrcode__copy-btn{width:100%;padding:10px 16px;border:1px solid #32bcad;background-color:#fff;color:#32bcad;border-radius:8px;font-size:13px;font-weight:600;cursor:pointer;transition:.2s;display:flex;align-items:center;justify-content:center;gap:6px}.pay-pix-qrcode__copy-btn:hover{background-color:rgba(50,188,173,.06)}.pay-pix-qrcode__copy-btn:active{background-color:rgba(50,188,173,.12)}.pay-pix-qrcode__copy-btn--copied{color:#2ecc71;border-color:#2ecc71;background-color:rgba(46,204,113,.04)}.pay-pix-qrcode__copy-btn--copied:hover{background-color:rgba(46,204,113,.08)}.pay-pix-qrcode__copy-btn--copied:active{background-color:rgba(46,204,113,.14)}.pay-pix-qrcode__copy-icon{width:16px;height:16px;flex-shrink:0}
1
+ .pay-dot-loading{display:inline-block}.pay-fullscreen-loading{position:fixed;z-index:9999;left:0;top:0;right:0;bottom:0;background:hsla(0,0%,100%,.8);display:flex;align-items:center;justify-content:center;pointer-events:auto;user-select:none}.pay-fullscreen-loading__center{display:flex;flex-direction:column;align-items:center;justify-content:center}.pay-fullscreen-loading__spinner-box{display:flex;flex-direction:column;align-items:center;justify-content:center;background-color:rgba(17,17,17,.8);border-radius:16px;transition:width .2s,height .2s;box-sizing:border-box;padding:8px}.pay-fullscreen-loading__spinner-box--no-text{padding:4px}.pay-fullscreen-loading__spinner{margin-bottom:8px}.pay-fullscreen-loading__spinner-box--no-text .pay-fullscreen-loading__spinner{margin-bottom:0}.pay-fullscreen-loading__circle{border:3px solid rgba(255,255,255,.3);border-top-color:#fff;border-radius:50%;animation:1.2s linear infinite spin}.pay-fullscreen-loading__text{color:#fff;font-weight:600;letter-spacing:.25px;text-align:center;width:100%;word-break:break-all;line-height:1.2;overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.pay-fullscreen-loading__dots{display:flex;align-items:center;gap:10px}.pay-fullscreen-loading__dot{background:#fff;border-radius:50%;animation:.5s ease-in-out infinite bounce}.pay-fullscreen-loading__dot:nth-child(2){animation-delay:.1s}.pay-fullscreen-loading__dot:nth-child(3){animation-delay:.2s}.pay-fullscreen-loading__spin-dots{position:relative;animation:1.2s steps(12) infinite spin}.pay-fullscreen-loading__spin-dot{position:absolute;top:0;left:50%;background:#fff;border-radius:50%}.pay-fullscreen-loading--small .pay-fullscreen-loading__spinner-box{width:88px;height:88px}.pay-fullscreen-loading--small .pay-fullscreen-loading__spinner-box--no-text{width:48px;height:48px}.pay-fullscreen-loading--small .pay-fullscreen-loading__circle{width:24px;height:24px;border-width:3px}.pay-fullscreen-loading--small .pay-fullscreen-loading__text{font-size:14px}.pay-fullscreen-loading--small .pay-fullscreen-loading__dot{width:6px;height:6px}.pay-fullscreen-loading--small .pay-fullscreen-loading__spin-dots{width:28px;height:28px}.pay-fullscreen-loading--small .pay-fullscreen-loading__spin-dot{width:3.5px;height:3.5px;margin-left:-1.75px;transform-origin:50% 14px}.pay-fullscreen-loading--medium .pay-fullscreen-loading__spinner-box{width:112px;height:112px}.pay-fullscreen-loading--medium .pay-fullscreen-loading__spinner-box--no-text{width:62px;height:62px}.pay-fullscreen-loading--medium .pay-fullscreen-loading__circle{width:36px;height:36px;border-width:4px}.pay-fullscreen-loading--medium .pay-fullscreen-loading__text{font-size:16px}.pay-fullscreen-loading--medium .pay-fullscreen-loading__dot{width:10px;height:10px}.pay-fullscreen-loading--medium .pay-fullscreen-loading__spin-dots{width:40px;height:40px}.pay-fullscreen-loading--medium .pay-fullscreen-loading__spin-dot{width:4.5px;height:4.5px;margin-left:-2.25px;transform-origin:50% 20px}.pay-fullscreen-loading--large .pay-fullscreen-loading__spinner-box{width:144px;height:144px}.pay-fullscreen-loading--large .pay-fullscreen-loading__spinner-box--no-text{width:80px;height:80px}.pay-fullscreen-loading--large .pay-fullscreen-loading__circle{width:42px;height:42px;border-width:5px}.pay-fullscreen-loading--large .pay-fullscreen-loading__text{font-size:18px}.pay-fullscreen-loading--large .pay-fullscreen-loading__dot{width:12px;height:12px}.pay-fullscreen-loading--large .pay-fullscreen-loading__spin-dots{width:48px;height:48px}.pay-fullscreen-loading--large .pay-fullscreen-loading__spin-dot{width:5.5px;height:5.5px;margin-left:-2.75px;transform-origin:50% 24px}.pay-fullscreen-loading--default .pay-fullscreen-loading__spinner-box{width:100px;height:100px}.pay-fullscreen-loading--default .pay-fullscreen-loading__spinner-box--no-text{width:56px;height:56px}.pay-fullscreen-loading--default .pay-fullscreen-loading__circle{width:32px;height:32px;border-width:4px}.pay-fullscreen-loading--default .pay-fullscreen-loading__text{font-size:16px}.pay-fullscreen-loading--default .pay-fullscreen-loading__dot{width:9px;height:9px}.pay-fullscreen-loading--default .pay-fullscreen-loading__spin-dots{width:32px;height:32px}.pay-fullscreen-loading--default .pay-fullscreen-loading__spin-dot{width:4px;height:4px;margin-left:-2px;transform-origin:50% 16px}.pay-fullscreen-loading__container{position:relative;display:block}.pay-fullscreen-loading__mask{position:absolute;left:0;top:0;right:0;bottom:0;background:hsla(0,0%,100%,.8);z-index:10;display:flex;align-items:center;justify-content:center}@keyframes spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}@keyframes bounce{0%,100%{transform:translateY(0)}50%{transform:translateY(-12px)}}.pay-button{display:inline-block;padding:7px 12px;font-size:16px;border-radius:4px;border:1px solid #eee;background:#fff;color:#333;cursor:pointer;transition:.2s;user-select:none;position:relative;text-align:center}.pay-button-content{display:flex;align-items:center;justify-content:center;gap:6px}.pay-button-block{display:block;width:100%}.pay-button-disabled{opacity:.4;cursor:not-allowed}.pay-button-loading{cursor:wait}.pay-button-loading-wrapper{display:flex;align-items:center;justify-content:center;gap:6px}.pay-button-primary{background:#1677ff;border-color:#1677ff;color:#fff}.pay-button-primary:hover{background:#409eff}.pay-button-success{background:#00b578;border-color:#00b578;color:#fff}.pay-button-danger{background:#ff3141;border-color:#ff3141;color:#fff}.pay-button-warning{background:#ff8f1f;border-color:#ff8f1f;color:#fff}.pay-button-default{background:#fff;border-color:#eee;color:#333}.pay-button-fill-outline{background:0 0;color:inherit}.pay-button-fill-none{background:0 0;border:none;color:inherit}.pay-button-mini{font-size:12px;padding:2px 8px}.pay-button-small{font-size:14px;padding:4px 10px}.pay-button-large{font-size:18px;padding:10px 18px}.pay-button-shape-rounded{border-radius:1000px}.pay-button-shape-rectangular{border-radius:0}.pay-popup{position:fixed;z-index:1001}.pay-popup-body{position:fixed;display:flex;flex-direction:column;background-color:#fff;z-index:1010;box-sizing:border-box}.pay-popup-body.pay-popup-body-position-bottom{width:100%;left:0;bottom:0}.pay-popup-body.pay-popup-body-position-top{width:100%;left:0;top:0}.pay-popup-body.pay-popup-body-position-left{height:100%;width:80vw;left:0;top:0}.pay-popup-body.pay-popup-body-position-right{height:100%;width:80vw;right:0;top:0}.pay-popup-body.pay-popup-body-round.pay-popup-body-position-bottom{border-radius:16px 16px 0 0}.pay-popup-body.pay-popup-body-round.pay-popup-body-position-top{border-radius:0 0 16px 16px}.pay-popup-body.pay-popup-body-round.pay-popup-body-position-left{border-radius:0 16px 16px 0}.pay-popup-body.pay-popup-body-round.pay-popup-body-position-right{border-radius:16px 0 0 16px}.pay-popup-close-icon{position:absolute;z-index:1;cursor:pointer;padding:4px;font-size:18px;line-height:1;color:#999}.pay-popup-body.pay-popup-body-position-bottom .pay-popup-close-icon,.pay-popup-body.pay-popup-body-position-left .pay-popup-close-icon{top:8px;right:8px}.pay-popup-body.pay-popup-body-position-top .pay-popup-close-icon{bottom:8px;right:8px}.pay-popup-body.pay-popup-body-position-right .pay-popup-close-icon{top:8px;left:8px}.pay-popup-content{flex:1;overflow-y:auto;-webkit-overflow-scrolling:touch}.pay-popup-body.pay-popup-body-with-close.pay-popup-body-position-bottom .pay-popup-content,.pay-popup-body.pay-popup-body-with-close.pay-popup-body-position-left .pay-popup-content{padding-top:40px}.pay-popup-body.pay-popup-body-with-close.pay-popup-body-position-right .pay-popup-content{padding-top:40px}.pay-popup-body.pay-popup-body-with-close.pay-popup-body-position-top .pay-popup-content{padding-bottom:40px}.pay-mask-content{position:relative;width:100%;height:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:0 88px}.pay-mask-close{position:absolute;right:12px;top:12px;background:0 0;border:none;font-size:28px;color:#fff;cursor:pointer;z-index:1}.pay-mask-title{display:flex;align-items:center;gap:4px;font-weight:700;font-size:28px;color:#fff;margin-bottom:16px;text-shadow:0 2px 8px #000}.pay-mask-title>.pay-icon-paypal-white{width:36px;height:36px}.pay-mask-desc{color:#fff;text-align:center;margin-bottom:24px;line-height:1.5;white-space:pre-line}.pay-mask-continue{color:#fff;font-weight:700;text-decoration:underline;text-underline-offset:4px;cursor:pointer;text-align:center;font-size:18px}.pay-icon{display:inline-block;color:inherit;width:16px;vertical-align:-2px;stroke:currentColor}.pay-icon[fill=currentColor]{fill:currentColor;stroke:none}.pay-icon[stroke=currentColor]{stroke:currentColor;fill:none}.pay-icon[fill=currentColor][stroke=currentColor]{fill:currentColor;stroke:currentColor}.pay-icon-paypal-text{width:64px;height:26px;max-width:72px;max-height:32px}.pay-icon-close{width:18px;height:18px}.pay-icon-stripe-text{width:24px;height:24px}.pay-icon-alipay{width:20px;height:20px}.pay-icon-wechat-pay{width:20px;height:20px}.pay-icon-payssion-pay{width:36px;height:20px}.pay-mask{position:fixed;z-index:1000;left:0;top:0;right:0;bottom:0;display:flex;align-items:center;justify-content:center}.pay-modal{position:fixed;z-index:9999;left:0;top:0;right:0;bottom:0;display:flex;align-items:center;justify-content:center}.pay-modal__mask{position:absolute;left:0;top:0;right:0;bottom:0;background:rgba(0,0,0,.55);z-index:0}.pay-modal__content{position:relative;z-index:1;background:#fff;border-radius:16px;padding:42px 20px 20px;min-width:280px;max-width:80vw;box-shadow:0 4px 24px #0001;text-align:center;max-height:80vh;display:flex;flex-direction:column}.pay-modal__close{position:absolute;right:12px;top:12px;background:0 0;border:none;font-size:32px;font-weight:500;line-height:32px;cursor:pointer;text-align:left}.pay-modal__icon{display:flex;justify-content:center;margin-bottom:8px;font-size:40px}.pay-modal__title{font-size:20px;font-weight:700;color:#222;margin-bottom:12px}.pay-modal__desc{color:#222;font-size:15px;margin-bottom:24px;line-height:1.7;text-align:left}.pay-modal__content-wrapper{position:relative;z-index:1;text-align:center;overflow-y:auto;flex:0 1 auto;min-height:0}.pay-modal__actions{display:flex;justify-content:center;gap:16px;margin-top:16px}.pay-modal__btn{min-width:96px;padding:8px 0;border-radius:24px;border:none;font-size:15px;font-weight:600;cursor:pointer;transition:background .2s}.pay-modal__btn--retry{background:#fff;color:#f25a5a;border:1.5px solid #f25a5a}.pay-modal__btn--finish{background:#f25a5a;color:#fff;border:none}.pay-paypal-btn.pay-button>span{display:flex;align-items:center;gap:.5rem}@media (min-width:576px){.pay-stripe-modal.pay-modal .pay-modal__content{width:72%}}@media (min-width:768px){.pay-stripe-modal.pay-modal .pay-modal__content{width:50%}}@media (min-width:992px){.pay-stripe-modal.pay-modal .pay-modal__content{width:40%}}@media (min-width:1200px){.pay-stripe-modal.pay-modal .pay-modal__content{width:27%}}@media (min-width:1600px){.pay-stripe-modal.pay-modal .pay-modal__content{width:26%}}@media (min-width:2000px){.pay-stripe-modal.pay-modal .pay-modal__content{width:20%}}.pay-alipay-qr-iframe{display:flex;flex-direction:column;align-items:center}.pay-alipay-qr-iframe__iframe{border:none;width:180px;height:180px;margin-top:10px;margin-bottom:8px}.pay-alipay-qr-iframe__tip{text-align:center;color:#333;font-size:14px;line-height:20px}.pay-wechat-qrcode{display:flex;flex-direction:column;align-items:center}.pay-wechat-qrcode__container{background-color:#fff;border-radius:8px;display:flex;justify-content:center;align-items:center;width:180px;height:180px}.pay-wechat-qrcode__image{width:100%;height:100%;object-fit:cover}.pay-wechat-qrcode__tip{text-align:center;color:#333;font-size:14px;line-height:20px}.pay-pix-qrcode{display:flex;flex-direction:column;align-items:center}.pay-pix-qrcode__container{background-color:#fff;border-radius:8px;display:flex;justify-content:center;align-items:center;width:180px;height:180px}.pay-pix-qrcode__image{width:100%;height:100%;object-fit:cover}.pay-pix-qrcode__tip{text-align:center;color:#333;font-size:14px;line-height:20px;margin-top:12px}.pay-pix-qrcode__code-section{width:100%;max-width:320px;margin-top:16px}.pay-pix-qrcode__copy-btn{width:100%;padding:10px 16px;border:1px solid #32bcad;background-color:#fff;color:#32bcad;border-radius:8px;font-size:13px;font-weight:600;cursor:pointer;transition:.2s;display:flex;align-items:center;justify-content:center;gap:6px}.pay-pix-qrcode__copy-btn:hover{background-color:rgba(50,188,173,.06)}.pay-pix-qrcode__copy-btn:active{background-color:rgba(50,188,173,.12)}.pay-pix-qrcode__copy-btn--copied{color:#2ecc71;border-color:#2ecc71;background-color:rgba(46,204,113,.04)}.pay-pix-qrcode__copy-btn--copied:hover{background-color:rgba(46,204,113,.08)}.pay-pix-qrcode__copy-btn--copied:active{background-color:rgba(46,204,113,.14)}.pay-pix-qrcode__copy-icon{width:16px;height:16px;flex-shrink:0}.pay-pix-qrcode__code{display:block;max-width:100%;overflow-wrap:anywhere;padding:8px}.pay-pix-qrcode__confirm-btn{cursor:pointer;margin-top:12px;padding:8px 16px}
@@ -1,4 +1,4 @@
1
- var _excluded = ["children", "onClick", "createOrder"];
1
+ var _excluded = ["children", "onClick", "createOrder", "executionOptions"];
2
2
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
3
  function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
4
4
  function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { if (r) i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n;else { var o = function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); }; o("next", 0), o("throw", 1), o("return", 2); } }, _regeneratorDefine2(e, r, n, t); }
@@ -12,6 +12,7 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
12
12
  function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
13
13
  function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
14
14
  function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
15
+ import { useManagedOrder } from '../hooks/useManagedOrder';
15
16
  import React, { forwardRef, memo, useCallback, useImperativeHandle, useRef, useState } from 'react';
16
17
  import AirwallexPopup from './airwallex-popup';
17
18
  import AirwallexModal from './airwallex-modal';
@@ -23,6 +24,7 @@ var AirwallexButton = /*#__PURE__*/forwardRef(function (props, ref) {
23
24
  children = _props$children === void 0 ? 'Airwallex' : _props$children,
24
25
  onClick = props.onClick,
25
26
  createOrder = props.createOrder,
27
+ executionOptions = props.executionOptions,
26
28
  others = _objectWithoutProperties(props, _excluded);
27
29
  var airwallexButtonRef = useRef(null);
28
30
  var airwallexPopupRef = useRef(null);
@@ -47,6 +49,7 @@ var AirwallexButton = /*#__PURE__*/forwardRef(function (props, ref) {
47
49
  },
48
50
  closeModal: function closeModal() {
49
51
  var _airwallexModalRef$cu2;
52
+ if (executionOptions) managed.cancel();
50
53
  (_airwallexModalRef$cu2 = airwallexModalRef.current) === null || _airwallexModalRef$cu2 === void 0 || _airwallexModalRef$cu2.close();
51
54
  },
52
55
  openPopup: function openPopup(options) {
@@ -55,6 +58,7 @@ var AirwallexButton = /*#__PURE__*/forwardRef(function (props, ref) {
55
58
  },
56
59
  closePopup: function closePopup() {
57
60
  var _airwallexPopupRef$cu2;
61
+ if (executionOptions) managed.cancel();
58
62
  (_airwallexPopupRef$cu2 = airwallexPopupRef.current) === null || _airwallexPopupRef$cu2 === void 0 || _airwallexPopupRef$cu2.close();
59
63
  },
60
64
  openPayment: function openPayment(options) {
@@ -64,30 +68,50 @@ var AirwallexButton = /*#__PURE__*/forwardRef(function (props, ref) {
64
68
  }
65
69
  },
66
70
  closePayment: function closePayment() {
71
+ if (executionOptions) managed.cancel();
67
72
  setShowMask(false);
68
73
  },
69
74
  current: airwallexButtonRef.current
70
75
  };
71
76
  });
72
- var handlePayCreateOrder = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
73
- var options, _airwallexModalRef$cu3, _airwallexPopupRef$cu3;
77
+ var managed = useManagedOrder(createOrder ? /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
74
78
  return _regenerator().w(function (_context) {
75
79
  while (1) switch (_context.n) {
80
+ case 0:
81
+ return _context.a(2, createOrder());
82
+ }
83
+ }, _callee);
84
+ })) : undefined, function (target) {
85
+ if (props.payMode === 'embedded') {
86
+ var _airwallexModalRef$cu3, _airwallexPopupRef$cu3;
87
+ if (props.displayType === 'modal') (_airwallexModalRef$cu3 = airwallexModalRef.current) === null || _airwallexModalRef$cu3 === void 0 || _airwallexModalRef$cu3.open(target);else (_airwallexPopupRef$cu3 = airwallexPopupRef.current) === null || _airwallexPopupRef$cu3 === void 0 || _airwallexPopupRef$cu3.open(target);
88
+ } else {
89
+ setAirwallexUrl(target.airwallexUrl);
90
+ setShowMask(true);
91
+ }
92
+ }, executionOptions, function (target) {
93
+ return props.payMode === 'embedded' ? Boolean(target.type && target.options) : typeof target.airwallexUrl === 'string' && Boolean(target.airwallexUrl.trim());
94
+ });
95
+ var managedRun = managed.run;
96
+ var handlePayCreateOrder = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
97
+ var options, _airwallexModalRef$cu4, _airwallexPopupRef$cu4;
98
+ return _regenerator().w(function (_context2) {
99
+ while (1) switch (_context2.n) {
76
100
  case 0:
77
101
  if (!createOrder) {
78
- _context.n = 2;
102
+ _context2.n = 2;
79
103
  break;
80
104
  }
81
- _context.n = 1;
105
+ _context2.n = 1;
82
106
  return createOrder();
83
107
  case 1:
84
- options = _context.v;
108
+ options = _context2.v;
85
109
  if (options) {
86
110
  if ((props === null || props === void 0 ? void 0 : props.payMode) === 'embedded') {
87
111
  if ((props === null || props === void 0 ? void 0 : props.displayType) === 'modal') {
88
- airwallexModalRef === null || airwallexModalRef === void 0 || (_airwallexModalRef$cu3 = airwallexModalRef.current) === null || _airwallexModalRef$cu3 === void 0 || _airwallexModalRef$cu3.open(options);
112
+ airwallexModalRef === null || airwallexModalRef === void 0 || (_airwallexModalRef$cu4 = airwallexModalRef.current) === null || _airwallexModalRef$cu4 === void 0 || _airwallexModalRef$cu4.open(options);
89
113
  } else {
90
- (_airwallexPopupRef$cu3 = airwallexPopupRef.current) === null || _airwallexPopupRef$cu3 === void 0 || _airwallexPopupRef$cu3.open(options);
114
+ (_airwallexPopupRef$cu4 = airwallexPopupRef.current) === null || _airwallexPopupRef$cu4 === void 0 || _airwallexPopupRef$cu4.open(options);
91
115
  }
92
116
  } else {
93
117
  setShowMask(true);
@@ -95,13 +119,19 @@ var AirwallexButton = /*#__PURE__*/forwardRef(function (props, ref) {
95
119
  }
96
120
  }
97
121
  case 2:
98
- return _context.a(2);
122
+ return _context2.a(2);
99
123
  }
100
- }, _callee);
124
+ }, _callee2);
101
125
  })), [createOrder, props]);
102
126
  var handleClick = useCallback(function (e) {
103
127
  onClick === null || onClick === void 0 || onClick(e);
104
128
  if (createOrder) {
129
+ if (executionOptions) {
130
+ if (e.defaultPrevented) return;
131
+ return managedRun().then(function () {
132
+ return undefined;
133
+ });
134
+ }
105
135
  handlePayCreateOrder();
106
136
  return;
107
137
  }
@@ -109,14 +139,14 @@ var AirwallexButton = /*#__PURE__*/forwardRef(function (props, ref) {
109
139
  if ((props === null || props === void 0 ? void 0 : props.displayType) === 'modal') {
110
140
  var _props$modalProps;
111
141
  if (props !== null && props !== void 0 && (_props$modalProps = props.modalProps) !== null && _props$modalProps !== void 0 && (_props$modalProps = _props$modalProps.airwallexProps) !== null && _props$modalProps !== void 0 && _props$modalProps.initOptions) {
112
- var _airwallexModalRef$cu4;
113
- airwallexModalRef === null || airwallexModalRef === void 0 || (_airwallexModalRef$cu4 = airwallexModalRef.current) === null || _airwallexModalRef$cu4 === void 0 || _airwallexModalRef$cu4.open();
142
+ var _airwallexModalRef$cu5;
143
+ airwallexModalRef === null || airwallexModalRef === void 0 || (_airwallexModalRef$cu5 = airwallexModalRef.current) === null || _airwallexModalRef$cu5 === void 0 || _airwallexModalRef$cu5.open();
114
144
  }
115
145
  } else {
116
146
  var _props$popupProps;
117
147
  if (props !== null && props !== void 0 && (_props$popupProps = props.popupProps) !== null && _props$popupProps !== void 0 && (_props$popupProps = _props$popupProps.airwallexProps) !== null && _props$popupProps !== void 0 && _props$popupProps.initOptions) {
118
- var _airwallexPopupRef$cu4;
119
- airwallexPopupRef === null || airwallexPopupRef === void 0 || (_airwallexPopupRef$cu4 = airwallexPopupRef.current) === null || _airwallexPopupRef$cu4 === void 0 || _airwallexPopupRef$cu4.open();
148
+ var _airwallexPopupRef$cu5;
149
+ airwallexPopupRef === null || airwallexPopupRef === void 0 || (_airwallexPopupRef$cu5 = airwallexPopupRef.current) === null || _airwallexPopupRef$cu5 === void 0 || _airwallexPopupRef$cu5.open();
120
150
  }
121
151
  }
122
152
  return;
@@ -125,11 +155,13 @@ var AirwallexButton = /*#__PURE__*/forwardRef(function (props, ref) {
125
155
  setShowMask(true);
126
156
  setAirwallexUrl(props === null || props === void 0 ? void 0 : props.airwallexUrl);
127
157
  }
128
- }, [onClick, createOrder, handlePayCreateOrder, props]);
158
+ }, [executionOptions, managedRun, onClick, createOrder, handlePayCreateOrder, props]);
129
159
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, _extends({
130
160
  ref: airwallexButtonRef,
131
161
  onClick: handleClick
132
- }, omit(others, ['payMode', 'displayType', 'createOrder', 'airwallexUrl', 'maskProps', 'popupProps', 'modalProps'])), children), (props === null || props === void 0 ? void 0 : props.payMode) === 'embedded' && (props === null || props === void 0 ? void 0 : props.displayType) === 'popup' && /*#__PURE__*/React.createElement(AirwallexPopup, _extends({
162
+ }, omit(others, ['payMode', 'displayType', 'createOrder', 'airwallexUrl', 'maskProps', 'popupProps', 'modalProps']), {
163
+ loading: executionOptions ? managed.loading || others.loading : others.loading
164
+ }), children), (props === null || props === void 0 ? void 0 : props.payMode) === 'embedded' && (props === null || props === void 0 ? void 0 : props.displayType) === 'popup' && /*#__PURE__*/React.createElement(AirwallexPopup, _extends({
133
165
  ref: airwallexPopupRef
134
166
  }, props === null || props === void 0 ? void 0 : props.popupProps)), (props === null || props === void 0 ? void 0 : props.payMode) === 'embedded' && (props === null || props === void 0 ? void 0 : props.displayType) === 'modal' && /*#__PURE__*/React.createElement(AirwallexModal, _extends({
135
167
  ref: airwallexModalRef
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { AirwallexCheckoutButtonProps } from './interface';
3
+ declare const _default: React.MemoExoticComponent<(props: AirwallexCheckoutButtonProps) => import("react/jsx-runtime").JSX.Element>;
4
+ export default _default;