PHP code example of soneritics / buckaroo

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

    

soneritics / buckaroo example snippets


$gateway = new \Buckaroo\Gateways\Test;
$transactionRequest = new \Buckaroo\ServiceOperations\TransactionRequest;
$buckaroo = new \Buckaroo\Buckaroo($gateway, $websiteKey, $secretKey);

$transactionRequest
    ->setCurrency(new \Buckaroo\Currency\EUR)
    ->setPaymentMethod(new \Buckaroo\PaymentMethods\iDeal)
    ->setAmount(12.5)
    ->setInvoiceNumber('Test-' . time())
    ->setReturnURL($returnURL)
    ->setCancelURL($returnURL)
    ->setRejectURL($returnURL)
    ->setErrorURL($returnURL);

$response = $buckaroo->performServiceOperation($transactionRequest);

try {
    $redirectURL = $response->getField('BRQ_REDIRECTURL');
    header("Location: {$redirectURL}");
} catch (Exception $ex) {
    echo 'ERROR: Something went wrong: ' . $ex->getMessage();
}
 php
try {
    $transactionStatusResponse = new \Buckaroo\Response\TransactionStatusResponse($_POST, $secretKey);

    if ($transactionStatusResponse->getStatus() === \Buckaroo\Status::SUCCESS) {
        $order = $transactionStatusResponse->getInvoiceNumber();
        $currency = $transactionStatusResponse->getCurrency();
        $amount = $transactionStatusResponse->getAmount();
        echo "The order {$order} with amount {$currency} {$amount} has been paid.";
    } elseif ($transactionStatusResponse->getStatus() === \Buckaroo\Status::PENDING_PROCESSING) {
        $paymentCode = $transactionStatusResponse->getPaymentCode();
        echo "The order is pending. Fetch transaction details later for order with payment code {$paymentCode}.";
    } else {
        echo 'Order has not been paid for.';
    }
} catch (\Buckaroo\Exceptions\InvalidSignatureException $e) {
    echo 'Signature does not match, possible break in attempt.';
}