Restore magenta transfer after payment denial

I am creating a purple payment extension that does the following:

When a user clicks on a check on the seller’s website, he is redirected to the website (for example, paypal), where he enters his payment information. If the payment method fails, the user is redirected to the seller’s website.

However, the quote seems to be inactive.

What are the features that allow the end user to reuse his quote?

A few possibilities:

  • Duplicate quotes if the user returns.
  • Get a quote and set it to active so that it shows again

Here is the code that I use in my payment model:

To initialize a payment method before pending_payment

/**
 * Instantiate state to pending_payment
 * @param
 * @param
 */
public function initialize($paymentAction, $stateObject)
{
    $state = Mage_Sales_Model_Order::STATE_PENDING_PAYMENT;
    $stateObject->setState($state);
    $stateObject->setStatus(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT);
    $stateObject->setIsNotified(false);
}

To redirect to a payment method (URL will be redirected to the remote host)

/**
 * Checkout redirect URL getter for onepage checkout
 *
 * @see Mage_Checkout_OnepageController::savePaymentAction()
 * @see Mage_Sales_Model_Quote_Payment::getOrderPlaceRedirectUrl()
 * @return string
 */

public function getOrderPlaceRedirectUrl()
{
    return Mage::getUrl('pay/payment/redirect');
}

url/pay/payment/fail ( , , - ).

+4
1

, ( : Paypal, Authorizenet, Stripe)

( registerCancellation), quote, setIsActive 1 ReservedOrderId.

public function cancelAction()
{
    $session = Mage::getSingleton('checkout/session');
    if ($session->getLastRealOrderId())
    {
        $order = Mage::getModel('sales/order')->loadByIncrementId($session->getLastRealOrderId());
        if ($order->getId())
        {
            //Cancel order
            if ($order->getState() != Mage_Sales_Model_Order::STATE_CANCELED)
            {
                $order->registerCancellation("Canceled by Payment Provider")->save();
            }
            $quote = Mage::getModel('sales/quote')
                ->load($order->getQuoteId());
            //Return quote
            if ($quote->getId())
            {
                $quote->setIsActive(1)
                    ->setReservedOrderId(NULL)
                    ->save();
                $session->replaceQuote($quote);
            }

            //Unset data
            $session->unsLastRealOrderId();
        }
    }

    return $this->getResponse()->setRedirect( Mage::getUrl('checkout/onepage'));
}
+6

All Articles