@tap-payments/apple-pay-button 0.0.2-test → 0.0.3-staging

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 (50) hide show
  1. package/README.md +204 -84
  2. package/build/@types/ApplePayButtonProps.d.ts +129 -0
  3. package/build/@types/ApplePayButtonProps.js +1 -0
  4. package/build/@types/charge.d.ts +57 -0
  5. package/build/@types/charge.js +1 -0
  6. package/build/@types/checkoutProfile.d.ts +216 -0
  7. package/build/@types/checkoutProfile.js +1 -0
  8. package/build/@types/enums.d.ts +65 -0
  9. package/build/@types/enums.js +76 -0
  10. package/build/@types/index.d.ts +6 -74
  11. package/build/@types/index.js +6 -1
  12. package/build/@types/tapLocalisation.d.ts +193 -0
  13. package/build/@types/tapLocalisation.js +1 -0
  14. package/build/@types/tapTheme.d.ts +842 -0
  15. package/build/@types/tapTheme.js +1 -0
  16. package/build/api.d.ts +29 -0
  17. package/build/api.js +244 -0
  18. package/build/constants/index.d.ts +2 -20
  19. package/build/constants/index.js +2 -20
  20. package/build/features/ApplePayButton/ApplePayButton.d.ts +4 -8
  21. package/build/features/ApplePayButton/ApplePayButton.js +30 -24
  22. package/build/features/ApplePayButton/index.d.ts +2 -2
  23. package/build/hooks/index.d.ts +1 -1
  24. package/build/hooks/index.js +1 -1
  25. package/build/hooks/useApplePay.d.ts +89 -5
  26. package/build/hooks/useApplePay.js +324 -82
  27. package/build/hooks/useMerchantApplePay.d.ts +20 -0
  28. package/build/hooks/useMerchantApplePay.js +188 -0
  29. package/build/index.d.ts +4 -4
  30. package/build/index.js +8 -5
  31. package/build/utils/config.d.ts +12 -6
  32. package/build/utils/config.js +49 -38
  33. package/build/utils/defaultValues.d.ts +2 -0
  34. package/build/utils/defaultValues.js +27 -0
  35. package/build/utils/html.d.ts +1 -3
  36. package/build/utils/html.js +4 -15
  37. package/build/utils/index.d.ts +3 -0
  38. package/build/utils/index.js +3 -0
  39. package/build/utils/theme.d.ts +12 -0
  40. package/build/utils/theme.js +61 -0
  41. package/package.json +109 -102
  42. package/build/api/app.service.d.ts +0 -11
  43. package/build/api/app.service.js +0 -217
  44. package/build/api/base.d.ts +0 -9
  45. package/build/api/base.js +0 -45
  46. package/build/api/httpClient.d.ts +0 -2
  47. package/build/api/httpClient.js +0 -16
  48. package/build/features/ApplePayButton/ApplePayButton.css +0 -51
  49. package/build/hooks/useScript.d.ts +0 -1
  50. package/build/hooks/useScript.js +0 -39
package/README.md CHANGED
@@ -22,99 +22,219 @@ yarn add @tap-payments/apple-pay-button
22
22
 
23
23
  ### ES6
24
24
 
25
- ```js
25
+ ```javascript
26
26
  import React from 'react'
27
- import { ApplePayButton, ButtonStyle, SupportedNetworks, Scope } from '@tap-payments/apple-pay-button'
27
+ import {
28
+ ApplePayButton,
29
+ ThemeMode,
30
+ SupportedNetworks,
31
+ Scope,
32
+ Environment,
33
+ Locale,
34
+ ButtonType,
35
+ Edges
36
+ } from '@tap-payments/apple-pay-button'
28
37
 
