Skip to content

Instantly share code, notes, and snippets.

@razbakov
Created February 24, 2016 12:10
Show Gist options
  • Save razbakov/8372d7e8ae920e8ef098 to your computer and use it in GitHub Desktop.
Save razbakov/8372d7e8ae920e8ef098 to your computer and use it in GitHub Desktop.
<?php
/**
*
*
* @category Kirchbergerknorr
* @package Kirchbergerknorr_OrderProcessor
* @author Aleksey Razbakov <[email protected]>
* @copyright Copyright (c) 2016 kirchbergerknorr GmbH (http://www.kirchbergerknorr.de)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
class Kirchbergerknorr_OrderProcessor_Model_AdyenPayment_Adyen_Data_PaymentRequest
extends Adyen_Payment_Model_Adyen_Data_PaymentRequest
{
public function reauthorize(
Varien_Object $payment,
$amount,
$merchantAccount = null,
$recurringDetailReference = null
) {
$order = $payment->getOrder();
$incrementId = $order->getIncrementId();
$orderCurrencyCode = $order->getOrderCurrencyCode();
// override amount because this amount uses the right currency
$amount = $order->getGrandTotal();
$this->selectedRecurringDetailReference = $recurringDetailReference;
$this->shopperInteraction = "ContAuth";
$this->recurring = new Adyen_Payment_Model_Adyen_Data_Recurring();
$this->recurring->contract = "RECURRING";
//shopper data
$customerEmail = $order->getCustomerEmail();
$this->shopperEmail = $customerEmail;
$customerId = $order->getCustomerId();
if ($customerId) {
$customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
$customerId = $customer->getData('adyen_customer_ref')
?: $customer->getData('increment_id')
?: $customerId;
}
$realOrderId = $order->getRealOrderId();
$this->shopperReference = (!empty($customerId)) ? $customerId : self::GUEST_ID . $realOrderId;
$this->amount->currency = $orderCurrencyCode;
$this->amount->value = Mage::helper('adyen')->formatAmount($amount, $orderCurrencyCode);
$this->reference = $incrementId;
$this->merchantAccount = $merchantAccount;
return $this;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment