For one of my Magento module I need to catch the event “any order is defined as paid”. So I found that the associated event is sales_order_payment_pay. Ok seems to fit perfectly with my needs.
I’m a Magento dev, not a merchant and, for the moment, I’ve never put a Magento instance online and in production. So the payment workflow is quite dark to me. I used to select “Check/Money Order” as payment method during my tests.
The problem is : I need to catch this event (sales_order_payment_pay) but it seems I can’t trigger it and never enter in my observer function. I have currently 2 payment method, check/money order and credit card. For the first one, the merchant needs to validate the payment in the backend and I red it’s the moment when he creates the invoice. So I tried it but the event is never triggered. For the second one, it’s more difficult : as I am in dev mode, I don’t know how to validate payment via credit card. I found a number for MasterCard online who allows tests in Magento, but in the back end, the total paid ammound is still equal to zero. So after order submission, no event triggered (seems quite logical) and when I create the invoice, still no event triggered.
Can you help me to understand a little more the payment process and to catch any order paid ? I can’t find any information or documentation about it.
PS : The aim of my module is to catch the event place order or payment paid and generate an XML file for data export. The first one with place order is already developed.
This topic seems a little tricky, so I will share my vision of payment methods and order lifecycle.
First of all I invite you to see this topics by one of the most famous Magento blogger, Alana Storm.
Here is how I think it’s working :
Case 1 : Order with an online payment (Paypal, credit card, etc ...), payment accepted
Order validated by Client -> order created by Magento -> status pending_payment
Order payed online by Client -> payment validated by Payment Service -> payment OK -> invoice created by Magento -> status pending_payment (not sure about this point).
Order shipped by merchant -> shippig coupon created by Magento -> status complete
Case 2 : Order with an online payment (Paypal, credit card, etc ...), payment refused
Order validated by Client -> order created by Magento -> status pending_payment
Order payed online by Client -> payment refused by Payment Service -> Order cancelled by Magento -> status canceled
Case 3 : Order with an offline payment (check/money order, selling coupon, etc ...). The merchant invoices before shipping
Order validated by Client -> order created by Magento -> status pending
Order payed offline by Client -> payment received by Merchant -> order invoiced by Merchant -> invoice created by Magento -> status processing
Order shipped by Merchant -> shipping coupon created by Magento -> status complete
Case 4 : Order with an offline payment (check/money order, selling coupon, etc ...). The merchant ships before invoicing
Order validated by Client -> order created by Magento -> status pending
Order payed offline by Client -> order shipped by Merchant -> shipping coupon created by Magento -> status processing
Order invoiced by Merchant -> invoice created by Magento -> status processing
Hope this topic will help someone in the future.
Let me know if you need some more information after that.