pay-sdk-react 1.1.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 (367) hide show
  1. package/README.md +1059 -0
  2. package/README.zh-CN.md +1061 -0
  3. package/dist/css/index.css +1 -0
  4. package/dist/es/Airwallex/airwallex-button.d.ts +4 -0
  5. package/dist/es/Airwallex/airwallex-button.js +86 -0
  6. package/dist/es/Airwallex/airwallex-modal.d.ts +6 -0
  7. package/dist/es/Airwallex/airwallex-modal.js +63 -0
  8. package/dist/es/Airwallex/airwallex-popup.d.ts +6 -0
  9. package/dist/es/Airwallex/airwallex-popup.js +74 -0
  10. package/dist/es/Airwallex/airwallex.d.ts +6 -0
  11. package/dist/es/Airwallex/airwallex.js +77 -0
  12. package/dist/es/Airwallex/index.d.ts +12 -0
  13. package/dist/es/Airwallex/index.js +10 -0
  14. package/dist/es/Airwallex/interface.d.ts +75 -0
  15. package/dist/es/Airwallex/interface.js +1 -0
  16. package/dist/es/Airwallex/style/index.css +1 -0
  17. package/dist/es/Airwallex/style/index.d.ts +1 -0
  18. package/dist/es/Airwallex/style/index.js +1 -0
  19. package/dist/es/Alipay/alipay-button.d.ts +6 -0
  20. package/dist/es/Alipay/alipay-button.js +52 -0
  21. package/dist/es/Alipay/alipay-modal.d.ts +6 -0
  22. package/dist/es/Alipay/alipay-modal.js +45 -0
  23. package/dist/es/Alipay/alipay.d.ts +4 -0
  24. package/dist/es/Alipay/alipay.js +44 -0
  25. package/dist/es/Alipay/index.d.ts +10 -0
  26. package/dist/es/Alipay/index.js +8 -0
  27. package/dist/es/Alipay/interface.d.ts +53 -0
  28. package/dist/es/Alipay/interface.js +1 -0
  29. package/dist/es/Alipay/style/index.css +1 -0
  30. package/dist/es/Alipay/style/index.d.ts +3 -0
  31. package/dist/es/Alipay/style/index.js +3 -0
  32. package/dist/es/Button/button.d.ts +21 -0
  33. package/dist/es/Button/button.js +74 -0
  34. package/dist/es/Button/index.d.ts +3 -0
  35. package/dist/es/Button/index.js +3 -0
  36. package/dist/es/Button/interface.d.ts +21 -0
  37. package/dist/es/Button/interface.js +1 -0
  38. package/dist/es/Button/style/index.css +1 -0
  39. package/dist/es/Button/style/index.d.ts +1 -0
  40. package/dist/es/Button/style/index.js +1 -0
  41. package/dist/es/FullScreenLoading/index.d.ts +4 -0
  42. package/dist/es/FullScreenLoading/index.js +116 -0
  43. package/dist/es/FullScreenLoading/interface.d.ts +43 -0
  44. package/dist/es/FullScreenLoading/interface.js +1 -0
  45. package/dist/es/FullScreenLoading/style/index.css +1 -0
  46. package/dist/es/FullScreenLoading/style/index.d.ts +1 -0
  47. package/dist/es/FullScreenLoading/style/index.js +1 -0
  48. package/dist/es/MAlipay/index.d.ts +8 -0
  49. package/dist/es/MAlipay/index.js +6 -0
  50. package/dist/es/MAlipay/interface.d.ts +44 -0
  51. package/dist/es/MAlipay/interface.js +1 -0
  52. package/dist/es/MAlipay/m-alipay-auto-submit.d.ts +6 -0
  53. package/dist/es/MAlipay/m-alipay-auto-submit.js +37 -0
  54. package/dist/es/MAlipay/m-alipay-button.d.ts +6 -0
  55. package/dist/es/MAlipay/m-alipay-button.js +127 -0
  56. package/dist/es/MAlipay/style/index.css +1 -0
  57. package/dist/es/MAlipay/style/index.d.ts +1 -0
  58. package/dist/es/MAlipay/style/index.js +1 -0
  59. package/dist/es/MWeChat/index.d.ts +2 -0
  60. package/dist/es/MWeChat/index.js +2 -0
  61. package/dist/es/MWeChat/interface.d.ts +50 -0
  62. package/dist/es/MWeChat/interface.js +1 -0
  63. package/dist/es/MWeChat/m-wechat-button.d.ts +6 -0
  64. package/dist/es/MWeChat/m-wechat-button.js +117 -0
  65. package/dist/es/MWeChat/style/index.css +1 -0
  66. package/dist/es/MWeChat/style/index.d.ts +1 -0
  67. package/dist/es/MWeChat/style/index.js +1 -0
  68. package/dist/es/Mask/index.d.ts +3 -0
  69. package/dist/es/Mask/index.js +3 -0
  70. package/dist/es/Mask/interface.d.ts +81 -0
  71. package/dist/es/Mask/interface.js +1 -0
  72. package/dist/es/Mask/mask.d.ts +5 -0
  73. package/dist/es/Mask/mask.js +97 -0
  74. package/dist/es/Mask/style/index.css +1 -0
  75. package/dist/es/Mask/style/index.d.ts +1 -0
  76. package/dist/es/Mask/style/index.js +1 -0
  77. package/dist/es/PayButton/index.d.ts +5 -0
  78. package/dist/es/PayButton/index.js +57 -0
  79. package/dist/es/PayButton/interface.d.ts +130 -0
  80. package/dist/es/PayButton/interface.js +93 -0
  81. package/dist/es/PayMask/index.d.ts +3 -0
  82. package/dist/es/PayMask/index.js +3 -0
  83. package/dist/es/PayMask/interface.d.ts +56 -0
  84. package/dist/es/PayMask/interface.js +1 -0
  85. package/dist/es/PayMask/pay-mask.d.ts +5 -0
  86. package/dist/es/PayMask/pay-mask.js +92 -0
  87. package/dist/es/PayMask/style/index.css +1 -0
  88. package/dist/es/PayMask/style/index.d.ts +1 -0
  89. package/dist/es/PayMask/style/index.js +1 -0
  90. package/dist/es/Paypal/index.d.ts +2 -0
  91. package/dist/es/Paypal/index.js +2 -0
  92. package/dist/es/Paypal/interface.d.ts +42 -0
  93. package/dist/es/Paypal/interface.js +1 -0
  94. package/dist/es/Paypal/paypal-button.d.ts +6 -0
  95. package/dist/es/Paypal/paypal-button.js +75 -0
  96. package/dist/es/Paypal/style/index.css +1 -0
  97. package/dist/es/Paypal/style/index.d.ts +1 -0
  98. package/dist/es/Paypal/style/index.js +1 -0
  99. package/dist/es/Payssion/index.d.ts +2 -0
  100. package/dist/es/Payssion/index.js +2 -0
  101. package/dist/es/Payssion/interface.d.ts +38 -0
  102. package/dist/es/Payssion/interface.js +1 -0
  103. package/dist/es/Payssion/payssion-button.d.ts +6 -0
  104. package/dist/es/Payssion/payssion-button.js +75 -0
  105. package/dist/es/Payssion/style/index.css +1 -0
  106. package/dist/es/Payssion/style/index.d.ts +1 -0
  107. package/dist/es/Payssion/style/index.js +1 -0
  108. package/dist/es/Stripe/index.d.ts +12 -0
  109. package/dist/es/Stripe/index.js +10 -0
  110. package/dist/es/Stripe/interface.d.ts +91 -0
  111. package/dist/es/Stripe/interface.js +1 -0
  112. package/dist/es/Stripe/stripe-button.d.ts +6 -0
  113. package/dist/es/Stripe/stripe-button.js +65 -0
  114. package/dist/es/Stripe/stripe-modal.d.ts +6 -0
  115. package/dist/es/Stripe/stripe-modal.js +50 -0
  116. package/dist/es/Stripe/stripe-popup.d.ts +6 -0
  117. package/dist/es/Stripe/stripe-popup.js +61 -0
  118. package/dist/es/Stripe/stripe.d.ts +5 -0
  119. package/dist/es/Stripe/stripe.js +38 -0
  120. package/dist/es/Stripe/style/index.css +1 -0
  121. package/dist/es/Stripe/style/index.d.ts +1 -0
  122. package/dist/es/Stripe/style/index.js +1 -0
  123. package/dist/es/Wechat/index.d.ts +10 -0
  124. package/dist/es/Wechat/index.js +8 -0
  125. package/dist/es/Wechat/interface.d.ts +69 -0
  126. package/dist/es/Wechat/interface.js +1 -0
  127. package/dist/es/Wechat/style/index.css +1 -0
  128. package/dist/es/Wechat/style/index.d.ts +1 -0
  129. package/dist/es/Wechat/style/index.js +1 -0
  130. package/dist/es/Wechat/wechat-button.d.ts +6 -0
  131. package/dist/es/Wechat/wechat-button.js +50 -0
  132. package/dist/es/Wechat/wechat-modal.d.ts +6 -0
  133. package/dist/es/Wechat/wechat-modal.js +45 -0
  134. package/dist/es/Wechat/wechat.d.ts +4 -0
  135. package/dist/es/Wechat/wechat.js +40 -0
  136. package/dist/es/confirm-modal/index.d.ts +5 -0
  137. package/dist/es/confirm-modal/index.js +52 -0
  138. package/dist/es/confirm-modal/interface.d.ts +21 -0
  139. package/dist/es/confirm-modal/interface.js +1 -0
  140. package/dist/es/confirm-modal/style/index.css +1 -0
  141. package/dist/es/confirm-modal/style/index.d.ts +1 -0
  142. package/dist/es/confirm-modal/style/index.js +1 -0
  143. package/dist/es/dot-loading/dot-loading.d.ts +4 -0
  144. package/dist/es/dot-loading/dot-loading.js +60 -0
  145. package/dist/es/dot-loading/index.d.ts +3 -0
  146. package/dist/es/dot-loading/index.js +3 -0
  147. package/dist/es/dot-loading/interface.d.ts +4 -0
  148. package/dist/es/dot-loading/interface.js +1 -0
  149. package/dist/es/dot-loading/style/index.css +1 -0
  150. package/dist/es/dot-loading/style/index.d.ts +1 -0
  151. package/dist/es/dot-loading/style/index.js +1 -0
  152. package/dist/es/hooks/use-initialized.d.ts +1 -0
  153. package/dist/es/hooks/use-initialized.js +8 -0
  154. package/dist/es/hooks/use-inner-visible.d.ts +1 -0
  155. package/dist/es/hooks/use-inner-visible.js +9 -0
  156. package/dist/es/hooks/use-lock-scroll.d.ts +2 -0
  157. package/dist/es/hooks/use-lock-scroll.js +82 -0
  158. package/dist/es/hooks/use-touch.d.ts +17 -0
  159. package/dist/es/hooks/use-touch.js +60 -0
  160. package/dist/es/hooks/usePayWindowOpen.d.ts +21 -0
  161. package/dist/es/hooks/usePayWindowOpen.js +87 -0
  162. package/dist/es/icons/IconAlipay/index.d.ts +4 -0
  163. package/dist/es/icons/IconAlipay/index.js +21 -0
  164. package/dist/es/icons/IconClose/index.d.ts +4 -0
  165. package/dist/es/icons/IconClose/index.js +27 -0
  166. package/dist/es/icons/IconPaypalText/index.d.ts +4 -0
  167. package/dist/es/icons/IconPaypalText/index.js +27 -0
  168. package/dist/es/icons/IconPaypalWhite/index.d.ts +4 -0
  169. package/dist/es/icons/IconPaypalWhite/index.js +22 -0
  170. package/dist/es/icons/IconPayssionPay/index.d.ts +4 -0
  171. package/dist/es/icons/IconPayssionPay/index.js +50 -0
  172. package/dist/es/icons/IconStripe/index.d.ts +4 -0
  173. package/dist/es/icons/IconStripe/index.js +22 -0
  174. package/dist/es/icons/IconStripeText/index.d.ts +4 -0
  175. package/dist/es/icons/IconStripeText/index.js +22 -0
  176. package/dist/es/icons/IconWechatPay/index.d.ts +4 -0
  177. package/dist/es/icons/IconWechatPay/index.js +21 -0
  178. package/dist/es/icons/index.d.ts +9 -0
  179. package/dist/es/icons/index.js +9 -0
  180. package/dist/es/icons/interface.d.ts +5 -0
  181. package/dist/es/icons/interface.js +1 -0
  182. package/dist/es/icons/style/index.css +1 -0
  183. package/dist/es/icons/style/index.d.ts +1 -0
  184. package/dist/es/icons/style/index.js +1 -0
  185. package/dist/es/index.d.ts +19 -0
  186. package/dist/es/index.js +10 -0
  187. package/dist/es/pay-modal/index.d.ts +3 -0
  188. package/dist/es/pay-modal/index.js +3 -0
  189. package/dist/es/pay-modal/interface.d.ts +94 -0
  190. package/dist/es/pay-modal/interface.js +1 -0
  191. package/dist/es/pay-modal/pay-modal.d.ts +5 -0
  192. package/dist/es/pay-modal/pay-modal.js +93 -0
  193. package/dist/es/pay-modal/style/index.css +1 -0
  194. package/dist/es/pay-modal/style/index.d.ts +1 -0
  195. package/dist/es/pay-modal/style/index.js +1 -0
  196. package/dist/es/pay-popup/index.d.ts +5 -0
  197. package/dist/es/pay-popup/index.js +156 -0
  198. package/dist/es/pay-popup/interface.d.ts +148 -0
  199. package/dist/es/pay-popup/interface.js +1 -0
  200. package/dist/es/pay-popup/style/index.css +1 -0
  201. package/dist/es/pay-popup/style/index.d.ts +1 -0
  202. package/dist/es/pay-popup/style/index.js +1 -0
  203. package/dist/es/shared/enums/index.d.ts +57 -0
  204. package/dist/es/shared/enums/index.js +58 -0
  205. package/dist/es/shared/index.d.ts +1 -0
  206. package/dist/es/shared/index.js +1 -0
  207. package/dist/es/utils/can-use-dom.d.ts +1 -0
  208. package/dist/es/utils/can-use-dom.js +1 -0
  209. package/dist/es/utils/classNames.d.ts +5 -0
  210. package/dist/es/utils/classNames.js +27 -0
  211. package/dist/es/utils/dom.d.ts +8 -0
  212. package/dist/es/utils/dom.js +80 -0
  213. package/dist/es/utils/get-container.d.ts +2 -0
  214. package/dist/es/utils/get-container.js +5 -0
  215. package/dist/es/utils/get-scroll-parent.d.ts +3 -0
  216. package/dist/es/utils/get-scroll-parent.js +24 -0
  217. package/dist/es/utils/getPrefixCls.d.ts +1 -0
  218. package/dist/es/utils/getPrefixCls.js +3 -0
  219. package/dist/es/utils/is.d.ts +35 -0
  220. package/dist/es/utils/is.js +122 -0
  221. package/dist/es/utils/native-props.d.ts +8 -0
  222. package/dist/es/utils/native-props.js +26 -0
  223. package/dist/es/utils/omit.d.ts +1 -0
  224. package/dist/es/utils/omit.js +15 -0
  225. package/dist/es/utils/qrcode.d.ts +7 -0
  226. package/dist/es/utils/qrcode.js +17 -0
  227. package/dist/es/utils/render-to-container.d.ts +3 -0
  228. package/dist/es/utils/render-to-container.js +10 -0
  229. package/dist/es/utils/should-render.d.ts +10 -0
  230. package/dist/es/utils/should-render.js +12 -0
  231. package/dist/es/utils/supports-passive.d.ts +1 -0
  232. package/dist/es/utils/supports-passive.js +14 -0
  233. package/dist/es/utils/warning.d.ts +1 -0
  234. package/dist/es/utils/warning.js +13 -0
  235. package/dist/es/utils/with-default-props.d.ts +9 -0
  236. package/dist/es/utils/with-default-props.js +33 -0
  237. package/dist/es/utils/with-stop-propagation.d.ts +4 -0
  238. package/dist/es/utils/with-stop-propagation.js +22 -0
  239. package/dist/lib/Airwallex/airwallex-button.js +94 -0
  240. package/dist/lib/Airwallex/airwallex-modal.js +70 -0
  241. package/dist/lib/Airwallex/airwallex-popup.js +81 -0
  242. package/dist/lib/Airwallex/airwallex.js +83 -0
  243. package/dist/lib/Airwallex/index.js +29 -0
  244. package/dist/lib/Airwallex/interface.js +5 -0
  245. package/dist/lib/Airwallex/style/index.css +1 -0
  246. package/dist/lib/Airwallex/style/index.js +3 -0
  247. package/dist/lib/Alipay/alipay-button.js +60 -0
  248. package/dist/lib/Alipay/alipay-modal.js +53 -0
  249. package/dist/lib/Alipay/alipay.js +52 -0
  250. package/dist/lib/Alipay/index.js +27 -0
  251. package/dist/lib/Alipay/interface.js +5 -0
  252. package/dist/lib/Alipay/style/index.css +1 -0
  253. package/dist/lib/Alipay/style/index.js +5 -0
  254. package/dist/lib/Button/button.js +82 -0
  255. package/dist/lib/Button/index.js +22 -0
  256. package/dist/lib/Button/interface.js +5 -0
  257. package/dist/lib/Button/style/index.css +1 -0
  258. package/dist/lib/Button/style/index.js +3 -0
  259. package/dist/lib/FullScreenLoading/index.js +124 -0
  260. package/dist/lib/FullScreenLoading/interface.js +5 -0
  261. package/dist/lib/FullScreenLoading/style/index.css +1 -0
  262. package/dist/lib/FullScreenLoading/style/index.js +3 -0
  263. package/dist/lib/MAlipay/index.js +25 -0
  264. package/dist/lib/MAlipay/interface.js +5 -0
  265. package/dist/lib/MAlipay/m-alipay-auto-submit.js +43 -0
  266. package/dist/lib/MAlipay/m-alipay-button.js +135 -0
  267. package/dist/lib/MAlipay/style/index.css +1 -0
  268. package/dist/lib/MAlipay/style/index.js +3 -0
  269. package/dist/lib/MWeChat/index.js +28 -0
  270. package/dist/lib/MWeChat/interface.js +5 -0
  271. package/dist/lib/MWeChat/m-wechat-button.js +125 -0
  272. package/dist/lib/MWeChat/style/index.css +1 -0
  273. package/dist/lib/MWeChat/style/index.js +3 -0
  274. package/dist/lib/Mask/index.js +22 -0
  275. package/dist/lib/Mask/interface.js +5 -0
  276. package/dist/lib/Mask/mask.js +117 -0
  277. package/dist/lib/Mask/style/index.css +1 -0
  278. package/dist/lib/Mask/style/index.js +3 -0
  279. package/dist/lib/PayButton/index.js +76 -0
  280. package/dist/lib/PayButton/interface.js +3 -0
  281. package/dist/lib/PayMask/index.js +22 -0
  282. package/dist/lib/PayMask/interface.js +5 -0
  283. package/dist/lib/PayMask/pay-mask.js +112 -0
  284. package/dist/lib/PayMask/style/index.css +1 -0
  285. package/dist/lib/PayMask/style/index.js +3 -0
  286. package/dist/lib/Paypal/index.js +28 -0
  287. package/dist/lib/Paypal/interface.js +5 -0
  288. package/dist/lib/Paypal/paypal-button.js +83 -0
  289. package/dist/lib/Paypal/style/index.css +1 -0
  290. package/dist/lib/Paypal/style/index.js +3 -0
  291. package/dist/lib/Payssion/index.js +28 -0
  292. package/dist/lib/Payssion/interface.js +5 -0
  293. package/dist/lib/Payssion/payssion-button.js +83 -0
  294. package/dist/lib/Payssion/style/index.css +1 -0
  295. package/dist/lib/Payssion/style/index.js +3 -0
  296. package/dist/lib/Stripe/index.js +29 -0
  297. package/dist/lib/Stripe/interface.js +5 -0
  298. package/dist/lib/Stripe/stripe-button.js +73 -0
  299. package/dist/lib/Stripe/stripe-modal.js +57 -0
  300. package/dist/lib/Stripe/stripe-popup.js +68 -0
  301. package/dist/lib/Stripe/stripe.js +46 -0
  302. package/dist/lib/Stripe/style/index.css +1 -0
  303. package/dist/lib/Stripe/style/index.js +3 -0
  304. package/dist/lib/Wechat/index.js +27 -0
  305. package/dist/lib/Wechat/interface.js +5 -0
  306. package/dist/lib/Wechat/style/index.css +1 -0
  307. package/dist/lib/Wechat/style/index.js +3 -0
  308. package/dist/lib/Wechat/wechat-button.js +58 -0
  309. package/dist/lib/Wechat/wechat-modal.js +52 -0
  310. package/dist/lib/Wechat/wechat.js +48 -0
  311. package/dist/lib/confirm-modal/index.js +72 -0
  312. package/dist/lib/confirm-modal/interface.js +5 -0
  313. package/dist/lib/confirm-modal/style/index.css +1 -0
  314. package/dist/lib/confirm-modal/style/index.js +3 -0
  315. package/dist/lib/dot-loading/dot-loading.js +67 -0
  316. package/dist/lib/dot-loading/index.js +22 -0
  317. package/dist/lib/dot-loading/interface.js +5 -0
  318. package/dist/lib/dot-loading/style/index.css +1 -0
  319. package/dist/lib/dot-loading/style/index.js +3 -0
  320. package/dist/lib/hooks/use-initialized.js +14 -0
  321. package/dist/lib/hooks/use-inner-visible.js +15 -0
  322. package/dist/lib/hooks/use-lock-scroll.js +88 -0
  323. package/dist/lib/hooks/use-touch.js +66 -0
  324. package/dist/lib/hooks/usePayWindowOpen.js +92 -0
  325. package/dist/lib/icons/IconAlipay/index.js +28 -0
  326. package/dist/lib/icons/IconClose/index.js +34 -0
  327. package/dist/lib/icons/IconPaypalText/index.js +34 -0
  328. package/dist/lib/icons/IconPaypalWhite/index.js +29 -0
  329. package/dist/lib/icons/IconPayssionPay/index.js +57 -0
  330. package/dist/lib/icons/IconStripe/index.js +29 -0
  331. package/dist/lib/icons/IconStripeText/index.js +29 -0
  332. package/dist/lib/icons/IconWechatPay/index.js +28 -0
  333. package/dist/lib/icons/index.js +84 -0
  334. package/dist/lib/icons/interface.js +5 -0
  335. package/dist/lib/icons/style/index.css +1 -0
  336. package/dist/lib/icons/style/index.js +3 -0
  337. package/dist/lib/index.js +92 -0
  338. package/dist/lib/pay-modal/index.js +22 -0
  339. package/dist/lib/pay-modal/interface.js +5 -0
  340. package/dist/lib/pay-modal/pay-modal.js +113 -0
  341. package/dist/lib/pay-modal/style/index.css +1 -0
  342. package/dist/lib/pay-modal/style/index.js +3 -0
  343. package/dist/lib/pay-popup/index.js +176 -0
  344. package/dist/lib/pay-popup/interface.js +5 -0
  345. package/dist/lib/pay-popup/style/index.css +1 -0
  346. package/dist/lib/pay-popup/style/index.js +3 -0
  347. package/dist/lib/shared/enums/index.js +64 -0
  348. package/dist/lib/shared/index.js +16 -0
  349. package/dist/lib/utils/can-use-dom.js +7 -0
  350. package/dist/lib/utils/classNames.js +34 -0
  351. package/dist/lib/utils/dom.js +86 -0
  352. package/dist/lib/utils/get-container.js +11 -0
  353. package/dist/lib/utils/get-scroll-parent.js +30 -0
  354. package/dist/lib/utils/getPrefixCls.js +9 -0
  355. package/dist/lib/utils/is.js +160 -0
  356. package/dist/lib/utils/native-props.js +33 -0
  357. package/dist/lib/utils/omit.js +21 -0
  358. package/dist/lib/utils/qrcode.js +23 -0
  359. package/dist/lib/utils/render-to-container.js +16 -0
  360. package/dist/lib/utils/should-render.js +20 -0
  361. package/dist/lib/utils/supports-passive.js +20 -0
  362. package/dist/lib/utils/warning.js +19 -0
  363. package/dist/lib/utils/with-default-props.js +40 -0
  364. package/dist/lib/utils/with-stop-propagation.js +29 -0
  365. package/dist/umd/pay-sdk-react.umd.js +16360 -0
  366. package/dist/umd/pay-sdk-react.umd.js.map +1 -0
  367. package/package.json +181 -0
