PHP code example of onursimsek / paravan

1. Go to this page and download the library: Download onursimsek/paravan 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/ */

    

onursimsek / paravan example snippets


$config = new \Paravan\Configuration\GvpConfiguration([
    'gateway' => \Paravan\Component\Bank::GARANTI,
    'mode' => 'PROD',
    'api_version' => 'v0.01',
    'type' => 'sales',
    'currency_code' => '949',
    'cardholder_present_code' => '13',
    'moto_ind' => 'N',
    'merchant_id' => 'XXXXXXX',
    'terminal_id' => 'XXXXXXX',
    'terminal_user_id' => 'XXXXXXX',
    'provision_user' => 'PROVAUT',
    'provision_password' => 'XXXXXXXXXXX',
    'store_key' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
    'success_url' => 'https://example.com/payment/success',
    'error_url' => 'https://example.com/payment/fail',
    'security_level' => '3D',
]);

$paravan = new \Paravan\Paravan($config);
$response = $paravan->setCustomer('[email protected]', $_SERVER['REMOTE_ADDR'])
    ->setCard('0123456789012345', '2', '2020', '123')
    ->setOrder(uniqid(), 1.00, 1)
    ->preAuth();
    
// Yönlendirme yapmak için
$response->getRawResponse();

$paravan = new \Paravan\Paravan($config);

// Bankadan dönen isteğin doğrulanması
$validator = $paravan->callbackValidation($_POST);
if (!$validator->isValid()) {
    throw new Exception($validator->getErrorMessage());
}

// Tutarı çekme işlemi
$response = $paravan->setCustomer('[email protected]', $_SERVER['REMOTE_ADDR'])
    ->setOrder($_POST['oid'], 1.00, $_POST['txninstallmentcount'])
    ->setTransaction(
        $_POST['cavv'],
        $_POST['eci'],
        $_POST['xid'],
        $_POST['md']
    )
    ->pay();

if (!$response->isSuccess()) {
  throw new Exception($pay->getErrorMessage());
}

$response->getRawResponse();