Closed prasadsupare closed 5 years ago
The recommended way for using the SDK is through composer. Do you use it that way? Can you provide some example code so we could help you?
Please don't provide sensitive data (such as credit details, emails, codes, secrets, etc.)
Please don't provide sensitive data (such as credit details, emails, codes, secrets, etc.)
sir, these are the fake card details used for sandbox testing..
This is my index file:
require_once 'sumup/SumUp.php';
try {
$sumup = new \SumUp\SumUp ([
'app_id' => 'Xxxxxxxxxxxxxxxxxxxxxx',
'app_secret' => 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy',
'grant_type' => 'client_credentials'
]);
$accessToken = $sumup->getAccessToken();
$value = $accessToken->getValue();
$checkoutService = $sumup->getCheckoutService();
$checkoutResponse = $checkoutService->create($amount, $currency, $checkoutRef, $payToEmail);
$checkoutId = $checkoutResponse->getBody()->id;
// pass the $chekoutId to the front-end to be processed
} catch (\SumUp\Exceptions\SumUpAuthenticationException $e) {
echo 'Authentication error: ' . $e->getMessage();
} catch (\SumUp\Exceptions\SumUpResponseException $e) {
echo 'Response error: ' . $e->getMessage();
} catch(\SumUp\Exceptions\SumUpSDKException $e) {
echo 'SumUp SDK error: ' . $e->getMessage();
}
$headers = array(
sprintf('Authorization: Bearer %s', $accessToken),
'Content-Type' => 'application/json'
);
$data = '{
"payment_type": "card",
"card": {
"name": "'.$card_name.'",
"number": "'.$card_number.'",
"expiry_month": "'.$expiry_month.'",
"expiry_year": "'.$expiry_year.'",
"cvv": "'.$cvv.'"
}
}';
$url="https://api.sumup.com/v0.1/checkouts/".$checkoutId;
$packet_json = json_encode($data);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS, $packet_json);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($ch);
$output = json_decode($output, true);
if (!$output)
{
return false;
}
The recommended way of using the SDK is by composer. Obviously you don't want to use it so you need to implement autoloader yourself or to 'require' all files from the SDK one by one.
NOTE: you must not process (in production) any checkouts with card details from your backend if you are not PCI DSS certified.
Thank you sir! that helped!! :)
How did you fix this issue? I have the same problem. How can I call the classes?
I've created an index file from where i'am using SumUp class of SumUp.php file from sumup folder, And i'am getting the following error from SumUp.php file:
Fatal error: Uncaught Error: Class 'SumUp\Application\ApplicationConfiguration' not found in /mnt/stor1-wc1-dfw1/388632/www.xyz.com/web/content/wilson/sumup/sumup/SumUp.php:54 Stack trace: #0 /mnt/stor1-wc1-dfw1/388632/www.xyz.com/web/content/wilson/sumup/index.php(23): SumUp\SumUp->__construct(Array) #1 {main} thrown in /mnt/stor1-wc1-dfw1/388632/www.xyz.com/web/content/wilson/sumup/sumup/SumUp.php on line 54