* define $paymentGateway
 * define $creditCard
 */
include __DIR__ . '/config.php';
$transaction = new PaymentGateway\Helper\Transaction();
$transaction->setTransactionId('1' . time());
$transaction->setTransactionDate(new \DateTime());
$transaction->setCurrency('USD');
$transaction->setAmount('10.00');
$transaction->setComment('Test Transaction');
$paymentGateway->createCharge($creditCard, $transaction, function (PaymentGateway\Response\CreateCharge $response) {
    /**
     * store the reference number for future use
     */
    $response->getTransaction()->setReferenceNumber($response->getReferenceNumber());
    echo sprintf("Your credit card was charged for \$%.2f with reference number: %s", $response->getTransaction()->getAmount(), $response->getReferenceNumber()) . PHP_EOL;
}, function (PaymentGateway\Response\CreateCharge $response) {
    echo sprintf("Oops, seems like there was a problem charging the credit card: %s", $response->getApiError()) . PHP_EOL;
});
$refundTransaction = new PaymentGateway\Helper\Transaction();
$refundTransaction->setParentTransaction($transaction);
$refundTransaction->setTransactionId('2' . time());
$refundTransaction->setTransactionDate(new \DateTime());
$refundTransaction->setCurrency('USD');
$refundTransaction->setAmount('4.59');
$refundTransaction->setComment('Test Transaction');
$paymentGateway->returnTransaction($refundTransaction, function (PaymentGateway\Response\ReturnTransaction $response) {
    echo sprintf("Successfully refunded \$%.2f with reference number %s linked to reference number %s", $response->getTransaction()->getAmount(), $response->getTransaction()->getReferenceNumber(), $response->getTransaction()->getParentTransaction()->getReferenceNumber()) . PHP_EOL;
}, function (PaymentGateway\Response\ReturnTransaction $response) {
    echo sprintf("Oops, seems like there was a problem refunding the transaction: %s", $response->getApiError()) . PHP_EOL;
});
<?php

use Augwa\PaymentGateway;
/**
 * define $paymentGateway
 * define $creditCard
 */
include __DIR__ . '/config.php';
$savedCard = $paymentGateway->saveCard($creditCard, function (PaymentGateway\Response\SaveCard $response) {
    echo sprintf("Billing profile successfully created, your token is %s and will expire on %s", $response->getToken(), $response->getTokenExpiryDate()->format('F jS, Y')) . PHP_EOL;
}, function (PaymentGateway\Response\SaveCard $response) {
    echo sprintf("Oops, seems like there was a problem saving the credit card: %s", $response->getApiError()) . PHP_EOL;
});
$transaction = new PaymentGateway\Helper\Transaction();
$transaction->setTransactionId(time());
$transaction->setTransactionDate(new \DateTime());
$transaction->setCurrency('USD');
$transaction->setAmount('10.00');
$transaction->setComment('Test Transaction');
$transaction->setBillingProfile($savedCard->getToken());
$paymentGateway->createChargeSaved($transaction, function (PaymentGateway\Response\CreateChargeSaved $response) {
    echo sprintf("Your credit card was charged for \$%.2f with reference number: %s", $response->getTransaction()->getAmount(), $response->getReferenceNumber()) . PHP_EOL;
}, function (PaymentGateway\Response\CreateChargeSaved $response) {
    echo sprintf("Oops, seems like there was a problem charging the billing profile: %s", $response->getApiError()) . PHP_EOL;
});