Problem/Motivation
With the latest version 8.x-1.x (hash da90c292), 2 payments are created per order due to changes related to webhook handling. This only happens when the "Queue webhook events" is disabled. So 1 payment is created in onReturn() and another is created in processWebHook().
See the attached screenshot for more information:


Steps to reproduce
It can be easily reproduced using Commerce Kickstart and the latest version of commerce_stripe.
Proposed resolution
When the "Queue webhook events" option is disabled, the creation of payments and placing of orders should not happen in processWebHook().
| Comment | File | Size | Author |
|---|---|---|---|
| webhooks.png | 88.29 KB | vmarchuk | |
| order_log.png | 150.35 KB | vmarchuk |
Issue fork commerce_stripe-3476156
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
vmarchukComment #6
tomtech commentedComment #8
nicolas bouteille commentedFrom what I understand, when webhooks are enabled, Commerce and thus Commerce Stripe as well, are relying on both the return page and webhooks to mark the order as "paid" and complete. Is this the reason why 2 payments were mistakenly created here?
From what I read, when relying on webhooks to finalize the order, the return page should not try to finalize it as well anymore. Do you know why the choice has been made to keep using both these mechanisms side by side? Also, can you explain how you fixed this problem? I tried to understand the code behind the merge request 131 but did not understand it. To prevent this from happening, do we need to use "automatic_async" capture_method so that the webhooks are called faster hoping they get called before the return page?
Thank you for your enlightenments