question

salmanbhatti52 avatar image
salmanbhatti52 asked David Marginian Deactivated edited

401 Unauthorized issue

I am facing issue with (401 unauthorized) issue, i am sharing my code
i have tried with code method in app and also testing only method.

i want to capture payment from user and i need a proper documentation for that. The token generated by api is not working i guess. Can anybody check or share php curl code for sample?

Some one suggested me in community clover to delete and recreate app in Web Sandbox dashboard but i cant find option to delete or recreate app for the clover api access.

Its Quite urgent if some one give me a sample code for PHP i need to integrate Clover Payments in my web.


Thanks all.

$data = json_encode(

array(

"orderId" => "1",

"taxAmount" => 9,

"zip" => "94041",

"expMonth" => 1,

"cvv" => "111",

"amount" => 100,

"currency" => "USD",

"last4" => "1111",

"expYear" => 2021,

"first6" => "411111",

"cardEncrypted" => "X8UeKej+AEG1h0wD9Xw=="

)

);

//exit;


$ch = curl_init();


curl_setopt($ch, CURLOPT_URL, 'https://apisandbox.dev.clover.com/v3/merchant/'. $mid .'/pay');

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_POST, 1);

curl_setopt($ch, CURLOPT_POSTFIELDS, $data);


$headers = array();

$headers[] = 'Accept: application/json';

$headers[] = 'Authorization: Bearer 9656dc91-0353-d7d7-30da-bb34ce43f486';

//$headers[] = 'Authorization: Bearer '.$oauth->access_token;

$headers[] = 'Content-Type: application/json';

curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);


$result = curl_exec($ch);

if (curl_errno($ch)) {

echo 'Error:' . curl_error($ch);

}

curl_close($ch);

REST APIe-commerce apiOAuthDeveloper Pay APIaccess 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.

1 Answer

·
David Marginian avatar image
David Marginian Deactivated answered David Marginian Deactivated edited

The endpoint you are using is deprecated. You should be using our Ecomm API - https://docs.clover.com/docs/ecommerce-api-tutorials. The permissions for the Ecomm API are discussed here - https://docs.clover.com/docs/ecommerce-app-permissions. Information on how to resolve 401s (including how to uninstall your app) can be found here - https://community.clover.com/articles/23744/resolving-401-unauthorized-responses-when-making-a.html.

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

salmanbhatti52 avatar image salmanbhatti52 commented ·

Hi i have gone through it. I have changed to IFrame Now and getting a new error saying clover not

Uncaught ReferenceError: Clover is not defined

i am using Merchant ID in

const clover = new Clover('528000610115495');

can you please help as we are on a dead end waiting for integration to complete. Its urgent
Thanks

0 Likes 0 ·
David Marginian avatar image David Marginian ♦♦ salmanbhatti52 commented ·

That constructor requires your public key, not your merchant id. Please see this section in our documentation: https://docs.clover.com/docs/using-the-clover-hosted-iframe#configuring-the-sdk. Here is an example codepen - https://codepen.io/gareth-dsouza/pen/MWKbWwv (per above, you need to use your public key).

0 Likes 0 ·

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