Best way to have auto-renewal recurring payments

I am creating a website service that will allow users to pay either manually every month or with a recurring payment. I am designing my own website and using your PHP APIs. I will NOT be storing any payment details (credit card, bank accounts, etc) on my site/DB. Also, my base subscription fee will be $15/month, but for every email referral that becomes an active account they will get an automatic $1 off their base fee monthly. I have already worked out how to do a one time payment using square API with Payment Links. My challenge is the recurring auto-renewal payment option. Basically, the user will just have a checkbox that they can check which will trigger auto-renewals for their desired payment type. I was looking at using Subscription API, but that seems like it might get hard to manage due to the myriad of options the user could do:

  • If the user checks the auto-renewal and saves, start a subscription using current monthly rate.
  • If the user unchecks the auto-renewal and saves, cancel the current subscription.
  • If the user adds another email referrals (thus reducing monthly rate), update current subscription amount?
  • if the user changes the payment type and saves: Cancel current subscription, create new subscription with new payment type
    Here is a partial screen shot of my UI so you get the idea:

Is this the best way to manage this? Or do you have a better suggestion on how to handle auto renewals with variable amounts?

Thanks for your help in advance,

Curt

:wave: 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:

Additional Documentation

Square Developer
Invoices API
Checkout API

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.

Another thought, I believe I am comfortable with assuming if the user checks the Auto-renewal checkbox, then that means they are authorizing me to use there same CC information they used for one time payment and automatically charge them going forward. Is there a way to automatically store their payment information on file at square linked to their “customerID” when they do their first payment. Hopefully, that customerID (in this case email address) would allow me to lookup their payment info on file via API and then I could manually apply payments in their behalf via the auto-renewal agreement. Would a card be stored on file for a One Time payment with Square Payment Link?

Based on your requirements, using the Subscriptions API seems to be the most suitable approach. Here’s how you can handle the different scenarios:

  1. If the user checks the auto-renewal and saves, you can create a subscription using the CreatePaymentLink endpoint with the subscription_plan_id and price_money parameters. The price_money should match the current monthly rate.

  2. If the user unchecks the auto-renewal and saves, you can cancel the current subscription using the CancelSubscription endpoint.

  3. If the user adds another email referral, you can update the subscription amount by first cancelling the current subscription and then creating a new one with the updated price.

  4. If the user changes the payment type and saves, you can follow a similar approach as in point 3: cancel the current subscription and create a new one with the new payment type.

Remember, when a subscription plan is updated or cancelled, the changes are effective immediately on any existing subscriptions for the plan. Also, note that the Subscriptions API requires customers to have a profile in the seller’s Customer Directory to enroll them in a plan. The customer profiles must also include a valid email address because Square sends the subscription invoices and receipts to this email address.

This answer was reviewed by @Bryan-Square.

Thank for the response and advice. Fortunately, I had already started working on that same approach. I did stumble for awhile because your current SubscriptionPlan → PaymentLink documentation doesn’t say anything about SubscriptionPlanVariation needing to be created. Anyways, I eventually got there and have successfully created a Payment Link for a SubscriptionPlan.

Follow-up questions:

  1. The documentation and checkout page says that the SP CreatePayment link would automatically create a Customer and a recurring Subscription. I am assuming since I already had my Sandbox account customer that it did not create a new one…but not sure. However, I did at minimum expect it to create a recurring subscription for that customer. That was the whole point of the payment link. I do see a Payment processed under Payments though, just no resulting subscription.

I do not see any new Suscription or Customer created:

In your response above, you say that the Customer needs to already exist. Which one is it?

Thanks for your continued help.

With payment links the sandbox experience isn’t complete. You won’t see subscriptions created with payment links in sandbox. We’re constantly working to improve our features based on feedback like this, so I’ll be sure to share your request to the API product team. :slightly_smiling_face: