@fat-zebra/sdk 1.5.1 → 1.5.2

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.
Files changed (148) hide show
  1. package/.idea/fatzebra-js.iml +12 -0
  2. package/.idea/modules.xml +8 -0
  3. package/.idea/vcs.xml +6 -0
  4. package/README.dev.md +33 -0
  5. package/README.md +4 -1
  6. package/dist/fatzebra.css +91 -0
  7. package/dist/local/fatzebra.js +18990 -0
  8. package/dist/local/fatzebra.js.map +1 -1
  9. package/dist/production/fatzebra.css +91 -0
  10. package/dist/production/fatzebra.js +2 -0
  11. package/dist/sca/cardinal.js +1 -2
  12. package/dist/sca/index.js +0 -1
  13. package/dist/shared/util.d.ts +1 -1
  14. package/dist/shared/util.js +2 -2
  15. package/dist/staging/fatzebra.css +91 -0
  16. package/dist/staging/fatzebra.js +17717 -0
  17. package/dist/staging/fatzebra.js.map +1 -0
  18. package/dist/staging/index.html +247 -0
  19. package/dist/version.d.ts +1 -0
  20. package/dist/version.js +1 -0
  21. package/package.json +7 -6
  22. package/scripts/release-package.js +113 -0
  23. package/dist/react/url.d.ts +0 -12
  24. package/dist/react/url.js +0 -33
  25. package/dist/src/applepay/applepay.js +0 -198
  26. package/dist/src/applepay/applepay.js.map +0 -1
  27. package/dist/src/applepay/clients/apple-pay-client.js +0 -66
  28. package/dist/src/applepay/clients/apple-pay-client.js.map +0 -1
  29. package/dist/src/applepay/clients/paynow-client.js +0 -96
  30. package/dist/src/applepay/clients/paynow-client.js.map +0 -1
  31. package/dist/src/applepay/index.js +0 -6
  32. package/dist/src/applepay/index.js.map +0 -1
  33. package/dist/src/click_to_pay/index.js +0 -88
  34. package/dist/src/click_to_pay/index.js.map +0 -1
  35. package/dist/src/click_to_pay/types.js +0 -3
  36. package/dist/src/click_to_pay/types.js.map +0 -1
  37. package/dist/src/hpp/hpp.js +0 -230
  38. package/dist/src/hpp/hpp.js.map +0 -1
  39. package/dist/src/hpp/hpp.test.js +0 -135
  40. package/dist/src/hpp/hpp.test.js.map +0 -1
  41. package/dist/src/hpp/index.js +0 -6
  42. package/dist/src/hpp/index.js.map +0 -1
  43. package/dist/src/index.js +0 -14
  44. package/dist/src/index.js.map +0 -1
  45. package/dist/src/main.js +0 -243
  46. package/dist/src/main.js.map +0 -1
  47. package/dist/src/main.test.js +0 -236
  48. package/dist/src/main.test.js.map +0 -1
  49. package/dist/src/paypal/paypal-button.js +0 -311
  50. package/dist/src/paypal/paypal-button.js.map +0 -1
  51. package/dist/src/paypal/paypal-button.test.js +0 -41
  52. package/dist/src/paypal/paypal-button.test.js.map +0 -1
  53. package/dist/src/paypal/paypal-checkout.js +0 -111
  54. package/dist/src/paypal/paypal-checkout.js.map +0 -1
  55. package/dist/src/paypal/paypal-checkout.test.js +0 -167
  56. package/dist/src/paypal/paypal-checkout.test.js.map +0 -1
  57. package/dist/src/paypal/types.js +0 -9
  58. package/dist/src/paypal/types.js.map +0 -1
  59. package/dist/src/paypal/validation.js +0 -73
  60. package/dist/src/paypal/validation.js.map +0 -1
  61. package/dist/src/react/VerifyCard.js +0 -29
  62. package/dist/src/react/VerifyCard.js.map +0 -1
  63. package/dist/src/react/index.js +0 -11
  64. package/dist/src/react/index.js.map +0 -1
  65. package/dist/src/react/submitForm.js +0 -13
  66. package/dist/src/react/submitForm.js.map +0 -1
  67. package/dist/src/react/url.js +0 -60
  68. package/dist/src/react/url.js.map +0 -1
  69. package/dist/src/react/url.test.js +0 -88
  70. package/dist/src/react/url.test.js.map +0 -1
  71. package/dist/src/react/useFatZebra.js +0 -119
  72. package/dist/src/react/useFatZebra.js.map +0 -1
  73. package/dist/src/sca/cardinal.js +0 -110
  74. package/dist/src/sca/cardinal.js.map +0 -1
  75. package/dist/src/sca/eci-mappings.js +0 -63
  76. package/dist/src/sca/eci-mappings.js.map +0 -1
  77. package/dist/src/sca/eci-mappings.test.js +0 -31
  78. package/dist/src/sca/eci-mappings.test.js.map +0 -1
  79. package/dist/src/sca/index.js +0 -363
  80. package/dist/src/sca/index.js.map +0 -1
  81. package/dist/src/sca/index.test.js +0 -620
  82. package/dist/src/sca/index.test.js.map +0 -1
  83. package/dist/src/sca/scenarios/enrollment.js +0 -161
  84. package/dist/src/sca/scenarios/enrollment.js.map +0 -1
  85. package/dist/src/sca/scenarios/index.js +0 -8
  86. package/dist/src/sca/scenarios/index.js.map +0 -1
  87. package/dist/src/sca/scenarios/validation.js +0 -139
  88. package/dist/src/sca/scenarios/validation.js.map +0 -1
  89. package/dist/src/sca/types.js +0 -57
  90. package/dist/src/sca/types.js.map +0 -1
  91. package/dist/src/shared/api-gateway-client.js +0 -184
  92. package/dist/src/shared/api-gateway-client.js.map +0 -1
  93. package/dist/src/shared/bridge-client.js +0 -24
  94. package/dist/src/shared/bridge-client.js.map +0 -1
  95. package/dist/src/shared/constants.js +0 -19
  96. package/dist/src/shared/constants.js.map +0 -1
  97. package/dist/src/shared/env.development.js +0 -12
  98. package/dist/src/shared/env.development.js.map +0 -1
  99. package/dist/src/shared/env.js +0 -46
  100. package/dist/src/shared/env.js.map +0 -1
  101. package/dist/src/shared/envs/local.js +0 -12
  102. package/dist/src/shared/envs/local.js.map +0 -1
  103. package/dist/src/shared/envs/production.js +0 -12
  104. package/dist/src/shared/envs/production.js.map +0 -1
  105. package/dist/src/shared/envs/sandbox.js +0 -12
  106. package/dist/src/shared/envs/sandbox.js.map +0 -1
  107. package/dist/src/shared/envs/staging.js +0 -12
  108. package/dist/src/shared/envs/staging.js.map +0 -1
  109. package/dist/src/shared/event-manager.js +0 -14
  110. package/dist/src/shared/event-manager.js.map +0 -1
  111. package/dist/src/shared/post-message-client.js +0 -107
  112. package/dist/src/shared/post-message-client.js.map +0 -1
  113. package/dist/src/shared/post-message-client.test.js +0 -58
  114. package/dist/src/shared/post-message-client.test.js.map +0 -1
  115. package/dist/src/shared/types.js +0 -47
  116. package/dist/src/shared/types.js.map +0 -1
  117. package/dist/src/shared/types.test.js +0 -55
  118. package/dist/src/shared/types.test.js.map +0 -1
  119. package/dist/src/shared/util.js +0 -96
  120. package/dist/src/shared/util.js.map +0 -1
  121. package/dist/src/shared/util.test.js +0 -148
  122. package/dist/src/shared/util.test.js.map +0 -1
  123. package/dist/src/validation/index.js +0 -12
  124. package/dist/src/validation/index.js.map +0 -1
  125. package/dist/src/validation/schemas/click-to-pay/load-params.json +0 -34
  126. package/dist/src/validation/schemas/click-to-pay/options.json +0 -23
  127. package/dist/src/validation/schemas/click-to-pay/payment-intent.json +0 -42
  128. package/dist/src/validation/schemas/customer.json +0 -38
  129. package/dist/src/validation/schemas/hpp-load-params.json +0 -40
  130. package/dist/src/validation/schemas/hpp-options.json +0 -48
  131. package/dist/src/validation/schemas/payment-intent.json +0 -48
  132. package/dist/src/validation/schemas/payment-method.json +0 -83
  133. package/dist/src/validation/schemas/verify-card-options.json +0 -15
  134. package/dist/src/validation/schemas/verify-card-params.json +0 -24
  135. package/dist/src/validation/validation-helper.js +0 -10
  136. package/dist/src/validation/validation-helper.js.map +0 -1
  137. package/dist/src/validation/validation-helper.test.js +0 -34
  138. package/dist/src/validation/validation-helper.test.js.map +0 -1
  139. package/dist/src/validation/validators/click-to-pay-load-params-validator.js +0 -19
  140. package/dist/src/validation/validators/click-to-pay-load-params-validator.js.map +0 -1
  141. package/dist/src/validation/validators/hpp-load-params-validator.js +0 -21
  142. package/dist/src/validation/validators/hpp-load-params-validator.js.map +0 -1
  143. package/dist/src/validation/validators/hpp-load-params-validator.test.js +0 -56
  144. package/dist/src/validation/validators/hpp-load-params-validator.test.js.map +0 -1
  145. package/dist/src/validation/validators/verify-card-params-validator.js +0 -23
  146. package/dist/src/validation/validators/verify-card-params-validator.js.map +0 -1
  147. package/dist/tests/helpers/api-gateway-mock.js +0 -37
  148. package/dist/tests/helpers/api-gateway-mock.js.map +0 -1
