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