Skip to content

Commit

Permalink
Merge pull request #1550 from ministryofjustice/MLPAB-2250-no-payment…
Browse files Browse the repository at this point in the history
…-when-no-payment

MLPAB-2250 Use pending payment behaviour for all non-payment scenarios
  • Loading branch information
hawx authored Oct 14, 2024
2 parents 246cd39 + 730b7fc commit e5e99a4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion internal/donor/donorpage/pay.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func Pay(
appPublicURL string,
) Handler {
return func(appData appcontext.Data, w http.ResponseWriter, r *http.Request, provided *donordata.Provided) error {
if provided.FeeType.IsNoFee() || provided.FeeType.IsHardshipFee() || provided.Tasks.PayForLpa.IsMoreEvidenceRequired() {
if provided.FeeAmount().Pence() == 0 || provided.Tasks.PayForLpa.IsMoreEvidenceRequired() {
provided.Tasks.PayForLpa = task.PaymentStatePending
if err := donorStore.Put(r.Context(), provided); err != nil {
return err
Expand Down
21 changes: 14 additions & 7 deletions internal/donor/donorpage/pay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,29 +99,36 @@ func TestPay(t *testing.T) {
}

func TestPayWhenPaymentNotRequired(t *testing.T) {
testCases := []pay.FeeType{
pay.NoFee,
pay.HardshipFee,
testCases := map[string]struct {
feeType pay.FeeType
previousFee pay.PreviousFee
}{
"no fee": {feeType: pay.NoFee},
"hardship fee": {feeType: pay.HardshipFee},
"previously hardship": {feeType: pay.RepeatApplicationFee, previousFee: pay.PreviousFeeHardship},
"previously exemption": {feeType: pay.RepeatApplicationFee, previousFee: pay.PreviousFeeExemption},
}

for _, feeType := range testCases {
t.Run(feeType.String(), func(t *testing.T) {
for name, tc := range testCases {
t.Run(name, func(t *testing.T) {
w := httptest.NewRecorder()
r, _ := http.NewRequest(http.MethodPost, "/", nil)

donorStore := newMockDonorStore(t)
donorStore.EXPECT().
Put(r.Context(), &donordata.Provided{
LpaID: "lpa-id",
FeeType: feeType,
FeeType: tc.feeType,
PreviousFee: tc.previousFee,
Tasks: donordata.Tasks{PayForLpa: task.PaymentStatePending},
EvidenceDelivery: pay.Upload,
}).
Return(nil)

err := Pay(nil, nil, donorStore, nil, "")(testAppData, w, r, &donordata.Provided{
LpaID: "lpa-id",
FeeType: feeType,
FeeType: tc.feeType,
PreviousFee: tc.previousFee,
EvidenceDelivery: pay.Upload,
})
resp := w.Result()
Expand Down

0 comments on commit e5e99a4

Please sign in to comment.