1. Go to this page and download the library: Download lunalabs-srl/slimpay-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
$data = [
'started' => true,
'locale' => 'it',
'paymentScheme' => 'CARD',
'creditor' => ['reference' => 'xxxxxxxxxxx'],
'items' => [['type' => 'cardAlias']],
'subscriber' => [
'reference' => 'yourUniqueUserId',
'givenName' => 'John',
'familyName' => 'Doe',
'email' => '[email protected]',
'telephone' => '+393470000000',
],
'failureUrl' => 'http://yourdomain.com/failure.php',
'successUrl' => 'http://yourdomain.com/success.php',
'cancelUrl' => 'http://yourdomain.com/cancel.php'
];
try {
// This call returns a response with the order representation
// in which you can find the unique ID. Save it to keep the order
// reference (for example, if the order fails).
$response = $slimpay->checkout($data);
$slimpay->showCheckoutPage($response);
} catch (SlimPayPhpException $e) {
// In case of error, you can handle the formatted object response through some useful properties.
header('Content-Type: application/json');
echo json_encode($e->errorFormatter());
}
$data = [
'started' => true,
'creditor' => ['reference' => 'xxxxxxxxxxx'],
'subscriber' => ['reference' => 'yourUniqueUserId'],
'items' => [[
'type' => 'signMandate',
'mandate' => [
'signatory' => [
'givenName' => 'John',
'familyName' => 'Doe',
'email' => '[email protected]',
'telephone' => '+393470000000',
'billingAddress' => [
'street1' => 'Address street 123',
'postalCode' => '01234',
'city' => 'CityName',
'country' => 'IT'
],
]
]
]],
'failureUrl' => 'http://yourdomain.com/failure.php',
'successUrl' => 'http://yourdomain.com/success.php',
'cancelUrl' => 'http://yourdomain.com/cancel.php'
];
try {
// This call returns a response with the order representation
// in which you can find the unique ID. Save it to keep the order
// reference (for example, if the order fails).
$response = $slimpay->checkout($data);
$slimpay->showCheckoutPage($response);
} catch (SlimPayPhpException $e) {
// In case of error, you can handle the formatted object response through some useful properties.
header('Content-Type: application/json');
echo json_encode($e->errorFormatter());
}
try {
$response = $slimpay->getResource('https://api.slimpay.net/RESOURCE-NAME/00000000-0000-0000-0000-000000000000');
} catch (SlimPayPhpException $e) {
// In case of error, you can handle the formatted object response through some useful properties.
header('Content-Type: application/json');
echo json_encode($e->errorFormatter());
}
$notification = new SlimPayNotification();
$response = $notification->getResponse();
class Log
{
public function write($input)
{
$path = "./slimpay_notifications.log";
error_log(json_encode($input), 3, $path);
}
}
$customLog = new Log;
$notification = new SlimPayNotification($customLog);
$response = $notification->getResponse();
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.