pay-sdk-react 1.1.7 → 1.1.8

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.
@@ -60,8 +60,8 @@ var AirwallexButton = /*#__PURE__*/forwardRef(function (props, ref) {
60
60
  openPayment: function openPayment(options) {
61
61
  if (options) {
62
62
  setAirwallexUrl(options.airwallexUrl);
63
+ setShowMask(true);
63
64
  }
64
- setShowMask(true);
65
65
  },
66
66
  closePayment: function closePayment() {
67
67
  setShowMask(false);
@@ -107,11 +107,17 @@ var AirwallexButton = /*#__PURE__*/forwardRef(function (props, ref) {
107
107
  }
108
108
  if ((props === null || props === void 0 ? void 0 : props.payMode) === 'embedded') {
109
109
  if ((props === null || props === void 0 ? void 0 : props.displayType) === 'modal') {
110
- var _airwallexModalRef$cu4;
111
- airwallexModalRef === null || airwallexModalRef === void 0 || (_airwallexModalRef$cu4 = airwallexModalRef.current) === null || _airwallexModalRef$cu4 === void 0 || _airwallexModalRef$cu4.open();
110
+ var _props$modalProps;
111
+ if (props !== null && props !== void 0 && (_props$modalProps = props.modalProps) !== null && _props$modalProps !== void 0 && (_props$modalProps = _props$modalProps.airwallexProps) !== null && _props$modalProps !== void 0 && _props$modalProps.initOptions) {
112
+ var _airwallexModalRef$cu4;
113
+ airwallexModalRef === null || airwallexModalRef === void 0 || (_airwallexModalRef$cu4 = airwallexModalRef.current) === null || _airwallexModalRef$cu4 === void 0 || _airwallexModalRef$cu4.open();
114
+ }
112
115
  } else {
113
- var _airwallexPopupRef$cu4;
114
- airwallexPopupRef === null || airwallexPopupRef === void 0 || (_airwallexPopupRef$cu4 = airwallexPopupRef.current) === null || _airwallexPopupRef$cu4 === void 0 || _airwallexPopupRef$cu4.open();
116
+ var _props$popupProps;
117
+ if (props !== null && props !== void 0 && (_props$popupProps = props.popupProps) !== null && _props$popupProps !== void 0 && (_props$popupProps = _props$popupProps.airwallexProps) !== null && _props$popupProps !== void 0 && _props$popupProps.initOptions) {
118
+ var _airwallexPopupRef$cu4;
119
+ airwallexPopupRef === null || airwallexPopupRef === void 0 || (_airwallexPopupRef$cu4 = airwallexPopupRef.current) === null || _airwallexPopupRef$cu4 === void 0 || _airwallexPopupRef$cu4.open();
120
+ }
115
121
  }
116
122
  return;
117
123
  }
@@ -61,14 +61,15 @@ var AlipayButton = /*#__PURE__*/forwardRef(function (props, ref) {
61
61
  }, _callee);
62
62
  })), [createOrder]);
