Add PayPal checkout provider
This commit is contained in:
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import toast from 'react-hot-toast';
|
||||
|
||||
import { createTenantLemonSqueezyCheckout } from '../../api';
|
||||
import { createTenantPayPalCheckout } from '../../api';
|
||||
import { adminPath } from '../../constants';
|
||||
import { getApiErrorMessage } from '../../lib/apiError';
|
||||
import { storePendingCheckout } from '../lib/billingCheckout';
|
||||
@@ -33,7 +33,7 @@ export function usePackageCheckout(): {
|
||||
cancelUrl.searchParams.set('checkout', 'cancel');
|
||||
cancelUrl.searchParams.set('package_id', String(packageId));
|
||||
|
||||
const { checkout_url, checkout_session_id } = await createTenantLemonSqueezyCheckout(packageId, {
|
||||
const { approve_url, order_id, checkout_session_id } = await createTenantPayPalCheckout(packageId, {
|
||||
success_url: successUrl.toString(),
|
||||
return_url: cancelUrl.toString(),
|
||||
});
|
||||
@@ -43,10 +43,15 @@ export function usePackageCheckout(): {
|
||||
packageId,
|
||||
checkoutSessionId: checkout_session_id,
|
||||
startedAt: Date.now(),
|
||||
orderId: order_id,
|
||||
});
|
||||
}
|
||||
|
||||
window.location.href = checkout_url;
|
||||
if (!approve_url) {
|
||||
throw new Error('PayPal checkout URL missing.');
|
||||
}
|
||||
|
||||
window.location.href = approve_url;
|
||||
} catch (err) {
|
||||
toast.error(getApiErrorMessage(err, t('shop.errors.checkout', 'Checkout failed')));
|
||||
setBusy(false);
|
||||
|
||||
Reference in New Issue
Block a user