@alipay/ams-checkout 0.0.1709715270-dev.0 → 0.0.1709715270-dev.2
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.
- package/dist/umd/ams-checkout.min.js +1 -1
- package/esm/core/bus/ability/callback.d.ts +9 -0
- package/esm/core/bus/ability/callback.js +55 -0
- package/esm/core/bus/ability/security.d.ts +10 -0
- package/esm/core/bus/ability/security.js +104 -0
- package/esm/core/bus/ability/tracker.d.ts +9 -0
- package/esm/core/bus/ability/tracker.js +77 -0
- package/esm/core/bus/index.d.ts +72 -0
- package/esm/core/bus/index.js +309 -0
- package/esm/core/bus/interface.d.ts +32 -0
- package/esm/core/bus/interface.js +35 -0
- package/esm/core/component/index.d.ts +7 -1
- package/esm/core/component/index.js +106 -17
- package/esm/core/instance/index.d.ts +1 -0
- package/esm/core/instance/index.js +2 -0
- package/esm/index.d.ts +0 -3
- package/esm/index.js +8 -18
- package/esm/{core/applepay/index.d.ts → plugin/applepay/component.d.ts} +16 -7
- package/esm/{core/applepay/index.js → plugin/applepay/component.js} +110 -131
- package/esm/plugin/applepay/index.d.ts +17 -0
- package/esm/plugin/applepay/index.js +100 -0
- package/esm/{common → plugin}/applepay/interface.d.ts +61 -0
- package/esm/plugin/applepay/interface.js +73 -0
- package/esm/{common/applepay/index.d.ts → plugin/applepay/service.d.ts} +5 -3
- package/esm/{common/applepay/index.js → plugin/applepay/service.js} +75 -20
- package/esm/plugin/component/index.d.ts +2 -2
- package/esm/plugin/component/index.js +9 -9
- package/esm/types/index.d.ts +45 -4
- package/package.json +1 -1
- package/esm/common/applepay/interface.js +0 -1
@@ -0,0 +1,100 @@
|
|
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; }
|
4
|
+
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); }
|
5
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
6
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
7
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
8
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
9
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
10
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
11
|
+
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); } }
|
12
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
13
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
14
|
+
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; }
|
15
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
16
|
+
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); }
|
17
|
+
import { BusManager, BusMessage, BusSubscriber } from "../../core/bus";
|
18
|
+
import { ApplePayActionEnum, PaymentActionEnum, SDKCallbackActionEnum } from "../../core/bus/interface";
|
19
|
+
import ApplePayComponent from "./component";
|
20
|
+
import ApplePayService from "./service";
|
21
|
+
export var ApplePayInitMessage = /*#__PURE__*/_createClass(function ApplePayInitMessage() {
|
22
|
+
_classCallCheck(this, ApplePayInitMessage);
|
23
|
+
_defineProperty(this, "environment", void 0);
|
24
|
+
_defineProperty(this, "locale", void 0);
|
25
|
+
});
|
26
|
+
export var ApplePayBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
|
27
|
+
_inherits(ApplePayBusSubscriber, _BusSubscriber);
|
28
|
+
var _super = _createSuper(ApplePayBusSubscriber);
|
29
|
+
function ApplePayBusSubscriber(logger) {
|
30
|
+
var _this;
|
31
|
+
_classCallCheck(this, ApplePayBusSubscriber);
|
32
|
+
_this = _super.call(this);
|
33
|
+
_defineProperty(_assertThisInitialized(_this), "applePay", void 0);
|
34
|
+
_defineProperty(_assertThisInitialized(_this), "logger", void 0);
|
35
|
+
_this.logger = logger;
|
36
|
+
return _this;
|
37
|
+
}
|
38
|
+
_createClass(ApplePayBusSubscriber, [{
|
39
|
+
key: "actionNames",
|
40
|
+
value: function actionNames() {
|
41
|
+
return Object.values(ApplePayActionEnum).concat(Object.values(PaymentActionEnum));
|
42
|
+
}
|
43
|
+
}, {
|
44
|
+
key: "onOptionalInit",
|
45
|
+
value: function onOptionalInit(context, message) {
|
46
|
+
console.log('onOptionalInit', message.getData());
|
47
|
+
}
|
48
|
+
}, {
|
49
|
+
key: "onCanMakePayments",
|
50
|
+
value: function onCanMakePayments(context, message) {
|
51
|
+
var _message$getJSONObjec;
|
52
|
+
console.log('onCanMakePayments', message.getData());
|
53
|
+
var canMakePayments = ApplePayService.canMakePayments((_message$getJSONObjec = message.getJSONObject()) === null || _message$getJSONObjec === void 0 ? void 0 : _message$getJSONObjec.subPaymentMethod);
|
54
|
+
context === null || context === void 0 || context.onCallBack(message.result(canMakePayments));
|
55
|
+
}
|
56
|
+
}, {
|
57
|
+
key: "onCreateComponent",
|
58
|
+
value: function onCreateComponent(context, message) {
|
59
|
+
var data = message.getJSONObject();
|
60
|
+
console.log('onCreateComponent', message);
|
61
|
+
this.applePay = new ApplePayComponent(_objectSpread(_objectSpread({}, data === null || data === void 0 ? void 0 : data.options), {}, {
|
62
|
+
onEventCallback: function onEventCallback(state) {
|
63
|
+
console.log('onCreateComponent#onEventCallback', state);
|
64
|
+
if (state) {
|
65
|
+
BusManager.publish(new BusMessage(SDKCallbackActionEnum.onEventCallback, JSON.stringify(state)));
|
66
|
+
}
|
67
|
+
}
|
68
|
+
}), this.logger);
|
69
|
+
var paymentSessionData = data === null || data === void 0 ? void 0 : data.paymentSessionData;
|
70
|
+
this.applePay.submitPay(paymentSessionData);
|
71
|
+
}
|
72
|
+
}, {
|
73
|
+
key: "onDestoryComponent",
|
74
|
+
value: function onDestoryComponent(context, message) {
|
75
|
+
this.applePay = null;
|
76
|
+
console.log('onDestoryComponent', context, message);
|
77
|
+
}
|
78
|
+
}, {
|
79
|
+
key: "onMessage",
|
80
|
+
value: function onMessage(context, message) {
|
81
|
+
switch (message.getAction()) {
|
82
|
+
case PaymentActionEnum.optional_init:
|
83
|
+
this.onOptionalInit(context, message);
|
84
|
+
break;
|
85
|
+
case ApplePayActionEnum.canMakePayments:
|
86
|
+
this.onCanMakePayments(context, message);
|
87
|
+
break;
|
88
|
+
case ApplePayActionEnum.createComponent:
|
89
|
+
this.onCreateComponent(context, message);
|
90
|
+
break;
|
91
|
+
case ApplePayActionEnum.destoryComponent:
|
92
|
+
this.onDestoryComponent(context, message);
|
93
|
+
break;
|
94
|
+
default:
|
95
|
+
console.log("Unknown action: " + message.getAction());
|
96
|
+
}
|
97
|
+
}
|
98
|
+
}]);
|
99
|
+
return ApplePayBusSubscriber;
|
100
|
+
}(BusSubscriber);
|
@@ -6,6 +6,8 @@
|
|
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
|
export type Version = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
9
|
+
export declare const APPLE_PAY_VERSION = 2;
|
10
|
+
export declare const APPLE_PAY_RECURRING_VERSION = 14;
|
9
11
|
export interface IApplePayValidateMerchantEvent {
|
10
12
|
validationURL: string;
|
11
13
|
}
|
@@ -35,10 +37,41 @@ export interface IApplePayPaymentContact {
|
|
35
37
|
countryCode: string;
|
36
38
|
}
|
37
39
|
export type IApplePayLineItemType = 'final' | 'pending';
|
40
|
+
export type ApplePayPaymentTiming = "immediate" | "recurring" | "deferred" | "automaticReload";
|
41
|
+
export type ApplePayRecurringPaymentDateUnit = "year" | "month" | "day" | "hour" | "minute";
|
42
|
+
/**
|
43
|
+
*
|
44
|
+
{
|
45
|
+
"label": "Subscription",
|
46
|
+
"amount": "20.00",
|
47
|
+
"type": "final",
|
48
|
+
"paymentTiming": "recurring",
|
49
|
+
"recurringPaymentStartDate": new Date("2022-01-01T00:00:00"),
|
50
|
+
"recurringPaymentIntervalUnit": "month",
|
51
|
+
"recurringPaymentIntervalCount": 6,
|
52
|
+
"recurringPaymentEndDate": new Date("2024-01-01T00:00:00"),
|
53
|
+
}
|
54
|
+
*/
|
38
55
|
export interface IApplePayLineItem {
|
56
|
+
/**
|
57
|
+
* A value that indicates whether the line item is final or pending.
|
58
|
+
*/
|
39
59
|
type: IApplePayLineItemType;
|
60
|
+
/**
|
61
|
+
* A required value that’s a short, localized description of the line item.
|
62
|
+
*/
|
40
63
|
label: string;
|
64
|
+
/**
|
65
|
+
* A required value that’s the monetary amount of the line item.
|
66
|
+
*/
|
41
67
|
amount: string;
|
68
|
+
paymentTiming?: ApplePayPaymentTiming;
|
69
|
+
recurringPaymentStartDate?: Date;
|
70
|
+
recurringPaymentEndDate?: Date;
|
71
|
+
recurringPaymentIntervalUnit?: ApplePayRecurringPaymentDateUnit;
|
72
|
+
recurringPaymentIntervalCount?: number;
|
73
|
+
deferredPaymentDate?: Date;
|
74
|
+
automaticReloadPaymentThresholdAmount?: string;
|
42
75
|
}
|
43
76
|
export type applePayShippingType = 'shipping' | 'delivery' | 'storePickup' | 'servicePickup';
|
44
77
|
export interface IApplePayShippingMethod {
|
@@ -75,6 +108,34 @@ export interface IApplePayPaymentRequest {
|
|
75
108
|
currencyCode: string;
|
76
109
|
shippingType?: applePayShippingType;
|
77
110
|
shippingMethods?: IApplePayShippingMethod[];
|
111
|
+
recurringPaymentRequest?: IApplePayRecurringPaymentRequest;
|
112
|
+
}
|
113
|
+
export interface IApplePayRecurringPaymentRequest {
|
114
|
+
/**
|
115
|
+
* A description of the recurring payment that Apple Pay displays to the user in the payment sheet.
|
116
|
+
*/
|
117
|
+
paymentDescription: string;
|
118
|
+
/**
|
119
|
+
* A localized billing agreement that the payment sheet displays to the user before the user authorizes the payment.
|
120
|
+
*/
|
121
|
+
billingAgreement?: string;
|
122
|
+
/**
|
123
|
+
* The regular billing cycle for the recurring payment, including start and end dates, an interval, and an interval count.
|
124
|
+
*/
|
125
|
+
regularBilling: IApplePayLineItem;
|
126
|
+
/**
|
127
|
+
* 订阅试用的周期控制,暂时不需要
|
128
|
+
* The trial billing cycle for the recurring payment.
|
129
|
+
*/
|
130
|
+
trialBilling?: IApplePayLineItem;
|
131
|
+
/**
|
132
|
+
* A URL to a web page where the user can update or delete the payment method for the recurring payment.
|
133
|
+
*/
|
134
|
+
managementURL: string;
|
135
|
+
/**
|
136
|
+
* A URL you provide for receiving life-cycle notifications from the Apple Pay servers about the Apple Pay merchant token for the recurring payment.
|
137
|
+
*/
|
138
|
+
tokenNotificationURL?: string;
|
78
139
|
}
|
79
140
|
export interface IApplePaySession {
|
80
141
|
supportsVersion?: (version: Version) => boolean;
|
@@ -0,0 +1,73 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
|
3
|
+
*
|
4
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), the rights to use, copy, modify, merge, and/or distribute the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
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
|
+
* 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
|
+
*/
|
8
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
9
|
+
// https://developer.apple.com/documentation/apple_pay_on_the_web/apple_pay_on_the_web_version_history
|
10
|
+
|
11
|
+
export var APPLE_PAY_VERSION = 2;
|
12
|
+
export var APPLE_PAY_RECURRING_VERSION = 14;
|
13
|
+
|
14
|
+
// https://developer.apple.com/documentation/apple_pay_on_the_web/applepayvalidatemerchantevent
|
15
|
+
|
16
|
+
// https://developer.apple.com/documentation/apple_pay_on_the_web/applepaymerchantcapability
|
17
|
+
|
18
|
+
// https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypaymentrequest/1916122-supportednetworks
|
19
|
+
|
20
|
+
// https://developer.apple.com/documentation/apple_pay_on_the_web/applepaycontactfield
|
21
|
+
|
22
|
+
// https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypaymentcontact
|
23
|
+
|
24
|
+
// https://developer.apple.com/documentation/apple_pay_on_the_web/applepaylineitemtype
|
25
|
+
|
26
|
+
//https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypaymenttiming
|
27
|
+
|
28
|
+
//https://developer.apple.com/documentation/apple_pay_on_the_web/applepayrecurringpaymentdateunit
|
29
|
+
|
30
|
+
// https://developer.apple.com/documentation/apple_pay_on_the_web/applepaylineitem
|
31
|
+
/**
|
32
|
+
*
|
33
|
+
{
|
34
|
+
"label": "Subscription",
|
35
|
+
"amount": "20.00",
|
36
|
+
"type": "final",
|
37
|
+
"paymentTiming": "recurring",
|
38
|
+
"recurringPaymentStartDate": new Date("2022-01-01T00:00:00"),
|
39
|
+
"recurringPaymentIntervalUnit": "month",
|
40
|
+
"recurringPaymentIntervalCount": 6,
|
41
|
+
"recurringPaymentEndDate": new Date("2024-01-01T00:00:00"),
|
42
|
+
}
|
43
|
+
*/
|
44
|
+
|
45
|
+
// https://developer.apple.com/documentation/apple_pay_on_the_web/applepayshippingtype
|
46
|
+
|
47
|
+
// https://developer.apple.com/documentation/apple_pay_on_the_web/applepayshippingmethod
|
48
|
+
|
49
|
+
// https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypayment
|
50
|
+
|
51
|
+
// https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypaymentauthorizedevent
|
52
|
+
|
53
|
+
// https://developer.apple.com/documentation/apple_pay_on_the_web/apple_pay_js_api/apple_pay_status_codes
|
54
|
+
|
55
|
+
// https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypaymentauthorizationresult
|
56
|
+
|
57
|
+
// https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypaymentrequest
|
58
|
+
|
59
|
+
// https://developer.apple.com/documentation/apple_pay_on_the_web/applepayrecurringpaymentrequest
|
60
|
+
|
61
|
+
// https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession
|
62
|
+
|
63
|
+
// IGetMerchantSession spi type
|
64
|
+
|
65
|
+
// ICompletePaymentAuthorized spi type
|
66
|
+
|
67
|
+
// ICompleteApplePay spi type
|
68
|
+
|
69
|
+
// ILogError spi type
|
70
|
+
|
71
|
+
// trace msg type
|
72
|
+
|
73
|
+
// IApplePayTrace spi type
|
@@ -6,7 +6,7 @@
|
|
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
|
import { IGetMerchantSession, ICompletePaymentAuthorized, ICompleteApplePay, ILogError, IApplePayTrace } from './interface';
|
9
|
-
import { IpaymentSessionMetaData } from '../../types';
|
9
|
+
import { ApplePaySubTypeEnum, IpaymentSessionMetaData } from '../../types';
|
10
10
|
/**
|
11
11
|
* Apple Pay Service
|
12
12
|
*/
|
@@ -30,9 +30,11 @@ declare class ApplePayService {
|
|
30
30
|
*/
|
31
31
|
setApplePayParams(getMerchantSession: IGetMerchantSession, completePaymentAuthorized: ICompletePaymentAuthorized, completeApplePay: ICompleteApplePay, logError: ILogError, applePayTrace: IApplePayTrace): void;
|
32
32
|
/**
|
33
|
-
* Apple Pay
|
33
|
+
* Is Apple Pay Enabled
|
34
|
+
* @param subTypeEnum
|
35
|
+
* @returns
|
34
36
|
*/
|
35
|
-
|
37
|
+
static canMakePayments(subTypeEnum?: ApplePaySubTypeEnum): any;
|
36
38
|
/**
|
37
39
|
* has Active Card in Apple Pay
|
38
40
|
* @param merchantIdentifier
|
@@ -16,6 +16,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
16
16
|
* 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.
|
17
17
|
*/
|
18
18
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
19
|
+
import { APPLE_PAY_VERSION, APPLE_PAY_RECURRING_VERSION } from "./interface";
|
19
20
|
/**
|
20
21
|
* Apple Pay Service
|
21
22
|
*/
|
@@ -31,12 +32,6 @@ var ApplePayService = /*#__PURE__*/function () {
|
|
31
32
|
_defineProperty(this, "completeApplePay", void 0);
|
32
33
|
_defineProperty(this, "logError", void 0);
|
33
34
|
_defineProperty(this, "applePayTrace", void 0);
|
34
|
-
/**
|
35
|
-
* Apple Pay is enabled
|
36
|
-
*/
|
37
|
-
_defineProperty(this, "isEnabled", function () {
|
38
|
-
return window.ApplePaySession ? window.ApplePaySession.canMakePayments() : false;
|
39
|
-
});
|
40
35
|
_defineProperty(this, "onvalidatemerchant", function (event) {
|
41
36
|
_this.applePayTrace('onValidateMerchant');
|
42
37
|
_this.getMerchantSession({
|
@@ -44,6 +39,7 @@ var ApplePayService = /*#__PURE__*/function () {
|
|
44
39
|
merchantIdentifier: _this.merchantIdentifier,
|
45
40
|
validationUrl: event.validationURL
|
46
41
|
}).then(function (merchantSessionObjectString) {
|
42
|
+
console.log("onvalidatemerchant#merchantSessionObjectString", merchantSessionObjectString);
|
47
43
|
var merchantSessionObject = JSON.parse(merchantSessionObjectString);
|
48
44
|
_this.session.completeMerchantValidation(merchantSessionObject);
|
49
45
|
_this.applePayTrace('completeMerchantValidation');
|
@@ -88,28 +84,73 @@ var ApplePayService = /*#__PURE__*/function () {
|
|
88
84
|
throw Error('ApplePaySession is null in window');
|
89
85
|
}
|
90
86
|
var paymentSessionFactor = param.paymentSessionFactor;
|
91
|
-
var
|
87
|
+
var extendInfo = paymentSessionFactor.extendInfo,
|
92
88
|
merchantInfo = paymentSessionFactor.merchantInfo,
|
93
89
|
paymentAmount = paymentSessionFactor.paymentAmount,
|
94
|
-
order = paymentSessionFactor.order
|
90
|
+
order = paymentSessionFactor.order,
|
91
|
+
recurringInfo = paymentSessionFactor.recurringInfo;
|
95
92
|
_this.merchantIdentifier = merchantInfo === null || merchantInfo === void 0 ? void 0 : merchantInfo.partnerId;
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
93
|
+
if (!(extendInfo !== null && extendInfo !== void 0 && extendInfo.merchantCapabilities) || !(extendInfo !== null && extendInfo !== void 0 && extendInfo.supportedNetworks) || !(merchantInfo !== null && merchantInfo !== void 0 && merchantInfo.registeredCountry) || !(paymentAmount !== null && paymentAmount !== void 0 && paymentAmount.currency) || !(paymentAmount !== null && paymentAmount !== void 0 && paymentAmount.value) || !(merchantInfo !== null && merchantInfo !== void 0 && merchantInfo.merchantName)) {
|
94
|
+
_this.logError("invalid session data");
|
95
|
+
return;
|
96
|
+
}
|
97
|
+
if (recurringInfo) {
|
98
|
+
var _recurringInfo$interv;
|
99
|
+
if (!(order !== null && order !== void 0 && order.orderDescription) || !(recurringInfo !== null && recurringInfo !== void 0 && recurringInfo.managementURL)) {
|
100
|
+
_this.logError("invalid session data in recurring");
|
101
|
+
return;
|
105
102
|
}
|
106
|
-
|
107
|
-
|
103
|
+
var lineItem = {
|
104
|
+
type: 'final',
|
105
|
+
label: recurringInfo.title,
|
106
|
+
amount: paymentAmount === null || paymentAmount === void 0 ? void 0 : paymentAmount.value,
|
107
|
+
paymentTiming: "recurring",
|
108
|
+
recurringPaymentStartDate: recurringInfo !== null && recurringInfo !== void 0 && recurringInfo.startDate ? new Date(Number(recurringInfo.startDate) * 1000) : null,
|
109
|
+
recurringPaymentEndDate: recurringInfo !== null && recurringInfo !== void 0 && recurringInfo.endDate ? new Date(Number(recurringInfo.endDate) * 1000) : null,
|
110
|
+
recurringPaymentIntervalUnit: recurringInfo !== null && recurringInfo !== void 0 && recurringInfo.intervalUnit ? recurringInfo.intervalUnit : "month",
|
111
|
+
recurringPaymentIntervalCount: (_recurringInfo$interv = recurringInfo === null || recurringInfo === void 0 ? void 0 : recurringInfo.intervalCount) !== null && _recurringInfo$interv !== void 0 ? _recurringInfo$interv : 1
|
112
|
+
};
|
113
|
+
var recurringRequest = {
|
114
|
+
// 不知道显示在哪里
|
115
|
+
paymentDescription: order === null || order === void 0 ? void 0 : order.orderDescription,
|
116
|
+
billingAgreement: recurringInfo.agreementDescription,
|
117
|
+
regularBilling: lineItem,
|
118
|
+
managementURL: recurringInfo === null || recurringInfo === void 0 ? void 0 : recurringInfo.managementURL,
|
119
|
+
tokenNotificationURL: recurringInfo === null || recurringInfo === void 0 ? void 0 : recurringInfo.tokenNotificationURL
|
120
|
+
};
|
121
|
+
var request = {
|
122
|
+
merchantCapabilities: extendInfo === null || extendInfo === void 0 ? void 0 : extendInfo.merchantCapabilities,
|
123
|
+
supportedNetworks: extendInfo === null || extendInfo === void 0 ? void 0 : extendInfo.supportedNetworks,
|
124
|
+
countryCode: merchantInfo === null || merchantInfo === void 0 ? void 0 : merchantInfo.registeredCountry,
|
125
|
+
currencyCode: paymentAmount === null || paymentAmount === void 0 ? void 0 : paymentAmount.currency,
|
126
|
+
total: lineItem,
|
127
|
+
recurringPaymentRequest: recurringRequest,
|
128
|
+
lineItems: [lineItem]
|
129
|
+
};
|
130
|
+
_this.session = new ApplePaySession(APPLE_PAY_RECURRING_VERSION, request);
|
131
|
+
} else {
|
132
|
+
var _request = {
|
133
|
+
merchantCapabilities: extendInfo === null || extendInfo === void 0 ? void 0 : extendInfo.merchantCapabilities,
|
134
|
+
supportedNetworks: extendInfo === null || extendInfo === void 0 ? void 0 : extendInfo.supportedNetworks,
|
135
|
+
countryCode: merchantInfo === null || merchantInfo === void 0 ? void 0 : merchantInfo.registeredCountry,
|
136
|
+
currencyCode: paymentAmount === null || paymentAmount === void 0 ? void 0 : paymentAmount.currency,
|
137
|
+
total: {
|
138
|
+
type: 'final',
|
139
|
+
label: merchantInfo === null || merchantInfo === void 0 ? void 0 : merchantInfo.merchantName,
|
140
|
+
amount: paymentAmount === null || paymentAmount === void 0 ? void 0 : paymentAmount.value
|
141
|
+
}
|
142
|
+
};
|
143
|
+
_this.session = new ApplePaySession(APPLE_PAY_VERSION, _request);
|
144
|
+
}
|
108
145
|
_this.session.onvalidatemerchant = _this.onvalidatemerchant;
|
109
146
|
_this.session.onpaymentauthorized = _this.onpaymentauthorized;
|
110
147
|
_this.session.oncancel = function () {
|
111
148
|
_this.logError('UserCancel');
|
112
|
-
|
149
|
+
try {
|
150
|
+
_this.session.abort();
|
151
|
+
} catch (error) {
|
152
|
+
console.log("session.abort() error");
|
153
|
+
}
|
113
154
|
};
|
114
155
|
_this.session.begin();
|
115
156
|
_this.applePayTrace('sessionBegin');
|
@@ -133,6 +174,12 @@ var ApplePayService = /*#__PURE__*/function () {
|
|
133
174
|
this.logError = logError;
|
134
175
|
this.applePayTrace = applePayTrace;
|
135
176
|
}
|
177
|
+
|
178
|
+
/**
|
179
|
+
* Is Apple Pay Enabled
|
180
|
+
* @param subTypeEnum
|
181
|
+
* @returns
|
182
|
+
*/
|
136
183
|
}, {
|
137
184
|
key: "hasActiveCard",
|
138
185
|
value: (
|
@@ -165,6 +212,14 @@ var ApplePayService = /*#__PURE__*/function () {
|
|
165
212
|
}
|
166
213
|
return hasActiveCard;
|
167
214
|
}())
|
215
|
+
}], [{
|
216
|
+
key: "canMakePayments",
|
217
|
+
value: function canMakePayments(subTypeEnum) {
|
218
|
+
if ('ApplePayRecurringPayment' === subTypeEnum) {
|
219
|
+
return window.ApplePaySession ? window.ApplePaySession.canMakePayments() && window.ApplePaySession.supportsVersion(APPLE_PAY_RECURRING_VERSION) : false;
|
220
|
+
}
|
221
|
+
return window.ApplePaySession ? window.ApplePaySession.canMakePayments() && window.ApplePaySession.supportsVersion(APPLE_PAY_VERSION) : false;
|
222
|
+
}
|
168
223
|
}]);
|
169
224
|
return ApplePayService;
|
170
225
|
}();
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import type AMSCheckout from '../../core/instance';
|
2
2
|
import type { eventPayload, eventPayloadContext, IappendIframeNodesParams, IMerchantAppointParam, Iselector } from '../../types';
|
3
|
-
import { componentSignEnum, platformEnum, renderDisplayTypeEnum } from '../../types';
|
3
|
+
import { componentSignEnum, DeviceIdParameter, platformEnum, renderDisplayTypeEnum } from '../../types';
|
4
4
|
type IrenderFuncParams = (context: ComponentApp, selector: Iselector, renderDisplayType: renderDisplayTypeEnum) => Promise<void>;
|
5
5
|
export default class ComponentApp {
|
6
6
|
app: null | HTMLIFrameElement;
|
@@ -44,7 +44,7 @@ export default class ComponentApp {
|
|
44
44
|
setPreloadRender(renderFunc: any): void;
|
45
45
|
private initSecurity;
|
46
46
|
private logDeviceId;
|
47
|
-
|
47
|
+
getDeviceIdAndLog(deviceIdParameter?: DeviceIdParameter, isPolling?: boolean): Promise<string>;
|
48
48
|
/**
|
49
49
|
* @description render iframe content
|
50
50
|
*/
|
@@ -364,7 +364,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
364
364
|
this._actionQueryPromise = new Promise( /*#__PURE__*/function () {
|
365
365
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(resolve, reject) {
|
366
366
|
var _this5$_renderParams, _this5$_renderParams2, _this5$_renderParams3, _this5$_renderParams4, _this5$_renderParams5;
|
367
|
-
var envInfo, params,
|
367
|
+
var envInfo, params, _ref3, extendInfo, enableVaultingApiOptimize, enableEasypayApiOptimize, extendInfoData, _this5$_renderParams6, _this5$_renderParams7, _ref4, _ref4$productSceneVer, productSceneVersion, _ref4$productScene, productScene, _ref5, _ref5$action, _ref5$action2, _ref5$action2$autoDeb, autoDebitWithToken, _this5$_renderParams8, _action$web, _action$wap, action, signType;
|
368
368
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
369
369
|
while (1) switch (_context2.prev = _context2.next) {
|
370
370
|
case 0:
|
@@ -380,7 +380,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
380
380
|
/**
|
381
381
|
* @description Simulated or unnecessary scenarios
|
382
382
|
*/
|
383
|
-
|
383
|
+
_ref3 = ((_this5$_renderParams4 = _this5._renderParams) === null || _this5$_renderParams4 === void 0 ? void 0 : _this5$_renderParams4.paymentSessionMetaData) || {}, extendInfo = _ref3.extendInfo;
|
384
384
|
enableVaultingApiOptimize = false;
|
385
385
|
enableEasypayApiOptimize = false;
|
386
386
|
try {
|
@@ -427,8 +427,8 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
427
427
|
_context2.next = 26;
|
428
428
|
break;
|
429
429
|
}
|
430
|
-
|
431
|
-
|
430
|
+
_ref4 = params.paymentSessionConfig || {}, _ref4$productSceneVer = _ref4.productSceneVersion, productSceneVersion = _ref4$productSceneVer === void 0 ? '' : _ref4$productSceneVer, _ref4$productScene = _ref4.productScene, productScene = _ref4$productScene === void 0 ? '' : _ref4$productScene;
|
431
|
+
_ref5 = ((_this5$_renderParams6 = _this5._renderParams) === null || _this5$_renderParams6 === void 0 ? void 0 : _this5$_renderParams6.paymentSessionMetaData) || {}, _ref5$action = _ref5.action, _ref5$action2 = _ref5$action === void 0 ? {} : _ref5$action, _ref5$action2$autoDeb = _ref5$action2.autoDebitWithToken, autoDebitWithToken = _ref5$action2$autoDeb === void 0 ? false : _ref5$action2$autoDeb;
|
432
432
|
if (!((_this5$_renderParams7 = _this5._renderParams) !== null && _this5$_renderParams7 !== void 0 && (_this5$_renderParams7 = _this5$_renderParams7.paymentSessionMetaData) !== null && _this5$_renderParams7 !== void 0 && (_this5$_renderParams7 = _this5$_renderParams7.action) !== null && _this5$_renderParams7 !== void 0 && _this5$_renderParams7.skipSdkQuery && enableEasypayApiOptimize)) {
|
433
433
|
_context2.next = 21;
|
434
434
|
break;
|
@@ -542,7 +542,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
542
542
|
|
543
543
|
// eslint-disable-next-line no-async-promise-executor
|
544
544
|
this._actionSubmitPromise = new Promise( /*#__PURE__*/function () {
|
545
|
-
var
|
545
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(resolve) {
|
546
546
|
var _this6$_renderParams;
|
547
547
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
548
548
|
while (1) switch (_context3.prev = _context3.next) {
|
@@ -605,7 +605,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
605
605
|
}, _callee3);
|
606
606
|
}));
|
607
607
|
return function (_x3) {
|
608
|
-
return
|
608
|
+
return _ref6.apply(this, arguments);
|
609
609
|
};
|
610
610
|
}());
|
611
611
|
}
|
@@ -1196,9 +1196,9 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
1196
1196
|
}
|
1197
1197
|
}, {
|
1198
1198
|
key: "handleDeclareInfo",
|
1199
|
-
value: function handleDeclareInfo(
|
1200
|
-
var
|
1201
|
-
closeDialogData =
|
1199
|
+
value: function handleDeclareInfo(_ref7) {
|
1200
|
+
var _ref7$closeDialogData = _ref7.closeDialogData,
|
1201
|
+
closeDialogData = _ref7$closeDialogData === void 0 ? {} : _ref7$closeDialogData;
|
1202
1202
|
_handleDeclareInfo({
|
1203
1203
|
closeDialogData: closeDialogData
|
1204
1204
|
});
|
package/esm/types/index.d.ts
CHANGED
@@ -135,16 +135,17 @@ export interface IpaymentSessionMetaData {
|
|
135
135
|
skipSdkQuery: boolean;
|
136
136
|
};
|
137
137
|
paymentSessionFactor?: {
|
138
|
-
|
138
|
+
extendInfo?: {
|
139
139
|
merchantCapabilities?: string[];
|
140
140
|
supportedNetworks?: string[];
|
141
141
|
};
|
142
142
|
merchantInfo?: {
|
143
143
|
registeredCountry?: string;
|
144
144
|
partnerId?: string;
|
145
|
+
merchantName?: string;
|
145
146
|
};
|
146
147
|
order?: {
|
147
|
-
orderDescription
|
148
|
+
orderDescription: string;
|
148
149
|
};
|
149
150
|
paymentAmount?: {
|
150
151
|
value?: string;
|
@@ -156,6 +157,43 @@ export interface IpaymentSessionMetaData {
|
|
156
157
|
paymentMethodViewMetaData?: any;
|
157
158
|
paymentRequestId?: string;
|
158
159
|
supportedLanguages?: any;
|
160
|
+
/**
|
161
|
+
* 当前为苹果分期场景的信息
|
162
|
+
*/
|
163
|
+
recurringInfo?: {
|
164
|
+
/**
|
165
|
+
* 代扣协议开始日期 不传为当前系统时间
|
166
|
+
*/
|
167
|
+
startDate?: number;
|
168
|
+
/**
|
169
|
+
* 代扣协议结束日期 不传不限制结束时间
|
170
|
+
*/
|
171
|
+
endDate?: number;
|
172
|
+
/**
|
173
|
+
* 付款时间间隔单位,支持:"year" "month" "day" "hour" "minute" 不传默认month
|
174
|
+
*/
|
175
|
+
intervalUnit?: string;
|
176
|
+
/**
|
177
|
+
* 付款时间间隔。比如每过6个月付款一次,intervalCount就是6, 不传默认为1
|
178
|
+
*/
|
179
|
+
intervalCount?: number;
|
180
|
+
/**
|
181
|
+
* 分期标题信息
|
182
|
+
*/
|
183
|
+
title?: string;
|
184
|
+
/**
|
185
|
+
* 分期管理页面
|
186
|
+
*/
|
187
|
+
managementURL?: string;
|
188
|
+
/**
|
189
|
+
* 苹果通知ipay MAPN信息变更的地址
|
190
|
+
*/
|
191
|
+
tokenNotificationURL?: string;
|
192
|
+
/**
|
193
|
+
* 分期协议描述
|
194
|
+
*/
|
195
|
+
agreementDescription?: string;
|
196
|
+
};
|
159
197
|
};
|
160
198
|
}
|
161
199
|
export declare enum localeEnum {
|
@@ -201,8 +239,8 @@ export declare enum platformEnum {
|
|
201
239
|
desktop = "desktop",
|
202
240
|
mobile = "mobile"
|
203
241
|
}
|
204
|
-
type EventCallbackResult = {
|
205
|
-
result
|
242
|
+
export type EventCallbackResult = {
|
243
|
+
result?: {
|
206
244
|
resultCode: string;
|
207
245
|
resultStatus: string;
|
208
246
|
resultMessage: string;
|
@@ -433,4 +471,7 @@ export interface CallbackEventInfo {
|
|
433
471
|
export interface MultipleCallbackEvents {
|
434
472
|
[key: string]: CallbackEventInfo;
|
435
473
|
}
|
474
|
+
export type PaymentMethodTypeEnum = 'ApplePay';
|
475
|
+
export type ApplePaySubTypeEnum = 'ApplePayRecurringPayment';
|
476
|
+
export type SubPaymentMethodTypeEnum = ApplePaySubTypeEnum;
|
436
477
|
export {};
|
package/package.json
CHANGED
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|