@fat-zebra/sdk 1.5.5 → 1.5.7-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.
Files changed (116) hide show
  1. package/.idea/fatzebra-js.iml +12 -0
  2. package/.idea/modules.xml +8 -0
  3. package/.idea/prettier.xml +6 -0
  4. package/.idea/vcs.xml +6 -0
  5. package/dist/applepay/applepay.d.ts +22 -7
  6. package/dist/applepay/applepay.js +99 -21
  7. package/dist/applepay/applepaymanager.d.ts +28 -0
  8. package/dist/applepay/applepaymanager.js +115 -0
  9. package/dist/applepay/clients/apple-pay-client.d.ts +9 -5
  10. package/dist/applepay/clients/apple-pay-client.js +10 -4
  11. package/dist/applepay/clients/paynow-client.d.ts +4 -2
  12. package/dist/applepay/clients/paynow-client.js +2 -7
  13. package/dist/applepay/types.d.ts +15 -0
  14. package/dist/applepay/types.js +1 -0
  15. package/dist/click_to_pay/index.d.ts +1 -0
  16. package/dist/click_to_pay/index.js +42 -6
  17. package/dist/click_to_pay/types.d.ts +12 -2
  18. package/dist/fatzebra.css +91 -0
  19. package/dist/hpp/hpp.d.ts +4 -0
  20. package/dist/hpp/hpp.js +26 -5
  21. package/dist/local/fatzebra.js +19684 -0
  22. package/dist/local/fatzebra.js.map +1 -1
  23. package/dist/main.d.ts +2 -0
  24. package/dist/main.js +24 -2
  25. package/dist/production/fatzebra.css +91 -0
  26. package/dist/production/fatzebra.js +2 -0
  27. package/dist/react/ApplePay.d.ts +9 -0
  28. package/dist/react/ApplePay.js +11 -0
  29. package/dist/react/ApplePayButton.d.ts +8 -0
  30. package/dist/react/ApplePayButton.js +18 -0
  31. package/dist/react/{url.d.ts → applePayUrl.d.ts} +2 -2
  32. package/dist/react/applePayUrl.js +19 -0
  33. package/dist/react/index.d.ts +2 -1
  34. package/dist/react/index.js +2 -1
  35. package/dist/react/useFatZebra.js +8 -57
  36. package/dist/react/useMessage.d.ts +10 -0
  37. package/dist/react/useMessage.js +70 -0
  38. package/dist/sandbox/fatzebra.css +91 -0
  39. package/dist/sandbox/fatzebra.js +2 -0
  40. package/dist/sandbox/fatzebra.js.LICENSE.txt +1 -0
  41. package/dist/sca/cardinal.d.ts +2 -11
  42. package/dist/sca/cardinal.js +4 -10
  43. package/dist/sca/index.d.ts +11 -1
  44. package/dist/sca/index.js +3 -38
  45. package/dist/sca/scenarios/enrollment.js +12 -0
  46. package/dist/sca/types/cardinal_types.d.ts +61 -0
  47. package/dist/sca/types/cardinal_types.js +11 -0
  48. package/dist/sca/types.d.ts +4 -1
  49. package/dist/sca/types.js +1 -0
  50. package/dist/sca/utility/index.d.ts +7 -0
  51. package/dist/sca/utility/index.js +39 -0
  52. package/dist/shared/bridge-client.d.ts +5 -1
  53. package/dist/shared/bridge-client.js +19 -1
  54. package/dist/shared/env.development.d.ts +3 -3
  55. package/dist/shared/env.development.js +3 -3
  56. package/dist/shared/envs/local.d.ts +3 -3
  57. package/dist/shared/envs/local.js +3 -3
  58. package/dist/shared/event-manager.d.ts +1 -1
  59. package/dist/shared/post-message-client.d.ts +2 -0
  60. package/dist/shared/post-message-client.js +1 -1
  61. package/dist/shared/types.d.ts +28 -13
  62. package/dist/shared/types.js +11 -1
  63. package/dist/src/applepay/applepaymanager.js +279 -0
  64. package/dist/src/applepay/applepaymanager.js.map +1 -0
  65. package/dist/src/react/ApplePayButton.js +56 -0
  66. package/dist/src/react/ApplePayButton.js.map +1 -0
  67. package/dist/src/react/{url.js → applePayUrl.js} +7 -21
  68. package/dist/src/react/applePayUrl.js.map +1 -0
  69. package/dist/src/react/applePayUrl.test.js +57 -0
  70. package/dist/src/react/applePayUrl.test.js.map +1 -0
  71. package/dist/src/react/useFatZebra.js +7 -56
  72. package/dist/src/react/useFatZebra.js.map +1 -1
  73. package/dist/src/react/useMessage.js +140 -0
  74. package/dist/src/react/useMessage.js.map +1 -0
  75. package/dist/src/react/useMessage.test.js +222 -0
  76. package/dist/src/react/useMessage.test.js.map +1 -0
  77. package/dist/src/validation/validators/apple-pay-load-params-button-validator.js +19 -0
  78. package/dist/src/validation/validators/apple-pay-load-params-button-validator.js.map +1 -0
  79. package/dist/staging/fatzebra.css +91 -0
  80. package/dist/staging/fatzebra.js +19684 -0
  81. package/dist/staging/fatzebra.js.map +1 -0
  82. package/dist/staging/index.html +247 -0
  83. package/dist/validation/schemas/applepay/load-params.json +31 -0
  84. package/dist/validation/schemas/applepay/options.json +115 -0
  85. package/dist/validation/schemas/applepay/payment-intent.json +42 -0
  86. package/dist/validation/schemas/click-to-pay/options.json +33 -3
  87. package/dist/validation/validators/apple-pay-load-params-button-validator.d.ts +3 -0
  88. package/dist/validation/validators/apple-pay-load-params-button-validator.js +12 -0
  89. package/dist/version.d.ts +1 -1
  90. package/dist/version.js +1 -1
  91. package/package.json +4 -3
  92. package/tsconfig.json +1 -1
  93. package/dist/paypal/paypal-button.d.ts +0 -31
  94. package/dist/paypal/paypal-button.js +0 -199
  95. package/dist/paypal/paypal-checkout.d.ts +0 -21
  96. package/dist/paypal/paypal-checkout.js +0 -100
  97. package/dist/paypal/types.d.ts +0 -188
  98. package/dist/paypal/types.js +0 -5
  99. package/dist/paypal/validation.d.ts +0 -4
  100. package/dist/paypal/validation.js +0 -65
  101. package/dist/react/url.js +0 -33
  102. package/dist/src/paypal/paypal-button.js +0 -311
  103. package/dist/src/paypal/paypal-button.js.map +0 -1
  104. package/dist/src/paypal/paypal-button.test.js +0 -41
  105. package/dist/src/paypal/paypal-button.test.js.map +0 -1
  106. package/dist/src/paypal/paypal-checkout.js +0 -111
  107. package/dist/src/paypal/paypal-checkout.js.map +0 -1
  108. package/dist/src/paypal/paypal-checkout.test.js +0 -167
  109. package/dist/src/paypal/paypal-checkout.test.js.map +0 -1
  110. package/dist/src/paypal/types.js +0 -9
  111. package/dist/src/paypal/types.js.map +0 -1
  112. package/dist/src/paypal/validation.js +0 -73
  113. package/dist/src/paypal/validation.js.map +0 -1
  114. package/dist/src/react/url.js.map +0 -1
  115. package/dist/src/react/url.test.js +0 -88
  116. package/dist/src/react/url.test.js.map +0 -1
@@ -0,0 +1 @@
1
+ /** @license URI.js v4.2.1 (c) 2011 Gary Court. License: http://github.com/garycourt/uri-js */
@@ -1,14 +1,4 @@
1
- interface CardinalSetupCompleteResponseData {
2
- sessionId: string;
3
- modules: {
4
- module: string;
5
- loaded: boolean;
6
- }[];
7
- }
8
- interface PaymentValidatedDTO {
9
- processorTransactionId: string;
10
- jwt: string;
11
- }
1
+ import { CardinalSetupCompleteResponseData, PaymentValidatedDTO } from "./types/cardinal_types";
12
2
  export declare const defaultConfig: {
13
3
  timeout: number;
14
4
  maxRequestRetries: number;
@@ -24,6 +14,7 @@ export default class CardinalManager {
24
14
  onPaymentValidated(handler: (data: PaymentValidatedDTO, error: string) => void): void;
25
15
  onPaymentSetupComplete(callback: (data: CardinalSetupCompleteResponseData) => void): void;
26
16
  processBin(bin: string): Promise<any>;
17
+ trigger(event: string, bin: string): Promise<void>;
27
18
  continue(acsUrl: string, pareq: string, transactionId: string): void;
28
19
  }
29
20
  export { CardinalManager, };
@@ -7,16 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- var CardinalWorkflow;
11
- (function (CardinalWorkflow) {
12
- CardinalWorkflow["CCA"] = "cca";
13
- CardinalWorkflow["INIT"] = "init";
14
- })(CardinalWorkflow || (CardinalWorkflow = {}));
15
- var CardinalPaymentEvent;
16
- (function (CardinalPaymentEvent) {
17
- CardinalPaymentEvent["SETUP_COMPLETE"] = "payments.setupComplete";
18
- CardinalPaymentEvent["VALIDATED"] = "payments.validated";
19
- })(CardinalPaymentEvent || (CardinalPaymentEvent = {}));
10
+ import { CardinalPaymentEvent, CardinalWorkflow } from "./types/cardinal_types";
20
11
  export const defaultConfig = {
21
12
  timeout: 8000,
22
13
  maxRequestRetries: 3,
@@ -77,6 +68,9 @@ export default class CardinalManager {
77
68
  yield window.Cardinal.trigger('bin.process', bin);
78
69
  });
79
70
  }
