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

1

Open the Webhook Section

In your Dodo Payments dashboard, go to Webhooks → + Add Endpoint and expand the integrations dropdown.
Add Endpoint and integrations dropdown
2

Select HubSpot

Choose the HubSpot integration card.
3

Connect HubSpot

Click Connect to HubSpot and authorize the required OAuth scopes.
4

Configure Transformation

Edit the transformation code to map payment data to HubSpot CRM objects.
5

Test & Create

Test with sample payloads and click Create to activate the sync.
6

Done!

🎉 Payment events will now automatically create/update records in your HubSpot CRM.

Transformation Code Examples

Create Contact from Payment

create_contact.js
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.toString(),
        payment_method: p.payment_method || '',
        currency: p.currency || 'USD'
      }
    };
  }
  return webhook;
}

Update Contact with Subscription

update_contact.js
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.toString(),
        subscription_frequency: s.payment_frequency_interval,
        next_billing_date: s.next_billing_date,
        product_id: s.product_id
      }
    };
  }
  return webhook;
}

Create Deal from Payment

create_deal.js
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.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;
}

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