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
8 changes: 6 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ permissions:

jobs:
test:
runs-on: self-hosted
# runs-on: ubuntu-latest
# runs-on: self-hosted
runs-on: ubuntu-latest
env:
# define Java options for both official sbt and sbt-extras
JAVA_OPTS: -Xms2048M -Xmx2048M -Xss6M -XX:ReservedCodeCacheSize=256M -Dfile.encoding=UTF-8
Expand All @@ -38,6 +38,8 @@ jobs:
java-version: '8'
distribution: 'temurin'
# cache: 'sbt'
- name: Setup sbt launcher
uses: sbt/setup-sbt@v1
# - name: Run tests & Coverage Report
# run: sbt coverage test coverageReport
# - name: Upload coverage to Codecov
Expand Down Expand Up @@ -67,5 +69,7 @@ jobs:
java-version: '8'
distribution: 'temurin'
# cache: 'sbt'
- name: Setup sbt launcher
uses: sbt/setup-sbt@v1
- name: Formatting
run: sbt scalafmtSbtCheck scalafmtCheck test:scalafmtCheck
8 changes: 6 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ permissions:

jobs:
release:
runs-on: self-hosted
# runs-on: ubuntu-latest
# runs-on: self-hosted
runs-on: ubuntu-latest
env:
# define Java options for both official sbt and sbt-extras
JAVA_OPTS: -Xms2048M -Xmx2048M -Xss6M -XX:ReservedCodeCacheSize=256M -Dfile.encoding=UTF-8
Expand All @@ -35,6 +35,8 @@ jobs:
java-version: '8'
distribution: 'temurin'
cache: 'sbt'
- name: Setup sbt launcher
uses: sbt/setup-sbt@v1
- name: Run tests & Coverage Report
run: STRIPE_CLIENT_ID=${{secrets.STRIPE_CLIENT_ID}} STRIPE_API_KEY=${{secrets.STRIPE_API_KEY}} sbt coverage test coverageReport
- name: Upload coverage to Codecov
Expand All @@ -58,5 +60,7 @@ jobs:
java-version: '8'
distribution: 'temurin'
# cache: 'sbt'
- name: Setup sbt launcher
uses: sbt/setup-sbt@v1
- name: Formatting
run: sbt scalafmtSbtCheck scalafmtCheck test:scalafmtCheck
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.7.3.2"
ThisBuild / version := "0.7.4"

ThisBuild / scalaVersion := "2.12.18"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ object PaymentMessages {
* @param paymentMethodId
* - optional payment method id
* @param registerMeansOfPayment
* - optional flag to specify whether or not the means of payment should be registered
* - optional flag to specify whether the means of payment should be registered
*/
case class Payment(
orderUuid: String,
Expand Down Expand Up @@ -140,7 +140,7 @@ object PaymentMessages {
* @param paymentMethodId
* - optional payment method id
* @param registerMeansOfPayment
* - optional flag to specify whether or not the means of payment should be registered
* - optional flag to specify whether the means of payment should be registered
* @param clientId
* - optional client id
*/
Expand Down Expand Up @@ -644,22 +644,30 @@ object PaymentMessages {
case class BankAccountCommand(
bankAccount: BankAccount,
user: Either[NaturalUser, LegalUser],
acceptedTermsOfPSP: Option[Boolean] = None
acceptedTermsOfPSP: Option[Boolean] = None,
tokenId: Option[String] = None,
bankTokenId: Option[String] = None
)

object BankAccountCommand {

def apply(
bankAccount: BankAccount,
naturalUser: NaturalUser,
acceptedTermsOfPSP: Option[Boolean]
): BankAccountCommand = BankAccountCommand(bankAccount, Left(naturalUser), acceptedTermsOfPSP)
acceptedTermsOfPSP: Option[Boolean],
tokenId: Option[String],
bankTokenId: Option[String]
): BankAccountCommand =
BankAccountCommand(bankAccount, Left(naturalUser), acceptedTermsOfPSP, tokenId, bankTokenId)

def apply(
bankAccount: BankAccount,
legalUser: LegalUser,
acceptedTermsOfPSP: Option[Boolean]
): BankAccountCommand = BankAccountCommand(bankAccount, Right(legalUser), acceptedTermsOfPSP)
acceptedTermsOfPSP: Option[Boolean],
tokenId: Option[String],
bankTokenId: Option[String]
): BankAccountCommand =
BankAccountCommand(bankAccount, Right(legalUser), acceptedTermsOfPSP, tokenId, bankTokenId)
}

/** @param creditedAccount
Expand All @@ -676,6 +684,10 @@ object PaymentMessages {
* - user agent
* @param clientId
* - optional client id
* @param tokenId
* - optional account token id
* @param bankTokenId
* - optional bank token id
*/
case class CreateOrUpdateBankAccount(
creditedAccount: String,
Expand All @@ -684,7 +696,9 @@ object PaymentMessages {
acceptedTermsOfPSP: Option[Boolean] = None,
ipAddress: Option[String] = None,
userAgent: Option[String],
clientId: Option[String] = None
clientId: Option[String] = None,
tokenId: Option[String] = None,
bankTokenId: Option[String] = None
) extends PaymentCommandWithKey
with PaymentAccountCommand {
val key: String = creditedAccount
Expand Down Expand Up @@ -805,9 +819,19 @@ object PaymentMessages {

/** @param creditedAccount
* - account which owns the UBO declaration that would be validated
* @param ipAddress
* - ip address of the user
* @param userAgent
* - user agent of the user
* @param tokenId
* - optional token id for the user
*/
case class ValidateUboDeclaration(creditedAccount: String, ipAddress: String, userAgent: String)
extends PaymentCommandWithKey
case class ValidateUboDeclaration(
creditedAccount: String,
ipAddress: String,
userAgent: String,
tokenId: Option[String] = None
) extends PaymentCommandWithKey
with PaymentAccountCommand {
val key: String = creditedAccount
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,37 @@ trait PaymentAccountApi { _: PaymentContext =>

/** @param maybePaymentAccount
* - payment account to create or update
* @param acceptedTermsOfPSP
* - whether the user has accepted the terms of the PSP
* @param ipAddress
* - ip address of the user
* @param userAgent
* - user agent of the user
* @param tokenId
* - optional token id for the payment account
* @return
* provider user id
*/
def createOrUpdatePaymentAccount(
maybePaymentAccount: Option[PaymentAccount],
acceptedTermsOfPSP: Boolean,
ipAddress: Option[String],
userAgent: Option[String]
userAgent: Option[String],
tokenId: Option[String] = None
): Option[String] = {
maybePaymentAccount match {
case Some(paymentAccount) =>
import paymentAccount._
if (user.isLegalUser) {
createOrUpdateLegalUser(user.legalUser, acceptedTermsOfPSP, ipAddress, userAgent)
createOrUpdateLegalUser(user.legalUser, acceptedTermsOfPSP, ipAddress, userAgent, tokenId)
} else if (user.isNaturalUser) {
createOrUpdateNaturalUser(user.naturalUser, acceptedTermsOfPSP, ipAddress, userAgent)
createOrUpdateNaturalUser(
user.naturalUser,
acceptedTermsOfPSP,
ipAddress,
userAgent,
tokenId
)
} else {
None
}
Expand All @@ -40,6 +55,14 @@ trait PaymentAccountApi { _: PaymentContext =>

/** @param maybeNaturalUser
* - natural user to create
* @param acceptedTermsOfPSP
* - whether the user has accepted the terms of the PSP
* @param ipAddress
* - ip address of the user
* @param userAgent
* - user agent of the user
* @param tokenId
* - optional token id for the payment account
* @return
* provider user id
*/
Expand All @@ -48,11 +71,20 @@ trait PaymentAccountApi { _: PaymentContext =>
maybeNaturalUser: Option[NaturalUser],
acceptedTermsOfPSP: Boolean,
ipAddress: Option[String],
userAgent: Option[String]
userAgent: Option[String],
tokenId: Option[String]
): Option[String]

/** @param maybeLegalUser
* - legal user to create or update
* @param acceptedTermsOfPSP
* - whether the user has accepted the terms of the PSP
* @param ipAddress
* - ip address of the user
* @param userAgent
* - user agent of the user
* @param tokenId
* - optional token id for the payment account
* @return
* provider user id
*/
Expand All @@ -61,7 +93,8 @@ trait PaymentAccountApi { _: PaymentContext =>
maybeLegalUser: Option[LegalUser],
acceptedTermsOfPSP: Boolean,
ipAddress: Option[String],
userAgent: Option[String]
userAgent: Option[String],
tokenId: Option[String]
): Option[String]

/** @param userId
Expand Down Expand Up @@ -99,14 +132,21 @@ trait PaymentAccountApi { _: PaymentContext =>
* - Provider user id
* @param uboDeclarationId
* - Provider declaration id
* @param ipAddress
* - ip address of the user
* @param userAgent
* - user agent of the user
* @param tokenId
* - optional token id for the payment account
* @return
* Ultimate Beneficial Owner declaration
*/
def validateDeclaration(
userId: String,
uboDeclarationId: String,
ipAddress: String,
userAgent: String
userAgent: String,
tokenId: Option[String]
): Option[UboDeclaration]

/** @param userId
Expand Down Expand Up @@ -144,10 +184,15 @@ trait PaymentAccountApi { _: PaymentContext =>

/** @param maybeBankAccount
* - bank account to create
* @param bankTokenId
* - optional bank token id for the payment account
* @return
* bank account id
*/
def createOrUpdateBankAccount(maybeBankAccount: Option[BankAccount]): Option[String]
def createOrUpdateBankAccount(
maybeBankAccount: Option[BankAccount],
bankTokenId: Option[String]
): Option[String]

/** @param userId
* - provider user id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -597,9 +597,8 @@ trait PayInCommandHandler
List(
TransactionUpdatedEvent.defaultInstance
.withDocument(
transaction.copy(
clientId = paymentAccount.clientId,
debitedUserId = paymentAccount.userId)
transaction
.copy(clientId = paymentAccount.clientId, debitedUserId = paymentAccount.userId)
)
.withLastUpdated(lastUpdated)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1181,22 +1181,25 @@ trait PaymentBehavior
Some(updatedPaymentAccount),
acceptedTermsOfPSP.getOrElse(false),
ipAddress,
userAgent
userAgent,
tokenId
)
case Some(_) if shouldUpdateUser =>
if (shouldUpdateUserType) {
createOrUpdatePaymentAccount(
Some(updatedPaymentAccount.resetUserId(None)),
acceptedTermsOfPSP.getOrElse(false),
ipAddress,
userAgent
userAgent,
tokenId
)
} else {
createOrUpdatePaymentAccount(
Some(updatedPaymentAccount),
acceptedTermsOfPSP.getOrElse(false),
ipAddress,
userAgent
userAgent,
tokenId
)
}
case some => some
Expand Down Expand Up @@ -1228,11 +1231,13 @@ trait PaymentBehavior
(paymentAccount.bankAccount.flatMap(_.id) match {
case None =>
createOrUpdateBankAccount(
updatedPaymentAccount.resetBankAccountId().bankAccount
updatedPaymentAccount.resetBankAccountId().bankAccount,
bankTokenId
)
case Some(_) if shouldCreateOrUpdateBankAccount =>
createOrUpdateBankAccount(
updatedPaymentAccount.resetBankAccountId().bankAccount
updatedPaymentAccount.resetBankAccountId().bankAccount,
bankTokenId
)
case some => some
}) match {
Expand Down Expand Up @@ -1696,7 +1701,8 @@ trait PaymentBehavior
paymentAccount.userId.getOrElse(""),
uboDeclaration.id,
ipAddress,
userAgent
userAgent,
tokenId
) match {
case Some(declaration) =>
val updatedUbo = declaration.withUbos(uboDeclaration.ubos)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ trait BankAccountEndpoints[SD <: SessionData with SessionDataDecorator[SD]] {
acceptedTermsOfPSP,
clientId = client.map(_.clientId).orElse(session.clientId),
ipAddress = ipAddress,
userAgent = userAgent
userAgent = userAgent,
tokenId = tokenId
)
).map {
case r: BankAccountCreatedOrUpdated => Right(r)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ trait CheckoutEndpoints[SD <: SessionData with SessionDataDecorator[SD]] {
printReceipt,
creditedAccount.headOption,
feesAmount,
user = user, // required for Pre authorize without pre registered card
user = user, // required for Pre authorize without preregistered card
paymentMethodId = paymentMethodId,
registerMeansOfPayment = registerMeansOfPayment
)
Expand Down
Loading