71
+ trigger(event, bin) {
72
+ return window.Cardinal.trigger('bin.process', bin);
73
+ }
80
74
  continue(acsUrl, pareq, transactionId) {
81
75
  window.Cardinal.continue(CardinalWorkflow.CCA, {
82
76
  AcsUrl: acsUrl,
@@ -1,5 +1,5 @@
1
1
  import * as t from './types';
2
- import { EventCallback, Customer, CustomerSnakeCase, PaymentIntent } from '../shared/types';
2
+ import { EventCallback, Customer, PaymentIntent } from '../shared/types';
3
3
  import { CardinalManager } from './cardinal';
4
4
  import GatewayClient from '../shared/api-gateway-client';
5
5
  import { Environment } from "../shared/env";
@@ -10,6 +10,16 @@ export interface ScaRunProps {
10
10
  bin: string;
11
11
  challengeWindowSize?: t.ChallengeWindowSize;
12
12
  }
13
+ interface CustomerSnakeCase {
14
+ first_name?: string;
15
+ last_name?: string;
16
+ email?: string;
17
+ address?: string;
18
+ city?: string;
19
+ state?: string;
20
+ postcode?: string;
21
+ country?: string;
22
+ }
13
23
  export interface ScaConfig {
14
24
  gatewayClient: GatewayClient;
15
25
  successCallback?: EventCallback | null;
package/dist/sca/index.js CHANGED
@@ -8,14 +8,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import * as t from './types';
11
- import { enrollmentScenarios, validationScenarios, } from './scenarios';
12
11
  import { PublicEvent, } from '../shared/types';
13
12
  import { CardinalManager, } from './cardinal';
14
13
  import { emit, } from '../shared/event-manager';
15
- import { toFzSli } from './eci-mappings';
16
14
  import env, { Environment } from "../shared/env";
17
- import { failedEnrollmentRequestScenario } from './scenarios/enrollment';
18
- import { failedValidationRequestScenario } from './scenarios/validation';
15
+ import { getEnrollmentResult, getValidationResult, threedsResponseData } from "./utility";
19
16
  class Sca {
20
17
  constructor({ gatewayClient, successCallback, failureCallback }) {
21
18
  this.gatewayClient = gatewayClient;
@@ -178,6 +175,8 @@ class Sca {
178
175
  session_id: this.sessionId,
179
176
  challenge_window_size: this.challengeWindowSize,
180
177
  hide_card_holder: this.paymentIntent.payment.hide_card_holder,
178
+ screen_height: window.screen.height,
179
+ screen_width: window.screen.width,
181
180
  customer: this.customerProperties(this.customer),
182
181
  })).data;
183
182
  });
@@ -221,38 +220,4 @@ class Sca {
221
220
  }
222
221
  }
223
222
  }
