Process Stripe cancellations
Create an endpoint to cancel a user's Stripe subscription and send them a confirmation email.
Last updated
Create an endpoint to cancel a user's Stripe subscription and send them a confirmation email.
Last updated
Let's say we're building an internal tool for customer support, and want to create a workflow to cancel a user's Stripe subscription and send them a confirmation email.
We'll build a workflow that does this in 5 minutes.
Sign up for Paragon on our website to get started!
In this example, let's assume the frontend of our customer support tool has a button to cancel a user's subscription. We'll start by setting up our Paragon workflow with an API Endpoint trigger, so that our frontend sends it an HTTP request when the button is pressed.
Under Endpoint URL, copy the workflow's trigger URL to use for your frontend's HTTP request. Under How do you want to define test data for this step? choose "Enter in request parameters" and add a body parameter called email
. This will be the customer's email address that should be sent in your frontend's HTTP request.
If you want to authorize the request, you can optionally add an authorization header and enter a value to use as an "API Key". The workflow will then reject any incoming requests that do not include an Authorization header with the expected value.
Next, we'll add a Request step to lookup the customer in Stripe. Set the Request to perform a GET
request to the URL https://api.stripe.com/v1/customers
.
In the request params, use the dropdown variable menu to select 1.request.body.email
from the Trigger step. In the Headers, add a bearer auth header with your Stripe API Key.
Once your Request is configured, click the Test Step button to test that your request to Stripe is working.
We'll add another Request step to cancel the user's Stripe subscription. This time, we'll perform a DELETE
request to the URL https://api.stripe.com/v1/subscriptions/
.
You'll need to add the customer's subscription ID to the end of the URL – you can do this by typing {{
to bring up the variable menu and selecting response.body.data.0.subscriptions.data.0.id
from the previous step. Make sure to also add the same authentication headers as in the previous Request step.
Paragon supports several messaging platforms – and for this example, we'll use Sendgrid to send a confirmation email.
Under Recipients, click the dropdown to bring up the variable menu and choose the user's email address from the Fan Out step. In the Subject and Message fields, you can insert data from previous steps (e.g. your users' subscription info, etc.) by typing {{ to bring up the variable menu
Lastly, we'll add a Response step to send a response back to our frontend to confirm that the workflow ran successfully. Your request to include a confirmation message for your frontend to display it's UI, as well as any data from the workflow (e.g. the customer's information from Stripe).
Now that your workflow is all set up, all you have to do is deploy your workflow by clicking the "Deploy" button in the top-right of your screen. Once you do, your workflow's Trigger URL will go live and you can start making requests to it.
Great work! We just built a workflow to power the backend of your internal customer support tool in just a few minutes. Of course, this is just a basic example of what you can do with Paragon, and there's much more we could add to this workflow, e.g. issuing a refund, marking the user as canceled in your database, etc. We hope it gives you an idea of how to use Paragon for your own internal workflows!
Sign up for Paragon on our website to get started!