The payment action of PayPal it's set to authorization (I need it, I can't set to sale), therefore then I need to capture the payment.

I know that I can do it manually from the invoice sending page, but I need to capture the payment automatically after 6 hours from the order time.

Could you suggest how to do that cron, and the function to capture the money automatically after 6 hours?

1 Answer 1


The code to do it is fairly simple, you would need to create a cronjob and a datetime check.

if($order->getPayment()->getMethodInstance()->getCode() == 'paypal_express') {
    $invoice = $order->prepareInvoice();
  • How can I limit it only to who have paid with PayPal?
    – Xavier
    Oct 5, 2016 at 15:07
  • if($order->getPayment()->getMethodInstance()->getCode() == 'paypal_express') { //do the invoice }
    – elfling
    Oct 5, 2016 at 16:03

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.