63
63
  var handleClick = useCallback(function (e) {
64
+ var _modalProps$alipayPro;
64
65
  if (createOrder) {
65
66
  handlePayCreateOrder();
66
- } else {
67
+ } else if (modalProps !== null && modalProps !== void 0 && (_modalProps$alipayPro = modalProps.alipayProps) !== null && _modalProps$alipayPro !== void 0 && _modalProps$alipayPro.formHtml) {
67
68
  var _alipayModalRef$curre4;
68
69
  alipayModalRef === null || alipayModalRef === void 0 || (_alipayModalRef$curre4 = alipayModalRef.current) === null || _alipayModalRef$curre4 === void 0 || _alipayModalRef$curre4.open();
69
70
  }
70
71
  onClick === null || onClick === void 0 || onClick(e);
71
- }, [onClick, createOrder, handlePayCreateOrder]);
72
+ }, [onClick, createOrder, handlePayCreateOrder, modalProps]);
72
73
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, _extends({
73
74
  ref: alipayButtonRef,
74
75
  className: cs(getPrefixCls('alipay-btn'), className),
@@ -59,8 +59,8 @@ var PaypalButton = /*#__PURE__*/forwardRef(function (props, ref) {
59
59
  openPayment: function openPayment(options) {
60
60
  if (options) {
61
61
  setPaypalUrl(options.paypalUrl);
62
+ setShowMask(true);
62
63
  }
63
- setShowMask(true);
64
64
  },
65
65
  closePayment: function closePayment() {
66
66
  setShowMask(false);
@@ -49,8 +49,8 @@ var PayssionButton = /*#__PURE__*/forwardRef(function (props, ref) {
49
49
  openPayment: function openPayment(options) {
50
50
  if (options) {
51
51
  setPayssionUrl(options.payssionUrl);
52
+ setShowMask(true);
52
53
  }
53
- setShowMask(true);
54
54
  },
55
55
  closePayment: function closePayment() {
56
56
  setShowMask(false);
@@ -79,15 +79,25 @@ var StripeButton = /*#__PURE__*/forwardRef(function (props, ref) {
79
79
  handlePayCreateOrder();
80
80
  } else {
81
81
  if (displayType === 'modal') {
82
- var _stripeModalRef$curre4;
83
- stripeModalRef === null || stripeModalRef === void 0 || (_stripeModalRef$curre4 = stripeModalRef.current) === null || _stripeModalRef$curre4 === void 0 || _stripeModalRef$curre4.open();
82
+ var _stripeModalProps$str, _stripeModalProps$str2;
83
+ var clientSecret = stripeModalProps === null || stripeModalProps === void 0 || (_stripeModalProps$str = stripeModalProps.stripeProps) === null || _stripeModalProps$str === void 0 ? void 0 : _stripeModalProps$str.clientSecret;
84
+ var stripeKey = stripeModalProps === null || stripeModalProps === void 0 || (_stripeModalProps$str2 = stripeModalProps.stripeProps) === null || _stripeModalProps$str2 === void 0 ? void 0 : _stripeModalProps$str2.stripeKey;
85
+ if (clientSecret && stripeKey) {
86
+ var _stripeModalRef$curre4;
87
+ stripeModalRef === null || stripeModalRef === void 0 || (_stripeModalRef$curre4 = stripeModalRef.current) === null || _stripeModalRef$curre4 === void 0 || _stripeModalRef$curre4.open();
88
+ }
84
89
  } else {
85
- var _stripePopupRef$curre4;
86
- stripePopupRef === null || stripePopupRef === void 0 || (_stripePopupRef$curre4 = stripePopupRef.current) === null || _stripePopupRef$curre4 === void 0 || _stripePopupRef$curre4.open();
90
+ var _stripePopupProps$str, _stripePopupProps$str2;
91
+ var _clientSecret = stripePopupProps === null || stripePopupProps === void 0 || (_stripePopupProps$str = stripePopupProps.stripeProps) === null || _stripePopupProps$str === void 0 ? void 0 : _stripePopupProps$str.clientSecret;
92
+ var _stripeKey = stripePopupProps === null || stripePopupProps === void 0 || (_stripePopupProps$str2 = stripePopupProps.stripeProps) === null || _stripePopupProps$str2 === void 0 ? void 0 : _stripePopupProps$str2.stripeKey;
93
+ if (_clientSecret && _stripeKey) {
94
+ var _stripePopupRef$curre4;
95
+ stripePopupRef === null || stripePopupRef === void 0 || (_stripePopupRef$curre4 = stripePopupRef.current) === null || _stripePopupRef$curre4 === void 0 || _stripePopupRef$curre4.open();
96
+ }
87
97
  }
88
98
  }
89
99
  onClick === null || onClick === void 0 || onClick(e);
90
- }, [onClick, createOrder, handlePayCreateOrder, displayType]);
100
+ }, [onClick, createOrder, handlePayCreateOrder, displayType, stripeModalProps, stripePopupProps]);
91
101
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, _extends({
92
102
  ref: stripeButtonRef,
93
103
  onClick: handleClick
@@ -59,14 +59,15 @@ var WechatButton = /*#__PURE__*/forwardRef(function (props, ref) {
59
59
  }, _callee);
60
60
  })), [createOrder]);
61
61
  var handleClick = useCallback(function (e) {
62
+ var _modalProps$wechatPro;
62
63
  if (createOrder) {
63
64
  handlePayCreateOrder();
64
- } else {
65
+ } else if (modalProps !== null && modalProps !== void 0 && (_modalProps$wechatPro = modalProps.wechatProps) !== null && _modalProps$wechatPro !== void 0 && _modalProps$wechatPro.wechatUrl) {
65
66
  var _wechatModalRef$curre4;
66
67
  wechatModalRef === null || wechatModalRef === void 0 || (_wechatModalRef$curre4 = wechatModalRef.current) === null || _wechatModalRef$curre4 === void 0 || _wechatModalRef$curre4.open();
67
68
  }
68
69
  onClick === null || onClick === void 0 || onClick(e);
69
- }, [onClick, createOrder, handlePayCreateOrder]);
70
+ }, [onClick, createOrder, handlePayCreateOrder, modalProps]);
70
71
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, _extends({
71
72
  ref: wechatButtonRef,
72
73
  className: cs(getPrefixCls('wechat-btn'), className),
@@ -49,8 +49,8 @@ const AirwallexButton = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
49
49
  openPayment: options => {
50
50
  if (options) {
51
51
  setAirwallexUrl(options.airwallexUrl);
52
+ setShowMask(true);
52
53
  }
53
- setShowMask(true);
54
54
  },
55
55
  closePayment: () => {
56
56
  setShowMask(false);
@@ -85,11 +85,17 @@ const AirwallexButton = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
85
85
  }
86
86
  if ((props === null || props === void 0 ? void 0 : props.payMode) === 'embedded') {
87
87
  if ((props === null || props === void 0 ? void 0 : props.displayType) === 'modal') {
88
- var _airwallexModalRef$cu4;
89
- airwallexModalRef === null || airwallexModalRef === void 0 || (_airwallexModalRef$cu4 = airwallexModalRef.current) === null || _airwallexModalRef$cu4 === void 0 || _airwallexModalRef$cu4.open();
88
+ var _props$modalProps;
89
+ if (props !== null && props !== void 0 && (_props$modalProps = props.modalProps) !== null && _props$modalProps !== void 0 && (_props$modalProps = _props$modalProps.airwallexProps) !== null && _props$modalProps !== void 0 && _props$modalProps.initOptions) {
90
+ var _airwallexModalRef$cu4;
91
+ airwallexModalRef === null || airwallexModalRef === void 0 || (_airwallexModalRef$cu4 = airwallexModalRef.current) === null || _airwallexModalRef$cu4 === void 0 || _airwallexModalRef$cu4.open();
92
+ }
90
93
  } else {
91
- var _airwallexPopupRef$cu4;
92
- airwallexPopupRef === null || airwallexPopupRef === void 0 || (_airwallexPopupRef$cu4 = airwallexPopupRef.current) === null || _airwallexPopupRef$cu4 === void 0 || _airwallexPopupRef$cu4.open();
94
+ var _props$popupProps;
95
+ if (props !== null && props !== void 0 && (_props$popupProps = props.popupProps) !== null && _props$popupProps !== void 0 && (_props$popupProps = _props$popupProps.airwallexProps) !== null && _props$popupProps !== void 0 && _props$popupProps.initOptions) {
96
+ var _airwallexPopupRef$cu4;
97
+ airwallexPopupRef === null || airwallexPopupRef === void 0 || (_airwallexPopupRef$cu4 = airwallexPopupRef.current) === null || _airwallexPopupRef$cu4 === void 0 || _airwallexPopupRef$cu4.open();
98
+ }
93
99
  }
94
100
  return;
95
101
  }
@@ -49,14 +49,15 @@ const AlipayButton = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
49
49
  }
50
50
  }, [createOrder]);
