public function testGetBatchStatistics()
 {
     $request = new AuthorizeNetTD();
     $response = $request->getSettledBatchList();
     $this->assertTrue($response->isOk());
     $this->assertTrue($response->xml->batchList->count() >= 1);
     $batchId = $response->xml->batchList->batch[0]->batchId;
     $request = new AuthorizeNetTD();
     $response = $request->getBatchStatistics($batchId);
     $this->assertTrue($response->isOk());
 }
Example #2
0
 /**
  * Finds a single instance.
  * 
  * @param int|array $options Instance identifier or filter data.
  *
  * @return array|null
  */
 public function find_one($options = array())
 {
     if (is_numeric($options)) {
         $transaction_id = $options;
     }
     $request = new AuthorizeNetTD();
     $response = $request->getTransactionDetails($transaction_id);
     if (!$response->isOk()) {
         Log::error('Unable to retrieve Authorize.net transaction.');
         return false;
     }
     $transaction = $response->xml->transaction;
     return array('id' => $transaction_id, 'amount' => $transaction->authAmount, 'status' => Arr::get($this->statuses, $transaction->transactionStatus, 'error'));
 }
 public function testGetTransactionDetails()
 {
     $sale = new AuthorizeNetAIM();
     $amount = rand(1, 100);
     $response = $sale->authorizeAndCapture($amount, '4012888818888', '04/17');
     $this->assertTrue($response->approved);
     $transId = $response->transaction_id;
     $request = new AuthorizeNetTD();
     $response = $request->getTransactionDetails($transId);
     $this->assertTrue($response->isOk());
     $this->assertEquals($transId, (string) $response->xml->transaction->transId);
     $this->assertEquals($amount, (string) $response->xml->transaction->authAmount);
     $this->assertEquals("Visa", (string) $response->xml->transaction->payment->creditCard->cardType);
 }
 function AuthorizeNet($that)
 {
     require_once $that->pluginDir . '/extlib/anet_sdk/AuthorizeNet.php';
     define("AUTHORIZENET_API_LOGIN_ID", $that->GetOption('anloginid'));
     define("AUTHORIZENET_TRANSACTION_KEY", $that->GetOption('antransid'));
     define("AUTHORIZENET_MD5_SETTING", $that->GetOption('anmd5hash'));
     $anetsandbox = $that->GetOption('anetsandbox');
     $request = new AuthorizeNetTD();
     if ((int) $anetsandbox != 1) {
         $request->setSandbox(false);
     }
     $response = $request->getTransactionDetails(wlm_arrval($_GET, 'x_trans_id'));
     // Check if transaction response, transaction_id and authCode if present.
     if (!isset($response->xml->transaction->responseCode) || !isset($response->xml->transaction->authCode) || !isset($response->xml->transaction->transId)) {
         return;
     }
     // Check if transaction code is approved.
     if ($response->xml->transaction->responseCode != 1) {
         return;
     }
     foreach ($response->xml->transaction->lineItems->lineItem as $lineItem) {
         $_POST['wpm_id'] = (string) $lineItem->itemId;
     }
     foreach ($response->xml->transaction->billTo as $billTo) {
         $_POST['lastname'] = (string) $billTo->lastName;
         $_POST['firstname'] = (string) $billTo->firstName;
         $_POST['password1'] = $_POST['password2'] = 'sldkfjsdlkfj';
     }
     foreach ($response->xml->transaction->customer as $customer) {
         $_POST['username'] = (string) $customer->email;
         $_POST['email'] = (string) $customer->email;
     }
     $_POST['action'] = 'wpm_register';
     $_POST['sctxnid'] = (string) $response->xml->transaction->transId;
     $amount = (string) $response->xml->transaction->authAmount;
     $transaction_id = (string) $response->xml->transaction->transId;
     $x_md5_hash = (string) $_GET['x_MD5_Hash'];
     $amount = isset($amount) ? $amount : "0.00";
     // Generate hash for checking with authorize.net submitted hash value.
     $generated_hash = strtoupper(md5(AUTHORIZENET_MD5_SETTING . AUTHORIZENET_API_LOGIN_ID . $transaction_id . $amount));
     // Let's verify is authorize.net and generate hash is valid.
     if ($x_md5_hash === $generated_hash) {
         $that->ShoppingCartRegistration();
     } else {
         $that->ShoppingCartDeactivate();
     }
 }
