26 lines
485 B
Go
26 lines
485 B
Go
package paymentapiimp
|
|
|
|
import (
|
|
"net"
|
|
"strings"
|
|
|
|
"github.com/tech/sendico/server/interface/api/srequest"
|
|
)
|
|
|
|
func applyCustomerIP(intent *srequest.PaymentIntent, remoteAddr string) {
|
|
if intent == nil {
|
|
return
|
|
}
|
|
ip := strings.TrimSpace(remoteAddr)
|
|
if ip == "" {
|
|
return
|
|
}
|
|
if host, _, err := net.SplitHostPort(ip); err == nil && host != "" {
|
|
ip = host
|
|
}
|
|
if intent.Customer == nil {
|
|
intent.Customer = &srequest.Customer{}
|
|
}
|
|
intent.Customer.IP = strings.TrimSpace(ip)
|
|
}
|