29
38
  const App = () => {
30
- return (
31
- <ApplePayButton
32
- // required (The public Key provided by Tap)
33
- publicKey={'pk_test_xxxxxxxxxxxxxxxxxxxxxxxxxzh'}
34
- // required
35
- merchant={{
36
- // required (The merchant domain name)
37
- domain: 'example.com',
38
- // optional (The merchant identifier provided by Tap)
39
- id: '1xxxxx8'
40
- }}
41
- // required
42
- transaction={{
43
- // required (The amount to be charged)
44
- amount: '12',
45
- // required (The currency of the amount)
46
- currency: 'KWD',
47
- // required (The description/label of the transaction)
48
- label: 'to Merchant'
49
- }}
50
- // optional (The scope of the SDK and it can be one of these scopes:
51
- // [TapToken,AppleToken], by default it is TapToken)
52
- scope={Scope.TapToken}
53
- // optional (The supported networks for the Apple Pay button and it
54
- // can be one of these networks: [Mada,Visa,MasterCard], by default
55
- // we bring all the supported networks from tap merchant configuration)
56
- supportedNetworks={[SupportedNetworks.Mada, SupportedNetworks.Visa, SupportedNetworks.MasterCard]}
57
- // optional (The style of the Apple Pay button and it can be one of
58
- // these styles: [White,WhiteOutline,Black], by default it is WhiteOutline)
59
- buttonStyle={ButtonStyle.WhiteOutline}
60
- // optional (The billing contact information)
61
- billingContact={{
62
- // required
63
- email: {
64
- // required
65
- address: 'test@gmail.com'
66
- },
67
- // required
68
- name: {
69
- // required
70
- first: 'test',
71
- // required
72
- last: 'tester',
73
- // optional
74
- middle: 'test'
75
- },
76
- // required
77
- phone: {
78
- number: '10XXXXXX56',
79
- code: '+20'
80
- }
81
- }}
82
- // optional (A callback function that will be called when you cancel
83
- // the payment process)
84
- onCancel={() => console.log('cancelled')}
85
- // optional (A callback function that will be called when you have an error)
86
- onError={(err) => console.error(err)}
87
- // optional (A async function that will be called after creating the token
88
- // successfully)
89
- onSuccess={async (token) => {
90
- // do your stuff here...
91
- console.log(token)
92
- }}
93
- />
94
- )
39
+ return (
40
+ <ApplePayButton
41
+ // The public Key provided by Tap
42
+ publicKey={'pk_test_xxxxxxxxxxxxxxxzh'}
43
+ //The environment of the SDK and it can be one of these environments
44
+ environment={Environment.Development}
45
+ //to enable the debug mode
46
+ debug
47
+ merchant={{
48
+ // The merchant domain name
49
+ domain: 'example.com',
50
+ // The merchant identifier provided by Tap
51
+ id: '1xxxxx8'
52
+ }}
53
+ transaction={{
54
+ // The amount to be charged
55
+ amount: '12',
56
+ // The currency of the amount
57
+ currency: 'KWD'
58
+ }}
59
+ // The scope of the SDK and it can be one of these scopes:
60
+ // [TapToken,AppleToken], by default it is TapToken)
61
+ scope={Scope.TapToken}
62
+ acceptance={{
63
+ // The supported networks for the Apple Pay button and it
64
+ // can be one of these networks: [Mada,Visa,MasterCard], by default
65
+ // we bring all the supported networks from tap merchant configuration
66
+ supportedBrands: [SupportedNetworks.Mada, SupportedNetworks.Visa, SupportedNetworks.MasterCard]
67
+ supportedCards : ["DEBIT","CREDIT"],
68
+ supportedCardsWithAuthentications : ["3DS","EMV"]
69
+ }}
70
+ // The billing contact information
71
+ customer={{
72
+ id: 'cus_xxx',
73
+ name: [
74
+ {
75
+ //"en or ar",
76
+ lang: Locale.EN,
77
+ // "First name of the customer.",
78
+ first: 'test',
79
+ //"Last name of the customer.",
80
+ last: 'tester',
81
+ // "Middle name of the customer.",
82
+ middle: 'test'
83
+ }
84
+ ],
85
+ // Defines the contact details for the customer & to be used in creating the billing contact info in Apple pay request
86
+ contact: {
87
+ //"The customer's email",
88
+ email: 'test@gmail.com',
89
+ //"The customer's phone number"
90
+ phone: {
91
+ //"The customer's country code",
92
+ countryCode: '+20',
93
+ //"The customer's phone number
94
+ number: '10XXXXXX56'
95
+ }
96
+ }
97
+ }}
98
+ //for styling button
99
+ interface={{
100
+ //The locale of the Apple Pay button and it can be one of these locales:[EN,AR]
101
+ locale: Locale.EN,
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
104
+ theme: ThemeMode.DARK,
105
+ // The type of the Apple Pay
106
+ type: ButtonType.BUY,
107
+ // The border of the Apple Pay button and it can be one of these values:[curved,straight]
108
+ edges: Edges.CURVED
109
+ }}
110
+ // optional (A callback function that will be called when you cancel
111
+ // the payment process)
112
+ onCancel={() => console.log('cancelled')}
113
+ // optional (A callback function that will be called when you have an error)
114
+ onError={(err) => console.error(err)}
115
+ // optional (A async function that will be called after creating the token
116
+ // successfully)
117
+ onSuccess={async (token) => {
118
+ // do your stuff here...
119
+ console.log(token)
120
+ }}
121
+ // optional (A callback function that will be called when you button is clickable)
122
+ onReady={() => {
123
+ console.log('Ready')
124
+ }}
125
+ // optional (A callback function that will be called when the button clicked)
126
+ onClick={() => {
127
+ console.log('Clicked')
128
+ }}
129
+ />
130
+ )
95
131
  }
96
132
  ```
97
133
 
98
134
  ### Vanilla JS
99
135
 
100
- ```js
101
- // coming soon...
136
+ ```html
137
+ <!DOCTYPE html>
138
+ <html lang="en">
139
+ <head>
140
+ <meta charset="UTF-8" />
141
+ <meta http-equiv="X-UA-Compatible" content="IE=edge" />
142
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
143
+ <title>apple pay button</title>
144
+ <link rel="stylesheet" href="https://tap-sdks.b-cdn.net/apple-pay/build-0.0.36-test/main.css" />
145
+ <script src="https://tap-sdks.b-cdn.net/apple-pay/build-0.0.36-test/main.js"></script>
146
+ </head>
147
+
148
+ <body>
149
+ <div id="apple-pay-button"></div>
150
+ <script type="text/javascript">
151
+ const { renderApplePayButton, ThemeMode, SupportedNetworks, Scope, Environment, Locale, ButtonType, Edges } =
152
+ window.TapSDKs
153
+ renderApplePayButton(
154
+ {
155
+ publicKey: 'pk_test_7xxxxxxxxx',
156
+ environment: Environment.Sandbox,
157
+ scope: Scope.TapToken,
158
+ merchant: {
159
+ domain: 'tp-txxxxxxxx',
160
+ id: 'merchant_xxxxxxxxxx'
161
+ },
162
+ transaction: {
163
+ currency: 'SAR',
164
+ amount: '3'
165
+ },
166
+ acceptance: {
167
+ supportedBrands: [SupportedNetworks.Mada, SupportedNetworks.Visa, SupportedNetworks.MasterCard],
168
+ supportedCards: ['DEBIT', 'CREDIT'],
169
+ supportedCardsWithAuthentications: ['3DS', 'EMV']
170
+ },
171
+
172
+ customer: {
173
+ id: 'cus_xxx',
174
+ name: [
175
+ {
176
+ locale: 'en',
177
+ first: 'test',
178
+ last: 'tester',
179
+ middle: 'test'
180
+ }
181
+ ],
182
+ contact: {
183
+ email: 'test@gmail.com',
184
+ phone: {
185
+ number: '10XXXXXX56',
186
+ countryCode: '+20'
187
+ }
188
+ }
189
+ },
190
+ interface: {
191
+ locale: Locale.EN,
192
+ theme: ThemeMode.DARK,
193
+ type: ButtonType.BUY,
194
+ edges: Edges.CURVED
195
+ },
196
+ onCancel: async () => {
197
+ console.log('onCancel')
198
+ },
199
+ onError: async (error) => {
200
+ console.log('onError', error)
201
+ },
202
+ onSuccess: async (data) => {
203
+ console.log('onSuccess', data)
204
+ },
205
+ onReady: async () => {
206
+ console.log('onReady')
207
+ }
208
+ },
209
+ 'apple-pay-button'
210
+ )
211
+ </script>
212
+ </body>
213
+ </html>
102
214
  ```
103
215
 
104
216
  ## Configurations
105
217
 
