/** * Import payment data to billing agreement * * $payment->getBillingAgreementData() contains array with following structure : * [billing_agreement_id] => string * [method_code] => string * * @param Mage_Sales_Model_Order_Payment $payment * @return Mage_Sales_Model_Billing_Agreement */ public function importOrderPayment(Mage_Sales_Model_Order_Payment $payment) { $baData = $payment->getBillingAgreementData(); $this->_paymentMethodInstance = isset($baData['method_code']) ? Mage::helper('payment')->getMethodInstance($baData['method_code']) : $payment->getMethodInstance(); if ($this->_paymentMethodInstance) { $this->_paymentMethodInstance->setStore($payment->getMethodInstance()->getStore()); $this->setCustomerId($payment->getOrder()->getCustomerId())->setMethodCode($this->_paymentMethodInstance->getCode())->setReferenceId($baData['billing_agreement_id'])->setStatus(self::STATUS_ACTIVE); } return $this; }
/** * Build the request with necessary parameters for doAuthorisation() and doTransaction() * * @param Mage_Sales_Model_Order_Payment $payment * @param $amount * @return Eway_Rapid31_Model_Request_Direct */ protected function _buildRequest(Mage_Sales_Model_Order_Payment $payment, $amount) { // Empty Varien_Object's data $this->unsetData(); $methodInstance = $payment->getMethodInstance(); $infoInstance = $methodInstance->getInfoInstance(); $order = $payment->getOrder(); $billing = $order->getBillingAddress(); $shipping = $order->getShippingAddress(); $this->setCustomerIP(Mage::helper('core/http')->getRemoteAddr()); if (Mage::helper('ewayrapid')->isBackendOrder()) { $this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_MOTO); } else { $this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_PURCHASE); } $this->setDeviceID('Magento ' . Mage::getEdition() . ' ' . Mage::getVersion()); $this->setShippingMethod('Other'); $paymentParam = Mage::getModel('ewayrapid/field_payment'); $paymentParam->setTotalAmount($amount)->setCurrencyCode($order->getBaseCurrencyCode()); $this->setPayment($paymentParam); $customerParam = Mage::getModel('ewayrapid/field_customer'); $customerParam->setTitle($billing->getPrefix())->setFirstName($billing->getFirstname())->setLastName($billing->getLastname())->setCompanyName($billing->getCompany())->setJobDescription('')->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('')->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()); $customerParam->setCardDetails($cardDetails); $this->setCustomer($customerParam); $shippingParam = Mage::getModel('ewayrapid/field_shippingAddress'); $shippingParam->setFirstName($shipping->getFirstname())->setLastName($shipping->getLastname())->setStreet1($shipping->getStreet1())->setStreet2($shipping->getStreet2())->setCity($shipping->getCity())->setState($shipping->getRegion())->setPostalCode($shipping->getPostcode())->setCountry(strtolower($shipping->getCountryModel()->getIso2Code()))->setEmail($shipping->getEmail())->setPhone($shipping->getTelephone())->setFax($shipping->getFax()); $this->setShippingAddress($shippingParam); if ($methodInstance->getConfigData('transfer_cart_items')) { $orderItems = $order->getAllVisibleItems(); $lineItems = array(); foreach ($orderItems as $orderItem) { /* @var Mage_Sales_Model_Order_Item $orderItem */ $lineItem = Mage::getModel('ewayrapid/field_lineItem'); $lineItem->setSKU($orderItem->getSku()); $lineItem->setDescription(substr($orderItem->getName(), 0, 26)); $lineItem->setQuantity($orderItem->getQtyOrdered()); $lineItem->setUnitCost(round($orderItem->getBasePrice() * 100)); $lineItem->setTax(round($orderItem->getBaseTaxAmount() * 100)); $lineItem->setTotal(round($orderItem->getBaseRowTotalInclTax() * 100)); $lineItems[] = $lineItem; } $this->setItems($lineItems); } return $this; }
/** * @param Mage_Sales_Model_Order_Payment $payment */ protected function init(Mage_Sales_Model_Order_Payment $payment) { $this->setOrder($payment->getOrder()); $this->setPaymentMethod($payment->getMethodInstance()); }
/** * Encrypt the payment data for the given payment model * * @param Mage_Sales_Model_Quote_Payment|Mage_Sales_Model_Order_Payment $payment Payment Model */ protected function _encryptPaymentData($payment) { try { $method = $payment->getMethodInstance(); } catch (Exception $e) { return $this; } if ($method instanceof Itabs_Debit_Model_Debit) { $info = $method->getInfoInstance(); if ($payment->getData('debit_swift') != '') { $payment->setData('debit_swift', $info->encrypt($payment->getData('debit_swift'))); } if ($payment->getData('debit_iban') != '') { $payment->setData('debit_iban', $info->encrypt($payment->getData('debit_iban'))); } } }
protected function _buildRequest(Mage_Sales_Model_Order_Payment $payment, $amount) { // Empty Varien_Object's data $this->unsetData(); // in case recurring profile, $methodInstance is not exist, and $payment->getIsRecurring() is used if (!$payment->getIsRecurring()) { $methodInstance = $payment->getMethodInstance(); $infoInstance = $methodInstance->getInfoInstance(); Mage::helper('ewayrapid')->unserializeInfoInstace($infoInstance); } $order = $payment->getOrder(); $shipping = $order->getShippingAddress(); $this->setCustomerIP(Mage::helper('core/http')->getRemoteAddr()); if (Mage::helper('ewayrapid')->isBackendOrder()) { $this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_MOTO); } elseif ($payment->getIsRecurring()) { $this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_RECURRING); } else { $this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_PURCHASE); } $this->setDeviceID('Magento ' . Mage::getEdition() . ' ' . Mage::getVersion()); $this->setShippingMethod('Other'); $paymentParam = Mage::getModel('ewayrapid/field_payment'); $paymentParam->setTotalAmount($amount)->setCurrencyCode($order->getBaseCurrencyCode()); $this->setPayment($paymentParam); $customerParam = Mage::getModel('ewayrapid/field_customer'); $customerTokenId = null; /** get $customerTokenId if product is recurring profile */ if ($payment->getIsRecurring()) { /** @todo save customer id and tokent id into payment when place order */ $customer = Mage::getModel('customer/customer')->load($payment->getCustomerId()); $customerHelper = Mage::helper('ewayrapid/customer'); $customerHelper->setCurrentCustomer($customer); $customerTokenId = $customerHelper->getCustomerTokenId($payment->getTokenId()); } else { /** get $customerTokenId if product is normal item */ if ($infoInstance->getSavedToken()) { $customerHelper = Mage::helper('ewayrapid/customer'); $customerTokenId = $customerHelper->getCustomerTokenId($infoInstance->getSavedToken()); } else { Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while making the transaction: Token info does not exist.')); } } if ($customerTokenId) { $customerParam->setTokenCustomerID($customerTokenId); if ($this->getTransactionType() == Eway_Rapid31_Model_Config::TRANSACTION_PURCHASE) { $cardDetails = Mage::getModel('ewayrapid/field_cardDetails'); $cardDetails->setCVN($infoInstance->getCcCid()); $customerParam->setCardDetails($cardDetails); } $this->setCustomer($customerParam); } else { Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while making the transaction: Token info does not exist.')); } $shippingParam = Mage::getModel('ewayrapid/field_shippingAddress'); $shippingParam->setFirstName($shipping->getFirstname())->setLastName($shipping->getLastname())->setStreet1($shipping->getStreet1())->setStreet2($shipping->getStreet2())->setCity($shipping->getCity())->setState($shipping->getRegion())->setPostalCode($shipping->getPostcode())->setCountry(strtolower($shipping->getCountryModel()->getIso2Code()))->setEmail($shipping->getEmail())->setPhone($shipping->getTelephone())->setFax($shipping->getFax()); $this->setShippingAddress($shippingParam); if (isset($methodInstance) && $methodInstance->getConfigData('transfer_cart_items') || $payment->getIsRecurring() || !$payment->getIsInitialFee()) { $orderItems = $order->getAllVisibleItems(); $lineItems = array(); foreach ($orderItems as $orderItem) { /* @var Mage_Sales_Model_Order_Item $orderItem */ $lineItem = Mage::getModel('ewayrapid/field_lineItem'); $lineItem->setSKU($orderItem->getSku()); $lineItem->setDescription(substr($orderItem->getName(), 0, 26)); $lineItem->setQuantity($orderItem->getQtyOrdered()); $lineItem->setUnitCost(round($orderItem->getBasePrice() * 100)); $lineItem->setTax(round($orderItem->getBaseTaxAmount() * 100)); $lineItem->setTotal(round($orderItem->getBaseRowTotalInclTax() * 100)); $lineItems[] = $lineItem; } $this->setItems($lineItems); } return $this; }
/** * Get HTML representation for transaction id for Payment Bridge methods * * @param Mage_Sales_Model_Order_Payment $payment * @param string $txnId * @return string */ public function getHtmlTransactionId(Mage_Sales_Model_Order_Payment $payment, $txnId) { $methodInstance = $payment->getMethodInstance(); $methodCode = method_exists($methodInstance, 'getOriginalCode') ? $methodInstance->getOriginalCode() : $methodInstance->getCode(); return Mage::helper('paypal')->getHtmlTransactionId($methodCode, $txnId); }
/** * Set Payment Transaction Information * * @param Mage_Sales_Model_Order_Payment $payment Sales Payment Model * @param array $params Request params * @param string $action Action (accept|cancel|decline|wait|exception) */ protected function setPaymentTransactionInformation(Mage_Sales_Model_Order_Payment $payment, $params, $action) { $payment->setTransactionId($params['PAYID']); $code = $payment->getMethodInstance()->getCode(); $isInline = false; /* In authorize mode we still have no authorization transaction for CC and DirectDebit payments, * so capture or cancel won't work. So we need to create a new authorization transaction for them * when a payment was accepted by Barclaycard * * In exception-case we create the authorization-transaction too because some exception-cases can turn into accepted */ if (('accept' === $action || 'exception' === $action) && in_array($code, array('ops_cc', 'ops_directDebit'))) { $payment->setIsTransactionClosed(false); $isInline = $this->isInlinePayment($payment); /* create authorization transaction for non-inline pms */ if (false === $isInline || (array_key_exists('HTML_ANSWER', $params) || 0 < strlen($payment->getAdditionalInformation('HTML_ANSWER')))) { $payment->addTransaction("authorization", null, true, $this->__("Process outgoing transaction")); } $payment->setLastTransId($params['PAYID']); } /* Barclaycard sends parameter HTML_ANSWER to trigger 3D secure redirection */ if (isset($params['HTML_ANSWER']) && 'ops_cc' == $code) { $payment->setAdditionalInformation('HTML_ANSWER', $params['HTML_ANSWER']); $payment->setIsTransactionPending(true); } $payment->setAdditionalInformation('paymentId', $params['PAYID']); $payment->setAdditionalInformation('status', $params['STATUS']); if (array_key_exists('ACCEPTANCE', $params) && 0 < strlen(trim($params['ACCEPTANCE']))) { $payment->setAdditionalInformation('acceptance', $params['ACCEPTANCE']); } if (array_key_exists('BRAND', $params) && 'ops_cc' == $code && 0 < strlen(trim($params['BRAND']))) { $payment->setAdditionalInformation('CC_BRAND', $params['BRAND']); } if (false === $isInline || array_key_exists('HTML_ANSWER', $params)) { $payment->setIsTransactionClosed(true); } $payment->setDataChanges(true); $payment->save(); }
/** * Set Payment Transaction Information * * @param Mage_Sales_Model_Order_Payment $payment Sales Payment Model * @param array $params Request params */ protected function setPaymentTransactionInformation($payment, $params) { $payment->setTransactionId($params['PAYID']); $code = $payment->getMethodInstance()->getCode(); if (in_array($code, array('postfinance_cc', 'postfinance_directDebit'))) { $payment->setIsTransactionClosed(false); $payment->addTransaction("authorization", null, true, $this->__("Process outgoing transaction")); $payment->setLastTransId($params['PAYID']); if (isset($params['HTML_ANSWER'])) { $payment->setAdditionalInformation('HTML_ANSWER', $params['HTML_ANSWER']); } } $payment->setAdditionalInformation('paymentId', $params['PAYID']); $payment->setAdditionalInformation('status', $params['STATUS']); $payment->setIsTransactionClosed(true); $payment->setDataChanges(true); $payment->save(); }
protected function canNotUseOrderId(Mage_Sales_Model_Order_Payment $payment) { $methodInstance = $payment->getMethodInstance(); return $methodInstance instanceof Netresearch_OPS_Model_Payment_Kwixo_Abstract || $methodInstance instanceof Netresearch_OPS_Model_Payment_DirectDebit || $methodInstance instanceof Netresearch_OPS_Model_Payment_Cc && $methodInstance->hasBrandAliasInterfaceSupport($payment); }
public function getMethodInstance() { $method = parent::getMethodInstance(); return $method->setStore($this->getOrder()->getStore()); }