@alipay/ams-checkout 0.0.1711691167-dev.2 → 0.0.1711691167-dev.21

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.
@@ -1,4 +1,6 @@
1
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 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; }
3
+ 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; }
2
4
  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
5
  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); } }
4
6
  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); }); }; }
@@ -17,7 +19,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
17
19
  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); }
18
20
  import { BusManager, BusMessage, BusSubscriber } from "../../core/bus";
19
21
  import { PaypalActionEnum, SDKCallbackActionEnum } from "../../core/bus/interface";
20
- import { submitPayInfo } from "../../service";
22
+ import { queryPaymentInfo } from "../../service";
21
23
  import { eventCodeEnum, payPalConfigurationIntentEnum, PaypalMethodEnum } from "../../types";
22
24
  import { isFunction } from "../../util";
23
25
  import { appendLoadingIcon, isShowLoading } from "../utils";
@@ -90,6 +92,8 @@ export var PaypalBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
90
92
  });
91
93
  }
92
94
  var paypalScript = _this.createPaypalScript(paypalPluginProps);
95
+ // 将script标签添加到DOM中
96
+ document.body.appendChild(paypalScript);
93
97
  // 在script加载完成后执行回调函数
94
98
  paypalScript.onload = function () {
95
99
  resolve('loading successfully');
@@ -98,16 +102,14 @@ export var PaypalBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
98
102
  paypalScript.onerror = function (error) {
99
103
  reject(error);
100
104
  };
101
- // 将script标签添加到DOM中
102
- document.body.appendChild(paypalScript);
103
105
  });
104
106
  });
105
107
  _defineProperty(_assertThisInitialized(_this), "createPaypalScript", function (paypalPluginProps) {
106
108
  var _paypalPluginProps$pa3, _paypalPluginProps$pa4, _paypalPluginProps$pa5, _paypalPluginProps$pa6;
107
- 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.channelMerchantAccountId;
108
- 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;
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
+ var accessToken = (_paypalPluginProps$pa4 = paypalPluginProps.paymentSessionFactor) === null || _paypalPluginProps$pa4 === void 0 || (_paypalPluginProps$pa4 = _paypalPluginProps$pa4.paypal) === null || _paypalPluginProps$pa4 === void 0 ? void 0 : _paypalPluginProps$pa4.accessToken;
109
111
  var locale = paypalPluginProps.locale;
110
- var currency = (_paypalPluginProps$pa5 = paypalPluginProps.paymentSessionFactor) === null || _paypalPluginProps$pa5 === void 0 || (_paypalPluginProps$pa5 = _paypalPluginProps$pa5.paymentMethodInfo) === null || _paypalPluginProps$pa5 === void 0 || (_paypalPluginProps$pa5 = _paypalPluginProps$pa5.paymentAmount) === null || _paypalPluginProps$pa5 === void 0 ? void 0 : _paypalPluginProps$pa5.currency;
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;
111
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;
112
114
  var _ref2 = (paypalPluginProps === null || paypalPluginProps === void 0 ? void 0 : paypalPluginProps.paypalConfiguration) || {},
113
115
  blockPayPalCreditButton = _ref2.blockPayPalCreditButton,
@@ -122,19 +124,15 @@ export var PaypalBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
122
124
  locale: locale,
123
125
  'client-id': channelMerchantAccountId
124
126
  });
125
- if (displayPayPalPayLaterButtonOnly) {
126
- urlSearchParams.append('disable-funding', 'credit,card');
127
- } else {
128
- var disableFundingArr = [];
129
- if (blockPayPalCreditButton) {
130
- disableFundingArr.push('card');
131
- }
132
- if (blockPayPalPayLaterButton) {
133
- disableFundingArr.push('credit');
134
- }
135
- if (disableFundingArr.length) {
136
- urlSearchParams.append('disable-funding', disableFundingArr.join(','));
137
- }
127
+ var disableFundingArr = [];
128
+ if (blockPayPalCreditButton && !displayPayPalPayLaterButtonOnly) {
129
+ disableFundingArr.push('card');
130
+ }
131
+ if (blockPayPalPayLaterButton && !displayPayPalPayLaterButtonOnly) {
132
+ disableFundingArr.push('credit');
133
+ }
134
+ if (disableFundingArr.length) {
135
+ urlSearchParams.append('disable-funding', disableFundingArr.join(','));
138
136
  }
139
137
  if (enableMessages) {
140
138
  urlSearchParams.append('components', 'messages,buttons');
@@ -150,7 +148,7 @@ export var PaypalBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
150
148
  }
151
149
  src += urlSearchParams.toString();
152
150
  script.src = src;
153
- script['data-user-id-token'] = accessToken;
151
+ script.setAttribute('data-user-id-token', accessToken);
154
152
  return script;
155
153
  });
156
154
  _defineProperty(_assertThisInitialized(_this), "onShippingChange", /*#__PURE__*/function () {
@@ -175,17 +173,23 @@ export var PaypalBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
175
173
  };
176
174
  }());
177
175
  _defineProperty(_assertThisInitialized(_this), "createOrder", /*#__PURE__*/function () {
178
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_data, _action, paymentSessionData) {
179
- var _submitPayInfoRes$ext;
180
- var submitPayInfoRes;
176
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_data, _action, paymentSessionData, env, paymentSessionConfig) {
177
+ var _queryPaymentInfoRes$;
178
+ var queryPaymentInfoRes;
181
179
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
182
180
  while (1) switch (_context2.prev = _context2.next) {
183
181
  case 0:
184
182
  _context2.next = 2;
185
- return submitPayInfo(paymentSessionData, {}, _this.logger);
183
+ return queryPaymentInfo({
184
+ paymentSessionData: paymentSessionData,
185
+ paymentSessionConfig: paymentSessionConfig
186
+ }, {
187
+ env: env,
188
+ timeout: 15000
189
+ }, _this.logger);
186
190
  case 2:
187
- submitPayInfoRes = _context2.sent;
188
- if (!(!(submitPayInfoRes !== null && submitPayInfoRes !== void 0 && submitPayInfoRes.success) || !(submitPayInfoRes !== null && submitPayInfoRes !== void 0 && (_submitPayInfoRes$ext = submitPayInfoRes.extendInfo) !== null && _submitPayInfoRes$ext !== void 0 && _submitPayInfoRes$ext.channelOrderId))) {
191
+ queryPaymentInfoRes = _context2.sent;
192
+ if (!(!(queryPaymentInfoRes !== null && queryPaymentInfoRes !== void 0 && queryPaymentInfoRes.success) || !(queryPaymentInfoRes !== null && queryPaymentInfoRes !== void 0 && (_queryPaymentInfoRes$ = queryPaymentInfoRes.extendInfo) !== null && _queryPaymentInfoRes$ !== void 0 && _queryPaymentInfoRes$.channelOrderId))) {
189
193
  _context2.next = 7;
190
194
  break;
191
195
  }
@@ -198,14 +202,14 @@ export var PaypalBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
198
202
  });
199
203
  return _context2.abrupt("return");
200
204
  case 7:
201
- return _context2.abrupt("return", submitPayInfoRes.extendInfo.channelOrderId);
205
+ return _context2.abrupt("return", queryPaymentInfoRes.extendInfo.channelOrderId);
202
206
  case 8:
203
207
  case "end":
204
208
  return _context2.stop();
205
209
  }
206
210
  }, _callee2);
207
211
  }));
208
- return function (_x2, _x3, _x4) {
212
+ return function (_x2, _x3, _x4, _x5, _x6) {
209
213
  return _ref4.apply(this, arguments);
210
214
  };
211
215
  }());
@@ -231,7 +235,7 @@ export var PaypalBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
231
235
  }
232
236
  }, _callee3);
233
237
  }));
234
- return function (_x5) {
238
+ return function (_x7) {
235
239
  return _ref5.apply(this, arguments);
236
240
  };
237
241
  }());
@@ -257,7 +261,7 @@ export var PaypalBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
257
261
  }
258
262
  }, _callee4);
259
263
  }));
260
- return function (_x6) {
264
+ return function (_x8) {
261
265
  return _ref6.apply(this, arguments);
262
266
  };
263
267
  }());
@@ -281,7 +285,7 @@ export var PaypalBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
281
285
  }
282
286
  }, _callee5);
283
287
  }));
284
- return function (_x7, _x8) {
288
+ return function (_x9, _x10) {
285
289
  return _ref7.apply(this, arguments);
286
290
  };
287
291
  }());
