@alipay/ams-checkout 0.0.1711691167-dev.12 → 0.0.1711691167-dev.13
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.
@@ -21,7 +21,7 @@ import { BusManager, BusMessage, BusSubscriber } from "../../core/bus";
|
|
21
21
|
import { PaypalActionEnum, SDKCallbackActionEnum } from "../../core/bus/interface";
|
22
22
|
import { queryPaymentInfo } from "../../service";
|
23
23
|
import { eventCodeEnum, payPalConfigurationIntentEnum, PaypalMethodEnum } from "../../types";
|
24
|
-
import { isFunction } from "../../util";
|
24
|
+
import { isFunction, safeJson } from "../../util";
|
25
25
|
import { appendLoadingIcon, isShowLoading } from "../utils";
|
26
26
|
export var PaypalBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
|
27
27
|
_inherits(PaypalBusSubscriber, _BusSubscriber);
|
@@ -71,8 +71,8 @@ export var PaypalBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
|
|
71
71
|
}
|
72
72
|
});
|
73
73
|
_defineProperty(_assertThisInitialized(_this), "preCheck", function (paypalPluginProps) {
|
74
|
-
var _paypalPluginProps$pa, _paypalPluginProps$pa2;
|
75
|
-
var boundPaymentMethod = (_paypalPluginProps$pa = paypalPluginProps.paymentSessionFactor) === null || _paypalPluginProps$pa === void 0 || (_paypalPluginProps$pa = _paypalPluginProps$pa.paymentMethodInfo) === null || _paypalPluginProps$pa === void 0
|
74
|
+
var _safeJson, _paypalPluginProps$pa, _paypalPluginProps$pa2;
|
75
|
+
var boundPaymentMethod = (_safeJson = safeJson((((_paypalPluginProps$pa = paypalPluginProps.paymentSessionFactor) === null || _paypalPluginProps$pa === void 0 || (_paypalPluginProps$pa = _paypalPluginProps$pa.paymentMethodInfo) === null || _paypalPluginProps$pa === void 0 ? void 0 : _paypalPluginProps$pa.paymentMethodMetaData) || '').replace(/\\"/g, '"'), {})) === null || _safeJson === void 0 ? void 0 : _safeJson.boundPaymentMethod;
|
76
76
|
var paymentMethodType = (_paypalPluginProps$pa2 = paypalPluginProps.paymentSessionFactor) === null || _paypalPluginProps$pa2 === void 0 || (_paypalPluginProps$pa2 = _paypalPluginProps$pa2.paymentMethodInfo) === null || _paypalPluginProps$pa2 === void 0 ? void 0 : _paypalPluginProps$pa2.paymentMethodType;
|
77
77
|
if (boundPaymentMethod && PaypalMethodEnum.PAYPAL_VAULT === paymentMethodType) {
|
78
78
|
_this.onEventCallback({
|
@@ -106,10 +106,10 @@ export var PaypalBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
|
|
106
106
|
});
|
107
107
|
_defineProperty(_assertThisInitialized(_this), "createPaypalScript", function (paypalPluginProps) {
|
108
108
|
var _paypalPluginProps$pa3, _paypalPluginProps$pa4, _paypalPluginProps$pa5, _paypalPluginProps$pa6;
|
109
|
-
var channelMerchantAccountId = (_paypalPluginProps$pa3 = paypalPluginProps.paymentSessionFactor) === null || _paypalPluginProps$pa3 === void 0 || (_paypalPluginProps$pa3 = _paypalPluginProps$pa3.merchantInfo) === null || _paypalPluginProps$pa3 === void 0 ? void 0 : _paypalPluginProps$pa3.
|
109
|
+
var channelMerchantAccountId = (_paypalPluginProps$pa3 = paypalPluginProps.paymentSessionFactor) === null || _paypalPluginProps$pa3 === void 0 || (_paypalPluginProps$pa3 = _paypalPluginProps$pa3.merchantInfo) === null || _paypalPluginProps$pa3 === void 0 ? void 0 : _paypalPluginProps$pa3.channelMerchantClientId;
|
110
110
|
var accessToken = (_paypalPluginProps$pa4 = paypalPluginProps.paymentSessionFactor) === null || _paypalPluginProps$pa4 === void 0 || (_paypalPluginProps$pa4 = _paypalPluginProps$pa4.paymentMethodInfo) === null || _paypalPluginProps$pa4 === void 0 || (_paypalPluginProps$pa4 = _paypalPluginProps$pa4.paypal) === null || _paypalPluginProps$pa4 === void 0 ? void 0 : _paypalPluginProps$pa4.accessToken;
|
111
111
|
var locale = paypalPluginProps.locale;
|
112
|
-
var currency = (_paypalPluginProps$pa5 = paypalPluginProps.paymentSessionFactor) === null || _paypalPluginProps$pa5 === void 0 || (_paypalPluginProps$pa5 = _paypalPluginProps$pa5.
|
112
|
+
var currency = (_paypalPluginProps$pa5 = paypalPluginProps.paymentSessionFactor) === null || _paypalPluginProps$pa5 === void 0 || (_paypalPluginProps$pa5 = _paypalPluginProps$pa5.paymentAmount) === null || _paypalPluginProps$pa5 === void 0 ? void 0 : _paypalPluginProps$pa5.currency;
|
113
113
|
var paymentMethodType = (_paypalPluginProps$pa6 = paypalPluginProps.paymentSessionFactor) === null || _paypalPluginProps$pa6 === void 0 || (_paypalPluginProps$pa6 = _paypalPluginProps$pa6.paymentMethodInfo) === null || _paypalPluginProps$pa6 === void 0 ? void 0 : _paypalPluginProps$pa6.paymentMethodType;
|
114
114
|
var _ref2 = (paypalPluginProps === null || paypalPluginProps === void 0 ? void 0 : paypalPluginProps.paypalConfiguration) || {},
|
115
115
|
blockPayPalCreditButton = _ref2.blockPayPalCreditButton,
|
@@ -172,7 +172,7 @@ export var PaypalBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
|
|
172
172
|
};
|
173
173
|
}());
|
174
174
|
_defineProperty(_assertThisInitialized(_this), "createOrder", /*#__PURE__*/function () {
|
175
|
-
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_data, _action, paymentSessionData, env) {
|
175
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_data, _action, paymentSessionData, env, paymentSessionConfig) {
|
176
176
|
var _queryPaymentInfoRes$;
|
177
177
|
var queryPaymentInfoRes;
|
178
178
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
@@ -180,7 +180,8 @@ export var PaypalBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
|
|
180
180
|
case 0:
|
181
181
|
_context2.next = 2;
|
182
182
|
return queryPaymentInfo({
|
183
|
-
paymentSessionData: paymentSessionData
|
183
|
+
paymentSessionData: paymentSessionData,
|
184
|
+
paymentSessionConfig: paymentSessionConfig
|
184
185
|
}, {
|
185
186
|
env: env,
|
186
187
|
timeout: 15000
|
@@ -207,7 +208,7 @@ export var PaypalBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
|
|
207
208
|
}
|
208
209
|
}, _callee2);
|
209
210
|
}));
|
210
|
-
return function (_x2, _x3, _x4, _x5) {
|
211
|
+
return function (_x2, _x3, _x4, _x5, _x6) {
|
211
212
|
return _ref4.apply(this, arguments);
|
212
213
|
};
|
213
214
|
}());
|
@@ -233,7 +234,7 @@ export var PaypalBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
|
|
233
234
|
}
|
234
235
|
}, _callee3);
|
235
236
|
}));
|
236
|
-
return function (
|
237
|
+
return function (_x7) {
|
237
238
|
return _ref5.apply(this, arguments);
|
238
239
|
};
|
239
240
|
}());
|
@@ -259,7 +260,7 @@ export var PaypalBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
|
|
259
260
|
}
|
260
261
|
}, _callee4);
|
261
262
|
}));
|
262
|
-
return function (
|
263
|
+
return function (_x8) {
|
263
264
|
return _ref6.apply(this, arguments);
|
264
265
|
};
|
265
266
|
}());
|
@@ -283,7 +284,7 @@ export var PaypalBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
|
|
283
284
|
}
|
284
285
|
}, _callee5);
|
285
286
|
}));
|
286
|
-
return function (
|
287
|
+
return function (_x9, _x10) {
|
287
288
|
return _ref7.apply(this, arguments);
|
288
289
|
};
|
289
290
|
}());
|
@@ -305,6 +306,7 @@ export var PaypalBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
|
|
305
306
|
_data$appendParams3,
|
306
307
|
_data$appendParams4,
|
307
308
|
_data$appendParams5,
|
309
|
+
_data$appendParams6,
|
308
310
|
_this2 = this;
|
309
311
|
var data = message.getJSONObject();
|
310
312
|
var paypalPluginProps = {
|
@@ -314,7 +316,8 @@ export var PaypalBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
|
|
314
316
|
paymentSessionFactor: (_data$appendParams2 = data.appendParams) === null || _data$appendParams2 === void 0 || (_data$appendParams2 = _data$appendParams2.iframeNodesParams) === null || _data$appendParams2 === void 0 || (_data$appendParams2 = _data$appendParams2.paymentSessionMetaData) === null || _data$appendParams2 === void 0 ? void 0 : _data$appendParams2.paymentSessionFactor,
|
315
317
|
selector: (_data$appendParams3 = data.appendParams) === null || _data$appendParams3 === void 0 || (_data$appendParams3 = _data$appendParams3.iframeNodesParams) === null || _data$appendParams3 === void 0 ? void 0 : _data$appendParams3.selector,
|
316
318
|
paypalConfiguration: (_data$appendParams4 = data.appendParams) === null || _data$appendParams4 === void 0 || (_data$appendParams4 = _data$appendParams4.iframeNodesParams) === null || _data$appendParams4 === void 0 ? void 0 : _data$appendParams4.paypalConfiguration,
|
317
|
-
appearance: (_data$appendParams5 = data.appendParams) === null || _data$appendParams5 === void 0 || (_data$appendParams5 = _data$appendParams5.iframeNodesParams) === null || _data$appendParams5 === void 0 ? void 0 : _data$appendParams5.appearance
|
319
|
+
appearance: (_data$appendParams5 = data.appendParams) === null || _data$appendParams5 === void 0 || (_data$appendParams5 = _data$appendParams5.iframeNodesParams) === null || _data$appendParams5 === void 0 ? void 0 : _data$appendParams5.appearance,
|
320
|
+
paymentSessionConfig: (_data$appendParams6 = data.appendParams) === null || _data$appendParams6 === void 0 || (_data$appendParams6 = _data$appendParams6.iframeNodesParams) === null || _data$appendParams6 === void 0 || (_data$appendParams6 = _data$appendParams6.paymentSessionMetaData) === null || _data$appendParams6 === void 0 ? void 0 : _data$appendParams6.paymentSessionConfig
|
318
321
|
};
|
319
322
|
return this.preCheck(paypalPluginProps).then(function (paypalPluginProps) {
|
320
323
|
return _this2.loadPaypalResource(paypalPluginProps).then(function () {
|
@@ -328,7 +331,7 @@ export var PaypalBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
|
|
328
331
|
fundingSource: undefined,
|
329
332
|
onShippingChange: _this2.onShippingChange,
|
330
333
|
createOrder: function createOrder(data, action) {
|
331
|
-
return _this2.createOrder(data, action, paypalPluginProps.paymentSessionData, paypalPluginProps.environment);
|
334
|
+
return _this2.createOrder(data, action, paypalPluginProps.paymentSessionData, paypalPluginProps.environment, paypalPluginProps.paymentSessionConfig);
|
332
335
|
},
|
333
336
|
onApprove: _this2.onApprove,
|
334
337
|
onCancel: _this2.onCancel
|
package/esm/types/index.d.ts
CHANGED
@@ -112,7 +112,7 @@ export interface IbillingAddress {
|
|
112
112
|
export interface Isubmit {
|
113
113
|
billingAddress?: IbillingAddress;
|
114
114
|
}
|
115
|
-
interface IpaymentSessionConfig {
|
115
|
+
export interface IpaymentSessionConfig {
|
116
116
|
productScene: productSceneEnum;
|
117
117
|
paymentMethodCategoryType: paymentMethodCategoryTypeEnum;
|
118
118
|
productSceneVersion: string;
|
@@ -212,10 +212,10 @@ export interface IpaymentSessionMetaData {
|
|
212
212
|
export interface IPaymentSessionFactor {
|
213
213
|
merchantInfo?: IMerchantInfo;
|
214
214
|
paymentMethodInfo: IPaymentMethodInfo;
|
215
|
+
paymentAmount?: IPaymentAmount;
|
215
216
|
}
|
216
217
|
export interface IPaymentMethodInfo {
|
217
|
-
|
218
|
-
paymentMethodMetaData?: IPaymentMethodMetaData;
|
218
|
+
paymentMethodMetaData?: string;
|
219
219
|
paymentMethodType?: PaypalMethodEnum;
|
220
220
|
paypal?: IPaypalConfig;
|
221
221
|
}
|
@@ -227,7 +227,7 @@ export interface IPaymentMethodMetaData {
|
|
227
227
|
boundPaymentMethod?: string;
|
228
228
|
}
|
229
229
|
export interface IMerchantInfo {
|
230
|
-
|
230
|
+
channelMerchantClientId?: string;
|
231
231
|
}
|
232
232
|
export interface IPaymentAmount {
|
233
233
|
value?: string;
|
@@ -538,4 +538,3 @@ export type IAppendParams = {
|
|
538
538
|
componentSign: componentSignEnum;
|
539
539
|
iframeNodesParams: IappendIframeNodesParams;
|
540
540
|
};
|
541
|
-
export {};
|