@fat-zebra/sdk 1.5.5-beta.0 → 1.5.6

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 (78) hide show
  1. package/dist/applepay/applepay.js +10 -0
  2. package/dist/applepay/clients/apple-pay-client.js +1 -1
  3. package/dist/click_to_pay/index.d.ts +1 -0
  4. package/dist/click_to_pay/index.js +27 -5
  5. package/dist/click_to_pay/types.d.ts +1 -0
  6. package/dist/hpp/hpp.js +1 -0
  7. package/dist/local/fatzebra.js.map +1 -1
  8. package/dist/main.js +3 -3
  9. package/dist/paypal/paypal-button.d.ts +31 -0
  10. package/dist/paypal/paypal-button.js +199 -0
  11. package/dist/paypal/paypal-checkout.d.ts +21 -0
  12. package/dist/paypal/paypal-checkout.js +100 -0
  13. package/dist/paypal/types.d.ts +188 -0
  14. package/dist/paypal/types.js +5 -0
  15. package/dist/paypal/validation.d.ts +4 -0
  16. package/dist/paypal/validation.js +65 -0
  17. package/dist/react/{applePayUrl.d.ts → url.d.ts} +2 -2
  18. package/dist/react/url.js +33 -0
  19. package/dist/sandbox/fatzebra.js +1 -1
  20. package/dist/sandbox/fatzebra.js.LICENSE.txt +1 -1
  21. package/dist/sca/index.js +4 -2
  22. package/dist/sca/scenarios/enrollment.js +2 -2
  23. package/dist/sca/scenarios/validation.js +3 -3
  24. package/dist/sca/types.d.ts +2 -0
  25. package/dist/shared/event-manager.d.ts +1 -1
  26. package/dist/shared/types.d.ts +16 -3
  27. package/dist/shared/types.js +9 -1
  28. package/dist/src/paypal/paypal-button.js +311 -0
  29. package/dist/src/paypal/paypal-button.js.map +1 -0
  30. package/dist/src/paypal/paypal-button.test.js +41 -0
  31. package/dist/src/paypal/paypal-button.test.js.map +1 -0
  32. package/dist/src/paypal/paypal-checkout.js +111 -0
  33. package/dist/src/paypal/paypal-checkout.js.map +1 -0
  34. package/dist/src/paypal/paypal-checkout.test.js +167 -0
  35. package/dist/src/paypal/paypal-checkout.test.js.map +1 -0
  36. package/dist/src/paypal/types.js +9 -0
  37. package/dist/src/paypal/types.js.map +1 -0
  38. package/dist/src/paypal/validation.js +73 -0
  39. package/dist/src/paypal/validation.js.map +1 -0
  40. package/dist/src/react/{applePayUrl.js → url.js} +21 -7
  41. package/dist/src/react/url.js.map +1 -0
  42. package/dist/src/react/url.test.js +88 -0
  43. package/dist/src/react/url.test.js.map +1 -0
  44. package/dist/src/react/useFatZebra.js +56 -7
  45. package/dist/src/react/useFatZebra.js.map +1 -1
  46. package/dist/validation/schemas/applepay/options.json +73 -0
  47. package/dist/validation/schemas/click-to-pay/options.json +3 -0
  48. package/dist/version.d.ts +1 -1
  49. package/dist/version.js +1 -1
  50. package/package.json +3 -2
  51. package/.idea/fatzebra-js.iml +0 -12
  52. package/.idea/modules.xml +0 -8
  53. package/.idea/vcs.xml +0 -6
  54. package/dist/applepay/applepaymanager.d.ts +0 -28
  55. package/dist/applepay/applepaymanager.js +0 -115
  56. package/dist/local/fatzebra.js +0 -19565
  57. package/dist/production/fatzebra.css +0 -91
  58. package/dist/production/fatzebra.js +0 -2
  59. package/dist/react/ApplePay.d.ts +0 -9
  60. package/dist/react/ApplePay.js +0 -11
  61. package/dist/react/applePayUrl.js +0 -19
  62. package/dist/src/applepay/applepaymanager.js +0 -279
  63. package/dist/src/applepay/applepaymanager.js.map +0 -1
  64. package/dist/src/react/ApplePayButton.js +0 -56
  65. package/dist/src/react/ApplePayButton.js.map +0 -1
  66. package/dist/src/react/applePayUrl.js.map +0 -1
  67. package/dist/src/react/applePayUrl.test.js +0 -57
  68. package/dist/src/react/applePayUrl.test.js.map +0 -1
  69. package/dist/src/react/useMessage.js +0 -140
  70. package/dist/src/react/useMessage.js.map +0 -1
  71. package/dist/src/react/useMessage.test.js +0 -222
  72. package/dist/src/react/useMessage.test.js.map +0 -1
  73. package/dist/src/validation/validators/apple-pay-load-params-button-validator.js +0 -19
  74. package/dist/src/validation/validators/apple-pay-load-params-button-validator.js.map +0 -1
  75. package/dist/staging/fatzebra.css +0 -91
  76. package/dist/staging/fatzebra.js +0 -19565
  77. package/dist/staging/fatzebra.js.map +0 -1
  78. package/dist/staging/index.html +0 -247
