@fat-zebra/sdk 1.4.14 → 1.5.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.
Files changed (172) 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/CHANGELOG.md +13 -0
  5. package/README.dev.md +1 -14
  6. package/build-styles.js +12 -0
  7. package/dist/click_to_pay/index.d.ts +1 -1
  8. package/dist/click_to_pay/index.js +45 -1
  9. package/dist/fatzebra.css +91 -0
  10. package/dist/hpp/hpp.js +1 -3
  11. package/dist/local/fatzebra.js +18266 -0
  12. package/dist/local/fatzebra.js.map +1 -1
  13. package/dist/main.d.ts +2 -2
  14. package/dist/main.js +7 -21
  15. package/dist/react/VerifyCard.d.ts +2 -2
  16. package/dist/react/VerifyCard.js +4 -4
  17. package/dist/react/VerifyExistingCard.d.ts +10 -0
  18. package/dist/react/VerifyExistingCard.js +12 -0
  19. package/dist/react/index.d.ts +2 -1
  20. package/dist/react/index.js +2 -1
  21. package/dist/react/useFatZebra.d.ts +4 -2
  22. package/dist/react/useFatZebra.js +7 -7
  23. package/dist/react/verifyUrl.d.ts +8 -0
  24. package/dist/react/verifyUrl.js +22 -0
  25. package/dist/sca/cardinal.d.ts +11 -10
  26. package/dist/sca/cardinal.js +29 -8
  27. package/dist/sca/index.d.ts +3 -0
  28. package/dist/sca/index.js +53 -48
  29. package/dist/sca/types.d.ts +2 -2
  30. package/dist/shared/api-gateway-client.d.ts +4 -10
  31. package/dist/shared/api-gateway-client.js +12 -38
  32. package/dist/shared/env.d.ts +4 -0
  33. package/dist/shared/env.js +4 -0
  34. package/dist/shared/event-manager.d.ts +3 -1
  35. package/dist/shared/event-manager.js +7 -1
  36. package/dist/shared/post-message-client.d.ts +1 -0
  37. package/dist/shared/post-message-client.js +8 -13
  38. package/dist/shared/types.d.ts +8 -20
  39. package/dist/shared/types.js +4 -15
  40. package/dist/staging/fatzebra.css +91 -0
  41. package/dist/staging/fatzebra.js +18265 -0
  42. package/dist/staging/fatzebra.js.map +1 -0
  43. package/dist/staging/index.html +247 -0
  44. package/dist/validation/schemas/hpp-options.json +45 -93
  45. package/package.json +6 -7
  46. package/dist/production/fatzebra.js.LICENSE.txt +0 -1
  47. package/dist/src/applepay/applepay.js +0 -198
  48. package/dist/src/applepay/applepay.js.map +0 -1
  49. package/dist/src/applepay/clients/apple-pay-client.js +0 -66
  50. package/dist/src/applepay/clients/apple-pay-client.js.map +0 -1
  51. package/dist/src/applepay/clients/paynow-client.js +0 -96
  52. package/dist/src/applepay/clients/paynow-client.js.map +0 -1
  53. package/dist/src/applepay/index.js +0 -6
  54. package/dist/src/applepay/index.js.map +0 -1
  55. package/dist/src/click_to_pay/index.js +0 -88
  56. package/dist/src/click_to_pay/index.js.map +0 -1
  57. package/dist/src/click_to_pay/types.js +0 -3
  58. package/dist/src/click_to_pay/types.js.map +0 -1
  59. package/dist/src/hpp/hpp.js +0 -230
  60. package/dist/src/hpp/hpp.js.map +0 -1
  61. package/dist/src/hpp/hpp.test.js +0 -135
  62. package/dist/src/hpp/hpp.test.js.map +0 -1
  63. package/dist/src/hpp/index.js +0 -6
  64. package/dist/src/hpp/index.js.map +0 -1
  65. package/dist/src/index.js +0 -14
  66. package/dist/src/index.js.map +0 -1
  67. package/dist/src/main.js +0 -243
  68. package/dist/src/main.js.map +0 -1
  69. package/dist/src/main.test.js +0 -236
  70. package/dist/src/main.test.js.map +0 -1
  71. package/dist/src/paypal/paypal-button.js +0 -311
  72. package/dist/src/paypal/paypal-button.js.map +0 -1
  73. package/dist/src/paypal/paypal-button.test.js +0 -41
  74. package/dist/src/paypal/paypal-button.test.js.map +0 -1
  75. package/dist/src/paypal/paypal-checkout.js +0 -111
  76. package/dist/src/paypal/paypal-checkout.js.map +0 -1
  77. package/dist/src/paypal/paypal-checkout.test.js +0 -167
  78. package/dist/src/paypal/paypal-checkout.test.js.map +0 -1
  79. package/dist/src/paypal/types.js +0 -9
  80. package/dist/src/paypal/types.js.map +0 -1
  81. package/dist/src/paypal/validation.js +0 -73
  82. package/dist/src/paypal/validation.js.map +0 -1
  83. package/dist/src/react/VerifyCard.js +0 -29
  84. package/dist/src/react/VerifyCard.js.map +0 -1
  85. package/dist/src/react/index.js +0 -11
  86. package/dist/src/react/index.js.map +0 -1
  87. package/dist/src/react/submitForm.js +0 -13
  88. package/dist/src/react/submitForm.js.map +0 -1
  89. package/dist/src/react/url.js +0 -60
  90. package/dist/src/react/url.js.map +0 -1
  91. package/dist/src/react/url.test.js +0 -88
  92. package/dist/src/react/url.test.js.map +0 -1
  93. package/dist/src/react/useFatZebra.js +0 -119
  94. package/dist/src/react/useFatZebra.js.map +0 -1
  95. package/dist/src/sca/cardinal.js +0 -110
  96. package/dist/src/sca/cardinal.js.map +0 -1
  97. package/dist/src/sca/eci-mappings.js +0 -63
  98. package/dist/src/sca/eci-mappings.js.map +0 -1
  99. package/dist/src/sca/eci-mappings.test.js +0 -31
  100. package/dist/src/sca/eci-mappings.test.js.map +0 -1
  101. package/dist/src/sca/index.js +0 -363
  102. package/dist/src/sca/index.js.map +0 -1
  103. package/dist/src/sca/index.test.js +0 -620
  104. package/dist/src/sca/index.test.js.map +0 -1
  105. package/dist/src/sca/scenarios/enrollment.js +0 -161
  106. package/dist/src/sca/scenarios/enrollment.js.map +0 -1
  107. package/dist/src/sca/scenarios/index.js +0 -8
  108. package/dist/src/sca/scenarios/index.js.map +0 -1
  109. package/dist/src/sca/scenarios/validation.js +0 -139
  110. package/dist/src/sca/scenarios/validation.js.map +0 -1
  111. package/dist/src/sca/types.js +0 -57
  112. package/dist/src/sca/types.js.map +0 -1
  113. package/dist/src/shared/api-gateway-client.js +0 -184
  114. package/dist/src/shared/api-gateway-client.js.map +0 -1
  115. package/dist/src/shared/bridge-client.js +0 -24
  116. package/dist/src/shared/bridge-client.js.map +0 -1
  117. package/dist/src/shared/constants.js +0 -19
  118. package/dist/src/shared/constants.js.map +0 -1
  119. package/dist/src/shared/env.development.js +0 -12
  120. package/dist/src/shared/env.development.js.map +0 -1
  121. package/dist/src/shared/env.js +0 -46
  122. package/dist/src/shared/env.js.map +0 -1
  123. package/dist/src/shared/envs/local.js +0 -12
  124. package/dist/src/shared/envs/local.js.map +0 -1
  125. package/dist/src/shared/envs/production.js +0 -12
  126. package/dist/src/shared/envs/production.js.map +0 -1
  127. package/dist/src/shared/envs/sandbox.js +0 -12
  128. package/dist/src/shared/envs/sandbox.js.map +0 -1
  129. package/dist/src/shared/envs/staging.js +0 -12
  130. package/dist/src/shared/envs/staging.js.map +0 -1
  131. package/dist/src/shared/event-manager.js +0 -14
  132. package/dist/src/shared/event-manager.js.map +0 -1
  133. package/dist/src/shared/post-message-client.js +0 -107
  134. package/dist/src/shared/post-message-client.js.map +0 -1
  135. package/dist/src/shared/post-message-client.test.js +0 -58
  136. package/dist/src/shared/post-message-client.test.js.map +0 -1
  137. package/dist/src/shared/types.js +0 -47
  138. package/dist/src/shared/types.js.map +0 -1
  139. package/dist/src/shared/types.test.js +0 -55
  140. package/dist/src/shared/types.test.js.map +0 -1
  141. package/dist/src/shared/util.js +0 -96
  142. package/dist/src/shared/util.js.map +0 -1
  143. package/dist/src/shared/util.test.js +0 -148
  144. package/dist/src/shared/util.test.js.map +0 -1
  145. package/dist/src/validation/index.js +0 -12
  146. package/dist/src/validation/index.js.map +0 -1
  147. package/dist/src/validation/schemas/click-to-pay/load-params.json +0 -34
  148. package/dist/src/validation/schemas/click-to-pay/options.json +0 -23
  149. package/dist/src/validation/schemas/click-to-pay/payment-intent.json +0 -42
  150. package/dist/src/validation/schemas/customer.json +0 -38
  151. package/dist/src/validation/schemas/hpp-load-params.json +0 -40
  152. package/dist/src/validation/schemas/hpp-options.json +0 -48
  153. package/dist/src/validation/schemas/payment-intent.json +0 -48
  154. package/dist/src/validation/schemas/payment-method.json +0 -83
  155. package/dist/src/validation/schemas/verify-card-options.json +0 -15
  156. package/dist/src/validation/schemas/verify-card-params.json +0 -24
  157. package/dist/src/validation/validation-helper.js +0 -10
  158. package/dist/src/validation/validation-helper.js.map +0 -1
  159. package/dist/src/validation/validation-helper.test.js +0 -34
  160. package/dist/src/validation/validation-helper.test.js.map +0 -1
  161. package/dist/src/validation/validators/click-to-pay-load-params-validator.js +0 -19
  162. package/dist/src/validation/validators/click-to-pay-load-params-validator.js.map +0 -1
  163. package/dist/src/validation/validators/hpp-load-params-validator.js +0 -21
  164. package/dist/src/validation/validators/hpp-load-params-validator.js.map +0 -1
  165. package/dist/src/validation/validators/hpp-load-params-validator.test.js +0 -56
  166. package/dist/src/validation/validators/hpp-load-params-validator.test.js.map +0 -1
  167. package/dist/src/validation/validators/verify-card-params-validator.js +0 -23
  168. package/dist/src/validation/validators/verify-card-params-validator.js.map +0 -1
  169. package/dist/tests/helpers/api-gateway-mock.js +0 -37
  170. package/dist/tests/helpers/api-gateway-mock.js.map +0 -1
  171. /package/dist/react/{url.d.ts → paymentUrl.d.ts} +0 -0
  172. /package/dist/react/{url.js → paymentUrl.js} +0 -0
