This is the next article of Magento series and I am going to cover the install of basic custom payment option in admin panel.In Previous article,we have learned Magento Extension Configuration
Before we have defined extension into the community folder the code pool so Magento code resides into app/code/community.
So, Let’s dive into the code for creating custom extension of Magento for payment gateway
First of all, go to PaymentMethod/Module folder and create an etc folder and in this folder create a config.XML file. Place the following code into your config file.
0.1.2 PaymentMethod_PaymentMethod_Model PaymentMethod_PaymentMethod_Helper PaymentMethod_PaymentMethod PaymentMethod_PaymentMethod_Block /paymentmethod/processing PaymentMethod_PaymentMethod paymentmethod paymentmethod.xml paymentmethod/paymentmethod PaymentMethod 0 processing authorize_capture 0
Next, is about system configuration so create system.xml and place the following code into it.
304 1 1 0 select adminhtml/system_config_source_yesno 1 1 1 0 This is what the customers will see as the name of the payment option text 2 1 1 0 text 3 1 1 0 select paymentmethod/source_paymentmethodServers 5 1 1 0 text 7 1 1 0 select adminhtml/system_config_source_order_status 8 1 1 0
Now, create model folder into your community/PaymentMethod/PaymentMethod directory and create file Paymentmethod.php
class PaymentMethod_PaymentMethod_Model_Paymentmethod extends Mage_Payment_Model_Method_Abstract
{
protected $_code = 'paymentmethod';
protected $_canCapture = true;
protected $_canReviewPayment = false;
protected $_canAuthorize = true;
protected $_formBlockType = 'paymentmethod/form';
protected $_infoBlockType = 'paymentmethod/info';
protected $_paymentMethod = 'paymentmethod';
// Order specific fields
protected $_order_status;
public function capture(Varien_Object $payment, $amount)
{
$payment->setStatus(self::STATUS_APPROVED)
->setTransactionId($this->getTransactionId())
->setIsTransactionClosed(0);
return $this;
}
}
Here in model folder create one more folder Model/Source and creat file PaymentMethodServers.php
class PaymentMethod_PaymentMethod_Model_Source_PaymentMethodServers
{
const SERVER_TEST = 'Test';
const SERVER_LIVE = 'Live';
public function toOptionArray()
{
return array(
array(
'value' => self::SERVER_LIVE,
'label' => Mage::helper('paygate')->__('Live')
),
array(
'value' => self::SERVER_TEST,
'label' => Mage::helper('paygate')->__('Test')
),
);
}
}
Create helper folder into PaymentMethod/PaymentMethod and in that Data.php file
class PaymentMethod_PaymentMethod_Helper_Data extends Mage_Payment_Helper_Data
{
}
Thanks for reading and feel free to share your thoughts! Don’t Forget to Follow us on Twitter or Subscribe us to Get the Latest Updates.






Comments (1)