@@ -32,6 +32,79 @@
32
32
  ]
33
33
  }
34
34
  },
35
+ "apple_button_type": {
36
+ "type": "string",
37
+ "enum": [
38
+ "buy",
39
+ "donate",
40
+ "plain",
41
+ "set-up",
42
+ "book",
43
+ "check-out",
44
+ "subscribe",
45
+ "add-money",
46
+ "contribute",
47
+ "order",
48
+ "reload",
49
+ "rent",
50
+ "support",
51
+ "tip",
52
+ "top-up",
53
+ "continue"
54
+ ]
55
+ },
56
+ "apple_button_style": {
57
+ "type": "string",
58
+ "enum": [
59
+ "black",
60
+ "white",
61
+ "white-outline"
62
+ ]
63
+ },
64
+ "apple_button_locale": {
65
+ "type": "string",
66
+ "enum": [
67
+ "ar-AB",
68
+ "ca-ES",
69
+ "cs-CZ",
70
+ "da-DK",
71
+ "de-DE",
72
+ "el-GR",
73
+ "en-AU",
74
+ "en-GB",
75
+ "en-US",
76
+ "es-ES",
77
+ "es-MX",
78
+ "fi-FI",
79
+ "fr-CA",
80
+ "fr-FR",
81
+ "he-IL",
82
+ "hi-IN",
83
+ "hr-HR",
84
+ "hu-HU",
85
+ "id-ID",
86
+ "it-IT",
87
+ "ja-JP",
88
+ "ko-KR",
89
+ "ms-MY",
90
+ "nb-NO",
91
+ "nl-NL",
92
+ "pl-PL",
93
+ "pt-BR",
94
+ "pt-PT",
95
+ "ro-RO",
96
+ "ru-RU",
97
+ "sk-SK",
98
+ "sv-SE",
99
+ "th-TH",
100
+ "tr-TR",
101
+ "uk-UA",
102
+ "vi-VN",
103
+ "zh-CN",
104
+ "zh-HK",
105
+ "zh-TW"
106
+ ]
107
+ },
35
108
  "domain_name": {
36
109
  "type": "string"
37
110
  }
@@ -26,6 +26,9 @@
26
26
  "hideManualEntryLink": {
27
27
  "type": "boolean"
28
28
  },
29
+ "mrt": {
30
+ "type": "string"
31
+ },
29
32
  "returnPath": {
30
33
  "type": "string"
31
34
  },
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "1.5.5-beta.0";
1
+ export declare const version = "1.5.6";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '1.5.5-beta.0';
1
+ export const version = '1.5.6';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fat-zebra/sdk",
3
- "version": "1.5.5-beta.0",
3
+ "version": "1.5.6",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -23,6 +23,7 @@
23
23
  "author": "",
24
24
  "license": "ISC",