@@ -0,0 +1,12 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="WEB_MODULE" version="4">
3
+ <component name="NewModuleRootManager">
4
+ <content url="file://$MODULE_DIR$">
5
+ <excludeFolder url="file://$MODULE_DIR$/temp" />
6
+ <excludeFolder url="file://$MODULE_DIR$/.tmp" />
7
+ <excludeFolder url="file://$MODULE_DIR$/tmp" />
8
+ </content>
9
+ <orderEntry type="inheritedJdk" />
10
+ <orderEntry type="sourceFolder" forTests="false" />
11
+ </component>
12
+ </module>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/fatzebra-js.iml" filepath="$PROJECT_DIR$/.idea/fatzebra-js.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
package/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="" vcs="Git" />
5
+ </component>
6
+ </project>
package/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ # CHANGELOG
2
+
3
+ v1.2.1
4
+ * PAY-1731: Provide merchant username in API request headers.
5
+
6
+ v1.2.0
7
+ * FEAT-43: Emit HPP form validation error messages via events
8
+
9
+ v1.1.5
10
+ * PAY-1710: Update README and include jwt generation script
11
+
12
+ v1.1.4 (Rolled back. Scheduled for later release.)
13
+ * PAY-1568: Conditionally require customer object depending on enableSca
package/README.dev.md CHANGED
@@ -109,19 +109,6 @@ Visit https://fzapplepay.ngrok.io in Safari. That's all!
109
109
 
