i would like to explain the use case;
instead of selling the course via namaste enroll, one can put up woo-commerce or any shopping cart and sell the enrollment through it.
now since the lms has to know about the payment via the cart, we need to program a database update in the cart code to insert approp. row in lms tables.
this database update would be similar to the one you have written in payments.php ( Paypal code).
My question is will this approach work.?