5
5
namespace Flutterwave \Service ;
6
6
7
7
use Flutterwave \Contract \ConfigInterface ;
8
- use Flutterwave \EventHandlers \TransactionVerificationEventHandler ;
8
+ use Flutterwave \EventHandlers \EventTracker ;
9
9
use Flutterwave \Traits \ApiOperations \Post ;
10
10
use Psr \Http \Client \ClientExceptionInterface ;
11
11
12
12
class Transactions extends Service
13
13
{
14
+ use EventTracker;
14
15
use Post;
15
16
16
17
public const ENDPOINT = 'transactions ' ;
@@ -26,14 +27,12 @@ class Transactions extends Service
26
27
private array $ payment_type = [
27
28
'card ' ,'debit_ng_account ' ,'mobilemoney ' ,'bank_transfer ' , 'ach_payment ' ,
28
29
];
29
- private TransactionVerificationEventHandler $ eventHandler ;
30
30
31
31
public function __construct (?ConfigInterface $ config = null )
32
32
{
33
33
parent ::__construct ($ config );
34
- $ this ->baseUrl = $ this ->config ::BASE_URL ;
35
34
$ this ->end_point = Transactions::ENDPOINT ;
36
- $ this -> eventHandler = new TransactionVerificationEventHandler ();
35
+
37
36
}
38
37
39
38
/**
@@ -43,13 +42,13 @@ public function verify(string $transactionId): \stdClass
43
42
{
44
43
$ this ->checkTransactionId ($ transactionId );
45
44
$ this ->logger ->notice ('Transaction Service::Verifying Transaction... ' . $ transactionId );
46
- TransactionVerificationEventHandler ::startRecording ();
45
+ self ::startRecording ();
47
46
$ response = $ this ->request (
48
47
null ,
49
48
'GET ' ,
50
49
self ::ENDPOINT . "/ {$ transactionId }/verify " ,
51
50
);
52
- TransactionVerificationEventHandler ::setResponseTime ();
51
+ self ::setResponseTime ();
53
52
54
53
return $ response ;
55
54
}
@@ -60,13 +59,13 @@ public function verify(string $transactionId): \stdClass
60
59
public function verifyWithTxref (string $ tx_ref ): \stdClass
61
60
{
62
61
$ this ->logger ->notice ('Transaction Service::Verifying Transaction... ' . $ tx_ref );
63
- TransactionVerificationEventHandler ::startRecording ();
62
+ self ::startRecording ();
64
63
$ response = $ this ->request (
65
64
null ,
66
65
'GET ' ,
67
66
self ::ENDPOINT . '/verify_by_reference?tx_ref= ' . $ tx_ref ,
68
67
);
69
- TransactionVerificationEventHandler ::setResponseTime ();
68
+ self ::setResponseTime ();
70
69
return $ response ;
71
70
}
72
71
@@ -77,13 +76,13 @@ public function refund(string $trasanctionId): \stdClass
77
76
{
78
77
$ this ->checkTransactionId ($ trasanctionId );
79
78
$ this ->logger ->notice ("Transaction Service::Refunding Transaction... {$ trasanctionId }" );
80
- TransactionVerificationEventHandler ::startRecording ();
79
+ self ::startRecording ();
81
80
$ response = $ this ->request (
82
81
null ,
83
82
'GET ' ,
84
83
self ::ENDPOINT . "/ {$ trasanctionId }/refund " ,
85
84
);
86
- TransactionVerificationEventHandler ::setResponseTime ();
85
+ self ::setResponseTime ();
87
86
return $ response ;
88
87
}
89
88
@@ -93,13 +92,13 @@ public function refund(string $trasanctionId): \stdClass
93
92
public function getAllTransactions (): \stdClass
94
93
{
95
94
$ this ->logger ->notice ('Transaction Service::Retrieving all Transaction for Merchant ' );
96
- TransactionVerificationEventHandler ::startRecording ();
95
+ self ::startRecording ();
97
96
$ response = $ this ->request (
98
97
null ,
99
98
'GET ' ,
100
99
self ::ENDPOINT ,
101
100
);
102
- TransactionVerificationEventHandler ::setResponseTime ();
101
+ self ::setResponseTime ();
103
102
return $ response ;
104
103
}
105
104
@@ -110,13 +109,13 @@ public function getRefundInfo(string $trasanctionId): \stdClass
110
109
{
111
110
$ this ->checkTransactionId ($ trasanctionId );
112
111
$ this ->logger ->notice ("Transaction Service::Retrieving refund:Transactionid => {$ trasanctionId }" );
113
- TransactionVerificationEventHandler ::startRecording ();
112
+ self ::startRecording ();
114
113
$ response = $ this ->request (
115
114
null ,
116
115
'GET ' ,
117
116
"refunds/ {$ trasanctionId }" ,
118
117
);
119
- TransactionVerificationEventHandler ::setResponseTime ();
118
+ self ::setResponseTime ();
120
119
return $ response ;
121
120
}
122
121
@@ -151,13 +150,13 @@ public function getTransactionFee(
151
150
152
151
$ logData = json_encode ($ data );
153
152
$ this ->logger ->notice ("Transaction Service::Retrieving Transaction Fee: Util => {$ logData }" );
154
- TransactionVerificationEventHandler ::startRecording ();
153
+ self ::startRecording ();
155
154
$ response = $ this ->request (
156
155
null ,
157
156
'GET ' ,
158
157
self ::ENDPOINT . "/fee? {$ query }" ,
159
158
);
160
- TransactionVerificationEventHandler ::setResponseTime ();
159
+ self ::setResponseTime ();
161
160
return $ response ;
162
161
}
163
162
@@ -168,13 +167,13 @@ public function resendFailedHooks(string $transactionId): \stdClass
168
167
{
169
168
$ this ->checkTransactionId ($ transactionId );
170
169
$ this ->logger ->notice ("Transaction Service::Resending Transaction Webhook: TransactionId => {$ transactionId }" );
171
- TransactionVerificationEventHandler ::startRecording ();
170
+ self ::startRecording ();
172
171
$ response = $ this ->request (
173
172
null ,
174
- 'GET ' ,
173
+ 'POST ' ,
175
174
self ::ENDPOINT . "/ {$ transactionId }/resend-hook " ,
176
175
);
177
- TransactionVerificationEventHandler ::setResponseTime ();
176
+ self ::setResponseTime ();
178
177
return $ response ;
179
178
}
180
179
@@ -187,13 +186,13 @@ public function retrieveTimeline(string $transactionId): \stdClass
187
186
$ this ->logger ->notice (
188
187
"Transaction Service::Retrieving Transaction Timeline: TransactionId => {$ transactionId }"
189
188
);
190
- TransactionVerificationEventHandler ::startRecording ();
189
+ self ::startRecording ();
191
190
$ response = $ this ->request (
192
191
null ,
193
192
'GET ' ,
194
- self ::ENDPOINT . "/ {$ transactionId }/timeline " ,
193
+ self ::ENDPOINT . "/ {$ transactionId }/events " ,
195
194
);
196
- TransactionVerificationEventHandler ::setResponseTime ();
195
+ self ::setResponseTime ();
197
196
return $ response ;
198
197
}
199
198
0 commit comments