@alipay/ams-checkout 0.0.1782095417-dev.2 → 0.0.1782095417-dev.3

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.
@@ -1,159 +0,0 @@
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 _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
5
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
6
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
7
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
8
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
9
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
10
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
11
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
12
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
13
- /**
14
- * 为 GOOGLEPAY 支付方式补充 mock 的 paymentMethodDetail 数据
15
- * 预览模式下 GooglePay 需要完整的 googlePayProps 才能正常渲染
16
- */
17
- function handleGooglePayMethodDetail(method) {
18
- if (method.paymentMethodType === 'GOOGLEPAY') {
19
- method.paymentMethodDetail = _objectSpread(_objectSpread({}, method.paymentMethodDetail), {}, {
20
- googlePayProps: {
21
- environment: 'TEST',
22
- existingPaymentMethodRequired: true,
23
- paymentRequest: {
24
- allowedPaymentMethods: [{
25
- parameters: {
26
- allowedAuthMethods: ['PAN_ONLY', 'CRYPTOGRAM_3DS'],
27
- allowedCardNetworks: ['VISA', 'JCB']
28
- },
29
- tokenizationSpecification: {
30
- parameters: {
31
- protocolVersion: 'ECv2',
32
- publicKey: 'BDM6GVTLZmxSmTQzm04QKI2av54kFpkqjhbkejtdDUx+VMvUtJ6vc+ZlDp8TygNTf+QeihxpD869sCVWaa0KMJc='
33
- },
34
- type: 'DIRECT'
35
- },
36
- type: 'CARD'
37
- }],
38
- apiVersion: 2,
39
- apiVersionMinor: 0,
40
- callbackIntents: ['PAYMENT_AUTHORIZATION'],
41
- merchantInfo: {
42
- merchantId: '123',
43
- merchantName: 'merchantName'
44
- },
45
- shippingAddressRequired: true,
46
- transactionInfo: {
47
- countryCode: 'US',
48
- currencyCode: 'EUR',
49
- totalPrice: '10',
50
- totalPriceStatus: 'FINAL'
51
- }
52
- }
53
- }
54
- });
55
- }
56
- }
57
-
58
- /**
59
- * 为 ONLINEBANKING_YAPILY 支付方式处理 mock 数据
60
- * Yapily 在预览模式下需要清空 paymentElements
61
- */
62
- function handleYapilyMethodDetail(method) {
63
- if (method.paymentMethodType === 'ONLINEBANKING_YAPILY') {
64
- method.paymentElements = [];
65
- }
66
- }
67
-
68
- /**
69
- * 合并所有的 Card 类支付方式
70
- * 与 CKP handleAllCardsData 逻辑一致
71
- */
72
- function handleAllCardsData() {
73
- var supportedMethods = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
74
- var firstCardIndex = -1;
75
- var logoList = [];
76
- supportedMethods.forEach(function (item, index) {
77
- if (item.paymentMethodName === 'CARD') {
78
- logoList.push({
79
- cardBrand: item.paymentMethodType,
80
- logoUrl: item.logoUrl || ''
81
- });
82
- if (firstCardIndex === -1) {
83
- firstCardIndex = index;
84
- }
85
- }
86
- });
87
- if (logoList.length) {
88
- return {
89
- firstCardIndex: firstCardIndex,
90
- cardPaymentMethod: {
91
- antomPage: 'paymentMetaPage',
92
- category: 'CARD',
93
- expressCheckout: false,
94
- logoList: logoList,
95
- paymentMethod: 'CARD',
96
- paymentMethodName: 'Card',
97
- paymentMethodType: 'CARD',
98
- recommend: false,
99
- webRedirectType: 'PAGE_REFRESH'
100
- }
101
- };
102
- }
103
- return null;
104
- }
105
-
106
- /**
107
- * 将 paymentMethods 配置转换为内部格式
108
- * 与 CKP 的 convertPaymentMethods 逻辑保持一致
109
- */
110
- export function convertPaymentMethods(paymentMethodsConf) {
111
- if (!paymentMethodsConf) {
112
- return [];
113
- }
114
- var expressCheckout = paymentMethodsConf.expressCheckout,
115
- supportedMethods = paymentMethodsConf.supportedMethods,
116
- topping = paymentMethodsConf.topping;
117
-
118
- // 1. 处理极速支付(排在最前面)
119
- var supportedExpressCheckoutMethods = ((expressCheckout === null || expressCheckout === void 0 ? void 0 : expressCheckout.methods) || []).map(function (item) {
120
- var method = {
121
- paymentMethodName: item.paymentMethodName,
122
- paymentMethodType: item.paymentMethodType,
123
- category: item.paymentMethodType,
124
- expressCheckout: true
125
- };
126
- handleGooglePayMethodDetail(method);
127
- return method;
128
- });
129
-
130
- // 2. 处理普通支付方式(跳过 CARD,CARD 统一合并处理)
131
- var supportedPaymentMethods = [];
132
- (supportedMethods || []).forEach(function (item) {
133
- if (item.paymentMethodName === 'CARD') {
134
- return;
135
- }
136
- var method = {
137
- paymentMethodName: item.paymentMethodName,
138
- paymentMethodType: item.paymentMethodType,
139
- category: item.paymentMethodType,
140
- icon: item.logoUrl,
141
- recommend: false
142
- };
143
- if (method.paymentMethodType === topping) {
144
- method.recommend = true;
145
- }
146
- handleGooglePayMethodDetail(method);
147
- handleYapilyMethodDetail(method);
148
- supportedPaymentMethods.push(method);
149
- });
150
-
151
- // 3. 合并所有的 Card 类支付方式
152
- var cardPaymentMethods = handleAllCardsData(supportedMethods);
153
-
154
- // 4. 插入 Card 类支付方式 (card 第一次出现的位置)
155
- if (cardPaymentMethods) {
156
- supportedPaymentMethods.splice(cardPaymentMethods.firstCardIndex, 0, cardPaymentMethods.cardPaymentMethod);
157
- }
158
- return [].concat(_toConsumableArray(supportedExpressCheckoutMethods), supportedPaymentMethods);
159
- }