Example #1
0
 /**
  * Instantiate state and set it to state object
  *
  * @param string $paymentAction
  * @param Varien_Object
  */
 public function initialize($paymentAction, $stateObject)
 {
     $payment = $this->getInfoInstance();
     $order = $payment->getOrder();
     parent::order($payment, $order->getBaseTotalDue());
 }
Example #2
0
 /**
  * Instantiate state and set it to state object
  *
  * @param string $paymentAction
  * @param Varien_Object
  */
 public function initialize($paymentAction, $stateObject)
 {
     $standard = Mage::getModel('mundipagg/standard');
     switch ($standard->getConfigData('payment_action')) {
         case 'order':
             $this->setCreditCardOperationEnum('AuthAndCapture');
             $paymentAction = $orderAction = 'order';
             break;
         case 'authorize':
             $this->setCreditCardOperationEnum('AuthOnly');
             $paymentAction = $orderAction = 'authorize';
             break;
         case 'authorize_capture':
             $this->setCreditCardOperationEnum('AuthAndCaptureWithDelay');
             $paymentAction = $orderAction = 'authorize_capture';
             break;
     }
     $payment = $this->getInfoInstance();
     $order = $payment->getOrder();
     switch ($paymentAction) {
         case Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE:
             parent::authorize($payment, $order->getBaseTotalDue());
             break;
         case Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE:
             parent::authorize($payment, $order->getBaseTotalDue());
             break;
         case $orderAction:
             parent::order($payment, $order->getBaseTotalDue());
             break;
         default:
             parent::order($payment, $order->getBaseTotalDue());
             break;
     }
 }
Example #3
0
 /**
  * Instantiate state and set it to state object
  *
  * @param string $paymentAction
  * @param Varien_Object
  */
 public function initialize($paymentAction, $stateObject)
 {
     $this->setCreditCardOperationEnum('AuthAndCapture');
     $payment = $this->getInfoInstance();
     $order = $payment->getOrder();
     parent::authorize($payment, $order->getBaseTotalDue());
 }
Example #4
0
 /**
  * Manage Order Request: capture / void / refund
  **/
 public function manageOrderRequest($data, Uecommerce_Mundipagg_Model_Standard $standard)
 {
     try {
         // Get Webservice URL
         $url = $standard->getURL() . '/' . $data['ManageOrderOperationEnum'];
         unset($data['ManageOrderOperationEnum']);
         // Get store key
         $key = $standard->getMerchantKey();
         if ($standard->getDebug() == 1) {
             Mage::log('Uecommerce_Mundipagg: ' . Mage::helper('mundipagg')->getExtensionVersion(), null, 'Uecommerce_Mundipagg.log');
             Mage::log(print_r($data, 1), null, 'Uecommerce_Mundipagg.log');
         }
         $dataToPost = json_encode($data);
         // Send payment data to MundiPagg
         $ch = curl_init();
         // Header
         curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json', 'MerchantKey: ' . $key . ''));
         // Set the url, number of POST vars, POST data
         curl_setopt($ch, CURLOPT_URL, $url);
         curl_setopt($ch, CURLOPT_POSTFIELDS, $dataToPost);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         // Execute post
         $_response = curl_exec($ch);
         // Close connection
         curl_close($ch);
         if ($standard->getDebug() == 1) {
             Mage::log('Uecommerce_Mundipagg: ' . Mage::helper('mundipagg')->getExtensionVersion(), null, 'Uecommerce_Mundipagg.log');
             Mage::log(print_r($_response, 1), null, 'Uecommerce_Mundipagg.log');
         }
         // Return
         return array('result' => simplexml_load_string($_response));
     } catch (Exception $e) {
         //Redirect to Cancel page
         Mage::getSingleton('checkout/session')->setApprovalRequestSuccess(false);
         //Log error
         Mage::logException($e);
         //Mail error
         $this->mailError(print_r($e->getMessage(), 1));
         // Throw Exception
         Mage::throwException(Mage::helper('mundipagg')->__('Payment Error'));
     }
 }