Payments

Use the payments API to fetch information about an account's payments. This is a read-only API, so it cannot be used for creating new or managing existing payments. 

For example, use this API to fetch all refunded payments in an account.

Requirements

To use this API, the account must be set up to collect payments through either HubSpot payments or Stripe payment processing.

Retrieve payments

Depending on the information you need, there are a few ways to retrieve payments:

  • To retrieve all payments, make a GET request to crm/v3/objects/commerce_payments.
  • To retrieve a payment, make a GET request to the above URL and specify an payment ID. For example: crm/v3/objects/commerce_payments/44446244097.
  • To retrieve payments that meet a specific set of criteria, you can make a POST request to the search endpoint and include filters in the request body. See an example of using the search endpoint below.

The response will include a few default properties, including the create date, last modified date.

// Example response { "id":"44446244097", "properties":{ "hs_createdate":"2023-03-08T14:54:17.333Z", "hs_lastmodifieddate":"2024-03-01T22:33:09.011Z", "hs_object_id":"44446244097" }, "createdAt":"2023-03-08T14:54:17.333Z", "updatedAt":"2024-03-01T22:33:09.011Z", "archived":false }

Properties

To return specific properties, include a properties query parameter in the request URL along with comma-separated property names. For example, making a GET request to the following URL would result in the response below:

crm/v3/objects/commerce_payments?properties=hs_customer_email,hs_latest_status

// Example response { "id":"40744976671", "properties":{ "hs_createdate":"2022-09-02T15:03:40.828Z", "hs_customer_email": "name@emailaddress.com", "hs_lastmodifieddate":"2024-02-27T15:03:53.620Z", "hs_object_id":"40744976671", "hs_latest_status":"succeeded" }, "createdAt":"2022-09-02T15:03:40.828Z", "updatedAt":"2024-02-27T15:03:53.620Z", "archived":false }

To view all available payment properties, make a GET request to crm/v3/properties/commerce_payments. Learn more about using the properties API.

Below are some common payment properties that you may want to query. 

Property name Label in UI Description
hs_latest_status

Status

The current status of the payment. Values include:

  • succeeded
  • refunded
  • processing
  • failed
hs_initial_amount

Gross amount

The total amount that the buyer was charged.

hs_customer_email

Customer

The buyer's email address.

hs_initiated_date

Payment date

The date that the payment was created.

hs_payment_id

Payment ID

The payment's unique ID.

Search for payments by properties

You can use the search endpoint to retrieve payments that meet a specific set of filter criteria. This will be a POST request that includes your filter criteria in the request body.

For example, to search for all refunded payments, you would make a POST request to crm/v3/objects/commerce_payments/search with the following request body:

// Example search request body { "filterGroups": [ { "filters": [ { "propertyName": "hs_latest_status", "value": "refunded", "operator": "EQ" } ] } ], "properties": ["hs_latest_status","hs_customer_email"] }

Note that the filters array specifies the search criteria, while the properties array specifies which properties to return.

Associations

While you cannot set associations using this API, you can retrieve association information by making a GET request to the following URL:

crm/v3/objects/commerce_payments/{paymentId}/associations/{associatedObjectName}

Associated objects can include contacts, companies, deals, invoices, quotes, line items, subscriptions, discounts, fees, and taxes. These associates are based on the associations set on the invoice, payment link, or quote used for transaction. To manage these associations, you can update the payment in HubSpot.

Below is an example of how you might use this API combined with another API to get a specific set of association information.

Retrieving a payment with associated contact

To retrieve a payment and contact associated with it, make a GET request to:

crm/v3/objects/commerce_payments/{paymentId}/associations/contact

This will return the IDs of the currently associated contact, along with meta information about the association type.

// Example response { "results":[ { "id":"301", "type":"commerce_payment_to_contact" } ] }

You can then use the returned IDs to request more information about the line items through the contacts API. For example, you could retrieve the contact using its ID by making a GET request to crm/v3/objects/contacts/{contactId}

// Example response { "id":"301", "properties":{ "createdate":"2022-09-27T13:13:31.004Z", "email":"tom.bombadil@oldforest.com", "firstname":"Tom", "hs_object_id":"301", "lastmodifieddate":"2023-11- 07T17:14:00.841Z", "lastname":"Bombadil" }, "createdAt":"2022-09-27T13:13:31.004Z", "updatedAt":"2023-11-07T17:14:00.841Z", "archived":false }

Was this article helpful?
This form is used for documentation feedback only. Learn how to get help with HubSpot.