Example #1
0
 protected function _buildRequest(Varien_Object $payment)
 {
     if (!$payment->getTrxtype()) {
         $payment->setTrxtype(self::TRXTYPE_AUTH_ONLY);
     }
     if (!$payment->getTender()) {
         $payment->setTender(self::TENDER_CC);
     }
     $request = Mage::getModel('paygate/payflow_pro_request')->setUser($this->getConfigData('user'))->setVendor($this->getConfigData('vendor'))->setPartner($this->getConfigData('partner'))->setPwd($this->getConfigData('pwd'))->setTender($payment->getTender())->setTrxtype($payment->getTrxtype())->setVerbosity($this->getConfigData('verbosity'))->setRequestId($this->_generateRequestId());
     if ($payment->getAmount()) {
         $request->setAmt(round($payment->getAmount(), 2));
         $request->setCurrency($payment->getOrder()->getBaseCurrencyCode());
     }
     switch ($request->getTender()) {
         case self::TENDER_CC:
             if ($payment->getCcNumber()) {
                 $request->setAcct($payment->getCcNumber())->setExpdate(sprintf('%02d', $payment->getCcExpMonth()) . substr($payment->getCcExpYear(), -2, 2))->setCvv2($payment->getCcCid());
             }
             break;
     }
     $order = $payment->getOrder();
     if (!empty($order)) {
         $billing = $order->getBillingAddress();
         if (!empty($billing)) {
             $request->setFirstname($billing->getFirstname())->setLastname($billing->getLastname())->setStreet($billing->getStreet(1))->setCity($billing->getCity())->setState($billing->getRegion())->setZip($billing->getPostcode())->setCountry($billing->getCountry())->setEmail($payment->getOrder()->getCustomerEmail());
         }
         $shipping = $order->getShippingAddress();
         if (!empty($shipping)) {
             $request->setShiptofirstname($shipping->getFirstname())->setShiptolastname($shipping->getLastname())->setShiptostreet($shipping->getStreet(1))->setShiptocity($shipping->getCity())->setShiptostate($shipping->getRegion())->setShiptozip($shipping->getPostcode())->setShiptocountry($shipping->getCountry());
         }
     }
     return $request;
 }
Example #2
0
 protected function _buildRequest(Varien_Object $payment)
 {
     if (!$payment->getTrxtype()) {
         $payment->setTrxtype(self::TRXTYPE_AUTH_ONLY);
     }
     if (!$payment->getTender()) {
         $payment->setTender(self::TENDER_CC);
     }
     $request = $this->_getRequestObject()->setUser($this->getConfigData('user'))->setVendor($this->getConfigData('vendor'))->setPartner($this->getConfigData('partner'))->setPwd($this->getConfigData('pwd'))->setTender($payment->getTender())->setTrxtype($payment->getTrxtype())->setVerbosity($this->getConfigData('verbosity'))->setRequestId($this->_generateRequestId());
     if ($this->getIsCentinelValidationEnabled()) {
         $params = array();
         $params = $this->getCentinelValidator()->exportCmpiData($params);
         $request = Varien_Object_Mapper::accumulateByMap($params, $request, $this->_centinelFieldMap);
     }
     if ($payment->getAmount()) {
         $request->setAmt(round($payment->getAmount(), 2));
         $request->setCurrency($payment->getOrder()->getBaseCurrencyCode());
     }
     switch ($request->getTender()) {
         case self::TENDER_CC:
             if ($payment->getCcNumber()) {
                 $request->setAcct($payment->getCcNumber())->setExpdate(sprintf('%02d', $payment->getCcExpMonth()) . substr($payment->getCcExpYear(), -2, 2))->setCvv2($payment->getCcCid());
             }
             break;
     }
     $order = $payment->getOrder();
     if (!empty($order)) {
         $billing = $order->getBillingAddress();
         if (!empty($billing)) {
             $request->setFirstname($billing->getFirstname())->setLastname($billing->getLastname())->setStreet($billing->getStreet(1))->setCity($billing->getCity())->setState($billing->getRegion())->setZip($billing->getPostcode())->setCountry($billing->getCountry())->setEmail($payment->getOrder()->getCustomerEmail());
         }
         $shipping = $order->getShippingAddress();
         if (!empty($shipping)) {
             $request->setShiptofirstname($shipping->getFirstname())->setShiptolastname($shipping->getLastname())->setShiptostreet($shipping->getStreet(1))->setShiptocity($shipping->getCity())->setShiptostate($shipping->getRegion())->setShiptozip($shipping->getPostcode())->setShiptocountry($shipping->getCountry());
         }
     }
     return $request;
 }