@@ -0,0 +1,247 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <title>Merchant XYZ Checkout Page</title>
6
+ <link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
7
+ <style type="text/css">
8
+ iframe {
9
+ height: 600px;
10
+ width: 700px;
11
+ }
12
+ </style>
13
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
14
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.2/rollups/hmac-md5.js"></script>
15
+ <script>
16
+ window.localStorage.setItem('fz-access-token', "")
17
+ // card tokens will be filled out
18
+ var actionItems = {
19
+ tokens: [
20
+ {
21
+ token: 'whatever',
22
+ number: '4000000000001000',
23
+ description: 'Successful Frictionless Authentication'
24
+ },
25
+ {
26
+ token: '',
27
+ number: '4000000000001026',
28
+ description: 'Attempts Stand-In Frictionless'
29
+ },
30
+ {
31
+ token: '',
32
+ number: '4000000000001034',
33
+ description: 'Unavailable Frictionless'
34
+ },
35
+ {
36
+ token: '',
37
+ number: '4000000000001059',
38
+ description: 'Authentication Not Available on Lookup'
39
+ },
40
+ {
41
+ token: '',
42
+ number: '4000000000001067',
43
+ description: 'Error on Lookup'
44
+ },
45
+ {
46
+ token: '',
47
+ number: '4000000000001075',
48
+ description: 'Timeout on cmpi_lookup'
49
+ },
50
+ {
51
+ token: '',
52
+ number: '4000000000001083',
53
+ description: 'Bypassed Authentication'
54
+ },
55
+ {
56
+ token: '',
57
+ number: '4000000000001018',
58
+ description: 'Failed Frictionless'
59
+ },
60
+ {
61
+ token: '',
62
+ number: '4000000000001042',
63
+ description: 'Rejected Frictionless'
64
+ },
65
+ {
66
+ token: 'ahq94qb60fs0xaruga3h',
67
+ number: '4000000000001091',
68
+ description: 'Challenge'
69
+ }
70
+ ],
71
+ cards: [
72
+ {
73
+ number: '4000000000001000',
74
+ description: 'Successful Frictionless Authentication'
75
+ },
76
+ {
77
+ number: '4000000000001026',
78
+ description: 'Attempts Stand-In Frictionless'
79
+ },
80
+ {
81
+ number: '4000000000001034',
82
+ description: 'Unavailable Frictionless'
83
+ },
84
+ {
85
+ number: '4000000000001059',
86
+ description: 'Authentication Not Available on Lookup'
87
+ },
88
+ {
89
+ number: '4000000000001067',
90
+ description: 'Error on Lookup'
91
+ },
92
+ {
93
+ number: '4000000000001075',
94
+ description: 'Timeout on cmpi_lookup'
95
+ },
96
+ {
97
+ number: '4000000000001083',
98
+ description: 'Bypassed Authentication'
99
+ },
100
+ {
101
+ number: '4000000000001018',
102
+ description: 'Failed Frictionless'
103
+ },
104
+ {
105
+ number: '4000000000001042',
106
+ description: 'Rejected Frictionless'
107
+ },
108
+ {
109
+ number: '4000000000001091',
110
+ description: 'Challenge'
111
+ }
112
+ ]
113
+ }
114
+ </script>
115
+ <script src="fatzebra.js"></script></head>
116
+ <body>
117
+ <table id="options" class="table table-bordered">
118
+ <thead>
119
+ <tr>
120
+ <th scope="col">Card Token</th>
121
+ <th scope="col">New Card</th>
122
+ <th scope="col">Description</th>
123
+ </tr>
124
+ </thead>
125
+ <tbody>
126
+ </tbody>
127
+ </table>
128
+ <button type="button" class="btn btn-primary" id='doCheckout'>Primary</button>
129
+
130
+ <script>
131
+ var selectedMode = undefined
132
+ var selectedValue = undefined
133
+
134
+ $(document).ready(function() {
135
+
136
+ for (var i = 0; i < actionItems.tokens.length; i ++ ) {
137
+ const row = "<tr><td><input type='checkbox' class='option' data-mode='token' value='" + actionItems.tokens[i].token + "'><label>token for " + actionItems.tokens[i].number + "</label></td>" +
138
+ "<td><input type='checkbox' class='option' data-mode='card' value='" + actionItems.cards[i].number + "'><label>" + actionItems.cards[i].number + "</label></td>" +
139
+ "<td><label>" + actionItems.cards[i].description + "</label></td></tr>";
140
+ $('#options').append(row)
141
+ }
142
+
143
+ $('.option').change(function() {
144
+
145
+ if ($(this).prop("checked") == true) {
146
+ if (selectedValue === undefined) {
147
+ selectedMode = $(this).data('mode');
148
+ selectedValue = $(this).val();
149
+ } else {
150
+ $(this).prop("checked", false)
151
+ alert("There can only be one checkbox selected!");
152
+ }
153
+ } else {
154
+ selectedMode = undefined;
155
+ selectedValue = undefined;
156
+ }
157
+
158
+ console.log('selectedMode: ' + selectedMode);
159
+ console.log('selectedValue: ' + selectedValue);
160
+ })
161
+ })
162
+
163
+ </script>
164
+ </body>
165
+ <footer>
166
+
167
+ <script>
168
+ var fz = new FatZebra({
169
+ username: 'TEST'
170
+ });
171
+
172
+ $('#doCheckout').click(function() {
173
+ if (selectedMode === undefined || selectedValue == undefined) {
174
+ alert('Please select an option.');
175
+ return
176
+ }
177
+
178
+ var paymentMethod = undefined;
179
+
180
+ if (selectedMode === 'card') {
181
+ paymentMethod = {
182
+ type: 'card',
183
+ data: {
184
+ number: selectedValue,
185
+ holder: 'John Doe',
186
+ expiryMonth: '01',
187
+ expiryYear: '2022',
188
+ cvv: '123'
189
+ }
190
+ }
191
+ } else {
192
+ paymentMethod = {
193
+ type: 'card_on_file',
194
+ data: {
195
+ token: selectedValue
196
+ }
197
+ }
198
+ }
199
+
200
+ function randomString(length) {
201
+ return Math.round((Math.pow(36, length + 1) - Math.random() * Math.pow(36, length))).toString(36).slice(1);
202
+ }
203
+
204
+ const reference = randomString(16);
205
+ const amount = 1200000;
206
+ const currency = 'AUD';
207
+ const message = [reference, amount, currency].join(':')
208
+ const verification = CryptoJS.HmacMD5(message, "033bd94b11").toString();
209
+
210
+ fz.verifyCard({
211
+ customer: {
212
+ firstName: 'Captain',
213
+ lastName: 'America',
214
+ email: 'sos@fatzebra.com.au',
215
+ address: '123 Get High Blvd.',
216
+ city: 'Red Light District',
217
+ postcode: '6666',
218
+ state: 'NSW',
219
+ country: 'Australia'
220
+ },
221
+ paymentIntent: {
222
+ payment: {
223
+ amount: amount,
224
+ currency: currency,
225
+ reference: reference
226
+ },
227
+ verification: verification
228
+ },
229
+ paymentMethod: paymentMethod
230
+ })
231
+ })
232
+
233
+ fz.on('fz.sca.error', function(event) {
234
+ console.log(JSON.stringify(event.detail))
235
+ })
236
+
237
+ fz.on('fz.sca.success', function(event) {
238
+ console.log(JSON.stringify(event.detail))
239
+ })
240
+
241
+ fz.on('fz.validation.error', function(event) {
242
+ console.log(JSON.stringify(event.detail))
243
+ })
244
+ </script>
245
+
246
+ </footer>
247
+ </html>
@@ -0,0 +1 @@
1
+ export declare const version = "1.5.2";
@@ -0,0 +1 @@
1
+ export const version = '1.5.2';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fat-zebra/sdk",
3
- "version": "1.5.1",
3
+ "version": "1.5.2",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -9,14 +9,15 @@
9
9
  "build:staging": "cp .env.staging .env && export ENVIRONMENT=staging && npx webpack --config webpack.config.dev.js && node build-styles.js",
