@alipay/ams-checkout 0.0.1701393225-dev.14 → 0.0.1701393225-dev.16

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.
@@ -44,9 +44,7 @@ var ApplePayService = /*#__PURE__*/function () {
44
44
  merchantIdentifier: _this.merchantIdentifier,
45
45
  validationUrl: event.validationURL
46
46
  }).then(function (merchantSessionObjectString) {
47
- console.log('merchantSessionObjectString', merchantSessionObjectString);
48
47
  var merchantSessionObject = JSON.parse(merchantSessionObjectString);
49
- console.log('merchantSessionObject', merchantSessionObject);
50
48
  _this.session.completeMerchantValidation(merchantSessionObject);
51
49
  _this.applePayTrace('completeMerchantValidation');
52
50
  }).catch(function (error) {
@@ -56,7 +54,6 @@ var ApplePayService = /*#__PURE__*/function () {
56
54
  });
57
55
  _defineProperty(this, "onpaymentauthorized", function (event) {
58
56
  var _event$payment;
59
- console.log('onpaymentauthorized', event);
60
57
  _this.applePayTrace('onpaymentauthorized');
61
58
  var _window = window,
62
59
  ApplePaySession = _window.ApplePaySession;
@@ -70,7 +67,6 @@ var ApplePayService = /*#__PURE__*/function () {
70
67
  _this.completePaymentAuthorized({
71
68
  paymentToken: JSON.stringify(event.payment.token)
72
69
  }).then(function (data) {
73
- console.log('onpaymentauthorized then', data);
74
70
  _this.applePayTrace('completeApplePay');
75
71
  _this.session.completePayment(ApplePaySession.STATUS_SUCCESS);
76
72
  _this.completeApplePay(data);
@@ -97,14 +93,12 @@ var ApplePayService = /*#__PURE__*/function () {
97
93
  paymentAmount = paymentSessionFactor.paymentAmount,
98
94
  order = paymentSessionFactor.order;
99
95
  _this.merchantIdentifier = merchantInfo === null || merchantInfo === void 0 ? void 0 : merchantInfo.partnerId;
100
- // TODO 参数判空处理
101
96
  var request = {
102
97
  merchantCapabilities: applePay === null || applePay === void 0 ? void 0 : applePay.merchantCapabilities,
103
98
  supportedNetworks: applePay === null || applePay === void 0 ? void 0 : applePay.supportedNetworks,
104
99
  countryCode: merchantInfo === null || merchantInfo === void 0 ? void 0 : merchantInfo.registeredCountry,
105
100
  currencyCode: paymentAmount === null || paymentAmount === void 0 ? void 0 : paymentAmount.currency,
106
101
  total: {
107
- // todo 待确认
108
102
  type: 'final',
109
103
  label: order === null || order === void 0 ? void 0 : order.orderDescription,
110
104
  amount: paymentAmount === null || paymentAmount === void 0 ? void 0 : paymentAmount.value
@@ -14,6 +14,7 @@ declare class ApplePayComponent extends CoreInstance {
14
14
  private _applePayService;
15
15
  private _parseData;
16
16
  private _sessionData;
17
+ private _isFinish;
17
18
  constructor(options: IApplePayOptionsParams);
18
19
  private getDeviceIdAndLog;
19
20
  private logDeviceId;
@@ -25,6 +26,6 @@ declare class ApplePayComponent extends CoreInstance {
25
26
  * Submit Pay
26
27
  * @param paymentSessionData
27
28
  */
28
- submitPay(paymentSessionData: string): Promise<never>;
29
+ submitPay(paymentSessionData: string): void;
29
30
  }
30
31
  export default ApplePayComponent;
@@ -28,12 +28,13 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
28
28
  * 1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE; and
29
29
  * 2. If applicable, the use of the Software is also subject to the terms and conditions of any non-disclosure agreement signed by you and the relevant Ant Group entity.
30
30
  */
31
- import { componentSignEnum, eventCodeEnum, productSceneEnum } from "../../types";
31
+ import { componentSignEnum, environmentEnum, eventCodeEnum, productSceneEnum } from "../../types";
32
32
  import ApplePayService from "../../common/applepay";
33
33
  import { getComponentSign, parseSessionData } from "../component";
34
34
  import { getApplePayPaymentSession, submitPayInfo } from "../../service";
35
35
  import CoreInstance from "../instance";
36
- import { ERRORMESSAGE, EVENT } from "../../constant";
36
+ import { EVENT } from "../../constant";
37
+
37
38
  /**
38
39
  * Apple pay Component
39
40
  */
@@ -43,13 +44,16 @@ var ApplePayComponent = /*#__PURE__*/function (_CoreInstance) {
43
44
  function ApplePayComponent(options) {
44
45
  var _this;
45
46
  _classCallCheck(this, ApplePayComponent);
46
- var _options = Object.assign({}, options, {
47
+ var _options = Object.assign({
48
+ environment: environmentEnum.prod
49
+ }, options, {
47
50
  product: productSceneEnum.CARD_APPLE_PAY
48
51
  });
49
52
  _this = _super.call(this, _options);
50
53
  _defineProperty(_assertThisInitialized(_this), "_applePayService", void 0);
51
54
  _defineProperty(_assertThisInitialized(_this), "_parseData", void 0);
52
55
  _defineProperty(_assertThisInitialized(_this), "_sessionData", void 0);
56
+ _defineProperty(_assertThisInitialized(_this), "_isFinish", false);
53
57
  _this._applePayService = new ApplePayService();
54
58
  return _this;
55
59
  }
@@ -143,6 +147,7 @@ var ApplePayComponent = /*#__PURE__*/function (_CoreInstance) {
143
147
  key: "submitPay",
144
148
  value: function submitPay(paymentSessionData) {
145
149
  var _this3 = this;
150
+ this._isFinish = false;
146
151
  // parse session Data
147
152
  var _parseSessionData = parseSessionData(paymentSessionData),
148
153
  _parseSessionData2 = _slicedToArray(_parseSessionData, 2),
@@ -150,14 +155,43 @@ var ApplePayComponent = /*#__PURE__*/function (_CoreInstance) {
150
155
  sessionData = _parseSessionData2[1];
151
156
  this._parseData = parseData;
152
157
  this._sessionData = sessionData;
158
+ // parse data is null
159
+ if (Object.keys(parseData).length === 0) {
160
+ this._eventCenter.emit(EVENT.eventCallback.name, {
161
+ code: eventCodeEnum.SDK_PAYMENT_FAIL,
162
+ result: {
163
+ errorMsg: 'Abnormal response data is null'
164
+ }
165
+ });
166
+ this.logger.logError({
167
+ name: 'APPLE_PAY',
168
+ title: 'sessionDataNull',
169
+ msg: 'Abnormal response data is null'
170
+ }, {
171
+ type: 'error',
172
+ biz: 'sdk'
173
+ }).send();
174
+ return;
175
+ }
153
176
  // validate parse data
154
177
  var componentSign = getComponentSign(parseData);
155
178
  if (componentSign === componentSignEnum.NONE) {
156
179
  // eslint-disable-next-line prefer-promise-reject-errors
157
- return Promise.reject({
158
- code: ERRORMESSAGE.CREATEPAYMENT_PARAMETER_ERROR.code,
159
- message: "Abnormal response data, interface failure, or unsupported payment method"
180
+ this._eventCenter.emit(EVENT.eventCallback.name, {
181
+ code: eventCodeEnum.SDK_PAYMENT_FAIL,
182
+ result: {
183
+ errorMsg: "Abnormal response data, interface failure, or unsupported payment method"
184
+ }
160
185
  });
186
+ this.logger.logError({
187
+ name: 'APPLE_PAY',
188
+ title: 'paymentMethodUnknown',
189
+ msg: 'Abnormal response data, interface failure, or unsupported payment method'
190
+ }, {
191
+ type: 'error',
192
+ biz: 'sdk'
193
+ }).send();
194
+ return;
161
195
  }
162
196
  /**
163
197
  * Get MerchantSession spi
@@ -174,18 +208,14 @@ var ApplePayComponent = /*#__PURE__*/function (_CoreInstance) {
174
208
  requestParams = {
175
209
  validateUrl: validationUrl,
176
210
  paymentSessionData: _this3._sessionData
177
- };
178
- console.log('getMerchantSession validationUrl', validationUrl);
179
- console.log('getMerchantSession _sessionData', _this3._sessionData);
180
-
181
- // get deviceId
211
+ }; // get deviceId
182
212
  _context2.t0 = getApplePayPaymentSession;
183
213
  _context2.t1 = _this3._sessionData;
184
214
  _context2.t2 = requestParams;
185
215
  _context2.t3 = _this3.options.env.environment;
186
- _context2.next = 10;
216
+ _context2.next = 8;
187
217
  return _this3.getDeviceIdAndLog();
188
- case 10:
218
+ case 8:
189
219
  _context2.t4 = _context2.sent;
190
220
  _context2.t5 = {
191
221
  deviceId: _context2.t4
@@ -196,9 +226,7 @@ var ApplePayComponent = /*#__PURE__*/function (_CoreInstance) {
196
226
  };
197
227
  _context2.t7 = _this3.logger;
198
228
  return _context2.abrupt("return", (0, _context2.t0)(_context2.t1, _context2.t2, _context2.t6, _context2.t7).then(function (res) {
199
- console.log('res', res);
200
229
  if (res !== null && res !== void 0 && res.success && res.merchantSessionObject) {
201
- console.log('res.merchantSessionObject', res.merchantSessionObject);
202
230
  return Promise.resolve(res.merchantSessionObject);
203
231
  }
204
232
  return Promise.reject({
@@ -208,7 +236,7 @@ var ApplePayComponent = /*#__PURE__*/function (_CoreInstance) {
208
236
  }).catch(function (error) {
209
237
  return Promise.reject(error);
210
238
  }));
211
- case 15:
239
+ case 13:
212
240
  case "end":
213
241
  return _context2.stop();
214
242
  }
@@ -252,7 +280,13 @@ var ApplePayComponent = /*#__PURE__*/function (_CoreInstance) {
252
280
  };
253
281
  _context3.t6 = _this3.logger;
254
282
  return _context3.abrupt("return", (0, _context3.t0)(_context3.t1, _context3.t5, _context3.t6).then(function (res) {
255
- console.log('completePaymentAuthorized then', res);
283
+ _this3.logger.logInfo({
284
+ name: 'APPLE_PAY',
285
+ title: 'submitPayStatus',
286
+ msg: res === null || res === void 0 ? void 0 : res.errorStatus
287
+ }, {
288
+ biz: 'sdk'
289
+ }).send();
256
290
  if (res !== null && res !== void 0 && res.success || (res === null || res === void 0 ? void 0 : res.errorStatus) === 'U') {
257
291
  return Promise.resolve(res);
258
292
  }
@@ -261,7 +295,6 @@ var ApplePayComponent = /*#__PURE__*/function (_CoreInstance) {
261
295
  errorMessage: res.errorMessage
262
296
  });
263
297
  }).catch(function (error) {
264
- console.log('completePaymentAuthorized catch', error);
265
298
  return Promise.reject(error);
266
299
  }));
267
300
  case 12:
@@ -276,7 +309,7 @@ var ApplePayComponent = /*#__PURE__*/function (_CoreInstance) {
276
309
  }();
277
310
  var completeApplePay = function completeApplePay(data) {
278
311
  var _data$actionForm;
279
- // TODO 处理redirectUrl
312
+ _this3._isFinish = true;
280
313
  _this3._eventCenter.emit(EVENT.eventCallback.name, {
281
314
  code: eventCodeEnum.SDK_PAYMENT_FINISH,
282
315
  result: {
@@ -285,14 +318,25 @@ var ApplePayComponent = /*#__PURE__*/function (_CoreInstance) {
285
318
  });
286
319
  };
287
320
  var logError = function logError(msg, error) {
288
- // TODO 回抛错误给商户
289
- console.error('logError', msg, error);
321
+ // log error
322
+ _this3.logger.logError({
323
+ name: 'APPLE_PAY',
324
+ title: msg,
325
+ label: msg,
326
+ msg: error
327
+ }, {
328
+ type: 'error',
329
+ biz: 'sdk'
330
+ }).send();
331
+ if (_this3._isFinish) {
332
+ return;
333
+ }
334
+ _this3._isFinish = true;
290
335
  if (msg === 'UserCancel') {
291
336
  _this3._eventCenter.emit(EVENT.eventCallback.name, {
292
337
  code: eventCodeEnum.SDK_PAYMENT_CANCEL
293
338
  });
294
339
  } else {
295
- // this._eventCenter.emit(EVENT.error.name, error);
296
340
  _this3._eventCenter.emit(EVENT.eventCallback.name, {
297
341
  code: eventCodeEnum.SDK_PAYMENT_FAIL,
298
342
  result: {
@@ -302,12 +346,14 @@ var ApplePayComponent = /*#__PURE__*/function (_CoreInstance) {
302
346
  }
303
347
  };
304
348
  var applePayTrace = function applePayTrace(msg) {
305
- // TODO 记录日志
306
- console.log('applePayTrace', msg);
349
+ // set log funnel
307
350
  _this3.logger.logInfo({
308
- title: 'APPLE_PAY'
351
+ name: 'APPLE_PAY',
352
+ title: msg,
353
+ label: msg
309
354
  }, {
310
- msg: msg
355
+ type: 'funnel',
356
+ biz: 'sdk'
311
357
  }).send();
312
358
  };
313
359
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alipay/ams-checkout",
3
- "version": "0.0.1701393225-dev.14",
3
+ "version": "0.0.1701393225-dev.16",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "esm/index.js",