@pisell/private-materials 3.4.37 → 3.4.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. package/build/lowcode/assets-daily.json +11 -11
  2. package/build/lowcode/assets-dev.json +2 -2
  3. package/build/lowcode/assets-prod.json +11 -11
  4. package/build/lowcode/index.js +1 -1
  5. package/build/lowcode/meta.js +1 -1
  6. package/build/lowcode/preview.js +7 -7
  7. package/build/lowcode/render/default/view.css +1 -1
  8. package/build/lowcode/render/default/view.js +7 -7
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +7 -7
  11. package/es/businessModel/SalesModel/index.d.ts +1 -0
  12. package/es/components/Sales/Event/Detail.js +4 -3
  13. package/es/components/Sales/Summary/utils.d.ts +1 -1
  14. package/es/components/appointmentBooking/components/Content/index.d.ts +1 -0
  15. package/es/components/appointmentBooking/components/Header/index.d.ts +1 -0
  16. package/es/components/appointmentBooking/components/Voucher/index.d.ts +1 -0
  17. package/es/components/appointmentBooking/deposit/index.d.ts +1 -0
  18. package/es/components/appointmentBooking/index.d.ts +1 -0
  19. package/es/components/booking/components/footer/index.d.ts +1 -0
  20. package/es/components/booking/deposit/index.d.ts +1 -0
  21. package/es/components/booking/hooks/useQuotation.d.ts +1 -0
  22. package/es/components/booking/info/addServiceVariant/index.d.ts +1 -0
  23. package/es/components/booking/info/header/index.d.ts +1 -0
  24. package/es/components/booking/info/hooks/useInfoHolder.d.ts +1 -0
  25. package/es/components/booking/info/index.d.ts +1 -0
  26. package/es/components/booking/info/service/Lists.d.ts +1 -0
  27. package/es/components/booking/info/service/addService/index.d.ts +1 -0
  28. package/es/components/booking/info/service/addTimeModal/index.d.ts +1 -0
  29. package/es/components/booking/info/service/editService/BookingList/index.d.ts +1 -0
  30. package/es/components/booking/info/service/serviceItem/index.d.ts +1 -0
  31. package/es/components/booking/info/service/serviceList/index.d.ts +1 -0
  32. package/es/components/booking/info/service2/Lists.d.ts +1 -0
  33. package/es/components/booking/info2/service/addTimeModal/index.d.ts +1 -0
  34. package/es/components/booking/info2/service/serviceItem/index.d.ts +1 -0
  35. package/es/components/booking/info2/service/serviceList/index.d.ts +1 -0
  36. package/es/components/booking/notes/addNote/index.d.ts +1 -0
  37. package/es/components/booking/utils.d.ts +2 -2
  38. package/es/components/eftpos/surcharge/index.d.ts +1 -0
  39. package/es/components/eftposPay/amount.d.ts +1 -1
  40. package/es/components/eftposPay/app.d.ts +1 -0
  41. package/es/components/eftposPay/device.d.ts +2 -1
  42. package/es/components/eftposPay/hooks.d.ts +1 -1
  43. package/es/components/eftposPay/index.d.ts +1 -0
  44. package/es/components/eftposPay/linkly/index.d.ts +1 -0
  45. package/es/components/eftposPay/store/index.d.ts +2 -2
  46. package/es/components/eventBooking/components/Provider/Cart/ContinueButton/index.d.ts +1 -0
  47. package/es/components/eventBooking/components/Provider/Cart/Item/Total.d.ts +1 -0
  48. package/es/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/CalenDateWeek/CallToBook/index.d.ts +1 -0
  49. package/es/components/eventBooking/components/scheduleCalendar/calendarItem.d.ts +1 -0
  50. package/es/components/eventBooking/index.d.ts +1 -0
  51. package/es/components/pay/toC/PaymentMethods/ApplePay/index.js +68 -35
  52. package/es/components/pay/toC/PaymentMethods/GooglePay/index.js +70 -42
  53. package/es/components/pay/toC/PaymentMethods/MWCreditCard/TDSPay/ThreedsLoading/index.d.ts +1 -0
  54. package/es/components/pay/toC/PaymentMethods/StripePay/Stripe/Finish/index.d.ts +1 -0
  55. package/es/components/pay/toC/PaymentMethods/StripePay/Stripe/StripeSDK/SDK.d.ts +1 -0
  56. package/es/components/pay/toC/PaymentMethods/StripePay/Stripe/components/PageLoading/index.d.ts +1 -0
  57. package/es/components/pay/toC/PaymentMethods/StripePay/Stripe/components/SetupForm/PaymentRequestForm.d.ts +1 -0
  58. package/es/components/pay/toC/PaymentMethods/SuperPayAliPayH5/index.js +72 -41
  59. package/es/components/pay/toC/PaymentMethods/components/PaymentReturnContent/index.d.ts +15 -0
  60. package/es/components/pay/toC/PaymentMethods/components/PaymentReturnContent/index.js +143 -0
  61. package/es/components/pay/toC/PaymentMethods/components/PaymentReturnContent/index.less +34 -0
  62. package/es/components/pay/toC/PaymentMethods/hooks/index.d.ts +19 -0
  63. package/es/components/pay/toC/PaymentMethods/hooks/index.js +126 -0
  64. package/es/components/pay/toC/index.js +3 -2
  65. package/es/components/pay/toC/locales.d.ts +9 -0
  66. package/es/components/pay/toC/locales.js +12 -3
  67. package/es/components/pay/toC/model.d.ts +1 -0
  68. package/es/components/pay/toC/serve.d.ts +5 -0
  69. package/es/components/pay/toC/serve.js +9 -1
  70. package/es/components/pisellSelectCustomerModal/RightPanel/Add/PhoneField/index.d.ts +1 -0
  71. package/es/components/pisellSelectCustomerModal/RightPanel/index.d.ts +1 -0
  72. package/es/components/pisellSelectCustomerModal/index.d.ts +1 -0
  73. package/es/components/productExtension/index.d.ts +1 -0
  74. package/es/components/productSelect/components/TabProduct/index.d.ts +1 -0
  75. package/es/components/productSelect/components/productGroup/index.d.ts +1 -0
  76. package/es/components/ruleSetting/index.d.ts +1 -0
  77. package/es/components/schedules/components/ScheduleList/RenderScheduleItem/index.d.ts +1 -0
  78. package/es/components/schedules/products/ProductDetailDrawer/ProductDetail/SchedulesModule/AddSchedules/index.d.ts +1 -0
  79. package/es/components/schedules/products/ProductDetailDrawer/ProductDetail/SchedulesModule/index.d.ts +1 -0
  80. package/es/components/shoppingCart/components/Cart/Product.d.ts +1 -0
  81. package/es/components/shoppingCart/components/Cart/index.d.ts +1 -0
  82. package/es/components/taxSelect/index.d.ts +1 -0
  83. package/es/components/ticketBooking/components/addServiceVariant/index.d.ts +1 -0
  84. package/es/components/ticketBooking/components/menuBar/index.d.ts +1 -0
  85. package/es/components/workSpaceList/components/SearchWorkspaceAndBase/index.d.ts +1 -0
  86. package/es/plus/saasCreateOrganization/index.d.ts +1 -0
  87. package/lib/businessModel/SalesModel/index.d.ts +1 -0
  88. package/lib/components/Sales/Event/Detail.js +3 -2
  89. package/lib/components/Sales/Summary/utils.d.ts +1 -1
  90. package/lib/components/appointmentBooking/components/Content/index.d.ts +1 -0
  91. package/lib/components/appointmentBooking/components/Header/index.d.ts +1 -0
  92. package/lib/components/appointmentBooking/components/Voucher/index.d.ts +1 -0
  93. package/lib/components/appointmentBooking/deposit/index.d.ts +1 -0
  94. package/lib/components/appointmentBooking/index.d.ts +1 -0
  95. package/lib/components/booking/components/footer/index.d.ts +1 -0
  96. package/lib/components/booking/deposit/index.d.ts +1 -0
  97. package/lib/components/booking/hooks/useQuotation.d.ts +1 -0
  98. package/lib/components/booking/info/addServiceVariant/index.d.ts +1 -0
  99. package/lib/components/booking/info/header/index.d.ts +1 -0
  100. package/lib/components/booking/info/hooks/useInfoHolder.d.ts +1 -0
  101. package/lib/components/booking/info/index.d.ts +1 -0
  102. package/lib/components/booking/info/service/Lists.d.ts +1 -0
  103. package/lib/components/booking/info/service/addService/index.d.ts +1 -0
  104. package/lib/components/booking/info/service/addTimeModal/index.d.ts +1 -0
  105. package/lib/components/booking/info/service/editService/BookingList/index.d.ts +1 -0
  106. package/lib/components/booking/info/service/serviceItem/index.d.ts +1 -0
  107. package/lib/components/booking/info/service/serviceList/index.d.ts +1 -0
  108. package/lib/components/booking/info/service2/Lists.d.ts +1 -0
  109. package/lib/components/booking/info2/service/addTimeModal/index.d.ts +1 -0
  110. package/lib/components/booking/info2/service/serviceItem/index.d.ts +1 -0
  111. package/lib/components/booking/info2/service/serviceList/index.d.ts +1 -0
  112. package/lib/components/booking/notes/addNote/index.d.ts +1 -0
  113. package/lib/components/booking/utils.d.ts +2 -2
  114. package/lib/components/eftpos/surcharge/index.d.ts +1 -0
  115. package/lib/components/eftposPay/amount.d.ts +1 -1
  116. package/lib/components/eftposPay/app.d.ts +1 -0
  117. package/lib/components/eftposPay/device.d.ts +2 -1
  118. package/lib/components/eftposPay/hooks.d.ts +1 -1
  119. package/lib/components/eftposPay/index.d.ts +1 -0
  120. package/lib/components/eftposPay/linkly/index.d.ts +1 -0
  121. package/lib/components/eftposPay/store/index.d.ts +2 -2
  122. package/lib/components/eventBooking/components/Provider/Cart/ContinueButton/index.d.ts +1 -0
  123. package/lib/components/eventBooking/components/Provider/Cart/Item/Total.d.ts +1 -0
  124. package/lib/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/CalenDateWeek/CallToBook/index.d.ts +1 -0
  125. package/lib/components/eventBooking/components/scheduleCalendar/calendarItem.d.ts +1 -0
  126. package/lib/components/eventBooking/index.d.ts +1 -0
  127. package/lib/components/pay/toC/PaymentMethods/ApplePay/index.js +27 -7
  128. package/lib/components/pay/toC/PaymentMethods/GooglePay/index.js +32 -8
  129. package/lib/components/pay/toC/PaymentMethods/MWCreditCard/TDSPay/ThreedsLoading/index.d.ts +1 -0
  130. package/lib/components/pay/toC/PaymentMethods/StripePay/Stripe/Finish/index.d.ts +1 -0
  131. package/lib/components/pay/toC/PaymentMethods/StripePay/Stripe/StripeSDK/SDK.d.ts +1 -0
  132. package/lib/components/pay/toC/PaymentMethods/StripePay/Stripe/components/PageLoading/index.d.ts +1 -0
  133. package/lib/components/pay/toC/PaymentMethods/StripePay/Stripe/components/SetupForm/PaymentRequestForm.d.ts +1 -0
  134. package/lib/components/pay/toC/PaymentMethods/SuperPayAliPayH5/index.js +30 -4
  135. package/lib/components/pay/toC/PaymentMethods/components/PaymentReturnContent/index.d.ts +15 -0
  136. package/lib/components/pay/toC/PaymentMethods/components/PaymentReturnContent/index.js +88 -0
  137. package/lib/components/pay/toC/PaymentMethods/components/PaymentReturnContent/index.less +34 -0
  138. package/lib/components/pay/toC/PaymentMethods/hooks/index.d.ts +19 -0
  139. package/lib/components/pay/toC/PaymentMethods/hooks/index.js +90 -0
  140. package/lib/components/pay/toC/index.js +2 -1
  141. package/lib/components/pay/toC/locales.d.ts +9 -0
  142. package/lib/components/pay/toC/locales.js +12 -3
  143. package/lib/components/pay/toC/model.d.ts +1 -0
  144. package/lib/components/pay/toC/serve.d.ts +5 -0
  145. package/lib/components/pay/toC/serve.js +3 -0
  146. package/lib/components/pisellSelectCustomerModal/RightPanel/Add/PhoneField/index.d.ts +1 -0
  147. package/lib/components/pisellSelectCustomerModal/RightPanel/index.d.ts +1 -0
  148. package/lib/components/pisellSelectCustomerModal/index.d.ts +1 -0
  149. package/lib/components/productExtension/index.d.ts +1 -0
  150. package/lib/components/productSelect/components/TabProduct/index.d.ts +1 -0
  151. package/lib/components/productSelect/components/productGroup/index.d.ts +1 -0
  152. package/lib/components/ruleSetting/index.d.ts +1 -0
  153. package/lib/components/schedules/components/ScheduleList/RenderScheduleItem/index.d.ts +1 -0
  154. package/lib/components/schedules/products/ProductDetailDrawer/ProductDetail/SchedulesModule/AddSchedules/index.d.ts +1 -0
  155. package/lib/components/schedules/products/ProductDetailDrawer/ProductDetail/SchedulesModule/index.d.ts +1 -0
  156. package/lib/components/shoppingCart/components/Cart/Product.d.ts +1 -0
  157. package/lib/components/shoppingCart/components/Cart/index.d.ts +1 -0
  158. package/lib/components/taxSelect/index.d.ts +1 -0
  159. package/lib/components/ticketBooking/components/addServiceVariant/index.d.ts +1 -0
  160. package/lib/components/ticketBooking/components/menuBar/index.d.ts +1 -0
  161. package/lib/components/workSpaceList/components/SearchWorkspaceAndBase/index.d.ts +1 -0
  162. package/lib/plus/saasCreateOrganization/index.d.ts +1 -0
  163. package/package.json +4 -4
