@tap-payments/apple-pay-button 0.0.9-test → 0.0.10-test
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/build/@types/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ declare class APPService extends BaseService {
|
|
|
4
4
|
constructor();
|
|
5
5
|
init(publicKey: string, merchantId?: string): Promise<ProfileResponse>;
|
|
6
6
|
appleSession(merchant: MerchantResponse, validationURL: string, merchantRegisteredDomain: string, options: ApplePayButtonProps['options']): Promise<any>;
|
|
7
|
+
nativeAppleSession(merchant: MerchantResponse, validationURL: string, merchantRegisteredDomain: string, options: ApplePayButtonProps['options']): Promise<any>;
|
|
7
8
|
tapTokenization(applePaymentData: Record<string, string>, merchant: MerchantResponse): Promise<any>;
|
|
8
9
|
createCharge(publicKey: string, merchant: MerchantResponse, request: ApplePayRequestData, cardToken: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
9
10
|
}
|
package/build/api/app.service.js
CHANGED
|
@@ -107,6 +107,29 @@ var APPService = (function (_super) {
|
|
|
107
107
|
data = (_a.sent()).data;
|
|
108
108
|
if (data.errors)
|
|
109
109
|
throw data;
|
|
110
|
+
return [2, data.body];
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
Object.defineProperty(APPService.prototype, "nativeAppleSession", {
|
|
117
|
+
enumerable: false,
|
|
118
|
+
configurable: true,
|
|
119
|
+
writable: true,
|
|
120
|
+
value: function (merchant, validationURL, merchantRegisteredDomain, options) {
|
|
121
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
122
|
+
var data;
|
|
123
|
+
return __generator(this, function (_a) {
|
|
124
|
+
switch (_a.label) {
|
|
125
|
+
case 0: return [4, this.httpClient.post(validationURL, {
|
|
126
|
+
merchantIdentifier: (options === null || options === void 0 ? void 0 : options.merchantIdentifier) || 'merchant.tap.gosell',
|
|
127
|
+
displayName: (options === null || options === void 0 ? void 0 : options.mn) || merchant.name,
|
|
128
|
+
initiative: 'web',
|
|
129
|
+
initiativeContext: merchantRegisteredDomain
|
|
130
|
+
})];
|
|
131
|
+
case 1:
|
|
132
|
+
data = (_a.sent()).data;
|
|
110
133
|
return [2, data];
|
|
111
134
|
}
|
|
112
135
|
});
|
|
@@ -17,7 +17,7 @@ import { useApplePay } from '../../hooks/useApplePay';
|
|
|
17
17
|
import { ButtonStyle, Scope } from '../../constants';
|
|
18
18
|
import './ApplePayButton.css';
|
|
19
19
|
var ApplePay = React.memo(function (_a) {
|
|
20
|
-
var publicKey = _a.publicKey, merchant = _a.merchant, transaction = _a.transaction, billingContact = _a.billingContact, supportedNetworks = _a.supportedNetworks, onCancel = _a.onCancel, onError = _a.onError, onSuccess = _a.onSuccess, _b = _a.scope, scope = _b === void 0 ? Scope.TapToken : _b, _c = _a.buttonStyle, buttonStyle = _c === void 0 ? ButtonStyle.WhiteOutline : _c, options = _a.options;
|
|
20
|
+
var publicKey = _a.publicKey, merchant = _a.merchant, transaction = _a.transaction, billingContact = _a.billingContact, supportedNetworks = _a.supportedNetworks, onCancel = _a.onCancel, onError = _a.onError, onSuccess = _a.onSuccess, _b = _a.scope, scope = _b === void 0 ? Scope.TapToken : _b, _c = _a.buttonStyle, buttonStyle = _c === void 0 ? ButtonStyle.WhiteOutline : _c, options = _a.options, clientSession = _a.clientSession;
|
|
21
21
|
var _d = useApplePay({
|
|
22
22
|
publicKey: publicKey,
|
|
23
23
|
merchant: merchant,
|
|
@@ -28,7 +28,8 @@ var ApplePay = React.memo(function (_a) {
|
|
|
28
28
|
onError: onError,
|
|
29
29
|
onSuccess: onSuccess,
|
|
30
30
|
scope: scope,
|
|
31
|
-
options: options
|
|
31
|
+
options: options,
|
|
32
|
+
clientSession: clientSession
|
|
32
33
|
}), loading = _d.loading, onApplePayButtonClicked = _d.onApplePayButtonClicked, disabled = _d.disabled;
|
|
33
34
|
return (_jsx("button", __assign({ className: "button-applepay-tap ".concat(buttonStyle), onClick: onApplePayButtonClicked, disabled: loading || disabled }, { children: _jsx("div", __assign({ className: 'img-container' }, { children: _jsx("img", { loading: 'eager', src: 'https://back-end.b-cdn.net/payment_methods/apple_pay.svg' }) })) })));
|
|
34
35
|
});
|
|
@@ -5,5 +5,5 @@ interface UseApplePayReturnProps {
|
|
|
5
5
|
onApplePayButtonClicked: () => Promise<void>;
|
|
6
6
|
disabled: boolean;
|
|
7
7
|
}
|
|
8
|
-
export declare const useApplePay: ({ publicKey, merchant, transaction, billingContact, onCancel, onError, onSuccess, scope, supportedNetworks, options }: UseApplePayProps) => UseApplePayReturnProps;
|
|
8
|
+
export declare const useApplePay: ({ publicKey, merchant, transaction, billingContact, onCancel, onError, onSuccess, scope, supportedNetworks, options, clientSession }: UseApplePayProps) => UseApplePayReturnProps;
|
|
9
9
|
export {};
|
|
@@ -50,7 +50,7 @@ import appService from '../api/app.service';
|
|
|
50
50
|
import { ApplePayVersion } from '../constants';
|
|
51
51
|
import { getApplePayPaymentMethod, getApplePayRequest, validateCurrency, validateSupportedNetworks } from '../utils/config';
|
|
52
52
|
export var useApplePay = function (_a) {
|
|
53
|
-
var publicKey = _a.publicKey, merchant = _a.merchant, transaction = _a.transaction, billingContact = _a.billingContact, onCancel = _a.onCancel, onError = _a.onError, onSuccess = _a.onSuccess, scope = _a.scope, supportedNetworks = _a.supportedNetworks, options = _a.options;
|
|
53
|
+
var publicKey = _a.publicKey, merchant = _a.merchant, transaction = _a.transaction, billingContact = _a.billingContact, onCancel = _a.onCancel, onError = _a.onError, onSuccess = _a.onSuccess, scope = _a.scope, supportedNetworks = _a.supportedNetworks, options = _a.options, clientSession = _a.clientSession;
|
|
54
54
|
var _b = useState(false), loading = _b[0], setLoading = _b[1];
|
|
55
55
|
var _c = useState(null), profileData = _c[0], setProfile = _c[1];
|
|
56
56
|
var _d = useState(false), disabled = _d[0], setDisabled = _d[1];
|
|
@@ -100,30 +100,38 @@ export var useApplePay = function (_a) {
|
|
|
100
100
|
console.info("Creating ApplePaySession with version: ".concat(ApplePayVersion, " and request: ").concat(JSON.stringify(request)));
|
|
101
101
|
session_1 = new ApplePaySession(ApplePayVersion, request);
|
|
102
102
|
session_1.onvalidatemerchant = function (event) { return __awaiter(void 0, void 0, void 0, function () {
|
|
103
|
-
var merchantSession, error_1;
|
|
104
|
-
return __generator(this, function (
|
|
105
|
-
switch (
|
|
103
|
+
var merchantSession, _a, error_1;
|
|
104
|
+
return __generator(this, function (_b) {
|
|
105
|
+
switch (_b.label) {
|
|
106
106
|
case 0:
|
|
107
107
|
console.info('Creating merchant session and validating merchant session');
|
|
108
108
|
console.info('onvalidatemerchant event', event);
|
|
109
109
|
setLoading(true);
|
|
110
|
-
|
|
110
|
+
_b.label = 1;
|
|
111
111
|
case 1:
|
|
112
|
-
|
|
112
|
+
_b.trys.push([1, 6, , 7]);
|
|
113
113
|
console.info("creating merchant session for merchantData: ".concat(JSON.stringify(profileData.merchant), " and validationURL: ").concat(event.validationURL, " and merchant.domain: ").concat(merchant.domain));
|
|
114
|
-
|
|
114
|
+
if (!clientSession) return [3, 3];
|
|
115
|
+
return [4, appService.nativeAppleSession(profileData.merchant, event.validationURL, merchant.domain, options)];
|
|
115
116
|
case 2:
|
|
116
|
-
|
|
117
|
+
_a = _b.sent();
|
|
118
|
+
return [3, 5];
|
|
119
|
+
case 3: return [4, appService.appleSession(profileData.merchant, event.validationURL, merchant.domain, options)];
|
|
120
|
+
case 4:
|
|
121
|
+
_a = _b.sent();
|
|
122
|
+
_b.label = 5;
|
|
123
|
+
case 5:
|
|
124
|
+
merchantSession = _a;
|
|
117
125
|
console.info('merchantSession', merchantSession);
|
|
118
126
|
session_1.completeMerchantValidation(merchantSession);
|
|
119
127
|
console.info('merchantSession completed successfully!');
|
|
120
|
-
return [3,
|
|
121
|
-
case
|
|
122
|
-
error_1 =
|
|
128
|
+
return [3, 7];
|
|
129
|
+
case 6:
|
|
130
|
+
error_1 = _b.sent();
|
|
123
131
|
console.error('error in onvalidatemerchant', error_1);
|
|
124
132
|
session_1.completePayment({ status: ApplePaySession.STATUS_FAILURE });
|
|
125
133
|
throw error_1;
|
|
126
|
-
case
|
|
134
|
+
case 7:
|
|
127
135
|
setLoading(false);
|
|
128
136
|
return [2];
|
|
129
137
|
}
|