Socket
Socket
Sign inDemoInstall

@alipay/ams-checkout

Package Overview
Dependencies
Maintainers
0
Versions
345
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@alipay/ams-checkout - npm Package Compare versions

Comparing version 0.0.1723203704-dev.3 to 0.0.1723203704-dev.4

4

esm/constant/index.d.ts

@@ -174,6 +174,2 @@ /**

};
onGetValue: {
name: string;
uniqueKey: string;
};
};

@@ -180,0 +176,0 @@ export declare const COMPONENT_CONTAINER_ID = "ams-component-container";

@@ -173,6 +173,2 @@ /**

uniqueKey: 'userChange'
},
onGetValue: {
name: 'onAddressResult',
uniqueKey: 'userGetValue'
}

@@ -179,0 +175,0 @@ };

@@ -1,34 +0,6 @@

import ComponentApp from '../../plugin/address';
import { componentSignEnum, IoptionsParams, IpaymentSessionMetaData, Iselector } from '../../types';
import { addressInitOption } from '../../types/address';
import CoreInstance from '../instance/address';
export declare const getComponentSign: (params: IpaymentSessionMetaData) => componentSignEnum;
export declare class AddressComponent extends CoreInstance {
_componentApp: ComponentApp;
channelType: componentSignEnum[];
productSceneVersion: string;
timer: any;
import { IoptionsParams } from '../../types';
import { AMSComponent } from './index';
export declare class AddressComponent extends AMSComponent {
constructor(options: IoptionsParams);
private parameterInitAndCheck;
private pluginAppendIframe;
private savePreviousChannel;
/**
* 初始化 Bus总线的能力
*/
private registerBusAbility;
preloadComponent(channelType: any, productSceneVersion: any): void;
private clearPreloadIframe;
/**
* @description Create and render components in the specified element area
* @param params - The data source created by the component, necessary sessionData, optional appearance configurations, and refer to the documentation for other parameters and detailed information.
* @param selector - Necessary element selector ID
*/
mountComponent(params: addressInitOption, selector: Iselector): Promise<void>;
private mountComponentProcess;
/**
* @description Execute payment submission process
* @description - When using your own payment button, you can execute the submit payment process by actively calling this function.
* @param data - Transfer information in the submission interface according to your requirements (optional)
*/
getValue(data?: any): Promise<unknown>;
}
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); }
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; }
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; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
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); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }

@@ -14,5 +14,2 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }

function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
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; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
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); }
/**

@@ -26,251 +23,28 @@ * Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.

import { v4 as uuid } from 'uuid';
import { COMPONENTPLUGINID, EVENT } from "../../constant";
import { ApplePayBusSubscriber } from "../../plugin/applepay";
import ComponentApp from "../../plugin/address";
import { PaypalBusSubscriber } from "../../plugin/paypal";
import { componentSignEnum, environmentEnum, modeEnum, networkModeEnum, renderDisplayTypeEnum } from "../../types";
import { createIframeNode, createPreloadIframeNode } from "../../util/createIframeNode";
import { BusManager, BusMessage } from "../bus";
import { SDKCallbackBusSubscriber } from "../bus/ability/callback";
import { SecurityBusSubscriber } from "../bus/ability/security";
import { TrackerBusSubscriber } from "../bus/ability/tracker";
import CoreInstance from "../instance/address";
export var getComponentSign = function getComponentSign(params) {
var _params$paymentSessio = params.paymentSessionConfig,
_params$paymentSessio2 = _params$paymentSessio === void 0 ? {} : _params$paymentSessio,
_params$paymentSessio3 = _params$paymentSessio2.productScene,
productScene = _params$paymentSessio3 === void 0 ? '' : _params$paymentSessio3,
_params$paymentSessio4 = _params$paymentSessio2.paymentMethodCategoryType,
paymentMethodCategoryType = _params$paymentSessio4 === void 0 ? '' : _params$paymentSessio4;
if (productScene && paymentMethodCategoryType) return "".concat(productScene, "_").concat(paymentMethodCategoryType);
if (productScene) return "".concat(productScene);
return componentSignEnum.NONE;
};
var handleParams = function handleParams(params) {
var _params = Object.assign(params);
// 地址组件不通过传参 固定
var componentSign = componentSignEnum.ELEMENT_ADDRESS;
return Promise.resolve({
iframeNodesParams: _params,
componentSign: componentSign
});
};
export var AddressComponent = /*#__PURE__*/function (_CoreInstance) {
_inherits(AddressComponent, _CoreInstance);
import { AMSComponent } from "./index";
export var AddressComponent = /*#__PURE__*/function (_AMSComponent) {
_inherits(AddressComponent, _AMSComponent);
var _super = _createSuper(AddressComponent);
function AddressComponent(options) {
var _this;
_classCallCheck(this, AddressComponent);
_this = _super.call(this, options);
// Instantiate the plug-in and set render
_defineProperty(_assertThisInitialized(_this), "_componentApp", void 0);
_defineProperty(_assertThisInitialized(_this), "channelType", void 0);
_defineProperty(_assertThisInitialized(_this), "productSceneVersion", void 0);
_defineProperty(_assertThisInitialized(_this), "timer", void 0);
var ComponentPlugin = new ComponentApp();
ComponentPlugin.setRender(createIframeNode);
ComponentPlugin.setPreloadRender(createPreloadIframeNode);
// Register Cashier Application Plug in
_this._registerPlugin(COMPONENTPLUGINID, ComponentPlugin);
_this._componentApp = _this._getPlugin(COMPONENTPLUGINID);
_this.registerBusAbility();
return _this;
return _super.call(this, options);
}
_createClass(AddressComponent, [{
key: "parameterInitAndCheck",
value: function parameterInitAndCheck(_ref) {
var params = _ref.params,
selector = _ref.selector,
renderDisplayType = _ref.renderDisplayType;
this.options.mode = modeEnum.component;
this.options.networkMode = this.options.networkMode || networkModeEnum.session;
var _params = Object.assign({
selector: selector,
renderDisplayType: renderDisplayType
}, params);
return Promise.resolve(_params);
}
}, {
key: "pluginAppendIframe",
value: function pluginAppendIframe(appendParams) {
try {
return this._componentApp.appendIframeNodes(appendParams.componentSign, appendParams.iframeNodesParams);
} catch (error) {
return Promise.reject(error);
}
}
}, {
key: "savePreviousChannel",
value: function savePreviousChannel(iframeNodesParams) {
var _ref2 = iframeNodesParams || {},
componentSign = _ref2.componentSign;
var channelType = componentSign;
if (Array.isArray(this.channelType) && this.channelType.includes(channelType)) {
this.logger.logInfo({
title: 'preload_match'
}, {
preloadChannel: this.channelType,
preloadVersion: this.productSceneVersion,
sessionDataChannel: channelType
});
} else {
this.logger.logInfo({
title: 'preload_no_match'
}, {
preloadChannel: this.channelType,
preloadVersion: this.productSceneVersion,
sessionDataChannel: channelType
});
}
var previousChannel = {
channelType: channelType,
productSceneVersion: this.productSceneVersion
};
localStorage.setItem('antom_checkout_previousChannel', JSON.stringify(previousChannel));
}
/**
* 初始化 Bus总线的能力
*/
}, {
key: "registerBusAbility",
value: function registerBusAbility() {
var _this$originOptions,
_this2 = this;
BusManager.debugTrace(((_this$originOptions = this.originOptions) === null || _this$originOptions === void 0 ? void 0 : _this$originOptions.environment) !== environmentEnum.prod, this.logger);
BusManager.clear();
BusManager.addInterceptor({
onPublishException: function onPublishException(message, e) {
_this2.logger.logError({
title: 'onBusPublishException'
}, _objectSpread(_objectSpread({}, message), {}, {
errorMessage: JSON.stringify(e)
}));
}
});
// subscribe basic ablility
BusManager.subscribe(new SDKCallbackBusSubscriber(function (state) {
var _this2$_componentApp;
(_this2$_componentApp = _this2._componentApp) === null || _this2$_componentApp === void 0 || (_this2$_componentApp = _this2$_componentApp.AMSSDK) === null || _this2$_componentApp === void 0 || _this2$_componentApp._eventCenter.emit(EVENT.eventCallback.name, state);
}));
BusManager.subscribe(new SecurityBusSubscriber(function (deviceIdParameter, isPolling) {
var _this2$_componentApp2;
return (_this2$_componentApp2 = _this2._componentApp) === null || _this2$_componentApp2 === void 0 ? void 0 : _this2$_componentApp2.getDeviceIdAndLog(deviceIdParameter, isPolling);
}));
BusManager.subscribe(new TrackerBusSubscriber(this.logger));
// subscribe plugin
BusManager.subscribe(new ApplePayBusSubscriber(this.logger));
BusManager.subscribe(new PaypalBusSubscriber(this.logger));
}
}, {
key: "preloadComponent",
value: function preloadComponent(channelType, productSceneVersion) {
var _this3 = this;
this.channelType = channelType;
this.productSceneVersion = productSceneVersion;
var MAX_CLEAR_TIME = 10000;
if (Array.isArray(channelType)) {
for (var i = 0; i < channelType.length; i++) {
this._componentApp.appendPreloadIframeNodes(channelType[i], productSceneVersion);
}
} else {
this.logger.logError({
title: 'performance_optimization_channelType_error'
}, {
channelType: channelType
});
}
this.timer = setTimeout(function () {
_this3.clearPreloadIframe(true);
}, MAX_CLEAR_TIME);
}
}, {
key: "clearPreloadIframe",
value: function clearPreloadIframe() {
var isTimeOut = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
!isTimeOut && clearTimeout(this.timer);
if (Array.isArray(this.channelType)) {
for (var i = 0; i < this.channelType.length; i++) {
var iframe = document.getElementById("ams-checkout-component-".concat(this.channelType[i], "-").concat(this.productSceneVersion));
iframe && document.body.removeChild(iframe);
}
}
if (!isTimeOut) {
this.logger.logInfo({
title: 'performance_optimization_clearPreloadIframe'
});
} else {
this.logger.logInfo({
title: 'performance_optimization_clearPreloadIframe_timeout'
});
}
}
/**
* @description Create and render components in the specified element area
* @param params - The data source created by the component, necessary sessionData, optional appearance configurations, and refer to the documentation for other parameters and detailed information.
* @param selector - Necessary element selector ID
*/
}, {
key: "mountComponent",
value: function mountComponent(params, selector) {
var _this4 = this;
this.clearPreloadIframe();
this.logger.setComponentStartTime(Date.now());
return this.parameterInitAndCheck({
params: params,
renderDisplayType: renderDisplayTypeEnum.inline,
selector: selector
}).then(function (_params) {
return handleParams(_params);
}).catch(function (error) {
_this4.logger.logError({
title: 'sdk_error_parameter'
}, {
params: JSON.stringify(params)
}).send();
_this4._eventCenter.emit(EVENT.error.name, error);
return Promise.reject(error);
}).then(function (appendParams) {
return _this4.mountComponentProcess(appendParams);
});
}
}, {
key: "mountComponentProcess",
value: function mountComponentProcess(appendParams) {
var _this$getBusActionNam;
this._appendParams = appendParams;
var actionName = (_this$getBusActionNam = this.getBusActionNames()) === null || _this$getBusActionNam === void 0 ? void 0 : _this$getBusActionNam.mountComponent;
if (actionName && BusManager.isSubscribed(actionName)) {
// 执行出错了,在通用拦截器返回
BusManager.publish(new BusMessage(actionName, JSON.stringify({
appendParams: appendParams,
options: this.originOptions
})));
return Promise.resolve();
}
this.savePreviousChannel(appendParams);
return this.pluginAppendIframe(appendParams);
}
/**
* @description Execute payment submission process
* @description - When using your own payment button, you can execute the submit payment process by actively calling this function.
* @param data - Transfer information in the submission interface according to your requirements (optional)
*/
}, {
key: "getValue",
value: function getValue(data) {
var _this5 = this;
var _this = this;
return new Promise(function (resolve, reject) {
try {
var _this5$getBusActionNa;
var _this$getBusActionNam;
var eventCallbackId = uuid();
_this5.logger.logInfo({
_this.logger.logInfo({
title: 'sdk_event_apiGetValue'
});
var actionName = (_this5$getBusActionNa = _this5.getBusActionNames()) === null || _this5$getBusActionNa === void 0 ? void 0 : _this5$getBusActionNa.getValue;
var actionName = (_this$getBusActionNam = _this.getBusActionNames()) === null || _this$getBusActionNam === void 0 ? void 0 : _this$getBusActionNam.getValue;
if (actionName && BusManager.isSubscribed(actionName)) {
// 执行出错了,在通用拦截器返回
BusManager.publishForResult(new BusMessage(actionName, JSON.stringify({
appendParams: _this5._appendParams,
options: _this5.originOptions,
appendParams: _this._appendParams,
options: _this.originOptions,
data: data

@@ -282,6 +56,6 @@ }))).then(function (busMessage) {

// eslint-disable-next-line @typescript-eslint/no-explicit-any
_this5._eventCenter.once(eventCallbackId, function (_data) {
_this._eventCenter.once(eventCallbackId, function (_data) {
resolve(_data);
});
_this5._componentApp.dispatchToApp({
_this._componentApp.dispatchToApp({
context: {

@@ -301,2 +75,2 @@ event: 'getValue',

return AddressComponent;
}(CoreInstance);
}(AMSComponent);

103

esm/core/component/index.js

@@ -94,3 +94,3 @@ 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); }

};
var handleParams = function handleParams(params) {
var handleParams = function handleParams(params, _this) {
var _params = Object.assign({

@@ -111,2 +111,5 @@ paymentSessionMetaData: {},

}
if (_this.options.product === productSceneEnum.ELEMENT_ADDRESS) {
componentSign = componentSignEnum.ELEMENT_ADDRESS;
}
if (componentSign === componentSignEnum.NONE) {

@@ -135,10 +138,10 @@ // eslint-disable-next-line prefer-promise-reject-errors

function AMSComponent(options) {
var _this;
var _this2;
_classCallCheck(this, AMSComponent);
_this = _super.call(this, options);
_this2 = _super.call(this, options);
// Instantiate the plug-in and set render
_defineProperty(_assertThisInitialized(_this), "_componentApp", void 0);
_defineProperty(_assertThisInitialized(_this), "channelType", void 0);
_defineProperty(_assertThisInitialized(_this), "productSceneVersion", void 0);
_defineProperty(_assertThisInitialized(_this), "timer", void 0);
_defineProperty(_assertThisInitialized(_this2), "_componentApp", void 0);
_defineProperty(_assertThisInitialized(_this2), "channelType", void 0);
_defineProperty(_assertThisInitialized(_this2), "productSceneVersion", void 0);
_defineProperty(_assertThisInitialized(_this2), "timer", void 0);
var ComponentPlugin = new ComponentApp();

@@ -148,6 +151,6 @@ ComponentPlugin.setRender(createIframeNode);

// Register Cashier Application Plug in
_this._registerPlugin(COMPONENTPLUGINID, ComponentPlugin);
_this._componentApp = _this._getPlugin(COMPONENTPLUGINID);
_this.registerBusAbility();
return _this;
_this2._registerPlugin(COMPONENTPLUGINID, ComponentPlugin);
_this2._componentApp = _this2._getPlugin(COMPONENTPLUGINID);
_this2.registerBusAbility();
return _this2;
}

@@ -166,3 +169,3 @@ _createClass(AMSComponent, [{

}, params);
if (_params && !_params.sessionData && !(_params !== null && _params !== void 0 && _params.paymentSessionData)) {
if (this.options.product !== productSceneEnum.ELEMENT_ADDRESS && _params && !_params.sessionData && !(_params !== null && _params !== void 0 && _params.paymentSessionData)) {
return Promise.reject(ERRORMESSAGE.CREATEPAYMENT_PARAMETER_ERROR);

@@ -252,3 +255,3 @@ }

var _this$originOptions,
_this2 = this;
_this3 = this;
BusManager.debugTrace(((_this$originOptions = this.originOptions) === null || _this$originOptions === void 0 ? void 0 : _this$originOptions.environment) !== environmentEnum.prod, this.logger);

@@ -258,3 +261,3 @@ BusManager.clear();

onPublishException: function onPublishException(message, e) {
_this2.logger.logError({
_this3.logger.logError({
title: 'onBusPublishException'

@@ -268,8 +271,8 @@ }, _objectSpread(_objectSpread({}, message), {}, {

BusManager.subscribe(new SDKCallbackBusSubscriber(function (state) {
var _this2$_componentApp;
(_this2$_componentApp = _this2._componentApp) === null || _this2$_componentApp === void 0 || (_this2$_componentApp = _this2$_componentApp.AMSSDK) === null || _this2$_componentApp === void 0 || _this2$_componentApp._eventCenter.emit(EVENT.eventCallback.name, state);
var _this3$_componentApp;
(_this3$_componentApp = _this3._componentApp) === null || _this3$_componentApp === void 0 || (_this3$_componentApp = _this3$_componentApp.AMSSDK) === null || _this3$_componentApp === void 0 || _this3$_componentApp._eventCenter.emit(EVENT.eventCallback.name, state);
}));
BusManager.subscribe(new SecurityBusSubscriber(function (deviceIdParameter, isPolling) {
var _this2$_componentApp2;
return (_this2$_componentApp2 = _this2._componentApp) === null || _this2$_componentApp2 === void 0 ? void 0 : _this2$_componentApp2.getDeviceIdAndLog(deviceIdParameter, isPolling);
var _this3$_componentApp2;
return (_this3$_componentApp2 = _this3._componentApp) === null || _this3$_componentApp2 === void 0 ? void 0 : _this3$_componentApp2.getDeviceIdAndLog(deviceIdParameter, isPolling);
}));

@@ -289,3 +292,3 @@ BusManager.subscribe(new TrackerBusSubscriber(this.logger));

if (paymentChannelMatcher) {
_this2._registerPlugin(paymentChannelMatcher.paymentMethod, item.busActionNames);
_this3._registerPlugin(paymentChannelMatcher.paymentMethod, item.busActionNames);
}

@@ -298,6 +301,6 @@ var sessionMatcher = item.sessionMatcher;

var subPluginKey = pluginKey + paymentMethodType;
_this2._registerPlugin(subPluginKey, item.busActionNames);
_this3._registerPlugin(subPluginKey, item.busActionNames);
});
} else {
_this2._registerPlugin(pluginKey, item.busActionNames);
_this3._registerPlugin(pluginKey, item.busActionNames);
}

@@ -307,3 +310,3 @@ }

if (optInit) {
BusManager.publish(new BusMessage(optInit, JSON.stringify(_this2.originOptions)));
BusManager.publish(new BusMessage(optInit, JSON.stringify(_this3.originOptions)));
}

@@ -322,10 +325,10 @@ });

value: function canMakePayments(paymentMethod, subPaymentMethod) {
var _this3 = this;
var _this4 = this;
// 判断支付方式是否可用
return new Promise(function (resolve) {
var _this3$_getPlugin;
var _this4$_getPlugin;
if (!paymentMethod) {
return resolve(true);
}
var actionName = (_this3$_getPlugin = _this3._getPlugin(paymentMethod)) === null || _this3$_getPlugin === void 0 ? void 0 : _this3$_getPlugin.canMakePayments;
var actionName = (_this4$_getPlugin = _this4._getPlugin(paymentMethod)) === null || _this4$_getPlugin === void 0 ? void 0 : _this4$_getPlugin.canMakePayments;
if (actionName && BusManager.isSubscribed(actionName)) {

@@ -340,3 +343,3 @@ BusManager.publishForResult(new BusMessage(actionName, JSON.stringify({

}).catch(function (e) {
_this3.logger.logInfo({
_this4.logger.logInfo({
title: 'canMakePayments_error'

@@ -360,3 +363,3 @@ }, {

value: function createComponent(params) {
var _this4 = this;
var _this5 = this;
this.clearPreloadIframe();

@@ -368,5 +371,5 @@ this.logger.setComponentStartTime(Date.now());

}).then(function (_params) {
return handleParams(_params);
return handleParams(_params, _this5);
}).catch(function (error) {
_this4.logger.logError({
_this5.logger.logError({
title: 'sdk_error_parameter'

@@ -376,8 +379,8 @@ }, {

}).send();
_this4._eventCenter.emit(EVENT.error.name, error);
_this5._eventCenter.emit(EVENT.error.name, error);
return Promise.reject(error);
}).then(function (appendParams) {
var iframeNodesParams = appendParams.iframeNodesParams;
_this4.logger.setTrackId(iframeNodesParams === null || iframeNodesParams === void 0 ? void 0 : iframeNodesParams.sessionData);
return _this4.createComponentProcess(appendParams);
_this5.logger.setTrackId(iframeNodesParams === null || iframeNodesParams === void 0 ? void 0 : iframeNodesParams.sessionData);
return _this5.createComponentProcess(appendParams);
});

@@ -406,3 +409,3 @@ }

value: function preloadComponent(channelType, productSceneVersion) {
var _this5 = this;
var _this6 = this;
this.channelType = channelType;

@@ -423,3 +426,3 @@ this.productSceneVersion = productSceneVersion;

this.timer = setTimeout(function () {
_this5.clearPreloadIframe(true);
_this6.clearPreloadIframe(true);
}, MAX_CLEAR_TIME);

@@ -456,3 +459,3 @@ }

value: function mountComponent(params, selector) {
var _this6 = this;
var _this7 = this;
this.clearPreloadIframe();

@@ -465,5 +468,5 @@ this.logger.setComponentStartTime(Date.now());

}).then(function (_params) {
return handleParams(_params);
return handleParams(_params, _this7);
}).catch(function (error) {
_this6.logger.logError({
_this7.logger.logError({
title: 'sdk_error_parameter'

@@ -473,8 +476,8 @@ }, {

}).send();
_this6._eventCenter.emit(EVENT.error.name, error);
_this7._eventCenter.emit(EVENT.error.name, error);
return Promise.reject(error);
}).then(function (appendParams) {
var iframeNodesParams = appendParams.iframeNodesParams;
_this6.logger.setTrackId(iframeNodesParams === null || iframeNodesParams === void 0 ? void 0 : iframeNodesParams.sessionData);
return _this6.mountComponentProcess(appendParams);
_this7.logger.setTrackId(iframeNodesParams === null || iframeNodesParams === void 0 ? void 0 : iframeNodesParams.sessionData);
return _this7.mountComponentProcess(appendParams);
});

@@ -497,3 +500,5 @@ }

var iframeNodesParams = appendParams.iframeNodesParams;
this.savePreviousChannel(iframeNodesParams);
if (this.options.product !== productSceneEnum.ELEMENT_ADDRESS) {
this.savePreviousChannel(appendParams);
}
return this.pluginAppendIframe(appendParams);

@@ -509,16 +514,16 @@ }

value: function submit(data) {
var _this7 = this;
var _this8 = this;
return new Promise(function (resolve, reject) {
try {
var _this7$getBusActionNa;
var _this8$getBusActionNa;
var eventCallbackId = uuid();
_this7.logger.logInfo({
_this8.logger.logInfo({
title: 'sdk_event_apiSubmit'
});
var actionName = (_this7$getBusActionNa = _this7.getBusActionNames()) === null || _this7$getBusActionNa === void 0 ? void 0 : _this7$getBusActionNa.submit;
var actionName = (_this8$getBusActionNa = _this8.getBusActionNames()) === null || _this8$getBusActionNa === void 0 ? void 0 : _this8$getBusActionNa.submit;
if (actionName && BusManager.isSubscribed(actionName)) {
// 执行出错了,在通用拦截器返回
BusManager.publishForResult(new BusMessage(actionName, JSON.stringify({
appendParams: _this7._appendParams,
options: _this7.originOptions,
appendParams: _this8._appendParams,
options: _this8.originOptions,
data: data

@@ -530,6 +535,6 @@ }))).then(function (busMessage) {

// eslint-disable-next-line @typescript-eslint/no-explicit-any
_this7._eventCenter.once(eventCallbackId, function (_data) {
_this8._eventCenter.once(eventCallbackId, function (_data) {
resolve(_data);
});
_this7._componentApp.dispatchToApp({
_this8._componentApp.dispatchToApp({
context: {

@@ -536,0 +541,0 @@ event: 'submitPay',

@@ -317,2 +317,7 @@ 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); }

}
/** 地址监听 */
if (options !== null && options !== void 0 && options.onChange) {
if (getType(options.onChange) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.message);
this._overrideSubscription(EVENT.onChange.name, options.onChange, EVENT.onChange.uniqueKey);
}
}

@@ -428,2 +433,5 @@ /**

}
if (this.options.product === productSceneEnum.ELEMENT_ADDRESS) {
actionNames = this._getPlugin(productSceneEnum.ELEMENT_ADDRESS);
}
return actionNames;

@@ -430,0 +438,0 @@ }

@@ -11,3 +11,3 @@ /**

import { IoptionsParams, componentSignEnum } from './types';
import { IoptionsAddressParams } from './types/address';
import { IoptionsAddressParams } from './types/index';
export * from './types';

@@ -35,8 +35,5 @@ export declare class AMSCheckout extends AMSComponent {

}
export declare class Address extends AddressComponent {
constructor(_options: any, channelType?: componentSignEnum[], productSceneVersion?: string);
}
export declare class AddressElement extends Address {
export declare class AddressElement extends AddressComponent {
constructor(options: IoptionsAddressParams);
}
export default AMSCheckout;

@@ -151,27 +151,15 @@ 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); }

}(AMSCheckout);
export var Address = /*#__PURE__*/function (_AddressComponent) {
_inherits(Address, _AddressComponent);
var _super8 = _createSuper(Address);
function Address(_options, channelType) {
var _this2;
var productSceneVersion = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '1.0';
_classCallCheck(this, Address);
_this2 = _super8.call(this, _options);
_this2.preloadComponent(channelType, productSceneVersion);
return _this2;
}
return _createClass(Address);
}(AddressComponent);
export var AddressElement = /*#__PURE__*/function (_Address) {
_inherits(AddressElement, _Address);
var _super9 = _createSuper(AddressElement);
export var AddressElement = /*#__PURE__*/function (_AddressComponent) {
_inherits(AddressElement, _AddressComponent);
var _super8 = _createSuper(AddressElement);
function AddressElement(options) {
_classCallCheck(this, AddressElement);
var _options = Object.assign({}, options, {
product: productSceneEnum.ELEMENT_ADDRESS
product: productSceneEnum.ELEMENT_ADDRESS,
environment: 'dev'
});
return _super9.call(this, _options, [componentSignEnum.ELEMENT_ADDRESS]);
return _super8.call(this, _options);
}
return _createClass(AddressElement);
}(Address);
}(AddressComponent);
export default AMSCheckout;

@@ -100,2 +100,6 @@ 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); }

}
// 地址应用特殊处理
if (componentSign === componentSignEnum.ELEMENT_ADDRESS) {
return "".concat(elementAppMarmotMap[environment], "/element-address/").concat(finalAppVersion, "/pages/address/index.html");
}
// element应用特殊处理

@@ -102,0 +106,0 @@ if (_toConsumableArray(Object.values(ComponentSignEnumV2)).includes(componentSign)) {

@@ -8,2 +8,13 @@ /**

*/
export type onChange = () => onCnageResult;
interface onCnageResult {
complete: boolean;
addressValue: AddressItem[];
selectIndex: number | string;
}
export type getValue = (hasValidate: boolean) => Promise<AddressValueResult>;
interface AddressValueResult {
complete: boolean;
value: AddressItem;
}
/**

@@ -21,2 +32,3 @@ * SDK options

onClose?: callOnClose;
onChange?: onChange;
networkMode?: string;

@@ -99,3 +111,78 @@ mode?: string;

paypalConfiguration?: IPaypalConfiguration;
/** 将address-element参数定义合入原参数定义 */
mode?: string;
appId?: string;
configParams?: {
hideFields?: string[];
addressAutoSuggestDisabled?: addressAutoSuggestDisabledType;
};
prefillValue?: AddressItem[];
componentSession?: string;
appearance?: {
[x: string]: any;
themeType?: string;
accentColor?: string;
};
local?: string;
}
/** 表单地址数据 */
export interface AddressItem {
shippingName: {
firstName: string;
lastName: string;
};
/** 手机号 */
shippingPhoneNo: string;
/** 地址 */
shippingAddress: {
/** 国家 */
region: string;
/** 地址1 */
address1: string;
/** 地址2 */
address2: string;
/** 省份 */
province?: string;
/** 城市 */
city?: string;
/** 地址级联 四层 【province,city,district,subDistrict】 */
district?: string[];
/** 邮政编码 */
zipCode: string;
/** 对应地址级联数据对象 */
districtValues?: {
/** 城市 */
city?: string;
/** 区/县 */
district?: string;
/** 省份 */
province?: string;
/** 子区域 */
subDistrict?: string;
};
};
/** 备注 */
notes?: string;
open?: boolean;
/** 是否默认地址 */
prefer?: '1' | '0';
shippingId?: string;
}
type addressAutoSuggestDisabledType = 0 | 1;
export interface addressInitOption {
mode?: string;
appId?: string;
configParams?: {
hideFields?: string[];
addressAutoSuggestDisabled?: addressAutoSuggestDisabledType;
};
prefillValue?: AddressItem[];
componentSession?: string;
appearance?: {
[x: string]: any;
themeType: string;
accentColor: string;
};
local?: string;
}
export interface IPaypalConfiguration {

@@ -577,1 +664,14 @@ style?: object;

};
export interface IoptionsAddressParams {
environment?: string;
locale?: string;
onSizeChanged?: callOnSizeChanged;
onChange?: onChange;
networkMode?: string;
mode?: string;
analytics?: {
enabled: boolean;
};
product?: string;
}
export {};

@@ -9,2 +9,3 @@ /**

/* eslint-disable @typescript-eslint/no-explicit-any */
/**

@@ -58,2 +59,5 @@ * SDK options

}({});
/** 表单地址数据 */
export var payPalConfigurationIntentEnum = /*#__PURE__*/function (payPalConfigurationIntentEnum) {

@@ -60,0 +64,0 @@ payPalConfigurationIntentEnum["intent"] = "intent";

{
"name": "@alipay/ams-checkout",
"version": "0.0.1723203704-dev.3",
"version": "0.0.1723203704-dev.4",
"description": "",

@@ -5,0 +5,0 @@ "author": "",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc