PHP code example of sportakal / garantipos

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

    

sportakal / garantipos example snippets




use Sportakal\Garantipos\Models\Options;

$options = new Options();
$options->setMode($_ENV['MODE']);
$options->setApiVersion($_ENV['API_VERSION']);
$options->setTerminalId($_ENV['TERMINAL_ID']);
$options->setTerminalProvUserId($_ENV['TERMINAL_PROV_USER_ID_PAY']);
$options->setTerminalProvUserPassword($_ENV['TERMINAL_PROV_USER_PASSWORD']);
$options->setTerminalUserId($_ENV['TERMINAL_USER_ID']);
$options->setTerminalMerchantId($_ENV['TERMINAL_MERCHANT_ID']);
$options->setStoreKey($_ENV['STORE_KEY']);

$card = new Card();
$card->setNumber('5549608789641500');
$card->setExpireDate('0323');
$card->setCVV2('712');

$customer = new Customer();
$customer->setIpAddress('159.146.45.34');
$customer->setEmailAddress('[email protected]');

$order = new Order();
$order->setOrderID('sportakal_garantipos_' . time());

$address = new Address();
$address->setType('B'); // B for 'billing' or S for 'shipping'
$address->setName('Sinan');
$address->setLastName('Portakal');
$address->setPhoneNumber('+90 532 345 67 89');
$address->setText('Kınıklı Mah.');
$address->setDistrict('Pamukkale');
$address->setCity('Denizli');
$address->setCountry('Turkey');

$order->addAddress($address);

$transaction = new Transaction();
$transaction->setInstallmentCnt("");
$transaction->setAmount(1000);
$transaction->setCurrencyCode('TRY');
$transaction->setCardholderPresentCode('0');
$transaction->setMotoInd('N');
$transaction->setDescription('test payment');

$request = new RequestModel();
$request->setOptions($options);
$request->setCard($card);
$request->setCustomer($customer);
$request->setOrder($order);
$request->setTransaction($transaction);

$request = new \Sportakal\Garantipos\Requests\Pay($request);

$request = new \Sportakal\Garantipos\Requests\Refund($request);

$request = new \Sportakal\Garantipos\Requests\ThreeDSecurePay($request);

$result = $request->getResult();

$status = $result->getStatus(); //boolean
$message = $result->getStatusMessage(); //string
$error_message = $result->getErrorMessage()); //string

$result = new \Sportakal\Garantipos\Results\ThreeDSecurePayResult($options);

$md_status = $result->getMdStatus();
$md_response_message = $result->getResponseMessage();
$md_error_message = $result->getErrorMessage()

$order = $result->getOrder();
$transaction = $result->getTransaction();