@fat-zebra/sdk 1.5.3-beta.3 → 1.5.5-beta.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/README.dev.md +22 -0
- package/deploy-menu.png +0 -0
- package/dist/applepay/applepay.d.ts +22 -7
- package/dist/applepay/applepay.js +89 -21
- package/dist/applepay/applepaymanager.d.ts +28 -0
- package/dist/applepay/applepaymanager.js +115 -0
- package/dist/applepay/clients/apple-pay-client.d.ts +9 -5
- package/dist/applepay/clients/apple-pay-client.js +9 -3
- package/dist/applepay/clients/paynow-client.d.ts +4 -2
- package/dist/applepay/clients/paynow-client.js +2 -7
- package/dist/applepay/types.d.ts +15 -0
- package/dist/applepay/types.js +1 -0
- package/dist/click_to_pay/index.js +12 -0
- package/dist/click_to_pay/types.d.ts +11 -2
- package/dist/local/fatzebra.js +585 -11
- package/dist/local/fatzebra.js.map +1 -1
- package/dist/main.d.ts +2 -0
- package/dist/main.js +24 -2
- package/dist/production/fatzebra.css +91 -0
- package/dist/production/fatzebra.js +2 -0
- package/dist/production/fatzebra.js.LICENSE.txt +1 -0
- package/dist/react/ApplePayButton.d.ts +8 -0
- package/dist/react/ApplePayButton.js +18 -0
- package/dist/react/applePayUrl.js +0 -16
- package/dist/react/index.d.ts +2 -1
- package/dist/react/index.js +2 -1
- package/dist/react/useFatZebra.js +8 -57
- package/dist/react/useMessage.d.ts +10 -0
- package/dist/react/useMessage.js +70 -0
- package/dist/sandbox/fatzebra.css +91 -0
- package/dist/sandbox/fatzebra.js +2 -0
- package/dist/sandbox/fatzebra.js.LICENSE.txt +1 -0
- package/dist/scripts/release-package.js +324 -0
- package/dist/scripts/release-package.js.map +1 -0
- package/dist/shared/env.development.d.ts +3 -3
- package/dist/shared/env.development.js +3 -3
- package/dist/shared/envs/local.d.ts +3 -3
- package/dist/shared/envs/local.js +3 -3
- package/dist/shared/post-message-client.d.ts +2 -0
- package/dist/shared/post-message-client.js +1 -1
- package/dist/shared/types.d.ts +14 -2
- package/dist/shared/types.js +2 -0
- package/dist/src/applepay/applepay.js +198 -0
- package/dist/src/applepay/applepay.js.map +1 -0
- package/dist/src/applepay/applepaymanager.js +279 -0
- package/dist/src/applepay/applepaymanager.js.map +1 -0
- package/dist/src/applepay/clients/apple-pay-client.js +66 -0
- package/dist/src/applepay/clients/apple-pay-client.js.map +1 -0
- package/dist/src/applepay/clients/paynow-client.js +96 -0
- package/dist/src/applepay/clients/paynow-client.js.map +1 -0
- package/dist/src/applepay/index.js +6 -0
- package/dist/src/applepay/index.js.map +1 -0
- package/dist/src/click_to_pay/clicktopay.test.js +131 -0
- package/dist/src/click_to_pay/clicktopay.test.js.map +1 -0
- package/dist/src/click_to_pay/index.js +135 -0
- package/dist/src/click_to_pay/index.js.map +1 -0
- package/dist/src/click_to_pay/types.js +3 -0
- package/dist/src/click_to_pay/types.js.map +1 -0
- package/dist/src/hpp/hpp.js +230 -0
- package/dist/src/hpp/hpp.js.map +1 -0
- package/dist/src/hpp/hpp.test.js +137 -0
- package/dist/src/hpp/hpp.test.js.map +1 -0
- package/dist/src/hpp/index.js +6 -0
- package/dist/src/hpp/index.js.map +1 -0
- package/dist/src/index.js +15 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/main.js +229 -0
- package/dist/src/main.js.map +1 -0
- package/dist/src/main.test.js +236 -0
- package/dist/src/main.test.js.map +1 -0
- package/dist/src/react/ApplePayButton.js +56 -0
- package/dist/src/react/ApplePayButton.js.map +1 -0
- package/dist/src/react/VerifyCard.js +29 -0
- package/dist/src/react/VerifyCard.js.map +1 -0
- package/dist/src/react/VerifyExistingCard.js +30 -0
- package/dist/src/react/VerifyExistingCard.js.map +1 -0
- package/dist/src/react/applePayUrl.js +46 -0
- package/dist/src/react/applePayUrl.js.map +1 -0
- package/dist/src/react/applePayUrl.test.js +57 -0
- package/dist/src/react/applePayUrl.test.js.map +1 -0
- package/dist/src/react/index.js +13 -0
- package/dist/src/react/index.js.map +1 -0
- package/dist/src/react/paymentUrl.js +60 -0
- package/dist/src/react/paymentUrl.js.map +1 -0
- package/dist/src/react/paymentUrl.test.js +88 -0
- package/dist/src/react/paymentUrl.test.js.map +1 -0
- package/dist/src/react/submitForm.js +13 -0
- package/dist/src/react/submitForm.js.map +1 -0
- package/dist/src/react/useFatZebra.js +70 -0
- package/dist/src/react/useFatZebra.js.map +1 -0
- package/dist/src/react/useMessage.js +140 -0
- package/dist/src/react/useMessage.js.map +1 -0
- package/dist/src/react/useMessage.test.js +222 -0
- package/dist/src/react/useMessage.test.js.map +1 -0
- package/dist/src/react/verifyUrl.js +49 -0
- package/dist/src/react/verifyUrl.js.map +1 -0
- package/dist/src/sca/cardinal.js +145 -0
- package/dist/src/sca/cardinal.js.map +1 -0
- package/dist/src/sca/cardinal.test.js +77 -0
- package/dist/src/sca/cardinal.test.js.map +1 -0
- package/dist/src/sca/eci-mappings.js +63 -0
- package/dist/src/sca/eci-mappings.js.map +1 -0
- package/dist/src/sca/eci-mappings.test.js +31 -0
- package/dist/src/sca/eci-mappings.test.js.map +1 -0
- package/dist/src/sca/index.js +382 -0
- package/dist/src/sca/index.js.map +1 -0
- package/dist/src/sca/index.test.js +624 -0
- package/dist/src/sca/index.test.js.map +1 -0
- package/dist/src/sca/scenarios/enrollment.js +161 -0
- package/dist/src/sca/scenarios/enrollment.js.map +1 -0
- package/dist/src/sca/scenarios/index.js +8 -0
- package/dist/src/sca/scenarios/index.js.map +1 -0
- package/dist/src/sca/scenarios/validation.js +139 -0
- package/dist/src/sca/scenarios/validation.js.map +1 -0
- package/dist/src/sca/types.js +57 -0
- package/dist/src/sca/types.js.map +1 -0
- package/dist/src/shared/api-gateway-client.js +148 -0
- package/dist/src/shared/api-gateway-client.js.map +1 -0
- package/dist/src/shared/bridge-client.js +24 -0
- package/dist/src/shared/bridge-client.js.map +1 -0
- package/dist/src/shared/constants.js +19 -0
- package/dist/src/shared/constants.js.map +1 -0
- package/dist/src/shared/env.development.js +12 -0
- package/dist/src/shared/env.development.js.map +1 -0
- package/dist/src/shared/env.js +50 -0
- package/dist/src/shared/env.js.map +1 -0
- package/dist/src/shared/envs/local.js +12 -0
- package/dist/src/shared/envs/local.js.map +1 -0
- package/dist/src/shared/envs/production.js +12 -0
- package/dist/src/shared/envs/production.js.map +1 -0
- package/dist/src/shared/envs/sandbox.js +12 -0
- package/dist/src/shared/envs/sandbox.js.map +1 -0
- package/dist/src/shared/envs/staging.js +12 -0
- package/dist/src/shared/envs/staging.js.map +1 -0
- package/dist/src/shared/event-manager.js +24 -0
- package/dist/src/shared/event-manager.js.map +1 -0
- package/dist/src/shared/post-message-client.js +127 -0
- package/dist/src/shared/post-message-client.js.map +1 -0
- package/dist/src/shared/post-message-client.test.js +58 -0
- package/dist/src/shared/post-message-client.test.js.map +1 -0
- package/dist/src/shared/types.js +36 -0
- package/dist/src/shared/types.js.map +1 -0
- package/dist/src/shared/types.test.js +55 -0
- package/dist/src/shared/types.test.js.map +1 -0
- package/dist/src/shared/util.js +96 -0
- package/dist/src/shared/util.js.map +1 -0
- package/dist/src/shared/util.test.js +148 -0
- package/dist/src/shared/util.test.js.map +1 -0
- package/dist/src/validation/index.js +12 -0
- package/dist/src/validation/index.js.map +1 -0
- package/dist/src/validation/schemas/click-to-pay/load-params.json +34 -0
- package/dist/src/validation/schemas/click-to-pay/options.json +23 -0
- package/dist/src/validation/schemas/click-to-pay/payment-intent.json +42 -0
- package/dist/src/validation/schemas/customer.json +38 -0
- package/dist/src/validation/schemas/hpp-load-params.json +40 -0
- package/dist/src/validation/schemas/hpp-options.json +48 -0
- package/dist/src/validation/schemas/payment-intent.json +48 -0
- package/dist/src/validation/schemas/payment-method.json +83 -0
- package/dist/src/validation/schemas/verify-card-options.json +15 -0
- package/dist/src/validation/schemas/verify-card-params.json +24 -0
- package/dist/src/validation/validation-helper.js +10 -0
- package/dist/src/validation/validation-helper.js.map +1 -0
- package/dist/src/validation/validation-helper.test.js +34 -0
- package/dist/src/validation/validation-helper.test.js.map +1 -0
- package/dist/src/validation/validators/apple-pay-load-params-button-validator.js +19 -0
- package/dist/src/validation/validators/apple-pay-load-params-button-validator.js.map +1 -0
- package/dist/src/validation/validators/click-to-pay-load-params-validator.js +19 -0
- package/dist/src/validation/validators/click-to-pay-load-params-validator.js.map +1 -0
- package/dist/src/validation/validators/hpp-load-params-validator.js +21 -0
- package/dist/src/validation/validators/hpp-load-params-validator.js.map +1 -0
- package/dist/src/validation/validators/hpp-load-params-validator.test.js +56 -0
- package/dist/src/validation/validators/hpp-load-params-validator.test.js.map +1 -0
- package/dist/src/validation/validators/verify-card-params-validator.js +23 -0
- package/dist/src/validation/validators/verify-card-params-validator.js.map +1 -0
- package/dist/src/version.js +5 -0
- package/dist/src/version.js.map +1 -0
- package/dist/staging/fatzebra.css +91 -0
- package/dist/staging/fatzebra.js +19565 -0
- package/dist/staging/fatzebra.js.map +1 -0
- package/dist/staging/index.html +247 -0
- package/dist/tests/helpers/api-gateway-mock.js +37 -0
- package/dist/tests/helpers/api-gateway-mock.js.map +1 -0
- package/dist/validation/schemas/applepay/load-params.json +31 -0
- package/dist/validation/schemas/applepay/options.json +42 -0
- package/dist/validation/schemas/applepay/payment-intent.json +42 -0
- package/dist/validation/schemas/click-to-pay/options.json +30 -3
- package/dist/validation/validators/apple-pay-load-params-button-validator.d.ts +3 -0
- package/dist/validation/validators/apple-pay-load-params-button-validator.js +12 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +10 -4
- package/tsconfig.json +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/** @license URI.js v4.2.1 (c) 2011 Gary Court. License: http://github.com/garycourt/uri-js */
|
|
@@ -0,0 +1,324 @@
|
|
|
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
|
+
var inquirer_1 = __importDefault(require("inquirer"));
|
|
66
|
+
var child_process_1 = require("child_process");
|
|
67
|
+
var fs_1 = __importDefault(require("fs"));
|
|
68
|
+
var path_1 = __importDefault(require("path"));
|
|
69
|
+
var simple_git_1 = __importDefault(require("simple-git"));
|
|
70
|
+
var git = (0, simple_git_1.default)();
|
|
71
|
+
var shell = process.env.SHELL;
|
|
72
|
+
// Get the json package
|
|
73
|
+
var packageJsonPath = path_1.default.resolve(__dirname, '../package.json');
|
|
74
|
+
var version = '';
|
|
75
|
+
/**
|
|
76
|
+
* Dynamically import the version from the transpiled version.js file
|
|
77
|
+
*
|
|
78
|
+
* @returns {Promise<string>} The version from version.js
|
|
79
|
+
*/
|
|
80
|
+
function getVersionFromJs() {
|
|
81
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
82
|
+
var versionModule;
|
|
83
|
+
return __generator(this, function (_a) {
|
|
84
|
+
switch (_a.label) {
|
|
85
|
+
case 0: return [4 /*yield*/, Promise.resolve("".concat(path_1.default.resolve(__dirname, '../src/version.ts'))).then(function (s) { return __importStar(require(s)); })];
|
|
86
|
+
case 1:
|
|
87
|
+
versionModule = _a.sent();
|
|
88
|
+
version = versionModule.version;
|
|
89
|
+
return [2 /*return*/];
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Reads the version from package.json and version.ts, compares them, and returns the version if they match
|
|
96
|
+
*
|
|
97
|
+
* @returns {Promise<string>} The version if both versions match
|
|
98
|
+
*/
|
|
99
|
+
function readAndCompareVersions() {
|
|
100
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
101
|
+
var packageData, packageJson, packageVersion, err_1;
|
|
102
|
+
return __generator(this, function (_a) {
|
|
103
|
+
switch (_a.label) {
|
|
104
|
+
case 0:
|
|
105
|
+
_a.trys.push([0, 2, , 3]);
|
|
106
|
+
return [4 /*yield*/, fs_1.default.promises.readFile(packageJsonPath, 'utf8')];
|
|
107
|
+
case 1:
|
|
108
|
+
packageData = _a.sent();
|
|
109
|
+
packageJson = JSON.parse(packageData);
|
|
110
|
+
packageVersion = packageJson.version;
|
|
111
|
+
if (packageVersion !== version) {
|
|
112
|
+
console.log("Version mismatch detected: package.json is ".concat(packageVersion, " and version.ts is ").concat(version));
|
|
113
|
+
}
|
|
114
|
+
return [2 /*return*/, packageVersion];
|
|
115
|
+
case 2:
|
|
116
|
+
err_1 = _a.sent();
|
|
117
|
+
throw new Error("Error reading or comparing versions: ".concat(err_1.message));
|
|
118
|
+
case 3: return [2 /*return*/];
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Builds and publishes to npm (for production)
|
|
125
|
+
*
|
|
126
|
+
*/
|
|
127
|
+
function publish() {
|
|
128
|
+
console.log("running build...");
|
|
129
|
+
try {
|
|
130
|
+
// Running the command synchronously and inheriting the shell
|
|
131
|
+
(0, child_process_1.execSync)("".concat(shell, " -c \"npm run build:package && npm publish\""), { stdio: 'inherit' });
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
// This will catch any errors that occur during the execution of the command
|
|
135
|
+
console.error("Execution error: ".concat(error.message));
|
|
136
|
+
console.error("stderr: ".concat(error.stderr));
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Writes version number to package.json and to another file to read from
|
|
141
|
+
*
|
|
142
|
+
* @param {string} filePath - path to where the file will be written (package.json | version.ts).
|
|
143
|
+
* @param {string} content - content of file (version number).
|
|
144
|
+
*/
|
|
145
|
+
function writeToFile(filePath, content) {
|
|
146
|
+
fs_1.default.writeFileSync(filePath, content, 'utf8');
|
|
147
|
+
console.log("content: ".concat(content, " written to ").concat(filePath));
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* @param newVersion
|
|
151
|
+
* Updates the version in package.json
|
|
152
|
+
*/
|
|
153
|
+
function updatePackageJsonVersion(newVersion) {
|
|
154
|
+
try {
|
|
155
|
+
// Read the current package.json content
|
|
156
|
+
var packageJsonContent = fs_1.default.readFileSync(packageJsonPath, 'utf8');
|
|
157
|
+
var packageJson = JSON.parse(packageJsonContent);
|
|
158
|
+
// Update the version
|
|
159
|
+
packageJson.version = newVersion;
|
|
160
|
+
// Write the updated content back to package.json
|
|
161
|
+
fs_1.default.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), 'utf8');
|
|
162
|
+
console.log("Version updated to ".concat(newVersion, " in ").concat(packageJsonPath));
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
console.error('Error updating package.json version:', error);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Take data from package.json and applies increment (depending on major/minor/patch/beta upgrade)
|
|
170
|
+
*
|
|
171
|
+
* @param {string} data - package.json data
|
|
172
|
+
* @param {string} releaseType - major, minor, patch or beta
|
|
173
|
+
* @returns {newVersion} The new version string
|
|
174
|
+
*/
|
|
175
|
+
function increment(currentVersion, releaseType) {
|
|
176
|
+
var _a = currentVersion.split('-'), version = _a[0], betaSuffix = _a[1];
|
|
177
|
+
var _b = version.split('.').map(Number), major = _b[0], minor = _b[1], patch = _b[2];
|
|
178
|
+
var betaNumber = 0;
|
|
179
|
+
if (betaSuffix && betaSuffix.startsWith('beta.')) {
|
|
180
|
+
betaNumber = parseInt(betaSuffix.split('.')[1], 10);
|
|
181
|
+
}
|
|
182
|
+
if (releaseType === 'beta') {
|
|
183
|
+
if (betaSuffix) {
|
|
184
|
+
betaNumber++;
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
betaNumber = 0;
|
|
188
|
+
}
|
|
189
|
+
currentVersion = "".concat(major, ".").concat(minor, ".").concat(patch, "-beta.").concat(betaNumber);
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
if (betaSuffix) {
|
|
193
|
+
// Remove beta suffix and handle as a normal version increment
|
|
194
|
+
betaSuffix = null;
|
|
195
|
+
betaNumber = 0;
|
|
196
|
+
}
|
|
197
|
+
if (releaseType === 'major') {
|
|
198
|
+
major++;
|
|
199
|
+
minor = 0;
|
|
200
|
+
patch = 0; // Reset minor and patch version on major update
|
|
201
|
+
}
|
|
202
|
+
else if (releaseType === 'minor') {
|
|
203
|
+
minor++;
|
|
204
|
+
patch = 0; // Reset patch version on minor update
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
patch++;
|
|
208
|
+
}
|
|
209
|
+
currentVersion = "".concat(major, ".").concat(minor, ".").concat(patch);
|
|
210
|
+
}
|
|
211
|
+
return currentVersion;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Commits and tags the updated version
|
|
215
|
+
*
|
|
216
|
+
* @param {string} newVersion - new version number
|
|
217
|
+
*/
|
|
218
|
+
function commitAndTagVersion(newVersion) {
|
|
219
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
220
|
+
var currentBranch, error_1;
|
|
221
|
+
return __generator(this, function (_a) {
|
|
222
|
+
switch (_a.label) {
|
|
223
|
+
case 0:
|
|
224
|
+
_a.trys.push([0, 8, , 9]);
|
|
225
|
+
return [4 /*yield*/, git.revparse(['--abbrev-ref', 'HEAD'])];
|
|
226
|
+
case 1:
|
|
227
|
+
currentBranch = _a.sent();
|
|
228
|
+
return [4 /*yield*/, git.add([packageJsonPath, path_1.default.resolve(__dirname, '../src/version.ts')])];
|
|
229
|
+
case 2:
|
|
230
|
+
_a.sent();
|
|
231
|
+
return [4 /*yield*/, git.add([packageJsonPath, path_1.default.resolve(__dirname, '../src/version.ts')])];
|
|
232
|
+
case 3:
|
|
233
|
+
_a.sent();
|
|
234
|
+
return [4 /*yield*/, git.commit("bumped the npm package to ".concat(newVersion, " and released to npm"))];
|
|
235
|
+
case 4:
|
|
236
|
+
_a.sent();
|
|
237
|
+
return [4 /*yield*/, git.tag(["v".concat(newVersion)])];
|
|
238
|
+
case 5:
|
|
239
|
+
_a.sent();
|
|
240
|
+
return [4 /*yield*/, git.push('origin', currentBranch)];
|
|
241
|
+
case 6:
|
|
242
|
+
_a.sent();
|
|
243
|
+
return [4 /*yield*/, git.pushTags('origin')];
|
|
244
|
+
case 7:
|
|
245
|
+
_a.sent();
|
|
246
|
+
console.log("Committed and tagged version ".concat(newVersion));
|
|
247
|
+
return [3 /*break*/, 9];
|
|
248
|
+
case 8:
|
|
249
|
+
error_1 = _a.sent();
|
|
250
|
+
console.error('Error committing and tagging version:', error_1);
|
|
251
|
+
return [3 /*break*/, 9];
|
|
252
|
+
case 9: return [2 /*return*/];
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Increments the version number in package.json based on the release type.
|
|
259
|
+
*
|
|
260
|
+
* @param {string} releaseType - The type of release (major, minor, patch, or beta).
|
|
261
|
+
*/
|
|
262
|
+
function incrementAndPublish(releaseType) {
|
|
263
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
264
|
+
var currentVersion, newVersion, fileContent;
|
|
265
|
+
return __generator(this, function (_a) {
|
|
266
|
+
switch (_a.label) {
|
|
267
|
+
case 0: return [4 /*yield*/, readAndCompareVersions()];
|
|
268
|
+
case 1:
|
|
269
|
+
currentVersion = _a.sent();
|
|
270
|
+
newVersion = increment(currentVersion, releaseType);
|
|
271
|
+
if (!newVersion) {
|
|
272
|
+
throw new Error('Failed to increment version');
|
|
273
|
+
}
|
|
274
|
+
updatePackageJsonVersion(newVersion);
|
|
275
|
+
fileContent = "export const version = '".concat(newVersion, "';\n");
|
|
276
|
+
writeToFile(path_1.default.resolve(__dirname, '../src/version.ts'), fileContent);
|
|
277
|
+
publish();
|
|
278
|
+
return [4 /*yield*/, commitAndTagVersion(newVersion)];
|
|
279
|
+
case 2:
|
|
280
|
+
_a.sent();
|
|
281
|
+
return [2 /*return*/];
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Asks the user whether the release is a major, minor, patch or beta.
|
|
288
|
+
*/
|
|
289
|
+
function askReleaseType() {
|
|
290
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
291
|
+
var currentVersion;
|
|
292
|
+
return __generator(this, function (_a) {
|
|
293
|
+
switch (_a.label) {
|
|
294
|
+
case 0: return [4 /*yield*/, getVersionFromJs()];
|
|
295
|
+
case 1:
|
|
296
|
+
_a.sent();
|
|
297
|
+
return [4 /*yield*/, readAndCompareVersions()];
|
|
298
|
+
case 2:
|
|
299
|
+
currentVersion = _a.sent();
|
|
300
|
+
console.log("Current version is: ".concat(currentVersion, "\n"));
|
|
301
|
+
inquirer_1.default.prompt([
|
|
302
|
+
{
|
|
303
|
+
type: 'list',
|
|
304
|
+
name: 'releaseType',
|
|
305
|
+
message: 'Select the release type:',
|
|
306
|
+
choices: [
|
|
307
|
+
{ name: 'Major', value: 'major' },
|
|
308
|
+
{ name: 'Minor', value: 'minor' },
|
|
309
|
+
{ name: 'Patch', value: 'patch' },
|
|
310
|
+
{ name: 'Beta', value: 'beta' }
|
|
311
|
+
]
|
|
312
|
+
}
|
|
313
|
+
]).then(function (answers) {
|
|
314
|
+
incrementAndPublish(answers.releaseType);
|
|
315
|
+
}).catch(function (error) {
|
|
316
|
+
console.error('Error:', error);
|
|
317
|
+
});
|
|
318
|
+
return [2 /*return*/];
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
askReleaseType();
|
|
324
|
+
//# sourceMappingURL=release-package.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"release-package.js","sourceRoot":"","sources":["../../scripts/release-package.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sDAAgC;AAChC,+CAAyC;AACzC,0CAAoB;AACpB,8CAAwB;AACxB,0DAAmC;AAEnC,IAAM,GAAG,GAAG,IAAA,oBAAS,GAAE,CAAC;AAC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Ac;;;;;wBAC3B,qBAAM,gBAAgB,EAAE,EAAA;;oBAAxB,SAAwB,CAAC;oBACF,qBAAM,sBAAsB,EAAE,EAAA;;oBAA/C,cAAc,GAAG,SAA8B;oBACrD,OAAO,CAAC,GAAG,CAAC,8BAAuB,cAAc,OAAI,CAAC,CAAC;oBACvD,kBAAQ,CAAC,MAAM,CAAC;wBACd;4BACE,IAAI,EAAE,MAAM;4BACZ,IAAI,EAAE,aAAa;4BACnB,OAAO,EAAE,0BAA0B;4BACnC,OAAO,EAAE;gCACP,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;gCACjC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;gCACjC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;gCACjC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;6BAChC;yBACF;qBACF,CAAC,CAAC,IAAI,CAAC,UAAA,OAAO;wBACb,mBAAmB,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;oBAC3C,CAAC,CAAC,CAAC,KAAK,CAAC,UAAA,KAAK;wBACZ,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;oBACjC,CAAC,CAAC,CAAC;;;;;CACJ;AAED,cAAc,EAAE,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
declare const bridgeUrl = "
|
|
2
|
-
declare const apiUrl = "
|
|
3
|
-
declare const payNowUrl = "
|
|
1
|
+
declare const bridgeUrl = "https://paynow.test";
|
|
2
|
+
declare const apiUrl = "https://api.test/sdk";
|
|
3
|
+
declare const payNowUrl = "https://paynow.test";
|
|
4
4
|
declare const songbirdUrl = "https://songbirdstag.cardinalcommerce.com/edge/v1/songbird.js";
|
|
5
5
|
export { bridgeUrl, apiUrl, payNowUrl, songbirdUrl };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const bridgeUrl = "
|
|
2
|
-
const apiUrl = "
|
|
3
|
-
const payNowUrl = "
|
|
1
|
+
const bridgeUrl = "https://paynow.test";
|
|
2
|
+
const apiUrl = "https://api.test/sdk";
|
|
3
|
+
const payNowUrl = "https://paynow.test";
|
|
4
4
|
const songbirdUrl = "https://songbirdstag.cardinalcommerce.com/edge/v1/songbird.js";
|
|
5
5
|
export { bridgeUrl, apiUrl, payNowUrl, songbirdUrl };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
declare const bridgeUrl = "
|
|
2
|
-
declare const apiUrl = "
|
|
3
|
-
declare const payNowUrl = "
|
|
1
|
+
declare const bridgeUrl = "https://paynow.test";
|
|
2
|
+
declare const apiUrl = "https://api.test:3002/sdk";
|
|
3
|
+
declare const payNowUrl = "https://paynow.test";
|
|
4
4
|
declare const songbirdUrl = "https://songbirdstag.cardinalcommerce.com/edge/v1/songbird.js";
|
|
5
5
|
export { bridgeUrl, apiUrl, payNowUrl, songbirdUrl };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const bridgeUrl = "
|
|
2
|
-
const apiUrl = "
|
|
3
|
-
const payNowUrl = "
|
|
1
|
+
const bridgeUrl = "https://paynow.test";
|
|
2
|
+
const apiUrl = "https://api.test:3002/sdk";
|
|
3
|
+
const payNowUrl = "https://paynow.test";
|
|
4
4
|
const songbirdUrl = "https://songbirdstag.cardinalcommerce.com/edge/v1/songbird.js";
|
|
5
5
|
export { bridgeUrl, apiUrl, payNowUrl, songbirdUrl };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Environment } from "./env";
|
|
1
2
|
interface PostMessage {
|
|
2
3
|
channel: string;
|
|
3
4
|
subject: string;
|
|
@@ -11,6 +12,7 @@ interface PostMessageLegacy {
|
|
|
11
12
|
}
|
|
12
13
|
interface PostMessageClientConfig {
|
|
13
14
|
channel: string;
|
|
15
|
+
environment?: Environment;
|
|
14
16
|
target?: HTMLIFrameElement;
|
|
15
17
|
}
|
|
16
18
|
interface EventHandlers {
|
|
@@ -11,7 +11,7 @@ import env, { Environment } from "./env";
|
|
|
11
11
|
class PostMessageClient {
|
|
12
12
|
constructor(config) {
|
|
13
13
|
this.channel = config.channel;
|
|
14
|
-
this.fzEnv = process.env.API_ENV;
|
|
14
|
+
this.fzEnv = config.environment || process.env.API_ENV;
|
|
15
15
|
this.domain = env[this.fzEnv].payNowUrl;
|
|
16
16
|
this.target = config.target;
|
|
17
17
|
}
|
package/dist/shared/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Environment } from './env';
|
|
2
|
+
import { MerchantCapability, SupportedNetwork } from "../applepay/clients/apple-pay-client";
|
|
2
3
|
declare enum PublicEvent {
|
|
3
4
|
FORM_VALIDATION_ERROR = "fz.form_validation.error",
|
|
4
5
|
FORM_VALIDATION_SUCCESS = "fz.form_validation.success",
|
|
@@ -11,7 +12,9 @@ declare enum PublicEvent {
|
|
|
11
12
|
PAYMENT_ERROR = "fz.payment.error",
|
|
12
13
|
BIN_LOOKUP = "fz.bin.lookup",
|
|
13
14
|
CLICK_TO_PAY_TOKENIZATION_SUCCESS = "fz.click_to_pay.tokenization.success",
|
|
14
|
-
CLICK_TO_PAY_TOKENIZATION_ERROR = "fz.click_to_pay.tokenization.error"
|
|
15
|
+
CLICK_TO_PAY_TOKENIZATION_ERROR = "fz.click_to_pay.tokenization.error",
|
|
16
|
+
CLICK_TO_PAY_RESIZE = "fz.click_to_pay.resize",
|
|
17
|
+
CLICK_TO_PAY_DCF_LOADED = "fz.click_to_pay.dcf"
|
|
15
18
|
}
|
|
16
19
|
declare enum BridgeEvent {
|
|
17
20
|
TOKENIZE_CARD_REQUEST = "fzi.tc_req",
|
|
@@ -89,6 +92,9 @@ export type OptionalUrlValues = {
|
|
|
89
92
|
hide_card_holder?: boolean;
|
|
90
93
|
hide_button?: boolean;
|
|
91
94
|
return_path?: string;
|
|
95
|
+
allowed_card_networks?: Array<SupportedNetwork>;
|
|
96
|
+
allowed_card_types?: Array<MerchantCapability>;
|
|
97
|
+
domain_name?: string;
|
|
92
98
|
card_types?: Array<string>;
|
|
93
99
|
surcharge_enabled?: string;
|
|
94
100
|
sca_enabled?: boolean;
|
|
@@ -102,6 +108,7 @@ declare global {
|
|
|
102
108
|
Cardinal: any;
|
|
103
109
|
FatZebra: any;
|
|
104
110
|
HPP: any;
|
|
111
|
+
ApplePayButton: any;
|
|
105
112
|
MerchantUsername: string;
|
|
106
113
|
}
|
|
107
114
|
}
|
|
@@ -137,5 +144,10 @@ type TokenizeCardResponse = {
|
|
|
137
144
|
token: string;
|
|
138
145
|
errors?: Array<string>;
|
|
139
146
|
};
|
|
147
|
+
type ApplePayPaymentResponse = {
|
|
148
|
+
message: string;
|
|
149
|
+
errors?: Array<string>;
|
|
150
|
+
data?: string;
|
|
151
|
+
};
|
|
140
152
|
export { BridgeEvent, PublicEvent, PaymentMethodType, };
|
|
141
|
-
export type { PaymentMethod, PaymentIntent, Payment, Card, CardOnFile, CustomerSnakeCase, Customer, Handlers, ValidationResult, TokenizeCardResponse, };
|
|
153
|
+
export type { PaymentMethod, PaymentIntent, Payment, Card, CardOnFile, CustomerSnakeCase, Customer, Handlers, ValidationResult, TokenizeCardResponse, ApplePayPaymentResponse };
|
package/dist/shared/types.js
CHANGED
|
@@ -12,6 +12,8 @@ var PublicEvent;
|
|
|
12
12
|
PublicEvent["BIN_LOOKUP"] = "fz.bin.lookup";
|
|
13
13
|
PublicEvent["CLICK_TO_PAY_TOKENIZATION_SUCCESS"] = "fz.click_to_pay.tokenization.success";
|
|
14
14
|
PublicEvent["CLICK_TO_PAY_TOKENIZATION_ERROR"] = "fz.click_to_pay.tokenization.error";
|
|
15
|
+
PublicEvent["CLICK_TO_PAY_RESIZE"] = "fz.click_to_pay.resize";
|
|
16
|
+
PublicEvent["CLICK_TO_PAY_DCF_LOADED"] = "fz.click_to_pay.dcf";
|
|
15
17
|
})(PublicEvent || (PublicEvent = {}));
|
|
16
18
|
var BridgeEvent;
|
|
17
19
|
(function (BridgeEvent) {
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
37
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
39
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
40
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
41
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
42
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
46
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
47
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
48
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
49
|
+
function step(op) {
|
|
50
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
51
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
52
|
+
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;
|
|
53
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
54
|
+
switch (op[0]) {
|
|
55
|
+
case 0: case 1: t = op; break;
|
|
56
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
57
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
58
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
59
|
+
default:
|
|
60
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
61
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
62
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
63
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
64
|
+
if (t[2]) _.ops.pop();
|
|
65
|
+
_.trys.pop(); continue;
|
|
66
|
+
}
|
|
67
|
+
op = body.call(thisArg, _);
|
|
68
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
69
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
73
|
+
exports.ApplePay = void 0;
|
|
74
|
+
var apple_pay_client_1 = require("./clients/apple-pay-client");
|
|
75
|
+
var payNow = __importStar(require("./clients/paynow-client"));
|
|
76
|
+
var post_message_client_1 = require("../shared/post-message-client");
|
|
77
|
+
var channel = 'applepay';
|
|
78
|
+
var fzPayNowDomain = process.env.PAYNOW_BASE_URL;
|
|
79
|
+
var ApplePay = /** @class */ (function () {
|
|
80
|
+
function ApplePay(config) {
|
|
81
|
+
this.iframe = config.iframe;
|
|
82
|
+
this.postMessageClient = new post_message_client_1.PostMessageClient({
|
|
83
|
+
channel: 'applepay',
|
|
84
|
+
target: this.iframe
|
|
85
|
+
});
|
|
86
|
+
this.registerEventListener();
|
|
87
|
+
this.checkApplePayEligibilty();
|
|
88
|
+
this.notifyApplePayEligibiity();
|
|
89
|
+
}
|
|
90
|
+
ApplePay.prototype.checkApplePayEligibilty = function () {
|
|
91
|
+
if ((0, apple_pay_client_1.getEligibilty)()) {
|
|
92
|
+
this.canMakePayments = true;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
ApplePay.prototype.notifyApplePayEligibiity = function () {
|
|
96
|
+
var message = {
|
|
97
|
+
channel: channel,
|
|
98
|
+
subject: 'eligibility',
|
|
99
|
+
data: {
|
|
100
|
+
canMakePayments: this.canMakePayments
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
this.postMessageClient.send(message);
|
|
104
|
+
};
|
|
105
|
+
ApplePay.prototype.registerEventListener = function () {
|
|
106
|
+
var _this = this;
|
|
107
|
+
this.postMessageClient.setEventListeners({
|
|
108
|
+
'paymentrequest': function (data) { return __awaiter(_this, void 0, void 0, function () {
|
|
109
|
+
return __generator(this, function (_a) {
|
|
110
|
+
switch (_a.label) {
|
|
111
|
+
case 0: return [4 /*yield*/, this.purchase(data)];
|
|
112
|
+
case 1:
|
|
113
|
+
_a.sent();
|
|
114
|
+
return [2 /*return*/];
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}); }
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
ApplePay.prototype.purchase = function (request) {
|
|
121
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
122
|
+
var applePayPaymentRequest, payNowPaymentAttributes, _a;
|
|
123
|
+
var _this = this;
|
|
124
|
+
return __generator(this, function (_b) {
|
|
125
|
+
switch (_b.label) {
|
|
126
|
+
case 0:
|
|
127
|
+
applePayPaymentRequest = this.extractApplePaymentRequestParams(request);
|
|
128
|
+
payNowPaymentAttributes = this.extractPayNowPaymentAttributes(request);
|
|
129
|
+
_a = this;
|
|
130
|
+
return [4 /*yield*/, (0, apple_pay_client_1.createSession)(applePayPaymentRequest)];
|
|
131
|
+
case 1:
|
|
132
|
+
_a.applePaySession = _b.sent();
|
|
133
|
+
this.applePaySession.onvalidatemerchant = function (event) { return __awaiter(_this, void 0, void 0, function () {
|
|
134
|
+
var merchantSession, e_1;
|
|
135
|
+
return __generator(this, function (_a) {
|
|
136
|
+
switch (_a.label) {
|
|
137
|
+
case 0:
|
|
138
|
+
_a.trys.push([0, 2, , 3]);
|
|
139
|
+
return [4 /*yield*/, payNow.getMerchantSession(event.validationURL, payNowPaymentAttributes)];
|
|
140
|
+
case 1:
|
|
141
|
+
merchantSession = _a.sent();
|
|
142
|
+
return [3 /*break*/, 3];
|
|
143
|
+
case 2:
|
|
144
|
+
e_1 = _a.sent();
|
|
145
|
+
console.log('Unable to establish new merchant session');
|
|
146
|
+
return [2 /*return*/];
|
|
147
|
+
case 3:
|
|
148
|
+
this.applePaySession.completeMerchantValidation(merchantSession);
|
|
149
|
+
return [2 /*return*/];
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
}); };
|
|
153
|
+
this.applePaySession.onpaymentauthorized = function (event) { return __awaiter(_this, void 0, void 0, function () {
|
|
154
|
+
var e_2;
|
|
155
|
+
return __generator(this, function (_a) {
|
|
156
|
+
switch (_a.label) {
|
|
157
|
+
case 0:
|
|
158
|
+
_a.trys.push([0, 2, , 3]);
|
|
159
|
+
return [4 /*yield*/, payNow.authorizePayment(__assign(__assign({}, payNowPaymentAttributes), event.payment.token))];
|
|
160
|
+
case 1:
|
|
161
|
+
_a.sent();
|
|
162
|
+
this.applePaySession.completePayment(window.ApplePaySession.STATUS_SUCCESS);
|
|
163
|
+
return [3 /*break*/, 3];
|
|
164
|
+
case 2:
|
|
165
|
+
e_2 = _a.sent();
|
|
166
|
+
this.applePaySession.completePayment(window.ApplePaySession.STATUS_FAILURE);
|
|
167
|
+
return [3 /*break*/, 3];
|
|
168
|
+
case 3: return [2 /*return*/];
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
}); };
|
|
172
|
+
this.applePaySession.begin();
|
|
173
|
+
return [2 /*return*/];
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
ApplePay.prototype.extractApplePaymentRequestParams = function (payload) {
|
|
179
|
+
var countryCode = payload.countryCode, currencyCode = payload.currencyCode, merchantCapabilities = payload.merchantCapabilities, supportedNetworks = payload.supportedNetworks, total = payload.total;
|
|
180
|
+
return {
|
|
181
|
+
countryCode: countryCode,
|
|
182
|
+
currencyCode: currencyCode,
|
|
183
|
+
merchantCapabilities: merchantCapabilities,
|
|
184
|
+
supportedNetworks: supportedNetworks,
|
|
185
|
+
total: total,
|
|
186
|
+
};
|
|
187
|
+
};
|
|
188
|
+
ApplePay.prototype.extractPayNowPaymentAttributes = function (payload) {
|
|
189
|
+
var paymentAttributes = payload.paymentAttributes;
|
|
190
|
+
return paymentAttributes;
|
|
191
|
+
};
|
|
192
|
+
ApplePay.prototype.sendMessage = function (payload) {
|
|
193
|
+
this.iframe.contentWindow.postMessage(payload, fzPayNowDomain);
|
|
194
|
+
};
|
|
195
|
+
return ApplePay;
|
|
196
|
+
}());
|
|
197
|
+
exports.ApplePay = ApplePay;
|
|
198
|
+
//# sourceMappingURL=applepay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"applepay.js","sourceRoot":"","sources":["../../../src/applepay/applepay.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+DAImC;AACnC,8DAAiD;AACjD,qEAGsC;AAEtC,IAAM,OAAO,GAAG,UAAU,CAAA;AAC1B,IAAM,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAA;AAElD;IAOE,kBAAY,MAAqC;QAC/C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAA;QAE3B,IAAI,CAAC,iBAAiB,GAAG,IAAI,uCAAiB,CAAC;YAC7C,OAAO,EAAE,UAAU;YACnB,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAC,CAAA;QAEF,IAAI,CAAC,qBAAqB,EAAE,CAAA;QAC5B,IAAI,CAAC,uBAAuB,EAAE,CAAA;QAC9B,IAAI,CAAC,wBAAwB,EAAE,CAAA;IACjC,CAAC;IAED,0CAAuB,GAAvB;QACE,IAAI,IAAA,gCAAa,GAAE,EAAE;YACnB,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;SAC7B;IACH,CAAC;IAED,2CAAwB,GAAxB;QACE,IAAM,OAAO,GAAgB;YAC3B,OAAO,SAAA;YACP,OAAO,EAAE,aAAa;YACtB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