Closed (fixed)
Project:
Commerce PayPal
Version:
8.x-1.x-dev
Component:
PayPal Checkout
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
14 Apr 2025 at 20:26 UTC
Updated:
27 May 2025 at 06:54 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
jsacksick commentedDo you have any error to share from the logs?
The error should be logged...What was displayed in the UI as well? Could be that the response has changed and the status isn't "COMPLETED" as expected? Is this a partial refund?
Comment #3
jsacksick commentedI just tried reproducing this locally and couldn't... I'd appreciate if we could get a screenshot / dump of the response. I just tried performing a partial and a full refund and both worked, see the attached screenshots:
Comment #4
jsacksick commentedhm... Quick q: do you have Webhooks configured? I'm wondering if there is a race condition or something... Since I'm testing locally this isn't happening to me.
Comment #5
tonytheferg commentedPartial refund.
Sorry for the lack of clarity in the OP but I was busy contacting the customer to straighten out the mess, so I just plopped this in so I didn't forget.
Comment #6
jsacksick commentedCan you confirm if you have Webhooks configured? If so, I think we might have an issue where the webhook is actually causing a double refund... Not really sure how we can prevent that unfortunately...
We'd either need to know that a particular event was processed or whether the refund was initiated from Drupal... Basically the intent was to make sure refunds initiated from PayPal directly would be reflected into Drupal.
In the meantime, perhaps you can stop listening to the PAYMENT.CAPTURE.REFUNDED event?
Comment #7
jsacksick commentedChatted with Ryan on this on Slack. We should check if it is possible to embed context in the API request so we can easily identify events that were initiated from on site activity (e.g: a refund triggered from the Drupal admin).
UPDATE: PayPal doesn't support arbitrary metadata fields like Stripe does, so we can't attach a key-value pair like "source": "drupal" and expect to see it in webhooks. We're not passing a "custom_id" whenever the refund is initiated but we are expecting it in the Webhook, which makes me think it is inherited from when the PayPal order is created.
We could use "invoice_id" as well but that might be reflected somewhere in the PayPal UI and that field has an associated meaning.
Comment #9
jsacksick commented@tonytheferg: Anyway you could test the patch?
Comment #10
tonytheferg commentedI don't have webhooks configured.
I would need to set up the test account to test the patch as this happened on a live site with a live transaction.
Comment #12
jsacksick commentedOk so my analysis isn't correct even though I believe this is also a problem.
Could you check if the status returned was "pending" perhaps? We can't consider "pending" refunds as "completed", so perhaps we should add special handling for this and add a message informing the merchant.
Anything else that could help us further diagnose the issue?
If webhooks are configured properly, then I believe the payment would be later marked as refunded.
Will merge the MR (that is unrelated), but update this issue status back to Postponed until more information is provided.
Comment #13
tonytheferg commentedYes, When I get some free time I can try to reproduce in a sandbox, or if I have another PayPal refund on the live site, I can try as well, and provide better info.
Thanks!
Comment #14
jsacksick commentedBut do you have logs for the problematic refund?
Comment #15
tonytheferg commentedUnfortunately no, as the log only goes back to the 18th.
Maybe I do in one of the dev environments. I'll follow up
Comment #16
tonytheferg commentedI have the DB log for that time, but no error logs in the DB for the transaction. My guess is it's just a form validation error that is not logged.
Comment #17
grevil commented@jsacksick you forgot to initiate the UUID service! Which currently leads to the following error when refunding:
Comment #19
jsacksick commentedFixed this and tagged a new release.
Comment #20
grevil commentedThank you!