-
Notifications
You must be signed in to change notification settings - Fork 2
/
send_us_your_evidence_by_post.go
41 lines (34 loc) · 1.21 KB
/
send_us_your_evidence_by_post.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package donor
import (
"net/http"
"github.com/ministryofjustice/opg-go-common/template"
"github.com/ministryofjustice/opg-modernising-lpa/internal/actor"
"github.com/ministryofjustice/opg-modernising-lpa/internal/event"
"github.com/ministryofjustice/opg-modernising-lpa/internal/page"
"github.com/ministryofjustice/opg-modernising-lpa/internal/pay"
"github.com/ministryofjustice/opg-modernising-lpa/internal/validation"
)
type sendUsYourEvidenceByPostData struct {
App page.AppData
Errors validation.List
FeeType pay.FeeType
}
func SendUsYourEvidenceByPost(tmpl template.Template, payer Payer, eventClient EventClient) Handler {
return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error {
data := &sendUsYourEvidenceByPostData{
App: appData,
FeeType: donor.FeeType,
}
if r.Method == http.MethodPost {
if err := eventClient.SendReducedFeeRequested(r.Context(), event.ReducedFeeRequested{
UID: donor.LpaUID,
RequestType: donor.FeeType.String(),
EvidenceDelivery: donor.EvidenceDelivery.String(),
}); err != nil {
return err
}
return payer.Pay(appData, w, r, donor)
}
return tmpl(w, data)
}
}