2

I'm working on changing various "order states" based on their statuses in magento when they come in via kount Ens.php. I've had some success with a couple of them but I can't seem to figure out the last three.

  1. When approved manually the state code needs to change to processing instead of payment_review.
  2. When declined maually the state code needs to change to holded instead of payment_review.
  3. When auto declined the state code needs to changed to canceled instead of payment_review.

Here's what I have currently:

/**
 * Approve an order from Kount
 *
 * @param \Mage_Sales_Model_Order $order
 *
 * @return bool
 */
protected function _approveOrder(Mage_Sales_Model_Order $order)
{
    // Ensure the status has not moved from it's payment review state
    if ($order->getStatus() == Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW) {

        // Inform the system that this update is occurring from an ENS update
        Mage::register('kount_ens_update', true);

        try {
            $order->setStatus("fraud_cleared");
            $order->save();
        } catch (Exception $e) {
            Gene_Braintree_Model_Debug::log('Accept Kount transaction failed to be accepted in Magento: ' . $e->getMessage());
            Gene_Braintree_Model_Debug::log($e);
            return false;
        }

        Mage::unregister('kount_ens_update');
        $order->addStatusHistoryComment('Order approved through Kount.')->save();
        return true;
    }

    return false;
}

/**
 * Decline an order in Magento
 *
 * If the payment is only voidable, we void the invoice cancelling the order. If the payment has settled we create
 * a credit memo and close the order that way.
 *
 * @param \Mage_Sales_Model_Order $order
 *
 * @return bool
 */
protected function _declineOrder(Mage_Sales_Model_Order $order)
{
    // Ensure the status has not moved from it's payment review state
    if ($order->getStatus() == Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW) {

        // Inform the system that this update is occurring from an ENS update
        Mage::register('kount_ens_update', true);
        try {
            $order->setState(Mage_Sales_Model_Order::STATE_HOLDED, "suspected_fraud_after_review");
            $order->save();
        } catch (Exception $e) {
            Gene_Braintree_Model_Debug::log('Declined Kount transaction failed to be declined in Magento: ' . $e->getMessage());
            Gene_Braintree_Model_Debug::log($e);
            return false;
        }

    }

    return false;
}

Here's some things i'm working on to fix:

try {
                $order->setStatus("fraud_cleared")
                    ->setState(Mage_Sales_Model_Order::STATE_PROCESSING)
                    ->save();
            } catch (Exception $e) {
                Gene_Braintree_Model_Debug::log('Accept Kount transaction failed to be accepted in Magento: ' . $e->getMessage());
                Gene_Braintree_Model_Debug::log($e);
                return false;
            }

enter image description here

1
  • Have you gone through all the error logs including system.log, execption.log and braintree.log ensuring there are no errors or restrictions
  • whether whitelisted all IP's and cleared all rules with our firewall to ensure there is nothing blocking us there.
  • try using the IP instead of the URL for the ens URL
  • Create new API keys & Check user permissions

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.