Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
sbt.json
target
.metals
*.log
*.log
tmp
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ThisBuild / organization := "app.softnetwork"

name := "payment"

ThisBuild / version := "0.8.2"
ThisBuild / version := "0.8.3"

ThisBuild / scalaVersion := "2.12.18"

Expand Down
1 change: 1 addition & 0 deletions common/src/main/protobuf/message/payment/transaction.proto
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ message TransferFailedEvent {
required string resultMessage = 2;
optional app.softnetwork.payment.model.Transaction transaction = 3;
optional string externalReference = 4;
optional string orderUuid = 5;
}

message DirectDebitedEvent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -471,37 +471,56 @@ trait PaymentBehavior
case Some(authorId) =>
paymentAccount.walletId match {
case Some(debitedWalletId) =>
// load credited payment account
paymentDao.loadPaymentAccount(creditedAccount, clientId) complete () match {
case Success(s) =>
maybeCreditedPaymentAccount = s
maybeCreditedPaymentAccount match {
case Some(creditedPaymentAccount) => // credited account
creditedPaymentAccount.userId match {
case Some(creditedUserId) =>
creditedPaymentAccount.walletId match {
case Some(creditedWalletId) =>
Some(
TransferTransaction.defaultInstance
.withDebitedAmount(debitedAmount)
.withFeesAmount(feesAmount)
.withCurrency(currency)
.withAuthorId(authorId)
.withDebitedWalletId(debitedWalletId)
.withCreditedUserId(creditedUserId)
.withCreditedWalletId(creditedWalletId)
.copy(
orderUuid = orderUuid,
externalReference = externalReference
)
)
case _ => None
}
case _ => None
}
case _ => None
}
case Failure(_) => None
if (debitedAccount == creditedAccount) { // direct transfer from the platform account to authorId
val creditedUserId = authorId
val creditedWalletId = debitedWalletId
Some(
TransferTransaction.defaultInstance
.withDebitedAmount(debitedAmount)
.withFeesAmount(feesAmount)
.withCurrency(currency)
.withAuthorId(authorId)
.withDebitedWalletId(debitedWalletId)
.withCreditedUserId(creditedUserId)
.withCreditedWalletId(creditedWalletId)
.copy(
orderUuid = orderUuid,
externalReference = externalReference
)
)
} else {
// load credited payment account
paymentDao.loadPaymentAccount(creditedAccount, clientId) complete () match {
case Success(s) =>
maybeCreditedPaymentAccount = s
maybeCreditedPaymentAccount match {
case Some(creditedPaymentAccount) => // credited account
creditedPaymentAccount.userId match {
case Some(creditedUserId) =>
creditedPaymentAccount.walletId match {
case Some(creditedWalletId) =>
Some(
TransferTransaction.defaultInstance
.withDebitedAmount(debitedAmount)
.withFeesAmount(feesAmount)
.withCurrency(currency)
.withAuthorId(authorId)
.withDebitedWalletId(debitedWalletId)
.withCreditedUserId(creditedUserId)
.withCreditedWalletId(creditedWalletId)
.copy(
orderUuid = orderUuid,
externalReference = externalReference
)
)
case _ => None
}
case _ => None
}
case _ => None
}
case Failure(_) => None
}
}
case _ => None
}
Expand Down Expand Up @@ -579,7 +598,10 @@ trait PaymentBehavior
.withDebitedAccount(paymentAccount.externalUuid)
.withResultMessage(transaction.resultMessage)
.withTransaction(transaction)
.copy(externalReference = externalReference)
.copy(
externalReference = externalReference,
orderUuid = orderUuid
)
) :+ transactionUpdatedEvent
)
.thenRun(_ =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ trait StripeTransferApi extends TransferApi { _: StripeContext =>
.setAmount(Math.min(amountToTransfer, availableAmount))
.setDestination(transferTransaction.creditedUserId)
.setCurrency(transferTransaction.currency)
// .setSourceType(TransferCreateParams.SourceType.CARD)
.putMetadata("available_amount", availableAmount.toString)
.putMetadata("debited_amount", transferTransaction.debitedAmount.toString)
.putMetadata("fees_amount", transferTransaction.feesAmount.toString)
Expand Down