Skip to content

Commit 017f662

Browse files
committed
Feature/2 phase refund flow (#390)
* fix: break on 2 phase refund process 1. create ledger entry 2. run job async to emit the refund on payment gateway * chore: fix unit tests * fix: repo typo
1 parent 71f8b03 commit 017f662

4 files changed

Lines changed: 220 additions & 70 deletions

File tree

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php namespace App\Jobs;
2+
/*
3+
* Copyright 2025 OpenStack Foundation
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
**/
14+
use App\Services\Model\ISummitOrderService;
15+
use Illuminate\Bus\Queueable;
16+
use Illuminate\Contracts\Queue\ShouldQueue;
17+
use Illuminate\Foundation\Bus\Dispatchable;
18+
use Illuminate\Queue\InteractsWithQueue;
19+
use Illuminate\Queue\SerializesModels;
20+
use Illuminate\Support\Facades\Log;
21+
use models\summit\SummitAttendeeTicketRefundRequest;
22+
use models\summit\SummitOrder;
23+
24+
final class ProcessPaymentGatewayRefundJob implements ShouldQueue
25+
{
26+
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
27+
28+
public int $tries = 2;
29+
30+
// no timeout
31+
public int $timeout = 0;
32+
/*
33+
/**
34+
* @var int
35+
*/
36+
private int $order_id;
37+
38+
/**
39+
* @var int
40+
*/
41+
private int $request_id;
42+
43+
/**
44+
* @param SummitOrder $order
45+
* @param SummitAttendeeTicketRefundRequest $request
46+
*/
47+
public function __construct(SummitOrder $order, SummitAttendeeTicketRefundRequest $request)
48+
{
49+
$this->request_id = $request->getId();
50+
$this->order_id = $order->getId();
51+
}
52+
53+
/**
54+
* @param ISummitOrderService $service
55+
* @return void
56+
*/
57+
public function handle(ISummitOrderService $service):void
58+
{
59+
Log::debug
60+
(
61+
sprintf
62+
(
63+
"ProcessPaymentGatewayRefundJob::handle order id %s request id %s",
64+
$this->order_id,
65+
$this->request_id
66+
)
67+
);
68+
69+
$service->processPaymentGatewayRefundRequest($this->order_id, $this->request_id);
70+
}
71+
72+
public function failed(\Throwable $exception)
73+
{
74+
Log::error($exception);
75+
}
76+
77+
}

app/Services/Model/ISummitOrderService.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,4 +436,11 @@ public function delegateTicket(Summit $summit, int $order_id, int $ticket_id,Mem
436436
* @return void
437437
*/
438438
public function ingestPaymentInfoForRegistrationOrders():void;
439+
440+
/**
441+
* @param int $order_id
442+
* @param int $request_id
443+
* @return void
444+
*/
445+
public function processPaymentGatewayRefundRequest(int $order_id, int $request_id):void;
439446
}

0 commit comments

Comments
 (0)