#Map Internal Customer ID with Dodo Customer ID

1 messages · Page 1 of 1 (latest)

pearl cloak
#

I am using dodo payments with betterAudth Adapter , Could anyone please help me with how can I can map my internal customer id to dodo customer id. I already have enabled createCustomerOnSignUp: true in betterAuth config for Dodo Payments. Please share the required steps. Thank you 🙂

umbral quailBOT
#

To map your internal customer ID to a Dodo customer ID using the BetterAuth Adapter, you need to follow these steps:

  1. Ensure Configuration for Customer Creation:

    • You have already set createCustomerOnSignUp: true in your BetterAuth configuration, which automatically creates a customer in Dodo Payments upon user sign-up. This is a crucial step to ensure each of your users gets a corresponding Dodo customer ID.
  2. Retrieve Dodo Customer ID:

    • Once a customer is created in Dodo Payments, you can retrieve the Dodo customer ID by querying the Dodo Payments API using your internal customer identifier (if stored during sign-up) or by mapping it to a specific user action that fetches customer details.
    • Use the following API endpoint to get customer details:
      import DodoPayments from 'dodopayments';
      
      const client = new DodoPayments({
        bearerToken: 'Your Bearer Token',
      });
      
      const customer = await client.customers.retrieve('customer_id');
      console.log(customer.business_id);
      
  3. Store and Map IDs:

    • Once you have the Dodo customer ID, store it in your database alongside your internal customer ID for easy mapping and reference in future transactions or operations.
  4. Use Webhooks (Optional):

    • To automatically update or map changes in customer data, consider setting up webhooks. This will allow your system to respond to real-time events from Dodo Payments, such as when a customer is created or updated.
  5. Testing:

    • Test the setup in a non-production environment (using test_mode) to ensure that the mapping works as expected and that all customer data is correctly synchronized between your system and Dodo Payments.