@@ -17,6 +17,8 @@ import { getPayGroupParamsFromStorage } from "../../payGroup";
17
17
  import useEngineContext from "../../../../../hooks/useEngineContext";
18
18
  import usePaymentLogger from "../../../../../hooks/usePaymentLogger";
19
19
  import { clientPayment, formatFranchiseeRoute } from "../../utils";
20
+ import { usePaymentRedirect } from "../hooks";
21
+ import PaymentReturnContent from "../components/PaymentReturnContent";
20
22
  /**
21
23
  * @title: 谷歌支付
22
24
  * @description:
@@ -27,7 +29,7 @@ import { clientPayment, formatFranchiseeRoute } from "../../utils";
27
29
  * @Date: 2024-08-16 11:01
28
30
  */
29
31
  var GooglePay = function GooglePay(props, ref) {
30
- var _context$appHelper, _context$appHelper2, _state$payGroup;
32
+ var _context$appHelper, _context$appHelper2, _state$payGroup, _state$payGroup2, _state$payGroup4;
31
33
  var _useContext = useContext(Context),
32
34
  state = _useContext.state;
33
35
  var _useState = useState(false),
@@ -46,6 +48,15 @@ var GooglePay = function GooglePay(props, ref) {
46
48
  step: '2'
47
49
  });
