Skip to content
Stripe

How to Parse Stripe Metadata in HubSpot

Utilize Stripe metadata in HubSpot to enrich your data. In this article, we will cover how saas•hapily syncs Stripe metadata to HubSpot and how to parse it.

What is Stripe Metadata?

In addition to the standard properties of a Stripe object, metadata offers a flexible and powerful means of storing additional information. This information can be anything from a unique identifier to additional data that you want to track. 

metadata-examples@2x

 

For businesses using HubSpot that want a more automated payment processing experience, using saas•hapily with Stripe is the way to go. 

No matter the reason for storing metadata in Stripe, this information can often help enrich your HubSpot data. saas•hapily makes it easy to sync metadata associated with customers, subscriptions, and transactions to your HubSpot records.

In this article, we will cover how to separate (parse) Stripe metadata in HubSpot.

How does saas•hapily sync metadata to HubSpot?

Because metadata fields can vary greatly between object types, individual records, and use cases, saas•hapily does not create a property for each possible metadata field.

Instead, saas•hapily syncs all metadata fields on stripe Customers, Subscriptions, and Transactions to a HubSpot property on the relevant record.

Giving you full control to determine which properties and values are placed where.

How to Parse Stripe Metadata in a HubSpot Workflow:

Since saas•hapily syncs all Stripe metadata fields to a single property, you will need to utilize a HubSpot Custom Coded Workflow Action to parse the values. 

Metadata will enter the workflow in this format:

{"domain_name":"saas•hapily.com","account_id":"123"} 

And the values will leave nicely nested in a HubSpot Property!

workflow-overview@2x

1. Create your workflow:

Depending on the type of object you are parsing metadata for, you will need to create a workflow based on that object. In this example, we will be creating a saas•hapily Subscription based workflow

2. Set your Enrollment Triggers:

Set the workflow enrollment trigger to " Subscription Metadata is Known"  if you want the metadata to parse when the object is created.

Set "Subscription Metadata has been updated in the last 1 day" and turn on re-enrollments if you want subscription metadata to update anytime it's updated in Stripe. 

3. Create a Custom Coded Action

Set the following fields:

  • Language: Node.js 16.x
    cca-language
  • Properties to Include (Input Fields):
    •  Subscription Metadata: subscription_metadata
      input-fields@2x
  • Data Outputs: Add an option for each expected output/metadata field.
    • Select the data type and add a name such as "fieldOne". This will be referenced in the code. 
      data-outputs
  • Code: Copy and Paste the code below into the code section.
    parse-code@2x
    • Change the value highlighted in red to match your Input Field.
    • Change the values highlighted in yellow to match the metadata field names from Stripe.
    • Change the values highlighted in green to match the name assigned to your Data Output. 
  • Test your custom coded action and address any errors.

CODE: 

exports.main = async (event, callback) => {

/* When parsing metadata for a Contact or Transaction, change 'subcsription_metadata' to match the input field ('customer_metadata' or 'transaction_metadata') */
const metaData = JSON.parse(event.inputFields['subscription_metadata']);

/* To parse additional metadata fields, copy the text below and change the 'change_me' values to match the metadata field name in stripe.
const changeMe = metaData['change_me'] ? metaData['field_one'] : null;
*/


const fieldOne = metaData['field_one'] ? metaData['field_one'] : null;
const fieldTwo = metaData['field_two'] ? metaData['field_two'] : null;

/* Make sure the outputFields below match the const defined aboove */

callback({
outputFields: {
fieldOne,
fieldTwo
}
});
}

4. Copy the out to your HubSpot Properties:

Add a Copy Property Value action for each data output. 

copy-property-values@2x

In this example, I have added 2 outputs. One for the "fieldOne" output and another for the "fieldTwo" output.

And that's all folks! If you run into any issues in building this or would be interested in us building it for you, do not hesitate to get in touch!

 

Jonathan Stevens

Jonathan Stevens

Jonathan is a Product Support Specialist at hapily. He helps professionals power up their HubSpot experience by supporting the most powerful apps in the HubSpot marketplace.

Latest Articles

Simplifying Tax Breakdown for Subscription Services Quotes

Simplifying Tax Breakdown for Subscription Services Quotes

Learn the benefits of providing efficient tax breakdowns in quotes for subscription services. Enhance customer satisfaction and streamline ...

Organize Your SaaS Business: Managing Multiple Stripe Accounts

Organize Your SaaS Business: Managing Multiple Stripe Accounts

Discover why managing multiple Stripe accounts can help SaaS companies organize different services more effectively. Learn how this strateg...

Why Offering Multiple Payment Options Boosts Your Business

Why Offering Multiple Payment Options Boosts Your Business

Learn about different payment methods, their benefits, and how they can expand your customer base. Explore insights on increasing conversio...