@tap-payments/apple-pay-button 0.0.23-test → 0.0.25-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.
package/README.md CHANGED
@@ -43,11 +43,13 @@ const App = () => {
43
43
  environment={Environment.Development}
44
44
  // optional (to enable the debug mode)
45
45
  debug
46
+ // required (The merchant identifier provided by Tap)
47
+ merchantIdentifier='merchant.tap.applepay.test'
46
48
  // required
47
49
  merchant={{
48
50
  // required (The merchant domain name)
49
51
  domain: 'example.com',
50
- // required (The merchant identifier provided by Tap)
52
+ // optional (The merchant identifier provided by Tap)
51
53
  id: '1xxxxx8'
52
54
  }}
53
55
  // required
@@ -129,9 +131,11 @@ const App = () => {
129
131
  renderApplePayButton(
130
132
  {
131
133
  publicKey: 'pk_test_7xxxxxxxxx',
134
+ merchantIdentifier: 'merchant.com.xxxxx',
132
135
  environment: Environment.Sandbox,
133
136
  merchant: {
134
137
  domain: 'tp-txxxxxxxx',
138
+
135
139
  id: 'merchant_xxxxxxxxxx"
136
140
  },
137
141
 
@@ -189,7 +193,8 @@ const App = () => {
189
193
  | publicKey | `string` | `required` | The public Key provided by Tap |
190
194
  | environment | `Environment` | `optional` | The environment of the SDK and it can be one of these environments `Environment` |
191
195
  | debug | `boolean` | `optional` | To enable the debug mode |
192
- | merchant.id | `string` | `required` | The merchant identifier provided by Tap |
196
+ | merchantIdentifier | `string` | `required` | The merchant identifier provided by Tap |
197
+ | merchant.id | `string` | `optional` | The merchant identifier provided by Tap |
193
198
  | merchant.domain | `string` | `required` | The merchant domain name |
194
199
  | transaction.amount | `string` | `required` | The amount to be charged |
195
200
  | transaction.currency | `string` | `required` | The currency of the amount |
@@ -18,8 +18,9 @@ export interface ApplePayRequestData {
18
18
  export interface ApplePayButtonProps {
19
19
  publicKey: string;
20
20
  environment: typeof Environment[keyof typeof Environment];
21
+ merchantIdentifier: string;
21
22
  merchant: {
22
- id: string;
23
+ id?: string;
23
24
  domain: string;
24
25
  };
25
26
  scope?: typeof Scope[keyof typeof Scope];
@@ -1,5 +1,5 @@
1
1
  export declare const MW_BASE_LIVE_URL = "https://mw-sdk.tap.company/v2/checkout";
2
- export declare const MW_BASE_STAGING_URL = "https://mw-sdk.staing.tap.company/v2/checkout";
2
+ export declare const MW_BASE_STAGING_URL = "https://mw-sdk.staging.tap.company/v2/checkout";
3
3
  export declare const MW_BASE_DEV_URL = "https://mw-sdk.dev.tap.company/v2/checkout";
4
4
  export declare const MW_BASE_BETA_URL = "https://mw-sdk.beta.tap.company/v2/checkout";
5
5
  export declare const MW_BASE_SANDBOX_URL = "https://mw-sdk.sandbox.tap.company/v2/checkout";
@@ -11,7 +11,7 @@ var __assign = (this && this.__assign) || function () {
11
11
  };
12
12
  import axios from 'axios';
13
13
  export var MW_BASE_LIVE_URL = 'https://mw-sdk.tap.company/v2/checkout';
14
- export var MW_BASE_STAGING_URL = 'https://mw-sdk.staing.tap.company/v2/checkout';
14
+ export var MW_BASE_STAGING_URL = 'https://mw-sdk.staging.tap.company/v2/checkout';
15
15
  export var MW_BASE_DEV_URL = 'https://mw-sdk.dev.tap.company/v2/checkout';
16
16
  export var MW_BASE_BETA_URL = 'https://mw-sdk.beta.tap.company/v2/checkout';
17
17
  export var MW_BASE_SANDBOX_URL = 'https://mw-sdk.sandbox.tap.company/v2/checkout';
@@ -17,7 +17,7 @@ import { useApplePay } from '../../hooks/useApplePay';
17
17
  import { ButtonStyle, ButtonType, Locale, Scope } from '../../constants';
18
18
  import './ApplePayButton.css';
19
19
  var ApplePay = React.memo(function (_a) {
20
- var publicKey = _a.publicKey, merchant = _a.merchant, transaction = _a.transaction, billingContact = _a.billingContact, supportedNetworks = _a.supportedNetworks, onCancel = _a.onCancel, onError = _a.onError, onSuccess = _a.onSuccess, onClick = _a.onClick, metaData = _a.metaData, _b = _a.scope, scope = _b === void 0 ? Scope.TapToken : _b, _c = _a.buttonStyle, buttonStyle = _c === void 0 ? ButtonStyle.WhiteOutline : _c, _d = _a.type, type = _d === void 0 ? ButtonType.PLAIN : _d, _e = _a.locale, locale = _e === void 0 ? Locale.EN : _e, debug = _a.debug, environment = _a.environment, onReady = _a.onReady;
20
+ var publicKey = _a.publicKey, merchant = _a.merchant, transaction = _a.transaction, billingContact = _a.billingContact, supportedNetworks = _a.supportedNetworks, onCancel = _a.onCancel, onError = _a.onError, onSuccess = _a.onSuccess, onClick = _a.onClick, metaData = _a.metaData, _b = _a.scope, scope = _b === void 0 ? Scope.TapToken : _b, _c = _a.buttonStyle, buttonStyle = _c === void 0 ? ButtonStyle.WhiteOutline : _c, _d = _a.type, type = _d === void 0 ? ButtonType.PLAIN : _d, _e = _a.locale, locale = _e === void 0 ? Locale.EN : _e, debug = _a.debug, merchantIdentifier = _a.merchantIdentifier, environment = _a.environment, onReady = _a.onReady;
21
21
  var _f = useApplePay({
22
22
  publicKey: publicKey,
23
23
  merchant: merchant,
@@ -30,6 +30,7 @@ var ApplePay = React.memo(function (_a) {
30
30
  scope: scope,
31
31
  metaData: metaData,
32
32
  debug: debug,
33
+ merchantIdentifier: merchantIdentifier,
33
34
  environment: environment,
34
35
  locale: locale,
35
36
  onReady: onReady
@@ -5,5 +5,5 @@ interface UseApplePayReturnProps {
5
5
  onApplePayButtonClicked: () => Promise<void>;
6
6
  disabled: boolean;
7
7
  }
8
- export declare const useApplePay: ({ publicKey, merchant, transaction, billingContact, onCancel, onError, onSuccess, scope, supportedNetworks, metaData, debug, environment, locale, onReady }: UseApplePayProps) => UseApplePayReturnProps;
8
+ export declare const useApplePay: ({ publicKey, merchant, transaction, billingContact, onCancel, onError, onSuccess, scope, supportedNetworks, metaData, debug, merchantIdentifier, environment, locale, onReady }: UseApplePayProps) => UseApplePayReturnProps;
9
9
  export {};
@@ -51,21 +51,22 @@ import { ApplePayVersion } from '../constants';
51
51
  import { setAxiosGlobalHeaders } from '../api/httpClient';
52
52
  import { getApplePayPaymentMethod, getApplePayRequest, validateCurrency, validateSupportedNetworks } from '../utils/config';
53
53
  export var useApplePay = function (_a) {
54
- 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, metaData = _a.metaData, debug = _a.debug, environment = _a.environment, locale = _a.locale, onReady = _a.onReady;
54
+ 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, metaData = _a.metaData, debug = _a.debug, merchantIdentifier = _a.merchantIdentifier, environment = _a.environment, locale = _a.locale, onReady = _a.onReady;
55
55
  var _b = useState(false), loading = _b[0], setLoading = _b[1];
56
56
  var _c = useState(null), profileData = _c[0], setProfile = _c[1];
57
57
  var _d = useState(false), disabled = _d[0], setDisabled = _d[1];
58
58
  var initialize = useCallback(function (metaData) { return __awaiter(void 0, void 0, void 0, function () {
59
59
  var merchantProfile, payment_options, headers, data, err_1;
60
- return __generator(this, function (_a) {
61
- switch (_a.label) {
60
+ var _a, _b;
61
+ return __generator(this, function (_c) {
62
+ switch (_c.label) {
62
63
  case 0:
63
64
  setLoading(true);
64
65
  appService.setEnv(environment);
65
66
  appService.setBaseUrl();
66
- _a.label = 1;
67
+ _c.label = 1;
67
68
  case 1:
68
- _a.trys.push([1, 4, 5, 6]);
69
+ _c.trys.push([1, 4, 5, 6]);
69
70
  if (metaData) {
70
71
  merchantProfile = metaData.merchant, payment_options = metaData.payment_options, headers = metaData.headers;
71
72
  setAxiosGlobalHeaders(__assign({}, headers));
@@ -74,10 +75,10 @@ export var useApplePay = function (_a) {
74
75
  }
75
76
  return [4, appService.setBrowserHeaders({ locale: locale, domain: merchant.domain, pk: publicKey })];
76
77
  case 2:
77
- _a.sent();
78
+ _c.sent();
78
79
  return [4, appService.checkoutProfile({
79
80
  currency: transaction.currency,
80
- merchant_id: merchant.id,
81
+ merchant_id: (_a = merchant.id) !== null && _a !== void 0 ? _a : '',
81
82
  total_amount: Number(transaction.amount),
82
83
  order: __assign(__assign({ amount: Number(transaction.amount), currency: transaction.currency }, (billingContact && {
83
84
  customer: {
@@ -91,7 +92,7 @@ export var useApplePay = function (_a) {
91
92
  }
92
93
  }
93
94
  })), { merchant: {
94
- id: merchant.id
95
+ id: (_b = merchant.id) !== null && _b !== void 0 ? _b : ''
95
96
  }, items: [
96
97
  {
97
98
  amount: Number(transaction.amount),
@@ -103,13 +104,13 @@ export var useApplePay = function (_a) {
103
104
  ] })
104
105
  })];
105
106
  case 3:
106
- data = _a.sent();
107
+ data = _c.sent();
107
108
  if (debug)
108
109
  console.log('merchant configuration: ', data);
109
110
  setProfile(data);
110
111
  return [3, 6];
111
112
  case 4:
112
- err_1 = _a.sent();
113
+ err_1 = _c.sent();
113
114
  onError && onError(err_1.errors || err_1);
114
115
  return [3, 6];
115
116
  case 5:
@@ -169,7 +170,7 @@ export var useApplePay = function (_a) {
169
170
  if (debug) {
170
171
  console.info("creating merchant session for merchantData: ".concat(JSON.stringify(profileData.merchant), " and validationURL: ").concat(event.validationURL, " and merchant.domain: ").concat(merchant.domain));
171
172
  }
172
- return [4, appService.appleSession(__assign(__assign({}, profileData.merchant), { id: merchant.id }), event.validationURL, merchant.domain, merchant.id)];
173
+ return [4, appService.appleSession(profileData.merchant, event.validationURL, merchant.domain, merchantIdentifier)];
173
174
  case 2:
174
175
  merchantSession = _a.sent();
175
176
  if (debug)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/apple-pay-button",
3
- "version": "0.0.23-test",
3
+ "version": "0.0.25-test",
4
4
  "description": "Apple Pay Button React Component",
5
5
  "main": "build/index.js",
6
6
  "module": "build/index.js",