<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Getting subscription by contact id for payments in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/Getting-subscription-by-contact-id-for-payments/m-p/1012507#M75133</link>
    <description>&lt;P&gt;I was able to get the subscription details with the following code, but I am now stuck at how to get the quality or the number of seats for that subscription. WHat si the correct property name for quantity/seats for the subscription? I couldn't find anything in the list of properties either. ANy help is appreciated. Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;      const subscriptionResponse = await this.hubspotClient.apiRequest({
        method: "POST",
        path: `/crm/v3/objects/subscriptions/search`,
        body: {
          filterGroups: [
            {
              filters: [
                {
                  propertyName: "hs_contact_email",
                  operator: "EQ",
                  value: email,
                },
              ],
            },
          ],
        },
      });
      let response = await subscriptionResponse.json();
      let subscriptionProps = response.results[0].properties;

      // Step 3: Return the subscription status and num seats/quantity
      // hs_quantity does not work
      const propertiesToFetch = ["hs_status", "hs_quantity"];
      let subscriptionObjectId = subscriptionProps.hs_object_id;
      const subscriptionStatusResponse = await this.hubspotClient.apiRequest({
        method: "GET",
        path: `/crm/v3/objects/subscriptions/${subscriptionObjectId}`,
        qs: {
          properties: propertiesToFetch.join(","),
        },
      });
      let subscriptionStatus = await subscriptionStatusResponse.json();
      console.log(subscriptionStatus);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 19 Jul 2024 02:18:52 GMT</pubDate>
    <dc:creator>CGSully</dc:creator>
    <dc:date>2024-07-19T02:18:52Z</dc:date>
    <item>
      <title>Getting subscription by contact id for payments</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Getting-subscription-by-contact-id-for-payments/m-p/1010984#M75054</link>
      <description>&lt;P&gt;Hi, I am trying to use the private app API with access token to get the status on a payment subscription for our customers.&lt;/P&gt;&lt;P&gt;I want to use the NodeJS SDK for this. I tried the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;    try {
      // Step 1: Search for the contact by email
      const contactSearchResponse =
        await hubspotClient.crm.contacts.searchApi.doSearch({
          filterGroups: [
            {
              filters: [
                {
                  propertyName: "email",
                  operator: "EQ",
                  value: email,
                },
              ],
            },
          ],
          properties: ["email"],
        });

      if (contactSearchResponse.total === 0) {
        console.log("No contact found with the provided email");
        return;
      }
      const contactId = contactSearchResponse.results[0].id;
      // Step 2: Get the subscription status for the contact
      const subscriptionResponse =
        await hubspotClient.crm.objects.subscriptions.basicApi.getById(
          contactId
        );

      console.log(subscriptionResponse);
    } catch (error) {
      console.error(
        "Error fetching subscription status:",
        error.response ? error.response.body : error.message
      );
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am able to correctly get the contactId in step 1, but at step 2 I am getting an error that&amp;nbsp;&lt;EM&gt;&lt;SPAN&gt;hubspotClient&lt;SPAN&gt;.&lt;SPAN&gt;crm&lt;SPAN&gt;.&lt;SPAN&gt;objects&lt;SPAN&gt;.&lt;SPAN&gt;&lt;EM&gt;subscriptions is undefined.&lt;/EM&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/EM&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;DIV&gt;What is the correct NodeJS API to get the subscription details from contact id.&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jul 2024 00:14:57 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Getting-subscription-by-contact-id-for-payments/m-p/1010984#M75054</guid>
      <dc:creator>CGSully</dc:creator>
      <dc:date>2024-07-17T00:14:57Z</dc:date>
    </item>
    <item>
      <title>Re: Getting subscription by contact id for payments</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Getting-subscription-by-contact-id-for-payments/m-p/1011022#M75056</link>
      <description>&lt;P&gt;I don't believe Subscriptions are wrapped yet in the Node package. At least I cannot find them in the &lt;A href="https://github.hubspot.com/hubspot-api-nodejs/index.html" target="_blank" rel="noopener"&gt;documentation&lt;/A&gt;.&amp;nbsp; You may have to use the .apiRequest method instead.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jul 2024 03:04:08 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Getting-subscription-by-contact-id-for-payments/m-p/1011022#M75056</guid>
      <dc:creator>Bortami</dc:creator>
      <dc:date>2024-07-17T03:04:08Z</dc:date>
    </item>
    <item>
      <title>Re: Getting subscription by contact id for payments</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Getting-subscription-by-contact-id-for-payments/m-p/1011405#M75081</link>
      <description>&lt;P&gt;Thanks for the quick response. Can you provide an example of using apiRequest for "&lt;SPAN&gt;crm/v3/objects/subscriptions/" REST endpoint to get subscription from a given customer email? Thanks!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jul 2024 15:56:17 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Getting-subscription-by-contact-id-for-payments/m-p/1011405#M75081</guid>
      <dc:creator>CGSully</dc:creator>
      <dc:date>2024-07-17T15:56:17Z</dc:date>
    </item>
    <item>
      <title>Re: Getting subscription by contact id for payments</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Getting-subscription-by-contact-id-for-payments/m-p/1012507#M75133</link>
      <description>&lt;P&gt;I was able to get the subscription details with the following code, but I am now stuck at how to get the quality or the number of seats for that subscription. WHat si the correct property name for quantity/seats for the subscription? I couldn't find anything in the list of properties either. ANy help is appreciated. Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;      const subscriptionResponse = await this.hubspotClient.apiRequest({
        method: "POST",
        path: `/crm/v3/objects/subscriptions/search`,
        body: {
          filterGroups: [
            {
              filters: [
                {
                  propertyName: "hs_contact_email",
                  operator: "EQ",
                  value: email,
                },
              ],
            },
          ],
        },
      });
      let response = await subscriptionResponse.json();
      let subscriptionProps = response.results[0].properties;

      // Step 3: Return the subscription status and num seats/quantity
      // hs_quantity does not work
      const propertiesToFetch = ["hs_status", "hs_quantity"];
      let subscriptionObjectId = subscriptionProps.hs_object_id;
      const subscriptionStatusResponse = await this.hubspotClient.apiRequest({
        method: "GET",
        path: `/crm/v3/objects/subscriptions/${subscriptionObjectId}`,
        qs: {
          properties: propertiesToFetch.join(","),
        },
      });
      let subscriptionStatus = await subscriptionStatusResponse.json();
      console.log(subscriptionStatus);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jul 2024 02:18:52 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Getting-subscription-by-contact-id-for-payments/m-p/1012507#M75133</guid>
      <dc:creator>CGSully</dc:creator>
      <dc:date>2024-07-19T02:18:52Z</dc:date>
    </item>
    <item>
      <title>Re: Getting subscription by contact id for payments</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Getting-subscription-by-contact-id-for-payments/m-p/1012528#M75134</link>
      <description>&lt;P&gt;Can you explain what you're trying to accomplish more?&lt;/P&gt;
&lt;P&gt;Subscriptions don't have a quantity or seats, so we may be talking about two different things.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jul 2024 03:14:38 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Getting-subscription-by-contact-id-for-payments/m-p/1012528#M75134</guid>
      <dc:creator>Bortami</dc:creator>
      <dc:date>2024-07-19T03:14:38Z</dc:date>
    </item>
  </channel>
</rss>

