Creating single marketplace payments
This section will go over how to create a one-time marketplace payment and taking a fee using the plugin.
Last updated
This section will go over how to create a one-time marketplace payment and taking a fee using the plugin.
Last updated
In this section we will create payments for connected accounts while taking a fee using Checkout. To start, make sure to:
Add the plugin to your app
Have a simple page with a button users can use to trigger the payment flow (we will go over this further on in this section)
Make sure the user has completed the Onboarding steps
➡️ You can take a look at the plugin demo created in this section here: https://bubble.io/page?name=index&id=stripeconnectdemo&tab=tabs-1
We are going to setup a page with a button that triggers the Stripe Checkout flow. Keep in mind we need to save the Checkout ID to the database, so setup your database structure accordingly.
⚠️ IMPORTANT NOTE:
Previously we could just save the Payment Intent ID when creating a Checkout Session, but the latest Stripe API versions do no return the Payment Intent ID when creating a checkout session. You can get the Payment Intent ID only when a Checkout Session is confirmed (payed). You can get the Payment Intent ID for a confirmed Checkout Session via a Stripe webhook or GET Checkout Session details call which is provided by the plugin.
The demo page has a really simple example database structure, but you can always use your own. The following demo page section demos the one-time payment integration:
To create a Checkout Session we will run the 'Stripe Connect - Checkout Single Payment' workflow action. We will input all the necessary information, like the Connected account ID from the user we just onboarded. The Success URL is used to redirect the user when the transaction flow is finished and the a Cancel URL is used to redirect the user when the transaction flow is cancelled. NOTE: We still need to check if the payment succeeded when the user lands on the Success URL (you can read more about this further on).
On the demo page we create a database item called 'One-time payment' to save the necessary Checkout to later check if the transaction succeeded and to get the transaction details. Important here is to save the Checkout ID (ONLY old Stripe API versions can also save the Payment Intent ID in this step, read more here).
In the demo this data entry is saved to the user type:
The 'Stripe Connect - Checkout Single Payment' workflow action also returns the Checkout URL to complete the payment. You will need to redirect the user to this URL like this:
Previously we could just save the Payment Intent ID when creating a Checkout Session, but the latest Stripe API versions do no return the Payment Intent ID when creating a checkout session. You can get the Payment Intent ID only when a Checkout Session is confirmed (payed). You can get the Payment Intent ID for a confirmed Checkout Session via a Stripe webhook or GET Checkout Session details call which is provided by the plugin.
When the user is send back to your Success URL we need to check if the payment succeeded. For this we will use the 'GET Payment Intent Details' data call.
For this call we need to enter the Payment Intent ID we saved to the database and the Account ID pointing to the onboarded user.
Next we can look at the status
field to see if it is set to "succeeded". You can read more about the different status fields here: https://docs.stripe.com/payments/paymentintents/lifecycle#intent-statuses
You can display / use this information how you like in your app!
Instead of checking if the Payment succeeded client side, you can also setup up a Stripe webhook inside Stripe to be notified if a user completes the Payment. Keep in mind that you need to be on a paid Bubble plan for this as you need to use a Backend workflow.