import type {
    ApplePayOneTimePaymentSession
}
from "@paypal/react-paypal-js/sdk-v6";


export type PaypalApplePaySession =
    ApplePayOneTimePaymentSession & {

        config: () => Promise<{
            merchantCapabilities:string[];
            supportedNetworks:string[];
            merchantCountry:string;
            tokenNotificationURL:string;
            isEligible: boolean;
        }>

    };


export async function getPaypalApplePayConfig(
    session: PaypalApplePaySession
){

    const config = await session.config();


    return {
        countryCode: config.merchantCountry,

        merchantCapabilities: config.merchantCapabilities,

        supportedNetworks: config.supportedNetworks,

        tokenNotificationURL: config.tokenNotificationURL,

        isEligible: config.isEligible
    };
}