10
10
  "build:sandbox": "cp .env.sandbox .env && export ENVIRONMENT=sandbox && npx webpack --config webpack.config.prod.js && node build-styles.js",
11
11
  "build:production": "cp .env.production .env && export ENVIRONMENT=production && npx webpack --config webpack.config.prod.js && node build-styles.js",
12
- "build:package": "yarn tsc -p tsconfig.package.json && node build-styles.js",
12
+ "build:package": "tsc -p tsconfig.package.json && ENVIRONMENT=production node build-styles.js",
13
13
  "start:local:api": "export MERCHANT_MODE=api && npm run build:local --watch && webpack serve --config webpack.config.dev.js --open 'Google Chrome'",
14
14
  "start:local:hpp": "export MERCHANT_MODE=hpp && npm run build:local --watch && webpack serve --config webpack.config.dev.js --open 'Google Chrome'",
15
15
  "start:staging:api": "export MERCHANT_MODE=api && npm run build:staging --watch && webpack serve --config webpack.config.dev.js --open 'Google Chrome'",
16
16
  "start:staging:hpp": "export MERCHANT_MODE=hpp && npm run build:staging --watch && webpack serve --config webpack.config.dev.js --open 'Google Chrome'",
17
17
  "start:staging:es5": "export MERCHANT_MODE=es5 && npm run build:staging --watch && webpack serve --config webpack.config.dev.js --open 'Google Chrome'",
