PHP code example of facestorept / omnipay-ifthenpay

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

    

facestorept / omnipay-ifthenpay example snippets


use Omnipay\Omnipay;

//you should use our own 50 char length key
$chaveAntiPhishing = "XXXXXX";

// Setup payment gateway
$gateway = Omnipay::create('Ifthenpay');

$gateway->setEntidade("XXXXX");
$gateway->setSubEntidade("XXX");
$gateway->setCurrency('EUR');
$gateway->setChaveAntiPhishing($chaveAntiPhishing);

$response = $gateway->purchase(['amount' => '100.99', 'transactionId' => '1'])->send();

if ($response->isSuccessful()) {
    // payment was successful: update database and store the transaction details
    $dadosMB = json_decode($response->getTransactionDetails());

    echo "Entidade: ".$dadosMB->entidade;
    echo "<br/>Referencia: ".$dadosMB->transactionReference;
    echo "<br/>Valor: ".$dadosMB->valor;
}

$response = $gateway->completePurchase(array('transactionReference' => '995 000 109','amount' => '100.99','currency' => 'EUR', 'ChaveAntiPhishingCallback' => 'XXXXXX'))->send();

if ($response->isSuccessful())
{
    //Configured AntiPhishing key matches with the received AntiPhishing key
    //This means that the payment was made
    echo "Sucesso";
}