25
25
  "devDependencies": {
26
+ "@inquirer/prompts": "^5.3.8",
26
27
  "@testing-library/dom": "^10.4.0",
27
28
  "@testing-library/react": "^16.0.0",
28
29
  "@testing-library/react-hooks": "^8.0.1",
@@ -30,6 +31,7 @@
30
31
  "@types/ajv": "^1.0.0",
31
32
  "@types/axios": "^0.14.0",
32
33
  "@types/dotenv": "^8.2.0",
34
+ "@types/inquirer": "^9.0.7",
33
35
  "@types/jest": "^24.0.23",
34
36
  "@types/jsdom": "^21.1.1",
35
37
  "@types/nock": "^11.1.0",
@@ -40,7 +42,6 @@
40
42
  "dotenv-webpack": "^8.0.0",
41
43
  "ejs": "^3.0.1",
42
44
  "html-webpack-plugin": "^5.3.1",
43
- "inquirer": "^10.0.1",
44
45
  "jest": "^29.6.1",
45
46
  "jest-environment-jsdom": "^29.6.1",
46
47
  "jest-localstorage-mock": "^2.4.22",
@@ -1,12 +0,0 @@
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>
package/.idea/modules.xml DELETED
@@ -1,8 +0,0 @@
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 DELETED
@@ -1,6 +0,0 @@
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>
@@ -1,28 +0,0 @@
1
- import { PaymentRequest } from './clients/apple-pay-client';
2
- import * as payNow from './clients/paynow-client';
3
- import { PostMessage } from '../shared/post-message-client';
4
- declare class ApplePayManager {
5
- private merchantId;
6
- private canMakePayments;
7
- private iframe;
8
- private applePaySession;
9
- private postMessageClient;
10
- private fzPayNowDomain;
11
- private username?;
12
- private token?;
13
- constructor(config: {
14
- iframe: HTMLIFrameElement;
15
- fzPayNowDomain: string;
16
- username?: string;
17
- token?: string;
18
- });
19
- initialize(): Promise<void>;
20
- checkApplePayEligibility(): void;
21
- notifyApplePayEligibility(): void;
22
- registerEventListener(): Promise<void>;
23
- purchase(request: PaymentRequest): Promise<void>;
24
- extractApplePaymentRequestParams(payload: any): PaymentRequest;
25
- extractPayNowPaymentAttributes(payload: any): payNow.PaymentAttributes;
26
- sendMessage(payload: PostMessage): void;
27
- }
28
- export default ApplePayManager;
@@ -1,115 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { createSession, getEligibilty, } from './clients/apple-pay-client';
11
- import * as payNow from './clients/paynow-client';
12
- import { PostMessageClient } from '../shared/post-message-client';
13
- // import * as process from "process";
14
- const channel = 'applepay';
15
- // const fzPayNowDomain = process.env.PAYNOW_BASE_URL
16
- // do the domain handling stuff better
17
- const paynowDomain = 'https://paynow.test';
18
- const merchantSessionPath = '/v2/apple_pay/payment_session';
19
- const purchaseTokenPath = '/v2/apple_pay/token';
20
- class ApplePayManager {
21
- constructor(config) {
22
- // if (!config.fzPayNowDomain) {
23
- // console.log('hitting i here')
24
- // this.fzPayNowDomain = process?.env?.PAYNOW_BASE_URL;
25
- // } else {
26
- this.fzPayNowDomain = config.fzPayNowDomain;
27
- this.username = config.username;
28
- this.token = config.token;
29
- // }
30
- this.iframe = config.iframe;
31
- this.postMessageClient = new PostMessageClient({
32
- channel: 'applepay',
33
- target: this.iframe
34
- });
35
- this.initialize();
36
- }
37
- initialize() {
38
- return __awaiter(this, void 0, void 0, function* () {
39
- yield this.registerEventListener();
40
- this.checkApplePayEligibility();
41
- this.notifyApplePayEligibility();
42
- });
43
- }
44
- checkApplePayEligibility() {
45
- if (getEligibilty()) {
46
- this.canMakePayments = true;
47
- }
48
- }
49
- notifyApplePayEligibility() {
50
- const message = {
51
- channel,
52
- subject: 'eligibility',
53
- data: {
54
- canMakePayments: this.canMakePayments
55
- }
56
- };
57
- this.postMessageClient.send(message);
58
- }
59
- registerEventListener() {
60
- return new Promise((resolve, reject) => {
61
- this.postMessageClient.setEventListeners({
62
- 'paymentrequest': (data) => __awaiter(this, void 0, void 0, function* () {
63
- yield this.purchase(data);
64
- })
65
- });
66
- resolve();
67
- });
68
- }
69
- purchase(request) {
70
- return __awaiter(this, void 0, void 0, function* () {
71
- const applePayPaymentRequest = this.extractApplePaymentRequestParams(request);
72
- const payNowPaymentAttributes = this.extractPayNowPaymentAttributes(request);
73
- this.applePaySession = yield createSession(applePayPaymentRequest);
74
- this.applePaySession.onvalidatemerchant = (event) => __awaiter(this, void 0, void 0, function* () {
75
- let merchantSession;
76
- try {
77
- merchantSession = yield payNow.getMerchantSession(event.validationURL, Object.assign(Object.assign({}, payNowPaymentAttributes), { merchant: this.username, domain_name: window.location.hostname, display_name: this.username }), `${paynowDomain}${merchantSessionPath}`, this.username, this.token);
78
- }
79
- catch (e) {
80
- console.log('Unable to establish new merchant session');
81
- return;
82
- }
83
- this.applePaySession.completeMerchantValidation(merchantSession);
84
- });
85
- this.applePaySession.onpaymentauthorized = (event) => __awaiter(this, void 0, void 0, function* () {
86
- try {
87
- yield payNow.authorizePayment(Object.assign(Object.assign({}, payNowPaymentAttributes), { merchant: this.username, token: event.payment.token }), `${paynowDomain}${purchaseTokenPath}`);
88
- this.applePaySession.completePayment(window.ApplePaySession.STATUS_SUCCESS);
89
- }
90
- catch (e) {
91
- this.applePaySession.completePayment(window.ApplePaySession.STATUS_FAILURE);
92
- }
93
- });
94
- this.applePaySession.begin();
95
- });
96
- }
97
- extractApplePaymentRequestParams(payload) {
98
- const { countryCode, currencyCode, merchantCapabilities, supportedNetworks, total, } = payload;
99
- return {
100
- countryCode,
101
- currencyCode,
102
- merchantCapabilities,
103
- supportedNetworks,
104
- total,
105
- };
106
- }
107
- extractPayNowPaymentAttributes(payload) {
108
- const { paymentAttributes } = payload;
109
- return paymentAttributes;
110
- }
111
- sendMessage(payload) {
112
- this.iframe.contentWindow.postMessage(payload, this.fzPayNowDomain);
113
- }
114
- }
115
- export default ApplePayManager;