Example #5
0
 /**
  * Return all transactions for a certain day.
  *
  * @param int $month
  * @param int $day
  * @param int $year
  *
  * @return array Array of SimpleXMLElments
  */
 public function getTransactionsForDay($month = false, $day = false, $year = false)
 {
     $transactions = array();
     $month = $month ? $month : date('m');
     $day = $day ? $day : date('d');
     $year = $year ? $year : date('Y');
     $firstSettlementDate = substr(date('c', mktime(0, 0, 0, (int) $month, (int) $day, (int) $year)), 0, -6);
     $lastSettlementDate = substr(date('c', mktime(0, 0, 0, (int) $month, (int) $day, (int) $year)), 0, -6);
     $response = $this->getSettledBatchList(true, $firstSettlementDate, $lastSettlementDate);
     $batches = $response->xpath("batchList/batch");
     foreach ($batches as $batch) {
         $batch_id = (string) $batch->batchId;
         $request = new AuthorizeNetTD();
         $tran_list = $request->getTransactionList($batch_id);
         $transactions = array_merge($transactions, $tran_list->xpath("transactions/transaction"));
     }
     return $transactions;
 }
 function detail()
 {
     $id = $this->input->get('id');
     $authorizenetmytd = new AuthorizeNetTD();
     $response = $authorizenetmytd->getTransactionDetails($id);
     //$response = $authorizenetmytd->getUnsettledTransactionList();
     //DebToFile('$response::'.print_r($response,true));
     //$response = json_encode($response);
     echo $response->response;
     //var_dump($response);
 }
 public function testGetBatchStatistics()
 {
     $this->markTestSkipped('Ignoring for Travis. Will fix after release.');
     //TODO
     $request = new AuthorizeNetTD();
     $response = $request->getSettledBatchList();
     $this->assertTrue($response->isOk());
     $this->assertTrue($response->xml->batchList->count() >= 1);
     $batchId = $response->xml->batchList->batch[0]->batchId;
     $request = new AuthorizeNetTD();
     $response = $request->getBatchStatistics($batchId);
     $this->assertTrue($response->isOk());
 }
Example #8
0
 /**
  * Record the reason the payment was refunded
  * @see ApplyPaymentInterface::rejectPaymentForm()
  */
 public function getRefundPaymentForm(\Jazzee\Entity\Payment $payment)
 {
     $transactionDetails = new \AuthorizeNetTD($this->_paymentType->getVar('gatewayId'), $this->_paymentType->getVar('gatewayKey'));
     $transactionDetails->setSandBox($this->_paymentType->getVar('testAccount'));
     //test accounts get sent to the sandbox
     // Get Transaction Details
     $transactionId = $payment->getVar('transactionId');
     $response = $transactionDetails->getTransactionDetails($transactionId);
     if ($response->isError()) {
         throw new \Jazzee\Exception('Unable to get transaction details for payment #' . $payment->getId() . " transcation id {$transactionId}.  Authorize.net said " . $response->getMessageText(), E_ERROR, 'There was a problem getting payment information.');
     }
     $submitted = new \DateTime($response->xml->transaction->submitTimeLocal);
     if ($submitted->diff(new \DateTime())->days > 120) {
         throw new \Jazzee\Exception('Cannot refund payment, it is too old. Payment ID #' . $payment->getId() . " transcation id {$transactionId}.", E_ERROR, 'Payment is too old to refund.');
     }
     $form = new \Foundation\Form();
     $field = $form->newField();
     $field->setLegend('Refund Payment');
     $element = $field->newElement('Plaintext', 'details');
     $element->setLabel('Details');
     $element->setValue('Refund $' . $payment->getAmount() . ' to card ' . $response->xml->transaction->payment->creditCard->cardNumber);
     $element = $field->newElement('Textarea', 'refundedReason');
     $element->setLabel('Reason displayed to Applicant');
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $form->newHiddenElement('cardNumber', substr($response->xml->transaction->payment->creditCard->cardNumber, strlen($response->xml->transaction->payment->creditCard->cardNumber) - 4, 4));
     $form->newHiddenElement('zip', (string) $response->xml->transaction->billTo->zip);
     $form->newButton('submit', 'Save');
     return $form;
 }