Adding paid payments for orders with state cart throws error

Created on 29 March 2023, over 1 year ago
Updated 29 November 2023, 12 months ago

Steps to reproduce

Have a drupal 9, commerce + payments enabled

  • Go to an order with state 'draft' (a cart)
  • Go to payments
  • Add a payment and directly mark the payment as paid

Current behaviour

Currently, a WSOD shows. Drupal logs show the following error:

InvalidArgumentException: The timestamp must be numeric. in Drupal\Component\Datetime\DateTimePlus::createFromTimestamp() (regel 201 van /var/www/femma/web/core/lib/Drupal/Component/Datetime/DateTimePlus.php).

I guess it has something to do with the fact the payment is only able to be received for orders with a state != draft.


In my opinion commerce needs to block payments from being received if the order state is draft.
It would be even better if we could add payments as already paid for draft orders (not sure if someone really needs this functionality, but it could come in handy), but that might have a big impact on the current payment-process. For example if an admin sets an order as fully paid, but not yet placed, the payment-step can be fully skipped. To be discussed with the commerce maintainers.

πŸ› Bug report
Status

Closed: cannot reproduce

Version

2.0

Component

Payment

Created by

πŸ‡§πŸ‡ͺBelgium pietermouton

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @pietermouton
  • πŸ‡ΊπŸ‡¦Ukraine tbkot

    @pietermouton could you provide a bit more details on how to reproduce this issue? I've tried provided steps and can not get an error. Does the order is for an anonymous or authenticated user? What kind of payment are you adding? Maybe yo could provide screenshots of steps or errors?

  • πŸ‡§πŸ‡ͺBelgium pietermouton

    @tBKoT
    The order was placed by an anonymous user, but I think it might also be the issue for an authenticated user.
    I've set up my webshop with a custom payment gateway (plugin: manual)

    What I do to reproduce:
    - Log in as admin
    - Go to admin > commerce > order
    - Go to carts
    - Select a cart
    - Go to payments
    - Add payment 'custom' (plugin manual)
    - Leave the amount as filled in (so the total of the order)
    - Check the 'received' checkbox
    - Save

    I get the error from above.

    I've a couple of custom modules active for this project, so there's a chance that it has something to do with these modules (some with eventsubscribers, so one of these can be invoked by the payment being paid).

    If you cannot reproduce the error with the steps above, I will look into my custom modules again.

  • πŸ‡ΊπŸ‡¦Ukraine tbkot

    @pietermouton I've checked provided steps and still cannot reproduce the issue. Tried different types of payment, and for the authenticated users too. As you have an error you also should have a bunch of methods/functions from where it goes. You could check there if any of your custom modules triggering there.

  • Status changed to Closed: cannot reproduce 12 months ago
  • πŸ‡ΊπŸ‡¦Ukraine tbkot

    Closing it, as still cannot reproduce

Production build 0.71.5 2024