I am creating a custom payment method.

Before calling the payment gateway, I am calling PlaceOrderAction javascript function in mypay-method.js. that way, order is created in Processing status.

placeOrder = placeOrderAction(this.getData(), false, this.messageContainer);

The fact is that I need the order to be created with Payment Pending status, so, I have to change order status accordingly after it was created.

How can I do it?

  • can you please share full code in qusestion?
    – Abdul
    Jan 5, 2018 at 6:43

2 Answers 2


Observe the sales_order_place_after event, then check the order from the observer if it has your payment method, do your logic and save the order again.

  • I assume this is for PHP observers, can the OP achieve what he wants the way he's doing it already i.e. with JavaScript?
    – scrowler
    Jun 9, 2016 at 20:56
  • Oh sry, didn't see this. I don't know Jun 9, 2016 at 20:57

I'm not sure you're approaching this the right way.

If you want to create orders with a Payment Pending status because of your payment method, i.e. don't charge the payment method when it is used in checkout, then you should configure your custom payment method so it doesn't capture during the checkout process.

I'm no expert in this area having only worked with payment methods that are captured immediately, but I'd suggest the most important part is going to be your payment method settings, specifically the "new order status" settings.

Disclaimer: This example is for Magento 1.x, but I imagine it's similar in Magento 2.

In Magento admin, under System -> Configuration -> Sales -> Payment Methods -> Your Custom Payment Method, there will be an option to choose "New Order Status". For payment methods that aren't captured immediately this should be "Pending". This will mean that an invoice is created, but the payment method is not charged immediately:

payment method settings

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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