16
16
17
17
package uk .gov .hmrc .cardpaymentfrontend .controllers
18
18
19
- import payapi .corcommon .model .{ Origin , Origins }
19
+ import payapi .corcommon .model .Origin
20
20
import play .api .mvc .{Action , AnyContent , Call , MessagesControllerComponents }
21
21
import uk .gov .hmrc .cardpaymentfrontend .actions .{Actions , JourneyRequest }
22
22
import uk .gov .hmrc .cardpaymentfrontend .config .AppConfig
23
- import uk .gov .hmrc .cardpaymentfrontend .models .Link
23
+ import uk .gov .hmrc .cardpaymentfrontend .models .extendedorigins .ExtendedOrigin .OriginExtended
24
+ import uk .gov .hmrc .cardpaymentfrontend .models .{Link , PaymentMethod }
24
25
import uk .gov .hmrc .cardpaymentfrontend .requests .RequestSupport
25
- import uk .gov .hmrc .cardpaymentfrontend .utils .{OriginExtraInfo , PaymentMethod , PaymentMethods }
26
26
import uk .gov .hmrc .cardpaymentfrontend .views .html .FeesPage
27
27
import uk .gov .hmrc .play .bootstrap .frontend .controller .FrontendController
28
28
29
29
import javax .inject .{Inject , Singleton }
30
30
31
31
@ Singleton
32
32
class FeesController @ Inject () (
33
- actions : Actions ,
34
- appConfig : AppConfig ,
35
- feesPage : FeesPage ,
36
- mcc : MessagesControllerComponents ,
37
- originExtraInfo : OriginExtraInfo ,
38
- requestSupport : RequestSupport
33
+ actions : Actions ,
34
+ appConfig : AppConfig ,
35
+ feesPage : FeesPage ,
36
+ mcc : MessagesControllerComponents ,
37
+ requestSupport : RequestSupport
39
38
) extends FrontendController (mcc) {
40
39
41
- private [controllers] def twoDirectDebitsPrimaryLink (origin : Origin ): Option [Link ] = {
42
- origin match {
43
- case Origins .BtaEpayeBill => Some (Link (
44
- href = Call (" GET" , " http://SomeDDUrl" ),
45
- linkId = " direct-debit-link-both-primary" ,
46
- messageKey = " card-fees.para2.direct-debit"
47
- ))
48
- case Origins .PfMgd => Some (Link (
49
- href = Call (" GET" , " http://SomeDDUrl" ),
50
- linkId = " direct-debit-link-both-primary" ,
51
- messageKey = " card-fees.para2.direct-debit"
52
- ))
53
- case _ => None
54
- }
55
- }
56
-
57
- private [controllers] def twoDirectDebitsSecondaryLink (origin : Origin ): Option [Link ] = {
58
- origin match {
59
- case Origins .BtaEpayeBill => Some (Link (
60
- href = Call (" GET" , " http://SomeDDUrl" ),
61
- linkId = " direct-debit-link-both-secondary" ,
62
- messageKey = " card-fees.para2.direct-debit"
63
- ))
64
- case Origins .PfMgd => Some (Link (
65
- href = Call (" GET" , " http://SomeDDUrl" ),
66
- linkId = " direct-debit-link-both-secondary" ,
67
- messageKey = " card-fees.para2.direct-debit"
68
- ))
69
- case _ => None
70
- }
71
- }
72
- private [controllers] def altPaymentLinks (origin : Origin ): Seq [Link ] = {
73
- val bacsLink = Seq (
74
- Link (
75
- href = Call (" GET" , " http://SomeURL" ),
76
- linkId = " bank-account-link-primary" ,
77
- messageKey = " card-fees.para2.bank-account"
78
- )
79
- )
80
-
81
- val openBankingLink = if (originExtraInfo.openBankingAllowed(origin)) {
82
- Seq (Link (
83
- href = Call (" GET" , " http://SomeURLOpenBankingUrl" ),
84
- linkId = " open-banking-link" ,
85
- messageKey = " card-fees.para2.open-banking"
86
- ))
87
- } else Seq .empty[Link ]
88
-
89
- val oneKindOfDDCondition : Boolean =
90
- (originExtraInfo.variableDirectDebitAllowed(origin) && ! originExtraInfo.oneOffDirectDebitAllowed(origin)) ||
91
- (! originExtraInfo.variableDirectDebitAllowed(origin) && originExtraInfo.oneOffDirectDebitAllowed(origin))
92
-
93
- val oneKindOfDDlink = if (oneKindOfDDCondition) {
94
- Seq (Link (
95
- href = Call (" GET" , " http://SomeDDUrl" ),
96
- linkId = " direct-debit-link" ,
97
- messageKey = " card-fees.para2.direct-debit"
98
- ))
99
- } else Seq .empty[Link ]
100
-
101
- val twoKindsOfDDPrimary = twoDirectDebitsPrimaryLink(origin) match {
102
- case Some (link) => Seq (link)
103
- case None => Seq .empty[Link ]
104
- }
105
-
106
- val twoKindsOfDDSecondary = twoDirectDebitsSecondaryLink(origin) match {
107
- case Some (link) => Seq (link)
108
- case None => Seq .empty[Link ]
109
- }
110
-
111
- bacsLink ++ openBankingLink ++ oneKindOfDDlink ++ twoKindsOfDDSecondary ++ twoKindsOfDDPrimary
112
- }
113
-
114
- // Note that when the Origin system is available this will be replaced with something more sensible
115
- def renderPage (origin : Origin ): Action [AnyContent ] = Action { implicit request =>
116
- val altPayments = altPaymentLinks(origin)
117
- if (altPayments.isEmpty) Redirect (" http://nextpage.html" )
118
- else Ok (feesPage(altPayments))
119
- }
120
-
121
- def renderPage0 (): Action [AnyContent ] = renderPage(Origins .AppSimpleAssessment )
122
-
123
- // Show open banking link
124
- def renderPage1 (): Action [AnyContent ] = renderPage(Origins .PfChildBenefitRepayments )
125
-
126
- // Show Variable Direct Debit link
127
- def renderPage2 (): Action [AnyContent ] = renderPage(Origins .PfSdil )
128
-
129
- // Show one off direct debit link
130
- def renderPage3 (): Action [AnyContent ] = renderPage(Origins .PfTpes )
131
-
132
- // Two kinds of DD with a primary link
133
- def renderPage4 (): Action [AnyContent ] = renderPage(Origins .BtaEpayeBill )
134
-
135
- // Two kinds of DD with secondary link
136
- def renderPage5 (): Action [AnyContent ] = renderPage(Origins .PfMgd )
137
-
138
40
import requestSupport ._
139
41
140
- def renderPageNew () : Action [AnyContent ] = actions.journeyAction { implicit journeyRequest : JourneyRequest [AnyContent ] =>
42
+ def renderPage : Action [AnyContent ] = actions.journeyAction { implicit journeyRequest : JourneyRequest [AnyContent ] =>
141
43
val altPayments = linksAvailableOnFeesPage(journeyRequest.journey.origin)
142
44
if (altPayments.isEmpty) Redirect (" http://nextpage.html" )
143
45
else Ok (feesPage(altPayments))
@@ -150,12 +52,11 @@ class FeesController @Inject() (
150
52
private [controllers] def paymentMethodToBeShown (paymentMethod : PaymentMethod , paymentMethods : Set [PaymentMethod ]): Boolean = paymentMethods.contains(paymentMethod)
151
53
152
54
private [controllers] def linksAvailableOnFeesPage (origin : Origin ): Seq [Link ] = {
153
-
154
- val extendedOrigin = originExtraInfo.lift(origin)
55
+ val extendedOrigin = origin.lift
155
56
val paymentMethodsToShow : Set [PaymentMethod ] = extendedOrigin.cardFeesPagePaymentMethods
156
- val showOpenBankingLink : Boolean = paymentMethodToBeShown(PaymentMethods .OpenBanking , paymentMethodsToShow)
157
- val showBankTransferLink : Boolean = paymentMethodToBeShown(PaymentMethods .Bacs , paymentMethodsToShow)
158
- val showOneOffDirectDebitLink : Boolean = paymentMethodToBeShown(PaymentMethods .OneOffDirectDebit , paymentMethodsToShow)
57
+ val showOpenBankingLink : Boolean = paymentMethodToBeShown(PaymentMethod .OpenBanking , paymentMethodsToShow)
58
+ val showBankTransferLink : Boolean = paymentMethodToBeShown(PaymentMethod .Bacs , paymentMethodsToShow)
59
+ val showOneOffDirectDebitLink : Boolean = paymentMethodToBeShown(PaymentMethod .OneOffDirectDebit , paymentMethodsToShow)
159
60
160
61
val maybeOpenBankingLink = if (showOpenBankingLink) {
161
62
Seq (Link (
0 commit comments