We've Moved! Please visit our new and improved forum over at our new portal: https://portal.plumvoice.com/hc/en-us/community/topics

Cannot handle Stripe API's legitimate card declined response

Questions and answers about Plum Fuse+

Moderators: admin, support

Post Reply
Fivable
Posts: 11
Joined: Fri May 11, 2018 7:32 am

Cannot handle Stripe API's legitimate card declined response

Post by Fivable »

Hello,

We are transacting with the Stripe API through REST modules, and when a call to charge a card receives what is a legitimate (though non-200) response the IVR system errors out without allowing the opportunity for us to handle the response (as far as we can tell). This does not happen with Authorize.net because they return their card declined message as a 2xx response and we are able to handle it and forward to customer service. Is there any way to accomplish this with such a response from Stripe? The response we get for a declined card is below.

Thanks for your time,
Fivable

-----
(This is a 402 HTTP status response)
Server: nginx
Date: Mon, 18 Jun 2018 19:10:42 GMT
Content-Type: application/json
Content-Length: 259
Connection: keep-alive
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: GET, POST, HEAD, OPTIONS, DELETE
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: Request-Id, Stripe-Manage-Version, X-Stripe-External-Auth-Required, X-Stripe-Privileged-Session-Required
Access-Control-Max-Age: 300
Cache-Control: no-cache, no-store
Request-Id: req_T78ZJxMFecRu7m
Stripe-Version: 2016-07-06

Response
Raw
{
"error": {
"charge": "ch_D4byCRFgbj8n3g",
"code": "card_declined",
"decline_code": "generic_decline",
"doc_url": "https://stripe.com/docs/error-codes/card-declined",
"message": "Your card was declined.",
"type": "card_error"
}
}

admin
Site Admin
Posts: 35
Joined: Thu May 29, 2003 3:12 pm

Re: Cannot handle Stripe API's legitimate card declined resp

Post by admin »

In the REST module, you should turn on custom errors. You can do this by clicking on the gear icon on the upper-right of the REST module. This will catch every sort of error, even non 2xx responses. From there, you can handle the error as you wish.

REST modules also have some shadow variables you may find handy. You can use [rest_module$.http_code] to access the HTTP code of the response.

Fivable
Posts: 11
Joined: Fri May 11, 2018 7:32 am

Re: Cannot handle Stripe API's legitimate card declined resp

Post by Fivable »

Thanks!

Fivable
Posts: 11
Joined: Fri May 11, 2018 7:32 am

Re: Cannot handle Stripe API's legitimate card declined resp

Post by Fivable »

Also I'm now wondering if there is a way to set a default path for any custom errors that are unhandled.

admin
Site Admin
Posts: 35
Joined: Thu May 29, 2003 3:12 pm

Re: Cannot handle Stripe API's legitimate card declined resp

Post by admin »

A standard practice is to create a page in your application dedicated to handling webservice errors. Typically it plays a message like "I'm sorry, we are having technical difficulties," then either prompts the user to try their call again later, or transfers them to customer service.

Then for all your REST modules, you would connect the error path to a Go To Page module that jumps to that dedicated page.

Post Reply