PHP code example of eseperio / ceca-omnipay

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

    

eseperio / ceca-omnipay example snippets


$gateway = Omnipay::create('Ceca');

$gateway->setMerchantId('your_merchant_id');
$gateway->setTerminalId('your_terminal_id');
$gateway->setAcquirerBin('your_acquirer_bin');
$gateway->setEncryptionKey('your_encryption_key');
$gateway->setTestMode(true); // skip this line to use production mode or set it to false
// IMPORTANT: this gateway use omnipay support for currency, so you must set the currenty
// using its ISO name instead of the currency code (978).
$gateway->setCurrency('EUR');

$response = $gateway->purchase();
    ->setTransactionId('your_transaction_id')
    ->setAmount('10.00')
    ->setDescription('your_description')
    ->setURL_OK('https://yourdomain.com/ok')
    ->setURL_NOK('https://yourdomain.com/nok');

/**
 * @var $response \Omnipay\Ceca\Message\PurchaseResponse
 */
$response = $purchaseRequest->send();
if ($response->isRedirect()) {
    $response->redirect();
} else {
    Yii::error('Payment request failed', 'omnipay');
    Yii::error($response->getMessage(), 'omnipay');
    throw new Exception($response->getMessage());
}

    $gateway = Omnipay::create('Ceca');
    $gateway->setMerchantId('your_merchant_id');
    [...] // same settings as before

    $notification = $gateway->acceptNotification();
    if ($notification->getTransactionStatus() == NotificationInterface::STATUS_COMPLETED) {
            // Mark your order as paid
            return;
        } else {
            throw new \Exception($notification->getMessage());
        }

    $gateway = Omnipay::create('Ceca');
    $gateway->setMerchantId('your_merchant_id');
    [...] // same settings as before

    $notification = $gateway->acceptNotification();
    $notification->send();