Skip to content

Commit

Permalink
[JB][OPS-12927] wire up card fees page for sa origins (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
barnesjake authored Nov 1, 2024
1 parent 47149a0 commit f0526b8
Show file tree
Hide file tree
Showing 18 changed files with 602 additions and 34 deletions.
7 changes: 6 additions & 1 deletion app/uk/gov/hmrc/cardpaymentfrontend/config/AppConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,14 @@ import uk.gov.hmrc.play.bootstrap.config.ServicesConfig

@Singleton
class AppConfig @Inject() (config: Configuration, servicesConfig: ServicesConfig) {
val welshLanguageSupportEnabled: Boolean = config.getOptional[Boolean]("features.welsh-language-support").getOrElse(false)

val payAnotherWayLink: String = config.get[String]("urls.govuk.pay-another-way")

val payApiBaseUrl: String = servicesConfig.baseUrl("pay-api")

val payFrontendBaseUrl: String = servicesConfig.baseUrl("pay-frontend") + "/pay"

val bankTransferRelativeUrl: String = config.get[String]("urls.pay-frontend.bank-transfer")
val oneOffDirectDebitRelativeUrl: String = config.get[String]("urls.pay-frontend.one-off-direct-debit")

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,27 @@ package uk.gov.hmrc.cardpaymentfrontend.controllers

import payapi.corcommon.model.{Origin, Origins}
import play.api.mvc.{Action, AnyContent, Call, MessagesControllerComponents}
import uk.gov.hmrc.cardpaymentfrontend.actions.{Actions, JourneyRequest}
import uk.gov.hmrc.cardpaymentfrontend.config.AppConfig
import uk.gov.hmrc.cardpaymentfrontend.models.Link
import uk.gov.hmrc.cardpaymentfrontend.utils.OriginExtraInfo
import uk.gov.hmrc.cardpaymentfrontend.models.extendedorigins.ExtendedOrigin
import uk.gov.hmrc.cardpaymentfrontend.requests.RequestSupport
import uk.gov.hmrc.cardpaymentfrontend.utils.{OriginExtraInfo, PaymentMethod, PaymentMethods}
import uk.gov.hmrc.cardpaymentfrontend.views.html.FeesPage
import uk.gov.hmrc.play.bootstrap.frontend.controller.FrontendController

import javax.inject.{Inject, Singleton}

@Singleton
class FeesController @Inject() (
originExtraInfo: OriginExtraInfo,
actions: Actions,
appConfig: AppConfig,
feesPage: FeesPage,
mcc: MessagesControllerComponents,
feesPage: FeesPage
originExtraInfo: OriginExtraInfo,
requestSupport: RequestSupport
) extends FrontendController(mcc) {

private[controllers] def twoDirectDebitsPrimaryLink(origin: Origin): Option[Link] = {
origin match {
case Origins.BtaEpayeBill => Some(Link(
Expand Down Expand Up @@ -128,4 +136,53 @@ class FeesController @Inject() (
// Two kinds of DD with secondary link
def renderPage5(): Action[AnyContent] = renderPage(Origins.PfMgd)

import requestSupport._

def renderPageNew(): Action[AnyContent] = actions.journeyAction { implicit journeyRequest: JourneyRequest[AnyContent] =>
val altPayments = linksAvailableOnFeesPage(journeyRequest.journey.origin)
if (altPayments.isEmpty) Redirect("http://nextpage.html")
else Ok(feesPage(altPayments))
}

def submit: Action[AnyContent] = actions.journeyAction { _ =>
Redirect(routes.EmailAddressController.renderPage)
}

private[controllers] def paymentMethodToBeShown(paymentMethod: PaymentMethod, paymentMethods: Set[PaymentMethod]): Boolean = paymentMethods.contains(paymentMethod)

private[controllers] def linksAvailableOnFeesPage(origin: Origin): Seq[Link] = {

val extendedOrigin: ExtendedOrigin = originExtraInfo.lift(origin)
val paymentMethodsToShow: Set[PaymentMethod] = extendedOrigin.cardFeesPagePaymentMethods
val showOpenBankingLink: Boolean = paymentMethodToBeShown(PaymentMethods.OpenBanking, paymentMethodsToShow)
val showBankTransferLink: Boolean = paymentMethodToBeShown(PaymentMethods.Bacs, paymentMethodsToShow)
val showOneOffDirectDebitLink: Boolean = paymentMethodToBeShown(PaymentMethods.OneOffDirectDebit, paymentMethodsToShow)

val maybeOpenBankingLink = if (showOpenBankingLink) {
Seq(Link(
href = Call("GET", "https://open_banking_url_goes_here"),
linkId = "open-banking-link",
messageKey = "card-fees.para2.open-banking"
))
} else Seq.empty[Link]

val maybeBankTransferLink = if (showBankTransferLink) {
Seq(Link(
href = Call("GET", appConfig.payFrontendBaseUrl + appConfig.bankTransferRelativeUrl),
linkId = "bank-transfer-link",
messageKey = "card-fees.para2.bank-transfer"
))
} else Seq.empty[Link]

val maybeOneOffDirectDebitLink = if (showOneOffDirectDebitLink) {
Seq(Link(
href = Call("GET", appConfig.payFrontendBaseUrl + appConfig.oneOffDirectDebitRelativeUrl),
linkId = "one-off-direct-debit-link",
messageKey = "card-fees.para2.one-off-direct-debit"
))
} else Seq.empty[Link]

maybeOpenBankingLink ++ maybeBankTransferLink ++ maybeOneOffDirectDebitLink
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import play.api.data.Form
import play.api.mvc.{Action, AnyContent, MessagesControllerComponents}
import uk.gov.hmrc.cardpaymentfrontend.forms.ChooseAPaymentMethodForm
import uk.gov.hmrc.cardpaymentfrontend.models.extendedorigins.ExtendedOrigin
import uk.gov.hmrc.cardpaymentfrontend.utils.{OpenBanking, OriginExtraInfo, PaymentMethod}
import uk.gov.hmrc.cardpaymentfrontend.utils.PaymentMethods.OpenBanking
import uk.gov.hmrc.cardpaymentfrontend.utils.{OriginExtraInfo, PaymentMethod}
import uk.gov.hmrc.cardpaymentfrontend.views.html.PaymentFailedPage
import uk.gov.hmrc.play.bootstrap.frontend.controller.FrontendController

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class DefaultExtendedOrigin extends ExtendedOrigin {
def serviceNameMessageKey = ""
def taxNameMessageKey: String = ""
def reference(): String = ""
def cardFeesPagePaymentMethods: Set[PaymentMethod] = Set.empty[PaymentMethod]
def paymentMethods(): Set[PaymentMethod] = Set.empty[PaymentMethod]

def checkYourAnswersRows(): Seq[CheckYourAnswersRow] = Seq.empty[CheckYourAnswersRow]
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
package uk.gov.hmrc.cardpaymentfrontend.models.extendedorigins

import uk.gov.hmrc.cardpaymentfrontend.models.CheckYourAnswersRow
import uk.gov.hmrc.cardpaymentfrontend.utils.PaymentMethods.{OneOffDirectDebit, OpenBanking}
import uk.gov.hmrc.cardpaymentfrontend.utils._

object ExtendedBtaSa extends ExtendedOrigin {
override val serviceNameMessageKey: String = "service-name.BtaSa"
override val taxNameMessageKey: String = "payment-complete.tax-name.BtaSa"
def reference(): String = "1097172564" //This would really come from the journey either pay-api or stored locally
def cardFeesPagePaymentMethods: Set[PaymentMethod] = Set(OpenBanking, OneOffDirectDebit)
//todo add these when we do that ticket
def paymentMethods(): Set[PaymentMethod] = Set.empty
//todo add this when we do that ticket
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
package uk.gov.hmrc.cardpaymentfrontend.models.extendedorigins

import uk.gov.hmrc.cardpaymentfrontend.models.CheckYourAnswersRow
import uk.gov.hmrc.cardpaymentfrontend.utils.PaymentMethods.Bacs
import uk.gov.hmrc.cardpaymentfrontend.utils._

object ExtendedItSa extends ExtendedOrigin {
override val serviceNameMessageKey: String = "service-name.ItSa"
override val taxNameMessageKey: String = "payment-complete.tax-name.ItSa"
def reference(): String = "1097172564" //This would really come from the journey either pay-api or stored locally
def cardFeesPagePaymentMethods: Set[PaymentMethod] = Set(Bacs)
//todo add these when we do that ticket
def paymentMethods(): Set[PaymentMethod] = Set.empty
//todo add this when we do that ticket
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ trait ExtendedOrigin {
def serviceNameMessageKey: String
def taxNameMessageKey: String
def reference(): String
//denotes which links/payment methods to show on the card-fees page.
def cardFeesPagePaymentMethods: Set[PaymentMethod]
def paymentMethods(): Set[PaymentMethod]
def checkYourAnswersRows(): Seq[CheckYourAnswersRow]
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ class ExtendedPfP800 extends ExtendedOrigin {
override val serviceNameMessageKey: String = "add.message.key.here"
override val taxNameMessageKey: String = "payment-complete.tax-name.PfP800"
def reference(): String = "ma000003AP3022016" //This would really come from the journey either pay-api or stored locally
def paymentMethods(): Set[PaymentMethod] = Set(Card, Bacs)
def cardFeesPagePaymentMethods: Set[PaymentMethod] = Set.empty[PaymentMethod]
def paymentMethods(): Set[PaymentMethod] = Set() //Set(Card, Bacs)//todo will we use this?

def checkYourAnswersRows(): Seq[CheckYourAnswersRow] = {
Seq.empty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ package uk.gov.hmrc.cardpaymentfrontend.models.extendedorigins

import play.api.mvc.Call
import uk.gov.hmrc.cardpaymentfrontend.models.{CheckYourAnswersRow, Link}
import uk.gov.hmrc.cardpaymentfrontend.utils.{Bacs, Card, OneOffDirectDebit, OpenBanking, PaymentMethod}
import uk.gov.hmrc.cardpaymentfrontend.utils.PaymentMethods.{Bacs, Card, OneOffDirectDebit, OpenBanking}
import uk.gov.hmrc.cardpaymentfrontend.utils.PaymentMethod

object ExtendedPfSa extends ExtendedOrigin {
override val serviceNameMessageKey: String = "service-name.PfSa"
override val taxNameMessageKey: String = "payment-complete.tax-name.PfSa"
def reference(): String = "1097172564" //This would really come from the journey either pay-api or stored locally
def cardFeesPagePaymentMethods: Set[PaymentMethod] = Set(OpenBanking, OneOffDirectDebit)
def paymentMethods(): Set[PaymentMethod] = Set(Card, OpenBanking, OneOffDirectDebit, Bacs)

def checkYourAnswersRows(): Seq[CheckYourAnswersRow] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ package uk.gov.hmrc.cardpaymentfrontend.models.extendedorigins

import play.api.mvc.Call
import uk.gov.hmrc.cardpaymentfrontend.models.{CheckYourAnswersRow, Link}
import uk.gov.hmrc.cardpaymentfrontend.utils.{Bacs, Card, OpenBanking, PaymentMethod, VariableDirectDebit}
import uk.gov.hmrc.cardpaymentfrontend.utils.PaymentMethods._
import uk.gov.hmrc.cardpaymentfrontend.utils._

class ExtendedPfVat extends ExtendedOrigin {
override val serviceNameMessageKey: String = "add.message.key.here"
override val taxNameMessageKey: String = "payment-complete.tax-name.PfVat"
def reference(): String = "999964805"
def cardFeesPagePaymentMethods: Set[PaymentMethod] = Set.empty[PaymentMethod]
def paymentMethods(): Set[PaymentMethod] = Set(Card, OpenBanking, VariableDirectDebit, Bacs)

def checkYourAnswersRows(): Seq[CheckYourAnswersRow] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
package uk.gov.hmrc.cardpaymentfrontend.models.extendedorigins

import uk.gov.hmrc.cardpaymentfrontend.models.CheckYourAnswersRow
import uk.gov.hmrc.cardpaymentfrontend.utils.PaymentMethods.{OneOffDirectDebit, OpenBanking}
import uk.gov.hmrc.cardpaymentfrontend.utils._

object ExtendedPtaSa extends ExtendedOrigin {
override val serviceNameMessageKey: String = "service-name.PtaSa"
override val taxNameMessageKey: String = "payment-complete.tax-name.PtaSa"
def reference(): String = "1097172564" //This would really come from the journey either pay-api or stored locally
def cardFeesPagePaymentMethods: Set[PaymentMethod] = Set(OpenBanking, OneOffDirectDebit)
//todo add these when we do that ticket
def paymentMethods(): Set[PaymentMethod] = Set.empty
//todo add this when we do that ticket
Expand Down
27 changes: 13 additions & 14 deletions app/uk/gov/hmrc/cardpaymentfrontend/utils/OriginExtraInfo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,27 @@ package uk.gov.hmrc.cardpaymentfrontend.utils

import uk.gov.hmrc.cardpaymentfrontend.models.extendedorigins.{DefaultExtendedOrigin, ExtendedBtaSa, ExtendedItSa, ExtendedOrigin, ExtendedPfP800, ExtendedPfSa, ExtendedPfVat, ExtendedPtaSa}
import payapi.corcommon.model.{Origin, Origins}
import uk.gov.hmrc.cardpaymentfrontend.utils.PaymentMethods.{Bacs, Card, OneOffDirectDebit, OpenBanking, PrintableDirectDebit, VariableDirectDebit}

import javax.inject.{Inject, Singleton}
trait PaymentMethod

case object Card extends PaymentMethod
//todo should probably be in it's own file.
sealed trait PaymentMethod

case object OpenBanking extends PaymentMethod
object PaymentMethods {

case object OneOffDirectDebit extends PaymentMethod
case object Card extends PaymentMethod

case object VariableDirectDebit extends PaymentMethod
case object OpenBanking extends PaymentMethod

case object PrintableDirectDebit extends PaymentMethod
case object OneOffDirectDebit extends PaymentMethod

case object Bacs extends PaymentMethod
case object VariableDirectDebit extends PaymentMethod

case object PrintableDirectDebit extends PaymentMethod

case object Bacs extends PaymentMethod
}

//Probably a temporary class - it will be subsumed by the ExtendedOrigins in due course

Expand Down Expand Up @@ -126,13 +132,6 @@ class OriginExtraInfo @Inject() () {

def variableDirectDebitAllowed(origin: Origin): Boolean = paymentMethod(origin).contains(VariableDirectDebit)

// def lift(origin: Origin): ExtendedOrigin = {
// origin match {
// case Origins.PfSa => new ExtendedPfSa()
// case _ => new DefaultExtendedOrigin()
// }
// }

def lift(origin: Origin): ExtendedOrigin = {
origin match {
case Origins.PfSa => ExtendedPfSa
Expand Down
8 changes: 4 additions & 4 deletions app/uk/gov/hmrc/cardpaymentfrontend/views/FeesPage.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

@import uk.gov.hmrc.cardpaymentfrontend.models.Link
@import uk.gov.hmrc.cardpaymentfrontend.views.html.Layout
@import uk.gov.hmrc.cardpaymentfrontend.utils.{PaymentMethod, OpenBanking, VariableDirectDebit, OneOffDirectDebit}
@import uk.gov.hmrc.govukfrontend.views.Aliases.{Button, ErrorSummary, Hint, Input, Label}
@import uk.gov.hmrc.govukfrontend.views.html.components.{FormWithCSRF, GovukButton, GovukErrorSummary, GovukInput}
@import uk.gov.hmrc.govukfrontend.views.Implicits.{RichFormErrors, RichInput}
Expand All @@ -39,16 +38,17 @@ <h1 class = "govuk-heading-xl govuk-!-margin-bottom-9">@heading</h1>
<p id="para1" class="govuk-body">@messages("card-fees.para1")</p>
<p id="para2" class="govuk-body">@messages("card-fees.para2")</p>

<ul class="govuk-body">
@links.map {alt =>
<ul id="payment-type-list" class="govuk-body">
@links.map { alt =>
<li><a class="govuk-link" id=@alt.linkId href=@alt.href.url>@messages(alt.messageKey)</a></li>
}
<li id="personal-debit-card">@messages("card-fees.para2.personal-debit-card")</li>
</ul>

<p id="para3" class="govuk-body">@messages("card-fees.para3")</p>
<p id="para4" class="govuk-body">@messages("card-fees.para4")</p>

@formWithCSRF(action = uk.gov.hmrc.cardpaymentfrontend.controllers.routes.EmailAddressController.submit) {
@formWithCSRF(action = uk.gov.hmrc.cardpaymentfrontend.controllers.routes.FeesController.submit) {
@govukButton(Button(
id = Some("submit"),
content = Text(messages("continue"))
Expand Down
2 changes: 2 additions & 0 deletions conf/app.routes
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ GET /assets/*file controllers.Assets.versioned(pa
GET /email-address uk.gov.hmrc.cardpaymentfrontend.controllers.EmailAddressController.renderPage
POST /email-address uk.gov.hmrc.cardpaymentfrontend.controllers.EmailAddressController.submit

GET /card-fees uk.gov.hmrc.cardpaymentfrontend.controllers.FeesController.renderPageNew
POST /card-fees uk.gov.hmrc.cardpaymentfrontend.controllers.FeesController.submit
GET /card-fees0 uk.gov.hmrc.cardpaymentfrontend.controllers.FeesController.renderPage0
GET /card-fees1 uk.gov.hmrc.cardpaymentfrontend.controllers.FeesController.renderPage1
GET /card-fees2 uk.gov.hmrc.cardpaymentfrontend.controllers.FeesController.renderPage2
Expand Down
9 changes: 9 additions & 0 deletions conf/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ microservice {
host = localhost
port = 9057
}
pay-frontend {
protocol = http
host = localhost
port = 9056
}
}
}

Expand All @@ -62,4 +67,8 @@ urls {
govuk {
pay-another-way = "https://www.gov.uk/topic/dealing-with-hmrc/paying-hmrc"
}
pay-frontend {
bank-transfer = "/bac"
one-off-direct-debit = "/pay-by-one-off-direct-debit"
}
}
11 changes: 6 additions & 5 deletions conf/messages
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,19 @@ email-address.heading = What is your email address? (optional)
email-address.hint = We’ll only use this to confirm you sent a payment
email-address.error.invalid = Enter a valid email address or leave it blank

# card fees page
# Card fees page
card-fees.heading = Card fees
card-fees.para1 = There is a non-refundable fee if you pay by corporate credit card or corporate debit card.
card-fees.para2 = There is no fee if you pay by:
card-fees.para2.bank-account = bank account
card-fees.para2.open-banking = open banking
card-fees.para2.bank-transfer = bank transfer
card-fees.para2.open-banking = bank account
card-fees.para2.direct-debit = direct debit
card-fees.para2.one-off-direct-debit = Direct Debit (one-off payment)
card-fees.para2.personal-debit-card = personal debit card
card-fees.para3 = You cannot pay using a personal credit card.
card-fees.para4 = Allow 3 working days for your payment to reach HMRC’s bank account.
card-fees.para2.bank-account = bank account

# check your answers page
# Check your answers page
# some refactoring here to consolidate common phrases
check-your-answers.heading = Check your answers
check-your-answers.your-ref = This payment will show in your bank as
Expand Down
5 changes: 5 additions & 0 deletions conf/messages.cy
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ email-address.error.invalid = Nodwch gyfeiriad e-bost dilys neu gadewch yn wag
card-fees.heading = Ffioedd cerdyn
card-fees.para1 = Bydd ffi na ellir ei had-dalu yn cael ei chodi os talwch â cherdyn credyd corfforaethol neu gerdyn debyd corfforaethol.
card-fees.para2 = Nid oes ffi yn cael ei chodi os talwch drwy un o’r dulliau canlynol:
card-fees.para2.bank-transfer = drosglwyddiad banc
card-fees.para2.open-banking = cyfrif banc
card-fees.para2.direct-debit = ADD_ME
card-fees.para2.one-off-direct-debit = Debyd Uniongyrchol (taliad untro)
card-fees.para2.personal-debit-card = cerdyn debyd personol
card-fees.para3 = Ni allwch dalu â cherdyn credyd personol.
card-fees.para4 = Dylech ganiatáu 3 diwrnod gwaith i’ch taliad gyrraedd cyfrif banc CThEM.
Expand Down
Loading

0 comments on commit f0526b8

Please sign in to comment.