48
50
 
51
+ // 使用支付跳转 hooks
52
+ var _usePaymentRedirect = usePaymentRedirect({
53
+ orderId: (_state$payGroup2 = state.payGroup) === null || _state$payGroup2 === void 0 ? void 0 : _state$payGroup2.order_id,
54
+ paymentType: 'googlePay'
55
+ }),
56
+ isReturned = _usePaymentRedirect.isReturned,
57
+ handleRedirect = _usePaymentRedirect.handleRedirect,
58
+ resetState = _usePaymentRedirect.resetState;
59
+
49
60
  /**
50
61
  * @title: 初始化
51
62
  * @description:
@@ -57,7 +68,7 @@ var GooglePay = function GooglePay(props, ref) {
57
68
  var init = /*#__PURE__*/function () {
58
69
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref2) {
59
70
  var _utils$getStore, _interaction$utils, _interaction$utils$is, _interaction$utils2, _interaction$utils2$i;
60
- var payGroup, utils, dvaStore, values, _dvaStore$core, _dvaStore$core2, _state$payGroup2, locale, shopId, currentURL, linkElement, shop_domain, _href;
71
+ var payGroup, utils, dvaStore, values, _dvaStore$core, _dvaStore$core2, _state$payGroup3, locale, shopId, currentURL, linkElement, shop_domain, _href;
61
72
  return _regeneratorRuntime().wrap(function _callee$(_context) {
62
73
  while (1) switch (_context.prev = _context.next) {
63
74
  case 0:
@@ -65,13 +76,14 @@ var GooglePay = function GooglePay(props, ref) {
65
76
  // 记录GooglePay初始化开始
66
77
  paymentLogger.addLog({
67
78
  key: 'GooglePay初始化开始',
68
- value: ""
79
+ value: ''
69
80
  });
81
+ setOpen(true);
70
82
  utils = context.appHelper.utils || {};
71
83
  dvaStore = utils === null || utils === void 0 || (_utils$getStore = utils.getStore) === null || _utils$getStore === void 0 || (_utils$getStore = _utils$getStore.call(utils)) === null || _utils$getStore === void 0 ? void 0 : _utils$getStore.getState(); // 获取交易组
72
84
  values = getPayGroupParamsFromStorage(payGroup.order_id);
73
85
  if (values) {
74
- _context.next = 10;
86
+ _context.next = 11;
75
87
  break;
76
88
  }
77
89
  // 记录获取支付参数失败
@@ -87,20 +99,20 @@ var GooglePay = function GooglePay(props, ref) {
87
99
  paymentLogger.sendLogs('GooglePay获取支付参数失败');
88
100
  setOpen(false);
89
101
  return _context.abrupt("return");
90
- case 10:
102
+ case 11:
91
103
  // 记录获取支付参数成功
92
104
  paymentLogger.addLog({
93
105
  key: 'GooglePay获取支付参数成功',
94
- value: ""
106
+ value: ''
95
107
  });
96
108
  if (!(interaction !== null && interaction !== void 0 && (_interaction$utils = interaction.utils) !== null && _interaction$utils !== void 0 && (_interaction$utils$is = _interaction$utils.isAppEnv) !== null && _interaction$utils$is !== void 0 && _interaction$utils$is.call(_interaction$utils) && (interaction === null || interaction === void 0 || (_interaction$utils2 = interaction.utils) === null || _interaction$utils2 === void 0 || (_interaction$utils2$i = _interaction$utils2.isAndroid_ios) === null || _interaction$utils2$i === void 0 ? void 0 : _interaction$utils2$i.call(_interaction$utils2)) === 'android')) {
97
- _context.next = 15;
109
+ _context.next = 16;
98
110
  break;
99
111
  }
100
112
  // 记录Android客户端支付
101
113
  paymentLogger.addLog({
102
114
  key: 'GooglePay使用Android客户端支付',
103
- value: ""
115
+ value: ''
104
116
  });
105
117
  paymentLogger.sendLogs('GooglePay客户端支付');
106
118
  return _context.abrupt("return", clientPayment({
@@ -109,44 +121,48 @@ var GooglePay = function GooglePay(props, ref) {
109
121
  values: values,
110
122
  interaction: interaction
111
123
  }));
112
- case 15:
113
- setOpen(true);
114
- try {
115
- locale = ((_dvaStore$core = dvaStore.core) === null || _dvaStore$core === void 0 ? void 0 : _dvaStore$core.translateLocale) || 'en';
116
- shopId = (_dvaStore$core2 = dvaStore.core) === null || _dvaStore$core2 === void 0 || (_dvaStore$core2 = _dvaStore$core2.core) === null || _dvaStore$core2 === void 0 || (_dvaStore$core2 = _dvaStore$core2.shop) === null || _dvaStore$core2 === void 0 ? void 0 : _dvaStore$core2.id;
117
- currentURL = window.location.href; // 创建一个a元素,用于解析URL
118
- linkElement = document.createElement('a');
119
- linkElement.href = currentURL;
124
+ case 16:
125
+ _context.prev = 16;
126
+ locale = ((_dvaStore$core = dvaStore.core) === null || _dvaStore$core === void 0 ? void 0 : _dvaStore$core.translateLocale) || 'en';
127
+ shopId = (_dvaStore$core2 = dvaStore.core) === null || _dvaStore$core2 === void 0 || (_dvaStore$core2 = _dvaStore$core2.core) === null || _dvaStore$core2 === void 0 || (_dvaStore$core2 = _dvaStore$core2.shop) === null || _dvaStore$core2 === void 0 ? void 0 : _dvaStore$core2.id;
128
+ currentURL = window.location.href; // 创建一个a元素,用于解析URL
129
+ linkElement = document.createElement('a');
130
+ linkElement.href = currentURL;
120
131
 
121
- // 提取域名
122
- shop_domain = linkElement.hostname;
123
- _href = "".concat(config.pay).concat(formatFranchiseeRoute("/google-pay?order_id=".concat((_state$payGroup2 = state.payGroup) === null || _state$payGroup2 === void 0 ? void 0 : _state$payGroup2.order_id, "&shop_id=").concat(shopId, "&locale=").concat(locale, "&shop_domain=").concat(shop_domain, "&total_amount=").concat(values.amount, "&payment_group_id=").concat(values.payment_group_id), state.history)); // 记录即将跳转到GooglePay
124
- paymentLogger.addLog({
125
- key: 'GooglePay准备跳转',
126
- value: ""
127
- });
128
- paymentLogger.sendLogs('GooglePay跳转成功');
129
- window.location.href = _href;
130
- } catch (err) {
131
- // 记录GooglePay处理错误
132
- paymentLogger.addLog({
133
- key: 'GooglePay处理错误',
134
- value: {
135
- title: "\u8BA2\u5355".concat(payGroup === null || payGroup === void 0 ? void 0 : payGroup.order_id, " GooglePay\u5904\u7406\u5931\u8D25: ").concat((err === null || err === void 0 ? void 0 : err.message) || '未知错误'),
136
- data: {
137
- payGroup: payGroup,
138
- values: values
139
- }
132
+ // 提取域名
133
+ shop_domain = linkElement.hostname;
134
+ _href = "".concat(config.pay).concat(formatFranchiseeRoute("/google-pay?order_id=".concat((_state$payGroup3 = state.payGroup) === null || _state$payGroup3 === void 0 ? void 0 : _state$payGroup3.order_id, "&shop_id=").concat(shopId, "&locale=").concat(locale, "&shop_domain=").concat(shop_domain, "&total_amount=").concat(values.amount, "&payment_group_id=").concat(values.payment_group_id, "&front_order_uuid=").concat(state.front_order_uuid), state.history)); // 记录即将跳转到GooglePay
135
+ paymentLogger.addLog({
136
+ key: 'GooglePay准备跳转',
137
+ value: ''
138
+ });
139
+ paymentLogger.sendLogs('GooglePay跳转成功');
140
+ _context.next = 28;
141
+ return handleRedirect(_href);
142
+ case 28:
143
+ _context.next = 35;
144
+ break;
145
+ case 30:
146
+ _context.prev = 30;
147
+ _context.t0 = _context["catch"](16);
148
+ // 记录GooglePay处理错误
149
+ paymentLogger.addLog({
150
+ key: 'GooglePay处理错误',
151
+ value: {
152
+ title: "\u8BA2\u5355".concat(payGroup === null || payGroup === void 0 ? void 0 : payGroup.order_id, " GooglePay\u5904\u7406\u5931\u8D25: ").concat((_context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.message) || '未知错误'),
153
+ data: {
154
+ payGroup: payGroup,
155
+ values: values
140
156
  }
141
- });
142
- paymentLogger.sendLogs('GooglePay处理失败', err);
143
- setOpen(false);
144
- }
145
- case 17:
157
+ }
158
+ });
159
+ paymentLogger.sendLogs('GooglePay处理失败', _context.t0);
160
+ setOpen(false);
161
+ case 35:
146
162
  case "end":
147
163
  return _context.stop();
148
164
  }
149
- }, _callee);
165
+ }, _callee, null, [[16, 30]]);
150
166
  }));
