I am creating a custom payment module using Paypal API(Don't want to use any Magento Paypal Module). I have 2 question while developing the custom module. Please help me to solve it.

  1. My logic is as follows: From magento default cart when a user click check out it is redirecting to my custom module for proceeding to payment using Paypal. Now after successful payment I need increment id to insert the order record in the order table . But how can I get the new increment id for the new order? This is my first question.
  2. After payment, magento storing the payment details in sales_order_payment table. It is storing the payment type in the 'method' field of the table, like ccsave,checkmo. These name are coming from the core_config_data table(which are storing from config.xml file of the module). But I cannot add my module to the config table(I wrote payment details in config.xml file). That's why while I add my custom payment type to the 'method' field of sales_order_payment table, It is not detecting my payment module. I am adding my config.xml file content here:


                <title>CUSTOM CARD</title>

Please help me solving this 2 issues.


for first one you just for getting the order id

$orderId = Mage::getSingleton('checkout/session')->getLastOrderId();

for second part

            <title>CUSTOM CARD</title>

model code code

    class Spacename_Moduelname_Model_Standard extends Mage_Payment_Model_Method_Abstract

protected $_code = 'youpaymentmodulecode'; // this code will be saved in core_config_data

protected $_isInitializeNeeded      = true;
protected $_canUseCheckout = true;
protected $_canUseInternal          = false;
protected $_canUseForMultishipping  = false;

* Return Order place redirect url
* @return string
public function getOrderPlaceRedirectUrl()
//when you click on place order you will be redirected on this url, if you don't want this action remove this method
return Mage::getUrl('redirectpath', array('_secure' => true));
public function isAvailable($quote = NULL)
    return true;

| improve this answer | |
  • $orderId = Mage::getSingleton('checkout/session')->getLastOrderId(); this code not showing any data. – Subhajyoti De Aug 25 '16 at 7:04
  • @SubhajyotiDe did you using this after the order placed? – Qaisar Satti Aug 25 '16 at 7:05
  • I searched in the session.php page in checkout model .But there is no function named getLastOrderId()‌​. I think thats why it is not returning any value. can you share your checkout/session.php page or the getLastOrderId()‌​ function? – Subhajyoti De Aug 25 '16 at 7:09
  • @SubhajyotiDe this is session not the method read about magento session how to set session and how to retrieve it. you can set session Mage::getSingleton('checkout/session')->setLastOrderId('fdfd')‌​; and get $orderId = Mage::getSingleton('checkout/session')->getLastOrderId()‌​; – Qaisar Satti Aug 25 '16 at 7:11
  • Ok. I will check that . For second part can you tell me a small part of your answer? first I will add the code block within <form>``</form> in the 'config.xml' file. But after that where I will add the the second part of the code? i.e model code. – Subhajyoti De Aug 25 '16 at 7:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.