@alipay/ams-checkout 1.29.0 → 1.30.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.
@@ -28,7 +28,7 @@ import { isLocalMock } from "../../util/mock";
28
28
  import { matchVersion } from "../../util/versionCompare";
29
29
  import { handlePaymentSessionConfig } from "../payment-element/utils";
30
30
  import { createIframe, createPreloadIframe, getAppDomain, getIframeUrl } from "./cashierApp";
31
- import { ApplePayService, getChannelBehavior, handleGooglePay } from "./channel";
31
+ import { ApplePaySdk, getChannelBehavior, handleGooglePay } from "./channel";
32
32
  import { addInlineLoading, createInlineBaseElement } from "./component.inline.style";
33
33
  import { addPopupLoading, createBaseElement, createMockup, createRetentionPopup, handleDeclareInfo as _handleDeclareInfo, hideRetentionPopup, removeRetentionPopup as _removeRetentionPopup, slideInAndOutKeyframes } from "./component.popup.style";
34
34
  import { createModal, destroyModal, insertStyleSheet, removePopupLoading } from "./popupWindow.style";
@@ -1342,15 +1342,33 @@ var ComponentApp = /*#__PURE__*/function () {
1342
1342
  });
1343
1343
  }
1344
1344
  if ((data === null || data === void 0 || (_data$context3 = data.context) === null || _data$context3 === void 0 ? void 0 : _data$context3.event) === EVENT.getApplePayToken.name) {
1345
- var _data$context4, _this$_renderParams16, _this$_renderParams17;
1346
- var applePayService = new ApplePayService({
1347
- paymentMethod: data === null || data === void 0 || (_data$context4 = data.context) === null || _data$context4 === void 0 || (_data$context4 = _data$context4.data) === null || _data$context4 === void 0 ? void 0 : _data$context4.paymentMethod,
1348
- sessionData: (_this$_renderParams16 = this._renderParams) === null || _this$_renderParams16 === void 0 ? void 0 : _this$_renderParams16.sessionData,
1349
- paymentSessionMetaData: (_this$_renderParams17 = this._renderParams) === null || _this$_renderParams17 === void 0 ? void 0 : _this$_renderParams17.paymentSessionMetaData,
1350
- logger: this.AMSSDK.logger,
1351
- dispatchToApp: this.dispatchToApp.bind(this)
1345
+ var _this$_renderParams16, _this$_renderParams17;
1346
+ var applePayService = new ApplePaySdk({
1347
+ paymentSessionData: (_this$_renderParams16 = this._renderParams) === null || _this$_renderParams16 === void 0 ? void 0 : _this$_renderParams16.sessionData,
1348
+ parseData: (_this$_renderParams17 = this._renderParams) === null || _this$_renderParams17 === void 0 ? void 0 : _this$_renderParams17.paymentSessionMetaData,
1349
+ logger: this.AMSSDK.logger
1350
+ });
1351
+ applePayService.startPay().then(function (res) {
1352
+ _this7.dispatchToApp({
1353
+ context: {
1354
+ event: 'getApplePayToken',
1355
+ data: {
1356
+ success: true,
1357
+ result: res
1358
+ }
1359
+ }
1360
+ });
1361
+ }).catch(function (err) {
1362
+ _this7.dispatchToApp({
1363
+ context: {
1364
+ event: 'getApplePayToken',
1365
+ data: {
1366
+ success: false,
1367
+ result: err
1368
+ }
1369
+ }
1370
+ });
1352
1371
  });
1353
- applePayService.submit();
1354
1372
  return;
1355
1373
  }
1356
1374
  // log event before sending the callback
@@ -1368,11 +1386,11 @@ var ComponentApp = /*#__PURE__*/function () {
1368
1386
  key: "logEventCallback",
1369
1387
  value: function logEventCallback(data, title) {
1370
1388
  if (data.context.event === EVENT.eventCallback.name) {
1371
- var _data$context6;
1389
+ var _data$context5;
1372
1390
  var callbackData = '';
1373
1391
  try {
1374
- var _data$context5;
1375
- callbackData = JSON.stringify((data === null || data === void 0 || (_data$context5 = data.context) === null || _data$context5 === void 0 ? void 0 : _data$context5.data) || '');
1392
+ var _data$context4;
1393
+ callbackData = JSON.stringify((data === null || data === void 0 || (_data$context4 = data.context) === null || _data$context4 === void 0 ? void 0 : _data$context4.data) || '');
1376
1394
  } catch (e) {
1377
1395
  console.error(e);
1378
1396
  }
@@ -1380,7 +1398,7 @@ var ComponentApp = /*#__PURE__*/function () {
1380
1398
  title: title
1381
1399
  }, {
1382
1400
  callbackData: callbackData,
1383
- callbackId: (data === null || data === void 0 || (_data$context6 = data.context) === null || _data$context6 === void 0 ? void 0 : _data$context6.eventCallbackId) || ''
1401
+ callbackId: (data === null || data === void 0 || (_data$context5 = data.context) === null || _data$context5 === void 0 ? void 0 : _data$context5.eventCallbackId) || ''
1384
1402
  }).send();
1385
1403
  }
1386
1404
  }
@@ -5,7 +5,7 @@ export var ExtendPlugin = [{
5
5
  productScene: ProductSceneEnum.CASHIER_PAYMENT,
6
6
  productSceneVersion: ProductSceneVersion.V1,
7
7
  paymentMethodCategoryType: PaymentMethodCategoryTypeEnum.CARD,
8
- paymentMethodTypes: ['CARD_APPLE_PAY']
8
+ paymentMethodTypes: ['APPLEPAY']
9
9
  },
10
10
  paymentChannelMatcher: {
11
11
  paymentMethod: 'ApplePay'
@@ -5,6 +5,7 @@
5
5
  * 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
6
6
  * 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.
7
7
  */
8
+ import { IApplePayContactField } from '../plugin/applepay/interface';
8
9
  export * from '../core/component/element/type';
9
10
  export type onChange = () => onCnageResult;
10
11
  interface onCnageResult {
@@ -264,6 +265,8 @@ export interface IPaymentSessionMetaData {
264
265
  extendInfo?: {
265
266
  merchantCapabilities?: string[];
266
267
  supportedNetworks?: string[];
268
+ requiredBillingContactFields: IApplePayContactField[];
269
+ requiredShippingContactFields: IApplePayContactField[];
267
270
  };
268
271
  merchantInfo?: {
269
272
  registeredCountry?: string;
@@ -878,7 +881,8 @@ export declare enum ElementPaymentEvent {
878
881
  LAUNCH = "onLaunch",
879
882
  CALLBACK = "callback",
880
883
  SEND_MUITI_APP_EVENT_TO_SDK = "sendMuitiAppEventToSdk",
881
- LOG = "log"
884
+ LOG = "log",
885
+ HANDLE_PAYMENT = "handlePayment"
882
886
  }
883
887
  export declare enum ConnectErrorCode {
884
888
  RISK_REJECT = "RISK_REJECT",
@@ -5,6 +5,7 @@
5
5
  * 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
6
6
  * 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.
7
7
  */
8
+
8
9
  /* eslint-disable @typescript-eslint/no-explicit-any */
9
10
  export * from "../core/component/element/type";
10
11
 
@@ -247,6 +248,7 @@ export var ElementPaymentEvent = /*#__PURE__*/function (ElementPaymentEvent) {
247
248
  ElementPaymentEvent["CALLBACK"] = "callback";
248
249
  ElementPaymentEvent["SEND_MUITI_APP_EVENT_TO_SDK"] = "sendMuitiAppEventToSdk";
249
250
  ElementPaymentEvent["LOG"] = "log";
251
+ ElementPaymentEvent["HANDLE_PAYMENT"] = "handlePayment";
250
252
  return ElementPaymentEvent;
251
253
  }({});
252
254
  export var ConnectErrorCode = /*#__PURE__*/function (ConnectErrorCode) {
@@ -46,4 +46,5 @@ declare function loadSDKScript({ src, attrOptions, timeOut, loadCallback }: {
46
46
  timeOut?: number;
47
47
  loadCallback?: any;
48
48
  }, logger: any): Promise<unknown>;
49
- export { getType, EventCenter, getViewPort, getOrigin, serialize, isJsonString, isDom, isFunction, device, safeJson, isPC, queryParse, getDesignFontSize, amsSetSize, addSetFontSizeEvent, getOrSetStorageId, checkTimeElapsed, parseBase64ToString, loadSDKScript, };
49
+ declare const isEmpty: (value: any) => boolean;
50
+ export { getType, EventCenter, getViewPort, getOrigin, serialize, isJsonString, isDom, isFunction, device, safeJson, isPC, queryParse, getDesignFontSize, amsSetSize, addSetFontSizeEvent, getOrSetStorageId, checkTimeElapsed, parseBase64ToString, loadSDKScript, isEmpty, };
package/esm/util/index.js CHANGED
@@ -328,4 +328,19 @@ function loadSDKScript(_ref, logger) {
328
328
  document.head.appendChild(script);
329
329
  });
330
330
  }
331
- export { getType, EventCenter, getViewPort, getOrigin, serialize, isJsonString, isDom, isFunction, device, safeJson, isPC, queryParse, getDesignFontSize, amsSetSize, addSetFontSizeEvent, getOrSetStorageId, checkTimeElapsed, parseBase64ToString, loadSDKScript };
331
+ var isEmpty = function isEmpty(value) {
332
+ // 判断空对象
333
+ if (value && _typeof(value) === 'object' && Object.keys(value).length === 0) {
334
+ return true;
335
+ }
336
+ // 判断空数组
337
+ if (Array.isArray(value) && value.length === 0) {
338
+ return true;
339
+ }
340
+ // 判断空值
341
+ if (value === null || value === undefined || value === '') {
342
+ return true;
343
+ }
344
+ return false;
345
+ };
346
+ export { getType, EventCenter, getViewPort, getOrigin, serialize, isJsonString, isDom, isFunction, device, safeJson, isPC, queryParse, getDesignFontSize, amsSetSize, addSetFontSizeEvent, getOrSetStorageId, checkTimeElapsed, parseBase64ToString, loadSDKScript, isEmpty };
@@ -3,7 +3,7 @@
3
3
  * @param v1
4
4
  * @param v2
5
5
  */
6
- export declare function compareVersion(v1: string, v2: string): 0 | 1 | -1;
6
+ export declare function compareVersion(v1: string, v2: string): 1 | 0 | -1;
7
7
  /**
8
8
  * 判断version版本是否在range参数版本的范围内
9
9
  * @param version
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alipay/ams-checkout",
3
- "version": "1.29.0",
3
+ "version": "1.30.0",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "esm/index.js",