151
167
  return function init(_x) {
152
168
  return _ref3.apply(this, arguments);
@@ -157,6 +173,10 @@ var GooglePay = function GooglePay(props, ref) {
157
173
  init: init
158
174
  };
159
175
  });
176
+ var handleReturn = function handleReturn() {
177
+ setOpen(false);
178
+ resetState();
179
+ };
160
180
  return /*#__PURE__*/React.createElement(PisellModal, {
161
181
  platform: 'h5',
162
182
  open: open,
@@ -168,8 +188,16 @@ var GooglePay = function GooglePay(props, ref) {
168
188
  }
169
189
  }, /*#__PURE__*/React.createElement("div", {
170
190
  className: ""
171
- }, /*#__PURE__*/React.createElement(ThreedsLoading, {
191
+ }, !isReturned && /*#__PURE__*/React.createElement(ThreedsLoading, {
172
192
  title: locales.getText('tocPay.text.connectingGooglePay')
193
+ }), isReturned &&
194
+ /*#__PURE__*/
195
+ // 跳转后返回时展示新组件内容
196
+ React.createElement(PaymentReturnContent, {
197
+ handleReturn: handleReturn,
198
+ state: state,
199
+ orderId: (_state$payGroup4 = state.payGroup) === null || _state$payGroup4 === void 0 ? void 0 : _state$payGroup4.order_id,
200
+ unique_payment_number: state.front_order_uuid
173
201
  })));
174
202
  };
