<?php

namespace litle\sdk;

require_once realpath(__DIR__) . '/../../vendor/autoload.php';
#PHP SDK- Litle Credit Transaction
#Credit
#litleTxnId contains the Litle Transaction Id returned on
#the capture or sale transaction being credited
#the amount is optional, if it isn't submitted the full amount will be credited
$credit_info = array('litleTxnId' => '100000000000000002', 'id' => '456', 'amount' => '1010');
$initilaize = new LitleOnlineRequest();
$creditResponse = $initilaize->creditRequest($credit_info);
#display results
echo "Response: " . XmlParser::getNode($creditResponse, 'response') . "<br>";
echo "Message: " . XmlParser::getNode($creditResponse, 'message') . "<br>";
echo "Litle Transaction ID: " . XmlParser::getNode($creditResponse, 'litleTxnId');
if (XmlParser::getNode($creditResponse, 'message') != 'Approved') {
    throw new \Exception('LitleCreditTransaction does not get the right response');
}
示例#2
0
 /**
  * called if refunding
  */
 public function refund(Varien_Object $payment, $amount)
 {
     $this->isFromVT($payment, 'refund');
     $order = $payment->getOrder();
     $isPartialRefund = $amount < $order->getGrandTotal() ? true : false;
     $amountToPass = Mage::helper('creditcard')->formatAmount($amount, true);
     if (!empty($order)) {
         $hash = array('litleTxnId' => $this->findCaptureLitleTxnToRefundForPayment($payment), 'amount' => $amountToPass);
         $merchantData = $this->merchantData($payment);
         $hash_in = array_merge($hash, $merchantData);
         $litleRequest = new LitleOnlineRequest();
         $litleResponse = $litleRequest->creditRequest($hash_in);
     }
     $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');
     }
 }