feature/pubsub #7

Merged
mats merged 67 commits from feature/pubsub into main 2025-11-28 17:45:22 +01:00
2 changed files with 11 additions and 0 deletions
Showing only changes of commit 23160479b3 - Show all commits

View File

@@ -17,6 +17,7 @@ type CheckoutMeta struct {
// Terms string
// Checkout string
// Confirmation string
ClientIp string
Country string
Currency string // optional override (defaults to "SEK" if empty)
Locale string // optional override (defaults to "sv-se" if empty)

View File

@@ -366,10 +366,19 @@ func getOriginalHost(r *http.Request) string {
return r.Host
}
func getClientIp(r *http.Request) string {
ip := r.Header.Get("X-Forwarded-For")
if ip == "" {
ip = r.RemoteAddr
}
return ip
}
func (s *PoolServer) CreateOrUpdateCheckout(r *http.Request, id cart.CartId) (*CheckoutOrder, error) {
host := getOriginalHost(r)
country := getCountryFromHost(host)
meta := &CheckoutMeta{
ClientIp: getClientIp(r),
SiteUrl: fmt.Sprintf("https://%s", host),
Country: country,
Currency: getCurrency(country),
@@ -729,6 +738,7 @@ func (s *PoolServer) AdyenSessionHandler(w http.ResponseWriter, r *http.Request,
host := getOriginalHost(r)
country := getCountryFromHost(host)
meta := &CheckoutMeta{
ClientIp: getClientIp(r),
SiteUrl: fmt.Sprintf("https://%s", host),
Country: country,
Currency: getCurrency(country),