Example #1
0
 /**
  * Convert xml object to a Varien object.
  *
  * @param SimpleXMLElement $xml Xml response from the API.
  * @return object Api response into a Varien object.
  */
 private function _mapTranscationDetails(SimpleXMLElement $xml)
 {
     $object = new Varien_Object();
     $object->setErrorcode($xml->errorcode);
     $object->setTimestamp($xml->timestamp);
     if ((string) $xml->errorcode === '0000') {
         $object->setVpstxid($xml->vpstxid);
         $object->setContactNumber($xml->contactnumber);
         $object->setVendortxcode($xml->vendortxcode);
         $object->setTransactiontype($xml->transactiontype);
         $object->setStatus($xml->status);
         $object->setDescription($xml->description);
         $object->setAmount($xml->amount);
         $object->setCurrency($xml->currency);
         $object->setStarted($xml->started);
         $object->setCompleted($xml->completed);
         $object->setSecuritykey($xml->securitykey);
         $object->setClientip($xml->clientip);
         $object->setIplocation($xml->iplocation);
         $object->setGiftaid($xml->giftaid);
         $object->setPaymentsystem($xml->paymentsystem);
         $object->setPaymentsystemdetails($xml->paymentsystemdetails);
         $object->setAuthprocessor($xml->authprocessor);
         $object->setMerchantnumber($xml->merchantnumber);
         $object->setAccounttype($xml->accounttype);
         $object->setBillingaddress($xml->billingaddress);
         $object->setBillingpostcode($xml->billingpostcode);
         $object->setDeliveryaddress($xml->deliveryaddress);
         $object->setDeliverypostcode($xml->deliverypostcode);
         $object->setSystemused($xml->systemused);
         $object->setCustomeremail($xml->customeremail);
         $object->setAborted($xml->aborted);
         $object->setRefunded($xml->refunded);
         $object->setRepeated($xml->repeated);
         $object->setBasket($xml->basket);
         $object->setApplyavscv2($xml->applyavscv2);
         $object->setApply3dsecure($xml->apply3dsecure);
         $object->setAttempt($xml->attempt);
         $object->setCardholder($xml->cardholder);
         $object->setCardaddress($xml->cardaddress);
         $object->setCardpostcode($xml->cardpostcode);
         $object->setStartdate($xml->startdate);
         $object->setExpirydate($xml->expirydate);
         $object->setLast4digits($xml->last4digits);
         $object->setThreedresult($xml->threedresult);
         $object->setEci($xml->eci);
         $object->setCavv($xml->cavv);
         $object->setT3mscore($xml->t3mscore);
         $object->setT3maction($xml->t3maction);
         $object->setT3mid($xml->t3mid);
     } else {
         $object->setError(htmlentities($xml->error));
     }
     return $object;
 }
