question

liju avatar image
liju asked liju commented

HTTP 503 Status error in REST v2 pay API

Hello,

Clover v2 REST pay api (used to pay for an order ) is giving a 503 Http error status in production at times.

We are calling the pay api from our node server and doing a JSON.parse of the response returned by clover. The content-type is application/json but this is failing with a "Unexpected Token E" syntax error which means that the response from clover may not be a valid JSON.

Any help is appreciated why this would happen and whats going wrong since this is happening for a merchant in production.

5 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Mike M avatar image Mike M commented ·

Sorry, I'm currently unable to reproduce this issue. I was just able to successfully post a web payment and the JSON response was completely valid. Are you saying that this parsing issue is sporadic for all v2 web payments (for both status 200 and 503)? Or is this only an issue with parsing the response body for a 503 error response?

0 Likes 0 ·
liju avatar image liju commented ·

It is sporadic and parsing issue seems to be happening only during a 503 response.

0 Likes 0 ·
Mike M avatar image Mike M commented ·

What is the response body you receive for a 503 response?

I believe it will be either of the below lines, neither of which should be parsable as JSON and would explain your Unexpected Token error. "Your service has been temporarily disabled. Please contact support." "Service Unavailable"

0 Likes 0 ·
liju avatar image liju commented ·

Sure, it could be the issue during a 503. But is there some reason the pay api should not be available anytime? Would it be due to a merchant gateway issue or a common server issue at your end?

0 Likes 0 ·
Mike M avatar image Mike M commented ·

In an ideal world, the Pay API shouldn't ever be unavailable. That being said, the payment gateway is a service layer that isn't owned by Clover so we, unfortunately, aren't able to control its reliability.

In regards to the 503, I'm looking at the logs for all production /v2/merchant/{mId}/pay API requests and all 503's have a response body of:

Error connecting to Payment Gateway

Which makes perfect sense in that its first letter is E and your syntax error is: Unexpected Token E

0 Likes 0 ·

1 Answer

Mike M avatar image
Mike M answered liju commented

Just to recap the comment thread into 1 answer.

The issue was the parsing of the 503 error response body. The /v2/merchant/{mId}/pay API requests that resulted in a 503 all have a response body of:

Error connecting to Payment Gateway

The first letter E of the response body correlates with the syntax error Unexpected Token E

1 comment
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

liju avatar image liju commented ·

Thanks for digging into this and clarifying. We are addressing this at our end to take care of this type of response.

0 Likes 0 ·

Welcome to the
Clover Developer Community