/** * @param Adyen_Payment_Model_Billing_Agreement $billingAgreement * @param Mage_Core_Model_Store $store * * @return bool */ protected function _createPaymentMethodFromBA(Adyen_Payment_Model_Billing_Agreement $billingAgreement, Mage_Core_Model_Store $store) { $methodInstance = $billingAgreement->getPaymentMethodInstance(); if (!$methodInstance || !$methodInstance->getConfigData('active', $store)) { return false; } $methodNewCode = 'adyen_oneclick_' . $billingAgreement->getReferenceId(); $methodData = array('model' => 'adyen/adyen_oneclick') + $billingAgreement->getOneClickData() + Mage::getStoreConfig('payment/adyen_oneclick', $store); foreach ($methodData as $key => $value) { $store->setConfig('payment/' . $methodNewCode . '/' . $key, $value); } return true; }
/** * @param Adyen_Payment_Model_Billing_Agreement $billingAgreement * @param array $data * * @return $this */ public function parseRecurringContractData(Adyen_Payment_Model_Billing_Agreement $billingAgreement, array $data) { $billingAgreement->setMethodCode($this->getCode())->setReferenceId($data['recurringDetailReference'])->setCreatedAt($data['creationDate']); $creationDate = str_replace(' ', '-', $data['creationDate']); $billingAgreement->setCreatedAt($creationDate); //Billing agreement SEPA if (isset($data['bank_iban'])) { $billingAgreement->setAgreementLabel(Mage::helper('adyen')->__('%s, %s', $data['bank_iban'], $data['bank_ownerName'])); } // Billing agreement is CC if (isset($data['card_number'])) { $ccType = $data['variant']; $ccTypes = Mage::helper('adyen')->getCcTypesAltData(); if (isset($ccTypes[$ccType])) { $ccType = $ccTypes[$ccType]['name']; } $label = Mage::helper('adyen')->__('%s, %s, **** %s', $ccType, $data['card_holderName'], $data['card_number'], $data['card_expiryMonth'], $data['card_expiryYear']); $billingAgreement->setAgreementLabel($label); } if ($data['variant'] == 'paypal') { $label = Mage::helper('adyen')->__('PayPal %s', $data['lastKnownShopperEmail']); $billingAgreement->setAgreementLabel($label); } return $this; }
/** * The additional info and cc type of a quote payment are not updated when * selecting another payment method while editing a subscription or subscription quote, * but they have to be updated for the payment method to be valid * * @param Mage_Sales_Model_Quote $quote * @param Adyen_Payment_Model_Billing_Agreement $billingAgreement * @return Mage_Sales_Model_Quote * @throws Exception */ public function updateQuotePayment(Mage_Sales_Model_Quote $quote, Adyen_Payment_Model_Billing_Agreement $billingAgreement) { Mage::dispatchEvent('adyen_subscription_quote_updatequotepayment_before', array('billingAgreement' => $billingAgreement, 'quote' => $quote)); $subscriptionDetailReference = str_replace('adyen_oneclick_', '', $quote->getPayment()->getData('method')); $quote->getPayment()->setAdditionalInformation('recurring_detail_reference', $subscriptionDetailReference); $agreementData = $billingAgreement->getAgreementData(); if (isset($agreementData['variant'])) { $quote->getPayment()->setCcType($agreementData['variant']); } else { $quote->getPayment()->setCcType(null); } $quote->getPayment()->save(); Mage::dispatchEvent('adyen_subscription_quote_updatequotepayment_after', array('billingAgreement' => $billingAgreement, 'quote' => $quote)); return $quote; }