Skip to content

Commit 2b97a08

Browse files
committed
add optional external reference to pay out
1 parent 0c48295 commit 2b97a08

14 files changed

Lines changed: 113 additions & 39 deletions

File tree

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ ThisBuild / organization := "app.softnetwork"
3131

3232
name := "payment"
3333

34-
ThisBuild / version := "0.4.2.1"
34+
ThisBuild / version := "0.4.2.2"
3535

3636
ThisBuild / scalaVersion := "2.12.15"
3737

common/src/main/protobuf/api/payment.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ message PayOutRequest {
8080
int32 creditedAmount = 3;
8181
int32 feesAmount = 4;
8282
string currency = 5;
83+
google.protobuf.StringValue externalReference = 6;
8384
}
8485

8586
message TransferRequest {

common/src/main/protobuf/message/payment/payment.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ message PayOutCommandEvent{
207207
required int32 creditedAmount = 3;
208208
required int32 feesAmount = 4;
209209
required string currency = 5 [default = "EUR"];
210+
optional string externalReference = 6;
210211
}
211212

212213
message TransferCommandEvent{

common/src/main/protobuf/message/payment/transaction.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ message PaidOutEvent {
7878
required string currency = 6 [default = "EUR"];
7979
required string transactionId = 7;
8080
required app.softnetwork.payment.model.Transaction.PaymentType paymentType = 8;
81+
optional string externalReference = 9;
8182
}
8283

8384
message PayOutFailedEvent {
@@ -86,6 +87,7 @@ message PayOutFailedEvent {
8687
required string orderUuid = 1;
8788
required string resultMessage = 2;
8889
optional app.softnetwork.payment.model.Transaction transaction = 3;
90+
optional string externalReference = 4;
8991
}
9092

9193
message RefundedEvent {

common/src/main/protobuf/model/payment/transaction.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ message PayOutTransaction {
162162
required string bankAccountId = 6;
163163
required string authorId = 7;
164164
required string debitedWalletId = 8;
165+
optional string externalReference = 9;
165166
}
166167

167168
message DirectDebitTransaction {

common/src/main/scala/app/softnetwork/payment/api/PaymentClient.scala

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,18 @@ trait PaymentClient extends GrpcClient {
7070
creditedAccount: String,
7171
creditedAmount: Int,
7272
feesAmount: Int,
73-
currency: String
73+
currency: String,
74+
externalReference: Option[String]
7475
): Future[TransactionResponse] = {
7576
grpcClient.payOut(
76-
PayOutRequest(orderUuid, creditedAccount, creditedAmount, feesAmount, currency)
77+
PayOutRequest(
78+
orderUuid,
79+
creditedAccount,
80+
creditedAmount,
81+
feesAmount,
82+
currency,
83+
externalReference
84+
)
7785
)
7886
}
7987

common/src/main/scala/app/softnetwork/payment/message/PaymentMessages.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,8 @@ object PaymentMessages {
264264
creditedAccount: String,
265265
creditedAmount: Int,
266266
feesAmount: Int = 0,
267-
currency: String = "EUR"
267+
currency: String = "EUR",
268+
externalReference: Option[String] = None
268269
) extends PaymentCommandWithKey {
269270
val key: String = creditedAccount
270271
}

core/src/main/scala/app/softnetwork/payment/api/PaymentServer.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,9 @@ trait PaymentServer extends PaymentServiceApi with GenericPaymentHandler {
140140

141141
override def payOut(in: PayOutRequest): Future[TransactionResponse] = {
142142
import in._
143-
!?(PayOut(orderUuid, creditedAccount, creditedAmount, feesAmount, currency)) map {
143+
!?(
144+
PayOut(orderUuid, creditedAccount, creditedAmount, feesAmount, currency, externalReference)
145+
) map {
144146
case r: PaidOut =>
145147
TransactionResponse(
146148
transactionId = Some(r.transactionId),

core/src/main/scala/app/softnetwork/payment/handlers/GenericPaymentHandler.scala

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,20 @@ trait GenericPaymentDao { _: GenericPaymentHandler =>
189189
}
190190
}
191191

192-
def payOut(orderUuid: String, creditedAccount: String, creditedAmount: Int, feesAmount: Int)(
193-
implicit system: ActorSystem[_]
192+
def payOut(
193+
orderUuid: String,
194+
creditedAccount: String,
195+
creditedAmount: Int,
196+
feesAmount: Int,
197+
currency: String = "EUR",
198+
externalReference: Option[String]
199+
)(implicit
200+
system: ActorSystem[_]
194201
): Future[Either[PayOutFailed, PaidOut]] = {
195202
implicit val ec: ExecutionContextExecutor = system.executionContext
196-
!?(PayOut(orderUuid, creditedAccount, creditedAmount, feesAmount)) map {
203+
!?(
204+
PayOut(orderUuid, creditedAccount, creditedAmount, feesAmount, currency, externalReference)
205+
) map {
197206
case result: PaidOut => Right(result)
198207
case error: PayOutFailed => Left(error)
199208
case _ =>

core/src/main/scala/app/softnetwork/payment/persistence/query/GenericPaymentCommandProcessorStream.scala

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,14 @@ trait GenericPaymentCommandProcessorStream extends EventProcessorStream[PaymentE
9191
}
9292
case evt: PayOutCommandEvent =>
9393
import evt._
94-
val command = PayOut(orderUuid, creditedAccount, creditedAmount, feesAmount, currency)
94+
val command = PayOut(
95+
orderUuid,
96+
creditedAccount,
97+
creditedAmount,
98+
feesAmount,
99+
currency,
100+
externalReference
101+
)
95102
!?(command) map {
96103
case _: PaidOut =>
97104
if (forTests) system.eventStream.tell(Publish(event))

0 commit comments

Comments
 (0)