Mahmoud_Hamdy | 2024-11-07 16:37:03 UTC | #1
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.REMOTEENDPOINT" } ], "errors": [ { "message": "REST call for action execute failed. Message: Request to backend service failed. Response from web service: {\n \"error\": {\n \"code\": \"invalidexpiryyear\",\n \"docurl\": \"https://stripe.com/docs/error-codes/invalid-expiry-year\",\n \"message\": \"Your card's expiration year is invalid.\",\n \"param\": \"expyear\",\n \"requestlogurl\": \"https://dashboard.stripe.com/test/logs/reqkQXZ3BnK2nkMin?t=1730845150\",\n \"type\": \"carderror\"\n }\n}\n [xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx]", "code": "INTERNALSERVER_ERROR", "status": 402, "messageParams": {}, "details": [], "errors": [] } ] }
so, is there a way to read the error message from the data action ?
crespino | 2024-11-07 22:25:31 UTC | #2
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.
system | 2024-12-08 22:25:42 UTC | #3
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 30257