Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
hawx committed Oct 10, 2024
1 parent 7c0153a commit 5980cb5
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 4 deletions.
2 changes: 2 additions & 0 deletions internal/donor/donorpage/payment_confirmation.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ func PaymentConfirmation(logger Logger, tmpl template.Template, payClient PayCli
nextPage = donor.PathEvidenceSuccessfullyUploaded
} else if provided.EvidenceDelivery.IsPost() {
nextPage = donor.PathWhatHappensNextPostEvidence
} else if provided.FeeType.IsRepeatApplicationFee() {
nextPage = donor.PathEvidenceSuccessfullyUploaded
}

switch provided.Tasks.PayForLpa {
Expand Down
101 changes: 101 additions & 0 deletions internal/donor/donorpage/payment_confirmation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,107 @@ func TestGetPaymentConfirmationHalfFee(t *testing.T) {
assert.Equal(t, http.StatusOK, resp.StatusCode)
}

func TestGetPaymentConfirmationRepeatApplicationFee(t *testing.T) {
testcases := map[string]struct {
evidenceDelivery pay.EvidenceDelivery
nextPage donor.Path
}{
"empty": {
nextPage: donor.PathEvidenceSuccessfullyUploaded,
},
"upload": {
evidenceDelivery: pay.Upload,
nextPage: donor.PathEvidenceSuccessfullyUploaded,
},
"post": {
evidenceDelivery: pay.Post,
nextPage: donor.PathWhatHappensNextPostEvidence,
},
}

for name, tc := range testcases {
t.Run(name, func(t *testing.T) {
w := httptest.NewRecorder()
r, _ := http.NewRequest(http.MethodGet, "/payment-confirmation", nil)

payClient := newMockPayClient(t).
withASuccessfulPayment(8200, r.Context())

localizer := newMockLocalizer(t).
withEmailLocalizations()

testAppData.Localizer = localizer

template := newMockTemplate(t)
template.EXPECT().
Execute(w, &paymentConfirmationData{
App: testAppData,
PaymentReference: "123456789012",
FeeType: pay.RepeatApplicationFee,
NextPage: tc.nextPage,
EvidenceDelivery: tc.evidenceDelivery,
}).
Return(nil)

sessionStore := newMockSessionStore(t).
withPaySession(r).
withExpiredPaySession(r, w)

donorStore := newMockDonorStore(t)
donorStore.EXPECT().
Put(r.Context(), &donordata.Provided{
Type: lpadata.LpaTypePersonalWelfare,
Donor: donordata.Donor{FirstNames: "a", LastName: "b"},
LpaUID: "lpa-uid",
FeeType: pay.RepeatApplicationFee,
EvidenceDelivery: tc.evidenceDelivery,
CertificateProvider: donordata.CertificateProvider{
Email: "[email protected]",
},
PaymentDetails: []donordata.Payment{{
PaymentId: "abc123",
PaymentReference: "123456789012",
Amount: 8200,
}},
Tasks: donordata.Tasks{
PayForLpa: task.PaymentStatePending,
},
}).
Return(nil)

eventClient := newMockEventClient(t)
eventClient.EXPECT().
SendPaymentReceived(r.Context(), event.PaymentReceived{
UID: "lpa-uid",
PaymentID: "abc123",
Amount: 8200,
}).
Return(nil)

notifyClient := newMockNotifyClient(t).
withEmailPersonalizations(r.Context(), "£82")

err := PaymentConfirmation(newMockLogger(t), template.Execute, payClient, donorStore, sessionStore, nil, nil, eventClient, notifyClient)(testAppData, w, r, &donordata.Provided{
LpaUID: "lpa-uid",
FeeType: pay.RepeatApplicationFee,
EvidenceDelivery: tc.evidenceDelivery,
CertificateProvider: donordata.CertificateProvider{
Email: "[email protected]",
},
Tasks: donordata.Tasks{
PayForLpa: task.PaymentStateInProgress,
},
Donor: donordata.Donor{FirstNames: "a", LastName: "b"},
Type: lpadata.LpaTypePersonalWelfare,
})
resp := w.Result()

assert.Nil(t, err)
assert.Equal(t, http.StatusOK, resp.StatusCode)
})
}
}

func TestGetPaymentConfirmationApprovedOrDenied(t *testing.T) {
for _, taskState := range []task.PaymentState{task.PaymentStateApproved, task.PaymentStateDenied} {
t.Run(taskState.String(), func(t *testing.T) {
Expand Down
5 changes: 4 additions & 1 deletion lang/cy.json
Original file line number Diff line number Diff line change
Expand Up @@ -927,11 +927,14 @@
"nothingHardship": "Dim - ni dalais am fy mod wedi cael hepgoriad oherwydd caledi",
"howMuchYouPreviouslyPaid": "y swm wnaethoch dalu o’r blaen",
"evidenceSuccessfullyUploaded": "Mae’r dystiolaeth wedi’i huwchlwytho’n llwyddiannus",
"weWillReviewYourLpaApplicationAndSupportingEvidence": "<p class=\"govuk-body\">Byddwn yn adolygu’ch cais am LPA a’ch tystiolaeth ategol.</p><h2 class=\"govuk-heading-m\">Beth fydd yn digwydd nesaf</h2><h3 class=\"govuk-heading-s\">Llofnodi’ch LPA</h3><p class=\"govuk-body\">Gallwch lofnodi’ch LPA tra byddwn ni yn adolygu’ch cais. Rhaid i’ch darparwr tystysgrif fod yn bresennol fel tyst pan fyddwch yn ei llofnodi.</p><p class=\"govuk-body\">Fodd bynnag, ni fyddwn yn cysylltu â’ch darparwr tystysgrif ynghylch darparu ei dystysgrif nes bydd eich {{.Application}} wedi cael ei gymeradwyo.</p><h3 class=\"govuk-heading-s\">Os bydd eich cais yn llwyddiannus</h3><p class=\"govuk-body\">Unwaith y byddwn wedi cymeradwyo’ch taliad, byddwn yn cysylltu â’ch darparwr tystysgrif er mwyn iddo ddarparu ei dystysgrif.</p><h3 class=\"govuk-heading-s\">Os na fydd eich cais yn llwyddiannus</h3><p class=\"govuk-body\">Byddwn yn cysylltu â chi os bydd arnom angen mwy o wybodaeth neu os nad oedd eich cais yn llwyddiannus.</p>",
"referenceNumberStored": "Welsh",
"weWillReviewYourLpaApplicationAndSupportingEvidence": "Byddwn yn adolygu’ch cais am LPA a’ch tystiolaeth ategol.",
"weWillReviewYourLpaApplication": "Welsh",
"youCanStillSignYourLpa": "<h3 class=\"govuk-heading-s\">Welsh</h3><p class=\"govuk-body\">Welsh</p><p class=\"govuk-body\">Welsh {{ .Application }} Welsh</p>",
"ifYourApplicationIsSuccessful": "Os bydd eich cais yn llwyddiannus",
"onceWeHaveApprovedYourPayment": "Unwaith y byddwn wedi cymeradwyo’ch taliad, byddwn yn cysylltu â’ch darparwr tystysgrif er mwyn iddo ddarparu ei dystysgrif.",
"onceWeHaveApprovedYourRequest": "Welsh",
"onceWeHaveApprovedYourRepeatApplication": "Welsh",
"ifYourApplicationIsNotSuccessful": "Os na fydd eich cais yn llwyddiannus",
"weWillContactYouIfWeNeedMoreInformation": "Byddwn yn cysylltu â chi os bydd arnom angen mwy o wybodaeth neu os nad oedd eich cais yn llwyddiannus.",
"applicationNoFee": "cais i beidio â thalu ffi",
Expand Down
5 changes: 4 additions & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -874,11 +874,14 @@
"nothingHardship": "Nothing - I paid no fee because I got a hardship fee waiver",
"howMuchYouPreviouslyPaid": "how much you previously paid",
"evidenceSuccessfullyUploaded": "Evidence successfully uploaded",
"weWillReviewYourLpaApplicationAndSupportingEvidence": "<p class=\"govuk-body\">We will review your LPA application and supporting evidence.</p><h2 class=\"govuk-heading-m\">What happens next</h2>",
"referenceNumberStored": "Reference number stored",
"weWillReviewYourLpaApplicationAndSupportingEvidence": "We will review your LPA application and supporting evidence.",
"weWillReviewYourLpaApplication": "We will review your LPA application.",
"youCanStillSignYourLpa": "<h3 class=\"govuk-heading-s\">Sign your LPA</h3><p class=\"govuk-body\">You can still sign your LPA while we’re reviewing your application. Your certificate provider must be there as a witness when you sign it.</p><p class=\"govuk-body\">However, we will not contact your certificate provider to provide their certificate until your {{ .Application }} has been approved.</p>",
"ifYourApplicationIsSuccessful": "If your application is successful",
"onceWeHaveApprovedYourPayment": "Once we have approved your payment, we will contact your certificate provider to provide their certificate.",
"onceWeHaveApprovedYourRequest": "Once we have approved your request, we will contact your certificate provider to provide their certificate.",
"onceWeHaveApprovedYourRepeatApplication": "Once we have approved your repeat application, we will contact your certificate provider to provide their certificate.",
"ifYourApplicationIsNotSuccessful": "If your application is not successful",
"weWillContactYouIfWeNeedMoreInformation": "We will contact you if we need more information or if your application is unsuccessful.",
"applicationNoFee": "application to pay no fee",
Expand Down
20 changes: 18 additions & 2 deletions web/template/donor/evidence_successfully_uploaded.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,24 @@
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<div class="govuk-panel govuk-panel--confirmation">
<h1 class="govuk-panel__title">{{ tr .App "evidenceSuccessfullyUploaded" }}</h1>
<h1 class="govuk-panel__title">
{{ if and .Donor.FeeType.IsRepeatApplicationFee (or .Donor.PreviousFee.IsPreviousFeeFull .Donor.PreviousFee.Empty) }}
{{ tr .App "referenceNumberStored" }}
{{ else }}
{{ tr .App "evidenceSuccessfullyUploaded" }}
{{ end }}
</h1>
</div>

{{ trHtml .App "weWillReviewYourLpaApplicationAndSupportingEvidence" }}
<p class="govuk-body">
{{ if and .Donor.FeeType.IsRepeatApplicationFee (or .Donor.PreviousFee.IsPreviousFeeFull .Donor.PreviousFee.Empty) }}
{{ tr .App "weWillReviewYourLpaApplication" }}
{{ else }}
{{ tr .App "weWillReviewYourLpaApplicationAndSupportingEvidence" }}
{{ end }}
</p>

<h2 class="govuk-heading-m">{{ tr .App "whatHappensNext" }}</h2>

{{ if .Donor.SignedAt.IsZero }}
{{ trFormatHtml .App "youCanStillSignYourLpa" "Application" (printf "application%s" .Donor.FeeType.String | tr .App) }}
Expand All @@ -19,6 +33,8 @@
<p class="govuk-body">
{{ if .Donor.FeeType.IsNoFee }}
{{ tr .App "onceWeHaveApprovedYourRequest" }}
{{ else if and .Donor.FeeType.IsRepeatApplicationFee }}
{{ tr .App "onceWeHaveApprovedYourRepeatApplication" }}
{{ else }}
{{ tr .App "onceWeHaveApprovedYourPayment" }}
{{ end }}
Expand Down
2 changes: 2 additions & 0 deletions web/template/donor/what_happens_next_post_evidence.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
<p class="govuk-body">
{{ if .Donor.FeeType.IsNoFee }}
{{ tr .App "onceWeHaveApprovedYourRequest" }}
{{ else if and .Donor.FeeType.IsRepeatApplicationFee }}
{{ tr .App "onceWeHaveApprovedYourRepeatApplication" }}
{{ else }}
{{ tr .App "onceWeHaveApprovedYourPayment" }}
{{ end }}
Expand Down

0 comments on commit 5980cb5

Please sign in to comment.