@@ -0,0 +1,1061 @@
1
+ <div align="center">
2
+
3
+ [English](./README.md) | 简体中文
4
+
5
+ </div>
6
+
7
+ # 特征
8
+
9
+
10
+ ## 全面
11
+ 支持支付宝、微信、PayPal、Stripe、Payssion、空中云汇(Airwallex)等主流支付方式,覆盖绝大部分业务场景。
12
+
13
+ ## 跨端适配
14
+ H5、PC、App跨端 场景均可用,适配多端,满足多样化业务需求。
15
+
16
+ ## TypeScript 友好
17
+ 所有组件均由 TypeScript 编写,类型安全,开发体验优秀。
18
+
19
+ ## 多种承接形式
20
+ 支持支付按钮、弹窗、二维码、表单、popup、modal、蒙层等多种支付承接方式,灵活组合,满足不同业务场景。
21
+
22
+ # 安装
23
+ 以 npm 包形式提供:
24
+
25
+ ```shell
26
+ # 使用 npm
27
+ npm install pay-sdk-react
28
+
29
+ # 使用 yarn
30
+ yarn add pay-sdk-react
31
+
32
+ # 使用 pnpm
33
+ pnpm add pay-sdk-react
34
+ ```
35
+
36
+ ## 示例
37
+
38
+ ### 基础使用
39
+
40
+ ```typescript
41
+ import React from 'react';
42
+ import ReactDOM from 'react-dom';
43
+ import { PayButton, PaymentMethod } from 'pay-sdk-react';
44
+ import 'pay-sdk-react/dist/css/index.css';
45
+
46
+ function App() {
47
+ return (
48
+ <PayButton payMethod={PaymentMethod.PaypalH5} paypalUrl={''}, />
49
+ );
50
+ }
51
+
52
+ ReactDOM.render(<App />, document.getElementById('app'));
53
+ ```
54
+
55
+ ### 按需加载
56
+ 使用 babel-plugin-import
57
+
58
+ #### 1. 安装
59
+
60
+ ```shell
61
+ npm i babel-plugin-import -D
62
+ ```
63
+
64
+
65
+ #### 2. 添加配置:组件和样式的按需加载
66
+ 在 babel 配置中加入:
67
+
68
+ ```js
69
+ plugins: [
70
+ [
71
+ 'babel-plugin-import',
72
+ {
73
+ libraryName: 'pay-sdk-react',
74
+ libraryDirectory: 'es',
75
+ camel2DashComponentName: false,
76
+ style: true, // 样式按需加载
77
+ },
78
+ ],
79
+ ];
80
+ ```
81
+
82
+ # 支付场景与用法
83
+
84
+ ## 支付宝
85
+ ### PC 端
86
+
87
+ #### 方式一:使用 PayButton
88
+ 引入 PayButton 按钮,点击唤起支付弹窗,展示支付宝二维码。
89
+
90
+ ```typescript
91
+ import { PayButton, PaymentMethod } from 'pay-sdk-react';
92
+
93
+ const AlipayComponent = () => {
94
+
95
+ const createOrder = async () => {
96
+ const res = await fetch('/create-order', {
97
+ method: 'POST',
98
+ });
99
+ return { formHtml: res.htmlStr };
100
+ };
101
+
102
+ return (
103
+ <div className="alipay-component">
104
+ <h3>PayButton-基础用法</h3>
105
+ <PayButton payMethod={PaymentMethod.AlipayPc} createOrder={createOrder}>
106
+ Pay Button
107
+ </PayButton>
108
+ </div>
109
+ );
110
+ };
111
+
112
+ export default AlipayComponent;
113
+ ```
114
+
115
+ #### 方式二:Alipay.Button
116
+ 引入 Alipay,Alipay.Button 点击唤起支付弹窗,展示支付宝二维码。
117
+ ```typescript
118
+ import { Alipay } from 'pay-sdk-react';
119
+
120
+ const AlipayComponent = () => {
121
+ const createOrder = async () => {
122
+ const res = await fetch('/create-order', {
123
+ method: 'POST',
124
+ });
125
+ return { formHtml: res.htmlStr };
126
+ };
127
+
128
+ return (
129
+ <div className="alipay-component">
130
+ <h3>Alipay.Button - modal</h3>
131
+ <Alipay.Button createOrder={createOrder}>alipay Button</Alipay.Button>
132
+ </div>
133
+ );
134
+ };
135
+
136
+ export default AlipayComponent;
137
+ ```
138
+
139
+
140
+ #### 方式三:自定义按钮
141
+ 使用自定义按钮,调用支付弹窗组件,展示二维码。
142
+
143
+ ```typescript
144
+ import { useRef, useState } from 'react';
145
+ import { Alipay, AlipayModalRef } from 'pay-sdk-react';
146
+
147
+ const formHtml = '<form ... />';
148
+
149
+ const AlipayComponent = () => {
150
+ const modalRef = useRef<AlipayModalRef>(null);
151
+
152
+ const [modalVisible, setModalVisible] = useState(false);
153
+
154
+ const createOrder = async () => {
155
+ const res = await fetch('/create-order', {
156
+ method: 'POST',
157
+ });
158
+ modalRef.current?.open({ formHtml: res.htmlStr });
159
+ };
160
+
161
+ return (
162
+ <div className="alipay-component">
163
+ <h3>自定义 Button - visible 参数唤起 modal</h3>
164
+ <button onClick={() => setModalVisible(true)}>自定义 Button</button>
165
+ <Alipay.Modal
166
+ visible={modalVisible}
167
+ onClose={() => setModalVisible(false)}
168
+ alipayProps={{ formHtml }}
169
+ />
170
+ <h3>自定义 Button - ref open 方法唤起 modal</h3>
171
+ <button onClick={() => createOrder()}>自定义 Button</button>
172
+ <Alipay.Modal ref={modalRef} />
173
+ </div>
174
+ );
175
+ };
176
+
177
+ export default AlipayComponent;
178
+
179
+ ```
180
+
181
+ #### 方式四:自定义承接
182
+ 直接引入二维码组件,自定义承接方式&展示时机。
183
+
184
+ ```typescript
185
+ import { Alipay } from 'pay-sdk-react';
186
+
187
+ const formHtml = '<form ... />';
188
+
189
+ const AlipayComponent = () => {
190
+ return (
191
+ <div className="alipay-component">
192
+ <Alipay formHtml={formHtml} />
193
+ </div>
194
+ );
195
+ };
196
+
197
+ export default AlipayComponent;
198
+ ```
199
+
200
+ ### H5 端
201
+
202
+ #### 方式一:PayButton
203
+ 引入支付按钮,点击唤起等待支付弹窗(或蒙层),自动提交 iframe 表单唤起支付宝 App,无 App 时跳转浏览器。
204
+ 等待结果承接:支持弹窗和蒙层两种方式。
205
+
206
+ ```typescript
207
+ import { PayButton, PaymentMethod } from 'pay-sdk-react';
208
+
209
+ const MAlipayComponent = () => {
210
+ const createOrder = async () => {
211
+ const res = await fetch('/create-order', {
212
+ method: 'POST',
213
+ });
214
+ return { formHtml: res.htmlStr };
215
+ };
216
+
217
+ return (
218
+ <div className="m-alipay-component">
219
+ <h3>PayButton-基础用法</h3>
220
+ <PayButton
221
+ payMethod={PaymentMethod.AlipayH5}
222
+ createOrder={createOrder}
223
+ displayType={'modal'}
224
+ >
225
+ Pay Button
226
+ </PayButton>
227
+ </div>
228
+ );
229
+ };
230
+
231
+ export default MAlipayComponent;
232
+ ```
233
+
234
+ #### 方式二:MAlipay.Button
235
+
236
+ ```typescript
237
+ import { MAlipay } from "pay-sdk-react";
238
+
239
+ const MAlipayComponent = () => {
240
+
241
+ const createOrder = async() => {
242
+ const res = await fetch('/create-order', {
243
+ method: 'POST',
244
+ });
245
+ return { formHtml: res.htmlStr };
246
+ }
247
+
248
+ return (
249
+ <div className="m-alipay-component">
250
+ <h3>Alipay Button - mask</h3>
251
+ <MAlipay.Button
252
+ displayType={'mask'}
253
+ createOrder={createOrder}
254
+ >
255
+ Alipay Button
256
+ </MAlipay.Button>
257
+ </div>
258
+ );
259
+ };
260
+
261
+ export default MAlipayComponent;
262
+ ```
263
+
264
+
265
+ #### 方式三:自定义表单
266
+ 引入 MAlipay 表单组件,自定义触发表单时机。
267
+
268
+ ```typescript
269
+ import { MAlipay } from "pay-sdk-react";
270
+
271
+ const formHtml = "";
272
+
273
+ const MAlipayComponent = () => {
274
+
275
+ return (
276
+ <div className="yfm-m-alipay-component">
277
+ <h3>Alipay 表单</h3>
278
+ <MAlipay formHtml={formHtml} />
279
+ </div>
280
+ );
281
+ };
282
+
283
+ export default MAlipayComponent;
284
+ ```
285
+
286
+ ## 微信
287
+
288
+ ### PC 端
289
+
290
+ #### 方式一:PayButton
291
+ 引入支付按钮,点击唤起支付弹窗,展示微信二维码。
292
+
293
+ ```typescript
294
+ import { PayButton, PaymentMethod } from 'pay-sdk-react';
295
+
296
+ const WechatComponent = () => {
297
+ const createOrder = async () => {
298
+ const res = await fetch('/create-order', {
299
+ method: 'POST',
300
+ });
301
+ return { wechatUrl: res.url };
302
+ };
303
+
304
+ return (
305
+ <div className="wechat-component">
306
+ <h3>PayButton-基础用法</h3>
307
+ <PayButton payMethod={PaymentMethod.WechatPc} createOrder={createOrder}>
308
+ Pay Button
309
+ </PayButton>
310
+ </div>
311
+ );
312
+ };
313
+
314
+ export default WechatComponent;
315
+ ```
316
+
317
+ #### 方式二:Wechat.Button
318
+
319
+ ```typescript
320
+ import { Wechat } from 'pay-sdk-react';
321
+
322
+ const WechatComponent = () => {
323
+ const createOrder = async () => {
324
+ const res = await fetch('/create-order', {
325
+ method: 'POST',
326
+ });
327
+ return { wechatUrl: res.url };
328
+ };
329
+
330
+ return (
331
+ <div className="wechat-component">
332
+ <h3>Wechat.Button - modal</h3>
333
+ <Wechat.Button createOrder={createOrder}>Wechat Button</Wechat.Button>
334
+ </div>
335
+ );
336
+ };
337
+
338
+ export default WechatComponent;
339
+ ```
340
+
341
+ #### 方式三:自定义按钮
342
+ 使用自定义按钮,调用支付弹窗组件,展示二维码。
343
+
344
+ ```typescript
345
+ import { useRef, useState } from 'react';
346
+ import { Wechat, WechatModalRef } from 'pay-sdk-react';
347
+
348
+ const wechatUrl = 'weixin://wxpay...';
349
+
350
+ const WechatComponent = () => {
351
+ const modalRef = useRef<WechatModalRef>(null);
352
+
353
+ const [modalVisible, setModalVisible] = useState(false);
354
+
355
+ const createOrder = async () => {
356
+ const res = await fetch('/create-order', {
357
+ method: 'POST',
358
+ });
359
+ modalRef.current?.open({ wechatUrl: res.url });
360
+ };
361
+
362
+ return (
363
+ <div className="wechat-component">
364
+ <h3>自定义 Button - visible 参数唤起 modal</h3>
365
+ <button onClick={() => setModalVisible(true)}>自定义 Button</button>
366
+ <Wechat.Modal
367
+ visible={modalVisible}
368
+ onClose={() => setModalVisible(false)}
369
+ wechatProps={{ wechatUrl }}
370
+ />
371
+
372
+ <h3>自定义 Button - ref open 方法唤起 modal</h3>
373
+ <button onClick={() => createOrder()}>自定义 Button</button>
374
+ <Wechat.Modal ref={modalRef} />
375
+ </div>
376
+ );
377
+ };
378
+
379
+ export default WechatComponent;
380
+ ```
381
+
382
+ #### 方式四:自定义承接
383
+ 直接引入二维码组件,自定义承接和唤起方式。
384
+
385
+ ```typescript
386
+ import { Wechat } from 'pay-sdk-react';
387
+
388
+ const wechatUrl = 'weixin://wxpay/...';
389
+
390
+ const WechatComponent = () => {
391
+ return (
392
+ <div className="wechat-component">
393
+ <h3>直接使用 Wechat - 用户自定义承接方式&展示时机</h3>
394
+ <Wechat wechatUrl={wechatUrl} />
395
+ </div>
396
+ );
397
+ };
398
+
399
+ export default WechatComponent;
400
+ ```
401
+
402
+ ### H5 端
403
+
404
+ #### 方式一:PayButton
405
+ 引入支付按钮,点击唤起等待支付弹窗(或蒙层),自动打开微信支付链接,微信内浏览器自动唤起支付。
406
+ 等待结果承接:支持弹窗和蒙层两种方式。
407
+
408
+ ```typescript
409
+ import { PayButton, PaymentMethod } from 'pay-sdk-react';
410
+
411
+ const MWechatComponent = () => {
412
+ const createOrder = async () => {
413
+ const res = await fetch('/create-order', {
414
+ method: 'POST',
415
+ });
416
+ return { wechatUrl: res.url };
417
+ };
418
+
419
+ return (
420
+ <div className="m-wechat-component">
421
+ <h3>PayButton - 基础用法</h3>
422
+ <PayButton payMethod={PaymentMethod.WechatH5} createOrder={createOrder}>
423
+ Pay Button
424
+ </PayButton>
425
+ <h3>PayButton - mask</h3>
426
+ <PayButton
427
+ payMethod={PaymentMethod.WechatH5}
428
+ createOrder={createOrder}
429
+ displayType="mask"
430
+ >
431
+ Pay Button
432
+ </PayButton>
433
+ </div>
434
+ );
435
+ };
436
+
437
+ export default MWechatComponent;
438
+ ```
439
+
440
+ #### 方式二:MWechatButton
441
+
442
+ ```typescript
443
+ import { MWechatButton } from 'pay-sdk-react';
444
+
445
+ const wechatUrl = 'https://wx.tenpay.com/cgi-bin/mmpayweb-bin/checkmweb?...';
446
+
447
+ const MWechatComponent = () => {
448
+ return (
449
+ <div className="m-wechat-component">
450
+ <h3>wechat Button - modal</h3>
451
+ <MWechatButton displayType={'modal'} modalProps={{ payUrl: wechatUrl }}>
452
+ Wechat Button
453
+ </MWechatButton>
454
+ </div>
455
+ );
456
+ };
457
+
458
+ export default MWechatComponent;
459
+ ```
460
+
461
+ ## PayPal
462
+
463
+ ### 方式一:PayButton
464
+ 引入支付按钮,点击唤起支付,自动打开 PayPal 支付链接,同时展示等待支付结果蒙层。
465
+
466
+ ```typescript
467
+ import { PayButton, PaymentMethod } from 'pay-sdk-react';
468
+
469
+ const PaypalComponent = () => {
470
+ const createOrder = async () => {
471
+ const res = await fetch('/create-order', {
472
+ method: 'POST',
473
+ });
474
+ return { wechatUrl: res.url };
475
+ };
476
+
477
+ return (
478
+ <div className="paypal-component">
479
+ <h3>PayButton-基础用法</h3>
480
+ <PayButton payMethod={PaymentMethod.PaypalH5} createOrder={createOrder}>
481
+ Pay Button
482
+ </PayButton>
483
+
484
+ <h3>PaypalButton - 不自动打开第三方支付页面 - 新tab</h3>
485
+ <PayButton
486
+ payMethod={PaymentMethod.PaypalH5}
487
+ createOrder={createOrder}
488
+ maskProps={{ autoOpenWindow: false }}
489
+ >
490
+ Pay Button
491
+ </PayButton>
492
+ </div>
493
+ );
494
+ };
495
+
496
+ export default PaypalComponent;
497
+ ```
498
+
499
+ ### 方式二:PaypalButton
500
+
501
+ ```typescript
502
+ import { PaypalButton } from 'pay-sdk-react';
503
+
504
+ const paypalUrl = 'https://www.sandbox.paypal.com/checkoutnow?...';
505
+
506
+ const PaypalComponent = () => {
507
+ const createOrder = async () => {
508
+ const res = await fetch('/create-order', {
509
+ method: 'POST',
510
+ });
511
+ return { wechatUrl: res.url };
512
+ };
513
+
514
+ return (
515
+ <div className="paypal-component">
516
+ <h3>PaypalButton - 自动打开第三方支付页面 - 当前tab</h3>
517
+ <PaypalButton
518
+ createOrder={createOrder}
519
+ maskProps={{ openMode: 'replace' }}
520
+ >
521
+ Paypal Button
522
+ </PaypalButton>
523
+
524
+ <h3>PaypalButton - 不自动打开第三方支付页面 - 新tab</h3>
525
+ <PaypalButton
526
+ createOrder={createOrder}
527
+ maskProps={{ autoOpenWindow: false }}
528
+ >
529
+ Paypal Button
530
+ </PaypalButton>
531
+
532
+ <h3>Paypal Button - 不自动打开第三方支付页面 - 当前tab</h3>
533
+ <PaypalButton
534
+ maskProps={{
535
+ payUrl: paypalUrl,
536
+ autoOpenWindow: false,
537
+ openMode: 'href',
538
+ }}
539
+ >
540
+ Paypal Button
541
+ </PaypalButton>
542
+ </div>
543
+ );
544
+ };
545
+
546
+ export default PaypalComponent;
547
+ ```
548
+
549
+ ## Stripe
550
+
551
+ ### 方式一:PayButton
552
+
553
+ ```typescript
554
+ import { PayButton, PaymentMethod } from 'pay-sdk-react';
555
+
556
+ const StripeComponent = () => {
557
+ const createOrder = async () => {
558
+ return await fetch('/create-order', {
559
+ method: 'POST',
560
+ });
561
+ };
562
+
563
+ return (
564
+ <div className="stripe-component">
565
+ <h3>PayButton-基础用法</h3>
566
+ <PayButton payMethod={PaymentMethod.StripeH5} createOrder={createOrder}>
567
+ Pay Button
568
+ </PayButton>
569
+ </div>
570
+ );
571
+ };
572
+
573
+ export default StripeComponent;
574
+ ```
575
+
576
+ ### 方式二:Stripe.Button
577
+
578
+ ```typescript
579
+ import { Stripe } from 'pay-sdk-react';
580
+
581
+ const StripeComponent = () => {
582
+ const createOrder = async () => {
583
+ return await fetch('/create-order', {
584
+ method: 'POST',
585
+ });
586
+ };
587
+
588
+ return (
589
+ <div className="stripe-component">
590
+ <h3>Stripe.Button</h3>
591
+ <Stripe.Button createOrder={createOrder}>Stripe Button</Stripe.Button>
592
+ </div>
593
+ );
594
+ };
595
+
596
+ export default StripeComponent;
597
+ ```
598
+
599
+
600
+ ### 方式三:自定义唤起 popup - 推荐 移动端 使用
601
+
602
+ ```typescript
603
+ import { useRef, useState } from 'react';
604
+ import { Stripe, StripePopupRef } from 'pay-sdk-react';
605
+
606
+ const options = {
607
+ stripeKey: '***',
608
+ clientSecret: '***',
609
+ } as const;
610
+
611
+ const StripeComponent = () => {
612
+ const popupRef = useRef<StripePopupRef>(null);
613
+
614
+ const [popupVisible, setPopupVisible] = useState(false);
615
+
616
+ const createOrder = async () => {
617
+ const res = await fetch('/create-order', {
618
+ method: 'POST',
619
+ });
620
+ popupRef.current?.open(res);
621
+ };
622
+
623
+ return (
624
+ <div className="stripe-component">
625
+ <h3>自定义 button-visible 参数唤起 popup</h3>
626
+ <button onClick={() => setPopupVisible(true)}>自定义 button</button>
627
+ <Stripe.Popup
628
+ visible={popupVisible}
629
+ onClose={() => setPopupVisible(false)}
630
+ stripeProps={options}
631
+ />
632
+ <h3>自定义 button-ref open 方法唤起 popup</h3>
633
+ <button onClick={() => createOrder()}>自定义 button</button>
634
+ <Stripe.Popup ref={popupRef} />
635
+ </div>
636
+ );
637
+ };
638
+
639
+ export default StripeComponent;
640
+ ```
641
+
642
+ ### 方式四:自定义唤起 modal - 推荐 PC 端使用
643
+
644
+ ```typescript
645
+ import { useRef, useState } from 'react';
646
+ import { Stripe, StripeModalRef } from 'pay-sdk-react';
647
+
648
+ const options = {
649
+ stripeKey: '***',
650
+ clientSecret: '***',
651
+ } as const;
652
+
653
+ const StripeComponent = () => {
654
+ const modalRef = useRef<StripeModalRef>(null);
655
+
656
+ const [modalVisible, setModalVisible] = useState(false);
657
+
658
+ const createOrder = async () => {
659
+ const res = await fetch('/create-order', {
660
+ method: 'POST',
661
+ });
662
+ modalRef.current?.open(res);
663
+ };
664
+
665
+ return (
666
+ <div className="stripe-component">
667
+ <h3>自定义 button-visible 参数唤起 modal</h3>
668
+ <button onClick={() => setModalVisible(true)}>自定义 button</button>
669
+ <Stripe.Modal
670
+ visible={modalVisible}
671
+ onClose={() => setModalVisible(false)}
672
+ stripeProps={options}
673
+ />
674
+
675
+ <h3>自定义 button-ref open 方法唤起 modal</h3>
676
+ <button onClick={createOrder}>自定义 button</button>
677
+ <Stripe.Modal ref={modalRef} />
678
+ </div>
679
+ );
680
+ };
681
+
682
+ export default StripeComponent;
683
+ ```
684
+
685
+ ### 方式五:Stripe 表单
686
+ 引入 Stripe 表单组件,自定义承接和展示时机。
687
+
688
+ ```typescript
689
+ import { Stripe } from 'pay-sdk-react';
690
+
691
+ const options = {
692
+ stripeKey: '***',
693
+ clientSecret: '***',
694
+ } as const;
695
+
696
+ const StripeComponent = () => {
697
+ return (
698
+ <div className="stripe-component">
699
+ <h3>Stripe表单</h3>
700
+ <Stripe {...options} />
701
+ </div>
702
+ );
703
+ };
704
+
705
+ export default StripeComponent;
706
+ ```
707
+
708
+ ## 空中云汇(Airwallex)
709
+
710
+ ### 方式一:PayButton
711
+ 引入支付按钮,点击唤起 popup 承接表单(推荐移动端),PC 端推荐唤起 modal。
712
+
713
+ ```typescript
714
+ import { PayButton, PaymentMethod } from 'pay-sdk-react';
715
+
716
+ const AirwallexComponent = () => {
717
+ const createOrder = async () => {
718
+ const res = await fetch('/create-order', {
719
+ method: 'POST',
720
+ });
721
+ return {
722
+ type: 'fullFeaturedCard',
723
+ initOptions: {
724
+ env: 'demo',
725
+ locale: 'en',
726
+ },
727
+ options: {
728
+ currency: res.currency,
729
+ intent: {
730
+ id: res.intentId,
731
+ client_secret: res.client_secret,
732
+ },
733
+ client_secret: res.client_secret,
734
+ },
735
+ onSuccess: () => {
736
+ window.location.replace('支付成功结果页');
737
+ },
738
+ };
739
+ };
740
+
741
+ return (
742
+ <div className="airwallex-component">
743
+ <h3>PayButton-基础用法</h3>
744
+ <PayButton
745
+ payMethod={PaymentMethod.Airwallex}
746
+ payMode="embedded"
747
+ displayType="popup"
748
+ createOrder={createOrder}
749
+ >
750
+ Pay Button
751
+ </PayButton>
752
+ </div>
753
+ );
754
+ };
755
+
756
+ export default AirwallexComponent;
757
+ ```
758
+
759
+ ### 方式二:自定义唤起 popup
760
+
761
+ ```typescript
762
+ import { useRef, useState } from 'react';
763
+ import { Airwallex, AirwallexPopupRef } from 'pay-sdk-react';
764
+
765
+ const intentId = '***';
766
+ const clientSecret = '***';
767
+
768
+ const options = {
769
+ type: 'fullFeaturedCard',
770
+ initOptions: {
771
+ env: 'demo',
772
+ locale: 'en',
773
+ },
774
+ options: {
775
+ currency: 'USD',
776
+ intent: {
777
+ id: intentId,
778
+ client_secret: clientSecret,
779
+ },
780
+ client_secret: clientSecret,
781
+ },
782
+ onSuccess: () => {
783
+ window.location.replace('支付成功结果页');
784
+ },
785
+ } as const;
786
+
787
+ const AirwallexComponent = () => {
788
+ const [popupVisible, setPopupVisible] = useState(false);
789
+
790
+ const popupRef = useRef<AirwallexPopupRef>(null);
791
+
792
+ const createOrder = async () => {
793
+ const res = await fetch('/create-order', {
794
+ method: 'POST',
795
+ });
796
+ popupRef.current?.open({
797
+ type: 'fullFeaturedCard',
798
+ initOptions: {
799
+ env: 'demo',
800
+ locale: 'en',
801
+ },
802
+ options: {
803
+ currency: res.currency,
804
+ intent: {
805
+ id: res.intentId,
806
+ client_secret: res.client_secret,
807
+ },
808
+ client_secret: res.client_secret,
809
+ },
810
+ onSuccess: () => {
811
+ window.location.replace('支付成功结果页');
812
+ },
813
+ });
814
+ };
815
+
816
+ return (
817
+ <div className="airwallex-component">
818
+ <h3>自定义 button - visible 参数唤起 popup</h3>
819
+ <button onClick={() => setPopupVisible(true)}>自定义 button</button>
820
+ <Airwallex.Popup
821
+ visible={popupVisible}
822
+ onClose={() => setPopupVisible(false)}
823
+ airwallexProps={options}
824
+ />
825
+
826
+ <h3>自定义 button - ref open 方法唤起 popup</h3>
827
+ <button onClick={createOrder}>自定义 button</button>
828
+ <Airwallex.Popup ref={popupRef} />
829
+ </div>
830
+ );
831
+ };
832
+
833
+ export default AirwallexComponent;
834
+ ```
835
+
836
+ ### 方式三:唤起 modal
837
+
838
+ ```typescript
839
+ import { useRef, useState } from 'react';
840
+ import { Airwallex, AirwallexModalRef } from 'pay-sdk-react';
841
+
842
+ const intentId = '***';
843
+ const clientSecret = '***';
844
+
845
+ const options = {
846
+ type: 'fullFeaturedCard',
847
+ initOptions: {
848
+ env: 'demo',
849
+ locale: 'en',
850
+ },
851
+ options: {
852
+ currency: 'USD',
853
+ intent: {
854
+ id: intentId,
855
+ client_secret: clientSecret,
856
+ },
857
+ client_secret: clientSecret,
858
+ },
859
+ onSuccess: () => {
860
+ window.location.replace('支付成功结果页');
861
+ },
862
+ } as const;
863
+
864
+ const AirwallexComponent = () => {
865
+ const [modalVisible, setModalVisible] = useState(false);
866
+
867
+ const modalRef = useRef<AirwallexModalRef>(null);
868
+
869
+ const createOrder = async () => {
870
+ const res = await fetch('/create-order', {
871
+ method: 'POST',
872
+ });
873
+ modalRef.current?.open({
874
+ type: 'fullFeaturedCard',
875
+ initOptions: {
876
+ env: 'demo',
877
+ locale: 'en',
878
+ },
879
+ options: {
880
+ currency: res.currency,
881
+ intent: {
882
+ id: res.intentId,
883
+ client_secret: res.client_secret,
884
+ },
885
+ client_secret: res.client_secret,
886
+ },
887
+ onSuccess: () => {
888
+ window.location.replace('支付成功结果页');
889
+ },
890
+ });
891
+ };
892
+
893
+ return (
894
+ <div className="airwallex-component">
895
+ <h3>自定义 button-visible 参数唤起 modal</h3>
896
+ <button onClick={() => setModalVisible(true)}>自定义 button</button>
897
+ <Airwallex.Modal
898
+ visible={modalVisible}
899
+ onClose={() => setModalVisible(false)}
900
+ airwallexProps={options}
901
+ />
902
+
903
+ <h3>Airwallex.button - ref open 方法唤起 modal</h3>
904
+ <button onClick={createOrder}>自定义button</button>
905
+ <Airwallex.Modal ref={modalRef} />
906
+ </div>
907
+ );
908
+ };
909
+
910
+ export default AirwallexComponent;
911
+ ```
912
+
913
+
914
+ ### 方式四:自定义承接
915
+ 引入 Airwallex 表单组件,自定义承接和展示时机。
916
+
917
+ ```typescript
918
+ import { Airwallex } from 'pay-sdk-react';
919
+
920
+ const intentId = '***';
921
+ const clientSecret = '***';
922
+
923
+ const options = {
924
+ type: 'fullFeaturedCard',
925
+ initOptions: {
926
+ env: 'demo',
927
+ locale: 'en',
928
+ },
929
+ options: {
930
+ currency: 'USD',
931
+ intent: {
932
+ id: intentId,
933
+ client_secret: clientSecret,
934
+ },
935
+ client_secret: clientSecret,
936
+ },
937
+ onSuccess: () => {
938
+ window.location.replace('支付成功结果页');
939
+ },
940
+ } as const;
941
+
942
+ const AirwallexComponent = () => {
943
+ return (
944
+ <div className="airwallex-component">
945
+ <h3>Airwallex表单</h3>
946
+ <Airwallex {...options} />
947
+ </div>
948
+ );
949
+ };
950
+
951
+ export default AirwallexComponent;
952
+ ```
953
+
954
+ ### 方式五:Airwallex.Button
955
+ 引入支付按钮,点击打开第三方支付链接,同时唤起等待支付结果蒙层。
956
+
957
+ ```typescript
958
+ import { Airwallex } from 'pay-sdk-react';
959
+
960
+ const AirwallexComponent = () => {
961
+ const createOrder = async () => {
962
+ const res = await fetch('/create-order', {
963
+ method: 'POST',
964
+ });
965
+ return { airwallexUrl: res.url };
966
+ };
967
+
968
+ return (
969
+ <div className="airwallex-component">
970
+ <h3>Airwallex.Button</h3>
971
+ <Airwallex.Button payMode={'redirect'} createOrder={createOrder}>
972
+ Airwallex Button
973
+ </Airwallex.Button>
974
+ </div>
975
+ );
976
+ };
977
+
978
+ export default AirwallexComponent;
979
+ ```
980
+
981
+ ## Payssion
982
+
983
+ ### 方式一:PayButton
984
+ 引入支付按钮,点击打开第三方支付链接,同时唤起等待支付结果蒙层
985
+
986
+ ```typescript
987
+ import { PayButton, PaymentMethod } from 'pay-sdk-react';
988
+
989
+ const PayssionComponent = () => {
990
+ const createOrder = async () => {
991
+ const res = await fetch('/create-order', {
992
+ method: 'POST',
993
+ });
994
+ return { payssionUrl: res.url };
995
+ };
996
+
997
+ return (
998
+ <div className="payssion-component">
999
+ <h3>PayButton-基础用法</h3>
1000
+ <PayButton payMethod={PaymentMethod.Payssion} createOrder={createOrder}>
1001
+ Pay Button
1002
+ </PayButton>
1003
+
1004
+ <h3>Pay Button - 不自动打开第三方支付页面</h3>
1005
+ <PayButton
1006
+ createOrder={createOrder}
1007
+ maskProps={{ autoOpenWindow: false }}
1008
+ >
1009
+ Pay Button
1010
+ </PayButton>
1011
+ </div>
1012
+ );
1013
+ };
1014
+
1015
+ export default PayssionComponent;
1016
+ ```
1017
+
1018
+ ### 方式二:PayssionButton
1019
+
1020
+ ```typescript
1021
+ import { PayssionButton } from 'pay-sdk-react';
1022
+
1023
+ const PayssionComponent = () => {
1024
+ const createOrder = async () => {
1025
+ const res = await fetch('/create-order', {
1026
+ method: 'POST',
1027
+ });
1028
+ return { payssionUrl: res.url };
1029
+ };
1030
+
1031
+ return (
1032
+ <div className="payssion-component">
1033
+ <h3>Payssion Button - 自动打开第三方支付页面 - 当前tab</h3>
1034
+ <PayssionButton
1035
+ createOrder={createOrder}
1036
+ maskProps={{ openMode: 'replace' }}
1037
+ >
1038
+ Payssion Button
1039
+ </PayssionButton>
1040
+
1041
+ <h3>PaypalButton - 不自动打开第三方支付页面 - 新tab</h3>
1042
+ <PayssionButton
1043
+ createOrder={createOrder}
1044
+ maskProps={{ autoOpenWindow: false }}
1045
+ >
1046
+ Payssion Button
1047
+ </PayssionButton>
1048
+
1049
+ <h3>PayssionButton - 不自动打开第三方支付页面 - 当前tab</h3>
1050
+ <PayssionButton
1051
+ createOrder={createOrder}
1052
+ maskProps={{ autoOpenWindow: false, openMode: 'href' }}
1053
+ >
1054
+ Payssion Button
1055
+ </PayssionButton>
1056
+ </div>
1057
+ );
1058
+ };
1059
+
1060
+ export default PayssionComponent;
1061
+ ```