Can we get a subscription API for dummies?

Personally, I feel as though using the api explorer to gain a better understanding of how to implement the subscription API to my website has not been successful.

I apparently can’t even find the right plan ID, even though I use the items api request to get it… it still gives me a bad request and says the item does not exist. So, apparently something is not correct…

Does anyone have a walkthrough or video available explaining how to set this up from start to finish? It would be outstanding if you did.

This is the 5th api I’ve worked with, and has been the most difficult so far. I haven’t been able to pin point why. I would think that if it could pull your token key for you, then it should also be able to help you in filling in the required ID’s as well.

With that being said, my goal is to create a subscription that provides access within my website. The users will set up their subscription from their account page. My goal is to have them submit the plan request, and then have my website check it regularly to ensure that the subscription is still active, and thus give them access to the paid part of my website.

Would love to see a more specific walkthrough on how to get this accomplished.

1 Like

Hi @ZachH83 welcome to the forums, and thanks for the feedback!

Have you already went through the existing Subscription API Walkthrough? As for the bad request, can you provide the plan_id that you are trying to use as well as your Square application id? I can take a look at our logs to see what is going on.

1 Like

Ive went through it yes.

It seems far more complicated than it needs to be, and doesn’t really fill in the blanks.

If the goal is to set it up so the user can create a subscription from your own website, then the need to add your customers prior is a moot point. How will I know the customer ID when they go to actually create a subscription from my website? This isn’t addressed…

How will I get all of the correct information submitted and then returned? What if they don’t have a card on file? This walk through explains just about the MOST basic of examples, for just the sandbox. It doesn’t really prepare you for live.

This isn’t a walkthrough, its an instruction manual for the basics. A walkthrough would provide more realistic examples for how to get this live. I’ve already created my location, my item, etc, all within the square dashboard. What I’m trying to find out is how to make the connection between my site and square. The link you provided doesn’t explain enough about that. I have the full basic understanding of an api, so I don’t expect that to be there. But, it feels like the end points are not well explained, and how to get the information you need to make the results happen…

I’ve been literally messing with this for over a week. I messaged square on twitter, and they didn’t even offer this forum as a solution. They told me to go to the sellers community and ask around, as if they didn’t know there was a developer forum… So I just happened to come across it today when attempting to contact you guys.

APP ID - sq0idp-4s81M3F1KLNHE0o6SPlOcQ

Actually it looks like the plan ID is CWHE652YFJEFNJFDC5VHGBFB… I just found that by creating a subscription for myself

But, to create that subscription, I clicked on the link and it redirected me to the square site where I entered in an email, and some credit card information. When complete it provided me with no useful data, so I’m not sure how I am supposed to associate a user account from my website with a transaction on square for the subscription plan.

When you create a customer, you would have their customer_id in the response. Moving forward, you probably would want to save it somehow; ie if you intend on having a login mechanism, you could save their customer_id in your database so you know what customer is currently using your site. Or, you could use SearchCustomers to look them up by name or email. The finding the customer is more up to your application on how you would handle it; you need someway to look them up of course.

I’m not sure what you mean by this. If you mean the customer’s information, you would need to build out something to ask for it, and then submit it to the API endpoint. Sandbox and production are pretty close related besides the URL used, so it should be a very similar experience.

The walkthrough shows you how to hit the API endpoints and what to expect back from them. You’re correct it doesn’t really show you how to collect some information, because that’s not really a Square-centric piece. Square doesn’t create a form for you to collect customer information, for example, that would be up to you to do; we simply take the information and do something with it.

I do not see any errors with that Square application id over the last few days. I do see CWHE652YFJEFNJFDC5VHGBFB as a valid plan, though. And it looks like you have a subscription using this plan with id of 5fe5f0bf-a473-4289-8476-2c1f3d560b1b, so it sounds like you’ve created a subscription successfully already. Is there a particular issue with this subscription that you’re trying to figure out?

So I would have to go ahead and create a customer within square for each of the users on my site prior to them setting up the subscription? What occurs if the email address for the customer is already in the system? I don’t collect my customers names, just their emails, as my service has no need for it.

That’s right; on our side we need to have the subscription linked to some customer entity for it to be valid. As for duplicate emails, we do not automatically prevent duplicates, so that would be something you would need to manage. The subscription, however, takes the customer_id, not the email, so it wouldn’t prevent the subscription from working regardless.

1 Like

So I guess what I am gathering is that after I create the customer, I will have to ask them for card information, which I will then store into square, and that will return the card ID for me, which I will use with the customer ID to create the subscription from within the site?

I am gathering that now. I never expected a form in full, but a little more clarity of the process.

So this has helped. I was under the impression that all of the information would be created once the user decided to set up a subscription. I did not understand that I would have to manually make everything. I guess I kind of expected it to feel more like a paypal experience (which I am glad it does not).

So everything can be handled from my end without it ever having to enter into a square site.

So from my end

-> create customer in square from my site using customer email
–> store customer id to website database
-> collect card data on website and create card for customer
–> store card ID to website database
-> create subscription using customer ID and Card ID associated with Plan ID
–> store subscription ID to website database

-> use subscription ID to verify subscription status.

Does that sound about right or did I leave something out?

I created that subscription using the link found in the dashboard so that I could review that data that is store with it

Yep, sounds about right. The saving customer card is technically optional; if they do not have a card on file, Square will send an invoice directly to their email which they can use to pay their subscription as well. For the saving card (or collecting card) information, though, you’ll need to use our Square Payment Form as we don’t currently allow raw card data to be sent to us. The Square Payment Form will generate a “nonce” which you can then use to save the card on file to the customer’s profile.

Well i really don’t want them to use an invoice, as that seems to really disrupt the flow of the set up, and I don’t want them to decide it is too much work to set up a subscription.

So when using the square payment form, how do I add in the customer ID? How does it tie back into the information that I’ll need to grant them access within my website?

The Square Payment Form is solely for collecting card information; essentially it’s 4 divs that gets transformed into four input fields inside a secure iframe. So, if you intend on asking for the customer’s information, you would need to add additional HTML (or whatever front-end language) fields to collect it. Then, in the backend use the Customers API to create the customer, in which case you’ll now have the customer_id.

By the time it came to collect the payment information, the customer would already be created, so the ID would already exist. So, knowing that, how would I use the ID from my database and combine it with the information on the web form so that way when it sends the data to you guys, you have the customer to associate it with?

In that case, the customer ID wouldn’t be used with the front-end form at all. You would pass the customer_id into the CreatePayment backend API request (it’s an optional field) so the payment is linked to the customer.

And this is why you need a walkthrough for dummies. Because, this just went from me thinking I understood it, to not understanding nearly enough.

I guess for now I can just create customer, have them create subscription, then have it email them the invoice to pay the amount…

Once they set up the initial payment, will it automatically charge them each month, or will it just keep sending them an invoice to be paid?

It will keep sending the invoice each month via email. The only way to have it automatically charge is by creating a card on file which you can do via the Square Payment Form, by manually typing in their card in the dashboard (on a customer profile), or in-person on the POS application.