51
51
  const handleClick = (0, _react.useCallback)(e => {
52
+ var _modalProps$alipayPro;
52
53
  if (createOrder) {
53
54
  handlePayCreateOrder();
54
- } else {
55
+ } else if (modalProps !== null && modalProps !== void 0 && (_modalProps$alipayPro = modalProps.alipayProps) !== null && _modalProps$alipayPro !== void 0 && _modalProps$alipayPro.formHtml) {
55
56
  var _alipayModalRef$curre4;
56
57
  alipayModalRef === null || alipayModalRef === void 0 || (_alipayModalRef$curre4 = alipayModalRef.current) === null || _alipayModalRef$curre4 === void 0 || _alipayModalRef$curre4.open();
57
58
  }
58
59
  onClick === null || onClick === void 0 || onClick(e);
59
- }, [onClick, createOrder, handlePayCreateOrder]);
60
+ }, [onClick, createOrder, handlePayCreateOrder, modalProps]);
60
61
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Button.default, _extends({
61
62
  ref: alipayButtonRef,
62
63
  className: (0, _classNames.default)((0, _getPrefixCls.getPrefixCls)('alipay-btn'), className),
@@ -47,8 +47,8 @@ const PaypalButton = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
47
47
  openPayment: options => {
48
48
  if (options) {
49
49
  setPaypalUrl(options.paypalUrl);
50
+ setShowMask(true);
50
51
  }
51
- setShowMask(true);
52
52
  },
53
53
  closePayment: () => {
54
54
  setShowMask(false);
@@ -38,8 +38,8 @@ const PayssionButton = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
38
38
  openPayment: options => {
39
39
  if (options) {
40
40
  setPayssionUrl(options.payssionUrl);
41
+ setShowMask(true);
41
42
  }
42
- setShowMask(true);
43
43
  },
44
44
  closePayment: () => {
45
45
  setShowMask(false);
@@ -68,15 +68,25 @@ const StripeButton = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
68
68
  handlePayCreateOrder();
69
69
  } else {
70
70
  if (displayType === 'modal') {
71
- var _stripeModalRef$curre4;
72
- stripeModalRef === null || stripeModalRef === void 0 || (_stripeModalRef$curre4 = stripeModalRef.current) === null || _stripeModalRef$curre4 === void 0 || _stripeModalRef$curre4.open();
71
+ var _stripeModalProps$str, _stripeModalProps$str2;
72
+ const clientSecret = stripeModalProps === null || stripeModalProps === void 0 || (_stripeModalProps$str = stripeModalProps.stripeProps) === null || _stripeModalProps$str === void 0 ? void 0 : _stripeModalProps$str.clientSecret;
73
+ const stripeKey = stripeModalProps === null || stripeModalProps === void 0 || (_stripeModalProps$str2 = stripeModalProps.stripeProps) === null || _stripeModalProps$str2 === void 0 ? void 0 : _stripeModalProps$str2.stripeKey;
74
+ if (clientSecret && stripeKey) {
75
+ var _stripeModalRef$curre4;
76
+ stripeModalRef === null || stripeModalRef === void 0 || (_stripeModalRef$curre4 = stripeModalRef.current) === null || _stripeModalRef$curre4 === void 0 || _stripeModalRef$curre4.open();
77
+ }
73
78
  } else {
74
- var _stripePopupRef$curre4;
75
- stripePopupRef === null || stripePopupRef === void 0 || (_stripePopupRef$curre4 = stripePopupRef.current) === null || _stripePopupRef$curre4 === void 0 || _stripePopupRef$curre4.open();
79
+ var _stripePopupProps$str, _stripePopupProps$str2;
80
+ const clientSecret = stripePopupProps === null || stripePopupProps === void 0 || (_stripePopupProps$str = stripePopupProps.stripeProps) === null || _stripePopupProps$str === void 0 ? void 0 : _stripePopupProps$str.clientSecret;
81
+ const stripeKey = stripePopupProps === null || stripePopupProps === void 0 || (_stripePopupProps$str2 = stripePopupProps.stripeProps) === null || _stripePopupProps$str2 === void 0 ? void 0 : _stripePopupProps$str2.stripeKey;
82
+ if (clientSecret && stripeKey) {
83
+ var _stripePopupRef$curre4;
84
+ stripePopupRef === null || stripePopupRef === void 0 || (_stripePopupRef$curre4 = stripePopupRef.current) === null || _stripePopupRef$curre4 === void 0 || _stripePopupRef$curre4.open();
85
+ }
76
86
  }
77
87
  }
78
88
  onClick === null || onClick === void 0 || onClick(e);
79
- }, [onClick, createOrder, handlePayCreateOrder, displayType]);
89
+ }, [onClick, createOrder, handlePayCreateOrder, displayType, stripeModalProps, stripePopupProps]);
80
90
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Button.default, _extends({
81
91
  ref: stripeButtonRef,
82
92
  onClick: handleClick
@@ -47,14 +47,15 @@ const WechatButton = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
47
47
  }
48
48
  }, [createOrder]);