@@ -297,35 +301,43 @@ export var PaypalBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
297
301
  key: "renderPaypalButton",
298
302
  value: function renderPaypalButton(context, message) {
299
303
  var _data$options,
304
+ _data$options2,
300
305
  _data$appendParams,
301
306
  _data$appendParams2,
302
307
  _data$appendParams3,
303
308
  _data$appendParams4,
304
309
  _data$appendParams5,
310
+ _data$appendParams6,
305
311
  _this2 = this;
306
312
  var data = message.getJSONObject();
307
313
  var paypalPluginProps = {
308
314
  locale: (_data$options = data.options) === null || _data$options === void 0 ? void 0 : _data$options.locale,
315
+ environment: (_data$options2 = data.options) === null || _data$options2 === void 0 ? void 0 : _data$options2.environment,
309
316
  paymentSessionData: (_data$appendParams = data.appendParams) === null || _data$appendParams === void 0 || (_data$appendParams = _data$appendParams.iframeNodesParams) === null || _data$appendParams === void 0 ? void 0 : _data$appendParams.sessionData,
310
317
  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,
311
318
  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,
312
319
  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,
313
- 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
+ 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,
321
+ 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
314
322
  };
315
323
  return this.preCheck(paypalPluginProps).then(function (paypalPluginProps) {
316
324
  return _this2.loadPaypalResource(paypalPluginProps).then(function () {
317
- var _paypalPluginProps$pa7, _paypalPluginProps$pa8, _paypalPluginProps$pa9;
325
+ var _paypalPluginProps$pa7, _paypalPluginProps$pa8;
318
326
  var createButtonConfig = {
319
- style: (_paypalPluginProps$pa7 = (_paypalPluginProps$pa8 = paypalPluginProps.paypalConfiguration) === null || _paypalPluginProps$pa8 === void 0 ? void 0 : _paypalPluginProps$pa8.style) !== null && _paypalPluginProps$pa7 !== void 0 ? _paypalPluginProps$pa7 : {},
327
+ style: _objectSpread({
328
+ layout: 'vertical',
329
+ color: 'gold',
330
+ shape: 'rect'
331
+ }, ((_paypalPluginProps$pa7 = paypalPluginProps.paypalConfiguration) === null || _paypalPluginProps$pa7 === void 0 ? void 0 : _paypalPluginProps$pa7.style) || {}),
320
332
  fundingSource: undefined,
321
333
  onShippingChange: _this2.onShippingChange,
322
334
  createOrder: function createOrder(data, action) {
323
- return _this2.createOrder(data, action, paypalPluginProps.paymentSessionData);
335
+ return _this2.createOrder(data, action, paypalPluginProps.paymentSessionData, paypalPluginProps.environment, paypalPluginProps.paymentSessionConfig);
324
336
  },
325
337
  onApprove: _this2.onApprove,
326
338
  onCancel: _this2.onCancel
327
339
  };
328
- if ((_paypalPluginProps$pa9 = paypalPluginProps.paypalConfiguration) !== null && _paypalPluginProps$pa9 !== void 0 && _paypalPluginProps$pa9.displayPayPalPayLaterButtonOnly) {
340
+ if ((_paypalPluginProps$pa8 = paypalPluginProps.paypalConfiguration) !== null && _paypalPluginProps$pa8 !== void 0 && _paypalPluginProps$pa8.displayPayPalPayLaterButtonOnly) {
329
341
  createButtonConfig.fundingSource = window.paypal.FUNDING.PAYLATER;
330
342
  }
331
343
  try {
@@ -50,8 +50,6 @@ function requestInstance(options) {
50
50
  withCredentials: (_options$withCredenti = options.withCredentials) !== null && _options$withCredenti !== void 0 ? _options$withCredenti : true,
51
51
  method: (options === null || options === void 0 ? void 0 : options.method) || 'POST'
52
52
  });
53
- console.log('baseURL', baseURL);
54
- console.log('_headers', _headers);
55
53
  return instance.request;
56
54
  }
57
55
 
@@ -99,25 +97,21 @@ function _request() {
99
97
  })];
100
98
  startTime = Date.now();
101
99
  _context.prev = 5;
102
- console.log('requestInstance options', options);
103
- console.log('requestInstance -data', _data);
104
100
  myRequest = requestInstance(options);
105
- _context.next = 11;
101
+ _context.next = 9;
106
102
  return myRequest({
107
103
  data: _data
108
104
  });
109
- case 11:
105
+ case 9:
110
106
  _yield$myRequest = _context.sent;
111
107
  data = _yield$myRequest.data;
112
108
  headers = _yield$myRequest.headers;
113
- console.log('requestInstance data', data);
114
- console.log('requestInstance headers', headers);
115
109
  resData = data || {};
116
110
  traceId = get(headers, 'Mgw-TraceId') || get(headers, 'mgw-traceid', '');
117
111
  resData.traceId = traceId || '';
118
112
  handleGetWayError = fomatGetwayError(headers, traceId);
119
113
  if (!(handleGetWayError !== null && handleGetWayError !== void 0 && handleGetWayError.errorCode)) {
120
- _context.next = 25;
114
+ _context.next = 21;
121
115
  break;
122
116
  }
123
117
  errorMessage = (resData === null || resData === void 0 ? void 0 : resData.errorMessage) || (handleGetWayError === null || handleGetWayError === void 0 ? void 0 : handleGetWayError.errorMessage);
@@ -136,7 +130,7 @@ function _request() {
136
130
  errorCode: errorCode,
137
131
  success: false
138
132
  }));
139
- case 25:
133
+ case 21:
140
134
  logger.reportRPC({
141
135
  name: options === null || options === void 0 ? void 0 : options['Operation-Type'],
142
136
  label: 'request',
@@ -147,8 +141,8 @@ function _request() {
147
141
  traceId: traceId
148
142
  }).send();
149
143
  return _context.abrupt("return", resData);
150
- case 29:
151
- _context.prev = 29;
144
+ case 25:
145
+ _context.prev = 25;
152
146
  _context.t0 = _context["catch"](5);
153
147
  _error = safeJson(_context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.message, {
154
148
  success: false,
@@ -170,11 +164,11 @@ function _request() {
170
164
  errorCode: _errorCode,
171
165
  errorMessage: _error === null || _error === void 0 ? void 0 : _error.message
172
166
  }));
173
- case 36:
167
+ case 32:
174
168
  case "end":
175
169
  return _context.stop();
176
170
  }
177
- }, _callee, null, [[5, 29]]);
171
+ }, _callee, null, [[5, 25]]);
178
172
  }));
