@newskit-render/my-account 7.20.3 → 7.21.0
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/cjs/Components/Sections/Form/Payment/Zuora/Zuora.d.ts +4 -0
- package/dist/cjs/Components/Sections/Form/Payment/Zuora/Zuora.js +264 -0
- package/dist/cjs/Components/Sections/Form/Payment/Zuora/Zuora.js.map +1 -0
- package/dist/cjs/Components/Sections/Form/Payment/Zuora/index.d.ts +2 -7
- package/dist/cjs/Components/Sections/Form/Payment/Zuora/index.js +5 -234
- package/dist/cjs/Components/Sections/Form/Payment/Zuora/index.js.map +1 -1
- package/dist/cjs/Components/Sections/Form/Payment/Zuora/styled.d.ts +13 -0
- package/dist/cjs/Components/Sections/Form/Payment/Zuora/styled.js +16 -0
- package/dist/cjs/Components/Sections/Form/Payment/Zuora/styled.js.map +1 -0
- package/dist/cjs/Components/Sections/Form/Payment/Zuora/types.d.ts +5 -4
- package/dist/cjs/Components/Sections/Form/Payment/index.d.ts +2 -2
- package/dist/cjs/Components/Sections/Form/Payment/index.js.map +1 -1
- package/dist/cjs/Components/Sections/Form/Phone/Phone.js +5 -5
- package/dist/cjs/Components/Sections/Form/Phone/{styles.js → styled.js} +1 -1
- package/dist/cjs/Components/Sections/Form/Phone/{styles.js.map → styled.js.map} +1 -1
- package/dist/cjs/Components/Templates/PaymentRender.js.map +1 -1
- package/dist/cjs/context/types.d.ts +3 -3
- package/dist/cjs/pages/Payment/Payment.js +2 -2
- package/dist/cjs/pages/Payment/Payment.js.map +1 -1
- package/dist/cjs/pages/types.d.ts +3 -3
- package/dist/cjs/providers/paymentProvider.js +11 -7
- package/dist/cjs/providers/paymentProvider.js.map +1 -1
- package/dist/cjs/providers/types.d.ts +5 -4
- package/dist/cjs/queries/getPaymentPageDetails.js +1 -1
- package/dist/cjs/queries/getPaymentPageDetails.js.map +1 -1
- package/dist/cjs/queries/index.d.ts +8 -9
- package/dist/cjs/queries/index.js +8 -9
- package/dist/cjs/queries/index.js.map +1 -1
- package/dist/esm/Components/Sections/Form/Payment/Zuora/Zuora.d.ts +4 -0
- package/dist/esm/Components/Sections/Form/Payment/Zuora/Zuora.js +234 -0
- package/dist/esm/Components/Sections/Form/Payment/Zuora/Zuora.js.map +1 -0
- package/dist/esm/Components/Sections/Form/Payment/Zuora/index.d.ts +2 -7
- package/dist/esm/Components/Sections/Form/Payment/Zuora/index.js +2 -217
- package/dist/esm/Components/Sections/Form/Payment/Zuora/index.js.map +1 -1
- package/dist/esm/Components/Sections/Form/Payment/Zuora/styled.d.ts +13 -0
- package/dist/esm/Components/Sections/Form/Payment/Zuora/styled.js +13 -0
- package/dist/esm/Components/Sections/Form/Payment/Zuora/styled.js.map +1 -0
- package/dist/esm/Components/Sections/Form/Payment/Zuora/types.d.ts +5 -4
- package/dist/esm/Components/Sections/Form/Payment/index.d.ts +2 -2
- package/dist/esm/Components/Sections/Form/Payment/index.js.map +1 -1
- package/dist/esm/Components/Sections/Form/Phone/Phone.js +1 -1
- package/dist/esm/Components/Sections/Form/Phone/{styles.js → styled.js} +1 -1
- package/dist/esm/Components/Sections/Form/Phone/{styles.js.map → styled.js.map} +1 -1
- package/dist/esm/Components/Templates/PaymentRender.js.map +1 -1
- package/dist/esm/context/types.d.ts +3 -3
- package/dist/esm/helpers/apiHandlerUtils.js +1 -1
- package/dist/esm/helpers/apiHandlerUtils.js.map +1 -1
- package/dist/esm/pages/Payment/Payment.js +2 -2
- package/dist/esm/pages/Payment/Payment.js.map +1 -1
- package/dist/esm/pages/types.d.ts +3 -3
- package/dist/esm/providers/paymentProvider.js +11 -7
- package/dist/esm/providers/paymentProvider.js.map +1 -1
- package/dist/esm/providers/types.d.ts +5 -4
- package/dist/esm/queries/getPaymentPageDetails.js +1 -1
- package/dist/esm/queries/getPaymentPageDetails.js.map +1 -1
- package/dist/esm/queries/index.d.ts +8 -9
- package/dist/esm/queries/index.js +8 -9
- package/dist/esm/queries/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/cjs/queries/updateUser.d.ts +0 -1
- package/dist/cjs/queries/updateUser.js +0 -11
- package/dist/cjs/queries/updateUser.js.map +0 -1
- package/dist/esm/queries/updateUser.d.ts +0 -1
- package/dist/esm/queries/updateUser.js +0 -8
- package/dist/esm/queries/updateUser.js.map +0 -1
- /package/dist/cjs/Components/Sections/Form/Phone/{styles.d.ts → styled.d.ts} +0 -0
- /package/dist/esm/Components/Sections/Form/Phone/{styles.d.ts → styled.d.ts} +0 -0
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
35
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
36
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
37
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
38
|
+
function step(op) {
|
|
39
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
40
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
41
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
42
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
43
|
+
switch (op[0]) {
|
|
44
|
+
case 0: case 1: t = op; break;
|
|
45
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
46
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
47
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
48
|
+
default:
|
|
49
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
50
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
51
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
52
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
53
|
+
if (t[2]) _.ops.pop();
|
|
54
|
+
_.trys.pop(); continue;
|
|
55
|
+
}
|
|
56
|
+
op = body.call(thisArg, _);
|
|
57
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
58
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
62
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
63
|
+
};
|
|
64
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
65
|
+
exports.Zuora = void 0;
|
|
66
|
+
/* istanbul ignore file */
|
|
67
|
+
var context_1 = require("../../../../../context");
|
|
68
|
+
var react_1 = __importStar(require("react"));
|
|
69
|
+
var router_1 = require("next/router");
|
|
70
|
+
var onFormSubmit_1 = __importDefault(require("../../onFormSubmit"));
|
|
71
|
+
var newskit_1 = require("newskit");
|
|
72
|
+
var types_1 = require("../../../../../context/types");
|
|
73
|
+
var paymentUtils_1 = require("../../../../../helpers/paymentUtils");
|
|
74
|
+
var dataUtils_1 = require("../../../../../helpers/dataUtils");
|
|
75
|
+
var styled_1 = require("./styled");
|
|
76
|
+
var addZuoraScript = function (onLoadCallback) {
|
|
77
|
+
var script = document.createElement('script');
|
|
78
|
+
script.src =
|
|
79
|
+
'https://static.zuora.com/Resources/libs/hosted/1.3.1/zuora-min.js';
|
|
80
|
+
script.async = true;
|
|
81
|
+
script.onload = function () { return onLoadCallback(); };
|
|
82
|
+
document.body.appendChild(script);
|
|
83
|
+
};
|
|
84
|
+
var getPrepopulateFields = function (paymentMethod, paymentSupportData) {
|
|
85
|
+
var _a;
|
|
86
|
+
if (!paymentMethod)
|
|
87
|
+
return {};
|
|
88
|
+
if (paymentMethod === 'direct-debit' ||
|
|
89
|
+
(paymentMethod === 'payment' &&
|
|
90
|
+
paymentSupportData.mandateId &&
|
|
91
|
+
((_a = paymentSupportData.mandateId) === null || _a === void 0 ? void 0 : _a.length) > 0)) {
|
|
92
|
+
var today = new Date();
|
|
93
|
+
return {
|
|
94
|
+
mandateId: paymentSupportData.mandateId,
|
|
95
|
+
mandateCreationDateDay: today.getDate(),
|
|
96
|
+
mandateCreationDateMonth: today.getMonth() + 1,
|
|
97
|
+
mandateCreationDateYear: today.getFullYear(),
|
|
98
|
+
mandateUpdateDateDay: today.getDate(),
|
|
99
|
+
mandateUpdateDateMonth: today.getMonth() + 1,
|
|
100
|
+
mandateUpdateDateYear: today.getFullYear(),
|
|
101
|
+
mandateReceivedStatus: 'Yes',
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
// paymentMethod === 'credit-card' || paymentMethod === 'payment' && paymentSupportData.mandateId === null
|
|
105
|
+
return {
|
|
106
|
+
creditCardCountry: 'GBR',
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
var Zuora = function (_a) {
|
|
110
|
+
var _b;
|
|
111
|
+
var paymentMethod = _a.paymentMethod;
|
|
112
|
+
var _c = (0, context_1.useAccountContext)(types_1.ContextName[(0, paymentUtils_1.getPaymentContextName)(paymentMethod)]), cancelButton = _c.cancelButton, paymentPageData = _c.paymentPageData, handleLoading = _c.handleLoading, handleError = _c.handleError, handleSuccess = _c.handleSuccess, baseUrl = _c.baseUrl, errorMessages = _c.errorMessages, genericErrorMessage = _c.genericErrorMessage, zuoraCustomErrorMessages = _c.zuoraCustomErrorMessages;
|
|
113
|
+
if (!paymentPageData) {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
var _d = paymentPageData, pageId = _d.pageId, mandateId = _d.mandateId, signature = _d.signature, key = _d.key, token = _d.token, tenantId = _d.tenantId, timestamp = _d.timestamp, url = _d.url;
|
|
117
|
+
var _e = zuoraCustomErrorMessages, creditCardHolderName = _e.creditCardHolderName, creditCardNumber = _e.creditCardNumber, cardSecurityCode = _e.cardSecurityCode, creditCardExpiration = _e.creditCardExpiration, creditCardPostalCode = _e.creditCardPostalCode, creditCardCountry = _e.creditCardCountry, unknownError = _e.unknownError;
|
|
118
|
+
var router = (0, router_1.useRouter)();
|
|
119
|
+
var iframeContainerRef = (0, react_1.useRef)(null);
|
|
120
|
+
var _f = (0, react_1.useState)(false), isIFrameLoaded = _f[0], setIsIFrameLoaded = _f[1];
|
|
121
|
+
var hasCancelButton = cancelButton && cancelButton.text;
|
|
122
|
+
var hostedPageCallback = function (response) { return __awaiter(void 0, void 0, void 0, function () {
|
|
123
|
+
var refId, signature_1, token_1, mutationObject;
|
|
124
|
+
return __generator(this, function (_a) {
|
|
125
|
+
switch (_a.label) {
|
|
126
|
+
case 0:
|
|
127
|
+
if (!response.success) return [3 /*break*/, 2];
|
|
128
|
+
if (handleLoading)
|
|
129
|
+
handleLoading('pending', errorMessages, genericErrorMessage, undefined, 60000);
|
|
130
|
+
refId = response.refId, signature_1 = response.signature, token_1 = response.token;
|
|
131
|
+
mutationObject = {
|
|
132
|
+
id: pageId,
|
|
133
|
+
tenantId: tenantId,
|
|
134
|
+
timestamp: timestamp,
|
|
135
|
+
token: token_1,
|
|
136
|
+
responseSignature: signature_1,
|
|
137
|
+
refId: refId,
|
|
138
|
+
};
|
|
139
|
+
return [4 /*yield*/, (0, onFormSubmit_1.default)(mutationObject, 'zuoraPaymentMethod', router, function () {
|
|
140
|
+
if (handleError)
|
|
141
|
+
handleError('error', errorMessages, genericErrorMessage);
|
|
142
|
+
}, handleSuccess, "".concat(baseUrl, "/subscription-and-billing"))];
|
|
143
|
+
case 1:
|
|
144
|
+
_a.sent();
|
|
145
|
+
return [3 /*break*/, 3];
|
|
146
|
+
case 2:
|
|
147
|
+
if (!response.success) {
|
|
148
|
+
handleError && handleError('paymentFailure', errorMessages);
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
handleError && handleError('payment', errorMessages);
|
|
152
|
+
}
|
|
153
|
+
_a.label = 3;
|
|
154
|
+
case 3: return [2 /*return*/];
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
}); };
|
|
158
|
+
var errorMessageCallback = function (key, code, message, rawGatewayInfo) {
|
|
159
|
+
var errorMessage = message;
|
|
160
|
+
if (key != 'error') {
|
|
161
|
+
switch (key) {
|
|
162
|
+
case 'creditCardHolderName':
|
|
163
|
+
if (code == '001') {
|
|
164
|
+
errorMessage = creditCardHolderName;
|
|
165
|
+
}
|
|
166
|
+
break;
|
|
167
|
+
case 'creditCardNumber':
|
|
168
|
+
if (code == '001') {
|
|
169
|
+
errorMessage = creditCardNumber.one;
|
|
170
|
+
}
|
|
171
|
+
if (code == '002') {
|
|
172
|
+
errorMessage = creditCardNumber.two;
|
|
173
|
+
}
|
|
174
|
+
if (code == '003') {
|
|
175
|
+
errorMessage = creditCardNumber.three;
|
|
176
|
+
}
|
|
177
|
+
break;
|
|
178
|
+
case 'cardSecurityCode':
|
|
179
|
+
if (code == '001') {
|
|
180
|
+
errorMessage = cardSecurityCode.one;
|
|
181
|
+
}
|
|
182
|
+
if (code == '004') {
|
|
183
|
+
errorMessage = cardSecurityCode.four;
|
|
184
|
+
}
|
|
185
|
+
break;
|
|
186
|
+
case 'creditCardExpirationYear':
|
|
187
|
+
case 'creditCardExpirationMonth':
|
|
188
|
+
if (code == '001') {
|
|
189
|
+
errorMessage = creditCardExpiration;
|
|
190
|
+
}
|
|
191
|
+
break;
|
|
192
|
+
case 'creditCardPostalCode':
|
|
193
|
+
if (code == '001') {
|
|
194
|
+
errorMessage = creditCardPostalCode;
|
|
195
|
+
}
|
|
196
|
+
break;
|
|
197
|
+
case 'creditCardCountry':
|
|
198
|
+
if (code == '001') {
|
|
199
|
+
errorMessage = creditCardCountry;
|
|
200
|
+
}
|
|
201
|
+
break;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
if (code == 'unknown' && rawGatewayInfo) {
|
|
206
|
+
// customize error message based on the rawGatewayInfo
|
|
207
|
+
errorMessage = "".concat(rawGatewayInfo.responseCode, ": ").concat(rawGatewayInfo.responseMessage);
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
errorMessage = unknownError;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
214
|
+
var anyWindow = window;
|
|
215
|
+
anyWindow.Z.sendErrorMessageToHpm(key, errorMessage);
|
|
216
|
+
};
|
|
217
|
+
var loadHostedPage = function () {
|
|
218
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
219
|
+
var anyWindow = window;
|
|
220
|
+
var params = {
|
|
221
|
+
tenantId: tenantId,
|
|
222
|
+
id: pageId,
|
|
223
|
+
token: token,
|
|
224
|
+
signature: signature,
|
|
225
|
+
style: 'inline',
|
|
226
|
+
key: key,
|
|
227
|
+
submitEnabled: 'true',
|
|
228
|
+
url: url,
|
|
229
|
+
};
|
|
230
|
+
var prepopulateFields = getPrepopulateFields(paymentMethod, { mandateId: mandateId });
|
|
231
|
+
anyWindow.Z.renderWithErrorHandler(params, prepopulateFields, hostedPageCallback, errorMessageCallback);
|
|
232
|
+
anyWindow.Z.setEventHandler('onloadCallback', function () {
|
|
233
|
+
setIsIFrameLoaded(true);
|
|
234
|
+
});
|
|
235
|
+
};
|
|
236
|
+
(0, react_1.useEffect)(function () {
|
|
237
|
+
if (typeof window !== 'undefined') {
|
|
238
|
+
addZuoraScript(loadHostedPage);
|
|
239
|
+
}
|
|
240
|
+
}, []);
|
|
241
|
+
return (react_1.default.createElement(newskit_1.GridLayout, { rows: '1fr auto', rowGap: { xs: 'space040', lg: 'space000' }, overrides: {
|
|
242
|
+
marginBlockEnd: {
|
|
243
|
+
xs: 'space070',
|
|
244
|
+
md: 'space080',
|
|
245
|
+
lg: 'space090', //64px
|
|
246
|
+
},
|
|
247
|
+
} },
|
|
248
|
+
react_1.default.createElement(styled_1.StyledIframeContainer, { id: "zuora_payment", ref: iframeContainerRef }),
|
|
249
|
+
hasCancelButton && isIFrameLoaded && (react_1.default.createElement(styled_1.StyledBackButton, { backButton: {
|
|
250
|
+
text: cancelButton === null || cancelButton === void 0 ? void 0 : cancelButton.text,
|
|
251
|
+
href: (0, dataUtils_1.replaceBaseURL)(baseUrl, cancelButton === null || cancelButton === void 0 ? void 0 : cancelButton.href),
|
|
252
|
+
'aria-label': cancelButton === null || cancelButton === void 0 ? void 0 : cancelButton['aria-label'],
|
|
253
|
+
}, backButtonOverrides: {
|
|
254
|
+
asLink: true,
|
|
255
|
+
iconSize: 'iconSize000',
|
|
256
|
+
typographyPreset: 'utilityButton020',
|
|
257
|
+
}, overrides: {
|
|
258
|
+
//In Figma the Cancel button is an actually button with buttonMinimalSecondary preset
|
|
259
|
+
//In code Cancel is a LinkStandalone component which does not support button style presets
|
|
260
|
+
stylePreset: (_b = cancelButton === null || cancelButton === void 0 ? void 0 : cancelButton.overrides) === null || _b === void 0 ? void 0 : _b.stylePreset,
|
|
261
|
+
} }))));
|
|
262
|
+
};
|
|
263
|
+
exports.Zuora = Zuora;
|
|
264
|
+
//# sourceMappingURL=Zuora.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Zuora.js","sourceRoot":"","sources":["../../../../../../../src/Components/Sections/Form/Payment/Zuora/Zuora.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0BAA0B;AAC1B,kDAG+B;AAC/B,6CAA0D;AAE1D,sCAAmD;AACnD,oEAA6C;AAC7C,mCAAoC;AAEpC,sDAA0D;AAC1D,oEAA2E;AAC3E,8DAAiE;AACjE,mCAAkE;AAElE,IAAM,cAAc,GAAG,UAAC,cAA0B;IAChD,IAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;IAC/C,MAAM,CAAC,GA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 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
export declare const addZuoraScript: (onLoadCallback: () => void) => void;
|
|
4
|
-
declare const Zuora: React.FC<{
|
|
5
|
-
paymentMethod: string;
|
|
6
|
-
}>;
|
|
7
|
-
export { ZuoraPaymentData, ZuoraCustomErrorMessages };
|
|
1
|
+
import { Zuora } from './Zuora';
|
|
2
|
+
export * from './types';
|
|
8
3
|
export default Zuora;
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
3
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
|
-
return cooked;
|
|
5
|
-
};
|
|
6
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
3
|
if (k2 === undefined) k2 = k;
|
|
8
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -14,236 +10,11 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
14
10
|
if (k2 === undefined) k2 = k;
|
|
15
11
|
o[k2] = m[k];
|
|
16
12
|
}));
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
}) : function(o, v) {
|
|
20
|
-
o["default"] = v;
|
|
21
|
-
});
|
|
22
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
23
|
-
if (mod && mod.__esModule) return mod;
|
|
24
|
-
var result = {};
|
|
25
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
26
|
-
__setModuleDefault(result, mod);
|
|
27
|
-
return result;
|
|
28
|
-
};
|
|
29
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
30
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
31
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
32
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
33
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
34
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
35
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
39
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
40
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
41
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
42
|
-
function step(op) {
|
|
43
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
44
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
45
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
46
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
47
|
-
switch (op[0]) {
|
|
48
|
-
case 0: case 1: t = op; break;
|
|
49
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
50
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
51
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
52
|
-
default:
|
|
53
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
54
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
55
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
56
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
57
|
-
if (t[2]) _.ops.pop();
|
|
58
|
-
_.trys.pop(); continue;
|
|
59
|
-
}
|
|
60
|
-
op = body.call(thisArg, _);
|
|
61
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
62
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
66
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
67
15
|
};
|
|
68
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
var router_1 = require("next/router");
|
|
73
|
-
var onFormSubmit_1 = __importDefault(require("../../onFormSubmit"));
|
|
74
|
-
var newskit_1 = require("newskit");
|
|
75
|
-
var shared_components_1 = require("@newskit-render/shared-components");
|
|
76
|
-
var types_1 = require("../../../../../context/types");
|
|
77
|
-
var paymentUtils_1 = require("../../../../../helpers/paymentUtils");
|
|
78
|
-
var dataUtils_1 = require("../../../../../helpers/dataUtils");
|
|
79
|
-
var addZuoraScript = function (onLoadCallback) {
|
|
80
|
-
var script = document.createElement('script');
|
|
81
|
-
script.src =
|
|
82
|
-
'https://static.zuora.com/Resources/libs/hosted/1.3.1/zuora-min.js';
|
|
83
|
-
script.async = true;
|
|
84
|
-
script.onload = function () { return onLoadCallback(); };
|
|
85
|
-
document.body.appendChild(script);
|
|
86
|
-
};
|
|
87
|
-
exports.addZuoraScript = addZuoraScript;
|
|
88
|
-
var StyledDiv = newskit_1.styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n iframe#z_hppm_iframe {\n background: none;\n border: none;\n width: 100%;\n }\n"], ["\n iframe#z_hppm_iframe {\n background: none;\n border: none;\n width: 100%;\n }\n"])));
|
|
89
|
-
var StyledBackButton = (0, newskit_1.styled)(shared_components_1.BackButton)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n height: 48px; /* same value hardcoded in the hosted page */\n display: flex;\n justify-content: center;\n align-items: center;\n\n & > a {\n align-self: stretch;\n display: flex;\n justify-content: center;\n flex-basis: 100%;\n text-decoration: none;\n ", "\n border-radius: none;\n }\n\n & > a:hover {\n border-radius: none;\n }\n\n ", " {\n justify-self: end;\n width: 98px; /* same value hardcoded in the hosted page */\n margin-right: calc(98px + 16px);\n margin-top: -48px;\n }\n"], ["\n height: 48px; /* same value hardcoded in the hosted page */\n display: flex;\n justify-content: center;\n align-items: center;\n\n & > a {\n align-self: stretch;\n display: flex;\n justify-content: center;\n flex-basis: 100%;\n text-decoration: none;\n ", "\n border-radius: none;\n }\n\n & > a:hover {\n border-radius: none;\n }\n\n ", " {\n justify-self: end;\n width: 98px; /* same value hardcoded in the hosted page */\n margin-right: calc(98px + 16px);\n margin-top: -48px;\n }\n"])), function (_a) {
|
|
90
|
-
var overrides = _a.overrides;
|
|
91
|
-
return (overrides === null || overrides === void 0 ? void 0 : overrides.stylePreset) && (0, newskit_1.getStylePresetFromTheme)(overrides === null || overrides === void 0 ? void 0 : overrides.stylePreset);
|
|
92
|
-
}, (0, newskit_1.getMediaQueryFromTheme)('lg'));
|
|
93
|
-
var Zuora = function (_a) {
|
|
94
|
-
var _b;
|
|
95
|
-
var paymentMethod = _a.paymentMethod;
|
|
96
|
-
var _c = (0, context_1.useAccountContext)(types_1.ContextName[(0, paymentUtils_1.getPaymentContextName)(paymentMethod)]), cancelButton = _c.cancelButton, paymentData = _c.paymentData, handleLoading = _c.handleLoading, handleError = _c.handleError, handleSuccess = _c.handleSuccess, baseUrl = _c.baseUrl, errorMessages = _c.errorMessages, genericErrorMessage = _c.genericErrorMessage, zuoraCustomErrorMessages = _c.zuoraCustomErrorMessages;
|
|
97
|
-
if (!paymentData) {
|
|
98
|
-
return null;
|
|
99
|
-
}
|
|
100
|
-
var _d = paymentData, signature = _d.signature, token = _d.token, tenantId = _d.tenantId, key = _d.key, pageId = _d.pageId, url = _d.url, timestamp = _d.timestamp;
|
|
101
|
-
var _e = zuoraCustomErrorMessages, creditCardHolderName = _e.creditCardHolderName, creditCardNumber = _e.creditCardNumber, cardSecurityCode = _e.cardSecurityCode, creditCardExpiration = _e.creditCardExpiration, creditCardPostalCode = _e.creditCardPostalCode, creditCardCountry = _e.creditCardCountry, unknownError = _e.unknownError;
|
|
102
|
-
var router = (0, router_1.useRouter)();
|
|
103
|
-
var iframeContainerRef = (0, react_1.useRef)(null);
|
|
104
|
-
var _f = (0, react_1.useState)(false), isIFrameLoaded = _f[0], setIsIFrameLoaded = _f[1];
|
|
105
|
-
var hasCancelButton = cancelButton && cancelButton.text;
|
|
106
|
-
var hostedPageCallback = function (response) { return __awaiter(void 0, void 0, void 0, function () {
|
|
107
|
-
var refId, signature_1, token_1, mutationObject;
|
|
108
|
-
return __generator(this, function (_a) {
|
|
109
|
-
switch (_a.label) {
|
|
110
|
-
case 0:
|
|
111
|
-
if (!response.success) return [3 /*break*/, 2];
|
|
112
|
-
if (handleLoading)
|
|
113
|
-
handleLoading('pending', errorMessages, genericErrorMessage, undefined, 60000);
|
|
114
|
-
refId = response.refId, signature_1 = response.signature, token_1 = response.token;
|
|
115
|
-
mutationObject = {
|
|
116
|
-
refId: refId,
|
|
117
|
-
responseSignature: signature_1,
|
|
118
|
-
token: token_1,
|
|
119
|
-
id: pageId,
|
|
120
|
-
timestamp: timestamp,
|
|
121
|
-
tenantId: tenantId,
|
|
122
|
-
};
|
|
123
|
-
return [4 /*yield*/, (0, onFormSubmit_1.default)(mutationObject, 'zuoraPaymentMethod', router, function () {
|
|
124
|
-
if (handleError)
|
|
125
|
-
handleError('error', errorMessages, genericErrorMessage);
|
|
126
|
-
}, handleSuccess, "".concat(baseUrl, "/subscription-and-billing"))];
|
|
127
|
-
case 1:
|
|
128
|
-
_a.sent();
|
|
129
|
-
return [3 /*break*/, 3];
|
|
130
|
-
case 2:
|
|
131
|
-
if (!response.success) {
|
|
132
|
-
handleError && handleError('paymentFailure', errorMessages);
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
handleError && handleError('payment', errorMessages);
|
|
136
|
-
}
|
|
137
|
-
_a.label = 3;
|
|
138
|
-
case 3: return [2 /*return*/];
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
}); };
|
|
142
|
-
var errorMessageCallback = function (key, code, message, rawGatewayInfo) {
|
|
143
|
-
var errorMessage = message;
|
|
144
|
-
if (key != 'error') {
|
|
145
|
-
switch (key) {
|
|
146
|
-
case 'creditCardHolderName':
|
|
147
|
-
if (code == '001') {
|
|
148
|
-
errorMessage = creditCardHolderName;
|
|
149
|
-
}
|
|
150
|
-
break;
|
|
151
|
-
case 'creditCardNumber':
|
|
152
|
-
if (code == '001') {
|
|
153
|
-
errorMessage = creditCardNumber.one;
|
|
154
|
-
}
|
|
155
|
-
if (code == '002') {
|
|
156
|
-
errorMessage = creditCardNumber.two;
|
|
157
|
-
}
|
|
158
|
-
if (code == '003') {
|
|
159
|
-
errorMessage = creditCardNumber.three;
|
|
160
|
-
}
|
|
161
|
-
break;
|
|
162
|
-
case 'cardSecurityCode':
|
|
163
|
-
if (code == '001') {
|
|
164
|
-
errorMessage = cardSecurityCode.one;
|
|
165
|
-
}
|
|
166
|
-
if (code == '004') {
|
|
167
|
-
errorMessage = cardSecurityCode.four;
|
|
168
|
-
}
|
|
169
|
-
break;
|
|
170
|
-
case 'creditCardExpirationYear':
|
|
171
|
-
case 'creditCardExpirationMonth':
|
|
172
|
-
if (code == '001') {
|
|
173
|
-
errorMessage = creditCardExpiration;
|
|
174
|
-
}
|
|
175
|
-
break;
|
|
176
|
-
case 'creditCardPostalCode':
|
|
177
|
-
if (code == '001') {
|
|
178
|
-
errorMessage = creditCardPostalCode;
|
|
179
|
-
}
|
|
180
|
-
break;
|
|
181
|
-
case 'creditCardCountry':
|
|
182
|
-
if (code == '001') {
|
|
183
|
-
errorMessage = creditCardCountry;
|
|
184
|
-
}
|
|
185
|
-
break;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
else {
|
|
189
|
-
if (code == 'unknown' && rawGatewayInfo) {
|
|
190
|
-
// customize error message based on the rawGatewayInfo
|
|
191
|
-
errorMessage = "".concat(rawGatewayInfo.responseCode, ": ").concat(rawGatewayInfo.responseMessage);
|
|
192
|
-
}
|
|
193
|
-
else {
|
|
194
|
-
errorMessage = unknownError;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
198
|
-
var anyWindow = window;
|
|
199
|
-
anyWindow.Z.sendErrorMessageToHpm(key, errorMessage);
|
|
200
|
-
};
|
|
201
|
-
var loadHostedPage = function () {
|
|
202
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
203
|
-
var anyWindow = window;
|
|
204
|
-
anyWindow.Z.renderWithErrorHandler({
|
|
205
|
-
tenantId: tenantId,
|
|
206
|
-
token: token,
|
|
207
|
-
signature: signature,
|
|
208
|
-
key: key,
|
|
209
|
-
style: 'inline',
|
|
210
|
-
submitEnabled: 'true',
|
|
211
|
-
url: url,
|
|
212
|
-
id: pageId,
|
|
213
|
-
}, {
|
|
214
|
-
creditCardCountry: 'GBR',
|
|
215
|
-
}, hostedPageCallback, errorMessageCallback);
|
|
216
|
-
anyWindow.Z.setEventHandler('onloadCallback', function () {
|
|
217
|
-
setIsIFrameLoaded(true);
|
|
218
|
-
});
|
|
219
|
-
};
|
|
220
|
-
(0, react_1.useEffect)(function () {
|
|
221
|
-
if (typeof window !== 'undefined') {
|
|
222
|
-
(0, exports.addZuoraScript)(loadHostedPage);
|
|
223
|
-
}
|
|
224
|
-
}, []);
|
|
225
|
-
return (react_1.default.createElement(newskit_1.GridLayout, { rows: '1fr auto', rowGap: { xs: 'space040', lg: 'space000' }, overrides: {
|
|
226
|
-
marginBlockEnd: {
|
|
227
|
-
xs: 'space070',
|
|
228
|
-
md: 'space080',
|
|
229
|
-
lg: 'space090', //64px
|
|
230
|
-
},
|
|
231
|
-
} },
|
|
232
|
-
react_1.default.createElement(StyledDiv, { id: "zuora_payment", ref: iframeContainerRef }),
|
|
233
|
-
hasCancelButton && isIFrameLoaded && (react_1.default.createElement(StyledBackButton, { backButton: {
|
|
234
|
-
text: cancelButton === null || cancelButton === void 0 ? void 0 : cancelButton.text,
|
|
235
|
-
href: (0, dataUtils_1.replaceBaseURL)(baseUrl, cancelButton === null || cancelButton === void 0 ? void 0 : cancelButton.href),
|
|
236
|
-
'aria-label': cancelButton === null || cancelButton === void 0 ? void 0 : cancelButton['aria-label'],
|
|
237
|
-
}, backButtonOverrides: {
|
|
238
|
-
asLink: true,
|
|
239
|
-
iconSize: 'iconSize000',
|
|
240
|
-
typographyPreset: 'utilityButton020',
|
|
241
|
-
}, overrides: {
|
|
242
|
-
//In Figma the Cancel button is an actually button with buttonMinimalSecondary preset
|
|
243
|
-
//In code Cancel is a LinkStandalone component which does not support button style presets
|
|
244
|
-
stylePreset: (_b = cancelButton === null || cancelButton === void 0 ? void 0 : cancelButton.overrides) === null || _b === void 0 ? void 0 : _b.stylePreset,
|
|
245
|
-
} }))));
|
|
246
|
-
};
|
|
247
|
-
exports.default = Zuora;
|
|
248
|
-
var templateObject_1, templateObject_2;
|
|
17
|
+
var Zuora_1 = require("./Zuora");
|
|
18
|
+
__exportStar(require("./types"), exports);
|
|
19
|
+
exports.default = Zuora_1.Zuora;
|
|
249
20
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../src/Components/Sections/Form/Payment/Zuora/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../src/Components/Sections/Form/Payment/Zuora/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iCAA+B;AAE/B,0CAAuB;AACvB,kBAAe,aAAK,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { MQ } from 'newskit';
|
|
3
|
+
export declare const StyledIframeContainer: import("@emotion/styled").StyledComponent<{
|
|
4
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
5
|
+
as?: import("react").ElementType<any> | undefined;
|
|
6
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
7
|
+
export declare const StyledBackButton: import("@emotion/styled").StyledComponent<import("@newskit-render/shared-components").BackButtonProps & {
|
|
8
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
9
|
+
} & {
|
|
10
|
+
overrides?: {
|
|
11
|
+
stylePreset?: MQ<string> | undefined;
|
|
12
|
+
} | undefined;
|
|
13
|
+
}, {}, {}>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
3
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
|
+
return cooked;
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.StyledBackButton = exports.StyledIframeContainer = void 0;
|
|
8
|
+
var newskit_1 = require("newskit");
|
|
9
|
+
var shared_components_1 = require("@newskit-render/shared-components");
|
|
10
|
+
exports.StyledIframeContainer = newskit_1.styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n iframe#z_hppm_iframe {\n background: none;\n border: none;\n width: 100%;\n }\n"], ["\n iframe#z_hppm_iframe {\n background: none;\n border: none;\n width: 100%;\n }\n"])));
|
|
11
|
+
exports.StyledBackButton = (0, newskit_1.styled)(shared_components_1.BackButton)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n height: 48px; /* same value hardcoded in the hosted page */\n display: flex;\n justify-content: center;\n align-items: center;\n\n & > a {\n align-self: stretch;\n display: flex;\n justify-content: center;\n flex-basis: 100%;\n text-decoration: none;\n ", "\n border-radius: none;\n }\n\n & > a:hover {\n border-radius: none;\n }\n\n ", " {\n justify-self: end;\n width: 98px; /* same value hardcoded in the hosted page */\n margin-right: calc(98px + 16px);\n margin-top: -48px;\n }\n"], ["\n height: 48px; /* same value hardcoded in the hosted page */\n display: flex;\n justify-content: center;\n align-items: center;\n\n & > a {\n align-self: stretch;\n display: flex;\n justify-content: center;\n flex-basis: 100%;\n text-decoration: none;\n ", "\n border-radius: none;\n }\n\n & > a:hover {\n border-radius: none;\n }\n\n ", " {\n justify-self: end;\n width: 98px; /* same value hardcoded in the hosted page */\n margin-right: calc(98px + 16px);\n margin-top: -48px;\n }\n"])), function (_a) {
|
|
12
|
+
var overrides = _a.overrides;
|
|
13
|
+
return (overrides === null || overrides === void 0 ? void 0 : overrides.stylePreset) && (0, newskit_1.getStylePresetFromTheme)(overrides === null || overrides === void 0 ? void 0 : overrides.stylePreset);
|
|
14
|
+
}, (0, newskit_1.getMediaQueryFromTheme)('lg'));
|
|
15
|
+
var templateObject_1, templateObject_2;
|
|
16
|
+
//# sourceMappingURL=styled.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styled.js","sourceRoot":"","sources":["../../../../../../../src/Components/Sections/Form/Payment/Zuora/styled.tsx"],"names":[],"mappings":";;;;;;;AAAA,mCAKgB;AAChB,uEAA8D;AAEjD,QAAA,qBAAqB,GAAG,gBAAM,CAAC,GAAG,kKAAA,+FAM9C,KAAA;AAEY,QAAA,gBAAgB,GAAG,IAAA,gBAAM,EAAC,8BAAU,CAAC,0lBAEhD,yRAYI,EACyE,yFAQ3E,EAA4B,iKAM/B,KAfK,UAAC,EAAa;QAAX,SAAS,eAAA;IACZ,OAAA,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,WAAW,KAAI,IAAA,iCAAuB,EAAC,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,WAAW,CAAC;AAAzE,CAAyE,EAQ3E,IAAA,gCAAsB,EAAC,IAAI,CAAC,EAM/B"}
|
|
@@ -14,12 +14,13 @@ export interface ZuoraCustomErrorMessages {
|
|
|
14
14
|
creditCardCountry: string;
|
|
15
15
|
unknownError: string;
|
|
16
16
|
}
|
|
17
|
-
export interface
|
|
17
|
+
export interface ZuoraPaymentPageData {
|
|
18
|
+
pageId: string;
|
|
19
|
+
mandateId: string | null;
|
|
18
20
|
signature: string;
|
|
21
|
+
key: string;
|
|
19
22
|
token: string;
|
|
20
23
|
tenantId: number;
|
|
21
|
-
key: string;
|
|
22
|
-
pageId: string;
|
|
23
|
-
url: string;
|
|
24
24
|
timestamp: number;
|
|
25
|
+
url: string;
|
|
25
26
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import Stripe from './Stripe';
|
|
2
|
-
import Zuora, {
|
|
2
|
+
import Zuora, { ZuoraPaymentPageData, ZuoraCustomErrorMessages } from './Zuora';
|
|
3
3
|
import { PaymentProvider } from './types';
|
|
4
|
-
export { Stripe, Zuora,
|
|
4
|
+
export { Stripe, Zuora, ZuoraPaymentPageData, ZuoraCustomErrorMessages, PaymentProvider, };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/Components/Sections/Form/Payment/index.tsx"],"names":[],"mappings":";;;;;;AAAA,oDAA6B;AAK3B,iBALK,gBAAM,CAKL;AAJR,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/Components/Sections/Form/Payment/index.tsx"],"names":[],"mappings":";;;;;;AAAA,oDAA6B;AAK3B,iBALK,gBAAM,CAKL;AAJR,kDAA+E;AAK7E,gBALK,eAAK,CAKL;AAJP,iCAAyC;AAOvC,gGAPO,uBAAe,OAOP"}
|