/**
  * Make prepaid credit card payloads for any payments
  * remaining in the list
  * @param Mage_Sales_Model_Order $order
  * @param IPaymentContainer      $paymentContainer
  * @param SplObjectStorage       $processedPayments
  */
 public function addPaymentsToPayload(Mage_Sales_Model_Order $order, IPaymentContainer $paymentContainer, SplObjectStorage $processedPayments)
 {
     foreach ($order->getAllPayments() as $payment) {
         if ($this->_shouldIgnorePayment($payment, $processedPayments)) {
             continue;
         }
         $iterable = $paymentContainer->getPayments();
         $payload = $iterable->getEmptyCreditCardPayment();
         $additionalInfo = new Varien_Object($payment->getAdditionalInformation());
         $payload->setOrderId($order->getIncrementId())->setTenderType($additionalInfo->getTenderType())->setAccountUniqueId($this->_getAccountUniqueId($payment))->setPanIsToken($additionalInfo->getPanIsToken())->setPaymentRequestId($additionalInfo->getRequestId())->setCreateTimestamp($this->_getAsDateTime($payment->getCreatedAt()))->setAmount($payment->getAmountAuthorized())->setBankAuthorizationCode($additionalInfo->getBankAuthorizationCode())->setResponseCode($additionalInfo->getResponseCode())->setCVV2ResponseCode($additionalInfo->getCvv2ResponseCode())->setAVSResponseCode($additionalInfo->getAvsResponseCode())->setPhoneResponseCode($additionalInfo->getPhoneResponseCode())->setNameResponseCode($additionalInfo->getNameResponseCode())->setEmailResponseCode($additionalInfo->getEmailResponseCode())->setAmountAuthorized($additionalInfo->getAmountAuthorized())->setExpirationDate($this->_getExpirationDateTime($payment))->setExtendedAuthDescription($additionalInfo->getExtendedAuthDescription())->setExtendedAuthReasonCode($additionalInfo->getExtendedAuthReasonCode())->setIssueNumber($additionalInfo->getIssueNumber())->setAuthenticationAvailable($additionalInfo->getAuthenticationAvailable())->setAuthenticationStatus($additionalInfo->getAuthenticationStatus())->setCavvUcaf($additionalInfo->getCavvUcaf())->setTransactionId($additionalInfo->getTransactionId())->setECI($additionalInfo->getECI())->setPayerAuthenticationResponse($additionalInfo->getPayerAuthenticationResponse())->setPurchasePlanCode($additionalInfo->getPurchasePlanCode())->setPurchasePlanDescription($additionalInfo->getPurchasePlanDescription());
         if ($additionalInfo->getStartDate()) {
             // prevent death by type error if getStartDate returns null
             $payload->setStartDate($this->_getAsDateTime($additionalInfo->getStartDate()));
         }
         // add the new payload
         $iterable->OffsetSet($payload, $payload);
         // put the payment in the processed payments set
         $processedPayments->attach($payment);
     }
 }
Example #2
0
 /**
  * Call create new customer token API
  *
  * @param Varien_Object $billing
  * @param Varien_Object $infoInstance
  * @return Eway_Rapid31_Model_Request_Token
  */
 public function createNewToken(Varien_Object $billing, Varien_Object $infoInstance)
 {
     // Empty Varien_Object's data
     $this->unsetData();
     $customerParam = Mage::getModel('ewayrapid/field_customer');
     $customerParam->setTitle($billing->getPrefix())->setFirstName($billing->getFirstname())->setLastName($billing->getLastname())->setCompanyName($billing->getCompany())->setJobDescription($billing->getJobDescription())->setStreet1($billing->getStreet1())->setStreet2($billing->getStreet2())->setCity($billing->getCity())->setState($billing->getRegion())->setPostalCode($billing->getPostcode())->setCountry(strtolower($billing->getCountryModel()->getIso2Code()))->setEmail($billing->getEmail())->setPhone($billing->getTelephone())->setMobile($billing->getMobile())->setComments('')->setFax($billing->getFax())->setUrl('');
     $cardDetails = Mage::getModel('ewayrapid/field_cardDetails');
     $cardDetails->setName($infoInstance->getCcOwner())->setNumber($infoInstance->getCcNumber())->setExpiryMonth($infoInstance->getCcExpMonth())->setExpiryYear($infoInstance->getCcExpYear())->setCVN($infoInstance->getCcCid())->setStartMonth($infoInstance->getStartMonth())->setStartYear($infoInstance->getStartYear())->setIssueNumber($infoInstance->getIssueNumber());
     $customerParam->setCardDetails($cardDetails);
     $this->setCustomer($customerParam);
     $response = $this->_doRapidAPI('Customer');
     if ($response->isSuccess()) {
         $customerReturn = $response->getCustomer();
         $cardDetails = $customerReturn['CardDetails'];
         unset($customerReturn['CardDetails']);
         $customerReturn['RegionId'] = !$billing->getRegion() && $billing->getRegionId() ? $billing->getRegionId() : '';
         $tokenInfo = array('Token' => $response->getTokenCustomerID(), 'Card' => substr_replace($cardDetails['Number'], '******', 6, 6), 'Owner' => $infoInstance->getCcOwner(), 'ExpMonth' => $infoInstance->getCcExpMonth(), 'ExpYear' => $infoInstance->getCcExpYear(), 'Type' => $infoInstance->getCcType(), 'Address' => Mage::getModel('ewayrapid/field_customer')->addData($customerReturn));
         Mage::helper('ewayrapid/customer')->addToken($tokenInfo);
         return $this;
     } else {
         Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while creating new token. Please try again. (Error message: %s)', $response->getMessage()));
     }
 }