224
- const threedsResponseData = (response) => {
225
- return {
226
- // CAVV: Visa & Amex only
227
- // AAV: Mastercard only, known as UCAF
228
- cavv: response.cavv || response.aav,
229
- par: response.pares,
230
- sli: toFzSli(response.eci),
231
- xid: response.xid,
232
- ver: response.enrolled,
233
- directoryServerTxnId: response.directory_server_txn_id,
234
- threedsVersion: response.version,
235
- };
236
- };
237
- const getEnrollmentResult = (enrollment) => {
238
- const result = enrollmentScenarios.find((item) => {
239
- return item.reasonCode === enrollment.reason_code &&
240
- item.veresEnrolled === enrollment.enrolled &&
241
- item.pares === enrollment.pares &&
242
- item.threedsVersion === getMajor3dsVersion(enrollment.version);
243
- });
244
- return result || failedEnrollmentRequestScenario;
245
- };
246
- const getValidationResult = (validation) => {
247
- const result = validationScenarios.find((item) => {
248
- return item.reasonCode === validation.reason_code &&
249
- item.pares === validation.pares &&
250
- item.threedsVersion === getMajor3dsVersion(validation.version);
251
- });
252
- return result || failedValidationRequestScenario;
253
- };
254
- // 3DS versioning follows SEMVER format. The first charactor is the major version number.
255
- const getMajor3dsVersion = (original) => {
256
- return original === null || original === void 0 ? void 0 : original[0];
257
- };
258
223
  export default Sca;
@@ -87,6 +87,18 @@ const enrollmentScenarios = [
87
87
  success: true
88
88
  }
89
89
  },