175
203
  export default /*#__PURE__*/forwardRef(GooglePay);
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import './index.less';
2
3
  declare const ThreedsLoading: ({ title, showSuccessBackButton, onSuccessBack }: any) => JSX.Element;
3
4
  export default ThreedsLoading;
@@ -1,2 +1,3 @@
1
+ /// <reference types="react" />
1
2
  declare const StripePayment: () => JSX.Element;
2
3
  export default StripePayment;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  declare const StripeSDK: ({ public_key, client_secret, children, lang, }: {
2
3
  public_key: string;
3
4
  client_secret?: string | undefined;
@@ -1,2 +1,3 @@
1
+ /// <reference types="react" />
1
2
  declare const PageLoading: () => JSX.Element;
2
3
  export default PageLoading;
@@ -1,2 +1,3 @@
1
+ /// <reference types="react" />
1
2
  declare const PaymentRequestForm: () => JSX.Element | null;
2
3
  export default PaymentRequestForm;
@@ -19,6 +19,8 @@ import "./index.less";
19
19
  import useEngineContext from "../../../../../hooks/useEngineContext";
20
20
  import usePaymentLogger from "../../../../../hooks/usePaymentLogger";
21
21
  import { clientPayment } from "../../utils";
22
+ import { usePaymentRedirect } from "../hooks";
23
+ import PaymentReturnContent from "../components/PaymentReturnContent";
22
24
  /**
23
25
  * @title: 支付宝支付
24
26
  * @description:
@@ -27,7 +29,7 @@ import { clientPayment } from "../../utils";
27
29
  * @Date: 2024-08-16 11:18
28
30
  */
29
31
  var SuperPayAliPayH5 = function SuperPayAliPayH5(props, ref) {
30
- var _context$appHelper, _state$payGroup;
32
+ var _context$appHelper, _state$payGroup, _state$payGroup2, _state$payGroup3;
31
33
  var _useContext = useContext(Context),
32
34
  state = _useContext.state;
33
35
  var onChange = props.onChange;
@@ -39,6 +41,10 @@ var SuperPayAliPayH5 = function SuperPayAliPayH5(props, ref) {
39
41
  _useState4 = _slicedToArray(_useState3, 2),
40
42
  showSuccessBackButton = _useState4[0],
41
43
  setShowSuccessBackButton = _useState4[1];
44
+ var _useState5 = useState(''),
45
+ _useState6 = _slicedToArray(_useState5, 2),
46
+ statePayNumber = _useState6[0],
47
+ setStatePayNumber = _useState6[1];
42
48
  var context = useEngineContext();
43
49
  var _context$appHelper$ut = (_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 ? void 0 : _context$appHelper.utils,
44
50
  interaction = _context$appHelper$ut.interaction;
@@ -49,6 +55,15 @@ var SuperPayAliPayH5 = function SuperPayAliPayH5(props, ref) {
49
55
  step: '2'
50
56
  });
51
57
 
58
+ // 使用支付跳转 hooks
59
+ var _usePaymentRedirect = usePaymentRedirect({
60
+ orderId: (_state$payGroup2 = state.payGroup) === null || _state$payGroup2 === void 0 ? void 0 : _state$payGroup2.order_id,
61
+ paymentType: 'aliPay'
62
+ }),
63
+ isReturned = _usePaymentRedirect.isReturned,
64
+ handleRedirect = _usePaymentRedirect.handleRedirect,
65
+ resetState = _usePaymentRedirect.resetState;
66
+
52
67
  /**
53
68
  * @title: 初始化
54
69
  * @description:
@@ -68,7 +83,7 @@ var SuperPayAliPayH5 = function SuperPayAliPayH5(props, ref) {
68
83
  // 记录SuperPayAliPayH5初始化开始
69
84
  paymentLogger.addLog({
70
85
  key: 'SuperPayAliPayH5初始化开始',
71
- value: ""
86
+ value: ''
72
87
  });
73
88
 
74
89
  // 交易组
@@ -80,7 +95,7 @@ var SuperPayAliPayH5 = function SuperPayAliPayH5(props, ref) {
80
95
  // 记录App环境检测
81
96
  paymentLogger.addLog({
82
97
  key: 'SuperPayAliPayH5App环境检测',
83
- value: "检测到App环境,调用客户端支付"
98
+ value: '检测到App环境,调用客户端支付'
84
99
  });
85
100
  paymentLogger.sendLogs('SuperPayAliPayH5App环境支付');
86
101
  return _context.abrupt("return", clientPayment({
@@ -112,51 +127,57 @@ var SuperPayAliPayH5 = function SuperPayAliPayH5(props, ref) {
112
127
  // 记录获取支付参数成功
113
128
  paymentLogger.addLog({
114
129
  key: 'SuperPayAliPayH5获取支付参数成功',
115
- value: ""
130
+ value: ''
116
131
  });
117
132
  _context.prev = 14;
118
133
  _context.next = 17;
119
134
  return getAliPayUrl(payGroup.order_id, values);
120
135
  case 17:
121
136
  data = _context.sent;
122
- if (data !== null && data !== void 0 && data.pay_url) {
123
- // 记录获取支付宝支付链接成功
124
- paymentLogger.addLog({
125
- key: 'SuperPayAliPayH5获取支付链接成功',
126
- value: ""
127
- });
128
-
129
- // 设置交易号
130
- setPayNumber(payGroup === null || payGroup === void 0 ? void 0 : payGroup.order_id, data === null || data === void 0 ? void 0 : data.pay_number);
131
- setShowSuccessBackButton(true);
137
+ if (!(data !== null && data !== void 0 && data.pay_url)) {
138
+ _context.next = 29;
139
+ break;
140
+ }
141
+ // 记录获取支付宝支付链接成功
142
+ paymentLogger.addLog({
143
+ key: 'SuperPayAliPayH5获取支付链接成功',
144
+ value: ''
145
+ });
132
146
 
133
- // 记录即将跳转到支付宝
134
- paymentLogger.addLog({
135
- key: 'SuperPayAliPayH5准备跳转支付宝',
136
- value: ""
137
- });
138
- paymentLogger.sendLogs('SuperPayAliPayH5跳转成功');
147
+ // 设置交易号
148
+ setPayNumber(payGroup === null || payGroup === void 0 ? void 0 : payGroup.order_id, data === null || data === void 0 ? void 0 : data.pay_number);
149
+ setStatePayNumber(data === null || data === void 0 ? void 0 : data.pay_number);
150
+ setShowSuccessBackButton(true);
139
151
 
140
- // 跳转
141
- window.location.href = data === null || data === void 0 ? void 0 : data.pay_url;
142
- } else {
143
- // 记录支付链接为空
144
- paymentLogger.addLog({
145
- key: 'SuperPayAliPayH5支付链接为空',
146
- value: {
147
- title: "\u8BA2\u5355".concat(payGroup === null || payGroup === void 0 ? void 0 : payGroup.order_id, " \u652F\u4ED8\u5B9D\u652F\u4ED8\u94FE\u63A5\u4E3A\u7A7A"),
148
- data: {
149
- response_data: data
150
- }
152
+ // 记录即将跳转到支付宝
153
+ paymentLogger.addLog({
154
+ key: 'SuperPayAliPayH5准备跳转支付宝',
155
+ value: ''
156
+ });
157
+ paymentLogger.sendLogs('SuperPayAliPayH5跳转成功');
158
+ _context.next = 27;
159
+ return handleRedirect(data === null || data === void 0 ? void 0 : data.pay_url);
160
+ case 27:
161
+ _context.next = 32;
162
+ break;
163
+ case 29:
164
+ // 记录支付链接为空
165
+ paymentLogger.addLog({
166
+ key: 'SuperPayAliPayH5支付链接为空',
167
+ value: {
168
+ title: "\u8BA2\u5355".concat(payGroup === null || payGroup === void 0 ? void 0 : payGroup.order_id, " \u652F\u4ED8\u5B9D\u652F\u4ED8\u94FE\u63A5\u4E3A\u7A7A"),
169
+ data: {
170
+ response_data: data
151
171
  }
152
- });
153
- paymentLogger.sendLogs('SuperPayAliPayH5支付链接为空');
154
- setOpen(false);
155
- }
156
- _context.next = 26;
172
+ }
173
+ });
174
+ paymentLogger.sendLogs('SuperPayAliPayH5支付链接为空');
175
+ setOpen(false);
176
+ case 32:
177
+ _context.next = 39;
157
178
  break;
158
- case 21:
159
- _context.prev = 21;
179
+ case 34:
180
+ _context.prev = 34;
160
181
  _context.t0 = _context["catch"](14);
161
182
  // 记录SuperPayAliPayH5处理错误
162
183
  paymentLogger.addLog({
@@ -171,11 +192,11 @@ var SuperPayAliPayH5 = function SuperPayAliPayH5(props, ref) {
171
192
  });
172
193
  paymentLogger.sendLogs('SuperPayAliPayH5处理失败', _context.t0);
173
194
  setOpen(false);
174
- case 26:
195
+ case 39:
175
196
  case "end":
176
197
  return _context.stop();
177
198
  }
178
- }, _callee, null, [[14, 21]]);
199
+ }, _callee, null, [[14, 34]]);
179
200
  }));
180
201
  return function init(_x) {
181
202
  return _ref2.apply(this, arguments);
@@ -192,6 +213,10 @@ var SuperPayAliPayH5 = function SuperPayAliPayH5(props, ref) {
192
213
  key: 'success'
193
214
  });
194
215
  };
216
+ var handleReturn = function handleReturn() {
217
+ setOpen(false);
218
+ resetState();
219
+ };
195
220
  return /*#__PURE__*/React.createElement(PisellModal, {
196
221
  platform: 'h5',
197
222
  open: open,
@@ -203,10 +228,16 @@ var SuperPayAliPayH5 = function SuperPayAliPayH5(props, ref) {
203
228
  }
204
229
  }, /*#__PURE__*/React.createElement("div", {
205
230
  className: ""
206
- }, /*#__PURE__*/React.createElement(ThreedsLoading, {
231
+ }, !isReturned && /*#__PURE__*/React.createElement(ThreedsLoading, {
207
232
  title: locales.getText('tocPay.text.redirectingToAlipay'),
208
233
  onSuccessBack: handleSuccessBack,
209
234
  showSuccessBackButton: showSuccessBackButton
235
+ }), isReturned && /*#__PURE__*/React.createElement(PaymentReturnContent, {
236
+ pay_number: statePayNumber,
237
+ handleReturn: handleReturn,
238
+ state: state,
239
+ orderId: (_state$payGroup3 = state.payGroup) === null || _state$payGroup3 === void 0 ? void 0 : _state$payGroup3.order_id,
240
+ unique_payment_number: state.front_order_uuid
210
241
  })));
211
242
  };
212
243
  export default /*#__PURE__*/forwardRef(SuperPayAliPayH5);
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import './index.less';
3
+ export interface PaymentReturnContentProps {
4
+ orderId?: string;
5
+ unique_payment_number?: string;
6
+ state?: any;
7
+ handleReturn?: () => void;
8
+ pay_number?: string;
9
+ }
10
+ /**
11
+ * 支付返回后展示的内容组件
12
+ * 当用户从外部支付页面返回时展示此组件
13
+ */
14
+ declare const PaymentReturnContent: React.FC<PaymentReturnContentProps>;
15
+ export default PaymentReturnContent;
@@ -0,0 +1,143 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
3
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
5
+ import React from 'react';
6
+ import { Button, PisellToast } from '@pisell/materials';
7
+ import { locales } from '@pisell/utils';
8
+ import { useMemoizedFn } from 'ahooks';
9
+ import { getPaymentResult } from "../../../serve";
10
+ import usePrefix from "../../../../../../hooks/usePrefix";
11
+ import "./index.less";
12
+ /**
13
+ * 支付返回后展示的内容组件
14
+ * 当用户从外部支付页面返回时展示此组件
15
+ */
16
+ var PaymentReturnContent = function PaymentReturnContent(_ref) {
17
+ var orderId = _ref.orderId,
18
+ unique_payment_number = _ref.unique_payment_number,
19
+ state = _ref.state,
20
+ handleReturn = _ref.handleReturn,
21
+ pay_number = _ref.pay_number;
22
+ var prefix = usePrefix();
23
+ var getPaymentIsPaid = useMemoizedFn( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
24
+ var _yield$getPaymentResu, data;
25
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
26
+ while (1) switch (_context.prev = _context.next) {
27
+ case 0:
28
+ if (!(!unique_payment_number && !pay_number)) {
29
+ _context.next = 2;
30
+ break;
31
+ }
32
+ return _context.abrupt("return", true);
33
+ case 2:
34
+ _context.next = 4;
35
+ return getPaymentResult({
36
+ order_id: orderId,
37
+ pay_number: pay_number,
38
+ unique_payment_number: pay_number ? undefined : unique_payment_number
39
+ });
40
+ case 4:
41
+ _yield$getPaymentResu = _context.sent;
42
+ data = _yield$getPaymentResu.data;
43
+ return _context.abrupt("return", (data === null || data === void 0 ? void 0 : data.payment_status) === 'paid');
44
+ case 7:
45
+ case "end":
46
+ return _context.stop();
47
+ }
48
+ }, _callee);
49
+ })));
50
+
51
+ /**
52
+ * 查看订单
53
+ * @returns
54
+ */
55
+ var handleViewOrder = /*#__PURE__*/function () {
56
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
57
+ var _state$payCallback;
58
+ var isPaid;
59
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
60
+ while (1) switch (_context2.prev = _context2.next) {
61
+ case 0:
62
+ _context2.next = 2;
63
+ return getPaymentIsPaid();
64
+ case 2:
65
+ isPaid = _context2.sent;
66
+ if (isPaid) {
67
+ _context2.next = 6;
68
+ break;
69
+ }
70
+ PisellToast({
71
+ content: locales.getText('tocPay.text.paymentFailed')
72
+ });
73
+ return _context2.abrupt("return");
74
+ case 6:
75
+ // 如果已支付,则跳转至订单详情
76
+ (_state$payCallback = state.payCallback) === null || _state$payCallback === void 0 || _state$payCallback.call(state, {
77
+ key: 'success'
78
+ });
79
+ case 7:
80
+ case "end":
81
+ return _context2.stop();
82
+ }
83
+ }, _callee2);
84
+ }));
85
+ return function handleViewOrder() {
86
+ return _ref3.apply(this, arguments);
87
+ };
88
+ }();
89
+
90
+ /**
91
+ * 返回并选择其他支付方式
92
+ * @returns
93
+ */
94
+ var handleGoBack = /*#__PURE__*/function () {
95
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
96
+ var isPaid, _state$payCallback2;
97
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
98
+ while (1) switch (_context3.prev = _context3.next) {
99
+ case 0:
100
+ _context3.next = 2;
101
+ return getPaymentIsPaid();
102
+ case 2:
103
+ isPaid = _context3.sent;
104
+ if (isPaid) {
105
+ _context3.next = 8;
106
+ break;
107
+ }
108
+ handleReturn === null || handleReturn === void 0 || handleReturn();
109
+ return _context3.abrupt("return");
110
+ case 8:
111
+ // 如果已支付,则跳转至订单详情
112
+ (_state$payCallback2 = state.payCallback) === null || _state$payCallback2 === void 0 || _state$payCallback2.call(state, {
113
+ key: 'success'
114
+ });
115
+ case 9:
116
+ case "end":
117
+ return _context3.stop();
118
+ }
119
+ }, _callee3);
120
+ }));
121
+ return function handleGoBack() {
122
+ return _ref4.apply(this, arguments);
123
+ };
124
+ }();
125
+ return /*#__PURE__*/React.createElement("div", {
126
+ className: "payment-return-content"
127
+ }, /*#__PURE__*/React.createElement("div", {
128
+ className: "payment-return-content-img"
129
+ }, /*#__PURE__*/React.createElement("img", {
130
+ src: "".concat(prefix, "/payment-content.png"),
131
+ alt: "success"
132
+ })), /*#__PURE__*/React.createElement("div", {
133
+ className: "payment-return-content-buttons"
134
+ }, /*#__PURE__*/React.createElement(Button, {
135
+ block: true,
136
+ className: "payment-return-content-order-button",
137
+ onClick: handleViewOrder
138
+ }, locales.getText('tocPay.text.paymentCompletedAndViewOrder')), /*#__PURE__*/React.createElement(Button, {
139
+ block: true,
140
+ onClick: handleGoBack
141
+ }, locales.getText('tocPay.text.returnAndSelectOtherPaymentMethod'))));
142
+ };
143
+ export default PaymentReturnContent;
@@ -0,0 +1,34 @@
1
+ .payment-return-content {
2
+ padding: 100px 46px 0;
3
+
4
+ .payment-return-content-img {
5
+ width: 100%;
6
+ margin-bottom: 60px;
7
+ min-height: 270px;
8
+ img {
9
+ width: 100%;
10
+ height: 100%;
11
+ }
12
+ }
13
+
14
+ .payment-return-content-buttons {
15
+ display: flex;
16
+ flex-direction: column;
17
+ gap: 24px;
18
+ button {
19
+ border-radius: 40px;
20
+ span {
21
+ width: 100%;
22
+ text-overflow: ellipsis;
23
+ overflow: hidden;
24
+ }
25
+ }
26
+ .payment-return-content-order-button {
27
+ background: #7F56DA;
28
+ color: var(--Primary-700, #6941C6);
29
+ border: 1px solid var(--Primary-200, #E9D7FE);
30
+ background: var(--Primary-50, #F9F5FF);
31
+ }
32
+ }
33
+ }
34
+
@@ -0,0 +1,19 @@
1
+ export interface UsePaymentRedirectOptions {
2
+ orderId?: string;
3
+ paymentType: string;
4
+ onAfterReturn?: () => void;
5
+ }
6
+ export interface UsePaymentRedirectReturn {
7
+ isReturned: boolean;
8
+ handleRedirect: (url: string) => Promise<void>;
9
+ resetState: () => void;
10
+ }
11
+ /**
12
+ * 支付跳转 Hook
13
+ * 用于处理跳转到外部支付页面的逻辑,包括:
14
+ * 1. 保存跳转标记到 history state
15
+ * 2. 跳转到外部支付页面
16
+ * 3. 监听页面返回事件
17
+ * 4. 返回后更新状态
18
+ */
19
+ export declare const usePaymentRedirect: (options: UsePaymentRedirectOptions) => UsePaymentRedirectReturn;