18
18
  "start:docker": "npm run build:dev --watch && webpack serve --config webpack.config.dev.js --host 0.0.0.0",
19
- "generate:jwt": "node scripts/generate-access-token.js"
19
+ "generate:jwt": "node scripts/generate-access-token.js",
20
+ "npm:publish": "node scripts/release-package.js"
20
21
  },
21
22
  "keywords": [],
22
23
  "author": "",
@@ -30,7 +31,7 @@
30
31
  "@types/nock": "^11.1.0",
31
32
  "@types/react": "^18.2.15",
32
33
  "@types/react-dom": "^18.2.7",
33
- "audit-ci": "^3.0.0",
34
+ "audit-ci": "^6.6.1",
34
35
  "dotenv": "^16.0.1",
35
36
  "dotenv-webpack": "^8.0.0",
36
37
  "ejs": "^3.0.1",
@@ -52,7 +53,7 @@
52
53
  },
53
54
  "dependencies": {
54
55
  "ajv": "^6.12.3",
55
- "axios": "^0.21.1",
56
+ "axios": "^1.6.4",
56
57
  "custom-event-polyfill": "^1.0.7",
57
58
  "ts-polyfill": "^3.8.2",
58
59
  "url-template": "^3.1.0"
@@ -61,4 +62,4 @@
61
62
  "react": ">= 16",
62
63
  "react-dom": ">= 16"
63
64
  }