90
+ {
91
+ // Challenge. Continue with OTP prompt
92
+ description: 'Challenge. Continue with OTP prompt',
93
+ threedsVersion: '2',
94
+ reasonCode: '475',
95
+ veresEnrolled: VEResEnrolled.ENROLLED,
96
+ pares: PARes.CHALLENGED,
97
+ outcome: {
98
+ authenticationType: 'challenge',
99
+ success: true
100
+ }
101
+ },
90
102
  {
91
103
  // Unsuccessful Frictionless Authentication
92
104
  description: 'Unsuccessful Frictionless Authentication',
@@ -0,0 +1,61 @@
1
+ interface CardinalConfig {
2
+ timeout?: number;
3
+ maxRequestRetries?: number;
4
+ logging?: {
5
+ level: 'on' | 'off' | 'verbose';
6
+ };
7
+ }
8
+ interface CardinalContinueObject {
9
+ AcsUrl: string;
10
+ Payload: string;
11
+ }
12
+ interface CardinalOrderObject {
13
+ OrderDetails: {
14
+ TransactionId: string;
15
+ };
16
+ }
17
+ interface CardinalSetupCompleteResponseData {
18
+ sessionId: string;
19
+ modules: {
20
+ module: string;
21
+ loaded: boolean;
22
+ }[];
23
+ }
24
+ interface PaymentValidatedResponseData {
25
+ Validated: boolean;
26
+ ErrorNumber: number;
27
+ ErrorDescription: string;
28
+ ActionCode: 'SUCCESS' | 'NOACTION' | 'FAILURE' | 'ERROR';
29
+ Payment: {
30
+ OrderId: string;
31
+ OrderNumber: string;
32
+ ProcessorTransactionId: string;
33
+ ReasonDescription: string;
34
+ };
35
+ }
36
+ interface PaymentValidatedDTO {
37
+ processorTransactionId: string;
38
+ jwt: string;
39
+ }
40
+ interface Cardinal {
41
+ configure(config: CardinalConfig): void;
42
+ continue(workflow: CardinalWorkflow, data: CardinalContinueObject, order: CardinalOrderObject): void;
43
+ on(event: string, callback: (...data: any[]) => void): void;
44
+ setup(workflow: CardinalWorkflow, data: any): void;
45
+ trigger(event: string, cardBin: string): Promise<any>;
46
+ }
47
+ interface ScaResult {
48
+ success: boolean;
49
+ type: 'frictionless' | 'challenge' | 'none';
50
+ error: string;
51
+ }
52
+ declare enum CardinalWorkflow {
53
+ CCA = "cca",
54
+ INIT = "init"
55
+ }
56
+ declare enum CardinalPaymentEvent {
57
+ SETUP_COMPLETE = "payments.setupComplete",
58
+ VALIDATED = "payments.validated"
59
+ }
60
+ export { CardinalWorkflow, CardinalPaymentEvent };
61
+ export type { CardinalConfig, CardinalContinueObject, CardinalOrderObject, CardinalSetupCompleteResponseData, PaymentValidatedResponseData, PaymentValidatedDTO, Cardinal, ScaResult, };
@@ -0,0 +1,11 @@
1
+ var CardinalWorkflow;
2
+ (function (CardinalWorkflow) {
3
+ CardinalWorkflow["CCA"] = "cca";
4
+ CardinalWorkflow["INIT"] = "init";
5
+ })(CardinalWorkflow || (CardinalWorkflow = {}));
6
+ var CardinalPaymentEvent;
7
+ (function (CardinalPaymentEvent) {
8
+ CardinalPaymentEvent["SETUP_COMPLETE"] = "payments.setupComplete";
9
+ CardinalPaymentEvent["VALIDATED"] = "payments.validated";
10
+ })(CardinalPaymentEvent || (CardinalPaymentEvent = {}));
11
+ export { CardinalWorkflow, CardinalPaymentEvent };
@@ -40,6 +40,8 @@ interface EnrollSCARequest {
40
40
  session_id: string;
41
41
  challenge_window_size: ChallengeWindowSize;
42
42
  hide_card_holder: boolean;
43
+ screen_height: number;
44
+ screen_width: number;
43
45
  customer?: {
44
46
  first_name?: string;
45
47
  last_name?: string;
@@ -103,7 +105,8 @@ declare enum PARes {
103
105
  CANCELED = "N",
104
106
  REJECTED = "R",
105
107
  NOT_COMPLETED = "U",
106
- SUCCESS = "Y"
108
+ SUCCESS = "Y",
109
+ CHALLENGED = "C"
107
110
  }
108
111
  interface ValidateSCARequest {
109
112
  amount: number;
package/dist/sca/types.js CHANGED
@@ -50,5 +50,6 @@ var PARes;
50
50
  PARes["REJECTED"] = "R";
51
51
  PARes["NOT_COMPLETED"] = "U";
52
52
  PARes["SUCCESS"] = "Y";
53
+ PARes["CHALLENGED"] = "C";
53
54
  })(PARes || (PARes = {}));
54
55
  export { ScaErrorCode, ChallengeWindowSize, CommerceIndicator, VEResEnrolled, PARes, };
@@ -0,0 +1,7 @@
1
+ import * as t from "../types";
2
+ import { ThreedsData } from "../types";
3
+ import { EnrollmentScenario, ValidationScenario } from "../scenarios";
4
+ declare const threedsResponseData: (response: t.EnrollSCAResponse | t.ValidateSCAResponse) => ThreedsData;
5
+ declare const getEnrollmentResult: (enrollment: t.EnrollSCAResponse) => EnrollmentScenario;
6
+ declare const getValidationResult: (validation: t.ValidateSCAResponse) => ValidationScenario;
7
+ export { threedsResponseData, getValidationResult, getEnrollmentResult };
@@ -0,0 +1,39 @@
1
+ import { toFzSli } from "../eci-mappings";
2
+ import { enrollmentScenarios, validationScenarios } from "../scenarios";
3
+ import { failedEnrollmentRequestScenario } from "../scenarios/enrollment";
4
+ import { failedValidationRequestScenario } from "../scenarios/validation";
5
+ const threedsResponseData = (response) => {
6
+ return {
7
+ // CAVV: Visa & Amex only
8
+ // AAV: Mastercard only, known as UCAF
9
+ cavv: response.cavv || response.aav,
10
+ par: response.pares,
11
+ sli: toFzSli(response.eci),
12
+ xid: response.xid,
13
+ ver: response.enrolled,
14
+ directoryServerTxnId: response.directory_server_txn_id,
15
+ threedsVersion: response.version,
16
+ };
17
+ };
18
+ const getEnrollmentResult = (enrollment) => {
19
+ const result = enrollmentScenarios.find((item) => {
20
+ return item.reasonCode === enrollment.reason_code &&
21
+ item.veresEnrolled === enrollment.enrolled &&
22
+ item.pares === enrollment.pares &&
23
+ item.threedsVersion === getMajor3dsVersion(enrollment.version);
24
+ });
25
+ return result || failedEnrollmentRequestScenario;
26
+ };
27
+ const getValidationResult = (validation) => {
28
+ const result = validationScenarios.find((item) => {
29
+ return item.reasonCode === validation.reason_code &&
30
+ item.pares === validation.pares &&
31
+ item.threedsVersion === getMajor3dsVersion(validation.version);
32
+ });
33
+ return result || failedValidationRequestScenario;
34
+ };
35
+ // 3DS versioning follows SEMVER format. The first charactor is the major version number.
36
+ const getMajor3dsVersion = (original) => {
37
+ return original === null || original === void 0 ? void 0 : original[0];
38
+ };
39
+ export { threedsResponseData, getValidationResult, getEnrollmentResult };
@@ -1,2 +1,6 @@
1
1
  declare const load: (url: string) => HTMLIFrameElement;
2
- export { load };
2
+ declare const load2: (url: string) => {
3
+ el: HTMLIFrameElement;
4
+ isExisting: boolean;
5
+ };
6
+ export { load, load2 };
@@ -17,4 +17,22 @@ const load = (url) => {
17
17
  document.body.appendChild(headless);
18
18
  return headless;
19
19
  };
20
- export { load };
20
+ const load2 = (url) => {
21
+ const existing = document.getElementById(headlessIframeId);
22
+ if (existing) {
23
+ return { el: existing, isExisting: true };
24
+ }
25
+ const headless = document.createElement('iframe');
26
+ headless.style.visibility = 'hidden';
27
+ headless.style.position = 'absolute';
28
+ headless.style.left = '0px';
29
+ headless.style.top = '0px';
30
+ headless.style.height = '0px';
31
+ headless.style.width = '0px';
32
+ headless.style.border = 'none';
33
+ headless.setAttribute('src', url);
34
+ headless.setAttribute('id', headlessIframeId);
35
+ document.body.appendChild(headless);
36
+ return { el: headless, isExisting: false };
37
+ };
38
+ export { load, load2 };
@@ -1,5 +1,5 @@
1
- declare const bridgeUrl = "http://paynow.test";
2
- declare const apiUrl = "http://api.test:3002/sdk";
3
- declare const payNowUrl = "http://paynow.test:3004";
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 = "http://paynow.test";
2
- const apiUrl = "http://api.test:3002/sdk";
3
- const payNowUrl = "http://paynow.test:3004";
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 = "http://paynow.test";
2
- declare const apiUrl = "http://api.test:3002/sdk";
3
- declare const payNowUrl = "http://paynow.test:3004";
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 = "http://paynow.test";
2
- const apiUrl = "http://api.test:3002/sdk";
3
- const payNowUrl = "http://paynow.test:3004";
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 };
@@ -23,7 +23,7 @@ interface ErrorEventDetail {
23
23
  errors: string[];
24
24
  data: any;
25
25
  }
26
- declare const emit: (event: PublicEvent, data: SuccessEventDetail | ErrorEventDetail, target?: HTMLElement | Window) => void;
26
+ declare const emit: (event: PublicEvent, data?: SuccessEventDetail | ErrorEventDetail, target?: HTMLElement | Window) => void;
27
27
  declare const off: (event: PublicEvent, callback: (e: any) => void, target?: HTMLElement | Window) => void;
28
28
  declare const onOnce: (event: PublicEvent, callback: (e: any) => void, target?: HTMLElement | Window) => void;
29
29
  declare const on: (event: PublicEvent, callback: (e: any) => void, target?: HTMLElement | Window) => void;
@@ -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
  }
