Loading PayPal SDK...
;
}
if (loadingStatus === INSTANCE_LOADING_STATE.REJECTED) {
return
PayPal SDK loaded successfully
Hydrated: {isHydrated ? "Yes" : "No"}
{eligiblePaymentMethods && (
PayPal eligible: {eligiblePaymentMethods.isEligible("paypal") ? "Yes" : "No"}
)}
);
}
```
## useEligibleMethods Hook
The `useEligibleMethods` hook checks which payment methods are available for the current buyer. It handles both server-hydrated and client-fetch scenarios.
```tsx
import {
PayPalProvider,
PayPalOneTimePaymentButton,
VenmoOneTimePaymentButton,
PayLaterOneTimePaymentButton,
useEligibleMethods,
} from "@paypal/react-paypal-js/sdk-v6";
function PaymentOptions() {
const { eligiblePaymentMethods, isLoading, error } = useEligibleMethods({
payload: {
purchase_units: [{ amount: { currency_code: "USD", value: "100.00" } }],
},
});
if (isLoading) {
return Checking payment eligibility...
;
}
if (error) {
return Loading...
;
if (error) return Loading...
;
const createOrder = async () => {
const response = await fetch("/api/create-order", { method: "POST" });
const { orderId } = await response.json();
return { orderId };
};
return (