49
49
  const handleClick = (0, _react.useCallback)(e => {
50
+ var _modalProps$wechatPro;
50
51
  if (createOrder) {
51
52
  handlePayCreateOrder();
52
- } else {
53
+ } else if (modalProps !== null && modalProps !== void 0 && (_modalProps$wechatPro = modalProps.wechatProps) !== null && _modalProps$wechatPro !== void 0 && _modalProps$wechatPro.wechatUrl) {
53
54
  var _wechatModalRef$curre4;
54
55
  wechatModalRef === null || wechatModalRef === void 0 || (_wechatModalRef$curre4 = wechatModalRef.current) === null || _wechatModalRef$curre4 === void 0 || _wechatModalRef$curre4.open();
55
56
  }
56
57
  onClick === null || onClick === void 0 || onClick(e);
57
- }, [onClick, createOrder, handlePayCreateOrder]);
58
+ }, [onClick, createOrder, handlePayCreateOrder, modalProps]);
58
59
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Button.default, _extends({
59
60
  ref: wechatButtonRef,
60
61
  className: (0, _classNames.default)((0, _getPrefixCls.getPrefixCls)('wechat-btn'), className),
@@ -5542,8 +5542,8 @@
5542
5542
  openPayment: (options) => {
5543
5543
  if (options) {
5544
5544
  setPaypalUrl(options.paypalUrl);
5545
+ setShowMask(true);
5545
5546
  }
5546
- setShowMask(true);
5547
5547
  },
5548
5548
  closePayment: () => {
5549
5549
  setShowMask(false);
@@ -9453,14 +9453,29 @@
9453
9453
  }
9454
9454
  else {
9455
9455
  if (displayType === 'modal') {
9456
- stripeModalRef?.current?.open();
9456
+ const clientSecret = stripeModalProps?.stripeProps?.clientSecret;
9457
+ const stripeKey = stripeModalProps?.stripeProps?.stripeKey;
9458
+ if (clientSecret && stripeKey) {
9459
+ stripeModalRef?.current?.open();
9460
+ }
9457
9461
  }
9458
9462
  else {
9459
- stripePopupRef?.current?.open();
9463
+ const clientSecret = stripePopupProps?.stripeProps?.clientSecret;
9464
+ const stripeKey = stripePopupProps?.stripeProps?.stripeKey;
9465
+ if (clientSecret && stripeKey) {
9466
+ stripePopupRef?.current?.open();
9467
+ }
9460
9468
  }
9461
9469
  }
9462
9470
  onClick?.(e);
9463
- }, [onClick, createOrder, handlePayCreateOrder, displayType]);
9471
+ }, [
9472
+ onClick,
9473
+ createOrder,
9474
+ handlePayCreateOrder,
9475
+ displayType,
9476
+ stripeModalProps,
9477
+ stripePopupProps,
9478
+ ]);
9464
9479
  return (jsxRuntimeExports.jsxs(React.Fragment, { children: [jsxRuntimeExports.jsx(Button, { ref: stripeButtonRef, onClick: handleClick, ...others, children: children }), displayType === 'popup' && (jsxRuntimeExports.jsx(StripePopup$1, { ref: stripePopupRef, ...stripePopupProps })), displayType === 'modal' && (jsxRuntimeExports.jsx(StripeModal$1, { ref: stripeModalRef, ...stripeModalProps }))] }));
