Skip to content

Commit c751908

Browse files
committed
to fix bance retrieval
1 parent 7e4f84c commit c751908

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

stripe/src/main/scala/app/softnetwork/payment/spi/StripePayOutApi.scala

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,15 +172,19 @@ trait StripePayOutApi extends PayOutApi { _: StripeContext with StripeTransferAp
172172
requestOptions = requestOptions.setStripeAccount(payOutTransaction.creditedUserId)
173173

174174
// load balance
175-
val availableAmount =
175+
val balances: Seq[Balance.Available] =
176176
Balance
177177
.retrieve(requestOptions.build())
178178
.getAvailable
179179
.asScala
180-
.find(_.getCurrency == payOutTransaction.currency) match {
180+
.toSeq
181+
182+
val availableAmount =
183+
balances.find(_.getCurrency.toLowerCase() == payOutTransaction.currency.toLowerCase) match {
181184
case Some(balance) =>
182185
balance.getAmount.intValue()
183186
case None =>
187+
mlog.info(s"balances -> ${new Gson().toJson(balances)}")
184188
0
185189
}
186190

@@ -201,15 +205,19 @@ trait StripePayOutApi extends PayOutApi { _: StripeContext with StripeTransferAp
201205
} else {
202206
// we receive funds from Stripe
203207
// load balance
204-
val availableAmount =
208+
val balances: Seq[Balance.Available] =
205209
Balance
206210
.retrieve(requestOptions.build())
207211
.getAvailable
208212
.asScala
209-
.find(_.getCurrency == payOutTransaction.currency) match {
213+
.toSeq
214+
215+
val availableAmount =
216+
balances.find(_.getCurrency.toLowerCase() == payOutTransaction.currency.toLowerCase) match {
210217
case Some(balance) =>
211218
balance.getAmount.intValue()
212219
case None =>
220+
mlog.info(s"balances -> ${new Gson().toJson(balances)}")
213221
0
214222
}
215223

0 commit comments

Comments
 (0)