Introduction
Sync your payment data directly to HubSpot CRM. Create contacts from successful payments, track subscription lifecycle, and build comprehensive customer profiles—all automatically triggered by Dodo Payments events.
This integration requires HubSpot admin access to configure OAuth scopes and API permissions.
Getting Started
Open the Webhook Section
In your Dodo Payments dashboard, go to Webhooks → + Add Endpoint and expand the integrations dropdown.
Select HubSpot
Choose the HubSpot integration card.
Connect HubSpot
Click Connect to HubSpot and authorize the required OAuth scopes.
Configure Transformation
Edit the transformation code to map payment data to HubSpot CRM objects.
Test & Create
Test with sample payloads and click Create to activate the sync.
Done!
🎉 Payment events will now automatically create/update records in your HubSpot CRM.
function handler ( webhook ) {
if ( webhook . eventType === "payment.succeeded" ) {
const p = webhook . payload . data ;
webhook . url = "https://api.hubapi.com/crm/v3/objects/contacts" ;
webhook . payload = {
properties: {
email: p . customer . email ,
firstname: p . customer . name . split ( ' ' )[ 0 ] || '' ,
lastname: p . customer . name . split ( ' ' ). slice ( 1 ). join ( ' ' ) || '' ,
phone: p . customer . phone || '' ,
company: p . customer . company || '' ,
amount: ( p . total_amount / 100 ). toString (),
payment_method: p . payment_method || '' ,
currency: p . currency || 'USD'
}
};
}
return webhook ;
}
See all 19 lines
function handler ( webhook ) {
if ( webhook . eventType === "subscription.active" ) {
const s = webhook . payload . data ;
webhook . url = `https://api.hubapi.com/crm/v3/objects/contacts/ ${ s . customer . customer_id } ` ;
webhook . method = "PATCH" ;
webhook . payload = {
properties: {
subscription_status: "active" ,
subscription_amount: ( s . recurring_pre_tax_amount / 100 ). toString (),
subscription_frequency: s . payment_frequency_interval ,
next_billing_date: s . next_billing_date ,
product_id: s . product_id
}
};
}
return webhook ;
}
See all 17 lines
Create Deal from Payment
function handler ( webhook ) {
if ( webhook . eventType === "payment.succeeded" ) {
const p = webhook . payload . data ;
webhook . url = "https://api.hubapi.com/crm/v3/objects/deals" ;
webhook . payload = {
properties: {
dealname: `Payment - ${ p . customer . email } ` ,
amount: ( p . total_amount / 100 ). toString (),
dealstage: "closedwon" ,
closedate: new Date (). toISOString (),
hs_currency: p . currency || "USD"
},
associations: [
{
to: {
id: p . customer . customer_id
},
types: [
{
associationCategory: "HUBSPOT_DEFINED" ,
associationTypeId: 3
}
]
}
]
};
}
return webhook ;
}
See all 29 lines
Tips
Use HubSpot’s API explorer to test object creation
Map payment amounts to HubSpot currency fields
Include customer IDs for proper associations
Set appropriate deal stages based on payment status
Troubleshooting
Records not created in HubSpot
Verify OAuth scopes include write permissions
Check that required HubSpot properties exist
Ensure customer email is valid and unique
Review HubSpot API rate limits