Stripe API Connector Issue

Greetings fellow Bubblers,

I have been using the Stripe.js plugin for awhile now but have run into some limitations of it and need to use the Stripe API with the API Connector. However, I am running into some issues with it. Here are the main things that I need to accomplish with this:

  1. Create a subscription for an existing customer.
  2. Send metadata with the api call for the customer and each subscription item
  3. Send 2 subscription items for the subscription.

Below is the Json that I have configured but I am getting an error (see screenshot below code). Any help you can provide would be greatly appreciated. Thanks!

{
   "customer":"<customer_id>",
   "metadata":[
      {
         "fh_subscription_id":"<fh_customer_id>"
      }
   ],
   "default_payment_method":"<payment_method_id>",
   "automatic_tax":{
      "enabled":"false"
   },
   "items":[
      {
         "quantity":"<access_quantity>",
         "price":"<access_product_id>",
         "metadata":[
            {
               "fh_subscription_id":"<fh_access_subscription_item_id>"
            }
         ]
      },
      {
         "quantity":"<hours_quantity>",
         "price":"<hours_product_id>",
         "metadata":{
            "fh_subscription_id":"<fh_hours_subscription_item_id>"
         }
      }
   ],
   "collection_method":"<collection_method>",
   "coupon":"<coupon>"
}

Stripe’s API doesn’t accept JSON requests… it only accepts parameters as URL Encoded query parameters.

Stripe API Reference - Create a subscription

Any idea on how to convert my Json to the accepted format? There has to be a way to do this through the API Connector, correct?

The simplest was is just to use the parameter inputs of the API connector - just make sure to check the query string box.

Alternatively, if you have a dynamic number of subscription items, you can enter the parameters into the body, in URL encoded query parameter format.

In either case, the formatting needs to be as in the following examples:

customer
items[0][price]
items[0][quantity]

etc.

The parameter way makes sense. How would I do the metadata for each item? The metadata is an array within an array.
customer
items[0][price]
items[0][quantity]
items[0][metadata]

items[0][metadata][fn_subscription_id] should work…

That worked!!! Thank you so much. You’re awesome!!!

1 Like