@tap-payments/apple-pay-button 0.0.0-test → 0.0.2-test

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.
@@ -53,6 +53,7 @@ export var useApplePay = function (_a) {
53
53
  var publicKey = _a.publicKey, merchant = _a.merchant, transaction = _a.transaction, billingContact = _a.billingContact, onCancel = _a.onCancel, onError = _a.onError, onSuccess = _a.onSuccess, scope = _a.scope, supportedNetworks = _a.supportedNetworks;
54
54
  var _b = useState(false), loading = _b[0], setLoading = _b[1];
55
55
  var _c = useState(null), profileData = _c[0], setProfile = _c[1];
56
+ var _d = useState(false), disabled = _d[0], setDisabled = _d[1];
56
57
  var getMerchantData = useCallback(function () {
57
58
  setLoading(true);
58
59
  appService
@@ -76,10 +77,12 @@ export var useApplePay = function (_a) {
76
77
  return __generator(this, function (_b) {
77
78
  ApplePaySession = window.ApplePaySession;
78
79
  if (!ApplePaySession) {
80
+ setDisabled(true);
79
81
  console.error('ApplePaySession is not available, please check if you are using Safari browser');
80
82
  return [2];
81
83
  }
82
84
  if (!profileData) {
85
+ setDisabled(true);
83
86
  console.error('The profile data is not available, please check networks and try again');
84
87
  return [2];
85
88
  }
@@ -88,18 +91,13 @@ export var useApplePay = function (_a) {
88
91
  currency = validateCurrency(transaction.currency, paymentMethod.supported_currencies);
89
92
  cardBrands = validateSupportedNetworks(paymentMethod.supported_card_brands, supportedNetworks);
90
93
  request = getApplePayRequest({
91
- countryCode: profileData === null || profileData === void 0 ? void 0 : profileData.merchant.country_code,
94
+ countryCode: profileData.merchant.country_code,
92
95
  transaction: __assign(__assign({}, transaction), { currency: currency }),
93
96
  billingContact: billingContact,
94
97
  supportedNetworks: cardBrands
95
98
  });
96
99
  console.info("Creating ApplePaySession with version: ".concat(ApplePayVersion, " and request: ").concat(JSON.stringify(request)));
97
100
  session_1 = new ApplePaySession(ApplePayVersion, request);
98
- session_1.oncancel = function () {
99
- console.info('oncancel event');
100
- if (onCancel)
101
- onCancel();
102
- };
103
101
  session_1.onvalidatemerchant = function (event) { return __awaiter(void 0, void 0, void 0, function () {
104
102
  var merchantSession, error_1;
105
103
  return __generator(this, function (_a) {
@@ -111,8 +109,8 @@ export var useApplePay = function (_a) {
111
109
  _a.label = 1;
112
110
  case 1:
113
111
  _a.trys.push([1, 3, , 4]);
114
- console.info("creating merchant session for merchantData: ".concat(JSON.stringify(profileData === null || profileData === void 0 ? void 0 : profileData.merchant), " and validationURL: ").concat(event.validationURL, " and merchant.domain: ").concat(merchant.domain));
115
- return [4, appService.appleSession(profileData === null || profileData === void 0 ? void 0 : profileData.merchant, event.validationURL, merchant.domain)];
112
+ console.info("creating merchant session for merchantData: ".concat(JSON.stringify(profileData.merchant), " and validationURL: ").concat(event.validationURL, " and merchant.domain: ").concat(merchant.domain));
113
+ return [4, appService.appleSession(profileData.merchant, event.validationURL, merchant.domain)];
116
114
  case 2:
117
115
  merchantSession = (_a.sent()).body;
118
116
  console.info('merchantSession', merchantSession);
@@ -151,7 +149,7 @@ export var useApplePay = function (_a) {
151
149
  _b.sent();
152
150
  session_1.completePayment({ status: 'STATUS_SUCCESS' });
153
151
  return [3, 8];
154
- case 4: return [4, appService.tapTokenization(event.payment.token.paymentData, profileData === null || profileData === void 0 ? void 0 : profileData.merchant)];
152
+ case 4: return [4, appService.tapTokenization(event.payment.token.paymentData, profileData.merchant)];
155
153
  case 5:
156
154
  data = _b.sent();
157
155
  return [4, (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(data))];
@@ -160,7 +158,7 @@ export var useApplePay = function (_a) {
160
158
  session_1.completePayment({ status: 'STATUS_SUCCESS' });
161
159
  return [3, 8];
162
160
  case 7:
163
- console.error('We only support AppleToken and ApplePay for now');
161
+ console.error('We only support AppleToken and TapToken for now');
164
162
  console.info('Completing payment with status: STATUS_FAILURE');
165
163
  session_1.completePayment({ status: 'STATUS_FAILURE' });
166
164
  _b.label = 8;
@@ -176,6 +174,11 @@ export var useApplePay = function (_a) {
176
174
  }
177
175
  });
178
176
  }); };
177
+ session_1.oncancel = function () {
178
+ console.info('oncancel event');
179
+ if (onCancel)
180
+ onCancel();
181
+ };
179
182
  session_1.begin();
180
183
  }
181
184
  catch (e) {
@@ -198,5 +201,5 @@ export var useApplePay = function (_a) {
198
201
  return [2];
199
202
  });
200
203
  }); };
201
- return { loading: loading, onApplePayButtonClicked: onApplePayButtonClicked, disabled: !profileData };
204
+ return { loading: loading, onApplePayButtonClicked: onApplePayButtonClicked, disabled: !profileData || disabled };
202
205
  };
package/build/index.js CHANGED
@@ -7,3 +7,4 @@ window['TapSDKs'] = {
7
7
  Scope: Scope,
8
8
  SupportedNetworks: SupportedNetworks
9
9
  };
10
+ console.log("apple-pay-button version: ".concat(require('../package.json').version));
package/package.json CHANGED
@@ -1,102 +1,102 @@
1
- {
2
- "name": "@tap-payments/apple-pay-button",
3
- "version": "0.0.0-test",
4
- "description": "Apple Pay Button React Component",
5
- "main": "build/index.js",
6
- "module": "build/index.js",
7
- "types": "build/index.d.ts",
8
- "files": [
9
- "build",
10
- "README.md"
11
- ],
12
- "scripts": {
13
- "prepare": "npx husky install",
14
- "prettier": "prettier --list-different \"src/**/*.{md,mdx,ts,js,tsx,jsx,json}\" *.json *.js",
15
- "prettier:fix": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,md,css,json}\" *.json *.js",
16
- "lint": "eslint src --color --ext .js,.jsx,.ts,.tsx,.json",
17
- "lint:fix": "eslint src --ext .js,.jsx,.ts,.tsx --fix",
18
- "start": "cross-env NODE_ENV=development webpack serve",
19
- "build": "cross-env NODE_ENV=production webpack",
20
- "copy:files": "copyfiles -u 1 src/**/*.css build/",
21
- "tsc:alias": "tsc-alias -p tsconfig.json",
22
- "ts:build": "rm -rf build && tsc && yarn tsc:alias && yarn copy:files",
23
- "push": "npm publish --access public"
24
- },
25
- "keywords": [],
26
- "author": {
27
- "name": "Ahmed Elsharkawy",
28
- "email": "a.elsharkawy@tap.company"
29
- },
30
- "license": "ISC",
31
- "devDependencies": {
32
- "@babel/core": "^7.18.6",
33
- "@babel/preset-env": "^7.18.6",
34
- "@babel/preset-react": "^7.18.6",
35
- "@babel/preset-typescript": "^7.18.6",
36
- "@types/crypto-js": "^4.1.1",
37
- "@types/react": "^18.0.15",
38
- "@types/react-dom": "^18.0.6",
39
- "@typescript-eslint/eslint-plugin": "^5.30.5",
40
- "@typescript-eslint/parser": "^5.30.5",
41
- "babel-loader": "^8.2.5",
42
- "copyfiles": "^2.4.1",
43
- "cross-env": "^7.0.3",
44
- "css-loader": "^6.7.1",
45
- "css-minimizer-webpack-plugin": "^4.0.0",
46
- "eslint": "^8.19.0",
47
- "eslint-config-airbnb": "^19.0.4",
48
- "eslint-config-prettier": "^8.5.0",
49
- "eslint-plugin-import": "^2.26.0",
50
- "eslint-plugin-jsx-a11y": "^6.6.0",
51
- "eslint-plugin-node": "^11.1.0",
52
- "eslint-plugin-prettier": "^4.2.1",
53
- "eslint-plugin-react": "^7.30.1",
54
- "eslint-plugin-react-hooks": "^4.6.0",
55
- "file-loader": "^6.2.0",
56
- "fork-ts-checker-webpack-plugin": "^7.2.12",
57
- "html-loader": "^3.1.2",
58
- "html-webpack-plugin": "^5.5.0",
59
- "husky": "^8.0.1",
60
- "lint-staged": "^13.0.3",
61
- "mini-css-extract-plugin": "^2.6.1",
62
- "prettier": "^2.7.1",
63
- "sass": "^1.53.0",
64
- "sass-loader": "^13.0.2",
65
- "style-loader": "^3.3.1",
66
- "terser-webpack-plugin": "^5.3.3",
67
- "tsc-alias": "^1.6.11",
68
- "typescript": "^4.7.4",
69
- "webpack": "^5.73.0",
70
- "webpack-cli": "^4.10.0",
71
- "webpack-dev-server": "^4.9.3",
72
- "webpack-merge": "^5.8.0"
73
- },
74
- "dependencies": {
75
- "axios": "^1.2.2",
76
- "react": ">=17.0.2",
77
- "react-dom": ">=17.0.2"
78
- },
79
- "peerDependencies": {
80
- "react": ">=17.0.2",
81
- "react-dom": ">=17.0.2"
82
- },
83
- "lint-staged": {
84
- "src/**/*.{ts,tsx,json,js,jsx}": [
85
- "yarn run prettier:fix",
86
- "yarn run lint",
87
- "git add ."
88
- ]
89
- },
90
- "browserslist": {
91
- "production": [
92
- ">0.2%",
93
- "not dead",
94
- "not op_mini all"
95
- ],
96
- "development": [
97
- "last 1 chrome version",
98
- "last 1 firefox version",
99
- "last 1 safari version"
100
- ]
101
- }
102
- }
1
+ {
2
+ "name": "@tap-payments/apple-pay-button",
3
+ "version": "0.0.2-test",
4
+ "description": "Apple Pay Button React Component",
5
+ "main": "build/index.js",
6
+ "module": "build/index.js",
7
+ "types": "build/index.d.ts",
8
+ "files": [
9
+ "build",
10
+ "README.md"
11
+ ],
12
+ "scripts": {
13
+ "prepare": "npx husky install",
14
+ "prettier": "prettier --list-different \"src/**/*.{md,mdx,ts,js,tsx,jsx,json}\" *.json *.js",
15
+ "prettier:fix": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,md,css,json}\" *.json *.js",
16
+ "lint": "eslint src --color --ext .js,.jsx,.ts,.tsx,.json",
17
+ "lint:fix": "eslint src --ext .js,.jsx,.ts,.tsx --fix",
18
+ "start": "cross-env NODE_ENV=development webpack serve",
19
+ "build": "cross-env NODE_ENV=production webpack",
20
+ "copy:files": "copyfiles -u 1 src/**/*.css build/",
21
+ "tsc:alias": "tsc-alias -p tsconfig.json",
22
+ "ts:build": "rm -rf build && tsc && yarn tsc:alias && yarn copy:files",
23
+ "push": "npm publish --access public"
24
+ },
25
+ "keywords": [],
26
+ "author": {
27
+ "name": "Ahmed Elsharkawy",
28
+ "email": "a.elsharkawy@tap.company"
29
+ },
30
+ "license": "ISC",
31
+ "devDependencies": {
32
+ "@babel/core": "^7.18.6",
33
+ "@babel/preset-env": "^7.18.6",
34
+ "@babel/preset-react": "^7.18.6",
35
+ "@babel/preset-typescript": "^7.18.6",
36
+ "@types/crypto-js": "^4.1.1",
37
+ "@types/react": "^18.0.15",
38
+ "@types/react-dom": "^18.0.6",
39
+ "@typescript-eslint/eslint-plugin": "^5.30.5",
40
+ "@typescript-eslint/parser": "^5.30.5",
41
+ "babel-loader": "^8.2.5",
42
+ "copyfiles": "^2.4.1",
43
+ "cross-env": "^7.0.3",
44
+ "css-loader": "^6.7.1",
45
+ "css-minimizer-webpack-plugin": "^4.0.0",
46
+ "eslint": "^8.19.0",
47
+ "eslint-config-airbnb": "^19.0.4",
48
+ "eslint-config-prettier": "^8.5.0",
49
+ "eslint-plugin-import": "^2.26.0",
50
+ "eslint-plugin-jsx-a11y": "^6.6.0",
51
+ "eslint-plugin-node": "^11.1.0",
52
+ "eslint-plugin-prettier": "^4.2.1",
53
+ "eslint-plugin-react": "^7.30.1",
54
+ "eslint-plugin-react-hooks": "^4.6.0",
55
+ "file-loader": "^6.2.0",
56
+ "fork-ts-checker-webpack-plugin": "^7.2.12",
57
+ "html-loader": "^3.1.2",
58
+ "html-webpack-plugin": "^5.5.0",
59
+ "husky": "^8.0.1",
60
+ "lint-staged": "^13.0.3",
61
+ "mini-css-extract-plugin": "^2.6.1",
62
+ "prettier": "^2.7.1",
63
+ "sass": "^1.53.0",
64
+ "sass-loader": "^13.0.2",
65
+ "style-loader": "^3.3.1",
66
+ "terser-webpack-plugin": "^5.3.3",
67
+ "tsc-alias": "^1.6.11",
68
+ "typescript": "^4.7.4",
69
+ "webpack": "^5.73.0",
70
+ "webpack-cli": "^4.10.0",
71
+ "webpack-dev-server": "^4.9.3",
72
+ "webpack-merge": "^5.8.0"
73
+ },
74
+ "dependencies": {
75
+ "axios": "^1.2.2",
76
+ "react": ">=17.0.2",
77
+ "react-dom": ">=17.0.2"
78
+ },
79
+ "peerDependencies": {
80
+ "react": ">=17.0.2",
81
+ "react-dom": ">=17.0.2"
82
+ },
83
+ "lint-staged": {
84
+ "src/**/*.{ts,tsx,json,js,jsx}": [
85
+ "yarn run prettier:fix",
86
+ "yarn run lint",
87
+ "git add ."
88
+ ]
89
+ },
90
+ "browserslist": {
91
+ "production": [
92
+ ">0.2%",
93
+ "not dead",
94
+ "not op_mini all"
95
+ ],
96
+ "development": [
97
+ "last 1 chrome version",
98
+ "last 1 firefox version",
99
+ "last 1 safari version"
100
+ ]
101
+ }
102
+ }