Use pre-authorization to accept payment, rather than charge

Customer wants this because the booking is not automatically created,
thus it is possible to overbook.  They want to accept the payment of
those that they can actually book.
This commit is contained in:
jordi fita mas 2024-03-24 22:06:59 +01:00
parent d71d974abd
commit 72f8a329d2
7 changed files with 270 additions and 130 deletions

View File

@ -2,6 +2,7 @@ package payment
import (
"context"
"fmt"
"net/http"
"time"
@ -9,6 +10,7 @@ import (
"dev.tandem.ws/tandem/camper/pkg/database"
httplib "dev.tandem.ws/tandem/camper/pkg/http"
"dev.tandem.ws/tandem/camper/pkg/locale"
"dev.tandem.ws/tandem/camper/pkg/redsys"
"dev.tandem.ws/tandem/camper/pkg/template"
"dev.tandem.ws/tandem/camper/pkg/uuid"
)
@ -67,12 +69,12 @@ func (h *AdminHandler) Handler(user *auth.User, company *auth.Company, conn *dat
}
panic(err)
}
h.paymentHandler(user, company, payment).ServeHTTP(w, r)
h.paymentHandler(user, company, conn, payment).ServeHTTP(w, r)
}
})
}
func (h *AdminHandler) paymentHandler(user *auth.User, company *auth.Company, payment *paymentDetails) http.Handler {
func (h *AdminHandler) paymentHandler(user *auth.User, company *auth.Company, conn *database.Conn, payment *paymentDetails) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
var head string
head, r.URL.Path = httplib.ShiftPath(r.URL.Path)
@ -81,6 +83,20 @@ func (h *AdminHandler) paymentHandler(user *auth.User, company *auth.Company, pa
case "":
switch r.Method {
case http.MethodGet:
if payment.Status == StatusPreAuthenticated {
var err error
if err = conn.QueryRow(r.Context(), "select environment from redsys where company_id = $1", company.ID).Scan(&payment.Environment); err != nil && !database.ErrorIsNotFound(err) {
panic(err)
}
payment.AcceptPreauthRequest, err = payment.createRequest(r, user, company, conn, redsys.TransactionTypePreauthConfirm)
if err != nil {
panic(err)
}
payment.VoidPreauthRequest, err = payment.createRequest(r, user, company, conn, redsys.TransactionTypePreauthVoid)
if err != nil {
panic(err)
}
}
payment.MustRender(w, r, user, company)
default:
httplib.MethodNotAllowed(w, r, http.MethodGet)
@ -164,6 +180,7 @@ func (page *paymentIndex) MustRender(w http.ResponseWriter, r *http.Request, use
type paymentDetails struct {
ID int
Slug string
Reference string
CampsiteType string
ArrivalDate time.Time
@ -185,6 +202,9 @@ type paymentDetails struct {
UpdatedAt time.Time
Options []*paymentOption
Customer *paymentCustomer
Environment string
AcceptPreauthRequest *redsys.SignedRequest
VoidPreauthRequest *redsys.SignedRequest
}
type paymentOption struct {
@ -206,6 +226,7 @@ type paymentCustomer struct {
func fetchPaymentDetails(ctx context.Context, conn *database.Conn, slug string, locale *locale.Locale) (*paymentDetails, error) {
row := conn.QueryRow(ctx, `
select payment_id
, payment.slug
, payment.reference
, coalesce(campsite_type_i18n.name, campsite_type.name)
, arrival_date
@ -238,6 +259,7 @@ func fetchPaymentDetails(ctx context.Context, conn *database.Conn, slug string,
details := &paymentDetails{}
if err := row.Scan(
&details.ID,
&details.Slug,
&details.Reference,
&details.CampsiteType,
&details.ArrivalDate,
@ -334,6 +356,22 @@ func fetchPaymentCustomer(ctx context.Context, conn *database.Conn, paymentID in
return customer, nil
}
func (f *paymentDetails) createRequest(r *http.Request, user *auth.User, company *auth.Company, conn *database.Conn, transactionType redsys.TransactionType) (*redsys.SignedRequest, error) {
schema := httplib.Protocol(r)
authority := httplib.Host(r)
paymentURL := fmt.Sprintf("%s://%s/admin/payments/%s", schema, authority, f.Slug)
request := redsys.Request{
TransactionType: transactionType,
Amount: f.DownPayment,
OrderNumber: f.Reference,
SuccessURL: paymentURL,
FailureURL: paymentURL,
NotificationURL: fmt.Sprintf("%s/notification", publicBaseURL(r, user, f.Slug)),
ConsumerLanguage: user.Locale.Language,
}
return request.Sign(r.Context(), conn, company)
}
func (f *paymentDetails) MustRender(w http.ResponseWriter, r *http.Request, user *auth.User, company *auth.Company) {
template.MustRenderAdmin(w, r, user, company, "payment/details.gohtml", f)
}

View File

@ -21,6 +21,7 @@ import (
const (
StatusCompleted = "completed"
StatusPreAuthenticated = "preauth"
)
type PublicHandler struct {
@ -101,11 +102,9 @@ type Payment struct {
}
func (payment *Payment) createRequest(r *http.Request, user *auth.User, company *auth.Company, conn *database.Conn) (*redsys.SignedRequest, error) {
schema := httplib.Protocol(r)
authority := httplib.Host(r)
baseURL := fmt.Sprintf("%s://%s/%s/payments/%s", schema, authority, user.Locale.Language, payment.Slug)
baseURL := publicBaseURL(r, user, payment.Slug)
request := redsys.Request{
TransactionType: redsys.TransactionTypeCharge,
TransactionType: redsys.TransactionTypePreauth,
Amount: payment.DownPayment,
OrderNumber: payment.Reference,
Product: user.Locale.Pgettext("Campsite Booking", "order product name"),
@ -117,6 +116,12 @@ func (payment *Payment) createRequest(r *http.Request, user *auth.User, company
return request.Sign(r.Context(), conn, company)
}
func publicBaseURL(r *http.Request, user *auth.User, slug string) string {
schema := httplib.Protocol(r)
authority := httplib.Host(r)
return fmt.Sprintf("%s://%s/%s/payments/%s", schema, authority, user.Locale.Language, slug)
}
type paymentPage struct {
*template.PublicPage
Environment string
@ -248,7 +253,7 @@ func handleNotification(w http.ResponseWriter, r *http.Request, user *auth.User,
return
}
switch status {
case StatusCompleted:
case StatusPreAuthenticated:
if err := sendEmail(r, conn, payment, company, user.Locale); err != nil {
log.Println("Could not send email:", err)
}

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: camper\n"
"Report-Msgid-Bugs-To: jordi@tandem.blog\n"
"POT-Creation-Date: 2024-03-14 22:05+0100\n"
"POT-Creation-Date: 2024-03-24 21:59+0100\n"
"PO-Revision-Date: 2024-02-06 10:04+0100\n"
"Last-Translator: jordi fita mas <jordi@tandem.blog>\n"
"Language-Team: Catalan <ca@dodds.net>\n"
@ -72,14 +72,14 @@ msgid "We have successfully received the payment for the booking with the follow
msgstr "Hem rebut amb èxit el pagament de la reserva amb els següents detalls:"
#: web/templates/mail/payment/details.gotxt:7
#: web/templates/admin/payment/details.gohtml:19
#: web/templates/admin/payment/details.gohtml:49
msgctxt "title"
msgid "Payment"
msgstr "Pagament"
#: web/templates/mail/payment/details.gotxt:9
#: web/templates/admin/payment/index.gohtml:21
#: web/templates/admin/payment/details.gohtml:22
#: web/templates/admin/payment/details.gohtml:52
#: web/templates/admin/booking/index.gohtml:21
msgctxt "header"
msgid "Reference"
@ -87,20 +87,20 @@ msgstr "Referència"
#: web/templates/mail/payment/details.gotxt:10
#: web/templates/admin/payment/index.gohtml:22
#: web/templates/admin/payment/details.gohtml:26
#: web/templates/admin/payment/details.gohtml:56
#: web/templates/admin/booking/index.gohtml:25
msgctxt "header"
msgid "Status"
msgstr "Estat"
#: web/templates/mail/payment/details.gotxt:11
#: web/templates/admin/payment/details.gohtml:30
#: web/templates/admin/payment/details.gohtml:60
msgctxt "payment header"
msgid "Created at"
msgstr "Creat el"
#: web/templates/mail/payment/details.gotxt:12
#: web/templates/admin/payment/details.gohtml:34
#: web/templates/admin/payment/details.gohtml:64
msgctxt "payment header"
msgid "Last updated at"
msgstr "Actualitzat per darrera vegada el"
@ -108,32 +108,32 @@ msgstr "Actualitzat per darrera vegada el"
#: web/templates/mail/payment/details.gotxt:14
#: web/templates/public/layout.gohtml:71
#: web/templates/public/booking/page.gohtml:7
#: web/templates/admin/payment/details.gohtml:41
#: web/templates/admin/payment/details.gohtml:71
msgctxt "title"
msgid "Booking"
msgstr "Reserva"
#: web/templates/mail/payment/details.gotxt:16
#: web/templates/public/booking/fields.gohtml:14
#: web/templates/admin/payment/details.gohtml:44
#: web/templates/admin/payment/details.gohtml:74
msgctxt "title"
msgid "Accommodation"
msgstr "Allotjament"
#: web/templates/mail/payment/details.gotxt:17
#: web/templates/admin/payment/details.gohtml:48
#: web/templates/admin/payment/details.gohtml:78
msgctxt "header"
msgid "Area preferences"
msgstr "Preferències dàrea"
#: web/templates/mail/payment/details.gotxt:18
#: web/templates/admin/payment/details.gohtml:52
#: web/templates/admin/payment/details.gohtml:82
msgctxt "input"
msgid "ACSI card?"
msgstr "Targeta ACSI?"
#: web/templates/mail/payment/details.gotxt:18
#: web/templates/admin/payment/details.gohtml:53
#: web/templates/admin/payment/details.gohtml:83
#: web/templates/admin/campsite/index.gohtml:41
#: web/templates/admin/campsite/type/index.gohtml:53
#: web/templates/admin/season/index.gohtml:44
@ -143,7 +143,7 @@ msgid "Yes"
msgstr "Sí"
#: web/templates/mail/payment/details.gotxt:18
#: web/templates/admin/payment/details.gohtml:53
#: web/templates/admin/payment/details.gohtml:83
#: web/templates/admin/campsite/index.gohtml:41
#: web/templates/admin/campsite/type/index.gohtml:53
#: web/templates/admin/season/index.gohtml:44
@ -155,7 +155,7 @@ msgstr "No"
#: web/templates/mail/payment/details.gotxt:19
#: web/templates/public/campsite/dates.gohtml:4
#: web/templates/public/booking/fields.gohtml:30
#: web/templates/admin/payment/details.gohtml:56
#: web/templates/admin/payment/details.gohtml:86
msgctxt "input"
msgid "Arrival date"
msgstr "Data darribada"
@ -163,47 +163,47 @@ msgstr "Data darribada"
#: web/templates/mail/payment/details.gotxt:20
#: web/templates/public/campsite/dates.gohtml:15
#: web/templates/public/booking/fields.gohtml:41
#: web/templates/admin/payment/details.gohtml:60
#: web/templates/admin/payment/details.gohtml:90
msgctxt "input"
msgid "Departure date"
msgstr "Data de sortida"
#: web/templates/mail/payment/details.gotxt:21
#: web/templates/admin/payment/details.gohtml:64
#: web/templates/admin/payment/details.gohtml:94
msgctxt "cart"
msgid "Nights"
msgstr "Nits"
#: web/templates/mail/payment/details.gotxt:22
#: web/templates/public/booking/fields.gohtml:60
#: web/templates/admin/payment/details.gohtml:68
#: web/templates/admin/payment/details.gohtml:98
msgctxt "input"
msgid "Adults aged 17 or older"
msgstr "Adults de 17 anys o més"
#: web/templates/mail/payment/details.gotxt:23
#: web/templates/public/booking/fields.gohtml:71
#: web/templates/admin/payment/details.gohtml:72
#: web/templates/admin/payment/details.gohtml:102
msgctxt "input"
msgid "Teenagers from 11 to 16 years old"
msgstr "Adolescents dentre 11 i 16 anys"
#: web/templates/mail/payment/details.gotxt:24
#: web/templates/public/booking/fields.gohtml:82
#: web/templates/admin/payment/details.gohtml:76
#: web/templates/admin/payment/details.gohtml:106
msgctxt "input"
msgid "Children from 2 to 10 years old"
msgstr "Nens dentre 2 i 10 anys"
#: web/templates/mail/payment/details.gotxt:25
#: web/templates/public/booking/fields.gohtml:100
#: web/templates/admin/payment/details.gohtml:80
#: web/templates/admin/payment/details.gohtml:110
msgctxt "input"
msgid "Dogs"
msgstr "Gossos"
#: web/templates/mail/payment/details.gotxt:26
#: web/templates/admin/payment/details.gohtml:84 pkg/booking/cart.go:197
#: web/templates/admin/payment/details.gohtml:114 pkg/booking/cart.go:197
msgctxt "cart"
msgid "Tourist tax"
msgstr "Impost turístic"
@ -216,13 +216,13 @@ msgstr "Total"
#: web/templates/mail/payment/details.gotxt:28
#: web/templates/public/booking/fields.gohtml:230
#: web/templates/admin/payment/details.gohtml:88
#: web/templates/admin/payment/details.gohtml:118
msgctxt "cart"
msgid "Down payment"
msgstr "A compte"
#: web/templates/mail/payment/details.gotxt:31
#: web/templates/admin/payment/details.gohtml:96
#: web/templates/admin/payment/details.gohtml:126
#: web/templates/admin/campsite/type/option/form.gohtml:18
#: web/templates/admin/campsite/type/option/index.gohtml:6
#: web/templates/admin/campsite/type/option/index.gohtml:17
@ -232,21 +232,21 @@ msgstr "Opcions del tipus dallotjament"
#: web/templates/mail/payment/details.gotxt:39
#: web/templates/public/booking/fields.gohtml:146
#: web/templates/admin/payment/details.gohtml:110
#: web/templates/admin/payment/details.gohtml:140
msgctxt "title"
msgid "Customer Details"
msgstr "Detalls del client"
#: web/templates/mail/payment/details.gotxt:41
#: web/templates/public/booking/fields.gohtml:149
#: web/templates/admin/payment/details.gohtml:113
#: web/templates/admin/payment/details.gohtml:143
msgctxt "input"
msgid "Full name"
msgstr "Nom i cognoms"
#: web/templates/mail/payment/details.gotxt:42
#: web/templates/public/booking/fields.gohtml:158
#: web/templates/admin/payment/details.gohtml:117
#: web/templates/admin/payment/details.gohtml:147
#: web/templates/admin/taxDetails.gohtml:69
msgctxt "input"
msgid "Address"
@ -254,14 +254,14 @@ msgstr "Adreça"
#: web/templates/mail/payment/details.gotxt:43
#: web/templates/public/booking/fields.gohtml:167
#: web/templates/admin/payment/details.gohtml:121
#: web/templates/admin/payment/details.gohtml:151
#: web/templates/admin/taxDetails.gohtml:93
msgctxt "input"
msgid "Postcode"
msgstr "Codi postal"
#: web/templates/mail/payment/details.gotxt:44
#: web/templates/admin/payment/details.gohtml:125
#: web/templates/admin/payment/details.gohtml:155
#: web/templates/admin/taxDetails.gohtml:77
msgctxt "input"
msgid "City"
@ -269,7 +269,7 @@ msgstr "Població"
#: web/templates/mail/payment/details.gotxt:45
#: web/templates/public/booking/fields.gohtml:185
#: web/templates/admin/payment/details.gohtml:129
#: web/templates/admin/payment/details.gohtml:159
#: web/templates/admin/taxDetails.gohtml:101
msgctxt "input"
msgid "Country"
@ -277,7 +277,7 @@ msgstr "País"
#: web/templates/mail/payment/details.gotxt:46
#: web/templates/public/booking/fields.gohtml:196
#: web/templates/admin/payment/details.gohtml:133
#: web/templates/admin/payment/details.gohtml:163
#: web/templates/admin/login.gohtml:27 web/templates/admin/profile.gohtml:38
#: web/templates/admin/taxDetails.gohtml:53
msgctxt "input"
@ -286,14 +286,14 @@ msgstr "Correu-e"
#: web/templates/mail/payment/details.gotxt:47
#: web/templates/public/booking/fields.gohtml:205
#: web/templates/admin/payment/details.gohtml:137
#: web/templates/admin/payment/details.gohtml:167
#: web/templates/admin/taxDetails.gohtml:45
msgctxt "input"
msgid "Phone"
msgstr "Telèfon"
#: web/templates/mail/payment/details.gotxt:48
#: web/templates/admin/payment/details.gohtml:141
#: web/templates/admin/payment/details.gohtml:171
#: web/templates/admin/profile.gohtml:68
msgctxt "input"
msgid "Language"
@ -1015,6 +1015,24 @@ msgctxt "title"
msgid "Payment %s"
msgstr "Pagament %s"
#: web/templates/admin/payment/details.gohtml:20
msgid "Are you sure you wish to accept this pre-authorization?"
msgstr "Esteu segur de voler acceptar aquesta pre-autorització?"
#: web/templates/admin/payment/details.gohtml:29
msgctxt "action"
msgid "Accept pre-authorization"
msgstr "Accepta pre-autorització"
#: web/templates/admin/payment/details.gohtml:34
msgid "Are you sure you wish to void this pre-authorization?"
msgstr "Esteu segur de voler anuŀlar aquesta opció?"
#: web/templates/admin/payment/details.gohtml:43
msgctxt "action"
msgid "Void pre-authorization"
msgstr "Anuŀla pre-autorització"
#: web/templates/admin/legal/form.gohtml:8
#: web/templates/admin/legal/form.gohtml:29
msgctxt "title"
@ -2265,12 +2283,12 @@ msgstr "La integració escollida no és vàlida."
msgid "The merchant key is not valid."
msgstr "Aquesta clau del comerç no és vàlid."
#: pkg/payment/public.go:111
#: pkg/payment/public.go:110
msgctxt "order product name"
msgid "Campsite Booking"
msgstr "Reserva de càmping"
#: pkg/payment/public.go:369
#: pkg/payment/public.go:374
msgctxt "subject"
msgid "Booking payment successfully received"
msgstr "Rebut amb èxit el pagament de la reserva"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: camper\n"
"Report-Msgid-Bugs-To: jordi@tandem.blog\n"
"POT-Creation-Date: 2024-03-14 22:05+0100\n"
"POT-Creation-Date: 2024-03-24 21:59+0100\n"
"PO-Revision-Date: 2024-02-06 10:04+0100\n"
"Last-Translator: jordi fita mas <jordi@tandem.blog>\n"
"Language-Team: Spanish <es@tp.org.es>\n"
@ -72,14 +72,14 @@ msgid "We have successfully received the payment for the booking with the follow
msgstr "Hemos recibido correctamente el pago de la reserva con los siguientes detalles:"
#: web/templates/mail/payment/details.gotxt:7
#: web/templates/admin/payment/details.gohtml:19
#: web/templates/admin/payment/details.gohtml:49
msgctxt "title"
msgid "Payment"
msgstr "Pago"
#: web/templates/mail/payment/details.gotxt:9
#: web/templates/admin/payment/index.gohtml:21
#: web/templates/admin/payment/details.gohtml:22
#: web/templates/admin/payment/details.gohtml:52
#: web/templates/admin/booking/index.gohtml:21
msgctxt "header"
msgid "Reference"
@ -87,20 +87,20 @@ msgstr "Referencia"
#: web/templates/mail/payment/details.gotxt:10
#: web/templates/admin/payment/index.gohtml:22
#: web/templates/admin/payment/details.gohtml:26
#: web/templates/admin/payment/details.gohtml:56
#: web/templates/admin/booking/index.gohtml:25
msgctxt "header"
msgid "Status"
msgstr "Estado"
#: web/templates/mail/payment/details.gotxt:11
#: web/templates/admin/payment/details.gohtml:30
#: web/templates/admin/payment/details.gohtml:60
msgctxt "payment header"
msgid "Created at"
msgstr "Creado el"
#: web/templates/mail/payment/details.gotxt:12
#: web/templates/admin/payment/details.gohtml:34
#: web/templates/admin/payment/details.gohtml:64
msgctxt "payment header"
msgid "Last updated at"
msgstr "Actualizado por última vez el"
@ -108,32 +108,32 @@ msgstr "Actualizado por última vez el"
#: web/templates/mail/payment/details.gotxt:14
#: web/templates/public/layout.gohtml:71
#: web/templates/public/booking/page.gohtml:7
#: web/templates/admin/payment/details.gohtml:41
#: web/templates/admin/payment/details.gohtml:71
msgctxt "title"
msgid "Booking"
msgstr "Reserva"
#: web/templates/mail/payment/details.gotxt:16
#: web/templates/public/booking/fields.gohtml:14
#: web/templates/admin/payment/details.gohtml:44
#: web/templates/admin/payment/details.gohtml:74
msgctxt "title"
msgid "Accommodation"
msgstr "Alojamientos"
#: web/templates/mail/payment/details.gotxt:17
#: web/templates/admin/payment/details.gohtml:48
#: web/templates/admin/payment/details.gohtml:78
msgctxt "header"
msgid "Area preferences"
msgstr "Preferencias de área"
#: web/templates/mail/payment/details.gotxt:18
#: web/templates/admin/payment/details.gohtml:52
#: web/templates/admin/payment/details.gohtml:82
msgctxt "input"
msgid "ACSI card?"
msgstr "¿Tarjeta ACSI?"
#: web/templates/mail/payment/details.gotxt:18
#: web/templates/admin/payment/details.gohtml:53
#: web/templates/admin/payment/details.gohtml:83
#: web/templates/admin/campsite/index.gohtml:41
#: web/templates/admin/campsite/type/index.gohtml:53
#: web/templates/admin/season/index.gohtml:44
@ -143,7 +143,7 @@ msgid "Yes"
msgstr "Sí"
#: web/templates/mail/payment/details.gotxt:18
#: web/templates/admin/payment/details.gohtml:53
#: web/templates/admin/payment/details.gohtml:83
#: web/templates/admin/campsite/index.gohtml:41
#: web/templates/admin/campsite/type/index.gohtml:53
#: web/templates/admin/season/index.gohtml:44
@ -155,7 +155,7 @@ msgstr "No"
#: web/templates/mail/payment/details.gotxt:19
#: web/templates/public/campsite/dates.gohtml:4
#: web/templates/public/booking/fields.gohtml:30
#: web/templates/admin/payment/details.gohtml:56
#: web/templates/admin/payment/details.gohtml:86
msgctxt "input"
msgid "Arrival date"
msgstr "Fecha de llegada"
@ -163,47 +163,47 @@ msgstr "Fecha de llegada"
#: web/templates/mail/payment/details.gotxt:20
#: web/templates/public/campsite/dates.gohtml:15
#: web/templates/public/booking/fields.gohtml:41
#: web/templates/admin/payment/details.gohtml:60
#: web/templates/admin/payment/details.gohtml:90
msgctxt "input"
msgid "Departure date"
msgstr "Fecha de salida"
#: web/templates/mail/payment/details.gotxt:21
#: web/templates/admin/payment/details.gohtml:64
#: web/templates/admin/payment/details.gohtml:94
msgctxt "cart"
msgid "Nights"
msgstr "Noches"
#: web/templates/mail/payment/details.gotxt:22
#: web/templates/public/booking/fields.gohtml:60
#: web/templates/admin/payment/details.gohtml:68
#: web/templates/admin/payment/details.gohtml:98
msgctxt "input"
msgid "Adults aged 17 or older"
msgstr "Adultos de 17 años o más"
#: web/templates/mail/payment/details.gotxt:23
#: web/templates/public/booking/fields.gohtml:71
#: web/templates/admin/payment/details.gohtml:72
#: web/templates/admin/payment/details.gohtml:102
msgctxt "input"
msgid "Teenagers from 11 to 16 years old"
msgstr "Adolescentes de 11 a 16 años"
#: web/templates/mail/payment/details.gotxt:24
#: web/templates/public/booking/fields.gohtml:82
#: web/templates/admin/payment/details.gohtml:76
#: web/templates/admin/payment/details.gohtml:106
msgctxt "input"
msgid "Children from 2 to 10 years old"
msgstr "Niños de 2 a 10 años"
#: web/templates/mail/payment/details.gotxt:25
#: web/templates/public/booking/fields.gohtml:100
#: web/templates/admin/payment/details.gohtml:80
#: web/templates/admin/payment/details.gohtml:110
msgctxt "input"
msgid "Dogs"
msgstr "Perros"
#: web/templates/mail/payment/details.gotxt:26
#: web/templates/admin/payment/details.gohtml:84 pkg/booking/cart.go:197
#: web/templates/admin/payment/details.gohtml:114 pkg/booking/cart.go:197
msgctxt "cart"
msgid "Tourist tax"
msgstr "Impuesto turístico"
@ -216,13 +216,13 @@ msgstr "Total"
#: web/templates/mail/payment/details.gotxt:28
#: web/templates/public/booking/fields.gohtml:230
#: web/templates/admin/payment/details.gohtml:88
#: web/templates/admin/payment/details.gohtml:118
msgctxt "cart"
msgid "Down payment"
msgstr "A cuenta"
#: web/templates/mail/payment/details.gotxt:31
#: web/templates/admin/payment/details.gohtml:96
#: web/templates/admin/payment/details.gohtml:126
#: web/templates/admin/campsite/type/option/form.gohtml:18
#: web/templates/admin/campsite/type/option/index.gohtml:6
#: web/templates/admin/campsite/type/option/index.gohtml:17
@ -232,21 +232,21 @@ msgstr "Opciones del tipo de alojamiento"
#: web/templates/mail/payment/details.gotxt:39
#: web/templates/public/booking/fields.gohtml:146
#: web/templates/admin/payment/details.gohtml:110
#: web/templates/admin/payment/details.gohtml:140
msgctxt "title"
msgid "Customer Details"
msgstr "Detalles del cliente"
#: web/templates/mail/payment/details.gotxt:41
#: web/templates/public/booking/fields.gohtml:149
#: web/templates/admin/payment/details.gohtml:113
#: web/templates/admin/payment/details.gohtml:143
msgctxt "input"
msgid "Full name"
msgstr "Nombre y apellidos"
#: web/templates/mail/payment/details.gotxt:42
#: web/templates/public/booking/fields.gohtml:158
#: web/templates/admin/payment/details.gohtml:117
#: web/templates/admin/payment/details.gohtml:147
#: web/templates/admin/taxDetails.gohtml:69
msgctxt "input"
msgid "Address"
@ -254,14 +254,14 @@ msgstr "Dirección"
#: web/templates/mail/payment/details.gotxt:43
#: web/templates/public/booking/fields.gohtml:167
#: web/templates/admin/payment/details.gohtml:121
#: web/templates/admin/payment/details.gohtml:151
#: web/templates/admin/taxDetails.gohtml:93
msgctxt "input"
msgid "Postcode"
msgstr "Código postal"
#: web/templates/mail/payment/details.gotxt:44
#: web/templates/admin/payment/details.gohtml:125
#: web/templates/admin/payment/details.gohtml:155
#: web/templates/admin/taxDetails.gohtml:77
msgctxt "input"
msgid "City"
@ -269,7 +269,7 @@ msgstr "Población"
#: web/templates/mail/payment/details.gotxt:45
#: web/templates/public/booking/fields.gohtml:185
#: web/templates/admin/payment/details.gohtml:129
#: web/templates/admin/payment/details.gohtml:159
#: web/templates/admin/taxDetails.gohtml:101
msgctxt "input"
msgid "Country"
@ -277,7 +277,7 @@ msgstr "País"
#: web/templates/mail/payment/details.gotxt:46
#: web/templates/public/booking/fields.gohtml:196
#: web/templates/admin/payment/details.gohtml:133
#: web/templates/admin/payment/details.gohtml:163
#: web/templates/admin/login.gohtml:27 web/templates/admin/profile.gohtml:38
#: web/templates/admin/taxDetails.gohtml:53
msgctxt "input"
@ -286,14 +286,14 @@ msgstr "Correo-e"
#: web/templates/mail/payment/details.gotxt:47
#: web/templates/public/booking/fields.gohtml:205
#: web/templates/admin/payment/details.gohtml:137
#: web/templates/admin/payment/details.gohtml:167
#: web/templates/admin/taxDetails.gohtml:45
msgctxt "input"
msgid "Phone"
msgstr "Teléfono"
#: web/templates/mail/payment/details.gotxt:48
#: web/templates/admin/payment/details.gohtml:141
#: web/templates/admin/payment/details.gohtml:171
#: web/templates/admin/profile.gohtml:68
msgctxt "input"
msgid "Language"
@ -1015,6 +1015,24 @@ msgctxt "title"
msgid "Payment %s"
msgstr "Pago %s"
#: web/templates/admin/payment/details.gohtml:20
msgid "Are you sure you wish to accept this pre-authorization?"
msgstr "¿Estáis seguro de querer acceptar esta preautorización?"
#: web/templates/admin/payment/details.gohtml:29
msgctxt "action"
msgid "Accept pre-authorization"
msgstr "Acceptar preautorización"
#: web/templates/admin/payment/details.gohtml:34
msgid "Are you sure you wish to void this pre-authorization?"
msgstr "¿Estáis seguro de querer anular esta preautorización?"
#: web/templates/admin/payment/details.gohtml:43
msgctxt "action"
msgid "Void pre-authorization"
msgstr "Anular preautorización"
#: web/templates/admin/legal/form.gohtml:8
#: web/templates/admin/legal/form.gohtml:29
msgctxt "title"
@ -2265,12 +2283,12 @@ msgstr "La integración escogida no es válida."
msgid "The merchant key is not valid."
msgstr "Esta clave del comercio no es válida."
#: pkg/payment/public.go:111
#: pkg/payment/public.go:110
msgctxt "order product name"
msgid "Campsite Booking"
msgstr "Reserva de camping"
#: pkg/payment/public.go:369
#: pkg/payment/public.go:374
msgctxt "subject"
msgid "Booking payment successfully received"
msgstr "Se ha recibido correctamente el pago de la reserva"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: camper\n"
"Report-Msgid-Bugs-To: jordi@tandem.blog\n"
"POT-Creation-Date: 2024-03-14 22:05+0100\n"
"POT-Creation-Date: 2024-03-24 21:59+0100\n"
"PO-Revision-Date: 2024-02-06 10:05+0100\n"
"Last-Translator: Oriol Carbonell <info@oriolcarbonell.cat>\n"
"Language-Team: French <traduc@traduc.org>\n"
@ -72,14 +72,14 @@ msgid "We have successfully received the payment for the booking with the follow
msgstr "Nous avons reçu avec succès le paiement de la réservation avec les détails suivants :"
#: web/templates/mail/payment/details.gotxt:7
#: web/templates/admin/payment/details.gohtml:19
#: web/templates/admin/payment/details.gohtml:49
msgctxt "title"
msgid "Payment"
msgstr "Paiement"
#: web/templates/mail/payment/details.gotxt:9
#: web/templates/admin/payment/index.gohtml:21
#: web/templates/admin/payment/details.gohtml:22
#: web/templates/admin/payment/details.gohtml:52
#: web/templates/admin/booking/index.gohtml:21
msgctxt "header"
msgid "Reference"
@ -87,20 +87,20 @@ msgstr "Référence"
#: web/templates/mail/payment/details.gotxt:10
#: web/templates/admin/payment/index.gohtml:22
#: web/templates/admin/payment/details.gohtml:26
#: web/templates/admin/payment/details.gohtml:56
#: web/templates/admin/booking/index.gohtml:25
msgctxt "header"
msgid "Status"
msgstr "Statut"
#: web/templates/mail/payment/details.gotxt:11
#: web/templates/admin/payment/details.gohtml:30
#: web/templates/admin/payment/details.gohtml:60
msgctxt "payment header"
msgid "Created at"
msgstr "Créé à"
#: web/templates/mail/payment/details.gotxt:12
#: web/templates/admin/payment/details.gohtml:34
#: web/templates/admin/payment/details.gohtml:64
msgctxt "payment header"
msgid "Last updated at"
msgstr "Dernière mise à jour à"
@ -108,32 +108,32 @@ msgstr "Dernière mise à jour à"
#: web/templates/mail/payment/details.gotxt:14
#: web/templates/public/layout.gohtml:71
#: web/templates/public/booking/page.gohtml:7
#: web/templates/admin/payment/details.gohtml:41
#: web/templates/admin/payment/details.gohtml:71
msgctxt "title"
msgid "Booking"
msgstr "Réservation"
#: web/templates/mail/payment/details.gotxt:16
#: web/templates/public/booking/fields.gohtml:14
#: web/templates/admin/payment/details.gohtml:44
#: web/templates/admin/payment/details.gohtml:74
msgctxt "title"
msgid "Accommodation"
msgstr "Hébergement"
#: web/templates/mail/payment/details.gotxt:17
#: web/templates/admin/payment/details.gohtml:48
#: web/templates/admin/payment/details.gohtml:78
msgctxt "header"
msgid "Area preferences"
msgstr "Préférences de zone"
#: web/templates/mail/payment/details.gotxt:18
#: web/templates/admin/payment/details.gohtml:52
#: web/templates/admin/payment/details.gohtml:82
msgctxt "input"
msgid "ACSI card?"
msgstr "Carte ACSI ?"
#: web/templates/mail/payment/details.gotxt:18
#: web/templates/admin/payment/details.gohtml:53
#: web/templates/admin/payment/details.gohtml:83
#: web/templates/admin/campsite/index.gohtml:41
#: web/templates/admin/campsite/type/index.gohtml:53
#: web/templates/admin/season/index.gohtml:44
@ -143,7 +143,7 @@ msgid "Yes"
msgstr "Oui"
#: web/templates/mail/payment/details.gotxt:18
#: web/templates/admin/payment/details.gohtml:53
#: web/templates/admin/payment/details.gohtml:83
#: web/templates/admin/campsite/index.gohtml:41
#: web/templates/admin/campsite/type/index.gohtml:53
#: web/templates/admin/season/index.gohtml:44
@ -155,7 +155,7 @@ msgstr "Non"
#: web/templates/mail/payment/details.gotxt:19
#: web/templates/public/campsite/dates.gohtml:4
#: web/templates/public/booking/fields.gohtml:30
#: web/templates/admin/payment/details.gohtml:56
#: web/templates/admin/payment/details.gohtml:86
msgctxt "input"
msgid "Arrival date"
msgstr "Date darrivée"
@ -163,47 +163,47 @@ msgstr "Date darrivée"
#: web/templates/mail/payment/details.gotxt:20
#: web/templates/public/campsite/dates.gohtml:15
#: web/templates/public/booking/fields.gohtml:41
#: web/templates/admin/payment/details.gohtml:60
#: web/templates/admin/payment/details.gohtml:90
msgctxt "input"
msgid "Departure date"
msgstr "Date de depart"
#: web/templates/mail/payment/details.gotxt:21
#: web/templates/admin/payment/details.gohtml:64
#: web/templates/admin/payment/details.gohtml:94
msgctxt "cart"
msgid "Nights"
msgstr "Nuits"
#: web/templates/mail/payment/details.gotxt:22
#: web/templates/public/booking/fields.gohtml:60
#: web/templates/admin/payment/details.gohtml:68
#: web/templates/admin/payment/details.gohtml:98
msgctxt "input"
msgid "Adults aged 17 or older"
msgstr "Adultes âgés 17 ans ou plus"
#: web/templates/mail/payment/details.gotxt:23
#: web/templates/public/booking/fields.gohtml:71
#: web/templates/admin/payment/details.gohtml:72
#: web/templates/admin/payment/details.gohtml:102
msgctxt "input"
msgid "Teenagers from 11 to 16 years old"
msgstr "Adolescents de 11 à 16 ans"
#: web/templates/mail/payment/details.gotxt:24
#: web/templates/public/booking/fields.gohtml:82
#: web/templates/admin/payment/details.gohtml:76
#: web/templates/admin/payment/details.gohtml:106
msgctxt "input"
msgid "Children from 2 to 10 years old"
msgstr "Enfants de 2 à 10 ans"
#: web/templates/mail/payment/details.gotxt:25
#: web/templates/public/booking/fields.gohtml:100
#: web/templates/admin/payment/details.gohtml:80
#: web/templates/admin/payment/details.gohtml:110
msgctxt "input"
msgid "Dogs"
msgstr "Chiens"
#: web/templates/mail/payment/details.gotxt:26
#: web/templates/admin/payment/details.gohtml:84 pkg/booking/cart.go:197
#: web/templates/admin/payment/details.gohtml:114 pkg/booking/cart.go:197
msgctxt "cart"
msgid "Tourist tax"
msgstr "Taxe touristique"
@ -216,13 +216,13 @@ msgstr "Totale"
#: web/templates/mail/payment/details.gotxt:28
#: web/templates/public/booking/fields.gohtml:230
#: web/templates/admin/payment/details.gohtml:88
#: web/templates/admin/payment/details.gohtml:118
msgctxt "cart"
msgid "Down payment"
msgstr "Acompte"
#: web/templates/mail/payment/details.gotxt:31
#: web/templates/admin/payment/details.gohtml:96
#: web/templates/admin/payment/details.gohtml:126
#: web/templates/admin/campsite/type/option/form.gohtml:18
#: web/templates/admin/campsite/type/option/index.gohtml:6
#: web/templates/admin/campsite/type/option/index.gohtml:17
@ -232,21 +232,21 @@ msgstr "Options de type demplacement de camping"
#: web/templates/mail/payment/details.gotxt:39
#: web/templates/public/booking/fields.gohtml:146
#: web/templates/admin/payment/details.gohtml:110
#: web/templates/admin/payment/details.gohtml:140
msgctxt "title"
msgid "Customer Details"
msgstr "Détails du client"
#: web/templates/mail/payment/details.gotxt:41
#: web/templates/public/booking/fields.gohtml:149
#: web/templates/admin/payment/details.gohtml:113
#: web/templates/admin/payment/details.gohtml:143
msgctxt "input"
msgid "Full name"
msgstr "Nom et prénom"
#: web/templates/mail/payment/details.gotxt:42
#: web/templates/public/booking/fields.gohtml:158
#: web/templates/admin/payment/details.gohtml:117
#: web/templates/admin/payment/details.gohtml:147
#: web/templates/admin/taxDetails.gohtml:69
msgctxt "input"
msgid "Address"
@ -254,14 +254,14 @@ msgstr "Adresse"
#: web/templates/mail/payment/details.gotxt:43
#: web/templates/public/booking/fields.gohtml:167
#: web/templates/admin/payment/details.gohtml:121
#: web/templates/admin/payment/details.gohtml:151
#: web/templates/admin/taxDetails.gohtml:93
msgctxt "input"
msgid "Postcode"
msgstr "Code postal"
#: web/templates/mail/payment/details.gotxt:44
#: web/templates/admin/payment/details.gohtml:125
#: web/templates/admin/payment/details.gohtml:155
#: web/templates/admin/taxDetails.gohtml:77
msgctxt "input"
msgid "City"
@ -269,7 +269,7 @@ msgstr "Ville"
#: web/templates/mail/payment/details.gotxt:45
#: web/templates/public/booking/fields.gohtml:185
#: web/templates/admin/payment/details.gohtml:129
#: web/templates/admin/payment/details.gohtml:159
#: web/templates/admin/taxDetails.gohtml:101
msgctxt "input"
msgid "Country"
@ -277,7 +277,7 @@ msgstr "Pays"
#: web/templates/mail/payment/details.gotxt:46
#: web/templates/public/booking/fields.gohtml:196
#: web/templates/admin/payment/details.gohtml:133
#: web/templates/admin/payment/details.gohtml:163
#: web/templates/admin/login.gohtml:27 web/templates/admin/profile.gohtml:38
#: web/templates/admin/taxDetails.gohtml:53
msgctxt "input"
@ -286,14 +286,14 @@ msgstr "E-mail"
#: web/templates/mail/payment/details.gotxt:47
#: web/templates/public/booking/fields.gohtml:205
#: web/templates/admin/payment/details.gohtml:137
#: web/templates/admin/payment/details.gohtml:167
#: web/templates/admin/taxDetails.gohtml:45
msgctxt "input"
msgid "Phone"
msgstr "Téléphone"
#: web/templates/mail/payment/details.gotxt:48
#: web/templates/admin/payment/details.gohtml:141
#: web/templates/admin/payment/details.gohtml:171
#: web/templates/admin/profile.gohtml:68
msgctxt "input"
msgid "Language"
@ -1015,6 +1015,24 @@ msgctxt "title"
msgid "Payment %s"
msgstr "Paiement %s"
#: web/templates/admin/payment/details.gohtml:20
msgid "Are you sure you wish to accept this pre-authorization?"
msgstr "Êtes-vous sûr de vouloir accepter cette pré-autorisation ?"
#: web/templates/admin/payment/details.gohtml:29
msgctxt "action"
msgid "Accept pre-authorization"
msgstr "Accepter pré-autorisation"
#: web/templates/admin/payment/details.gohtml:34
msgid "Are you sure you wish to void this pre-authorization?"
msgstr "Êtes-vous sûr de vouloir annuler cette pré-autorisation ?"
#: web/templates/admin/payment/details.gohtml:43
msgctxt "action"
msgid "Void pre-authorization"
msgstr "Annuler pré-autorisation"
#: web/templates/admin/legal/form.gohtml:8
#: web/templates/admin/legal/form.gohtml:29
msgctxt "title"
@ -2265,12 +2283,12 @@ msgstr "Lintégration sélectionnée nest pas valide."
msgid "The merchant key is not valid."
msgstr "La clé marchand nest pas valide."
#: pkg/payment/public.go:111
#: pkg/payment/public.go:110
msgctxt "order product name"
msgid "Campsite Booking"
msgstr "Réservation camping"
#: pkg/payment/public.go:369
#: pkg/payment/public.go:374
msgctxt "subject"
msgid "Booking payment successfully received"
msgstr "Paiement de réservation reçu avec succès"

View File

@ -756,3 +756,16 @@ label[x-show] > span, label[x-show] > br {
}
/*</editor-fold>*/
/*<editor-fold desc="Payment">*/
#payment-heading {
float: left;
}
#payment-actions {
display: flexpré-autorisation;
gap: 2ch;
justify-content: end;
}
/*</editor-fold>*/

View File

@ -13,7 +13,37 @@
{{ define "content" -}}
{{- /*gotype: dev.tandem.ws/tandem/camper/pkg/payment.paymentDetails*/ -}}
<h2>{{ template "title" . }}</h2>
<h2 id="payment-heading">{{ template "title" . }}</h2>
<div id="payment-actions">
{{ with .AcceptPreauthRequest -}}
{{ $confirm := (gettext "Are you sure you wish to accept this pre-authorization?")}}
<form method="post" x-data @submit.prevent="if (confirm('{{ $confirm }}')) $el.submit()"
{{- if eq $.Environment "live" }} action="https://sis.redsys.es/sis/realizarPago"
{{- else }} action="https://sis-t.redsys.es:25443/sis/realizarPago"
{{- end -}}
>
<input type="hidden" name="Ds_MerchantParameters" value="{{ .MerchantParameters }}"/>
<input type="hidden" name="Ds_Signature" value="{{ .Signature }}"/>
<input type="hidden" name="Ds_SignatureVersion" value="{{ .SignatureVersion }}"/>
<button type="submit">{{( pgettext "Accept pre-authorization" "action" )}}</button>
</form>
{{- end }}
{{ with .VoidPreauthRequest -}}
{{ $confirm := (gettext "Are you sure you wish to void this pre-authorization?")}}
<form method="post" x-data @submit.prevent="if (confirm('{{ $confirm }}')) $el.submit()"
{{- if eq $.Environment "live" }} action="https://sis.redsys.es/sis/realizarPago"
{{- else }} action="https://sis-t.redsys.es:25443/sis/realizarPago"
{{- end -}}
>
<input type="hidden" name="Ds_MerchantParameters" value="{{ .MerchantParameters }}"/>
<input type="hidden" name="Ds_Signature" value="{{ .Signature }}"/>
<input type="hidden" name="Ds_SignatureVersion" value="{{ .SignatureVersion }}"/>
<button type="submit">{{( pgettext "Void pre-authorization" "action" )}}</button>
</form>
{{- end }}
</div>
<table class="payment-{{ .Status}}">
<caption>{{( pgettext "Payment" "title" )}}</caption>