question

mhernaez avatar image
mhernaez asked aniclouds commented

How to get Authorization Code programmatically?

We have a native Clover POS app. We use the ACTION_SECURE_PAY, ACTION_MANUAL_PAY, ACTION_MANUAL_REFUND intents. In the event our app does not get the response back from the intent we would like to use the REST API to recall a payment.

According to https://docs.clover.com/build/oauth-2-0/ we need an API Token. To get an API Token, we need an Authorization Code. Is there a way to generate an Authorization Code without anyone having to physically log into a website? We are looking for a way to generate the Authorization Code programmatically using the merchant's credentials.

The reasoning behind this.. the merchant will know their credentials; however, it will be the employees that will be using the app. It doesn't make sense for our native Clover app to redirect to a website (is that even possible on a Clover Flex?) and prompt for credentials that employees will not have access to. We just want the process to be fluent without any redirects or prompting for credentials. Is this possible?

Any help would be greatly appreciated.
Thanks.

REST APIClover FlexOAuthAuth
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.

mhernaez avatar image mhernaez commented ·

Sorry, our app receives the response. What I meant to say is that our app then sends the response to a Windows service which then process the information. In the event of a communication issue and the Windows service does not get the response, is there a way for the Windows service to make a call to get the last transaction? Is there an Android SDK function that will get the last transaction?

0 Likes 0 ·

1 Answer

Jonathan Ryan Grice avatar image
Jonathan Ryan Grice answered aniclouds commented
PHP Example:
<?php
$mid = YOUR_MID;
$token = YOUR_API_TOKEN;


// If testing on sandbox use with same endpoint
//$restapi = 'https://apisandbox.dev.clover.com';
$restapi = 'https://api.clover.com';


$header = array();
$header[] = sprintf('Authorization: Bearer %s', $token);


$ch = curl_init();
curl_setopt_array($ch, array(
	CURLOPT_RETURNTRANSFER => TRUE,
	CURLOPT_URL => sprintf('%s/v3/merchants/%s/orders?limit=10', $restapi, $mid),
	CURLOPT_HTTPHEADER => $header
));
$result = curl_exec($ch);


if ($result === false) {
	
	echo sprintf('%s: %s', "CURL Error", curl_error($ch));
} else {
	header('Content-Type: application/json');
	print_r($result);
	curl_close($ch);
}
?>
Hope this helps.
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.

aniclouds avatar image aniclouds commented ·

Bei primus rewe finden Sie alles, was Sie für Ihren Haushalt benötigen, von Lebensmitteln bis zu nützlichen Haushaltswaren.

0 Likes 0 ·

Welcome to the
Clover Developer Community