question

yasu avatar image
yasu asked yasu commented

REST Pay API with status 209

Hello. I'm currently trying to process a payment with REST Pay API from browser in Sandbox environment.


Send a payment request to a Clover device

https://docs.clover.com/reference/pay


This is my request :

CURL *hnd = curl_easy_init();

curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "https://sandbox.dev.clover.com/connect/v1/payments");

struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Accept: application/json");
headers = curl_slist_append(headers, "X-Clover-Device-Id: 'My Device Id'");
headers = curl_slist_append(headers, "X-POS-Id: Xpos");
headers = curl_slist_append(headers, "Idempotency-Key: test_1");
headers = curl_slist_append(headers, "Content-Type: application/json");
headers = curl_slist_append(headers, "Authorization: Bearer 'My Token'");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);

curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\"capture\":true,\"deviceOptions\":{\"disableCashback\":false,\"offlineOptions\":{\"allowOfflinePayment\":false,\"approveOfflinePaymentWithoutPrompt\":false,\"forceOfflinePayment\":false},\"cardEntryMethods\":[\"MAG_STRIPE\",\"EMV\",\"NFC\"],\"cardNotPresent\":false},\"final\":false,\"amount\":123,\"externalPaymentId\":\"test\"}");

CURLcode ret = curl_easy_perform(hnd);

And here is the response I received :

{
  "code": "processing_error",
  "message": "validation_error",
  "requestId": "a625c60a-5f28-4402-936b-85bd2d7ed9d4",
  "requestType": "PAY",
  "type": "api_error"
}

Response status is 209, which says "Operation was canceled" and "message" tells me "validation error", but I have no idea what is incorrect in my request. What should I do in order to make this work?

I'm pretty sure my token is valid because other requests such as "Display a message", "Get the device's status" and "Display a thank you screen" has worked fine today.


Any advice would be appreciated. Thank you in advance.

REST APIClover Flex
10 |2000

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

1 Answer

David Marginian avatar image
David Marginian Deactivated answered yasu commented

Is this happening after you pay (swipe,tap,dip)? What test card are you using?

10 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.

yasu avatar image yasu commented ·
This happens before paying. I haven't even seen any payment screen on the terminal yet. When pressing the button "Try it!", I just see the welcome screen on the terminal.
0 Likes 0 ·
yasu avatar image yasu yasu commented ·

I'm trying to send a request from browser : https://docs.clover.com/reference/pay

0 Likes 0 ·
David Marginian avatar image David Marginian ♦♦ yasu commented ·
Honestly, I would recommend you use curl or use Postman. Are you able to get a simpler request (like a show message or something) working?
0 Likes 0 ·
Show more comments

Welcome to the
Clover Developer Community