Hi everybody.
I'm developing a custom payment module for Magento CE 1.9 and I can't figure out how to get my form to show on the Checkout page. This is not showing nothing about my plugin in bitnami server but in my machine(Local) its work.
Any help would very much welcome.
Here is my code:
config.xml:
<?xml version="1.0"?> <config> <modules> <Efika_GreenPay> <version>2.0.1</version> </Efika_GreenPay> </modules> <global> <models> <GreenPay> <class>Efika_GreenPay_Model</class> </GreenPay> </models> <helpers> <GreenPay> <class>Efika_GreenPay_Helper</class> </GreenPay> </helpers> <blocks> <GreenPay> <class>Efika_GreenPay_Block</class> </GreenPay> </blocks> </global> <default> <payment> <GreenPay> <model>GreenPay/standard</model> <active>1</active> <order_status>pending</order_status> <title>CUSTOM CARD</title> <payment_action>sale</payment_action> <submit_url>https://someurl.com</submit_url> <merchant_id>Insert merchant id</merchant_id> <allowspecific>0</allowspecific> <sort_order>1</sort_order> </GreenPay> </payment> </default> <frontend> <routers> <routeurfrontend> <use>standard</use> <args> <module>Efika_GreenPay</module> <frontName>greenpay</frontName> </args> </routeurfrontend> </routers> <layout> <updates> <GreenPay module="Efika_GreenPay"> <file>Efika_GreenPay.xml</file> </GreenPay> </updates> </layout> </frontend> </config>
system.xml:
<?xml version="1.0"?> <config> <sections> <payment> <groups> <GreenPay translate="label comment" module="paypal"> <label>GreenPay</label> <frontend_type>text</frontend_type> <sort_order>0</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> <fields> <active translate="label"> <label>Enabled</label> <frontend_type>select</frontend_type> <source_model>adminhtml/system_config_source_yesno</source_model> <sort_order>10</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> </active> <title translate="label"> <label>Title</label> <frontend_type>text</frontend_type> <sort_order>20</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> </title> <order_status translate="label"> <label>New Order Status</label> <frontend_type>select</frontend_type> <source_model>adminhtml/system_config_source_order_status</source_model> <sort_order>50</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> </order_status> <submit_url> <label>Gateway URL</label> <frontend_type>text</frontend_type> <sort_order>58</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> </submit_url> <form_url> <label>Form URL</label> <frontend_type>text</frontend_type> <sort_order>58</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> </form_url> <merchant_id> <label>Merchant ID</label> <frontend_type>text</frontend_type> <sort_order>59</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> </merchant_id> <terminal_id> <label>Terminal ID</label> <frontend_type>text</frontend_type> <sort_order>59</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> </terminal_id> <secret> <label>Secret</label> <frontend_type>text</frontend_type> <sort_order>61</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> </secret> <pkey> <label>Key</label> <frontend_type>textarea</frontend_type> <sort_order>62</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> </pkey> <allowspecific translate="label"> <label>Payment Applicable From</label> <frontend_type>select</frontend_type> <sort_order>61</sort_order> <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> </allowspecific> <specificcountry translate="label"> <label>Countries Payment Applicable From</label> <frontend_type>multiselect</frontend_type> <sort_order>70</sort_order> <source_model>adminhtml/system_config_source_country</source_model> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> <depends> <allowspecific>1</allowspecific> </depends> </specificcountry> <sort_order translate="label"> <label>Sort Order</label> <frontend_type>text</frontend_type> </sort_order> <sort_order>100</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> </fields> </GreenPay> </groups> </payment> </sections> </config>
controller.php
<?php class Efika_GreenPay_IndexController extends Mage_Core_Controller_Front_Action { public function checkoutAction() { echo "<script type='text/javascript'> location.href='" . Mage::getStoreConfig('payment/GreenPay/form_url') . "/" . $this->getRequest()->getParams()["chk"] . "'; </script>"; //print_r(Mage::getStoreConfig('payment/GreenPay/submit_url')); } public function closeOrderAction() { //https://www.magestore.com/manage-magento-online-store/magento-order-status-and-magento-order-state if ($this->getRequest()->getParams()["response"] == "cancel") { // $response = json_decode( base64_decode( $this->getRequest()->getParams()["response"]), true); if (Mage::getSingleton('checkout/session')->getLastRealOrderId()) { $orderid = Mage::getSingleton('checkout/session')->getLastOrderId(); $order = Mage::getModel('sales/order')->load($orderid); $order->setData('state', "canceled"); $order->setStatus("canceled"); //$order->salesOrderInfo('payment_id','null'); $order->setData('Authorization', "Authorization : null"); $history = $order->addStatusHistoryComment('Authorization: null', false); $history->setIsCustomerNotified(false); $order->save(); if ($lastQuoteId = Mage::getSingleton('checkout/session')->getLastQuoteId()) { $quote = Mage::getModel('sales/quote')->load($lastQuoteId); $quote->setIsActive(false)->save(); } Mage::getSingleton('core/session')->addNotice("<strong>Cancelado.</strong> Usted ha cancelado el pago ."); $this->_redirect('checkout/cart'); //Redirect to cart return; } } else { $response = json_decode(base64_decode($this->getRequest()->getParams()["response"]), true); $dataToSign = 'status:' . $response["status"] . ',orderId:' . $response["orderId"] . ''; $signatureV = openssl_verify($dataToSign, hex2bin($response["_signature"]), openssl_get_publickey(Mage::getStoreConfig('payment/GreenPay/pkey')), OPENSSL_ALGO_SHA256); if ($signatureV) { if ($response["status"] == 200) { $orderid = Mage::getSingleton('checkout/session')->getLastOrderId(); $order = Mage::getModel('sales/order')->loadByIncrementId($response["orderId"]); $order->setData('state', "complete"); $order->setStatus("complete"); $order->setData('Authorization', 'Authorization:' . $response["authorization"]); $history = $order->addStatusHistoryComment('Authorization:' . $response["authorization"], false); $history->setIsCustomerNotified(false); $order->save(); Mage_Core_Controller_Varien_Action::_redirect("checkout/onepage/success"); } elseif ($response["status"] == 500) { $orderid = Mage::getSingleton('checkout/session')->getLastOrderId(); $order = Mage::getModel('sales/order')->loadByIncrementId($response["orderId"]);; $order->setData('state', "canceled"); $order->setStatus("canceled"); $order->setData('Authorization', 'Authorization : null'); $history = $order->addStatusHistoryComment('Authorization : null', false); $history->setIsCustomerNotified(false); $order->save(); Mage::getSingleton('core/session')->addNotice("<strong>Orden cancelada.</strong>"); // 'Error:'.$response["reserved_private4"] +"." $this->_redirect('checkout/cart'); //Redirect to cart } else { if (Mage::getSingleton('checkout/session')->getLastRealOrderId()) { $orderid = Mage::getSingleton('checkout/session')->getLastOrderId(); $order = Mage::getModel('sales/order')->load($orderid); $order->setData('state', "canceled"); $order->setStatus("canceled"); //$order->salesOrderInfo('payment_id','null'); $order->setData('Authorization', "Authorization : null"); $history = $order->addStatusHistoryComment('Authorization: null', false); $history->setIsCustomerNotified(false); $order->save(); if ($lastQuoteId = Mage::getSingleton('checkout/session')->getLastQuoteId()) { $quote = Mage::getModel('sales/quote')->load($lastQuoteId); $quote->setIsActive(false)->save(); } Mage::getSingleton('core/session')->addError("<strong>Error procesando pago.</strong> Por favor validar con el banco emisor de su tarjeta antes de volver a intentar."); $this->_redirect('checkout/cart'); //Redirect to cart return; } } } else { Mage::getSingleton('core/session')->addError("Firma alterada en el proceso, posible intento de intrusion ilegal. Su IP ha sido registrada."); } } } }
model.php
<?php class Efika_GreenPay_Model_Standard extends Mage_Payment_Model_Method_Abstract { protected $_code = 'GreenPay'; protected $_isInitializeNeeded = true; protected $_canUseInternal = false; protected $_canUseForMultishipping = false; /** * Return Order place redirect url * * @return string */ public function getOrderPlaceRedirectUrl() { $chargerObj = Mage::helper('checkout')->getQuote()->getData(); $rt4 = "1234-5678901-abcded12345"; $payload = json_encode(array( "secret" => Mage::getStoreConfig('payment/GreenPay/secret'), "merchantId" => Mage::getStoreConfig('payment/GreenPay/merchant_id'), "terminal" => Mage::getStoreConfig('payment/GreenPay/terminal_id'), "amount" => $chargerObj["grand_total"], "currency" => $chargerObj["quote_currency_code"], "desciption" => "d", "orderReference" => $chargerObj["reserved_order_id"] )); // echo $payload; $ch = curl_init(Mage::getStoreConfig('payment/GreenPay/submit_url')); //attach encoded JSON string to the POST fields curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); //set the content type to application/json curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); //return response instead of outputting curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //execute the POST request $result = curl_exec($ch); curl_close($ch); $obj = JSON_DECODE($result, true); return Mage::getUrl('greenpay/index/checkout/chk/' . $obj["session"], array('_secure' => true)); } }
Thanks in advance for helping.
Solved! Go to Solution.
You need to do following things.
1. Remove spaces between line from your system.xml and config.xml file.
2. In to your bitnami server, check the log file or report for the error description.
Thank you very much.
That's help me. However the main error was that the folder model and the file inside it wasn't in capital letter.
(y)
You need to do following things.
1. Remove spaces between line from your system.xml and config.xml file.
2. In to your bitnami server, check the log file or report for the error description.