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
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { PaymentMethod } from "../shared";
|
|
2
|
+
import { PaypalButtonProps, PaypalButtonRef } from "../Paypal";
|
|
3
|
+
import { StripeButtonProps, StripeButtonRef } from "../Stripe";
|
|
4
|
+
import { AirwallexButtonProps, AirwallexButtonRef } from "../Airwallex";
|
|
5
|
+
import { PayssionButtonProps, PayssionButtonRef } from "../Payssion";
|
|
6
|
+
import { MWeChatButtonProps, MWeChatButtonRef } from "../MWeChat";
|
|
7
|
+
import { MAlipayButtonProps, MAlipayButtonRef } from "../MAlipay";
|
|
8
|
+
import { AlipayButtonProps, AlipayButtonRef } from "../Alipay";
|
|
9
|
+
import { WechatButtonProps, WechatButtonRef } from "../Wechat";
|
|
10
|
+
/**
|
|
11
|
+
* @zh PayPal 按钮基础属性
|
|
12
|
+
* @en Base props for PayPal button
|
|
13
|
+
*/
|
|
14
|
+
interface BasePaypalButtonProps {
|
|
15
|
+
payMethod: PaymentMethod.PaypalH5 | PaymentMethod.PaypalPc;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* @zh Stripe 按钮基础属性
|
|
19
|
+
* @en Base props for Stripe button
|
|
20
|
+
*/
|
|
21
|
+
interface BaseStripeButtonProps {
|
|
22
|
+
payMethod: PaymentMethod.StripeH5 | PaymentMethod.StripePc;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* @zh Airwallex 按钮基础属性
|
|
26
|
+
* @en Base props for Airwallex button
|
|
27
|
+
*/
|
|
28
|
+
interface BaseAirwallexButtonProps {
|
|
29
|
+
payMethod: PaymentMethod.Airwallex;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* @zh Payssion 按钮基础属性
|
|
33
|
+
* @en Base props for Payssion button
|
|
34
|
+
*/
|
|
35
|
+
interface BasePayssionButtonProps {
|
|
36
|
+
payMethod: PaymentMethod.Payssion;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* @zh MWeChat 按钮基础属性
|
|
40
|
+
* @en Base props for MWeChat button
|
|
41
|
+
*/
|
|
42
|
+
interface BaseMWeChatButtonProps {
|
|
43
|
+
payMethod: PaymentMethod.WechatH5;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* @zh MAlipay 按钮基础属性
|
|
47
|
+
* @en Base props for MAlipay button
|
|
48
|
+
*/
|
|
49
|
+
interface BaseMAlipayButtonProps {
|
|
50
|
+
payMethod: PaymentMethod.AlipayH5;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* @zh Alipay 按钮基础属性
|
|
54
|
+
* @en Base props for Alipay button
|
|
55
|
+
*/
|
|
56
|
+
interface BaseAlipayButtonProps {
|
|
57
|
+
payMethod: PaymentMethod.AlipayPc;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* @zh Wechat 按钮基础属性
|
|
61
|
+
* @en Base props for Wechat button
|
|
62
|
+
*/
|
|
63
|
+
interface BaseWechatButtonProps {
|
|
64
|
+
payMethod: PaymentMethod.WechatPc;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* @zh PayPal 按钮完整属性
|
|
68
|
+
* @en Full props for PayPal button
|
|
69
|
+
*/
|
|
70
|
+
type RealPaypalButtonProps = BasePaypalButtonProps & PaypalButtonProps;
|
|
71
|
+
/**
|
|
72
|
+
* @zh Stripe 按钮完整属性
|
|
73
|
+
* @en Full props for Stripe button
|
|
74
|
+
*/
|
|
75
|
+
type RealStripeButtonProps = BaseStripeButtonProps & StripeButtonProps;
|
|
76
|
+
/**
|
|
77
|
+
* @zh Airwallex 按钮完整属性
|
|
78
|
+
* @en Full props for Airwallex button
|
|
79
|
+
*/
|
|
80
|
+
type RealAirwallexButtonProps = BaseAirwallexButtonProps & AirwallexButtonProps;
|
|
81
|
+
/**
|
|
82
|
+
* @zh Payssion 按钮完整属性
|
|
83
|
+
* @en Full props for Payssion button
|
|
84
|
+
*/
|
|
85
|
+
type RealPayssionButtonProps = BasePayssionButtonProps & PayssionButtonProps;
|
|
86
|
+
/**
|
|
87
|
+
* @zh MWeChat 按钮完整属性
|
|
88
|
+
* @en Full props for MWeChat button
|
|
89
|
+
*/
|
|
90
|
+
type RealMWeChatButtonProps = BaseMWeChatButtonProps & MWeChatButtonProps;
|
|
91
|
+
/**
|
|
92
|
+
* @zh MAlipay 按钮完整属性
|
|
93
|
+
* @en Full props for MAlipay button
|
|
94
|
+
*/
|
|
95
|
+
type RealMAlipayButtonProps = BaseMAlipayButtonProps & MAlipayButtonProps;
|
|
96
|
+
/**
|
|
97
|
+
* @zh MAlipay 按钮完整属性
|
|
98
|
+
* @en Full props for MAlipay button
|
|
99
|
+
*/
|
|
100
|
+
type RealAlipayButtonProps = BaseAlipayButtonProps & AlipayButtonProps;
|
|
101
|
+
/**
|
|
102
|
+
* @zh Wechat 按钮完整属性
|
|
103
|
+
* @en Full props for Wechat button
|
|
104
|
+
*/
|
|
105
|
+
type RealWechatButtonProps = BaseWechatButtonProps & WechatButtonProps;
|
|
106
|
+
/**
|
|
107
|
+
* @zh 支付按钮属性联合类型,根据 payMethod 自动分发
|
|
108
|
+
* @en Union type for pay button props, auto-dispatch by payMethod
|
|
109
|
+
*/
|
|
110
|
+
export type PayButtonProps = RealPaypalButtonProps | RealStripeButtonProps | RealAirwallexButtonProps | RealPayssionButtonProps | RealMWeChatButtonProps | RealMAlipayButtonProps | RealAlipayButtonProps | RealWechatButtonProps;
|
|
111
|
+
type PayButtonRefMap = {
|
|
112
|
+
[PaymentMethod.PaypalH5]: PaypalButtonRef;
|
|
113
|
+
[PaymentMethod.PaypalPc]: PaypalButtonRef;
|
|
114
|
+
[PaymentMethod.StripeH5]: StripeButtonRef;
|
|
115
|
+
[PaymentMethod.StripePc]: StripeButtonRef;
|
|
116
|
+
[PaymentMethod.Airwallex]: AirwallexButtonRef;
|
|
117
|
+
[PaymentMethod.Payssion]: PayssionButtonRef;
|
|
118
|
+
[PaymentMethod.WechatH5]: MWeChatButtonRef;
|
|
119
|
+
[PaymentMethod.AlipayH5]: MAlipayButtonRef;
|
|
120
|
+
[PaymentMethod.AlipayPc]: AlipayButtonRef;
|
|
121
|
+
[PaymentMethod.WechatPc]: WechatButtonRef;
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* @zh 根据 payMethod 自动分发 ref 类型
|
|
125
|
+
* @en Auto-dispatch ref type by payMethod
|
|
126
|
+
*/
|
|
127
|
+
export type PayButtonRef<T extends PayButtonProps = PayButtonProps> = T extends {
|
|
128
|
+
payMethod: infer M;
|
|
129
|
+
} ? M extends keyof PayButtonRefMap ? PayButtonRefMap[M] : never : never;
|
|
130
|
+
export {};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { PaymentMethod } from "../shared";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @zh PayPal 按钮基础属性
|
|
5
|
+
* @en Base props for PayPal button
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @zh Stripe 按钮基础属性
|
|
10
|
+
* @en Base props for Stripe button
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @zh Airwallex 按钮基础属性
|
|
15
|
+
* @en Base props for Airwallex button
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @zh Payssion 按钮基础属性
|
|
20
|
+
* @en Base props for Payssion button
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @zh MWeChat 按钮基础属性
|
|
25
|
+
* @en Base props for MWeChat button
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @zh MAlipay 按钮基础属性
|
|
30
|
+
* @en Base props for MAlipay button
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @zh Alipay 按钮基础属性
|
|
35
|
+
* @en Base props for Alipay button
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @zh Wechat 按钮基础属性
|
|
40
|
+
* @en Base props for Wechat button
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @zh PayPal 按钮完整属性
|
|
45
|
+
* @en Full props for PayPal button
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @zh Stripe 按钮完整属性
|
|
50
|
+
* @en Full props for Stripe button
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @zh Airwallex 按钮完整属性
|
|
55
|
+
* @en Full props for Airwallex button
|
|
56
|
+
*/
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @zh Payssion 按钮完整属性
|
|
60
|
+
* @en Full props for Payssion button
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @zh MWeChat 按钮完整属性
|
|
65
|
+
* @en Full props for MWeChat button
|
|
66
|
+
*/
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @zh MAlipay 按钮完整属性
|
|
70
|
+
* @en Full props for MAlipay button
|
|
71
|
+
*/
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @zh MAlipay 按钮完整属性
|
|
75
|
+
* @en Full props for MAlipay button
|
|
76
|
+
*/
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @zh Wechat 按钮完整属性
|
|
80
|
+
* @en Full props for Wechat button
|
|
81
|
+
*/
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @zh 支付按钮属性联合类型,根据 payMethod 自动分发
|
|
85
|
+
* @en Union type for pay button props, auto-dispatch by payMethod
|
|
86
|
+
*/
|
|
87
|
+
|
|
88
|
+
// payMethod 到 ref 的映射
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* @zh 根据 payMethod 自动分发 ref 类型
|
|
92
|
+
* @en Auto-dispatch ref type by payMethod
|
|
93
|
+
*/
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { OpenPayUrlMode } from "../hooks/usePayWindowOpen";
|
|
3
|
+
import { MaskProps } from "../Mask";
|
|
4
|
+
/**
|
|
5
|
+
* @version 1.1.0
|
|
6
|
+
* @description
|
|
7
|
+
* @zh 支付蒙层组件属性定义,继承自基础 Mask 组件
|
|
8
|
+
* @en Props for payment mask component, extends from base Mask component
|
|
9
|
+
*/
|
|
10
|
+
export interface PayMaskProps extends MaskProps {
|
|
11
|
+
/**
|
|
12
|
+
* @zh 关闭蒙层的回调
|
|
13
|
+
* @en Callback when the mask is closed
|
|
14
|
+
*/
|
|
15
|
+
onClose?: () => void;
|
|
16
|
+
/**
|
|
17
|
+
* @zh 第三方支付页面链接
|
|
18
|
+
* @en URL of the third-party payment page
|
|
19
|
+
*/
|
|
20
|
+
payUrl?: string;
|
|
21
|
+
/**
|
|
22
|
+
* @zh 蒙层标题,默认值为 "PayPal"
|
|
23
|
+
* @en Title of the mask, default is "PayPal"
|
|
24
|
+
* @default "PayPal"
|
|
25
|
+
*/
|
|
26
|
+
title?: React.ReactNode;
|
|
27
|
+
/**
|
|
28
|
+
* @zh 蒙层描述,默认值为 "Don't see the secure paypal\nbrowser? We'll help you re-\nlaunch the window to complete\nyour purchase"
|
|
29
|
+
* @en Description text of the mask, default is "Don't see the secure paypal\nbrowser? We'll help you re-\nlaunch the window to complete\nyour purchase"
|
|
30
|
+
* @default "Don't see the secure paypal\nbrowser? We'll help you re-\nlaunch the window to complete\nyour purchase"
|
|
31
|
+
*/
|
|
32
|
+
desc?: React.ReactNode;
|
|
33
|
+
/**
|
|
34
|
+
* @zh 按钮文案,默认值为 "Click to Continue"
|
|
35
|
+
* @en Text of the action button, default is "Click to Continue"
|
|
36
|
+
* @default "Click to Continue"
|
|
37
|
+
*/
|
|
38
|
+
buttonText?: string;
|
|
39
|
+
/**
|
|
40
|
+
* @zh 点击继续按钮的回调
|
|
41
|
+
* @en Callback when the continue button is clicked
|
|
42
|
+
*/
|
|
43
|
+
onContinue?: () => void;
|
|
44
|
+
/**
|
|
45
|
+
* @zh 是否自动打开支付页面
|
|
46
|
+
* @en Whether to automatically open the payment page
|
|
47
|
+
* @default true
|
|
48
|
+
*/
|
|
49
|
+
autoOpenWindow?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* @zh 打开支付页面模式
|
|
52
|
+
* @en Mode for opening the payment page
|
|
53
|
+
* @default "window"
|
|
54
|
+
*/
|
|
55
|
+
openMode?: OpenPayUrlMode;
|
|
56
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
const _excluded = ["visible", "payUrl", "onClose", "onMaskClick", "onContinue", "openMode", "autoOpenWindow", "className", "destroyOnClose"];
|
|
2
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
3
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
4
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
5
|
+
import React, { useEffect, useState } from 'react';
|
|
6
|
+
import Mask from '../Mask';
|
|
7
|
+
import { usePayWindowOpen } from '../hooks/usePayWindowOpen';
|
|
8
|
+
import { mergeProps } from '../utils/with-default-props';
|
|
9
|
+
import cs from '../utils/classNames';
|
|
10
|
+
import { getPrefixCls } from '../utils/getPrefixCls';
|
|
11
|
+
const classPrefix = getPrefixCls('mask');
|
|
12
|
+
const defaultProps = {
|
|
13
|
+
visible: false,
|
|
14
|
+
title: 'Pay',
|
|
15
|
+
desc: "Don't see the secure pay browser? We'll help you re-launch the window to complete your purchase",
|
|
16
|
+
buttonText: 'Click to Continue',
|
|
17
|
+
autoOpenWindow: true
|
|
18
|
+
};
|
|
19
|
+
const PayMask = p => {
|
|
20
|
+
const props = mergeProps(defaultProps, p);
|
|
21
|
+
const {
|
|
22
|
+
visible,
|
|
23
|
+
payUrl,
|
|
24
|
+
onClose,
|
|
25
|
+
onMaskClick,
|
|
26
|
+
onContinue,
|
|
27
|
+
openMode,
|
|
28
|
+
autoOpenWindow,
|
|
29
|
+
className,
|
|
30
|
+
destroyOnClose = true
|
|
31
|
+
} = props,
|
|
32
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
33
|
+
const [isWindowMonitoring, setIsWindowMonitoring] = useState(false);
|
|
34
|
+
const {
|
|
35
|
+
openWindow,
|
|
36
|
+
closeWindow
|
|
37
|
+
} = usePayWindowOpen({
|
|
38
|
+
payUrl: payUrl || '',
|
|
39
|
+
onClose: () => {
|
|
40
|
+
onClose === null || onClose === void 0 || onClose();
|
|
41
|
+
setIsWindowMonitoring(false);
|
|
42
|
+
},
|
|
43
|
+
autoOpen: autoOpenWindow,
|
|
44
|
+
openMode
|
|
45
|
+
});
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (visible && autoOpenWindow) {
|
|
48
|
+
openWindow();
|
|
49
|
+
}
|
|
50
|
+
}, [visible, autoOpenWindow, openWindow]);
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (visible && isWindowMonitoring && !autoOpenWindow) {
|
|
53
|
+
openWindow();
|
|
54
|
+
}
|
|
55
|
+
}, [visible, isWindowMonitoring, autoOpenWindow, openWindow]);
|
|
56
|
+
const handleContinue = () => {
|
|
57
|
+
if (!autoOpenWindow) {
|
|
58
|
+
setIsWindowMonitoring(true);
|
|
59
|
+
} else {
|
|
60
|
+
openWindow();
|
|
61
|
+
}
|
|
62
|
+
onContinue === null || onContinue === void 0 || onContinue();
|
|
63
|
+
};
|
|
64
|
+
const handleClose = () => {
|
|
65
|
+
onClose === null || onClose === void 0 || onClose();
|
|
66
|
+
closeWindow();
|
|
67
|
+
};
|
|
68
|
+
const classNames = cs(classPrefix, className);
|
|
69
|
+
return /*#__PURE__*/React.createElement(Mask, _extends({
|
|
70
|
+
visible: visible,
|
|
71
|
+
onMaskClick: e => {
|
|
72
|
+
handleClose();
|
|
73
|
+
onMaskClick === null || onMaskClick === void 0 || onMaskClick(e);
|
|
74
|
+
},
|
|
75
|
+
className: classNames,
|
|
76
|
+
destroyOnClose: destroyOnClose
|
|
77
|
+
}, rest), /*#__PURE__*/React.createElement("div", {
|
|
78
|
+
className: "".concat(classPrefix, "-content")
|
|
79
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
80
|
+
className: "".concat(classPrefix, "-close"),
|
|
81
|
+
onClick: handleClose
|
|
82
|
+
}, "\xD7"), /*#__PURE__*/React.createElement("div", {
|
|
83
|
+
className: "".concat(classPrefix, "-title")
|
|
84
|
+
}, props.title), /*#__PURE__*/React.createElement("div", {
|
|
85
|
+
className: "".concat(classPrefix, "-desc")
|
|
86
|
+
}, props.desc), /*#__PURE__*/React.createElement("div", {
|
|
87
|
+
className: "".concat(classPrefix, "-continue"),
|
|
88
|
+
onClick: handleContinue
|
|
89
|
+
}, props.buttonText)));
|
|
90
|
+
};
|
|
91
|
+
export * from './interface';
|
|
92
|
+
export default PayMask;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.pay-mask{position:fixed;z-index:1000;left:0;top:0;right:0;bottom:0;display:flex;align-items:center;justify-content:center}.pay-mask-content{position:relative;width:100%;height:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:0 88px}.pay-mask-close{position:absolute;right:12px;top:12px;background:0 0;border:none;font-size:28px;color:#fff;cursor:pointer;z-index:1}.pay-mask-title{display:flex;align-items:center;gap:4px;font-weight:700;font-size:28px;color:#fff;margin-bottom:16px;text-shadow:0 2px 8px #000}.pay-mask-title>.pay-icon-paypal-white{width:36px;height:36px}.pay-mask-desc{color:#fff;text-align:center;margin-bottom:24px;line-height:1.5;white-space:pre-line}.pay-mask-continue{color:#fff;font-weight:700;text-decoration:underline;text-underline-offset:4px;cursor:pointer;text-align:center;font-size:18px}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './index.css';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './index.css';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ButtonProps, ButtonRef } from '../Button';
|
|
2
|
+
import { PayMaskProps } from '../PayMask';
|
|
3
|
+
/**
|
|
4
|
+
* @version 1.0.0
|
|
5
|
+
* @description
|
|
6
|
+
* @zh Paypal 组件属性定义
|
|
7
|
+
* @en Props for Paypal component
|
|
8
|
+
*/
|
|
9
|
+
export interface PaypalButtonProps extends ButtonProps {
|
|
10
|
+
/**
|
|
11
|
+
* @zh PaypalMask 组件的属性
|
|
12
|
+
* @en Props for PaypalMask component
|
|
13
|
+
*/
|
|
14
|
+
maskProps?: Omit<PayMaskProps, 'visible' | 'payUrl'>;
|
|
15
|
+
/**
|
|
16
|
+
* @zh Paypal 支付页面链接
|
|
17
|
+
* @en Paypal payment page URL
|
|
18
|
+
*/
|
|
19
|
+
paypalUrl?: string;
|
|
20
|
+
/**
|
|
21
|
+
* @zh 创建订单函数,返回 Paypal 所需参数
|
|
22
|
+
* @en Function to create order, returns Paypal required params
|
|
23
|
+
*/
|
|
24
|
+
createOrder?: CreateOrderPaypalFn;
|
|
25
|
+
}
|
|
26
|
+
export type PaypalButtonRef = ButtonRef;
|
|
27
|
+
/**
|
|
28
|
+
* @zh Paypal 所需参数
|
|
29
|
+
* @en Paypal required params
|
|
30
|
+
*/
|
|
31
|
+
export interface PaypalSecretMap {
|
|
32
|
+
/**
|
|
33
|
+
* @zh Paypal 支付页面链接
|
|
34
|
+
* @en Paypal payment page URL
|
|
35
|
+
*/
|
|
36
|
+
paypalUrl: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* @zh 创建订单函数,返回 Paypal 所需参数
|
|
40
|
+
* @en Function to create order, returns Paypal required params
|
|
41
|
+
*/
|
|
42
|
+
export type CreateOrderPaypalFn = () => Promise<PaypalSecretMap>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { PaypalButtonProps } from './interface';
|
|
3
|
+
declare const PaypalButton: React.ForwardRefExoticComponent<PaypalButtonProps & {
|
|
4
|
+
children?: React.ReactNode;
|
|
5
|
+
} & React.RefAttributes<import("../Button").ButtonRef>>;
|
|
6
|
+
export default PaypalButton;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
const _excluded = ["className", "children", "onClick", "paypalUrl", "createOrder", "maskProps"],
|
|
2
|
+
_excluded2 = ["onClose"];
|
|
3
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
4
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
5
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
6
|
+
import React, { forwardRef, useCallback, useImperativeHandle, useRef, useState } from 'react';
|
|
7
|
+
import { IconPaypalText, IconPaypalWhite } from '../icons';
|
|
8
|
+
import cs from '../utils/classNames';
|
|
9
|
+
import PayMask from '../PayMask';
|
|
10
|
+
import Button from '../Button';
|
|
11
|
+
import { getPrefixCls } from '../utils/getPrefixCls';
|
|
12
|
+
const PaypalButton = /*#__PURE__*/forwardRef((props, ref) => {
|
|
13
|
+
const {
|
|
14
|
+
className,
|
|
15
|
+
children = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(IconPaypalText, null), " Buy Now"),
|
|
16
|
+
onClick,
|
|
17
|
+
paypalUrl: propsPaypalUrl,
|
|
18
|
+
createOrder,
|
|
19
|
+
maskProps
|
|
20
|
+
} = props,
|
|
21
|
+
others = _objectWithoutProperties(props, _excluded);
|
|
22
|
+
const _ref = maskProps || {},
|
|
23
|
+
{
|
|
24
|
+
onClose: onMaskClose
|
|
25
|
+
} = _ref,
|
|
26
|
+
restMaskProps = _objectWithoutProperties(_ref, _excluded2);
|
|
27
|
+
const paypalButtonRef = useRef({
|
|
28
|
+
nativeElement: null
|
|
29
|
+
});
|
|
30
|
+
const [showMask, setShowMask] = useState(false);
|
|
31
|
+
const [paypalUrl, setPaypalUrl] = useState();
|
|
32
|
+
useImperativeHandle(ref, () => paypalButtonRef.current);
|
|
33
|
+
const handlePayCreateOrder = useCallback(async () => {
|
|
34
|
+
if (createOrder) {
|
|
35
|
+
// 1. 业务侧创建订单,获取参数
|
|
36
|
+
const {
|
|
37
|
+
paypalUrl
|
|
38
|
+
} = await (createOrder === null || createOrder === void 0 ? void 0 : createOrder());
|
|
39
|
+
if (paypalUrl) {
|
|
40
|
+
// 2. 唤起蒙层
|
|
41
|
+
setShowMask(true);
|
|
42
|
+
setPaypalUrl(paypalUrl);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}, [createOrder]);
|
|
46
|
+
const handleOpen = useCallback(() => {
|
|
47
|
+
if (propsPaypalUrl) {
|
|
48
|
+
setShowMask(true);
|
|
49
|
+
setPaypalUrl(propsPaypalUrl);
|
|
50
|
+
}
|
|
51
|
+
}, [propsPaypalUrl]);
|
|
52
|
+
const handleClick = useCallback(e => {
|
|
53
|
+
if (createOrder) {
|
|
54
|
+
handlePayCreateOrder();
|
|
55
|
+
} else {
|
|
56
|
+
handleOpen();
|
|
57
|
+
}
|
|
58
|
+
onClick === null || onClick === void 0 || onClick(e);
|
|
59
|
+
}, [onClick, createOrder, handlePayCreateOrder, handleOpen]);
|
|
60
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, _extends({
|
|
61
|
+
ref: paypalButtonRef,
|
|
62
|
+
className: cs(getPrefixCls('paypal-btn'), className),
|
|
63
|
+
onClick: handleClick
|
|
64
|
+
}, others), children), showMask && paypalUrl && /*#__PURE__*/React.createElement(PayMask, _extends({
|
|
65
|
+
visible: showMask,
|
|
66
|
+
onClose: () => {
|
|
67
|
+
setShowMask(false);
|
|
68
|
+
onMaskClose === null || onMaskClose === void 0 || onMaskClose();
|
|
69
|
+
},
|
|
70
|
+
payUrl: paypalUrl,
|
|
71
|
+
title: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(IconPaypalWhite, null), "PayPal")
|
|
72
|
+
}, restMaskProps)));
|
|
73
|
+
});
|
|
74
|
+
PaypalButton.displayName = 'PaypalButton';
|
|
75
|
+
export default PaypalButton;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.pay-dot-loading{display:inline-block}.pay-button{display:inline-block;padding:7px 12px;font-size:16px;border-radius:4px;border:1px solid #eee;background:#fff;color:#333;cursor:pointer;transition:all .2s;user-select:none;position:relative;text-align:center}.pay-button-content{display:flex;align-items:center;justify-content:center;gap:6px}.pay-button-block{display:block;width:100%}.pay-button-disabled{opacity:.4;cursor:not-allowed}.pay-button-loading{cursor:wait}.pay-button-loading-wrapper{display:flex;align-items:center;justify-content:center;gap:6px}.pay-button-primary{background:#1677ff;border-color:#1677ff;color:#fff}.pay-button-primary:hover{background:#409eff}.pay-button-success{background:#00b578;border-color:#00b578;color:#fff}.pay-button-danger{background:#ff3141;border-color:#ff3141;color:#fff}.pay-button-warning{background:#ff8f1f;border-color:#ff8f1f;color:#fff}.pay-button-default{background:#fff;border-color:#eee;color:#333}.pay-button-fill-outline{background:0 0;color:inherit}.pay-button-fill-none{background:0 0;border:none;color:inherit}.pay-button-mini{font-size:12px;padding:2px 8px}.pay-button-small{font-size:14px;padding:4px 10px}.pay-button-large{font-size:18px;padding:10px 18px}.pay-button-shape-rounded{border-radius:1000px}.pay-button-shape-rectangular{border-radius:0}.pay-mask{position:fixed;z-index:1000;left:0;top:0;right:0;bottom:0;display:flex;align-items:center;justify-content:center}.pay-mask-content{position:relative;width:100%;height:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:0 88px}.pay-mask-close{position:absolute;right:12px;top:12px;background:0 0;border:none;font-size:28px;color:#fff;cursor:pointer;z-index:1}.pay-mask-title{display:flex;align-items:center;gap:4px;font-weight:700;font-size:28px;color:#fff;margin-bottom:16px;text-shadow:0 2px 8px #000}.pay-mask-title>.pay-icon-paypal-white{width:36px;height:36px}.pay-mask-desc{color:#fff;text-align:center;margin-bottom:24px;line-height:1.5;white-space:pre-line}.pay-mask-continue{color:#fff;font-weight:700;text-decoration:underline;text-underline-offset:4px;cursor:pointer;text-align:center;font-size:18px}.pay-icon{display:inline-block;color:inherit;width:16px;vertical-align:-2px;stroke:currentColor}.pay-icon[fill=currentColor]{fill:currentColor;stroke:none}.pay-icon[stroke=currentColor]{stroke:currentColor;fill:none}.pay-icon[fill=currentColor][stroke=currentColor]{fill:currentColor;stroke:currentColor}.pay-icon-paypal-text{width:64px;height:26px;max-width:72px;max-height:32px}.pay-icon-close{width:18px;height:18px}.pay-icon-stripe-text{width:24px;height:24px}.pay-icon-alipay{width:20px;height:20px}.pay-icon-wechat-pay{width:20px;height:20px}.pay-icon-payssion-pay{width:36px;height:20px}.pay-paypal-btn.pay-button>span{display:flex;align-items:center;gap:.5rem}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './index.css';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './index.css';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ButtonProps, ButtonRef } from '../Button';
|
|
2
|
+
import { PayMaskProps } from '../PayMask';
|
|
3
|
+
/**
|
|
4
|
+
* @version 1.0.0
|
|
5
|
+
* @description
|
|
6
|
+
* @zh Paypal 组件属性定义
|
|
7
|
+
* @en Props for Paypal component
|
|
8
|
+
*/
|
|
9
|
+
export interface PayssionButtonProps extends ButtonProps {
|
|
10
|
+
/**
|
|
11
|
+
* @zh PayssionMask 组件的属性
|
|
12
|
+
* @en Props for PayssionMask component
|
|
13
|
+
*/
|
|
14
|
+
maskProps?: Omit<PayMaskProps, 'visible' | 'payUrl'>;
|
|
15
|
+
/**
|
|
16
|
+
* @zh Payssion 支付页面链接
|
|
17
|
+
* @en Payssion payment page URL
|
|
18
|
+
*/
|
|
19
|
+
payssionUrl?: string;
|
|
20
|
+
/**
|
|
21
|
+
* @zh 创建订单函数,返回 Paypal 所需参数
|
|
22
|
+
* @en Function to create order, returns Paypal required params
|
|
23
|
+
*/
|
|
24
|
+
createOrder?: CreateOrderPayssionFn;
|
|
25
|
+
}
|
|
26
|
+
export type PayssionButtonRef = ButtonRef;
|
|
27
|
+
export interface PayssionSecretMap {
|
|
28
|
+
/**
|
|
29
|
+
* @zh Payssion 支付页面链接
|
|
30
|
+
* @en Payssion payment page URL
|
|
31
|
+
*/
|
|
32
|
+
payssionUrl: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* @zh 创建订单函数,返回 Paypal 所需参数
|
|
36
|
+
* @en Function to create order, returns Paypal required params
|
|
37
|
+
*/
|
|
38
|
+
export type CreateOrderPayssionFn = () => Promise<PayssionSecretMap>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { PayssionButtonProps } from './interface';
|
|
3
|
+
declare const PayssionButton: React.ForwardRefExoticComponent<PayssionButtonProps & {
|
|
4
|
+
children?: React.ReactNode;
|
|
5
|
+
} & React.RefAttributes<import("../Button").ButtonRef>>;
|
|
6
|
+
export default PayssionButton;
|