* 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("[0;32mYour credit card was charged for [1;32m\$%.2f[0;32m with reference number: [1;32m%s[0;0m", $response->getTransaction()->getAmount(), $response->getReferenceNumber()) . PHP_EOL; }, function (PaymentGateway\Response\CreateCharge $response) { echo sprintf("[0;31mOops, seems like there was a problem charging the credit card: [1;31m%s[0;0m", $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("[0;32mSuccessfully refunded [1;32m\$%.2f[0;32m with reference number [1;32m%s[0;32m linked to reference number [1;32m%s[0;0m", $response->getTransaction()->getAmount(), $response->getTransaction()->getReferenceNumber(), $response->getTransaction()->getParentTransaction()->getReferenceNumber()) . PHP_EOL; }, function (PaymentGateway\Response\ReturnTransaction $response) { echo sprintf("[0;31mOops, seems like there was a problem refunding the transaction: [1;31m%s[0;0m", $response->getApiError()) . PHP_EOL; });
/** * @param Helper\Transaction $transaction */ public function voidTransaction(Helper\Transaction $transaction) { $this->api(sprintf('/charges/%s/refunds', $transaction->getReferenceNumber()), Enum\HttpMethod::POST); }
<?php use Augwa\PaymentGateway; /** * define $paymentGateway * define $creditCard */ include __DIR__ . '/config.php'; $savedCard = $paymentGateway->saveCard($creditCard, function (PaymentGateway\Response\SaveCard $response) { echo sprintf("[0;32mBilling profile successfully created, your token is [1;32m%s[0;32m and will expire on [1;32m%s[0;32m[0;0m", $response->getToken(), $response->getTokenExpiryDate()->format('F jS, Y')) . PHP_EOL; }, function (PaymentGateway\Response\SaveCard $response) { echo sprintf("[0;31mOops, seems like there was a problem saving the credit card: [1;31m%s[0;0m", $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("[0;32mYour credit card was charged for [1;32m\$%.2f[0;32m with reference number: [1;32m%s[0;0m", $response->getTransaction()->getAmount(), $response->getReferenceNumber()) . PHP_EOL; }, function (PaymentGateway\Response\CreateChargeSaved $response) { echo sprintf("[0;31mOops, seems like there was a problem charging the billing profile: [1;31m%s[0;0m", $response->getApiError()) . PHP_EOL; });
/** * @param Helper\Transaction $transaction */ public function voidTransaction(Helper\Transaction $transaction) { $this->api('CreditTransaction', ['tran' => $this->tStreamXML(['TranCode' => 'VoidSaleByRecordNo', 'InvoiceNo' => $transaction->getTransactionId(), 'RefNo' => $transaction->getApiResponse('RefNo'), 'Amount' => ['Purchase' => number_format($transaction->getAmount(), 2, '.', '')], 'TranInfo' => ['AuthCode' => $transaction->getApiResponse('AuthCode'), 'AcqRefData' => $transaction->getApiResponse('AcqRefData'), 'ProcessData' => $transaction->getApiResponse('ProcessData')], 'RecordNo' => $transaction->getReferenceNumber(), 'Frequency' => 'OneTime'])]); }
/** * @param Helper\Transaction $transaction */ public function voidTransaction(Helper\Transaction $transaction) { $this->api(sprintf('/payments/%s/returns', $transaction->getReferenceNumber()), Enum\HttpMethod::POST, ['amount' => number_format($transaction->getAmount(), 2, '.', '')]); }
<?php use Augwa\PaymentGateway; /** * define $paymentGateway * define $creditCard */ include __DIR__ . '/config.php'; $transaction = new PaymentGateway\Helper\Transaction(); $transaction->setTransactionId(time()); $transaction->setTransactionDate(new \DateTime()); $transaction->setCurrency('USD'); $transaction->setAmount('7.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("[0;32mYour credit card was charged for [1;32m\$%.2f[0;32m with reference number: [1;32m%s[0;0m", $response->getTransaction()->getAmount(), $response->getReferenceNumber()) . PHP_EOL; }, function (PaymentGateway\Response\CreateCharge $response) { echo sprintf("[0;31mOops, seems like there was a problem charging the credit card: [1;31m%s[0;0m", $response->getApiError()) . PHP_EOL; }); $paymentGateway->voidTransaction($transaction, function (PaymentGateway\Response\VoidTransaction $response) { echo sprintf("[0;32mTransaction with reference number [1;32m%s[0;32m has been voided, original charge amount of [1;32m\$%.2f[0;0m", $response->getTransaction()->getReferenceNumber(), $response->getTransaction()->getAmount()) . PHP_EOL; }, function (PaymentGateway\Response\VoidTransaction $response) { echo sprintf("[0;31mOops, seems like there was a problem voiding the transaction: [1;31m%s[0;0m", $response->getApiError()) . PHP_EOL; });
/** * @param Helper\Transaction $transaction */ public function createChargeSaved(Helper\Transaction $transaction) { $this->api('authprev', ['prevorderid' => $transaction->getBillingProfile(), 'card-amount' => number_format($transaction->getAmount(), 2, '.', '')]); }
/** * @param Helper\Transaction $transaction */ public function voidTransaction(Helper\Transaction $transaction) { $this->processCreditCard('Void', ['PNRef' => $transaction->getReferenceNumber()]); }
/** * @param Helper\Transaction $transaction */ public function voidTransaction(Helper\Transaction $transaction) { $this->api('purchasecorrection', ['order_id' => md5($transaction->getTransactionId()), 'txn_number' => $transaction->getApiResponse('TransID'), 'crypt_type' => 7, 'dynamic_descriptor' => $this->dynamicDescriptor]); }
/** * @param Helper\Transaction $transaction */ public function voidTransaction(Helper\Transaction $transaction) { $this->api('Reversal', ['TxRefNum' => $transaction->getReferenceNumber(), 'AdjustedAmt' => $transaction->getAmount() * pow(10, $this->getCurrencyExponent()), 'OrderID' => $transaction->getTransactionId()]); }
/** * @param Helper\Transaction $transaction * * @throws Exception\VoidException */ private function voidCheck(Helper\Transaction $transaction) { if ($transaction->getStatus() === Enum\Status::CANCELED) { throw new Exception\VoidException('This transaction has already been voided'); } }