@tap-payments/apple-pay-button 0.0.28-test → 0.0.29-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
@@ -38,75 +38,73 @@ import {
38
38
  const App = () => {
39
39
  return (
40
40
  <ApplePayButton
41
- // required (The public Key provided by Tap)
41
+ // The public Key provided by Tap
42
42
  publicKey={'pk_test_xxxxxxxxxxxxxxxzh'}
43
- // optional (The environment of the SDK and it can be one of these environments)
43
+ //The environment of the SDK and it can be one of these environments
44
44
  environment={Environment.Development}
45
- // optional (to enable the debug mode)
45
+ //to enable the debug mode
46
46
  debug
47
- // required
48
47
  merchant={{
49
- // required (The merchant domain name)
48
+ // The merchant domain name
50
49
  domain: 'example.com',
51
- // required (The merchant identifier provided by Tap)
50
+ // The merchant identifier provided by Tap
52
51
  id: '1xxxxx8'
53
52
  }}
54
- // required
55
53
  transaction={{
56
- // required (The amount to be charged)
54
+ // The amount to be charged
57
55
  amount: '12',
58
- // required (The currency of the amount)
56
+ // The currency of the amount
59
57
  currency: 'KWD'
60
58
  }}
61
- // optional (The scope of the SDK and it can be one of these scopes:
59
+ // The scope of the SDK and it can be one of these scopes:
62
60
  // [TapToken,AppleToken], by default it is TapToken)
63
61
  scope={Scope.TapToken}
64
- // optional
65
62
  acceptance={{
66
- // optional (The supported networks for the Apple Pay button and it
63
+ // The supported networks for the Apple Pay button and it
67
64
  // can be one of these networks: [Mada,Visa,MasterCard], by default
68
- // we bring all the supported networks from tap merchant configuration)
65
+ // we bring all the supported networks from tap merchant configuration
69
66
  supportedBrands: [SupportedNetworks.Mada, SupportedNetworks.Visa, SupportedNetworks.MasterCard]
67
+ supportedCards : ["DEBIT","CREDIT"],
68
+ supportedCardsWithAuthentications : ["3DS","EMV"]
70
69
  }}
71
- // optional (The billing contact information)
70
+ // The billing contact information
72
71
  customer={{
73
- //"OPTIONAL : Customer ID",
74
72
  id: 'cus_xxx',
75
73
  name: [
76
74
  {
77
- //"REQUIRED : en or ar",
75
+ //"en or ar",
78
76
  lang: Locale.EN,
79
- // "OPTIONAL : First name of the customer.",
77
+ // "First name of the customer.",
80
78
  first: 'test',
81
- //"OPTIONAL : Last name of the customer.",
79
+ //"Last name of the customer.",
82
80
  last: 'tester',
83
- // "OPTIONAL : Middle name of the customer.",
81
+ // "Middle name of the customer.",
84
82
  middle: 'test'
85
83
  }
86
84
  ],
87
85
  // Defines the contact details for the customer & to be used in creating the billing contact info in Apple pay request
88
86
  contact: {
89
- //"OPTIONAL : The customer's email",
87
+ //"The customer's email",
90
88
  email: 'test@gmail.com',
91
- //"OPTIONAL : The customer's phone number"
89
+ //"The customer's phone number"
92
90
  phone: {
93
- //"OPTIONAL : The customer's country code",
91
+ //"The customer's country code",
94
92
  countryCode: '+20',
95
- //"OPTIONAL : The customer's phone number
93
+ //"The customer's phone number
96
94
  number: '10XXXXXX56'
97
95
  }
98
96
  }
99
97
  }}
100
- //optional (for styling button)
98
+ //for styling button
101
99
  interface={{
102
- // optional (The locale of the Apple Pay button and it can be one of these locales:[EN,AR])
100
+ //The locale of the Apple Pay button and it can be one of these locales:[EN,AR]
103
101
  locale: Locale.EN,
104
- // optional (The theme of the Apple Pay button and it can be one of
105
- // these values : [light,Dark], by default it is detected from user device )
102
+ // The theme of the Apple Pay button and it can be one of
103
+ // these values : [light,Dark], by default it is detected from user device
106
104
  theme: ThemeMode.DARK,
107
- // optional (The type of the Apple Pay )
105
+ // The type of the Apple Pay
108
106
  type: ButtonType.BUY,
109
- // optional (The border of the Apple Pay button and it can be one of these values:[curved,straight])
107
+ // The border of the Apple Pay button and it can be one of these values:[curved,straight]
110
108
  edges: Edges.CURVED
111
109
  }}
112
110
  // optional (A callback function that will be called when you cancel
@@ -143,8 +141,8 @@ const App = () => {
143
141
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
144
142
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
145
143
  <title>apple pay button</title>
146
- <link rel="stylesheet" href="https://apple-pay-button.b-cdn.net/build-0.0.21-test/main.css" />
147
- <script src="https://apple-pay-button.b-cdn.net/build-0.0.21-test/main.js"></script>
144
+ <link rel="stylesheet" href="https://tap-sdks.b-cdn.net/apple-pay/build-1.0.29-test/main.css" />
145
+ <script src="https://tap-sdks.b-cdn.net/apple-pay/build-1.0.29-test/main.js"></script>
148
146
  </head>
149
147
 
150
148
  <body>
@@ -158,7 +156,7 @@ const App = () => {
158
156
  scope: Scope.TapToken,
159
157
  merchant: {
160
158
  domain: 'tp-txxxxxxxx',
161
- id: 'merchant_xxxxxxxxxx"
159
+ id: 'merchant_xxxxxxxxxx'
162
160
  },
163
161
  transaction: {
164
162
  currency: 'SAR',
@@ -166,6 +164,8 @@ const App = () => {
166
164
  },
167
165
  acceptance: {
168
166
  supportedBrands: [SupportedNetworks.Mada, SupportedNetworks.Visa, SupportedNetworks.MasterCard]
167
+ supportedCards : ["DEBIT","CREDIT"],
168
+ supportedCardsWithAuthentications : ["3DS","EMV"]
169
169
  },
170
170
 
171
171
  customer: {
@@ -50,6 +50,7 @@ import appService from '../api/app.service';
50
50
  import { ApplePayVersion } from '../constants';
51
51
  import { setAxiosGlobalHeaders } from '../api/httpClient';
52
52
  import { getApplePayPaymentMethod, getApplePayRequest, validateCurrency, validateSupportedNetworks } from '../utils/config';
53
+ import { getMerchantCapaplities } from '../utils/defaultValues';
53
54
  export var useApplePay = function (_a) {
54
55
  var publicKey = _a.publicKey, merchant = _a.merchant, transaction = _a.transaction, interfaceObj = _a.interface, customer = _a.customer, onCancel = _a.onCancel, onError = _a.onError, onSuccess = _a.onSuccess, scope = _a.scope, acceptance = _a.acceptance, metaData = _a.metaData, debug = _a.debug, environment = _a.environment, onReady = _a.onReady;
55
56
  var _b = useState(false), loading = _b[0], setLoading = _b[1];
@@ -152,6 +153,7 @@ export var useApplePay = function (_a) {
152
153
  transaction: __assign(__assign({}, transaction), { currency: currency }),
153
154
  customer: customer,
154
155
  supportedNetworks: cardBrands,
156
+ merchantCapabilities: getMerchantCapaplities(acceptance === null || acceptance === void 0 ? void 0 : acceptance.supportedCards),
155
157
  name: profileData.merchant.name
156
158
  });
157
159
  if (debug) {
@@ -2,8 +2,9 @@ import { Acceptance, ApplePayButtonProps, ApplePayRequestData, PaymentMethod } f
2
2
  import { SupportedNetworks } from '../constants';
3
3
  export declare const validateSupportedNetworks: (supportedNetworksConfig: Array<(typeof SupportedNetworks)[keyof typeof SupportedNetworks]>, supportedNetworks: Acceptance['supportedBrands']) => ("amex" | "mada" | "masterCard" | "visa" | "chinaUnionPay" | "discover" | "electron" | "jcb" | "maestro")[];
4
4
  export declare const validateCurrency: (currency: string, currencies: string[]) => string;
5
- export declare const getApplePayRequest: ({ transaction, customer, supportedNetworks, countryCode, name }: Pick<ApplePayButtonProps, "transaction" | "customer"> & {
5
+ export declare const getApplePayRequest: ({ transaction, customer, supportedNetworks, merchantCapabilities, countryCode, name }: Pick<ApplePayButtonProps, "transaction" | "customer"> & {
6
6
  supportedNetworks: Acceptance['supportedBrands'];
7
+ merchantCapabilities: ApplePayRequestData['merchantCapabilities'];
7
8
  countryCode: string;
8
9
  name: string;
9
10
  }) => ApplePayRequestData;
@@ -1,4 +1,3 @@
1
- import { MerchantCapabilities } from '../constants';
2
1
  import { JSEncrypt } from 'jsencrypt';
3
2
  export var validateSupportedNetworks = function (supportedNetworksConfig, supportedNetworks) {
4
3
  var toLowerCase = function (item) { return item.toLowerCase(); };
@@ -26,11 +25,11 @@ export var validateCurrency = function (currency, currencies) {
26
25
  };
27
26
  export var getApplePayRequest = function (_a) {
28
27
  var _b, _c, _d, _e, _f, _g, _h, _j, _k;
29
- var transaction = _a.transaction, customer = _a.customer, supportedNetworks = _a.supportedNetworks, countryCode = _a.countryCode, name = _a.name;
28
+ var transaction = _a.transaction, customer = _a.customer, supportedNetworks = _a.supportedNetworks, merchantCapabilities = _a.merchantCapabilities, countryCode = _a.countryCode, name = _a.name;
30
29
  return {
31
30
  countryCode: countryCode,
32
31
  currencyCode: transaction.currency,
33
- merchantCapabilities: [MerchantCapabilities.Supports3DS],
32
+ merchantCapabilities: merchantCapabilities,
34
33
  supportedNetworks: supportedNetworks,
35
34
  billingContact: customer && {
36
35
  phoneNumber: ((_c = (_b = customer.contact) === null || _b === void 0 ? void 0 : _b.phone) === null || _c === void 0 ? void 0 : _c.countryCode) || '' + ((_e = (_d = customer.contact) === null || _d === void 0 ? void 0 : _d.phone) === null || _e === void 0 ? void 0 : _e.number),
@@ -1,4 +1,4 @@
1
- import { ApplePayButtonProps } from '..';
1
+ import { ApplePayButtonProps } from '../@types';
2
2
  export declare const getDefaultValues: (mainObject: ApplePayButtonProps) => {
3
3
  interface: {
4
4
  locale?: "en" | "ar" | "fr" | undefined;
@@ -27,3 +27,4 @@ export declare const getDefaultValues: (mainObject: ApplePayButtonProps) => {
27
27
  metaData?: import("../@types").MetaData | undefined;
28
28
  debug?: boolean | undefined;
29
29
  };
30
+ export declare const getMerchantCapaplities: (supportedCards?: Array<string>) => ("supports3DS" | "supportsCredit" | "supportsDebit")[];
@@ -9,7 +9,16 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
- import { ThemeMode, Locale, ButtonType, Edges } from '../constants';
12
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
13
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
14
+ if (ar || !(i in from)) {
15
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
16
+ ar[i] = from[i];
17
+ }
18
+ }
19
+ return to.concat(ar || Array.prototype.slice.call(from));
20
+ };
21
+ import { ThemeMode, Locale, ButtonType, Edges, MerchantCapabilities } from '../constants';
13
22
  export var getDefaultValues = function (mainObject) {
14
23
  var userThemeMode = window.matchMedia('(prefers-color-scheme: light)').matches ? ThemeMode.LIGHT : ThemeMode.DARK;
15
24
  var userLang = navigator.language.toLowerCase().includes(Locale.AR) ? Locale.AR : Locale.EN;
@@ -21,3 +30,19 @@ export var getDefaultValues = function (mainObject) {
21
30
  };
22
31
  return __assign(__assign({}, mainObject), { interface: __assign(__assign({}, defaultInterface), mainObject.interface) });
23
32
  };
33
+ export var getMerchantCapaplities = function (supportedCards) {
34
+ var merchantCapaplities = [MerchantCapabilities.Supports3DS];
35
+ if (!supportedCards) {
36
+ merchantCapaplities = __spreadArray(__spreadArray([], merchantCapaplities, true), [
37
+ MerchantCapabilities.SupportsCredit,
38
+ MerchantCapabilities.SupportsDebit
39
+ ], false);
40
+ }
41
+ else if (supportedCards.includes('CREDIT')) {
42
+ merchantCapaplities.push(MerchantCapabilities.SupportsCredit);
43
+ }
44
+ else if (supportedCards.includes('DEBIT')) {
45
+ merchantCapaplities.push(MerchantCapabilities.SupportsDebit);
46
+ }
47
+ return merchantCapaplities;
48
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/apple-pay-button",
3
- "version": "0.0.28-test",
3
+ "version": "0.0.29-test",
4
4
  "description": "Apple Pay Button React Component",
5
5
  "main": "build/index.js",
6
6
  "module": "build/index.js",
@@ -20,7 +20,7 @@
20
20
  "copy:files": "copyfiles -u 1 src/**/*.css build/",
21
21
  "tsc:alias": "tsc-alias -p tsconfig.json",
22
22
  "ts:build": "rm -rf build && tsc && yarn tsc:alias && yarn copy:files",
23
- "push": "npm publish --access public --tag test"
23
+ "push": "npm publish --access public"
24
24
  },
25
25
  "keywords": [],
26
26
  "author": {