public function test_surchargeAmount_optional() { $hash_in = array('litleTxnId' => '3', 'amount' => '2', 'payPalNotes' => 'notes'); $mock = $this->getMock('litle\\sdk\\LitleXmlMapper'); $mock->expects($this->once())->method('request')->with($this->matchesRegularExpression('/.*<amount>2<\\/amount><payPalNotes>notes<\\/payPalNotes>.*/')); $litleTest = new LitleOnlineRequest(); $litleTest->newXML = $mock; $litleTest->authReversalRequest($hash_in); }
/** * called if voiding a payment */ public function void(Varien_Object $payment) { $this->isFromVT($payment, 'void'); $order = $payment->getOrder(); if (!empty($order)) { $hash = array('litleTxnId' => $payment->getCcTransId()); $merchantData = $this->merchantData($payment); $hash_in = array_merge($hash, $merchantData); $litleRequest = new LitleOnlineRequest(); // if (Mage::helper('creditcard')->isStateOfOrderEqualTo($order, // Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH)) if ($order->getPayment()->getAuthorizationTransaction() && $payment->getAmountPaid() == 0) { $litleResponse = $litleRequest->authReversalRequest($hash_in); } else { $litleResponse = $litleRequest->voidRequest($hash_in); $payment->setParentTransactionId($payment->getLastTransId()); } } $this->processResponse($payment, $litleResponse); return $this; }
public function makeTheTransaction($typeOfTransaction) { $this->load->language('payment/litle'); $order_id = $this->request->get['order_id']; $this->load->model('sale/order'); $total_order_histories = $this->model_sale_order->getTotalOrderHistories($order_id); $latest_order_history = $this->model_sale_order->getOrderHistories($order_id, 0, $total_order_histories); $order = $this->model_sale_order->getOrder($order_id); $latest_order_status_id = $order['order_status_id']; $merchantConfig = $this->merchantDataFromOC(); $litleRequest = new LitleOnlineRequest($treeResponse = true); // Refunds if ($typeOfTransaction == "Refund") { $litleTextToLookFor = $this->language->get('text_litle_capture_txn'); $hash_in = array_merge($merchantConfig, $this->getHashInWithLitleTxnId("Litle Transaction ID:")); $response = $litleRequest->creditRequest($hash_in); $code = strval($response->creditResponse->response); $responseMessage = strval($response->creditResponse->message); $litleTxnId = strval($response->creditResponse->litleTxnId); $comment = $this->generateComment($typeOfTransaction, $code, $litleTxnId, $responseMessage); if ($code == "000" || $code == "311" || $code == "316") { $data = array('order_status_id' => 11, 'comment' => $comment, 'notify' => false); //Refunded $this->model_sale_order->addOrderHistory($order_id, $data); } else { $this->error['warning'] = $comment; $data = array('order_status_id' => $latest_order_status_id, 'comment' => $comment, 'notify' => false); //Don't change the status $this->model_sale_order->addOrderHistory($order_id, $data); } } else { if ($typeOfTransaction == "Capture") { $litleTextToLookFor = $this->language->get('text_litle_capture_txn'); $hash_in = array_merge($merchantConfig, $this->getHashInWithLitleTxnId("Litle Transaction ID:")); $response = $litleRequest->captureRequest($hash_in); $code = strval($response->captureResponse->response); $responseMessage = strval($response->captureResponse->message); $litleTxnId = strval($response->captureResponse->litleTxnId); $comment = $this->generateComment($typeOfTransaction, $code, $litleTxnId, $responseMessage); if ($code == "000") { $data = array('order_status_id' => 2, 'comment' => $comment, 'notify' => false); //Processing $this->model_sale_order->addOrderHistory($order_id, $data); } else { $this->error['warning'] = $comment; $data = array('order_status_id' => $latest_order_status_id, 'comment' => $comment, 'notify' => false); //Don't change the status $this->model_sale_order->addOrderHistory($order_id, $data); } } else { if ($typeOfTransaction == "AuthReversal") { $litleTextToLookFor = $this->language->get('text_litle_capture_txn'); $hash_in = array_merge($merchantConfig, $this->getHashInWithLitleTxnId("Litle Transaction ID:")); $response = $litleRequest->authReversalRequest($hash_in); $code = strval($response->authReversalResponse->response); $responseMessage = strval($response->authReversalResponse->message); $litleTxnId = strval($response->authReversalResponse->litleTxnId); $comment = $this->generateComment($typeOfTransaction, $code, $litleTxnId, $responseMessage); if ($code == "000") { $data = array('order_status_id' => 12, 'comment' => $comment, 'notify' => false); //Reversed $this->model_sale_order->addOrderHistory($order_id, $data); } else { if ($code == "306") { $data = array('order_status_id' => 14, 'comment' => $comment, 'notify' => false); //Expired $this->model_sale_order->addOrderHistory($order_id, $data); } else { $this->error['warning'] = $comment; $data = array('order_status_id' => $latest_order_status_id, 'comment' => $comment, 'notify' => false); //Don't change the status $this->model_sale_order->addOrderHistory($order_id, $data); } } } } } if (isset($this->error['warning'])) { $this->session->data['litle_warning'] = $this->error['warning']; } if (isset($this->session->data['token'])) { $this->redirect(HTTPS_SERVER . 'index.php?route=sale/order&token=' . $this->session->data['token']); } else { $this->redirect(HTTPS_SERVER . 'index.php?route=sale/order'); } }