106
- | Name | Type | R/O | Description |
107
- | -------------------- | --------------------- | ---------- | -------------------------------------------------------------------------- |
108
- | publicKey | `string` | `required` | The public Key provided by Tap |
109
- | merchant.id | `string` | `optional` | The merchant identifier provided by Tap |
110
- | merchant.domain | `string` | `required` | The merchant domain name |
111
- | transaction.amount | `string` | `required` | The amount to be charged |
112
- | transaction.currency | `string` | `required` | The currency of the amount |
113
- | transaction.label | `string` | `required` | The description/label of the transaction |
114
- | scope | `Scope` | `optional` | The scope of the SDK |
115
- | supportedNetworks | `SupportedNetworks[]` | `optional` | The supported networks for the Apple Pay button |
116
- | buttonStyle | `ButtonStyle` | `optional` | The style of the Apple Pay button |
117
- | billingContact | `BillingContact` | `optional` | The billing contact information |
118
- | onCancel | `function` | `optional` | A callback function that will be called when you cancel the process |
119
- | onError | `function` | `optional` | A callback function that will be called when you have an error |
120
- | onSuccess | `function` | `optional` | A async function that will be called after creating the token successfully |
218
+ | Name | Type | R/O | Description |
219
+ | -------------------------------------------- | ------------ | ---------- | -------------------------------------------------------------------------------- |
220
+ | publicKey | `string` | `required` | The public Key provided by Tap |
221
+ | environment | `enum` | `optional` | The environment of the SDK and it can be one of these environments `Environment` |
222
+ | debug | `boolean` | `optional` | To enable the debug mode |
223
+ | merchant.id | `string` | `required` | The merchant identifier provided by Tap |
224
+ | merchant.domain | `string` | `required` | The merchant domain name |
225
+ | transaction.amount | `string` | `required` | The amount to be charged |
226
+ | transaction.currency | `string` | `required` | The currency of the amount |
227
+ | scope | `enum` | `optional` | The scope of the SDK |
228
+ | acceptance.supportedBrands | `array` | `optional` | The supported networks for the Apple Pay button |
229
+ | acceptance.supportedCards | `array` | `optional` | The supported cards for the Apple Pay button |
230
+ | acceptance.supportedCardsWithAuthentications | `array` | `optional` | The supported cards with authentications for the Apple Pay button |
231
+ | interface.theme | `enum` | `optional` | The theme of the Apple Pay button |
232
+ | interface.locale | `Locale` | `optional` | The locale of the Apple Pay button |
233
+ | interface.type | `ButtonType` | `optional` | The type of the Apple Pay button |
234
+ | interface.edges | `ButtonType` | `optional` | The border of the Apple Pay button |
235
+ | customer | `object` | `optional` | The Customer details information |
236
+ | onCancel | `function` | `optional` | A callback function that will be called when you cancel the process |
237
+ | onError | `function` | `optional` | A callback function that will be called when you have an error |
238
+ | onSuccess | `function` | `optional` | A async function that will be called after creating the token successfully |
239
+ | onClick | `function` | `optional` | A callback function that will be called when the button clicked |
240
+ | onReady | `function` | `optional` | A callback function that will be called when you button is clickable |
@@ -0,0 +1,129 @@
1
+ import { CheckoutProfileResponse } from './checkoutProfile';
2
+ import { Locale, ThemeMode, Edges, Scope, MerchantCapabilities, SupportedNetworks, ButtonType, ColorStyle } from './enums';
3
+ export interface ApplePayRequestData {
4
+ countryCode: string;
5
+ currencyCode: string;
6
+ merchantCapabilities: Array<MerchantCapabilities>;
7
+ supportedNetworks: Array<SupportedNetworks>;
8
+ billingContact?: {
9
+ phoneNumber?: string;
10
+ emailAddress?: string;
11
+ givenName: string;
12
+ familyName: string;
13
+ };
14
+ total: {
15
+ label: string;
16
+ amount: number;
17
+ };
18
+ }
19
+ export interface ApplePayDataToLunchSDKFromMerchantSide {
20
+ headers: Record<string, any>;
21
+ BASE_URL: string;
22
+ merchant: Record<string, string>;
23
+ applePayRequestData: ApplePayRequestData;
24
+ debug?: boolean;
25
+ applePaySDKVersion?: number;
26
+ }
27
+ export interface Interface {
28
+ locale?: Locale;
29
+ theme?: ThemeMode;
30
+ edges?: Edges;
31
+ type?: ButtonType;
32
+ colorStyle?: ColorStyle;
33
+ loader?: boolean;
34
+ }
35
+ export interface Customer {
36
+ id?: string;
37
+ name?: {
38
+ lang: Locale;
39
+ first: string;
40
+ last: string;
41
+ middle?: string;
42
+ }[];
43
+ contact?: {
44
+ email?: string;
45
+ phone?: {
46
+ countryCode: string;
47
+ number: string;
48
+ };
49
+ };
50
+ }
51
+ export interface Acceptance {
52
+ supportedSchemes?: Array<SupportedNetworks>;
53
+ supportedFundSource?: string[];
54
+ supportedPaymentAuthentications?: string[];
55
+ }
56
+ export interface ApplePayButtonProps {
57
+ operator: {
58
+ publicKey: string;
59
+ hashstring?: string;
60
+ };
61
+ merchant: {
62
+ id: string;
63
+ identifier?: string;
64
+ };
65
+ scope: Scope;
66
+ interface?: Interface;
67
+ customer?: Customer;
68
+ acceptance?: Acceptance;
69
+ transaction?: {
70
+ authentication?: boolean;
71
+ authorize?: {
72
+ auto: {
73
+ type: string;
74
+ time: number;
75
+ };
76
+ };
77
+ metadata?: Record<string, string>;
78
+ reference?: string;
79
+ paymentAgreement?: {
80
+ id: string;
81
+ contract?: {
82
+ id: string;
83
+ };
84
+ };
85
+ destinations?: Record<string, any>;
86
+ };
87
+ invoice?: {
88
+ id: string;
89
+ };
90
+ order: {
91
+ amount: number;
92
+ currency: string;
93
+ id?: string;
94
+ description?: string;
95
+ metadata?: Record<string, string>;
96
+ reference?: string;
97
+ };
98
+ post?: {
99
+ url: string;
100
+ };
101
+ redirect?: {
102
+ url: string;
103
+ };
104
+ onOrderCreated?: (orderId: string) => void;
105
+ onCancel?: () => void;
106
+ onError?: (error: any) => void;
107
+ onSuccess?: (data: Record<string, any>) => Promise<void>;
108
+ onClick?: (data?: ApplePayDataToLunchSDKFromMerchantSide) => void;
109
+ onReady?: () => void;
110
+ metaData?: MetaData;
111
+ debug?: boolean;
112
+ integration?: 'sdk' | 'iframe';
113
+ headers?: {
114
+ mdn: string;
115
+ application: string;
116
+ };
117
+ }
118
+ export interface MerchantResponse {
119
+ id: string;
120
+ name: string;
121
+ country_code: string;
122
+ session_token: string;
123
+ [other: string]: string;
124
+ }
125
+ export interface MetaData {
126
+ merchant: MerchantResponse;
127
+ payment_options: CheckoutProfileResponse['payment_options'];
128
+ headers: Record<string, string>;
129
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,57 @@
1
+ export interface ChargeRequestBody {
2
+ source: {
3
+ id: string;
4
+ };
5
+ ipaddress?: string;
6
+ amount: number;
7
+ currency: string;
8
+ selected_amount?: number;
9
+ selected_currency?: string;
10
+ product: string;
11
+ threeDSecure?: boolean;
12
+ save_card: boolean;
13
+ fee: number;
14
+ customer: {
15
+ id?: string;
16
+ first_name?: string;
17
+ middle_name?: string;
18
+ last_name?: string;
19
+ email?: string;
20
+ phone?: {
21
+ country_code: string;
22
+ number: string;
23
+ };
24
+ };
25
+ hashstring?: string;
26
+ metadata?: Record<string, string>;
27
+ post?: {
28
+ url: string;
29
+ };
30
+ redirect?: {
31
+ url: string;
32
+ };
33
+ merchant?: {
34
+ id: string;
35
+ };
36
+ order?: {
37
+ id: string;
38
+ };
39
+ payment_agreement?: {
40
+ id: string;
41
+ contract?: {
42
+ id: string;
43
+ };
44
+ };
45
+ destinations?: Record<string, any>;
46
+ reference?: {
47
+ order?: string;
48
+ transaction?: string;
49
+ };
50
+ description?: string;
51
+ }
52
+ export interface AuthorizeRequestBody extends ChargeRequestBody {
53
+ auto?: {
54
+ type: string;
55
+ time: number;
56
+ };
57
+ }
@@ -0,0 +1 @@
1
+ export {};