@tap-payments/apple-pay-button 0.0.14-test → 0.0.16-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
package/build/constants/index.js
CHANGED
|
@@ -17,7 +17,7 @@ import { useApplePay } from '../../hooks/useApplePay';
|
|
|
17
17
|
import { ButtonStyle, ButtonType, Locale, 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, onClick = _a.onClick, metaData = _a.metaData, _b = _a.scope, scope = _b === void 0 ? Scope.TapToken : _b, _c = _a.buttonStyle, buttonStyle = _c === void 0 ? ButtonStyle.WhiteOutline : _c, _d = _a.type, type = _d === void 0 ? ButtonType.PLAIN : _d, _e = _a.locale, locale = _e === void 0 ? Locale.EN : _e;
|
|
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, onClick = _a.onClick, metaData = _a.metaData, _b = _a.scope, scope = _b === void 0 ? Scope.TapToken : _b, _c = _a.buttonStyle, buttonStyle = _c === void 0 ? ButtonStyle.WhiteOutline : _c, _d = _a.type, type = _d === void 0 ? ButtonType.PLAIN : _d, _e = _a.locale, locale = _e === void 0 ? Locale.EN : _e, debug = _a.debug;
|
|
21
21
|
var _f = useApplePay({
|
|
22
22
|
publicKey: publicKey,
|
|
23
23
|
merchant: merchant,
|
|
@@ -28,17 +28,29 @@ var ApplePay = React.memo(function (_a) {
|
|
|
28
28
|
onSuccess: onSuccess,
|
|
29
29
|
onCancel: onCancel,
|
|
30
30
|
scope: scope,
|
|
31
|
-
metaData: metaData
|
|
31
|
+
metaData: metaData,
|
|
32
|
+
debug: debug
|
|
32
33
|
}), loading = _f.loading, onApplePayButtonClicked = _f.onApplePayButtonClicked, disabled = _f.disabled;
|
|
33
|
-
var ref = React.useRef();
|
|
34
34
|
React.useEffect(function () {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
if (debug) {
|
|
36
|
+
console.log('ApplePayButtonProps', {
|
|
37
|
+
publicKey: publicKey,
|
|
38
|
+
merchant: merchant,
|
|
39
|
+
transaction: transaction,
|
|
40
|
+
billingContact: billingContact,
|
|
41
|
+
supportedNetworks: supportedNetworks,
|
|
42
|
+
metaData: metaData,
|
|
43
|
+
scope: scope,
|
|
44
|
+
buttonStyle: buttonStyle,
|
|
45
|
+
type: type,
|
|
46
|
+
locale: locale,
|
|
47
|
+
debug: debug
|
|
48
|
+
});
|
|
38
49
|
}
|
|
39
|
-
});
|
|
40
|
-
return (_jsx("button", { className: "button-applepay-tap
|
|
41
|
-
'-apple-pay-button-type': type
|
|
50
|
+
}, []);
|
|
51
|
+
return (_jsx("button", { className: "button-applepay-tap", style: {
|
|
52
|
+
'-apple-pay-button-type': type,
|
|
53
|
+
'-apple-pay-button-style': buttonStyle
|
|
42
54
|
}, onClick: function () {
|
|
43
55
|
onApplePayButtonClicked();
|
|
44
56
|
onClick === null || onClick === void 0 ? void 0 : onClick();
|
|
@@ -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, metaData }: UseApplePayProps) => UseApplePayReturnProps;
|
|
8
|
+
export declare const useApplePay: ({ publicKey, merchant, transaction, billingContact, onCancel, onError, onSuccess, scope, supportedNetworks, metaData, debug }: 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, metaData = _a.metaData;
|
|
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, metaData = _a.metaData, debug = _a.debug;
|
|
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];
|
|
@@ -59,6 +59,8 @@ export var useApplePay = function (_a) {
|
|
|
59
59
|
appService
|
|
60
60
|
.init(publicKey, merchant.id)
|
|
61
61
|
.then(function (data) {
|
|
62
|
+
if (debug)
|
|
63
|
+
console.log('Merchant response: ', data);
|
|
62
64
|
setProfile(data);
|
|
63
65
|
})
|
|
64
66
|
.catch(function (error) {
|
|
@@ -102,30 +104,38 @@ export var useApplePay = function (_a) {
|
|
|
102
104
|
supportedNetworks: cardBrands,
|
|
103
105
|
name: profileData.merchant.name
|
|
104
106
|
});
|
|
105
|
-
|
|
107
|
+
if (debug) {
|
|
108
|
+
console.info("Creating ApplePaySession with version: ".concat(ApplePayVersion, " and request: ").concat(JSON.stringify(request)));
|
|
109
|
+
}
|
|
106
110
|
session_1 = new ApplePaySession(ApplePayVersion, request);
|
|
107
111
|
session_1.onvalidatemerchant = function (event) { return __awaiter(void 0, void 0, void 0, function () {
|
|
108
112
|
var merchantSession, error_1;
|
|
109
113
|
return __generator(this, function (_a) {
|
|
110
114
|
switch (_a.label) {
|
|
111
115
|
case 0:
|
|
112
|
-
|
|
113
|
-
|
|
116
|
+
if (debug) {
|
|
117
|
+
console.info('Creating merchant session and validating merchant session');
|
|
118
|
+
console.info('onvalidatemerchant event', event);
|
|
119
|
+
}
|
|
114
120
|
setLoading(true);
|
|
115
121
|
_a.label = 1;
|
|
116
122
|
case 1:
|
|
117
123
|
_a.trys.push([1, 3, , 4]);
|
|
118
|
-
|
|
124
|
+
if (debug) {
|
|
125
|
+
console.info("creating merchant session for merchantData: ".concat(JSON.stringify(profileData.merchant), " and validationURL: ").concat(event.validationURL, " and merchant.domain: ").concat(merchant.domain));
|
|
126
|
+
}
|
|
119
127
|
return [4, appService.appleSession(profileData.merchant, event.validationURL, merchant.domain)];
|
|
120
128
|
case 2:
|
|
121
129
|
merchantSession = (_a.sent()).body;
|
|
122
|
-
|
|
130
|
+
if (debug)
|
|
131
|
+
console.info('merchantSession', merchantSession);
|
|
123
132
|
session_1.completeMerchantValidation(merchantSession);
|
|
124
133
|
console.info('merchantSession completed successfully!');
|
|
125
134
|
return [3, 4];
|
|
126
135
|
case 3:
|
|
127
136
|
error_1 = _a.sent();
|
|
128
|
-
|
|
137
|
+
if (debug)
|
|
138
|
+
console.error('error in onvalidatemerchant', error_1);
|
|
129
139
|
session_1.completePayment({ status: ApplePaySession.STATUS_FAILURE });
|
|
130
140
|
throw error_1;
|
|
131
141
|
case 4:
|
|
@@ -140,7 +150,8 @@ export var useApplePay = function (_a) {
|
|
|
140
150
|
switch (_b.label) {
|
|
141
151
|
case 0:
|
|
142
152
|
setLoading(true);
|
|
143
|
-
|
|
153
|
+
if (debug)
|
|
154
|
+
console.info('onpaymentauthorized event', event);
|
|
144
155
|
_b.label = 1;
|
|
145
156
|
case 1:
|
|
146
157
|
_b.trys.push([1, 9, , 10]);
|
|
@@ -171,7 +182,8 @@ export var useApplePay = function (_a) {
|
|
|
171
182
|
case 8: return [3, 10];
|
|
172
183
|
case 9:
|
|
173
184
|
error_2 = _b.sent();
|
|
174
|
-
|
|
185
|
+
if (debug)
|
|
186
|
+
console.error('error in onpaymentauthorized', error_2);
|
|
175
187
|
session_1.completePayment({ status: ApplePaySession.STATUS_FAILURE });
|
|
176
188
|
throw error_2;
|
|
177
189
|
case 10:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tap-payments/apple-pay-button",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16-test",
|
|
4
4
|
"description": "Apple Pay Button React Component",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"module": "build/index.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"copy:files": "copyfiles -u 1 src/**/*.css build/",
|
|
21
21
|
"tsc:alias": "tsc-alias -p tsconfig.json",
|
|
22
22
|
"ts:build": "rm -rf build && tsc && yarn tsc:alias && yarn copy:files",
|
|
23
|
-
"push": "npm publish --access public"
|
|
23
|
+
"push": "npm publish --access public --tag test"
|
|
24
24
|
},
|
|
25
25
|
"keywords": [],
|
|
26
26
|
"author": {
|