Skip to content

Commit

Permalink
Default to Payment Accepted
Browse files Browse the repository at this point in the history
  • Loading branch information
ibrahimlawal committed Sep 9, 2016
1 parent f677429 commit 9481f93
Showing 1 changed file with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
* @license https://raw.githubusercontent.com/PaystackHQ/paystack-magento/master/LICENSE MIT License (MIT)
*/

class Paystack_Inline_PaymentController extends Mage_Core_Controller_Front_Action
class Paystack_Inline_PaymentController extends Mage_Core_Controller_Front_Action
{
public function cancelAction()
public function cancelAction()
{
Mage::getSingleton('core/session')->addError(
Mage::helper('paystack_inline')->__("Payment cancelled."));

$session = Mage::getSingleton('checkout/session');
if ($session->getLastRealOrderId())
{
Expand Down Expand Up @@ -48,26 +48,26 @@ public function cancelAction()
return $this->getResponse()->setRedirect( Mage::getUrl('checkout/onepage'));
}

public function popAction()
public function popAction()
{
$this->loadLayout();
$block = $this->getLayout()->createBlock('Mage_Core_Block_Template','paystack_inline',array('template' => 'paystack/pop.phtml'));
$this->getLayout()->getBlock('content')->append($block);
$this->renderLayout();
}

public function responseAction()
public function responseAction()
{
$success = false;

$orderId = $this->getRequest()->get("orderId");
$trxref = $this->getRequest()->get("trxref");

// Both are required
if(!$orderId || !$trxref){
return;
}

// trxref must start with orderId by design
if(strpos($trxref, $orderId) !== 0){
return;
Expand All @@ -92,7 +92,7 @@ public function responseAction()
}
elseif($transactionStatus->status == 'success')
{
$order->setState(Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW, true, 'Payment Success.');
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, 'Payment Success.');
$order->save();

Mage::getSingleton('checkout/session')->unsQuoteId();
Expand All @@ -106,13 +106,13 @@ public function responseAction()

Mage::getSingleton('checkout/session')->unsQuoteId();
}


if(!$success){
Mage::getSingleton('core/session')->addError(
Mage::helper('paystack_inline')->__("There was an error processing your payment. Please try again."));
Mage_Core_Controller_Varien_Action::_redirect('checkout/cart');
}

}
}
}

0 comments on commit 9481f93

Please sign in to comment.