@tap-payments/apple-pay-button 1.0.18 → 1.0.20
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 +5 -219
- package/build/@types/ApplePaySession.d.ts +110 -0
- package/build/@types/ApplePaySession.js +1 -0
- package/build/@types/index.d.ts +39 -21
- package/build/@types/index.js +1 -1
- package/build/features/ApplePayButton/ApplePayButton.d.ts +1 -0
- package/build/features/ApplePayButton/ApplePayButton.js +11 -1
- package/build/features/ApplePayButton/index.d.ts +2 -2
- package/build/features/ApplePayButton/index.js +2 -2
- package/build/hooks/useApplePay.d.ts +3 -2
- package/build/hooks/useApplePay.js +96 -5
- package/build/hooks/useGetEvents.d.ts +4 -0
- package/build/hooks/useGetEvents.js +15 -0
- package/build/hooks/useScript.d.ts +1 -1
- package/build/index.d.ts +2 -2
- package/build/index.js +3 -2
- package/build/utils/config.d.ts +1 -1
- package/build/utils/config.js +22 -3
- package/build/utils/defaultValues.d.ts +8 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Handling Apple Pay button in React and vanilla JS
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
# Install
|
|
6
6
|
|
|
7
7
|
This is a [React](https://reactjs.org/) module available through the
|
|
8
8
|
[npm registry](https://www.npmjs.com/). Installation is done using the
|
|
@@ -17,224 +17,10 @@ npm install @tap-payments/apple-pay-button
|
|
|
17
17
|
```console
|
|
18
18
|
yarn add @tap-payments/apple-pay-button
|
|
19
19
|
```
|
|
20
|
+
# Get your keys
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
You can always use the example keys within our example app, but we do recommend you to head to our [onboarding](https://register.tap.company/sell) page. You will need to register your `domain` to get your `Key`.
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
# Documentation
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
import React from 'react'
|
|
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'
|
|
37
|
-
|
|
38
|
-
const App = () => {
|
|
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
|
-
)
|
|
131
|
-
}
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
### Vanilla JS
|
|
135
|
-
|
|
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-1.0.18/main.css" />
|
|
145
|
-
<script src="https://tap-sdks.b-cdn.net/apple-pay/build-1.0.18/main.js"></script>
|
|
146
|
-
</head>
|
|
147
|
-
|
|
148
|
-
<body>
|
|
149
|
-
<div id="apple-pay-button"></div>
|
|
150
|
-
<script type="text/javascript">
|
|
151
|
-
const { render, ThemeMode, SupportedNetworks, Scope, Environment, Locale, ButtonType, Edges } =
|
|
152
|
-
window.TapApplepaySDK
|
|
153
|
-
render(
|
|
154
|
-
{
|
|
155
|
-
publicKey: 'pk_test_7xxxxxxxxx',
|
|
156
|
-
environment: Environment.Development,
|
|
157
|
-
scope: Scope.TapToken,
|
|
158
|
-
merchant: {
|
|
159
|
-
domain: window.location.hostname,
|
|
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>
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
## Configurations
|
|
217
|
-
|
|
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`: [Development,Production] |
|
|
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 |
|
|
26
|
+
Please find all the documentation needed through our [Tap official Docs](https://developers.tap.company/docs/web-applepay-sdk).
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { MerchantCapabilities, SupportedNetworks } from '../constants';
|
|
2
|
+
export declare type RequiredShippingContactField = 'postalAddress' | 'name' | 'phoneticName' | 'phone' | 'email';
|
|
3
|
+
export declare type ApplePayPaymentMethodType = 'debit' | 'credit' | 'prepaid' | 'store';
|
|
4
|
+
export interface ApplePayShippingMethod {
|
|
5
|
+
label: string;
|
|
6
|
+
detail: string;
|
|
7
|
+
amount: string;
|
|
8
|
+
identifier: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ApplePayPaymentContact {
|
|
11
|
+
phoneNumber?: string;
|
|
12
|
+
emailAddress?: string;
|
|
13
|
+
givenName?: string;
|
|
14
|
+
familyName?: string;
|
|
15
|
+
phoneticGivenName?: string;
|
|
16
|
+
phoneticFamilyName?: string;
|
|
17
|
+
addressLines?: string[];
|
|
18
|
+
subLocality?: string;
|
|
19
|
+
locality?: string;
|
|
20
|
+
postalCode?: string;
|
|
21
|
+
subAdministrativeArea?: string;
|
|
22
|
+
administrativeArea?: string;
|
|
23
|
+
country?: string;
|
|
24
|
+
countryCode?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface ApplePayPaymentTokenContext {
|
|
27
|
+
merchantIdentifier: string;
|
|
28
|
+
externalIdentifier: string;
|
|
29
|
+
merchantName: string;
|
|
30
|
+
merchantDomain?: string;
|
|
31
|
+
amount: string;
|
|
32
|
+
}
|
|
33
|
+
export interface ApplePayPaymentMethod {
|
|
34
|
+
displayName?: string;
|
|
35
|
+
network?: string;
|
|
36
|
+
type?: ApplePayPaymentMethodType;
|
|
37
|
+
billingContact?: ApplePayPaymentContact;
|
|
38
|
+
}
|
|
39
|
+
export interface ApplePayAutomaticReloadPaymentRequest {
|
|
40
|
+
paymentDescription: string;
|
|
41
|
+
automaticReloadBilling: ApplePayLineItem;
|
|
42
|
+
billingAgreement?: string;
|
|
43
|
+
managementURL: string;
|
|
44
|
+
tokenNotificationURL?: string;
|
|
45
|
+
}
|
|
46
|
+
export interface ApplePayRecurringPaymentRequest {
|
|
47
|
+
paymentDescription: string;
|
|
48
|
+
regularBilling: ApplePayLineItem;
|
|
49
|
+
trialBilling?: ApplePayLineItem;
|
|
50
|
+
billingAgreement?: string;
|
|
51
|
+
managementURL: string;
|
|
52
|
+
tokenNotificationURL?: string;
|
|
53
|
+
}
|
|
54
|
+
export interface ApplePayDeferredPaymentRequest {
|
|
55
|
+
billingAgreement?: string;
|
|
56
|
+
deferredBilling: ApplePayLineItem;
|
|
57
|
+
freeCancellationDate?: Date;
|
|
58
|
+
freeCancellationDateTimeZone?: string;
|
|
59
|
+
managementURL: string;
|
|
60
|
+
paymentDescription: string;
|
|
61
|
+
tokenNotificationURL?: string;
|
|
62
|
+
}
|
|
63
|
+
export interface ApplePayError {
|
|
64
|
+
code: string;
|
|
65
|
+
contactField: string;
|
|
66
|
+
message: string;
|
|
67
|
+
}
|
|
68
|
+
export interface ApplePayLineItem {
|
|
69
|
+
type?: 'final' | 'pending';
|
|
70
|
+
label?: string;
|
|
71
|
+
amount?: string;
|
|
72
|
+
paymentTiming?: 'immediate' | 'recurring' | 'deferred' | 'automaticReload';
|
|
73
|
+
recurringPaymentStartDate?: Date;
|
|
74
|
+
recurringPaymentIntervalUnit?: 'year' | 'month' | 'day' | 'hour' | 'minute';
|
|
75
|
+
recurringPaymentIntervalCount?: number;
|
|
76
|
+
recurringPaymentEndDate?: Date;
|
|
77
|
+
deferredPaymentDate?: Date;
|
|
78
|
+
automaticReloadPaymentThresholdAmount?: string;
|
|
79
|
+
}
|
|
80
|
+
export interface ApplePayUpdateData {
|
|
81
|
+
newTotal: ApplePayLineItem;
|
|
82
|
+
newLineItems?: ApplePayLineItem[];
|
|
83
|
+
newMultiTokenContexts?: ApplePayPaymentTokenContext[];
|
|
84
|
+
newAutomaticReloadPaymentRequest?: ApplePayAutomaticReloadPaymentRequest;
|
|
85
|
+
newRecurringPaymentRequest?: ApplePayRecurringPaymentRequest;
|
|
86
|
+
newDeferredPaymentRequest?: ApplePayDeferredPaymentRequest;
|
|
87
|
+
errors?: ApplePayError[];
|
|
88
|
+
newShippingMethods?: ApplePayShippingMethod[];
|
|
89
|
+
}
|
|
90
|
+
export interface ApplePayRequestData {
|
|
91
|
+
countryCode: string;
|
|
92
|
+
currencyCode: string;
|
|
93
|
+
merchantCapabilities: Array<typeof MerchantCapabilities[keyof typeof MerchantCapabilities]>;
|
|
94
|
+
supportedNetworks: Array<typeof SupportedNetworks[keyof typeof SupportedNetworks]>;
|
|
95
|
+
billingContact?: {
|
|
96
|
+
phoneNumber?: string;
|
|
97
|
+
emailAddress?: string;
|
|
98
|
+
givenName: string;
|
|
99
|
+
familyName: string;
|
|
100
|
+
};
|
|
101
|
+
total: {
|
|
102
|
+
label: string;
|
|
103
|
+
amount: number;
|
|
104
|
+
};
|
|
105
|
+
requiredShippingContactFields?: Array<RequiredShippingContactField>;
|
|
106
|
+
supportsCouponCode?: boolean;
|
|
107
|
+
couponCode?: string;
|
|
108
|
+
shippingMethods?: ApplePayShippingMethod[];
|
|
109
|
+
lineItems?: ApplePayLineItem[];
|
|
110
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/build/@types/index.d.ts
CHANGED
|
@@ -1,20 +1,6 @@
|
|
|
1
|
-
import { Scope,
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
currencyCode: string;
|
|
5
|
-
merchantCapabilities: Array<typeof MerchantCapabilities[keyof typeof MerchantCapabilities]>;
|
|
6
|
-
supportedNetworks: Array<typeof SupportedNetworks[keyof typeof SupportedNetworks]>;
|
|
7
|
-
billingContact?: {
|
|
8
|
-
phoneNumber?: string;
|
|
9
|
-
emailAddress?: string;
|
|
10
|
-
givenName: string;
|
|
11
|
-
familyName: string;
|
|
12
|
-
};
|
|
13
|
-
total: {
|
|
14
|
-
label: string;
|
|
15
|
-
amount: number;
|
|
16
|
-
};
|
|
17
|
-
}
|
|
1
|
+
import { Scope, SupportedNetworks, ButtonType, Locale, Environment, ThemeMode, Edges } from '../constants';
|
|
2
|
+
import { ApplePayPaymentContact, ApplePayPaymentMethod, ApplePayShippingMethod, ApplePayUpdateData, RequiredShippingContactField } from './ApplePaySession';
|
|
3
|
+
export * from './ApplePaySession';
|
|
18
4
|
export interface Interface {
|
|
19
5
|
locale?: typeof Locale[keyof typeof Locale];
|
|
20
6
|
theme?: typeof ThemeMode[keyof typeof ThemeMode];
|
|
@@ -42,6 +28,34 @@ export interface Acceptance {
|
|
|
42
28
|
supportedCards?: Array<string>;
|
|
43
29
|
supportedCardsWithAuthentications?: Array<string>;
|
|
44
30
|
}
|
|
31
|
+
export interface Transaction {
|
|
32
|
+
amount: string;
|
|
33
|
+
currency: string;
|
|
34
|
+
couponCode?: string;
|
|
35
|
+
shipping?: ApplePayShippingMethod[];
|
|
36
|
+
items?: Array<{
|
|
37
|
+
type?: 'final' | 'pending';
|
|
38
|
+
label?: string;
|
|
39
|
+
amount?: string;
|
|
40
|
+
paymentTiming?: 'immediate' | 'recurring' | 'deferred' | 'automaticReload';
|
|
41
|
+
scheduledPayment?: {
|
|
42
|
+
recurringStartDate?: Date;
|
|
43
|
+
recurringEndDate?: Date;
|
|
44
|
+
recurringIntervalUnit?: 'year' | 'month' | 'day' | 'hour' | 'minute';
|
|
45
|
+
recurringIntervalCount?: number;
|
|
46
|
+
};
|
|
47
|
+
deferredPayment?: {
|
|
48
|
+
deferredPaymentDate?: Date;
|
|
49
|
+
};
|
|
50
|
+
automaticReloadPayment?: {
|
|
51
|
+
thresholdAmount?: string;
|
|
52
|
+
};
|
|
53
|
+
}>;
|
|
54
|
+
}
|
|
55
|
+
export interface Features {
|
|
56
|
+
shippingContactFields?: Array<RequiredShippingContactField>;
|
|
57
|
+
supportsCouponCode?: boolean;
|
|
58
|
+
}
|
|
45
59
|
export interface ApplePayButtonProps {
|
|
46
60
|
scope?: typeof Scope[keyof typeof Scope];
|
|
47
61
|
publicKey: string;
|
|
@@ -49,19 +63,23 @@ export interface ApplePayButtonProps {
|
|
|
49
63
|
merchant: {
|
|
50
64
|
id: string;
|
|
51
65
|
domain: string;
|
|
66
|
+
identifier?: string;
|
|
52
67
|
};
|
|
53
68
|
interface?: Interface;
|
|
54
69
|
customer?: Customer;
|
|
55
70
|
acceptance: Acceptance;
|
|
56
|
-
transaction:
|
|
57
|
-
|
|
58
|
-
currency: string;
|
|
59
|
-
};
|
|
71
|
+
transaction: Transaction;
|
|
72
|
+
features: Features;
|
|
60
73
|
onCancel?: () => void;
|
|
61
74
|
onError?: (error: any) => void;
|
|
62
75
|
onSuccess?: (data: Record<string, any>) => Promise<void>;
|
|
63
76
|
onClick?: () => void;
|
|
64
77
|
onReady?: () => void;
|
|
78
|
+
onMerchantValidation?: (status: 'initiated' | 'completed' | 'error') => void;
|
|
79
|
+
onShippingMethodSelected?: (shippingMethod: ApplePayShippingMethod) => Promise<ApplePayUpdateData>;
|
|
80
|
+
onShippingContactSelected?: (shippingContact: ApplePayPaymentContact) => Promise<ApplePayUpdateData>;
|
|
81
|
+
onPaymentMethodSelected?: (paymentMethod: ApplePayPaymentMethod) => Promise<ApplePayUpdateData>;
|
|
82
|
+
onCouponChanged?: (couponCode: string) => Promise<ApplePayUpdateData>;
|
|
65
83
|
metaData?: MetaData;
|
|
66
84
|
debug?: boolean;
|
|
67
85
|
}
|
package/build/@types/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from './ApplePaySession';
|
|
@@ -3,4 +3,5 @@ import { ApplePayButtonProps } from '../../@types';
|
|
|
3
3
|
import './ApplePayButton.css';
|
|
4
4
|
export type { ApplePayButtonProps };
|
|
5
5
|
export declare function ApplePayButton(props: ApplePayButtonProps): JSX.Element;
|
|
6
|
+
export declare function abortApplePaySession(): void;
|
|
6
7
|
export declare const render: (props: ApplePayButtonProps, elementId: string) => any;
|
|
@@ -17,9 +17,16 @@ import { useApplePay } from '../../hooks/useApplePay';
|
|
|
17
17
|
import './ApplePayButton.css';
|
|
18
18
|
import { getDefaultValues } from '../../utils/defaultValues';
|
|
19
19
|
import { ButtonStyle, Edges, ThemeMode } from '../../constants';
|
|
20
|
+
import { GetEvents, useGetEvents } from '../../hooks/useGetEvents';
|
|
20
21
|
var ApplePay = React.memo(function (props) {
|
|
21
22
|
var mappedProps = getDefaultValues(props);
|
|
22
|
-
var _a = useApplePay(mappedProps), loading = _a.loading, onApplePayButtonClicked = _a.onApplePayButtonClicked, disabled = _a.disabled;
|
|
23
|
+
var _a = useApplePay(mappedProps), loading = _a.loading, onApplePayButtonClicked = _a.onApplePayButtonClicked, disabled = _a.disabled, abortApplePaySession = _a.abortApplePaySession;
|
|
24
|
+
var onEventReceieved = React.useCallback(function (event) {
|
|
25
|
+
if (event === GetEvents.ABORT) {
|
|
26
|
+
abortApplePaySession();
|
|
27
|
+
}
|
|
28
|
+
}, [abortApplePaySession]);
|
|
29
|
+
useGetEvents(onEventReceieved);
|
|
23
30
|
React.useEffect(function () {
|
|
24
31
|
if (props.debug) {
|
|
25
32
|
console.log('ApplePayButtonProps', props);
|
|
@@ -38,6 +45,9 @@ var ApplePay = React.memo(function (props) {
|
|
|
38
45
|
export function ApplePayButton(props) {
|
|
39
46
|
return _jsx(ApplePay, __assign({}, props));
|
|
40
47
|
}
|
|
48
|
+
export function abortApplePaySession() {
|
|
49
|
+
window.postMessage({ event: GetEvents.ABORT }, '*');
|
|
50
|
+
}
|
|
41
51
|
var tapConnectInstance = null;
|
|
42
52
|
export var render = function (props, elementId) {
|
|
43
53
|
if (tapConnectInstance) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ApplePayButtonProps, ApplePayButton, render } from './ApplePayButton';
|
|
2
|
-
export { ApplePayButton, render };
|
|
1
|
+
import { ApplePayButtonProps, ApplePayButton, render, abortApplePaySession } from './ApplePayButton';
|
|
2
|
+
export { ApplePayButton, render, abortApplePaySession };
|
|
3
3
|
export type { ApplePayButtonProps };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ApplePayButton, render } from './ApplePayButton';
|
|
2
|
-
export { ApplePayButton, render };
|
|
1
|
+
import { ApplePayButton, render, abortApplePaySession } from './ApplePayButton';
|
|
2
|
+
export { ApplePayButton, render, abortApplePaySession };
|
|
@@ -2,8 +2,9 @@ import { ApplePayButtonProps } from '../@types';
|
|
|
2
2
|
declare type UseApplePayProps = Omit<ApplePayButtonProps, 'buttonStyle'>;
|
|
3
3
|
interface UseApplePayReturnProps {
|
|
4
4
|
loading: boolean;
|
|
5
|
-
onApplePayButtonClicked: () => Promise<void>;
|
|
6
5
|
disabled: boolean;
|
|
6
|
+
onApplePayButtonClicked: () => Promise<void>;
|
|
7
|
+
abortApplePaySession: () => void;
|
|
7
8
|
}
|
|
8
|
-
export declare const useApplePay: ({ publicKey, merchant, transaction, interface: interfaceObj, customer, onCancel, onError, onSuccess, scope, acceptance, metaData, debug, environment, onReady }: UseApplePayProps) => UseApplePayReturnProps;
|
|
9
|
+
export declare const useApplePay: ({ publicKey, merchant, transaction, interface: interfaceObj, customer, onCancel, onError, onSuccess, scope, acceptance, features, metaData, debug, environment, onReady, onMerchantValidation, onShippingMethodSelected, onShippingContactSelected, onPaymentMethodSelected, onCouponChanged }: UseApplePayProps) => UseApplePayReturnProps;
|
|
9
10
|
export {};
|
|
@@ -52,10 +52,14 @@ import { setAxiosGlobalHeaders } from '../api/httpClient';
|
|
|
52
52
|
import { getApplePayPaymentMethod, getApplePayRequest, validateCurrency, validateSupportedNetworks } from '../utils/config';
|
|
53
53
|
import { getMerchantCapaplities } from '../utils/defaultValues';
|
|
54
54
|
export var useApplePay = function (_a) {
|
|
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
|
+
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, features = _a.features, metaData = _a.metaData, debug = _a.debug, environment = _a.environment, onReady = _a.onReady, onMerchantValidation = _a.onMerchantValidation, onShippingMethodSelected = _a.onShippingMethodSelected, onShippingContactSelected = _a.onShippingContactSelected, onPaymentMethodSelected = _a.onPaymentMethodSelected, onCouponChanged = _a.onCouponChanged;
|
|
56
56
|
var _b = useState(false), loading = _b[0], setLoading = _b[1];
|
|
57
57
|
var _c = useState(null), profileData = _c[0], setProfile = _c[1];
|
|
58
58
|
var _d = useState(false), disabled = _d[0], setDisabled = _d[1];
|
|
59
|
+
var _e = useState(undefined), applePaySession = _e[0], setApplePaySession = _e[1];
|
|
60
|
+
var abortApplePaySession = useCallback(function () {
|
|
61
|
+
applePaySession === null || applePaySession === void 0 ? void 0 : applePaySession.abort();
|
|
62
|
+
}, [applePaySession]);
|
|
59
63
|
var initialize = useCallback(function (metaData) { return __awaiter(void 0, void 0, void 0, function () {
|
|
60
64
|
var merchantProfile, payment_options, headers, data, err_1;
|
|
61
65
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
@@ -147,8 +151,9 @@ export var useApplePay = function (_a) {
|
|
|
147
151
|
try {
|
|
148
152
|
paymentMethod = getApplePayPaymentMethod(profileData.payment_options.payment_methods || []);
|
|
149
153
|
currency = validateCurrency(transaction.currency, paymentMethod.supported_currencies);
|
|
150
|
-
cardBrands = validateSupportedNetworks(paymentMethod.supported_card_brands, acceptance.supportedBrands);
|
|
154
|
+
cardBrands = validateSupportedNetworks(paymentMethod.supported_card_brands, acceptance === null || acceptance === void 0 ? void 0 : acceptance.supportedBrands);
|
|
151
155
|
request = getApplePayRequest({
|
|
156
|
+
features: features,
|
|
152
157
|
countryCode: profileData.merchant.country_code,
|
|
153
158
|
transaction: __assign(__assign({}, transaction), { currency: currency }),
|
|
154
159
|
customer: customer,
|
|
@@ -160,11 +165,13 @@ export var useApplePay = function (_a) {
|
|
|
160
165
|
console.info("Creating ApplePaySession with version: ".concat(ApplePayVersion, " and request: ").concat(JSON.stringify(request)));
|
|
161
166
|
}
|
|
162
167
|
session_1 = new ApplePaySession(ApplePayVersion, request);
|
|
168
|
+
setApplePaySession(session_1);
|
|
163
169
|
session_1.onvalidatemerchant = function (event) { return __awaiter(void 0, void 0, void 0, function () {
|
|
164
170
|
var merchantSession, error_1;
|
|
165
171
|
return __generator(this, function (_a) {
|
|
166
172
|
switch (_a.label) {
|
|
167
173
|
case 0:
|
|
174
|
+
onMerchantValidation === null || onMerchantValidation === void 0 ? void 0 : onMerchantValidation('initiated');
|
|
168
175
|
if (debug) {
|
|
169
176
|
console.info('Creating merchant session and validating merchant session');
|
|
170
177
|
console.info('onvalidatemerchant event', event);
|
|
@@ -176,16 +183,19 @@ export var useApplePay = function (_a) {
|
|
|
176
183
|
if (debug) {
|
|
177
184
|
console.info("creating merchant session for merchantData: ".concat(JSON.stringify(profileData.merchant), " and validationURL: ").concat(event.validationURL, " and merchant.domain: ").concat(merchant.domain));
|
|
178
185
|
}
|
|
179
|
-
return [4, appService.appleSession(__assign(__assign({}, profileData.merchant), { id: merchant.id }), event.validationURL, merchant.domain, merchant.id)];
|
|
186
|
+
return [4, appService.appleSession(__assign(__assign({}, profileData.merchant), { id: merchant.id }), event.validationURL, merchant.domain, merchant.identifier || merchant.id)];
|
|
180
187
|
case 2:
|
|
181
188
|
merchantSession = _a.sent();
|
|
182
189
|
if (debug)
|
|
183
190
|
console.info('merchantSession', merchantSession);
|
|
184
191
|
session_1.completeMerchantValidation(merchantSession);
|
|
185
|
-
|
|
192
|
+
onMerchantValidation === null || onMerchantValidation === void 0 ? void 0 : onMerchantValidation('completed');
|
|
193
|
+
if (debug)
|
|
194
|
+
console.info('merchantSession completed successfully!');
|
|
186
195
|
return [3, 4];
|
|
187
196
|
case 3:
|
|
188
197
|
error_1 = _a.sent();
|
|
198
|
+
onMerchantValidation === null || onMerchantValidation === void 0 ? void 0 : onMerchantValidation('error');
|
|
189
199
|
if (debug)
|
|
190
200
|
console.error('error in onvalidatemerchant', error_1);
|
|
191
201
|
session_1.completePayment({ status: ApplePaySession.STATUS_FAILURE });
|
|
@@ -245,6 +255,82 @@ export var useApplePay = function (_a) {
|
|
|
245
255
|
}
|
|
246
256
|
});
|
|
247
257
|
}); };
|
|
258
|
+
if (onShippingContactSelected) {
|
|
259
|
+
session_1.onshippingcontactselected = function (_a) {
|
|
260
|
+
var shippingContact = _a.shippingContact;
|
|
261
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
262
|
+
var response;
|
|
263
|
+
return __generator(this, function (_b) {
|
|
264
|
+
switch (_b.label) {
|
|
265
|
+
case 0: return [4, onShippingContactSelected(shippingContact)];
|
|
266
|
+
case 1:
|
|
267
|
+
response = _b.sent();
|
|
268
|
+
if (response) {
|
|
269
|
+
session_1.completeShippingContactSelection(response);
|
|
270
|
+
}
|
|
271
|
+
return [2];
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
});
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
if (onShippingMethodSelected) {
|
|
278
|
+
session_1.onshippingmethodselected = function (_a) {
|
|
279
|
+
var shippingMethod = _a.shippingMethod;
|
|
280
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
281
|
+
var response;
|
|
282
|
+
return __generator(this, function (_b) {
|
|
283
|
+
switch (_b.label) {
|
|
284
|
+
case 0: return [4, onShippingMethodSelected(shippingMethod)];
|
|
285
|
+
case 1:
|
|
286
|
+
response = _b.sent();
|
|
287
|
+
if (response) {
|
|
288
|
+
session_1.completeShippingMethodSelection(response);
|
|
289
|
+
}
|
|
290
|
+
return [2];
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
});
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
if (onPaymentMethodSelected) {
|
|
297
|
+
session_1.onpaymentmethodselected = function (_a) {
|
|
298
|
+
var paymentMethod = _a.paymentMethod;
|
|
299
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
300
|
+
var response;
|
|
301
|
+
return __generator(this, function (_b) {
|
|
302
|
+
switch (_b.label) {
|
|
303
|
+
case 0: return [4, onPaymentMethodSelected(paymentMethod)];
|
|
304
|
+
case 1:
|
|
305
|
+
response = _b.sent();
|
|
306
|
+
if (response) {
|
|
307
|
+
session_1.completePaymentMethodSelection(response);
|
|
308
|
+
}
|
|
309
|
+
return [2];
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
});
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
if (onCouponChanged) {
|
|
316
|
+
session_1.oncouponcodechanged = function (_a) {
|
|
317
|
+
var couponCode = _a.couponCode;
|
|
318
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
319
|
+
var response;
|
|
320
|
+
return __generator(this, function (_b) {
|
|
321
|
+
switch (_b.label) {
|
|
322
|
+
case 0: return [4, onCouponChanged(couponCode)];
|
|
323
|
+
case 1:
|
|
324
|
+
response = _b.sent();
|
|
325
|
+
if (response) {
|
|
326
|
+
session_1.completeCouponCodeChange(response);
|
|
327
|
+
}
|
|
328
|
+
return [2];
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
});
|
|
332
|
+
};
|
|
333
|
+
}
|
|
248
334
|
session_1.oncancel = function (event) {
|
|
249
335
|
console.info('oncancel event', event);
|
|
250
336
|
if (onCancel)
|
|
@@ -272,5 +358,10 @@ export var useApplePay = function (_a) {
|
|
|
272
358
|
return [2];
|
|
273
359
|
});
|
|
274
360
|
}); };
|
|
275
|
-
return {
|
|
361
|
+
return {
|
|
362
|
+
loading: loading,
|
|
363
|
+
disabled: !profileData || disabled,
|
|
364
|
+
onApplePayButtonClicked: onApplePayButtonClicked,
|
|
365
|
+
abortApplePaySession: abortApplePaySession
|
|
366
|
+
};
|
|
276
367
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useCallback, useEffect } from 'react';
|
|
2
|
+
export var GetEvents;
|
|
3
|
+
(function (GetEvents) {
|
|
4
|
+
GetEvents["ABORT"] = "applepaySDK:abort";
|
|
5
|
+
})(GetEvents || (GetEvents = {}));
|
|
6
|
+
export var useGetEvents = function (onEventReceieved) {
|
|
7
|
+
var onEventReceievedFun = useCallback(function (msg) {
|
|
8
|
+
var event = msg.data.event;
|
|
9
|
+
onEventReceieved(event);
|
|
10
|
+
}, [onEventReceieved]);
|
|
11
|
+
useEffect(function () {
|
|
12
|
+
window.addEventListener('message', onEventReceievedFun);
|
|
13
|
+
return function () { return window.removeEventListener('message', onEventReceievedFun); };
|
|
14
|
+
}, [onEventReceievedFun]);
|
|
15
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function useScript(src: string, async?: boolean): "
|
|
1
|
+
export declare function useScript(src: string, async?: boolean): "error" | "loading" | "ready" | "idle";
|
package/build/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApplePayButtonProps, ApplePayButton } from './features/ApplePayButton';
|
|
1
|
+
import { ApplePayButtonProps, ApplePayButton, abortApplePaySession } from './features/ApplePayButton';
|
|
2
2
|
import { ThemeMode, Scope, SupportedNetworks, Environment, Locale, ButtonType, Edges, MerchantCapabilities } from './constants';
|
|
3
3
|
export type { ApplePayButtonProps };
|
|
4
|
-
export { ApplePayButton, ThemeMode, Scope, SupportedNetworks, Environment, Locale, ButtonType, Edges, MerchantCapabilities };
|
|
4
|
+
export { ApplePayButton, abortApplePaySession, ThemeMode, Scope, SupportedNetworks, Environment, Locale, ButtonType, Edges, MerchantCapabilities };
|
package/build/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { ApplePayButton, render } from './features/ApplePayButton';
|
|
1
|
+
import { ApplePayButton, render, abortApplePaySession } from './features/ApplePayButton';
|
|
2
2
|
import { ThemeMode, Scope, SupportedNetworks, Environment, Locale, ButtonType, Edges, MerchantCapabilities } from './constants';
|
|
3
|
-
export { ApplePayButton, ThemeMode, Scope, SupportedNetworks, Environment, Locale, ButtonType, Edges, MerchantCapabilities };
|
|
3
|
+
export { ApplePayButton, abortApplePaySession, ThemeMode, Scope, SupportedNetworks, Environment, Locale, ButtonType, Edges, MerchantCapabilities };
|
|
4
4
|
window['TapApplepaySDK'] = {
|
|
5
5
|
render: render,
|
|
6
|
+
abortApplePaySession: abortApplePaySession,
|
|
6
7
|
Scope: Scope,
|
|
7
8
|
SupportedNetworks: SupportedNetworks,
|
|
8
9
|
Environment: Environment,
|
package/build/utils/config.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ 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, merchantCapabilities, countryCode, name }: Pick<ApplePayButtonProps, "transaction" | "customer"> & {
|
|
5
|
+
export declare const getApplePayRequest: ({ transaction, customer, supportedNetworks, merchantCapabilities, countryCode, name, features }: Pick<ApplePayButtonProps, "transaction" | "customer" | "features"> & {
|
|
6
6
|
supportedNetworks: Acceptance['supportedBrands'];
|
|
7
7
|
merchantCapabilities: ApplePayRequestData['merchantCapabilities'];
|
|
8
8
|
countryCode: string;
|
package/build/utils/config.js
CHANGED
|
@@ -24,8 +24,8 @@ export var validateCurrency = function (currency, currencies) {
|
|
|
24
24
|
return currency;
|
|
25
25
|
};
|
|
26
26
|
export var getApplePayRequest = function (_a) {
|
|
27
|
-
var _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
28
|
-
var transaction = _a.transaction, customer = _a.customer, supportedNetworks = _a.supportedNetworks, merchantCapabilities = _a.merchantCapabilities, countryCode = _a.countryCode, name = _a.name;
|
|
27
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
28
|
+
var transaction = _a.transaction, customer = _a.customer, supportedNetworks = _a.supportedNetworks, merchantCapabilities = _a.merchantCapabilities, countryCode = _a.countryCode, name = _a.name, features = _a.features;
|
|
29
29
|
return {
|
|
30
30
|
countryCode: countryCode,
|
|
31
31
|
currencyCode: transaction.currency,
|
|
@@ -40,7 +40,26 @@ export var getApplePayRequest = function (_a) {
|
|
|
40
40
|
total: {
|
|
41
41
|
amount: Number(transaction.amount),
|
|
42
42
|
label: name
|
|
43
|
-
}
|
|
43
|
+
},
|
|
44
|
+
supportsCouponCode: features.supportsCouponCode,
|
|
45
|
+
couponCode: transaction.couponCode,
|
|
46
|
+
requiredShippingContactFields: features === null || features === void 0 ? void 0 : features.shippingContactFields,
|
|
47
|
+
shippingMethods: transaction.shipping,
|
|
48
|
+
lineItems: (_l = transaction.items) === null || _l === void 0 ? void 0 : _l.map(function (item) {
|
|
49
|
+
var _a, _b, _c, _d, _e, _f;
|
|
50
|
+
return ({
|
|
51
|
+
type: item.type,
|
|
52
|
+
label: item.label,
|
|
53
|
+
amount: item.amount,
|
|
54
|
+
paymentTiming: item.paymentTiming,
|
|
55
|
+
recurringPaymentStartDate: (_a = item.scheduledPayment) === null || _a === void 0 ? void 0 : _a.recurringStartDate,
|
|
56
|
+
recurringPaymentIntervalUnit: (_b = item.scheduledPayment) === null || _b === void 0 ? void 0 : _b.recurringIntervalUnit,
|
|
57
|
+
recurringPaymentIntervalCount: (_c = item.scheduledPayment) === null || _c === void 0 ? void 0 : _c.recurringIntervalCount,
|
|
58
|
+
recurringPaymentEndDate: (_d = item.scheduledPayment) === null || _d === void 0 ? void 0 : _d.recurringEndDate,
|
|
59
|
+
deferredPaymentDate: (_e = item.deferredPayment) === null || _e === void 0 ? void 0 : _e.deferredPaymentDate,
|
|
60
|
+
automaticReloadPaymentThresholdAmount: (_f = item.automaticReloadPayment) === null || _f === void 0 ? void 0 : _f.thresholdAmount
|
|
61
|
+
});
|
|
62
|
+
})
|
|
44
63
|
};
|
|
45
64
|
};
|
|
46
65
|
export var getApplePayPaymentMethod = function (paymentMethods) {
|
|
@@ -12,18 +12,22 @@ export declare const getDefaultValues: (mainObject: ApplePayButtonProps) => {
|
|
|
12
12
|
merchant: {
|
|
13
13
|
id: string;
|
|
14
14
|
domain: string;
|
|
15
|
+
identifier?: string | undefined;
|
|
15
16
|
};
|
|
16
17
|
customer?: import("../@types").Customer | undefined;
|
|
17
18
|
acceptance: import("../@types").Acceptance;
|
|
18
|
-
transaction:
|
|
19
|
-
|
|
20
|
-
currency: string;
|
|
21
|
-
};
|
|
19
|
+
transaction: import("../@types").Transaction;
|
|
20
|
+
features: import("../@types").Features;
|
|
22
21
|
onCancel?: (() => void) | undefined;
|
|
23
22
|
onError?: ((error: any) => void) | undefined;
|
|
24
23
|
onSuccess?: ((data: Record<string, any>) => Promise<void>) | undefined;
|
|
25
24
|
onClick?: (() => void) | undefined;
|
|
26
25
|
onReady?: (() => void) | undefined;
|
|
26
|
+
onMerchantValidation?: ((status: "initiated" | "completed" | "error") => void) | undefined;
|
|
27
|
+
onShippingMethodSelected?: ((shippingMethod: import("../@types").ApplePayShippingMethod) => Promise<import("../@types").ApplePayUpdateData>) | undefined;
|
|
28
|
+
onShippingContactSelected?: ((shippingContact: import("../@types").ApplePayPaymentContact) => Promise<import("../@types").ApplePayUpdateData>) | undefined;
|
|
29
|
+
onPaymentMethodSelected?: ((paymentMethod: import("../@types").ApplePayPaymentMethod) => Promise<import("../@types").ApplePayUpdateData>) | undefined;
|
|
30
|
+
onCouponChanged?: ((couponCode: string) => Promise<import("../@types").ApplePayUpdateData>) | undefined;
|
|
27
31
|
metaData?: import("../@types").MetaData | undefined;
|
|
28
32
|
debug?: boolean | undefined;
|
|
29
33
|
};
|