@tap-payments/apple-pay-button 0.0.21-test → 0.0.22-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 +51 -68
- package/build/@types/index.d.ts +29 -0
- package/build/api/app.service.d.ts +2 -2
- package/build/api/app.service.js +2 -2
- package/build/hooks/useApplePay.js +35 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -129,74 +129,57 @@ const App = () => {
|
|
|
129
129
|
<script type="text/javascript">
|
|
130
130
|
const { renderApplePayButton, ButtonStyle, Scope, SupportedNetworks, Locale, ButtonType } = window.TapSDKs
|
|
131
131
|
renderApplePayButton(
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
code: '+20'
|
|
184
|
-
}
|
|
185
|
-
},
|
|
186
|
-
// optional
|
|
187
|
-
onCancel: () => {
|
|
188
|
-
console.log('onCancel')
|
|
189
|
-
},
|
|
190
|
-
// optional
|
|
191
|
-
onError: (error) => {
|
|
192
|
-
console.log('onError', error)
|
|
193
|
-
},
|
|
194
|
-
// optional
|
|
195
|
-
onSuccess: async (data) => {
|
|
196
|
-
console.log('onSuccess', data)
|
|
197
|
-
}
|
|
198
|
-
},
|
|
199
|
-
'apple-pay-button'
|
|
132
|
+
{
|
|
133
|
+
publicKey: 'pk_test_7xxxxxxxxx',
|
|
134
|
+
merchantIdentifier: 'merchant.com.xxxxx',
|
|
135
|
+
environment: Environment.Sandbox,
|
|
136
|
+
merchant: {
|
|
137
|
+
domain: 'tp-txxxxxxxx',
|
|
138
|
+
|
|
139
|
+
id: 'merchant_xxxxxxxxxx"
|
|
140
|
+
},
|
|
141
|
+
|
|
142
|
+
transaction: {
|
|
143
|
+
|
|
144
|
+
currency: 'SAR',
|
|
145
|
+
|
|
146
|
+
amount: '3'
|
|
147
|
+
},
|
|
148
|
+
|
|
149
|
+
scope: Scope.TapToken,
|
|
150
|
+
buttonStyle: ButtonStyle.Black,
|
|
151
|
+
type: ButtonType.PLAIN,
|
|
152
|
+
locale: Locale.EN,
|
|
153
|
+
supportedNetworks: [SupportedNetworks.Visa, SupportedNetworks.MasterCard, SupportedNetworks.Mada],
|
|
154
|
+
billingContact: {
|
|
155
|
+
email: {
|
|
156
|
+
|
|
157
|
+
address: 'test`@gmail.com'
|
|
158
|
+
},
|
|
159
|
+
name: {
|
|
160
|
+
first: 'test',
|
|
161
|
+
last: 'test',
|
|
162
|
+
middle: '123'
|
|
163
|
+
},
|
|
164
|
+
phone: {
|
|
165
|
+
number: '555555555',
|
|
166
|
+
code: '966'
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
onCancel: async () => {
|
|
170
|
+
console.log('onCancel')
|
|
171
|
+
},
|
|
172
|
+
onError: async (error) => {
|
|
173
|
+
console.log('onError', error)
|
|
174
|
+
},
|
|
175
|
+
onSuccess: async (data) => {
|
|
176
|
+
console.log('onSuccess', data)
|
|
177
|
+
},
|
|
178
|
+
onReady: async () => {
|
|
179
|
+
console.log('onReady')
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
'apple-pay-button'
|
|
200
183
|
)
|
|
201
184
|
</script>
|
|
202
185
|
</body>
|
package/build/@types/index.d.ts
CHANGED
|
@@ -80,3 +80,32 @@ export interface MetaData {
|
|
|
80
80
|
payment_options: PaymentOptionsResponse;
|
|
81
81
|
headers: Record<string, string>;
|
|
82
82
|
}
|
|
83
|
+
export interface CheckoutProfileRequest {
|
|
84
|
+
currency: string;
|
|
85
|
+
merchant_id: string;
|
|
86
|
+
total_amount: number;
|
|
87
|
+
order: {
|
|
88
|
+
amount: number;
|
|
89
|
+
currency: string;
|
|
90
|
+
customer?: {
|
|
91
|
+
id: string;
|
|
92
|
+
email: string;
|
|
93
|
+
first_name: string;
|
|
94
|
+
last_name: string;
|
|
95
|
+
phone: {
|
|
96
|
+
country_code: string;
|
|
97
|
+
number: string;
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
items: {
|
|
101
|
+
quantity: number;
|
|
102
|
+
amount: number;
|
|
103
|
+
currency: string;
|
|
104
|
+
name: string;
|
|
105
|
+
requiresShipping: string;
|
|
106
|
+
}[];
|
|
107
|
+
merchant: {
|
|
108
|
+
id: string;
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MerchantResponse, ApplePayButtonProps } from '../@types';
|
|
1
|
+
import { MerchantResponse, ApplePayButtonProps, CheckoutProfileRequest } from '../@types';
|
|
2
2
|
import BaseService from './base';
|
|
3
3
|
declare class APPService extends BaseService {
|
|
4
4
|
private baseUrl;
|
|
@@ -12,7 +12,7 @@ declare class APPService extends BaseService {
|
|
|
12
12
|
pk: string;
|
|
13
13
|
domain: string;
|
|
14
14
|
}): Promise<void>;
|
|
15
|
-
checkoutProfile(
|
|
15
|
+
checkoutProfile(request: CheckoutProfileRequest): Promise<{
|
|
16
16
|
merchant: any;
|
|
17
17
|
payment_options: any;
|
|
18
18
|
}>;
|
package/build/api/app.service.js
CHANGED
|
@@ -176,12 +176,12 @@ var APPService = (function (_super) {
|
|
|
176
176
|
enumerable: false,
|
|
177
177
|
configurable: true,
|
|
178
178
|
writable: true,
|
|
179
|
-
value: function (
|
|
179
|
+
value: function (request) {
|
|
180
180
|
return __awaiter(this, void 0, void 0, function () {
|
|
181
181
|
var data, merchant, payment_options, session;
|
|
182
182
|
return __generator(this, function (_a) {
|
|
183
183
|
switch (_a.label) {
|
|
184
|
-
case 0: return [4, this.post(this.baseUrl + '/checkoutprofile',
|
|
184
|
+
case 0: return [4, this.post(this.baseUrl + '/checkoutprofile', request)];
|
|
185
185
|
case 1:
|
|
186
186
|
data = (_a.sent()).data;
|
|
187
187
|
if (data.errors)
|
|
@@ -57,15 +57,16 @@ export var useApplePay = function (_a) {
|
|
|
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
|
-
|
|
61
|
-
|
|
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
|
-
|
|
67
|
+
_c.label = 1;
|
|
67
68
|
case 1:
|
|
68
|
-
|
|
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,16 +75,42 @@ 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
|
-
|
|
78
|
-
return [4, appService.checkoutProfile(
|
|
78
|
+
_c.sent();
|
|
79
|
+
return [4, appService.checkoutProfile({
|
|
80
|
+
currency: transaction.currency,
|
|
81
|
+
merchant_id: (_a = merchant.id) !== null && _a !== void 0 ? _a : '',
|
|
82
|
+
total_amount: Number(transaction.amount),
|
|
83
|
+
order: __assign(__assign({ amount: Number(transaction.amount), currency: transaction.currency }, (billingContact && {
|
|
84
|
+
customer: {
|
|
85
|
+
id: '',
|
|
86
|
+
email: billingContact.email.address,
|
|
87
|
+
first_name: billingContact.name.first,
|
|
88
|
+
last_name: billingContact.name.last,
|
|
89
|
+
phone: {
|
|
90
|
+
country_code: billingContact.phone.code,
|
|
91
|
+
number: billingContact.phone.number
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
})), { merchant: {
|
|
95
|
+
id: (_b = merchant.id) !== null && _b !== void 0 ? _b : ''
|
|
96
|
+
}, items: [
|
|
97
|
+
{
|
|
98
|
+
amount: Number(transaction.amount),
|
|
99
|
+
currency: transaction.currency,
|
|
100
|
+
name: 'apple pay sdk order item',
|
|
101
|
+
quantity: 1,
|
|
102
|
+
requiresShipping: 'no'
|
|
103
|
+
}
|
|
104
|
+
] })
|
|
105
|
+
})];
|
|
79
106
|
case 3:
|
|
80
|
-
data =
|
|
107
|
+
data = _c.sent();
|
|
81
108
|
if (debug)
|
|
82
109
|
console.log('merchant configuration: ', data);
|
|
83
110
|
setProfile(data);
|
|
84
111
|
return [3, 6];
|
|
85
112
|
case 4:
|
|
86
|
-
err_1 =
|
|
113
|
+
err_1 = _c.sent();
|
|
87
114
|
onError && onError(err_1.errors || err_1);
|
|
88
115
|
return [3, 6];
|
|
89
116
|
case 5:
|