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