Attribute revenue with DodoPayments Checkout API

  • Pass metadata with
    insightly_visitor_id
    and
    insightly_session_id
    (cookies from Insightly) when creating a checkout session:
  • // app/api/create-checkout/route.js
    import DodoPayments from 'dodopayments';
    import { cookies } from 'next/headers';
    
    export async function POST() {
      const cookieStore = cookies();
      // If you're using Next.js 15+, use this instead:
      // const cookieStore = await cookies();
      
    
    const client = new DodoPayments({
      bearerToken: 'My Bearer Token',
    });
    
    const checkoutSessionResponse = await client.checkoutSessions.create({
      product_cart: [...],
          metadata: {
          insightly_visitor_id: cookieStore.get('insightly_visitor_id')?.value,
          insightly_session_id: cookieStore.get('insightly_session_id')?.value,
        },
    });
    
    }

    Once connected and metadata is properly passed, DataFast will automatically attribute revenue to the correct marketing channels. No webhook setup is required.