Fix the issue of credit memo being not created on webhook.
2. Description of change
Change the webhook event from charge.complete to charge.capture so that webhook triggers the code that creates invoices because without invoice we can't create credit memo. We created CreditMemoService that abstracts the creation of credit memo from refund classes. We added the CreditMemoService class into the RefundSyncStats and WebhookRefundObserver.php as dependency and used its create method to generate credit memo.
###Edit###
Added back charge.complete as it is required for webhook flow. Now, we listen to both charge.complete and charge.capture, later for manual capture.
3. Quality assurance
Check credit memo creation on webhook and Sync order status.
1. Objective
Fix the issue of credit memo being not created on webhook.
2. Description of change
Change the webhook event from
charge.complete
tocharge.capture
so that webhook triggers the code that creates invoices because without invoice we can't create credit memo. We createdCreditMemoService
that abstracts the creation of credit memo from refund classes. We added theCreditMemoService
class into theRefundSyncStats
andWebhookRefundObserver.php
as dependency and used itscreate
method to generate credit memo.###Edit### Added back
charge.complete
as it is required for webhook flow. Now, we listen to bothcharge.complete
andcharge.capture
, later for manual capture.3. Quality assurance
Check credit memo creation on webhook and Sync order status.
🔧 Environments: