Refactor base URL for the payment success, failure, and notification

This commit is contained in:
jordi fita mas 2024-02-12 05:21:30 +01:00
parent e4636592c5
commit 148d9075da
1 changed files with 4 additions and 3 deletions

View File

@ -80,14 +80,15 @@ func makeReservation(w http.ResponseWriter, r *http.Request, user *auth.User, co
schema := httplib.Protocol(r)
authority := httplib.Host(r)
baseURL := fmt.Sprintf("%s://%s/%s/booking", schema, authority, user.Locale.Language)
request := &redsys.Request{
TransactionType: redsys.TransactionTypeCharge,
Amount: f.Cart.Total,
OrderNumber: randomOrderNumber(),
Product: "Test Booking",
SuccessURL: fmt.Sprintf("%s://%s/%s/booking/success", schema, authority, user.Locale.Language),
FailureURL: fmt.Sprintf("%s://%s/%s/booking/failure", schema, authority, user.Locale.Language),
NotificationURL: fmt.Sprintf("%s://%s/%s/booking/notification", schema, authority, user.Locale.Language),
SuccessURL: fmt.Sprintf("%s/success", baseURL),
FailureURL: fmt.Sprintf("%s/failure", baseURL),
NotificationURL: fmt.Sprintf("%s/notification", baseURL),
ConsumerLanguage: user.Locale.Language,
}
signed, err := redsys.SignRequest(r.Context(), conn, company, request)