Example #2
0
 /**
  * Return commno data for *all* transactions.
  * @return array Data
  */
 public function _getGeneralTrnData(Varien_Object $payment)
 {
     $order = $payment->getOrder();
     $quoteObj = $this->_getQuote();
     $vendorTxCode = $this->_getTrnVendorTxCode();
     if ($payment->getCcNumber()) {
         $vendorTxCode .= $this->_cleanString(substr($payment->getCcOwner(), 0, 10));
     }
     $payment->setVendorTxCode($vendorTxCode);
     $request = new Varien_Object();
     $request->setVPSProtocol('2.23')->setReferrerID($this->getConfigData('referrer_id'))->setVendor($this->getConfigData('vendor'))->setVendorTxCode($vendorTxCode);
     $request->setClientIPAddress($this->getClientIp());
     if ($payment->getIntegra()) {
         $this->getSageSuiteSession()->setLastVendorTxCode($vendorTxCode);
         $request->setIntegration($payment->getIntegra());
         $request->setData('notification_URL', $this->getNotificationUrl() . '&vtxc=' . $vendorTxCode);
         $request->setData('success_URL', $this->getSuccessUrl());
         $request->setData('redirect_URL', $this->getRedirectUrl());
         $request->setData('failure_URL', $this->getFailureUrl());
     }
     if ($this->_getIsAdminOrder()) {
         $request->setAccountType('M');
     }
     if ($payment->getAmountOrdered()) {
         $from = $order->getOrderCurrencyCode();
         if ((string) $this->getConfigData('trncurrency') == 'store') {
             $request->setAmount($this->formatAmount($quoteObj->getGrandTotal(), $quoteObj->getQuoteCurrencyCode()));
             $request->setCurrency($quoteObj->getQuoteCurrencyCode());
         } else {
             $request->setAmount($this->formatAmount($quoteObj->getBaseGrandTotal(), $quoteObj->getBaseCurrencyCode()));
             $request->setCurrency($quoteObj->getBaseCurrencyCode());
         }
     }
     if (!empty($order)) {
         $billing = $order->getBillingAddress();
         if (!empty($billing)) {
             $request->setBillingAddress($billing->getStreet(1) . ' ' . $billing->getCity() . ' ' . $billing->getRegion() . ' ' . $billing->getCountry())->setBillingSurname($this->ss($billing->getLastname(), 20))->setBillingFirstnames($this->ss($billing->getFirstname(), 20))->setBillingPostCode($this->ss($billing->getPostcode(), 10))->setBillingAddress1($this->ss($billing->getStreet(1), 100))->setBillingAddress2($this->ss($billing->getStreet(2), 100))->setBillingCity($this->ss($billing->getCity(), 40))->setBillingCountry($billing->getCountry())->setContactNumber(substr($this->_cphone($billing->getTelephone()), 0, 20));
             if ($billing->getCountry() == 'US') {
                 $request->setBillingState($billing->getRegionCode());
             }
             $request->setCustomerEMail($billing->getEmail());
         }
         if (!$request->getDescription()) {
             $request->setDescription('.');
         }
         $shipping = $order->getShippingAddress();
         if (!empty($shipping)) {
             $request->setDeliveryAddress($shipping->getStreet(1) . ' ' . $shipping->getCity() . ' ' . $shipping->getRegion() . ' ' . $shipping->getCountry())->setDeliverySurname($this->ss($shipping->getLastname(), 20))->setDeliveryFirstnames($this->ss($shipping->getFirstname(), 20))->setDeliveryPostCode($this->ss($shipping->getPostcode(), 10))->setDeliveryAddress1($this->ss($shipping->getStreet(1), 100))->setDeliveryAddress2($this->ss($shipping->getStreet(2), 100))->setDeliveryCity($this->ss($shipping->getCity(), 40))->setDeliveryCountry($shipping->getCountry())->setDeliveryPhone($this->ss(urlencode($this->_cphone($shipping->getTelephone())), 20));
             if ($shipping->getCountry() == 'US') {
                 $request->setDeliveryState($shipping->getRegionCode());
             }
         } else {
             #If the cart only has virtual products, I need to put an shipping address to Sage Pay.
             #Then the billing address will be the shipping address to
             $request->setDeliveryAddress($billing->getStreet(1) . ' ' . $billing->getCity() . ' ' . $billing->getRegion() . ' ' . $billing->getCountry())->setDeliverySurname($this->ss($billing->getLastname(), 20))->setDeliveryFirstnames($this->ss($billing->getFirstname(), 20))->setDeliveryPostCode($this->ss($billing->getPostcode(), 10))->setDeliveryAddress1($this->ss($billing->getStreet(1), 100))->setDeliveryAddress2($this->ss($billing->getStreet(2), 100))->setDeliveryCity($this->ss($billing->getCity(), 40))->setDeliveryCountry($billing->getCountry())->setDeliveryPhone($this->ss(urlencode($this->_cphone($billing->getTelephone())), 20));
             if ($billing->getCountry() == 'US') {
                 $request->setDeliveryState($billing->getRegionCode());
             }
         }
     }
     if ($payment->getCcNumber()) {
         $request->setCardNumber($payment->getCcNumber())->setExpiryDate(sprintf('%02d%02d', $payment->getCcExpMonth(), substr($payment->getCcExpYear(), strlen($payment->getCcExpYear()) - 2)))->setCardType($payment->getCcType())->setCV2($payment->getCcCid())->setCardHolder($payment->getCcOwner());
         if ($payment->getCcIssue()) {
             $request->setIssueNumber($payment->getCcIssue());
         }
         if ($payment->getCcStartMonth() && $payment->getCcStartYear()) {
             $request->setStartDate(sprintf('%02d%02d', $payment->getCcStartMonth(), substr($payment->getCcStartYear(), strlen($payment->getCcStartYear()) - 2)));
         }
     }
     $totals = $shipping->getTotals();
     $shippingTotal = isset($totals['shipping']) ? $totals['shipping']->getValue() : 0;
     if ($this->getSendBasket()) {
         $request->setBasket($this->_getBasketContents($quoteObj));
     }
     if (!$request->getDeliveryPostCode()) {
         $request->setDeliveryPostCode('000');
     }
     if (!$request->getBillingPostCode()) {
         $request->setBillingPostCode('000');
     }
     return $request;
 }