9465
9480
  });
9466
9481
  StripeButton.displayName = 'StripeButton';
@@ -9631,8 +9646,8 @@
9631
9646
  openPayment: (options) => {
9632
9647
  if (options) {
9633
9648
  setAirwallexUrl(options.airwallexUrl);
9649
+ setShowMask(true);
9634
9650
  }
9635
- setShowMask(true);
9636
9651
  },
9637
9652
  closePayment: () => {
9638
9653
  setShowMask(false);
@@ -9667,10 +9682,14 @@
9667
9682
  }
9668
9683
  if (props?.payMode === 'embedded') {
9669
9684
  if (props?.displayType === 'modal') {
9670
- airwallexModalRef?.current?.open();
9685
+ if (props?.modalProps?.airwallexProps?.initOptions) {
9686
+ airwallexModalRef?.current?.open();
9687
+ }
9671
9688
  }
9672
9689
  else {
9673
- airwallexPopupRef?.current?.open();
9690
+ if (props?.popupProps?.airwallexProps?.initOptions) {
9691
+ airwallexPopupRef?.current?.open();
9692
+ }
9674
9693
  }
9675
9694
  return;
9676
9695
  }
@@ -9713,8 +9732,8 @@
9713
9732
  openPayment: (options) => {
9714
9733
  if (options) {
9715
9734
  setPayssionUrl(options.payssionUrl);
9735
+ setShowMask(true);
9716
9736
  }
9717
- setShowMask(true);
9718
9737
  },
