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);
 }
 private function processRequest($hash_out, $hash_in, $type, $choice1 = null, $choice2 = null)
 {
     $hash_config = LitleOnlineRequest::overideconfig($hash_in);
     $hash = LitleOnlineRequest::getOptionalAttributes($hash_in, $hash_out);
     Checker::choice($choice1);
     Checker::choice($choice2);
     $request = Obj2xml::toXml($hash, $hash_config, $type);
     $litleOnlineResponse = $this->newXML->request($request, $hash_config, $this->useSimpleXml);
     return $litleOnlineResponse;
 }
Example #3
0
 /**
  * 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;
 }
<?php

namespace litle\sdk;

require_once realpath(__DIR__) . '/../../vendor/autoload.php';
#Authorization
$auth_info = array('orderId' => '1', 'amount' => '10010', 'id' => '456', 'orderSource' => 'ecommerce', 'billToAddress' => array('name' => 'John Smith', 'addressLine1' => '1 Main St.', 'city' => 'Burlington', 'state' => 'MA', 'zip' => '01803-3747', 'country' => 'US'), 'card' => array('number' => '4457010000000009', 'expDate' => '0112', 'cardValidationNum' => '349', 'type' => 'VI'));
$initilaize = new LitleOnlineRequest();
$authResponse = $initilaize->authorizationRequest($auth_info);
#display results
echo "Response: " . XmlParser::getNode($authResponse, 'response') . "<br>";
echo "Message: " . XmlParser::getNode($authResponse, 'message') . "<br>";
echo "Litle Transaction ID: " . XmlParser::getNode($authResponse, 'litleTxnId');
if (XmlParser::getNode($authResponse, 'message') != 'Approved') {
    throw new \Exception('LitleAuthorizationTransaction does not get the right response');
}
 public function send()
 {
     $this->load->model('checkout/order');
     $orderId = $this->session->data['order_id'];
     $order_info = $this->model_checkout_order->getOrder($orderId);
     $orderAmountToInsert = $this->getAmountInCorrectFormat($order_info['total']);
     $litle_order_info = array('orderId' => $order_info['order_id'], 'customerId' => $order_info['customer_id'], 'amount' => $orderAmountToInsert, 'orderSource' => "ecommerce", 'billToAddress' => $this->getAddressInfo($order_info, "payment"), 'shipToAddress' => $this->getAddressInfo($order_info, "shipping"), 'card' => $this->getCreditCardInfo());
     $hash_in = array_merge($this->merchantDataFromOC(), $litle_order_info);
     $litleResponseMessagePrefix = "";
     $litleRequest = new LitleOnlineRequest($treeResponse = true);
     $doingAuth = $this->config->get('litle_transaction') == "auth";
     if ($doingAuth) {
         //auth txn
         $response = $litleRequest->authorizationRequest($hash_in);
         $litleResponseMessagePrefix = "LitleAuthTxn: ";
         $code = strval($response->authorizationResponse->response);
         $litleTxnId = strval($response->authorizationResponse->litleTxnId);
         $avsResponse = strval($response->authorizationResponse->fraudResult->avsResult);
         $cvvResponse = strval($response->authorizationResponse->fraudResult->cardValidationResult);
         $authCode = strval($response->authorizationResponse->authCode);
     } else {
         //sale txn
         $response = $litleRequest->saleRequest($hash_in);
         $litleResponseMessagePrefix = "LitleSaleTxn: ";
         $code = strval($response->saleResponse->response);
         $litleTxnId = strval($response->saleResponse->litleTxnId);
         $avsResponse = strval($response->saleResponse->fraudResult->avsResult);
         $cvvResponse = strval($response->saleResponse->fraudResult->cardValidationResult);
         $authCode = strval($response->saleResponse->authCode);
     }
     $cvvResponseMap = array("M" => "Match", "N" => "No Match", "P" => "Not Processed", "S" => "CVV2/CVC2/CID should be on the card, but the merchant has indicated CVV2/CVC2/CID is not present", "U" => "Issuer is not certified for CVV2/CVC2/CID processing", "" => "Check was not done for an unspecified reason");
     $cvvResponse = $cvvResponse . " - " . $cvvResponseMap[$cvvResponse];
     $avsResponseMap = array("00" => "5-Digit zip and address match", "01" => "9-Digit zip and address match", "02" => "Postal code and address match", "10" => "5-Digit zip matches, address does not match", "11" => "9-Digit zip matches, address does not match", "12" => "Zip does not match, address matches", "13" => "Postal code does not match, address matches", "14" => "Postal code matches, address not verified", "20" => "Neither zip nor address match", "30" => "AVS service not supported by issuer", "31" => "AVS system not available", "32" => "Address unavailable", "33" => "General error", "34" => "AVS not performed", "40" => "Address failed Litle & Co. edit checks");
     if (array_key_exists($avsResponse, $avsResponseMap)) {
         $avsResponse = $avsResponse . " - " . $avsResponseMap[$avsResponse];
     }
     $litleValidationMessage = $response->message;
     $softDeclineCodes = array("100", "101", "102", "110", "120", "349", "350", "356", "368", "372", "601", "602");
     $genericErrorSoftDecline = "This method of payment has been declined.  Please try another method of payment or contact us for further help";
     $genericErrorHardDecline = "This method of payment has been declined.  Please try another method of payment or contact us for further help";
     $json = array();
     if ($code == "000") {
         //Success
         if ($doingAuth) {
             $orderStatusId = 1;
             //Pending
         } else {
             $orderStatusId = 2;
             //Processing
         }
         $message = "Approval\n" . $litleResponseMessagePrefix . $litleValidationMessage . " \n Litle Response Code: " . $code . "\n  Litle Transaction ID: " . $litleTxnId . " \nAVS Response: " . $avsResponse . "\nCard Validation Response: " . $cvvResponse . "\nAuthCode: " . $authCode;
         $json['success'] = $this->url->link('checkout/success', '', 'SSL');
         $this->model_checkout_order->confirm($order_info['order_id'], $orderStatusId, $message, true);
     } else {
         if (in_array($code, $softDeclineCodes)) {
             //Soft decline
             $orderStatusId = 8;
             //Denied
             $message = "Soft Decline\n" . $litleResponseMessagePrefix . $litleValidationMessage . " \n Litle Response Code: " . $code . "\n  Litle Transaction ID: " . $litleTxnId . " \nAVS Response: " . $avsResponse . "\nCard Validation Response: " . $cvvResponse . "\nAuthCode: " . $authCode;
             $json['error'] = $genericErrorSoftDecline;
             $this->model_checkout_order->update($order_info['order_id'], $orderStatusId, $message, false);
         } else {
             //Do we have a code, if so, hard decline
             $orderStatusId = 8;
             //Denied
             $json['error'] = $genericErrorHardDecline;
             if (!empty($code)) {
                 $message = $litleResponseMessagePrefix . $litleValidationMessage . " \n Litle Response Code: " . $code . "\n  Litle Transaction ID: " . $litleTxnId . " \nAVS Response: " . $avsResponse . "\nCard Validation Response: " . $cvvResponse . "\nAuthCode: " . $authCode;
             } else {
                 //The xml is invalid, incorrect username/password, or other configuration error
                 //scrub the card number and password
                 $hash_in['password'] = preg_replace("/./", "*", $hash_in['password']);
                 $hash_in['card']['number'] = preg_replace("/./", "*", $hash_in['card']['number'], strlen($hash_in['card']['number']) - 4);
                 $message = "The xml sent to Litle failed.\nRequest XML:\n" . print_r($hash_in, TRUE) . "\nResponse XML:\n" . htmlentities($response->asXML());
             }
             $this->model_checkout_order->update($order_info['order_id'], $orderStatusId, $message, false);
         }
     }
     $this->response->setOutput(json_encode($json));
 }
 /**
  * called if voiding a payment
  */
 public function void(Varien_Object $payment)
 {
     $order = $payment->getOrder();
     if (!empty($order)) {
         $hash = array('litleTxnId' => $payment->getCcTransId());
         $merchantData = $this->merchantData($payment);
         $hash_in = array_merge($hash, $merchantData);
         $litleRequest = new LitleOnlineRequest();
         $litleResponse = $litleRequest->echeckVoidRequest($hash_in);
     }
     $this->processResponse($payment, $litleResponse);
 }
<?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');
}
<?php

namespace litle\sdk;

require_once realpath(__DIR__) . '/../../vendor/autoload.php';
#Sale
$sale_info = array('orderId' => '1', 'id' => '456', 'amount' => '10010', 'orderSource' => 'ecommerce', 'billToAddress' => array('name' => 'John Smith', 'addressLine1' => '1 Main St.', 'city' => 'Burlington', 'state' => 'MA', 'zip' => '01803-3747', 'country' => 'US'), 'card' => array('number' => '5112010000000003', 'expDate' => '0112', 'cardValidationNum' => '349', 'type' => 'MC'));
$initilaize = new LitleOnlineRequest();
$saleResponse = $initilaize->saleRequest($sale_info);
#display results
echo "Response: " . XmlParser::getNode($saleResponse, 'response') . "<br>";
echo "Message: " . XmlParser::getNode($saleResponse, 'message') . "<br>";
echo "Litle Transaction ID: " . XmlParser::getNode($saleResponse, 'litleTxnId');
if (XmlParser::getNode($saleResponse, 'message') != 'Approved') {
    throw new \Exception('LitleSaleTransaction does not get the right response');
}
<?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');
}
 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');
     }
 }