Use redsys_environment to choose the correct URL to send the payment to

This commit is contained in:
jordi fita mas 2023-10-27 17:03:50 +02:00
parent 0cbf973cbb
commit ac09fd77da
2 changed files with 12 additions and 2 deletions

View File

@ -17,7 +17,8 @@ import (
type paymentPage struct { type paymentPage struct {
*template.PublicPage *template.PublicPage
Request *redsys.SignedRequest Environment string
Request *redsys.SignedRequest
} }
func newPaymentPage(request *redsys.SignedRequest) *paymentPage { func newPaymentPage(request *redsys.SignedRequest) *paymentPage {
@ -29,6 +30,9 @@ func newPaymentPage(request *redsys.SignedRequest) *paymentPage {
func (p *paymentPage) MustRender(w http.ResponseWriter, r *http.Request, user *auth.User, company *auth.Company, conn *database.Conn) { func (p *paymentPage) MustRender(w http.ResponseWriter, r *http.Request, user *auth.User, company *auth.Company, conn *database.Conn) {
p.Setup(r, user, company, conn) p.Setup(r, user, company, conn)
if err := conn.QueryRow(r.Context(), "select environment from redsys where company_id = $1", company.ID).Scan(&p.Environment); err != nil && !database.ErrorIsNotFound(err) {
panic(err)
}
template.MustRenderPublic(w, r, user, company, "payment/request.gohtml", p) template.MustRenderPublic(w, r, user, company, "payment/request.gohtml", p)
} }

View File

@ -10,7 +10,13 @@
{{- /*gotype: dev.tandem.ws/tandem/camper/pkg/booking.paymentPage*/ -}} {{- /*gotype: dev.tandem.ws/tandem/camper/pkg/booking.paymentPage*/ -}}
<h2>{{( pgettext "Payment" "title" )}}</h2> <h2>{{( pgettext "Payment" "title" )}}</h2>
{{ with .Request -}} {{ with .Request -}}
<form action="https://sis-t.redsys.es:25443/sis/realizarPago" method="post"> <form
{{ if eq $.Environment "live" -}}
action="https://sis.redsys.es/sis/realizarPago"
{{- else -}}
action="https://sis-t.redsys.es:25443/sis/realizarPago"
{{- end }}
method="post">
<input type="hidden" name="Ds_MerchantParameters" value="{{ .MerchantParameters }}"/> <input type="hidden" name="Ds_MerchantParameters" value="{{ .MerchantParameters }}"/>
<input type="hidden" name="Ds_Signature" value="{{ .Signature }}"/> <input type="hidden" name="Ds_Signature" value="{{ .Signature }}"/>
<input type="hidden" name="Ds_SignatureVersion" value="{{ .SignatureVersion }}"/> <input type="hidden" name="Ds_SignatureVersion" value="{{ .SignatureVersion }}"/>