@tagadapay/plugin-sdk 1.0.27 → 1.0.29
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useCallback, useEffect, useState } from 'react';
|
|
2
2
|
import { useTagadaContext } from '../providers/TagadaProvider';
|
|
3
3
|
export function usePostPurchases(options) {
|
|
4
|
-
const { apiService } = useTagadaContext();
|
|
4
|
+
const { apiService, session } = useTagadaContext();
|
|
5
5
|
const { orderId, enabled = true } = options;
|
|
6
6
|
const [offers, setOffers] = useState([]);
|
|
7
7
|
const [isLoading, setIsLoading] = useState(false);
|
|
@@ -29,12 +29,15 @@ export function usePostPurchases(options) {
|
|
|
29
29
|
}
|
|
30
30
|
}, [orderId]);
|
|
31
31
|
const initCheckoutSession = useCallback(async (offerId, orderId) => {
|
|
32
|
+
if (!session?.customerId) {
|
|
33
|
+
throw new Error('Customer ID is required');
|
|
34
|
+
}
|
|
32
35
|
const response = await apiService.fetch(`/api/v1/checkout/offer/init`, {
|
|
33
36
|
method: 'POST',
|
|
34
37
|
body: JSON.stringify({
|
|
35
38
|
offerId: offerId,
|
|
36
39
|
returnUrl: window.location.href,
|
|
37
|
-
customerId:
|
|
40
|
+
customerId: session?.customerId,
|
|
38
41
|
orderId,
|
|
39
42
|
}),
|
|
40
43
|
});
|