@@ -100,10 +100,10 @@ export class WithdrawalService {
100
100
) ;
101
101
}
102
102
103
- const hasVerifiedPaymentMethod =
104
- await this . paymentMethodRepo . hasVerifiedPaymentMethod ( userId ) ;
103
+ const connectedPaymentMethod =
104
+ await this . paymentMethodRepo . getConnectedPaymentMethod ( userId ) ;
105
105
106
- if ( ! hasVerifiedPaymentMethod ) {
106
+ if ( ! connectedPaymentMethod ) {
107
107
throw new Error (
108
108
'Please add a payment method before making a withdrawal.' ,
109
109
) ;
@@ -154,7 +154,7 @@ export class WithdrawalService {
154
154
user_id : userId ,
155
155
total_net_amount : totalAmount ,
156
156
status : payment_status . PROCESSING ,
157
- payment_method_id : hasVerifiedPaymentMethod . payment_method_id ,
157
+ payment_method_id : connectedPaymentMethod . payment_method_id ,
158
158
payee_id : recipient . trolley_id ,
159
159
external_transaction_id : paymentBatch . id ,
160
160
payment_release_associations : {
@@ -166,26 +166,29 @@ export class WithdrawalService {
166
166
} ,
167
167
} ,
168
168
} ) ;
169
+
170
+ try {
171
+ // generate quote
172
+ await this . trolleyService . client . batch . generateQuote ( paymentBatch . id ) ;
173
+
174
+ // trigger trolley payment (batch) process
175
+ await this . trolleyService . client . batch . startProcessing (
176
+ paymentBatch . id ,
177
+ ) ;
178
+ } catch ( error ) {
179
+ this . logger . error (
180
+ `Failed to process trolley payment batch: ${ error . message } ` ,
181
+ ) ;
182
+ throw new Error ( 'Failed to process trolley payment batch!' ) ;
183
+ }
184
+
169
185
this . logger . log (
170
186
`Payment release created successfully. ID: ${ paymentRelease . payment_release_id } ` ,
171
187
) ;
172
188
} catch ( error ) {
173
189
this . logger . error ( `Failed to create payment release: ${ error . message } ` ) ;
174
190
throw new Error ( 'Failed to create db entry for payment release!' ) ;
175
191
}
176
-
177
- try {
178
- // generate quote
179
- await this . trolleyService . client . batch . generateQuote ( paymentBatch . id ) ;
180
-
181
- // trigger trolley payment (batch) process
182
- await this . trolleyService . client . batch . startProcessing ( paymentBatch . id ) ;
183
- } catch ( error ) {
184
- this . logger . error (
185
- `Failed to process trolley payment batch: ${ error . message } ` ,
186
- ) ;
187
- throw new Error ( 'Failed to process trolley payment batch!' ) ;
188
- }
189
192
} ) ;
190
193
}
191
194
}
0 commit comments