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.