integrating card payment into website

Problems with the Windows version of XAMPP, questions, comments, and anything related.

integrating card payment into website

Postby MikeSiencyn » 11. June 2021 16:07

Hi folks
My card payment company says I need to do the following to obtain a token to use in the next stage.
“To request an access token with client credentials, make a POST request to the https://api.cardcompany.com/token endpoint with the following details:
Name Required Description
grant_type Yes The grant type used for obtaining an access token. In this case, the value must be client_credentials.
client_id Yes The client ID of your application that was generated when you registered it.
client_secret Yes The client secret of your application that was generated when you registered it.
Your request must contain the header:- Content-Type: application/x-www-form-urlencoded”.

I have created the following php file:

<?php
$postRequest = array(
'grant_type'=>'client_credentials',
'client_id'=>'XXXXXXXXXXXXXXXXXX',
'client_secret'=>'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');

$cURLConnection = curl_init('https://api.cardcompany.com/token');
curl_setopt($cURLConnection, CURLOPT_POSTFIELDS, $postRequest);
curl_setopt($cURLConnection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($cURLConnection, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));

$apiResponse = curl_exec($cURLConnection);
echo $apiResponse;
curl_close($cURLConnection);

// $apiResponse - available data from the API request
$jsonArrayResponse = json_decode($apiResponse);
?>

Should I expect this to work as long as I have correctly entered the personal data?
That is, should I expect the variable $apiResponse to contain the token?
Many thanks
Mike
MikeSiencyn
 
Posts: 24
Joined: 02. February 2021 15:41
XAMPP version: 3.2.4
Operating System: Windows10

Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 131 guests