# Necessary API calls to take payment for a Subscription via payment link and not through email

**URL:** <https://developer.squareup.com/forums/t/necessary-api-calls-to-take-payment-for-a-subscription-via-payment-link-and-not-through-email/20039>\
**Category:** Questions\
**Created:** [December 11, 2024, 7:57pm UTC](https://developer.squareup.com/forums/t/necessary-api-calls-to-take-payment-for-a-subscription-via-payment-link-and-not-through-email/20039 "2024-12-11T19:57:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sj\_nyc](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sj\_nyc](https://developer.squareup.com/forums/u/sj_nyc)\
**Post date:** [December 11, 2024, 7:57pm UTC](https://developer.squareup.com/forums/t/necessary-api-calls-to-take-payment-for-a-subscription-via-payment-link-and-not-through-email/20039/1 "2024-12-11T19:57:16Z")

</div>

I’m building a subscription flow for a SaaS service where the user must enter the card details from the outset, even if there’s a trial period. Trying to understand the sequence of APIs that need to be called. There are gaps in my understanding of the API sequencing, so I’d appreciate if anyone can help correct the following before I set out building this. Hopefully this will also help others embarking on a similar journey.

**One time initialization**

1. Create CatalogItems for each feature of the SaaS service
2. Create CatalogItemVariations for each subscription plan mapping to the features that are included (modeled as CatalogItems)
3. Create SubscriptionPlans for each tier of subscription e.g. Starter, Premium, Enterprise and associate with the CatalogItemVariation for that subscription plan
4. Create SubscriptionVariations for each payment cadence e.g. a Monthly variation and an Annual variation. Include ones or more phases in each variation, depending on whether there’s a free trial offered at the start. Use STATIC pricing for each phase.
5. Create OrderTemplates for each subscription tier x payment cadence. e.g. Starter Monthly, Starter Annual, Premium Monthly, Premium Annual

**User subscription flow**

1. Display Subscriptions in the FE - Use Catalog API - List Catalog
2. User selects their tier and chooses payment cadence (Monthly/Annual) clicks Subscribe
3. BE creates payment link using Checkout API with subscription plan id set in checkout options and order line items set to order template IDs. Order created by API and Order ID returned in response.
4. FE redirects user to payment link
5. User enters credit card info and submits payment form. Do I need a webhook here to fire on payment success and create the subscription with that order ID (and customer, location, subscription variation ids)?
6. User redirected to thank you page.

I’m not sure when I need to create the customer record, I can presumably do so prior to any of this, or maybe only do so once a successful payment has been made.

Greatly appreciate any feedback on this flow as I get to grips with the Square API.

---

<div class="post-metadata">

**Author:** ![Square-Dev-AI](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/square-dev-ai/32/2513_2.png) [@Square-Dev-AI](https://developer.squareup.com/forums/u/Square-Dev-AI)\
**Post date:** [December 11, 2024, 7:57pm UTC](https://developer.squareup.com/forums/t/necessary-api-calls-to-take-payment-for-a-subscription-via-payment-link-and-not-through-email/20039/2 "2024-12-11T19:57:50Z")

</div>

👋 I’m Square Dev AI, here to help answer your question!  
Based on the information you’ve provided, the following documentation will help answer your question:

> **[Subscription Plan Checkout](https://developer.squareup.com/docs/checkout-api/subscription-plan-checkout)**
>
> Learn how to create a quick pay checkout link for a subscription plan.

[https://developer.squareup.com/docs/app-marketplace/requirements/subscriptions-api](https://developer.squareup.com/docs/app-marketplace/requirements/subscriptions-api)

> **Additional Documentation**
>
> [Customers API Workflows](https://developer.squareup.com/docs/customers-api/how-it-works)  
> [Orders API: How It Works](https://developer.squareup.com/docs/orders-api/how-it-works)  
> [Create and Publish Invoices](https://developer.squareup.com/docs/invoices-api/walkthrough)

If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.  
Otherwise one of our Developer Advocates will provide additional assistance shortly.

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [December 11, 2024, 9:08pm UTC](https://developer.squareup.com/forums/t/necessary-api-calls-to-take-payment-for-a-subscription-via-payment-link-and-not-through-email/20039/3 "2024-12-11T21:08:13Z")

</div>

You’ll want to create the customer prior to any payments being processed so you can include the `customer_id` when creating the subscriptions for the customers. 🙂

---

<div class="post-metadata">

**Author:** ![sj\_nyc](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sj\_nyc](https://developer.squareup.com/forums/u/sj_nyc)\
**Post date:** [December 11, 2024, 9:55pm UTC](https://developer.squareup.com/forums/t/necessary-api-calls-to-take-payment-for-a-subscription-via-payment-link-and-not-through-email/20039/4 "2024-12-11T21:55:42Z")

</div>

Thanks Bryan! Do steps 3-6 look accurate in the user flow otherwise?

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [December 11, 2024, 10:11pm UTC](https://developer.squareup.com/forums/t/necessary-api-calls-to-take-payment-for-a-subscription-via-payment-link-and-not-through-email/20039/5 "2024-12-11T22:11:35Z")

</div>

Yes, those are correct except for step 3. You’ll really create the payment link with the `subscription_variation_id`. It will look like:

```auto
{
    "idempotency_key": "{{$guid}}",
    "quick_pay": {
      "name": "Coffee membership fees",
      "price_money": {
        "amount": 100,
        "currency": "USD"
      },
      "location_id": "{{location_id}}"
    },
    "checkout_options": {
      "subscription_plan_id": "WJZ33ATP5ER36Y6Y2ZIE33SZ" //is the subscription_variation_id
    }
  }

```

🙂
