-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[JB][OPS-12861] wire up payments survey for Sa Origins (#16)
- Loading branch information
1 parent
99d805e
commit acbec88
Showing
36 changed files
with
824 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
app/uk/gov/hmrc/cardpaymentfrontend/actions/JourneyFinishedActionRefiner.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright 2024 HM Revenue & Customs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package uk.gov.hmrc.cardpaymentfrontend.actions | ||
|
||
import play.api.mvc.{ActionRefiner, Result, Results} | ||
|
||
import javax.inject.{Inject, Singleton} | ||
import scala.concurrent.{ExecutionContext, Future} | ||
|
||
@Singleton | ||
class JourneyFinishedActionRefiner @Inject() ()(implicit ec: ExecutionContext) extends ActionRefiner[JourneyRequest, JourneyRequest] { | ||
|
||
override protected[actions] def refine[A](request: JourneyRequest[A]): Future[Either[Result, JourneyRequest[A]]] = { | ||
if (request.journey.status.isTerminalState) Future.successful(Right(request)) | ||
else Future.successful(Left(Results.NotFound("Journey not in valid state"))) | ||
} | ||
|
||
override protected def executionContext: ExecutionContext = ec | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
app/uk/gov/hmrc/cardpaymentfrontend/connectors/PaymentsSurveyConnector.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright 2024 HM Revenue & Customs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package uk.gov.hmrc.cardpaymentfrontend.connectors | ||
|
||
import play.api.libs.json.Json | ||
import uk.gov.hmrc.cardpaymentfrontend.config.AppConfig | ||
import uk.gov.hmrc.cardpaymentfrontend.models.paymentssurvey.{PaymentSurveyJourneyRequest, SsjResponse} | ||
import uk.gov.hmrc.http.{HeaderCarrier, StringContextOps} | ||
import uk.gov.hmrc.http.client.HttpClientV2 | ||
import uk.gov.hmrc.http.HttpReads.Implicits._ | ||
|
||
import java.net.URL | ||
import javax.inject.{Inject, Singleton} | ||
import scala.concurrent.{ExecutionContext, Future} | ||
|
||
@Singleton | ||
class PaymentsSurveyConnector @Inject() ( | ||
appConfig: AppConfig, | ||
httpClient: HttpClientV2 | ||
)( | ||
implicit | ||
ec: ExecutionContext | ||
) { | ||
|
||
private val serviceURL: URL = url"${appConfig.paymentsSurveyBaseUrl}/payments-survey/journey/start" | ||
|
||
def startSurvey(surveyRequest: PaymentSurveyJourneyRequest)(implicit headerCarrier: HeaderCarrier): Future[SsjResponse] = { | ||
httpClient.post(serviceURL).withBody(Json.toJson(surveyRequest)).execute[SsjResponse] | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
app/uk/gov/hmrc/cardpaymentfrontend/controllers/PaymentsSurveyController.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright 2024 HM Revenue & Customs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package uk.gov.hmrc.cardpaymentfrontend.controllers | ||
|
||
import play.api.mvc.{Action, AnyContent, MessagesControllerComponents} | ||
import uk.gov.hmrc.cardpaymentfrontend.actions.{Actions, JourneyRequest} | ||
import uk.gov.hmrc.cardpaymentfrontend.services.PaymentsSurveyService | ||
import uk.gov.hmrc.play.bootstrap.frontend.controller.FrontendController | ||
|
||
import javax.inject.{Inject, Singleton} | ||
import scala.concurrent.ExecutionContext | ||
|
||
@Singleton | ||
class PaymentsSurveyController @Inject() ( | ||
actions: Actions, | ||
mcc: MessagesControllerComponents, | ||
paymentsSurveyService: PaymentsSurveyService | ||
)(implicit executionContext: ExecutionContext) extends FrontendController(mcc) { | ||
|
||
def startSurvey(): Action[AnyContent] = actions.journeyFinishedAction.async { implicit journeyRequest: JourneyRequest[AnyContent] => | ||
paymentsSurveyService | ||
.startPaySurvey(journeyRequest.journey) | ||
.map(surveyStartUrl => Redirect(surveyStartUrl.value)) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
app/uk/gov/hmrc/cardpaymentfrontend/models/paymentssurvey/AuditOptions.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright 2024 HM Revenue & Customs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package uk.gov.hmrc.cardpaymentfrontend.models.paymentssurvey | ||
|
||
import payapi.cardpaymentjourney.model.journey.{Journey, JourneySpecificData} | ||
import play.api.libs.json.{Json, OFormat} | ||
import play.api.mvc.Request | ||
import uk.gov.hmrc.cardpaymentfrontend.models.extendedorigins.ExtendedOrigin | ||
import uk.gov.hmrc.cardpaymentfrontend.requests.RequestSupport | ||
|
||
final case class AuditOptions( | ||
userType: String, | ||
journey: Option[String] = None, | ||
orderId: Option[String] = None, | ||
liability: Option[String] = None | ||
) | ||
|
||
object AuditOptions { | ||
|
||
@SuppressWarnings(Array("org.wartremover.warts.Any")) | ||
implicit val format: OFormat[AuditOptions] = Json.format[AuditOptions] | ||
|
||
def default(implicit r: Request[_]): AuditOptions = AuditOptions( | ||
userType = if (RequestSupport.isLoggedIn) "LoggedIn" else "LoggedOut" | ||
) | ||
|
||
def getAuditOptions(journey: Journey[JourneySpecificData], extendedOrigin: ExtendedOrigin)(implicit r: Request[_]): AuditOptions = { | ||
AuditOptions( | ||
userType = if (RequestSupport.isLoggedIn) "LoggedIn" else "LoggedOut", | ||
journey = Option(journey.status.entryName), | ||
orderId = journey.reference.map(_.value), | ||
liability = Some(extendedOrigin.surveyAuditName) | ||
) | ||
} | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
app/uk/gov/hmrc/cardpaymentfrontend/models/paymentssurvey/PaymentSurveyJourneyRequest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright 2024 HM Revenue & Customs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package uk.gov.hmrc.cardpaymentfrontend.models.paymentssurvey | ||
|
||
import play.api.libs.json.{Json, Format} | ||
|
||
final case class PaymentSurveyJourneyRequest( | ||
origin: String, | ||
returnMsg: String, | ||
returnHref: String, | ||
auditName: String, | ||
audit: AuditOptions, | ||
contentOptions: SurveyContentOptions | ||
) | ||
|
||
@SuppressWarnings(Array("org.wartremover.warts.Any")) | ||
object PaymentSurveyJourneyRequest { | ||
implicit val format: Format[PaymentSurveyJourneyRequest] = Json.format[PaymentSurveyJourneyRequest] | ||
} |
27 changes: 27 additions & 0 deletions
27
app/uk/gov/hmrc/cardpaymentfrontend/models/paymentssurvey/SsjResponse.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright 2024 HM Revenue & Customs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package uk.gov.hmrc.cardpaymentfrontend.models.paymentssurvey | ||
|
||
import payapi.cardpaymentjourney.model.journey.Url | ||
import play.api.libs.json.{Format, Json} | ||
|
||
final case class SsjResponse(journeyId: SurveyJourneyId, nextUrl: Url) | ||
|
||
@SuppressWarnings(Array("org.wartremover.warts.Any")) | ||
object SsjResponse { | ||
implicit val format: Format[SsjResponse] = Json.format | ||
} |
26 changes: 26 additions & 0 deletions
26
app/uk/gov/hmrc/cardpaymentfrontend/models/paymentssurvey/SurveyBannerTitle.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright 2024 HM Revenue & Customs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package uk.gov.hmrc.cardpaymentfrontend.models.paymentssurvey | ||
|
||
import play.api.libs.json.{Json, Format} | ||
|
||
final case class SurveyBannerTitle(englishValue: String, welshValue: Option[String] = None) | ||
|
||
@SuppressWarnings(Array("org.wartremover.warts.Any")) | ||
object SurveyBannerTitle { | ||
implicit val format: Format[SurveyBannerTitle] = Json.format[SurveyBannerTitle] | ||
} |
Oops, something went wrong.