@paypal/paypal-js
    Preparing search index...

    Interface PayPalPaymentsInstance

    PayPal Payments Instance interface for creating and managing different types of PayPal payment sessions.

    This interface provides methods to create various PayPal payment flows including:

    • One-time payments with standard PayPal
    • Save payment methods for future use (vaulting)
    • PayPal Pay Later financing options
    • PayPal Credit transactions

    Each method returns a payment session object that can be used to initiate the corresponding payment flow with different presentation modes (popup, modal, redirect, etc.).

    // Create a one-time payment session
    const paypalCheckout = sdkInstance.createPayPalOneTimePaymentSession({
    onApprove: (data) => console.log('Payment approved:', data),
    onCancel: () => console.log('Payment canceled'),
    onError: (data) => console.error('Payment error:', data)
    });

    // Start the payment flow
    await paypalCheckout.start({ mode: 'auto' });
    interface PayPalPaymentsInstance {
        createPayLaterOneTimePaymentSession: (
            paymentSessionOptions: PayPalOneTimePaymentSessionOptions,
        ) => OneTimePaymentSession;
        createPayPalCreditOneTimePaymentSession: (
            paymentSessionOptions: PayPalOneTimePaymentSessionOptions,
        ) => OneTimePaymentSession;
        createPayPalOneTimePaymentSession: (
            paymentSessionOptions: PayPalOneTimePaymentSessionOptions,
        ) => OneTimePaymentSession;
        createPayPalSavePaymentSession: (
            paymentSessionOptions: SavePaymentSessionOptions,
        ) => SavePaymentSession;
    }
    Index

    Properties

    createPayLaterOneTimePaymentSession: (
        paymentSessionOptions: PayPalOneTimePaymentSessionOptions,
    ) => OneTimePaymentSession

    Creates a PayPal Pay Later one-time payment session for buy now, pay later transactions.

    Type Declaration

    This method enables customers to make purchases and pay for them over time through PayPal's Pay Later financing options. Available in supported countries.

    const payLaterSession = sdkInstance.createPayLaterOneTimePaymentSession({
    onApprove: (data) => {
    console.log('Pay Later payment approved:', data);
    },
    onCancel: () => {
    console.log('Pay Later payment canceled');
    },
    onError: (data) => {
    console.error('Pay Later payment error:', data);
    }
    });
    createPayPalCreditOneTimePaymentSession: (
        paymentSessionOptions: PayPalOneTimePaymentSessionOptions,
    ) => OneTimePaymentSession

    Creates a PayPal Credit one-time payment session for credit-based transactions.

    Type Declaration

    This method enables customers to make purchases using PayPal Credit, allowing them to pay over time with financing options. Available in supported countries.

    const creditSession = sdkInstance.createPayPalCreditOneTimePaymentSession({
    onApprove: (data) => {
    console.log('PayPal Credit payment approved:', data);
    },
    onCancel: () => {
    console.log('PayPal Credit payment canceled');
    },
    onError: (data) => {
    console.error('PayPal Credit payment error:', data);
    }
    });
    createPayPalOneTimePaymentSession: (
        paymentSessionOptions: PayPalOneTimePaymentSessionOptions,
    ) => OneTimePaymentSession

    Creates a PayPal one-time payment session for processing single payments through PayPal.

    Type Declaration

    This method allows you to configure callback functions to handle different stages of the PayPal checkout process, including payment approval, shipping address changes, shipping option changes, cancelation, and errors.

    const paypalSession = sdkInstance.createPayPalOneTimePaymentSession({
    onApprove: (data) => {
    console.log('PayPal payment approved:', data);
    },
    onShippingAddressChange: (data) => {
    console.log('Shipping address changed:', data);
    },
    onShippingOptionsChange: (data) => {
    console.log('Shipping options changed:', data);
    },
    onCancel: () => {
    console.log('PayPal payment canceled');
    },
    onError: (data) => {
    console.error('PayPal payment error:', data);
    }
    });
    createPayPalSavePaymentSession: (
        paymentSessionOptions: SavePaymentSessionOptions,
    ) => SavePaymentSession

    Creates a PayPal save payment session for storing payment methods for future use.

    Type Declaration

    This method allows you to set up vault payment sessions where customers can save their PayPal payment method for future transactions without re-entering details.

    const savePaymentSession = sdkInstance.createPayPalSavePaymentSession({
    vaultSetupToken: 'your-vault-setup-token',
    onApprove: (data) => {
    console.log('Payment method saved:', data);
    },
    onCancel: () => {
    console.log('Save payment canceled');
    },
    onError: (data) => {
    console.error('Save payment error:', data);
    }
    });