PHP code example of doge-dev / all-secure-php-client
1. Go to this page and download the library: Download doge-dev/all-secure-php-client 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/ */
doge-dev / all-secure-php-client example snippets
use DogeDev\AllSecure\Client;
use DogeDev\AllSecure\Data\Customer;
use DogeDev\AllSecure\Transaction\Debit;
use DogeDev\AllSecure\Transaction\Result;
// Include the autoloader (if not already done via Composer autoloader)
l.test");
$debit = new Debit();
// define your transaction ID: e.g. 'myId-'.date('Y-m-d').'-'.uniqid()
$merchantTransactionId = 'your_transaction_id'; // must be unique
$debit->setTransactionId($merchantTransactionId)
->setSuccessUrl($redirectUrl)
->setCancelUrl($redirectUrl)
->setCallbackUrl($callbackUrl)
->setAmount(10.00)
->setCurrency('EUR')
->setCustomer($customer);
// send the transaction
$result = $client->debit($debit);
// now handle the result
if ($result->isSuccess()) {
//act depending on $result->getReturnType()
$gatewayReferenceId = $result->getReferenceId(); //store it in your database
if ($result->getReturnType() == Result::RETURN_TYPE_ERROR) {
//error handling
$errors = $result->getErrors();
//cancelCart();
} elseif ($result->getReturnType() == Result::RETURN_TYPE_REDIRECT) {
//redirect the user
header('Location: '.$result->getRedirectUrl());
die;
} elseif ($result->getReturnType() == Result::RETURN_TYPE_PENDING) {
//payment is pending, wait for callback to complete
//setCartToPending();
} elseif ($result->getReturnType() == Result::RETURN_TYPE_FINISHED) {
//payment is finished, update your cart/payment transaction
//finishCart();
}
}