9719
9738
  closePayment: () => {
9720
9739
  setShowMask(false);
@@ -10102,11 +10121,11 @@
10102
10121
  if (createOrder) {
10103
10122
  handlePayCreateOrder();
10104
10123
  }
10105
- else {
10124
+ else if (modalProps?.alipayProps?.formHtml) {
10106
10125
  alipayModalRef?.current?.open();
10107
10126
  }
10108
10127
  onClick?.(e);
10109
- }, [onClick, createOrder, handlePayCreateOrder]);
10128
+ }, [onClick, createOrder, handlePayCreateOrder, modalProps]);
10110
10129
  return (jsxRuntimeExports.jsxs(React.Fragment, { children: [jsxRuntimeExports.jsx(Button, { ref: alipayButtonRef, className: cs(getPrefixCls('alipay-btn'), className), onClick: handleClick, ...others, children: children }), jsxRuntimeExports.jsx(AlipayModal$1, { ref: alipayModalRef, ...modalProps })] }));
10111
10130
  });
10112
10131
  AlipayButton.displayName = 'AlipayButton';
@@ -16518,11 +16537,11 @@
16518
16537
  if (createOrder) {
16519
16538
  handlePayCreateOrder();
16520
16539
  }
16521
- else {
16540
+ else if (modalProps?.wechatProps?.wechatUrl) {
16522
16541
  wechatModalRef?.current?.open();
16523
16542
  }
16524
16543
  onClick?.(e);
16525
- }, [onClick, createOrder, handlePayCreateOrder]);
16544
+ }, [onClick, createOrder, handlePayCreateOrder, modalProps]);
16526
16545
  return (jsxRuntimeExports.jsxs(React.Fragment, { children: [jsxRuntimeExports.jsx(Button, { ref: wechatButtonRef, className: cs(getPrefixCls('wechat-btn'), className), onClick: handleClick, ...others, children: children }), jsxRuntimeExports.jsx(WechatModal$1, { ref: wechatModalRef, ...modalProps })] }));
16527
16546
  });
16528
16547
  WechatButton.displayName = 'WechatButton';