@tap-payments/apple-pay-button 0.0.3-test → 0.0.4-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/hooks/useApplePay.js +15 -9
- package/package.json +1 -1
|
@@ -105,6 +105,7 @@ export var useApplePay = function (_a) {
|
|
|
105
105
|
case 0:
|
|
106
106
|
console.info('Creating merchant session and validating merchant session');
|
|
107
107
|
console.info('onvalidatemerchant event', event);
|
|
108
|
+
setLoading(true);
|
|
108
109
|
_a.label = 1;
|
|
109
110
|
case 1:
|
|
110
111
|
_a.trys.push([1, 3, , 4]);
|
|
@@ -119,9 +120,11 @@ export var useApplePay = function (_a) {
|
|
|
119
120
|
case 3:
|
|
120
121
|
error_1 = _a.sent();
|
|
121
122
|
console.error('error in onvalidatemerchant', error_1);
|
|
122
|
-
session_1.completePayment({ status:
|
|
123
|
+
session_1.completePayment({ status: ApplePaySession.STATUS_FAILURE });
|
|
123
124
|
throw error_1;
|
|
124
|
-
case 4:
|
|
125
|
+
case 4:
|
|
126
|
+
setLoading(false);
|
|
127
|
+
return [2];
|
|
125
128
|
}
|
|
126
129
|
});
|
|
127
130
|
}); };
|
|
@@ -130,6 +133,7 @@ export var useApplePay = function (_a) {
|
|
|
130
133
|
return __generator(this, function (_b) {
|
|
131
134
|
switch (_b.label) {
|
|
132
135
|
case 0:
|
|
136
|
+
setLoading(true);
|
|
133
137
|
console.info('onpaymentauthorized event', event);
|
|
134
138
|
_b.label = 1;
|
|
135
139
|
case 1:
|
|
@@ -143,7 +147,7 @@ export var useApplePay = function (_a) {
|
|
|
143
147
|
case 2: return [4, (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(event.payment.token.paymentData))];
|
|
144
148
|
case 3:
|
|
145
149
|
_b.sent();
|
|
146
|
-
session_1.completePayment({ status:
|
|
150
|
+
session_1.completePayment({ status: ApplePaySession.STATUS_SUCCESS });
|
|
147
151
|
return [3, 8];
|
|
148
152
|
case 4: return [4, appService.tapTokenization(event.payment.token.paymentData, profileData.merchant)];
|
|
149
153
|
case 5:
|
|
@@ -151,25 +155,27 @@ export var useApplePay = function (_a) {
|
|
|
151
155
|
return [4, (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(data))];
|
|
152
156
|
case 6:
|
|
153
157
|
_b.sent();
|
|
154
|
-
session_1.completePayment({ status:
|
|
158
|
+
session_1.completePayment({ status: ApplePaySession.STATUS_SUCCESS });
|
|
155
159
|
return [3, 8];
|
|
156
160
|
case 7:
|
|
157
161
|
console.error('We only support AppleToken and TapToken for now');
|
|
158
162
|
console.info('Completing payment with status: STATUS_FAILURE');
|
|
159
|
-
session_1.completePayment({ status:
|
|
163
|
+
session_1.completePayment({ status: ApplePaySession.STATUS_FAILURE });
|
|
160
164
|
_b.label = 8;
|
|
161
165
|
case 8: return [3, 10];
|
|
162
166
|
case 9:
|
|
163
167
|
error_2 = _b.sent();
|
|
164
168
|
console.error('error in onpaymentauthorized', error_2);
|
|
165
|
-
session_1.completePayment({ status:
|
|
169
|
+
session_1.completePayment({ status: ApplePaySession.STATUS_FAILURE });
|
|
166
170
|
throw error_2;
|
|
167
|
-
case 10:
|
|
171
|
+
case 10:
|
|
172
|
+
setLoading(false);
|
|
173
|
+
return [2];
|
|
168
174
|
}
|
|
169
175
|
});
|
|
170
176
|
}); };
|
|
171
|
-
session_1.oncancel = function () {
|
|
172
|
-
console.info('oncancel event');
|
|
177
|
+
session_1.oncancel = function (event) {
|
|
178
|
+
console.info('oncancel event', event);
|
|
173
179
|
if (onCancel)
|
|
174
180
|
onCancel();
|
|
175
181
|
};
|