Stripe Integration

we are integrating with Stripe as a payment gateway

and call this API from secure flow

We need to read the error message in case of failed payment like invalid card or invalid expiry date

here's a sample of the failed response

  {

"message": "The server encountered an unexpected condition which prevented it from fulfilling the request.",
"code": "internal.server.error",
"status": 500,
"messageParams": {},
"contextId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"details": [
{
"errorCode": "ACTION.REMOTE_ENDPOINT"
}
],
"errors": [
{
"message": "REST call for action execute failed. Message: Request to backend service failed. Response from web service: {\n "error": {\n "code": "invalid_expiry_year",\n "doc_url": "https://stripe.com/docs/error-codes/invalid-expiry-year\",\n "message": "Your card's expiration year is invalid.",\n "param": "exp_year",\n "request_log_url": "Stripe Login | Sign in to the Stripe Dashboard",\n "type": "card_error"\n }\n}\n [xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx]",
"code": "INTERNAL_SERVER_ERROR",
"status": 402,
"messageParams": {},
"details": [],
"errors": []
}
]
}

so, is there a way to read the error message from the data action ?

Hi Mahmoud,

Since the request is returning an HTTP 500 then the data action is only going to look at the top level "message" and "code" properties. It is not going to process the body of the response. Data Actions only parse response bodies on an HTTP 200 OK.

You might instead look at using the AWS Lambda Data Actions. The secure callflow will call your AWS Lambda. The Lambda will call Stripe and can deal with the HTTP 500 responses in the Lambda but return an HTTP 200 OK to the Data Action along with the detailed success or error response that is in the body of that response.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.