<?php namespace litle\sdk; require_once realpath(__DIR__) . '/../../vendor/autoload.php'; #Partial Capture #litleTxnId contains the Litle Transaction Id returned as part of the authorization #submit the amount to capture which is less than the authorization amount #to generate a partial capture $capture_in = array('partial' => 'true', 'id' => '456', 'litleTxnId' => '320000000000000001', 'amount' => '5005'); $initilaize = new LitleOnlineRequest(); $captureResponse = $initilaize->captureRequest($capture_in); #display results echo "Response: " . XmlParser::getNode($captureResponse, 'response') . "<br>"; echo "Message: " . XmlParser::getNode($captureResponse, 'message') . "<br>"; echo "Litle Transaction ID: " . XmlParser::getNode($captureResponse, 'litleTxnId'); if (XmlParser::getNode($captureResponse, 'message') != 'Approved') { throw new \Exception('LitlePartialCapture does not get the right response'); }
/** * this method is called if we are authorising AND capturing a transaction */ public function capture(Varien_Object $payment, $amount) { // throw new Exception('who calls me?'); if (preg_match('/sales_order_create/i', $_SERVER['REQUEST_URI']) && $this->getConfigData('paypage_enable') == '1') { $payment->setStatus('N/A')->setCcTransId('Litle VT')->setLastTransId('Litle VT')->setTransactionId('Litle VT')->setIsTransactionClosed(0)->setCcType('Litle VT'); return; } $this->isFromVT($payment, 'capture'); $order = $payment->getOrder(); if (!empty($order)) { $orderId = $order->getIncrementId(); $orderSource = "ecommerce"; if ($orderId > 200000000) { $orderSource = "recurring"; } $info = $this->getInfoInstance(); if (!$info->getAdditionalInformation('orderSource')) { $info->setAdditionalInformation('orderSource', $orderSource); } $amountToPass = Mage::helper('creditcard')->formatAmount($amount, true); $isPartialCapture = $amount < $order->getGrandTotal() ? 'true' : 'false'; $isSale = $payment->getCcTransId() != null ? false : true; if (!$isSale) { $hash = array('litleTxnId' => $payment->getParentTransactionId(), 'amount' => $amountToPass, 'partial' => $isPartialCapture); } else { $hash_temp = array('orderId' => $orderId, 'id' => $orderId, 'amount' => $amountToPass, 'orderSource' => $info->getAdditionalInformation('orderSource'), 'billToAddress' => $this->getBillToAddress($payment), 'shipToAddress' => $this->getAddressInfo($payment), 'enhancedData' => $this->getEnhancedData($payment)); $payment_hash = $this->creditCardOrPaypageOrToken($payment, $info); $hash = array_merge($hash_temp, $payment_hash); } $merchantData = $this->merchantData($payment); $hash_in = array_merge($hash, $merchantData); $litleRequest = new LitleOnlineRequest(); if ($isSale) { $litleResponse = $litleRequest->saleRequest($hash_in); Mage::helper('palorus')->saveCustomerInsight($payment, $litleResponse); } else { $litleResponse = $litleRequest->captureRequest($hash_in); } if (!is_null($info->getAdditionalInformation('cc_should_save'))) { $this->_saveToken($payment, $litleResponse); } } $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'); } }