110
110
  Webpack-dev-server supports hot reloading, meaning that code changes are reflected on the web page without restarting the server.
111
111
 
112
- ## PayPal
113
-
114
- You can build & run for PayPal integration using:
115
- ```bash
116
- npm run start:dev:paypal
117
- ```
118
-
119
- You can also change the order request in:
120
- ```bash
121
- # Change the `data` argument in the `paymentMethod` field
122
- examples/paypal/merchant.ejs
123
- ```
124
-
125
112
  ## Build Javascript
126
113
 
127
114
  There are two npm build scripts in `package.json` for building javascript files.
@@ -159,4 +146,4 @@ The release of the sdk follows a weekly schedule. In the beginning of a new rele
159
146
  10. Prepare a new git tag for the new release version `git tag -a vX.X.X`.
160
147
  11. Push git tag. `git push origin vX.X.X`.
161
148
 
162
- Upon successful CI , a new entry with title 'Merged in release/vX.X,X' will be visible in the master branch page. This provides us with a clear view of what gets released in the past. Moreoever, we can quickly find out the list of features/bug fixes in a release by referring to the PR of the release candidate.
149
+ Upon successful CI , a new entry with title 'Merged in release/vX.X,X' will be visible in the master branch page. This provides us with a clear view of what gets released in the past. Moreoever, we can quickly find out the list of features/bug fixes in a release by referring to the PR of the release candidate.
@@ -0,0 +1,12 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
4
+ // Define the source file and the destination folder
5
+ const sourceFile = path.join(__dirname, './src/styles.css');
6
+ const destinationFolder = path.join(__dirname, 'dist/' + process.env.ENVIRONMENT);
7
+ const destinationFile = path.join(destinationFolder, 'fatzebra.css');
8
+
9
+ // Copy the file
10
+ fs.copyFileSync(sourceFile, destinationFile);
11
+
12
+ console.log('File copied successfully!');
@@ -14,7 +14,6 @@ declare class ClickToPay {
14
14
  private iframe;
15
15
  private paymentIntent;
16
16
  private username;
17
- private cardToken;
18
17
  private postMessageClient;
19
18
  private test;
20
19
  private options;
@@ -23,6 +22,7 @@ declare class ClickToPay {
23
22
  getPayNowUrl(options?: {
24
23
  [key: string]: boolean | string;
25
24
  }): string;
25
+ setCrossFramesEventListeners(): void;
26
26
  purchase(): void;
27
27
  }
28
28
  export default ClickToPay;
@@ -1,13 +1,20 @@
1
- import { BridgeEvent } from "../shared/types";
1
+ import { PostMessageClient } from "../shared/post-message-client";
2
+ import { BridgeEvent, PublicEvent } from "../shared/types";
2
3
  import * as util from '../shared/util';
4
+ import { emit } from "../shared/event-manager";
3
5
  const CLICK_TO_PAY_DEFAULT_OPTIONS = {
4
6
  iframe: true,
7
+ postmessage: true,
5
8
  };
6
9
  class ClickToPay {
7
10
  constructor(config) {
8
11
  this.paymentIntent = config.paymentIntent;
9
12
  this.username = config.username;
10
13
  this.test = config.test;
14
+ this.postMessageClient = new PostMessageClient({
15
+ channel: 'click_to_pay',
16
+ target: this.iframe
17
+ });
11
18
  }
12
19
  load(config) {
13
20
  this.options = config.options;
@@ -15,6 +22,9 @@ class ClickToPay {
15
22
  document.getElementById(config.containerId).appendChild(this.iframe);
16
23
  const payNowUrl = this.getPayNowUrl(config.options);
17
24
  this.iframe.setAttribute("src", payNowUrl);
25
+ this.iframe.onload = () => {
26
+ this.setCrossFramesEventListeners();
27
+ };
18
28
  }
19
29
  getPayNowUrl(options) {
20
30
  const { payment } = this.paymentIntent;
@@ -38,6 +48,40 @@ class ClickToPay {
38
48
  let searchParams = new URLSearchParams(queryString);
39
49
  return queryString ? `${base}?${searchParams.toString()}` : `${base}`;
40
50
  }
51
+ setCrossFramesEventListeners() {
52
+ const handlers = {};
53
+ handlers[BridgeEvent.TOKENIZE_CARD_RESPONSE] = (data) => {
54
+ console.log(data);
55
+ if (data.errors) {
56
+ emit(PublicEvent.TOKENIZATION_ERROR, {
57
+ message: 'Card tokenization failed.',
58
+ errors: data.errors,
59
+ data: null,
60
+ });
61
+ return;
62
+ }
63
+ else {
64
+ emit(PublicEvent.TOKENIZATION_SUCCESS, {
65
+ message: 'Card tokenization success.',
66
+ data
67
+ });
68
+ }
69
+ };
70
+ handlers[PublicEvent.CLICK_TO_PAY_TOKENIZATION_ERROR] = (data) => {
71
+ emit(PublicEvent.CLICK_TO_PAY_TOKENIZATION_ERROR, {
72
+ message: 'Card tokenization failed.',
73
+ errors: data.errors,
74
+ data: null,
75
+ });
76
+ };
77
+ handlers[PublicEvent.CLICK_TO_PAY_TOKENIZATION_SUCCESS] = (data) => {
78
+ emit(PublicEvent.CLICK_TO_PAY_TOKENIZATION_SUCCESS, {
79
+ message: 'Card tokenization success.',
80
+ data
81
+ });
82
+ };
83
+ this.postMessageClient.setEventListeners(handlers);
84
+ }
41
85
  purchase() {
42
86
  const message = {
43
87
  channel: 'click_to_pay',
@@ -0,0 +1,91 @@
1
+ .checkout-button-wrapper {
2
+ display: flex;
3
+ justify-content: center;
4
+ align-items: center;
5
+ height: 200px;
6
+ }
7
+
8
+ .iframe-checkout {
9
+ flex: 1;
10
+ border: none;
11
+ width: 100%;
12
+ height: 100%;
13
+ min-height: 0;
14
+ overflow: auto;
15
+ -webkit-overflow-scrolling: touch;
16
+ }
17
+
18
+ .iframe-foreground,
19
+ .iframe-background {
20
+ top: 0;
21
+ left: 0;
22
+ right: 0;
23
+ bottom: 0;
24
+ flex-direction: column;
25
+ }
26
+
27
+ .iframe-foreground,
28
+ .iframe-background {
29
+ position: fixed;
30
+ }
31
+
32
+ .iframe-foreground {
33
+ z-index: -1;
34
+ }
35
+
36
+ .iframe-background {
37
+ background: rgba(0, 0, 0, 0.5);
38
+ }
39
+
40
+ .iframe-foreground {
41
+ flex-grow: 1;
42
+ top: auto;
43
+ width: 100%;
44
+ max-width: 480px;
45
+ height: 80vh;
46
+ background-color: #ffffff;
47
+ border-radius: 25px 25px 0 0;
48
+ }
49
+
50
+ .slide-in .iframe-foreground {
51
+ transform: translateY(100vh);
52
+ transition: transform 0.4s ease, z-index 0.3s ease 0.4s;
53
+ z-index: -1;
54
+ }
55
+
56
+ .slide-in .iframe-background {
57
+ opacity: 0;
58
+ z-index: -1;
59
+ transition: opacity 0.3s ease, z-index 0.3s ease 0.3s;
60
+ }
61
+
62
+ .slide-in.show .iframe-foreground {
63
+ transform: none;
64
+ transition: transform 0.4s ease;
65
+ z-index: 100;
66
+ }
67
+
68
+ .slide-in.show .iframe-background {
69
+ opacity: 1;
70
+ z-index: 0;
71
+ transition: opacity 0.3s ease;
72
+ }
73
+
74
+ @media only screen and (min-width: 480px) {
75
+ .iframe-foreground {
76
+ margin: 0 auto;
77
+ }
78
+ }
79
+
80
+ @media only screen and (min-width: 768px) {
81
+ .iframe-foreground {
82
+ margin: 0;
83
+ width: 400px;
84
+ height: 100vh;
85
+ left: 0;
86
+ }
87
+
88
+ .slide-in .iframe-foreground {
89
+ transform: translateX(-400px);
90
+ }
91
+ }
package/dist/hpp/hpp.js CHANGED
@@ -82,9 +82,7 @@ class Hpp {
82
82
  else {
83
83
  emit(PublicEvent.TOKENIZATION_SUCCESS, {
84
84
  message: 'Card tokenization success.',
85
- data: {
86
- token: data.token
87
- }
85
+ data
88
86
  });
89
87
  }
90
88
  // Required for payment later