diff --git a/app/services/payment_requests/create_service.rb b/app/services/payment_requests/create_service.rb index 3749f3ca422..f17ebdd1fa1 100644 --- a/app/services/payment_requests/create_service.rb +++ b/app/services/payment_requests/create_service.rb @@ -23,10 +23,12 @@ def call ) end - SendWebhookJob.perform_later("payment_request.created", payment_request) + after_commit do + SendWebhookJob.perform_later("payment_request.created", payment_request) - payment_result = Payments::CreateService.call(payment_request) - PaymentRequestMailer.with(payment_request:).requested.deliver_later unless payment_result.success? + payment_result = Payments::CreateService.call(payment_request) + PaymentRequestMailer.with(payment_request:).requested.deliver_later unless payment_result.success? + end result.payment_request = payment_request