Stripe Connect and API Backend Workflow

Hi,
I installed Stripe Connect plugin in order to set up a marketplace payment.
I tryed to go a bit further and use API Workflow with Webhook Endpoint to catch payment_intent.succeeded event. (With API Connector) and then modify Order object in my DB.

  1. when charging user, i store payment_intend_id in an Order object.
  2. The payment succeeds and the event seems to be triggered since i manage to send me an email from the API Backend Workflow.
    But when trying to modify any object in DB is not working. Here is an exemple of the customer i “did a search for” but not working.



My “Do search” request doesn’t return anything.
Any idea about that please?
Here is a snapshot of the bubble log :

Thanks.

It’s hard to give you something useful since we don’t have what the webhook is receiving.

probably the field “stripe_payment_ID” is still empty when you’re doing the search, that’s why the ‘do a search for’ is not returning anything

My advice is to create a debug table in your database with a text field.

Then, in the first action of the webhook you create a new thing in your debug database and store as many values from the webhook as you need (you can probably save the whole JSON you receive)

Then you need to make sure you are receiving the correct data from stripe (you can use tools like Json Parser Online - All-in-One Solution to better analyze the json)

Let me know how it goes

Lucas Moura

https://www.linkedin.com/in/lucas-moura-bastos/

Hi Lucas, thank you for your advice.
I stripe_payment_ID is well set in return of the ChargeUser workflow.
But could that happens that the payment_success event should be triggered before the “Create a new Order” WF is finished?

In that case maybe i should use “charge_id” instead ?

Thanks

Here is the JSON

{"id":"evt_3OqBp7InBSsK9E9W2WnmXjVA","object":"event","account":"acct_1OoSiyInBSsK9E9W","api_version":"2023-10-16","created":1709459954,"data":{"object":{"id":"pi_3OqBp7InBSsK9E9W2m1My0ie","object":"payment_intent","amount":13500,"amount_capturable":0,"amount_details":{"tip":{}},"amount_received":13500,"application":"ca_PYtEmPc93VPqEIkZjkVo464IBncmIOBC","application_fee_amount":null,"automatic_payment_methods":null,"canceled_at":null,"cancellation_reason":null,"capture_method":"automatic","client_secret":"xxxxxInBSsK9E9W2m1My0ie_secret_tz6skEYI67N1Lgj","confirmation_method":"automatic","created":1709459953,"currency":"eur","customer":null,"description":"Cours collectif.","invoice":null,"last_payment_error":null,"latest_charge":"ch_3OqBp7InBSsK9E9W2mfO4ef1","livemode":false,"metadata":{},"next_action":null,"on_behalf_of":null,"payment_method":"pm_1OqBp6InBSsK9E9WX28fGVhl","payment_method_configuration_details":null,"payment_method_options":{"card":{"installments":null,"mandate_options":null,"network":null,"request_three_d_secure":"automatic"}},"payment_method_types":["card"],"processing":null,"receipt_email":null,"review":null,"setup_future_usage":"off_session","shipping":null,"source":null,"statement_descriptor":null,"statement_descriptor_suffix":null,"status":"succeeded","transfer_data":null,"transfer_group":null}},"livemode":false,"pending_webhooks":1,"request":{"id":"req_WDkWT3DXcpdIn1","idempotency_key":"2a99a8d2-5790-4baf-b7c8-4001faf91928"},"type":"payment_intent.succeeded"} 

object id is well set.

I think i found the reason.
“Charge the current user” workflow returns only when payment is done.
So i received the payment_success event before creating the Order thing.
I thought that was asynchronous and that i had to catch that event myself.
But if i’m not wrong i can wait the end of the “Charge the current user” workflow to know if the payment was successful.
Am i right?
In that case, how can i know if payment failed in order to trigger another action?

Thank you

You’ll need to test the different scenarios and/or look at stripe’s documentation (I prefer to test the different scenarios myself to make sure I’m covering all of them).

Maybe the “charge the current user” workflow has a flag of success/failed for you to look at.

Here is what the doc says:

“In a failed transaction, the workflow will stop running” but i would like to make actions in that case and don’t know how to detect that.

You can use webhooks for that or you can check if any of the outputs from the ‘charge current user’ is empty.

If a transition is successful, all of them must be filled (I think). if the payment is failed, one or more (or all) of them is empty. So this, maybe you can use this…

image

In fact, step 5 is never triggered if charge (step 4) failed so that’s not possible

the only solution i thought about is using API Workflow with endpoint to listen to Stripe Event (session closed, failure…)