@alipay/ams-checkout 1.29.0 → 1.31.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.
Files changed (43) hide show
  1. package/dist/umd/ams-checkout.min.js +1 -1
  2. package/esm/config/index.d.ts +7 -7
  3. package/esm/config/index.js +7 -7
  4. package/esm/core/component/element/components/address.d.ts +1 -1
  5. package/esm/core/component/element/components/address.js +2 -2
  6. package/esm/core/component/element/components/payment.d.ts +1 -1
  7. package/esm/core/component/element/components/payment.js +2 -2
  8. package/esm/core/component/element/index.d.ts +9 -6
  9. package/esm/core/component/element/index.js +361 -230
  10. package/esm/core/component/element/type.d.ts +171 -12
  11. package/esm/core/component/element/type.js +48 -3
  12. package/esm/core/component/index.js +5 -0
  13. package/esm/core/instance/index.js +12 -1
  14. package/esm/foundation/index.d.ts +1 -1
  15. package/esm/foundation/product-processor/easysafepay/index.d.ts +0 -2
  16. package/esm/foundation/product-processor/easysafepay/index.js +29 -73
  17. package/esm/foundation/service/container/index.d.ts +0 -2
  18. package/esm/foundation/service/container/index.js +20 -47
  19. package/esm/foundation/utils/payment_product_utils.d.ts +1 -1
  20. package/esm/foundation/utils/payment_product_utils.js +2 -2
  21. package/esm/foundation/utils/preload_helper.d.ts +21 -0
  22. package/esm/foundation/utils/preload_helper.js +143 -0
  23. package/esm/index.d.ts +7 -2
  24. package/esm/index.js +94 -7
  25. package/esm/plugin/component/channel.d.ts +20 -26
  26. package/esm/plugin/component/channel.js +392 -428
  27. package/esm/plugin/component/index.d.ts +1 -0
  28. package/esm/plugin/component/index.js +51 -20
  29. package/esm/plugin/const.js +1 -1
  30. package/esm/service/index.d.ts +0 -1
  31. package/esm/service/index.js +0 -2
  32. package/esm/types/index.d.ts +11 -116
  33. package/esm/types/index.js +3 -33
  34. package/esm/util/index.d.ts +2 -1
  35. package/esm/util/index.js +16 -1
  36. package/esm/util/security.d.ts +1 -0
  37. package/esm/util/security.js +3 -1
  38. package/esm/util/spm-map.d.ts +3 -0
  39. package/esm/util/spm-map.js +3 -0
  40. package/esm/util/versionCompare.d.ts +1 -1
  41. package/package.json +1 -1
  42. package/esm/service/element.d.ts +0 -4
  43. package/esm/service/element.js +0 -51
@@ -79,6 +79,7 @@ export default class ComponentApp {
79
79
  */
80
80
  private addEventListener;
81
81
  private removeEventListener;
82
+ private elementEventCallback;
82
83
  /**
83
84
  * @description Processing messages from iframe
84
85
  */
@@ -23,12 +23,13 @@ import { COMPONENTPLUGINID, COMPONENT_CLOSE_BLOCK_ID, COMPONENT_CLOSE_MASK_BLOCK
23
23
  import { queryPaymentInfo, submitPayInfo } from "../../service";
24
24
  import { ComponentSignEnum, DisplayTypeEnum, eventCodeEnum, MessageName, PlatformEnum, ProductSceneEnum, RedirectType, TargetEnum } from "../../types";
25
25
  import { getType, isJsonString, isPC } from "../../util";
26
+ import { ElementPaymentMethod } from "../../core/component/element/type";
26
27
  import { getBackScheme } from "../../util/getBackScheme";
27
28
  import { isLocalMock } from "../../util/mock";
28
29
  import { matchVersion } from "../../util/versionCompare";
29
30
  import { handlePaymentSessionConfig } from "../payment-element/utils";
30
31
  import { createIframe, createPreloadIframe, getAppDomain, getIframeUrl } from "./cashierApp";
31
- import { ApplePayService, getChannelBehavior, handleGooglePay } from "./channel";
32
+ import { ApplePaySdk, getChannelBehavior, handleGooglePay } from "./channel";
32
33
  import { addInlineLoading, createInlineBaseElement } from "./component.inline.style";
33
34
  import { addPopupLoading, createBaseElement, createMockup, createRetentionPopup, handleDeclareInfo as _handleDeclareInfo, hideRetentionPopup, removeRetentionPopup as _removeRetentionPopup, slideInAndOutKeyframes } from "./component.popup.style";
34
35
  import { createModal, destroyModal, insertStyleSheet, removePopupLoading } from "./popupWindow.style";
@@ -1168,15 +1169,26 @@ var ComponentApp = /*#__PURE__*/function () {
1168
1169
  window.removeEventListener('resize', window["".concat(LISTENER_PREFIX, "_").concat(this.AMSSDK._instanceId, "_resize")]);
1169
1170
  }
1170
1171
 
1172
+ // element payment event callback回调码
1173
+ }, {
1174
+ key: "elementEventCallback",
1175
+ value: function elementEventCallback(data) {
1176
+ var _data$context, _data$context2;
1177
+ if (data.context.event === EVENT.sendMuitiAppEventToSdk.name && ((_data$context = data.context) === null || _data$context === void 0 || (_data$context = _data$context.data) === null || _data$context === void 0 ? void 0 : _data$context.source) === ElementPaymentMethod.PAYMENT_ELEMENT && ((_data$context2 = data.context) === null || _data$context2 === void 0 || (_data$context2 = _data$context2.data) === null || _data$context2 === void 0 ? void 0 : _data$context2.target) === ElementPaymentMethod.CONTAINER_ELEMENT) {
1178
+ var _data$context3;
1179
+ this.dispatchToSDK(EVENT.eventCallback.name, (_data$context3 = data.context) === null || _data$context3 === void 0 || (_data$context3 = _data$context3.data) === null || _data$context3 === void 0 ? void 0 : _data$context3.data);
1180
+ }
1181
+ }
1182
+
1171
1183
  /**
1172
1184
  * @description Processing messages from iframe
1173
1185
  */
1174
1186
  }, {
1175
1187
  key: "_handleAppMessage",
1176
1188
  value: function _handleAppMessage(data) {
1177
- var _data$context2,
1189
+ var _data$context5,
1178
1190
  _this7 = this,
1179
- _data$context3;
1191
+ _data$context6;
1180
1192
  var eventKeyMap = Object.keys(EVENT).map(function (key) {
1181
1193
  return EVENT[key].name;
1182
1194
  });
@@ -1205,11 +1217,12 @@ var ComponentApp = /*#__PURE__*/function () {
1205
1217
  return;
1206
1218
  }
1207
1219
  if (data.context.event === EVENT.popupWindow.name) {
1208
- var _data$context;
1209
- this.createDialog((_data$context = data.context) === null || _data$context === void 0 ? void 0 : _data$context.data);
1220
+ var _data$context4;
1221
+ this.createDialog((_data$context4 = data.context) === null || _data$context4 === void 0 ? void 0 : _data$context4.data);
1210
1222
  return;
1211
1223
  }
1212
1224
  if (data.context.event === EVENT.sendMuitiAppEventToSdk.name) {
1225
+ this.elementEventCallback(data);
1213
1226
  this.dispatchToApp({
1214
1227
  context: {
1215
1228
  event: 'receiveMuitiAppFromSdk',
@@ -1305,7 +1318,7 @@ var ComponentApp = /*#__PURE__*/function () {
1305
1318
  title: 'sdk_event_event_callback'
1306
1319
  }).send();
1307
1320
  }
1308
- if ((data === null || data === void 0 || (_data$context2 = data.context) === null || _data$context2 === void 0 ? void 0 : _data$context2.event) === EVENT.getGooglePayToken.name) {
1321
+ if ((data === null || data === void 0 || (_data$context5 = data.context) === null || _data$context5 === void 0 ? void 0 : _data$context5.event) === EVENT.getGooglePayToken.name) {
1309
1322
  handleGooglePay(data).then(function (res) {
1310
1323
  _this7.dispatchToApp({
1311
1324
  context: {
@@ -1337,20 +1350,38 @@ var ComponentApp = /*#__PURE__*/function () {
1337
1350
  this.dispatchToApp({
1338
1351
  context: {
1339
1352
  event: EVENT.closePaymentPolling.name,
1340
- data: {}
1353
+ data: data.context.data
1341
1354
  }
1342
1355
  });
1343
1356
  }
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)
1357
+ if ((data === null || data === void 0 || (_data$context6 = data.context) === null || _data$context6 === void 0 ? void 0 : _data$context6.event) === EVENT.getApplePayToken.name) {
1358
+ var _this$_renderParams16, _this$_renderParams17;
1359
+ var applePayService = new ApplePaySdk({
1360
+ paymentSessionData: (_this$_renderParams16 = this._renderParams) === null || _this$_renderParams16 === void 0 ? void 0 : _this$_renderParams16.sessionData,
1361
+ parseData: (_this$_renderParams17 = this._renderParams) === null || _this$_renderParams17 === void 0 ? void 0 : _this$_renderParams17.paymentSessionMetaData,
1362
+ logger: this.AMSSDK.logger
1363
+ });
1364
+ applePayService.startPay().then(function (res) {
1365
+ _this7.dispatchToApp({
1366
+ context: {
1367
+ event: 'getApplePayToken',
1368
+ data: {
1369
+ success: true,
1370
+ result: res
1371
+ }
1372
+ }
1373
+ });
1374
+ }).catch(function (err) {
1375
+ _this7.dispatchToApp({
1376
+ context: {
1377
+ event: 'getApplePayToken',
1378
+ data: {
1379
+ success: false,
1380
+ result: err
1381
+ }
1382
+ }
1383
+ });
1352
1384
  });
1353
- applePayService.submit();
1354
1385
  return;
1355
1386
  }
1356
1387
  // log event before sending the callback
@@ -1368,11 +1399,11 @@ var ComponentApp = /*#__PURE__*/function () {
1368
1399
  key: "logEventCallback",
1369
1400
  value: function logEventCallback(data, title) {
1370
1401
  if (data.context.event === EVENT.eventCallback.name) {
1371
- var _data$context6;
1402
+ var _data$context8;
1372
1403
  var callbackData = '';
1373
1404
  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) || '');
1405
+ var _data$context7;
1406
+ callbackData = JSON.stringify((data === null || data === void 0 || (_data$context7 = data.context) === null || _data$context7 === void 0 ? void 0 : _data$context7.data) || '');
1376
1407
  } catch (e) {
1377
1408
  console.error(e);
1378
1409
  }
@@ -1380,7 +1411,7 @@ var ComponentApp = /*#__PURE__*/function () {
1380
1411
  title: title
1381
1412
  }, {
1382
1413
  callbackData: callbackData,
1383
- callbackId: (data === null || data === void 0 || (_data$context6 = data.context) === null || _data$context6 === void 0 ? void 0 : _data$context6.eventCallbackId) || ''
1414
+ callbackId: (data === null || data === void 0 || (_data$context8 = data.context) === null || _data$context8 === void 0 ? void 0 : _data$context8.eventCallbackId) || ''
1384
1415
  }).send();
1385
1416
  }
1386
1417
  }
@@ -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'
@@ -1,6 +1,5 @@
1
1
  import { ApplePayPaymentSessionRequest, ApplePayPaymentSessionResult, CashierSdkActionQueryRequest, CashierSdkActionQueryResult, CashierSubmitPayRequest, CashierSubmitPayResult, RequestConfig } from '../types';
2
2
  import type { Logger } from '../util/logger';
3
- export * as elementService from './element';
4
3
  export declare function queryPaymentInfo(params: CashierSdkActionQueryRequest, options: RequestConfig, logger: Logger): Promise<CashierSdkActionQueryResult>;
5
4
  export declare function antomConfig(options: RequestConfig, logger: Logger): Promise<any>;
6
5
  export declare function submitPayInfo(params: CashierSubmitPayRequest, options: RequestConfig, logger: Logger): Promise<CashierSubmitPayResult>;
@@ -16,8 +16,6 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
16
16
  */
17
17
  import { marmotConfigMap } from "../config";
18
18
  import { request } from "../request";
19
- import * as _elementService from "./element";
20
- export { _elementService as elementService };
21
19
  export function queryPaymentInfo(_x, _x2, _x3) {
22
20
  return _queryPaymentInfo.apply(this, arguments);
23
21
  }
@@ -5,8 +5,9 @@
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
- export * from '../core/component/element/type';
8
+ import { IApplePayContactField } from '../plugin/applepay/interface';
9
9
  export type onChange = () => onCnageResult;
10
+ export { type IElementOptions, ElementType, ThemeType, PaymentElementLayout } from '../core/component/element/type';
10
11
  interface onCnageResult {
11
12
  complete: boolean;
12
13
  addressValue: AddressItem[];
@@ -37,6 +38,11 @@ export interface IoptionsParams {
37
38
  product?: string;
38
39
  networkMode?: string;
39
40
  mode?: string;
41
+ securityRegion?: 'US' | 'SG' | 'DE';
42
+ }
43
+ export interface IPreloadOptions {
44
+ environment?: string;
45
+ securityRegion?: 'US' | 'SG' | 'DE';
40
46
  }
41
47
  export interface IApplePayOptionsParams extends Pick<IoptionsParams, 'locale' | 'environment' | 'onEventCallback' | 'analytics'> {
42
48
  }
@@ -223,6 +229,7 @@ export interface IsecurityConfig {
223
229
  export interface InitSecurityConfig {
224
230
  product: ProductSceneEnum;
225
231
  region?: string;
232
+ securityRegion?: 'US' | 'SG' | 'DE';
226
233
  }
227
234
  export interface frontModulesToBeLoadedInterface {
228
235
  acquirerName: string;
@@ -264,6 +271,8 @@ export interface IPaymentSessionMetaData {
264
271
  extendInfo?: {
265
272
  merchantCapabilities?: string[];
266
273
  supportedNetworks?: string[];
274
+ requiredBillingContactFields: IApplePayContactField[];
275
+ requiredShippingContactFields: IApplePayContactField[];
267
276
  };
268
277
  merchantInfo?: {
269
278
  registeredCountry?: string;
@@ -670,43 +679,7 @@ export type IAppendParams = {
670
679
  componentSign: ComponentSignEnum;
671
680
  iframeNodesParams: IappendIframeNodesParams;
672
681
  };
673
- export declare enum AccountStatusEnum {
674
- EFFECTIVE = "EFFECTIVE",
675
- UNREGISTERED = "UNREGISTERED"
676
- }
677
- export type IAccountInfo = {
678
- email?: string;
679
- verifyId?: string;
680
- accountStatus?: AccountStatusEnum;
681
- oneAccountId?: string;
682
- needOtp?: boolean;
683
- errorMsg?: string;
684
- inputStatus?: 'success' | 'loading' | 'error' | 'focused' | '';
685
- resendLeftTimes?: number;
686
- };
687
- export interface AccountQueryRequest {
688
- paymentSessionData: string;
689
- paymentSessionConfig: any;
690
- accountInfo: IAccountInfo;
691
- }
692
- export interface ShippingsItem {
693
- shippingName: {
694
- firstName: string;
695
- lastName: string;
696
- };
697
- prefer: '1' | '0';
698
- shippingId: string;
699
- shippingPhoneNo: string;
700
- shippingAddress: {
701
- region: string;
702
- state: string;
703
- city: string;
704
- address1: string;
705
- address2: string;
706
- zipCode: string;
707
- };
708
- }
709
- export interface ISubPaymentElementView {
682
+ interface ISubPaymentElementView {
710
683
  defaultText: string;
711
684
  defaultValue: string;
712
685
  elementMandatory: boolean;
@@ -802,84 +775,6 @@ export interface IPaymentMethod {
802
775
  paymentAmountView?: IAmountView;
803
776
  paymentQuoteId?: string;
804
777
  }
805
- interface Estimate {
806
- unit: string;
807
- value: number;
808
- }
809
- interface DeliveryEstimate {
810
- maximum: Estimate;
811
- minimum: Estimate;
812
- }
813
- interface FixedAmount {
814
- amount: number;
815
- currency: string;
816
- }
817
- interface ShippingRateData {
818
- displayName: string;
819
- deliveryEstimate: DeliveryEstimate;
820
- fixedAmount: FixedAmount;
821
- }
822
- export interface ShippingAddress {
823
- address1: string;
824
- address2: string;
825
- city: string;
826
- region: string;
827
- state: string;
828
- zipCode: string;
829
- }
830
- export interface IUserName {
831
- firstName: string;
832
- middleName?: string;
833
- lastName: string;
834
- fullName?: string;
835
- }
836
- export type Shippings = ShippingsItem[];
837
- export type IPaymentMethods = IPaymentMethod[];
838
- export interface CKPShipping {
839
- shippingRateId?: string;
840
- shippingRateData?: ShippingRateData;
841
- shippingAddress: ShippingAddress;
842
- shippingFee?: IAmount;
843
- shippingFeeView?: IAmountView;
844
- shippingDescription?: string;
845
- deliveryEstimate?: DeliveryEstimate;
846
- shippingFeeId?: string;
847
- shippingName?: IUserName;
848
- shippingPhoneNo?: string;
849
- shipToEmail?: string;
850
- notes?: string;
851
- }
852
- export interface AccountQueryResult {
853
- accountInfo: IAccountInfo;
854
- actionForm?: ActionForm;
855
- paymentMethods: IPaymentMethods;
856
- shippings: Shippings;
857
- success: boolean;
858
- errorCode?: string;
859
- errorMessage?: string;
860
- errorStatus?: string;
861
- shippingInfo?: CKPShipping;
862
- }
863
- export declare enum ElementPaymentMethod {
864
- CONTAINER_ELEMENT = "CONTAINER_ELEMENT",
865
- AUTH_ELEMENT = "AUTH_ELEMENT",
866
- ADDRESS_ELEMENT = "ADDRESS_ELEMENT",
867
- PAYMENT_ELEMENT = "PAYMENT_ELEMENT"
868
- }
869
- export declare enum ElementPaymentEvent {
870
- RENDER_COMPONENT = "renderComponent",
871
- CAPTURE_ASSET = "onCaptureAsset",
872
- SIGN_OUT = "onSignout",
873
- BLUR = "onBlur",
874
- VALIDATE = "submitPay",
875
- SUBMIT_RISK = "onSubmitRisk",
876
- AFTER_SUBMIT = "onAfterSubmit",
877
- SIZE_CHANGE = "onSizeChange",
878
- LAUNCH = "onLaunch",
879
- CALLBACK = "callback",
880
- SEND_MUITI_APP_EVENT_TO_SDK = "sendMuitiAppEventToSdk",
881
- LOG = "log"
882
- }
883
778
  export declare enum ConnectErrorCode {
884
779
  RISK_REJECT = "RISK_REJECT",
885
780
  USER_AUTH_VERIFICATION_FAILED = "USER_AUTH_VERIFICATION_FAILED",
@@ -5,8 +5,10 @@
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
- export * from "../core/component/element/type";
10
+
11
+ export { ElementType, ThemeType, PaymentElementLayout } from "../core/component/element/type";
10
12
 
11
13
  /**
12
14
  * SDK options
@@ -210,14 +212,6 @@ export var ProductSceneVersion = /*#__PURE__*/function (ProductSceneVersion) {
210
212
  ProductSceneVersion["V2"] = "2.0";
211
213
  return ProductSceneVersion;
212
214
  }({});
213
- export var AccountStatusEnum = /*#__PURE__*/function (AccountStatusEnum) {
214
- AccountStatusEnum["EFFECTIVE"] = "EFFECTIVE";
215
- AccountStatusEnum["UNREGISTERED"] = "UNREGISTERED";
216
- return AccountStatusEnum;
217
- }({});
218
-
219
- // element 接口start
220
-
221
215
  export var InterActionTypeEnum = /*#__PURE__*/function (InterActionTypeEnum) {
222
216
  InterActionTypeEnum["COLLECT_REDIRECT"] = "COLLECT_REDIRECT";
223
217
  InterActionTypeEnum["SHOW_CODE"] = "SHOW_CODE";
@@ -225,30 +219,6 @@ export var InterActionTypeEnum = /*#__PURE__*/function (InterActionTypeEnum) {
225
219
  InterActionTypeEnum["REDIRECT"] = "REDIRECT";
226
220
  return InterActionTypeEnum;
227
221
  }({});
228
- // element 接口end
229
-
230
- export var ElementPaymentMethod = /*#__PURE__*/function (ElementPaymentMethod) {
231
- ElementPaymentMethod["CONTAINER_ELEMENT"] = "CONTAINER_ELEMENT";
232
- ElementPaymentMethod["AUTH_ELEMENT"] = "AUTH_ELEMENT";
233
- ElementPaymentMethod["ADDRESS_ELEMENT"] = "ADDRESS_ELEMENT";
234
- ElementPaymentMethod["PAYMENT_ELEMENT"] = "PAYMENT_ELEMENT";
235
- return ElementPaymentMethod;
236
- }({});
237
- export var ElementPaymentEvent = /*#__PURE__*/function (ElementPaymentEvent) {
238
- ElementPaymentEvent["RENDER_COMPONENT"] = "renderComponent";
239
- ElementPaymentEvent["CAPTURE_ASSET"] = "onCaptureAsset";
240
- ElementPaymentEvent["SIGN_OUT"] = "onSignout";
241
- ElementPaymentEvent["BLUR"] = "onBlur";
242
- ElementPaymentEvent["VALIDATE"] = "submitPay";
243
- ElementPaymentEvent["SUBMIT_RISK"] = "onSubmitRisk";
244
- ElementPaymentEvent["AFTER_SUBMIT"] = "onAfterSubmit";
245
- ElementPaymentEvent["SIZE_CHANGE"] = "onSizeChange";
246
- ElementPaymentEvent["LAUNCH"] = "onLaunch";
247
- ElementPaymentEvent["CALLBACK"] = "callback";
248
- ElementPaymentEvent["SEND_MUITI_APP_EVENT_TO_SDK"] = "sendMuitiAppEventToSdk";
249
- ElementPaymentEvent["LOG"] = "log";
250
- return ElementPaymentEvent;
251
- }({});
252
222
  export var ConnectErrorCode = /*#__PURE__*/function (ConnectErrorCode) {
253
223
  ConnectErrorCode["RISK_REJECT"] = "RISK_REJECT";
254
224
  ConnectErrorCode["USER_AUTH_VERIFICATION_FAILED"] = "USER_AUTH_VERIFICATION_FAILED";
@@ -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 };
@@ -13,6 +13,7 @@ export declare const securityHost: {
13
13
  export declare const sceneMap: {
14
14
  CASHIER_PAYMENT: string;
15
15
  AUTO_DEBIT: string;
16
+ AUTO_DEBIT_PAY: string;
16
17
  VAULTING: string;
17
18
  CARD_APPLE_PAY: string;
18
19
  EASYPAY: string;
@@ -24,11 +24,12 @@ export var securityHost = {
24
24
  US: 'https://open-na-global.alipay.com/api/open/risk_client',
25
25
  DE: 'https://open-de-global.alipay.com/api/open/risk_client'
26
26
  };
27
- export var sceneMap = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ProductSceneEnum.CASHIER_PAYMENT, 'Acquirer'), ProductSceneEnum.AUTO_DEBIT, 'Acquirer'), ProductSceneEnum.VAULTING, 'Acquirer'), ProductSceneEnum.CARD_APPLE_PAY, 'Acquirer'), "EASYPAY", 'EasyPay'), ProductSceneEnum.EASY_PAY, 'EasyPay'), ProductSceneEnum.FLASH_BUY, 'OneAccount'), ProductSceneEnum.ELEMENT_PAYMENT, 'Acquirer');
27
+ export var sceneMap = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ProductSceneEnum.CASHIER_PAYMENT, 'Acquirer'), ProductSceneEnum.AUTO_DEBIT, 'Acquirer'), ProductSceneEnum.AUTO_DEBIT_PAY, 'Acquirer'), ProductSceneEnum.VAULTING, 'Acquirer'), ProductSceneEnum.CARD_APPLE_PAY, 'Acquirer'), "EASYPAY", 'EasyPay'), ProductSceneEnum.EASY_PAY, 'EasyPay'), ProductSceneEnum.FLASH_BUY, 'OneAccount'), ProductSceneEnum.ELEMENT_PAYMENT, 'Acquirer');
28
28
  export var getSecurityHost = function getSecurityHost(region) {
29
29
  return securityHost[region] || securityHost[SecurityRegionEnum.SG];
30
30
  };
31
31
  export var getSecurityScene = function getSecurityScene(product) {
32
+ console.log('getSecurityScene', product);
32
33
  return sceneMap[product] || '';
33
34
  };
34
35
  export var Security = /*#__PURE__*/function () {
@@ -42,6 +43,7 @@ export var Security = /*#__PURE__*/function () {
42
43
  _createClass(Security, [{
43
44
  key: "initSecurity",
44
45
  value: function initSecurity(successCallback, failCallback) {
46
+ console.log(this.scene, 'preloadSecuritySDK');
45
47
  if (!this.scene) {
46
48
  throw new Error('securityConfig parameter error');
47
49
  }
@@ -164,6 +164,9 @@ export declare const SPM_MAP: {
164
164
  load_item_sdk_timeout: string;
165
165
  MerchantValidationError: string;
166
166
  PaymentAuthorizedError: string;
167
+ sdk_element_create: string;
168
+ sdk_element_mount_fail: string;
169
+ sdk_element_mount_start: string;
167
170
  'ApplePaySession is only support in Safari': string;
168
171
  'Abnormal params paymentSessionFactor': string;
169
172
  'Abnormal params recurringInfo': string;
@@ -164,6 +164,9 @@ export var SPM_MAP = {
164
164
  load_item_sdk_timeout: 'a3753.b101271.c388188.d512345',
165
165
  MerchantValidationError: 'a3753.b101271.c388189.d518377',
166
166
  PaymentAuthorizedError: 'a3753.b101271.c388189.d518377',
167
+ sdk_element_create: 'a3753.b101271.c386688',
168
+ sdk_element_mount_fail: 'a3753.b101271.c386691',
169
+ sdk_element_mount_start: 'a3753.b101271.c386690',
167
170
  'ApplePaySession is only support in Safari': 'a3753.b101271.c388189.d518377',
168
171
  'Abnormal params paymentSessionFactor': 'a3753.b101271.c388189.d518377',
169
172
  'Abnormal params recurringInfo': 'a3753.b101271.c388189.d518377',
@@ -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.31.0",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "esm/index.js",
@@ -1,4 +0,0 @@
1
- import { AccountQueryRequest, RequestConfig, AccountQueryResult, CashierSdkActionQueryRequest, CashierSdkActionQueryResult } from '../types';
2
- import type { Logger } from '../util/logger';
3
- export declare function getElementOneAccount(payload: AccountQueryRequest, options: RequestConfig, logger: Logger): Promise<AccountQueryResult>;
4
- export declare function getElementSdkAction(payload: CashierSdkActionQueryRequest, options: RequestConfig, logger: Logger): Promise<CashierSdkActionQueryResult>;
@@ -1,51 +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 _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 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; }
4
- 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; }
5
- 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; }
6
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
- 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); }
8
- 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); } }
9
- 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); }); }; }
10
- import { request } from "../request";
11
- export function getElementOneAccount(_x, _x2, _x3) {
12
- return _getElementOneAccount.apply(this, arguments);
13
- }
14
- function _getElementOneAccount() {
15
- _getElementOneAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(payload, options, logger) {
16
- return _regeneratorRuntime().wrap(function _callee$(_context) {
17
- while (1) switch (_context.prev = _context.next) {
18
- case 0:
19
- return _context.abrupt("return", request(payload, _objectSpread(_objectSpread({}, options), {}, {
20
- 'Operation-Type': 'com.ipay.iexpfront.one.account.query'
21
- }), logger));
22
- case 1:
23
- case "end":
24
- return _context.stop();
25
- }
26
- }, _callee);
27
- }));
28
- return _getElementOneAccount.apply(this, arguments);
29
- }
30
- export function getElementSdkAction(_x4, _x5, _x6) {
31
- return _getElementSdkAction.apply(this, arguments);
32
- }
33
- function _getElementSdkAction() {
34
- _getElementSdkAction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(payload, options, logger) {
35
- var _options;
36
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
37
- while (1) switch (_context2.prev = _context2.next) {
38
- case 0:
39
- // const deviceId = await getDeviceId();
40
- _options = _objectSpread({}, options);
41
- return _context2.abrupt("return", request(payload, _objectSpread(_objectSpread({}, _options), {}, {
42
- 'Operation-Type': 'com.ipay.iexpcashier.sdkAction.query'
43
- }), logger));
44
- case 2:
45
- case "end":
46
- return _context2.stop();
47
- }
48
- }, _callee2);
49
- }));
50
- return _getElementSdkAction.apply(this, arguments);
51
- }