179
173
  return _request.apply(this, arguments);
180
174
  }
@@ -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;
@@ -146,6 +146,11 @@ export interface IpaymentSessionMetaData {
146
146
  action?: {
147
147
  autoDebitWithToken: boolean;
148
148
  skipSdkQuery: boolean;
149
+ skipSdkQueryForm?: {
150
+ value: boolean;
151
+ version: string;
152
+ platform: string;
153
+ };
149
154
  };
150
155
  paymentSessionFactor?: {
151
156
  extendInfo?: {
@@ -212,12 +217,12 @@ export interface IpaymentSessionMetaData {
212
217
  export interface IPaymentSessionFactor {
213
218
  merchantInfo?: IMerchantInfo;
214
219
  paymentMethodInfo: IPaymentMethodInfo;
220
+ paymentAmount?: IPaymentAmount;
221
+ paypal?: IPaypalConfig;
215
222
  }
216
223
  export interface IPaymentMethodInfo {
217
- paymentAmount?: IPaymentAmount;
218
224
  paymentMethodMetaData?: IPaymentMethodMetaData;
219
225
  paymentMethodType?: PaypalMethodEnum;
220
- paypal?: IPaypalConfig;
221
226
  }
222
227
  export type IPaypalConfig = {
223
228
  accessToken: string;
@@ -227,7 +232,7 @@ export interface IPaymentMethodMetaData {
227
232
  boundPaymentMethod?: string;
228
233
  }
229
234
  export interface IMerchantInfo {
230
- channelMerchantAccountId?: string;
235
+ channelMerchantClientId?: string;
231
236
  }
232
237
  export interface IPaymentAmount {
233
238
  value?: string;
@@ -437,6 +442,9 @@ export interface CashierSdkActionQueryResult {
437
442
  applinkUrl?: string;
438
443
  schemeUrl?: string;
439
444
  authUrl?: string;
445
+ extendInfo?: {
446
+ channelOrderId?: string;
447
+ };
440
448
  }
441
449
  /**
442
450
  * Get App Pay Payment Session Request.
@@ -535,4 +543,3 @@ export type IAppendParams = {
535
543
  componentSign: componentSignEnum;
536
544
  iframeNodesParams: IappendIframeNodesParams;
537
545
  };
538
- export {};
@@ -4,3 +4,5 @@
4
4
  * @param v2
5
5
  */
6
6
  export declare function compareVersion(v1: string, v2: string): 0 | 1 | -1;
7
+ export declare function isVersionInRange(currentVersion: any, minVersion: any, maxVersion: any): boolean;
8
+ export declare function matchVersion(config: any, currentVersion: any): boolean;
@@ -1,3 +1,9 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
1
7
  /**
2
8
  * 返回值0标识一样大,1表示v1大,-1表示v2大
3
9
  * @param v1
@@ -42,4 +48,73 @@ export function compareVersion(v1, v2) {
42
48
  } else {
43
49
  return 1;
44
50
  }
51
+ }
52
+ export function isVersionInRange(currentVersion, minVersion, maxVersion) {
53
+ function splitVersion(version) {
54
+ return version.split('.').map(function (num) {
55
+ return parseInt(num, 10);
56
+ });
57
+ }
58
+ function compareVersions(v1, v2) {
59
+ for (var i = 0; i < Math.max(v1.length, v2.length); i++) {
60
+ var num1 = v1[i] === undefined ? 0 : v1[i];
61
+ var num2 = v2[i] === undefined ? 0 : v2[i];
62
+ if (num1 > num2) return 1;
63
+ if (num1 < num2) return -1;
64
+ }
65
+ return 0;
66
+ }
67
+ var current = splitVersion(currentVersion);
68
+ var min = minVersion ? splitVersion(minVersion) : null;
69
+ var max = maxVersion ? splitVersion(maxVersion) : null;
70
+ if (min && compareVersions(current, min) < 0) {
71
+ // 当前版本小于最小允许版本
72
+ return false;
73
+ }
74
+ if (max && compareVersions(current, max) > 0) {
75
+ // 当前版本大于最大允许版本
76
+ return false;
77
+ }
78
+ // 当前版本在允许的版本范围内
79
+ return true;
80
+ }
81
+ export function matchVersion(config, currentVersion) {
82
+ var value = config.value,
83
+ version = config.version,
84
+ platform = config.platform;
85
+ var CURRENT_PLATFORM = 'WEB';
86
+ var isMatchVersion = false;
87
+ var isMatchPlatform = false;
88
+
89
+ // 平台判断
90
+ if (platform) {
91
+ var platformList = platform.split('|').map(function (platform) {
92
+ return platform.toLocaleUpperCase();
93
+ });
94
+ isMatchPlatform = platformList.includes(CURRENT_PLATFORM);
95
+ } else {
96
+ // 没有表示平台全匹配
97
+ isMatchPlatform = true;
98
+ }
99
+ // 版本判断
100
+ if (!version) {
101
+ // 为空全匹配
102
+ isMatchVersion = true;
103
+ } else if (version.indexOf('|') !== -1) {
104
+ // | 范围匹配
105
+ var _version$split = version.split('|'),
106
+ _version$split2 = _slicedToArray(_version$split, 2),
107
+ _version$split2$ = _version$split2[0],
108
+ minVersion = _version$split2$ === void 0 ? '' : _version$split2$,
109
+ _version$split2$2 = _version$split2[1],
110
+ maxVersion = _version$split2$2 === void 0 ? '' : _version$split2$2;
111
+ isMatchVersion = isVersionInRange(currentVersion, minVersion, maxVersion);
112
+ } else if (version.indexOf(',') !== -1) {
113
+ // , 枚举匹配
114
+ var versionList = version.split(',');
115
+ isMatchVersion = versionList.includes(currentVersion);
116
+ } else {
117
+ isMatchVersion = version === currentVersion;
118
+ }
119
+ return value && isMatchPlatform && isMatchVersion;
45
120
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alipay/ams-checkout",
3
- "version": "0.0.1711691167-dev.2",
3
+ "version": "0.0.1711691167-dev.21",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "esm/index.js",