diff --git a/adapters/aduptech/aduptech.go b/adapters/aduptech/aduptech.go index c3977e1d65..964c9287ee 100644 --- a/adapters/aduptech/aduptech.go +++ b/adapters/aduptech/aduptech.go @@ -9,10 +9,11 @@ import ( "github.com/prebid/openrtb/v20/openrtb2" "github.com/prebid/prebid-server/v3/adapters" "github.com/prebid/prebid-server/v3/config" - "github.com/prebid/prebid-server/v3/currency" + prebidcurrency "github.com/prebid/prebid-server/v3/currency" "github.com/prebid/prebid-server/v3/errortypes" "github.com/prebid/prebid-server/v3/openrtb_ext" "github.com/prebid/prebid-server/v3/util/jsonutil" + "golang.org/x/text/currency" ) type adapter struct { @@ -34,6 +35,12 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server co return nil, errors.New("invalid extra info: TargetCurrency is empty, pls check") } + parsedCurrency, err := currency.ParseISO(extraInfo.TargetCurrency) + if err != nil { + return nil, fmt.Errorf("invalid extra info: invalid TargetCurrency %s, pls check", extraInfo.TargetCurrency) + } + extraInfo.TargetCurrency = parsedCurrency.String() + bidder := &adapter{ endpoint: config.Endpoint, extraInfo: extraInfo, @@ -81,7 +88,7 @@ func (a *adapter) convertCurrency(value float64, cur string, reqInfo *adapters.E convertedValue, err := reqInfo.ConvertCurrency(value, cur, a.extraInfo.TargetCurrency) if err != nil { - var convErr currency.ConversionNotFoundError + var convErr prebidcurrency.ConversionNotFoundError if !errors.As(err, &convErr) { return 0, err } diff --git a/adapters/aduptech/aduptech_test.go b/adapters/aduptech/aduptech_test.go index f6322380b5..64dc6b3d41 100644 --- a/adapters/aduptech/aduptech_test.go +++ b/adapters/aduptech/aduptech_test.go @@ -46,3 +46,20 @@ func TestInvalidExtraAdapterInfo(t *testing.T) { assert.EqualError(t, buildErr, "invalid extra info: TargetCurrency is empty, pls check") } + +func TestInvalidTargetCurrency(t *testing.T) { + _, buildErr := Builder( + openrtb_ext.BidderAdUpTech, + config.Adapter{ + Endpoint: "https://example.com/rtb/bid", + ExtraAdapterInfo: `{"target_currency": "INVALID"}`, + }, + config.Server{ + ExternalUrl: "http://hosturl.com", + GvlID: 1, + DataCenter: "2", + }, + ) + + assert.EqualError(t, buildErr, "invalid extra info: invalid TargetCurrency INVALID, pls check") +}