question

juggernautsei avatar image
juggernautsei asked parquet76 answered

Create a charge - 400 Bad Request invalid_request

Hi, I am trying to create a charge using

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

The request is this

<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://scl-sandbox.dev.clover.com/v1/charges', [
'body' => '{"ecomind":"ecom","metadata":{"existingDebtIndicator":false},"amount":25,"currency":"usd","capture":true,"external_reference_id":"9865742","receipt_email":"sherwin@gmail.com","source":"token"}',
'headers' => [
'accept' => 'application/json',
'authorization' => 'Bearer f7f0fake-09ab87-MadeUp-Not-realfd5501c',
'content-type' => 'application/json',
'x-forwarded-for' => 'https%3A%2F%2Fmywebsiteaddresshere.net%2Finterface%2Fmodules%2Fcustom_modules%2Foe-module-clover%2Fpublic%2FpatientPaymentPage.php',
],
]);

echo $response->getBody();


This returns:


{
"message": "400 Bad Request",
"error": {
"type": "invalid_request_error",
"code": "invalid_request",
"message": "Please provide a valid source for the charge."
}
}

I tried token "source":"token". That did not work. I tried "alternate_tender"

Did not work.

But from what I am beginning to understand is that this is not for a web only credit card charge.

Am I right?


Payments
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

·
parquet76 avatar image
parquet76 answered parquet76 edited

"But from what I am beginning to understand is that this is not for a web only credit card charge? " Huh? I have no idea "not for web only credit charge" means.

The source should be tokenized card data, please read the docs. You need to tokenize a card THEN you can make a charge passing the tokenized card as the source, see the docs - https://docs.clover.com/docs/ecommerce-generating-a-card-token

10 |2000

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

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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

Welcome to the
Clover Developer Community