uniform
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
"git.k6n.net/mats/go-cart-actor/pkg/cart"
|
||||
"git.k6n.net/mats/go-cart-actor/pkg/checkout"
|
||||
"git.k6n.net/mats/platform/conv"
|
||||
"git.k6n.net/mats/platform/httpclient"
|
||||
"git.k6n.net/mats/platform/tax"
|
||||
adyenCheckout "github.com/adyen/adyen-go-api-library/v21/src/checkout"
|
||||
@@ -228,7 +229,7 @@ func defaultAdyenTaxRate(tp tax.Provider, country string) int64 {
|
||||
|
||||
func GetCheckoutMetaFromRequest(r *http.Request) *CheckoutMeta {
|
||||
host := getOriginalHost(r)
|
||||
country := getCountryFromHost(host)
|
||||
country := conv.CountryFromHost(host)
|
||||
siteUrl := fmt.Sprintf("%s://%s", getScheme(r), host)
|
||||
if checkoutPublicURL != "" {
|
||||
siteUrl = checkoutPublicURL
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
@@ -60,12 +61,15 @@ func (k *KlarnaClient) getOrderResponse(res *http.Response) (*CheckoutOrder, err
|
||||
}
|
||||
return &klarnaOrderResponse, nil
|
||||
}
|
||||
body, err := io.ReadAll(res.Body)
|
||||
if err == nil {
|
||||
log.Println(string(body))
|
||||
body, readErr := io.ReadAll(res.Body)
|
||||
if len(body) > 0 {
|
||||
log.Printf("klarna error body: %s", string(body))
|
||||
return nil, fmt.Errorf("klarna: %s: %s", res.Status, string(bytes.TrimSpace(body)))
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("%s", res.Status)
|
||||
if readErr != nil {
|
||||
return nil, fmt.Errorf("klarna: %s (body unreadable: %v)", res.Status, readErr)
|
||||
}
|
||||
return nil, fmt.Errorf("klarna: %s", res.Status)
|
||||
}
|
||||
|
||||
func (k *KlarnaClient) CreateOrder(ctx context.Context, reader io.Reader) (*CheckoutOrder, error) {
|
||||
|
||||
@@ -237,7 +237,7 @@ func main() {
|
||||
log.Print("checkout: data retention / GDPR purge disabled (CHECKOUT_RETENTION_DAYS not set or <= 0)")
|
||||
}
|
||||
|
||||
otelShutdown, err := telemetry.SetupOTelSDK(ctx)
|
||||
otelShutdown, err := telemetry.SetupOTelSDK(ctx, telemetry.LoggerConfigFromEnv())
|
||||
if err != nil {
|
||||
log.Fatalf("Unable to start otel %v", err)
|
||||
}
|
||||
|
||||
@@ -60,15 +60,7 @@ func getCountryFromCurrency(currency string) string {
|
||||
return "se"
|
||||
}
|
||||
|
||||
func getCountryFromHost(host string) string {
|
||||
if strings.Contains(strings.ToLower(host), "-no") {
|
||||
return "no"
|
||||
}
|
||||
if strings.Contains(strings.ToLower(host), "-se") {
|
||||
return "se"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
|
||||
func (a *CheckoutPoolServer) reserveInventory(ctx context.Context, grain *checkout.CheckoutGrain) error {
|
||||
if a.reservationPolicy == nil {
|
||||
|
||||
Reference in New Issue
Block a user