#Map Internal Customer ID with Dodo Customer ID
1 messages · Page 1 of 1 (latest)
To map your internal customer ID to a Dodo customer ID using the BetterAuth Adapter, you need to follow these steps:
-
Ensure Configuration for Customer Creation:
- You have already set
createCustomerOnSignUp: truein 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.
- You have already set
-
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);
-
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.
-
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.
-
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.
- Test the setup in a non-production environment (using