64
- }
65
+ }
@@ -0,0 +1,113 @@
1
+ const { execSync } = require('child_process');
2
+ const shell = process.env.SHELL;
3
+
4
+ const readline = require('node:readline').createInterface({
5
+ input: process.stdin,
6
+ output: process.stdout,
7
+ });
8
+ const fs = require('fs');
9
+ const path = require('path');
10
+ /**
11
+ * Builds and publishes to npm (for production)
12
+ *
13
+ */
14
+ function publish() {
15
+ console.log("running build...");
16
+ try {
17
+ // Running the command synchronously and inheriting the shell
18
+ execSync(`${shell} -c "npm run build:package && npm publish"`, { stdio: 'inherit' });
19
+ } catch (error) {
20
+ // This will catch any errors that occur during the execution of the command
21
+ console.error(`Execution error: ${error}`);
22
+ console.error(`stderr: ${error.stderr}`);
23
+ }
24
+ }
25
+
26
+ /**
27
+ * Writes version number to package.json and to another file to read from
28
+ *
29
+ * @param {string} path - path to where the file will be written (package.json | version.ts).
30
+ * @param {string} content - content of file (version number).
31
+ */
32
+ function writeToFile(path, content) {
33
+ fs.writeFileSync(path, content, 'utf8', (err) => {
34
+ if (err) {
35
+ console.error('Error writing version to file:', err);
36
+ } else {
37
+ console.log(`content: ${content} written to ${path}`);
38
+ }
39
+ });
40
+ }
41
+
42
+ /**
43
+ * take data from package.json and applies increment (depending on major/minor upgrade)
44
+ *
45
+ * @param {string} data - package.json data
46
+ * @param {string} releaseType - minor or major release
47
+ * @returns {Object|null} The updated package.json object with the incremented version, or null if parsing fails.
48
+ */
49
+ function increment(data, releaseType) {
50
+ let packageJson;
51
+ try {
52
+ packageJson = JSON.parse(data);
53
+ } catch (parseErr) {
54
+ console.error('Error parsing package.json:', parseErr);
55
+ return;
56
+ }
57
+
58
+ let [major, minor, patch] = packageJson.version.split('.').map(Number);
59
+
60
+ if (releaseType === 'minor') {
61
+ minor++;
62
+ patch = 0; // Reset patch version on minor update
63
+ } else {
64
+ patch++;
65
+ }
66
+
67
+ packageJson.version = [major, minor, patch].join('.');
68
+ return packageJson
69
+ }
70
+
71
+ /**
72
+ * Increments the version number in package.json based on the release type.
73
+ *
74
+ * @param {string} releaseType - The type of release (minor or patch).
75
+ */
76
+ function incrementAndPublish(releaseType) {
77
+ const packagePath = path.join(__dirname, '../package.json');
78
+ const versionPath = path.join(__dirname, '../src/version.ts')
79
+ fs.readFile(packagePath, 'utf8', (err, data) => {
80
+ if (err) {
81
+ console.error('Error reading package.json:', err);
82
+ return;
83
+ }
84
+
85
+ let packageJson = increment(data, releaseType)
86
+
87
+ writeToFile(packagePath, JSON.stringify(packageJson, null, 2))
88
+ const fileContent = `export const version = '${packageJson.version}';\n`;
89
+ writeToFile(versionPath, fileContent)
90
+ publish()
91
+ });
92
+ }
93
+
94
+ /**
95
+ * Asks the user whether the release is a minor release or a patch.
96
+ */
97
+ function askReleaseType() {
98
+ readline.question(`enter (y) for minor release or (n) for patch release `, releaseType => {
99
+ releaseType = releaseType.trim().toLowerCase();
100
+
101
+ if (releaseType === 'y') {
102
+ incrementAndPublish('minor');
103
+ } else if (releaseType === 'n') {
104
+ incrementAndPublish('patch');
105
+ } else {
106
+ console.log("Please answer 'y' (yes) or 'n' (no).");
107
+ askReleaseType(); // Recursively ask again if the input is not y/n
108
+ }
109
+ });
110
+ }
111
+
112
+ askReleaseType();
113
+
@@ -1,12 +0,0 @@
1
- import { Environment } from "../shared/env";
2
- import { OptionalUrlValues } from '../shared/types';
3
- type RequiredURLValues = {
4
- merchant: string;
5
- hash: string;
6
- reference: string;
7
- amount: number;
8
- currency: string;
9
- };
10
- type UrlValues = RequiredURLValues & OptionalUrlValues;
11
- declare const generatePaymentURL: (values: UrlValues, environment?: Environment) => string;
12
- export { generatePaymentURL };
package/dist/react/url.js DELETED
@@ -1,33 +0,0 @@
1
- import { parseTemplate } from 'url-template';
2
- import env, { Environment } from "../shared/env";
3
- const generatePaymentURL = (values, environment) => {
4
- const queryParts = [
5
- "tokenize_only",
6
- "css",
7
- "css_signature",
8
- "iframe",
9
- "postmessage",
10
- "hide_card_holder",
11
- "hide_button",
12
- "sca_enabled",
13
- ];
14
- const environmentConfig = env[environment || Environment.sandbox];
15
- const urlTemplate = parseTemplate(`${environmentConfig.payNowUrl}/sdk/v3/{merchant}/{reference}/{currency}/{amount}/{verification}{?${queryParts.join(",")}}`);
16
- const url = urlTemplate.expand({
17
- merchant: values.merchant,
18
- reference: values.reference,
19
- currency: values.currency,
20
- amount: values.amount,
21
- verification: values.hash,
22
- sca_enabled: values.sca_enabled,
23
- css: values.css,
24
- css_signature: values.css_signature,
25
- iframe: true,
26
- postmessage: true,
27
- tokenize_only: values.tokenize_only,
28
- hide_card_holder: values.hide_card_holder,
29
- hide_button: values.hide_button,
30
- });
31
- return url;
32
- };
33
- export { generatePaymentURL };
@@ -1,198 +0,0 @@
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
@@ -1 +0,0 @@
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,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