@@ -1,5 +1,10 @@
1
1
  import { Environment } from './env';
2
+ import { MerchantCapability, SupportedNetwork } from "../applepay/clients/apple-pay-client";
3
+ declare enum Channel {
4
+ CLICK_TO_PAY = "click_to_pay"
5
+ }
2
6
  declare enum PublicEvent {
7
+ HPP_READY = "fz.ready",
3
8
  FORM_VALIDATION_ERROR = "fz.form_validation.error",
4
9
  FORM_VALIDATION_SUCCESS = "fz.form_validation.success",
5
10
  VALIDATION_ERROR = "fz.validation.error",
@@ -11,7 +16,12 @@ declare enum PublicEvent {
11
16
  PAYMENT_ERROR = "fz.payment.error",
12
17
  BIN_LOOKUP = "fz.bin.lookup",
13
18
  CLICK_TO_PAY_TOKENIZATION_SUCCESS = "fz.click_to_pay.tokenization.success",
14
- CLICK_TO_PAY_TOKENIZATION_ERROR = "fz.click_to_pay.tokenization.error"
19
+ CLICK_TO_PAY_TOKENIZATION_ERROR = "fz.click_to_pay.tokenization.error",
20
+ CLICK_TO_PAY_RESIZE = "fz.click_to_pay.resize",
21
+ CLICK_TO_PAY_DCF_LOADED = "fz.click_to_pay.dcf",
22
+ CLICK_TO_PAY_MRT = "fz.click_to_pay.mrt",
23
+ CLICK_TO_PAY_INITIAL_MRT_REQUEST = "fz.click_to_pay.initial_mrt_req",
24
+ CLICK_TO_PAY_INITIAL_MRT_RESPONSE = "fz.click_to_pay.initial_mrt_res"
15
25
  }
16
26
  declare enum BridgeEvent {
17
27
  TOKENIZE_CARD_REQUEST = "fzi.tc_req",
@@ -48,16 +58,6 @@ interface Customer {
48
58
  state?: string;
49
59
  country?: string;
50
60
  }
51
- interface CustomerSnakeCase {
52
- first_name?: string;
53
- last_name?: string;
54
- email?: string;
55
- address?: string;
56
- city?: string;
57
- state?: string;
58
- postcode?: string;
59
- country?: string;
60
- }
61
61
  interface Payment {
62
62
  amount: number;
63
63
  currency: string;
@@ -85,16 +85,25 @@ export type PaymentConfig = {
85
85
  paymentIntent: PaymentIntent;
86
86
  options: OptionalUrlValues;
87
87
  };
88
+ export type ApplePayButtonType = 'buy' | 'donate' | 'plain' | 'set-up' | 'book' | 'check-out' | 'subscribe' | 'add-money' | 'contribute' | 'order' | 'reload' | 'rent' | 'support' | 'tip' | 'top-up' | 'continue';
89
+ export type ApplePayButtonStyle = 'black' | 'white' | 'white-outline';
90
+ export type ApplePayButtonLocale = 'ar-AB' | 'ca-ES' | 'cs-CZ' | 'da-DK' | 'de-DE' | 'el-GR' | 'en-AU' | 'en-GB' | 'en-US' | 'es-ES' | 'es-MX' | 'fi-FI' | 'fr-CA' | 'fr-FR' | 'he-IL' | 'hi-IN' | 'hr-HR' | 'hu-HU' | 'id-ID' | 'it-IT' | 'ja-JP' | 'ko-KR' | 'ms-MY' | 'nb-NO' | 'nl-NL' | 'pl-PL' | 'pt-BR' | 'pt-PT' | 'ro-RO' | 'ru-RU' | 'sk-SK' | 'sv-SE' | 'th-TH' | 'tr-TR' | 'uk-UA' | 'vi-VN' | 'zh-CN' | 'zh-HK' | 'zh-TW';
88
91
  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;
95
101
  css?: string;
96
102
  css_signature?: string;
97
103
  tokenize_only?: boolean;
104
+ apple_button_style?: ApplePayButtonStyle;
105
+ apple_button_type?: ApplePayButtonType;
106
+ apple_button_locale?: ApplePayButtonLocale;
98
107
  };
99
108
  declare global {
100
109
  interface Window {
@@ -102,6 +111,7 @@ declare global {
102
111
  Cardinal: any;
103
112
  FatZebra: any;
104
113
  HPP: any;
114
+ ApplePayButton: any;
105
115
  MerchantUsername: string;
106
116
  }
107
117
  }
@@ -137,5 +147,10 @@ type TokenizeCardResponse = {
137
147
  token: string;
138
148
  errors?: Array<string>;
139
149
  };
140
- export { BridgeEvent, PublicEvent, PaymentMethodType, };
141
- export type { PaymentMethod, PaymentIntent, Payment, Card, CardOnFile, CustomerSnakeCase, Customer, Handlers, ValidationResult, TokenizeCardResponse, };
150
+ type ApplePayPaymentResponse = {
151
+ message: string;
152
+ errors?: Array<string>;
153
+ data?: string;
154
+ };
155
+ export { Channel, BridgeEvent, PublicEvent, PaymentMethodType, };
156
+ export type { PaymentMethod, PaymentIntent, Payment, Card, CardOnFile, Customer, Handlers, ValidationResult, TokenizeCardResponse, ApplePayPaymentResponse };
@@ -1,5 +1,10 @@
1
+ var Channel;
2
+ (function (Channel) {
3
+ Channel["CLICK_TO_PAY"] = "click_to_pay";
4
+ })(Channel || (Channel = {}));
1
5
  var PublicEvent;
2
6
  (function (PublicEvent) {
7
+ PublicEvent["HPP_READY"] = "fz.ready";
3
8
  PublicEvent["FORM_VALIDATION_ERROR"] = "fz.form_validation.error";
4
9
  PublicEvent["FORM_VALIDATION_SUCCESS"] = "fz.form_validation.success";
5
10
  PublicEvent["VALIDATION_ERROR"] = "fz.validation.error";
@@ -12,6 +17,11 @@ var PublicEvent;
12
17
  PublicEvent["BIN_LOOKUP"] = "fz.bin.lookup";
13
18
  PublicEvent["CLICK_TO_PAY_TOKENIZATION_SUCCESS"] = "fz.click_to_pay.tokenization.success";
14
19
  PublicEvent["CLICK_TO_PAY_TOKENIZATION_ERROR"] = "fz.click_to_pay.tokenization.error";
20
+ PublicEvent["CLICK_TO_PAY_RESIZE"] = "fz.click_to_pay.resize";
21
+ PublicEvent["CLICK_TO_PAY_DCF_LOADED"] = "fz.click_to_pay.dcf";
22
+ PublicEvent["CLICK_TO_PAY_MRT"] = "fz.click_to_pay.mrt";
23
+ PublicEvent["CLICK_TO_PAY_INITIAL_MRT_REQUEST"] = "fz.click_to_pay.initial_mrt_req";
24
+ PublicEvent["CLICK_TO_PAY_INITIAL_MRT_RESPONSE"] = "fz.click_to_pay.initial_mrt_res";
15
25
  })(PublicEvent || (PublicEvent = {}));
16
26
  var BridgeEvent;
17
27
  (function (BridgeEvent) {
@@ -30,4 +40,4 @@ var PaymentMethodType;
30
40
  PaymentMethodType["CARD"] = "card";
31
41
  PaymentMethodType["CARD_ON_FILE"] = "card_on_file";
32
42
  })(PaymentMethodType || (PaymentMethodType = {}));
33
- export { BridgeEvent, PublicEvent, PaymentMethodType, };
43
+ export { Channel, BridgeEvent, PublicEvent, PaymentMethodType, };