diff --git a/modules/prebidServerBidAdapter/index.js b/modules/prebidServerBidAdapter/index.js index b7f3f082cce..8d512554489 100644 --- a/modules/prebidServerBidAdapter/index.js +++ b/modules/prebidServerBidAdapter/index.js @@ -935,10 +935,10 @@ const OPEN_RTB_PROTOCOL = { bidObject.creative_id = bid.crid; bidObject.creativeId = bid.crid; if (bid.burl) { bidObject.burl = bid.burl; } + bidObject.currency = (response.cur) ? response.cur : DEFAULT_S2S_CURRENCY; - // TODO: Remove when prebid-server returns ttl, currency and netRevenue + // TODO: Remove when prebid-server returns ttl and netRevenue bidObject.ttl = (bid.ttl) ? bid.ttl : DEFAULT_S2S_TTL; - bidObject.currency = (bid.currency) ? bid.currency : DEFAULT_S2S_CURRENCY; bidObject.netRevenue = (bid.netRevenue) ? bid.netRevenue : DEFAULT_S2S_NETREVENUE; bids.push({ adUnit: bid.impid, bid: bidObject }); diff --git a/test/spec/modules/prebidServerBidAdapter_spec.js b/test/spec/modules/prebidServerBidAdapter_spec.js index c198502d4b3..52c8919b557 100644 --- a/test/spec/modules/prebidServerBidAdapter_spec.js +++ b/test/spec/modules/prebidServerBidAdapter_spec.js @@ -353,6 +353,7 @@ const RESPONSE_OPENRTB = { 'seat': 'appnexus' }, ], + 'cur': 'EUR', 'ext': { 'responsetimemillis': { 'appnexus': 8, @@ -1544,9 +1545,34 @@ describe('S2S Adapter', function () { expect(response).to.have.property('dealId', 'test-dealid'); }); + it('should set the bidResponse currency to whats in the PBS response', function() { + server.respondWith(JSON.stringify(RESPONSE_OPENRTB)); + let ortb2Config = utils.deepClone(CONFIG); + ortb2Config.endpoint = 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction'; + config.setConfig({ s2sConfig: ortb2Config }); + adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); + server.respond(); + sinon.assert.calledOnce(addBidResponse); + const pbjsResponse = addBidResponse.firstCall.args[1]; + expect(pbjsResponse).to.have.property('currency', 'EUR'); + }); + + it('should set the default bidResponse currency when not specified in OpenRTB', function() { + let modifiedResponse = utils.deepClone(RESPONSE_OPENRTB); + modifiedResponse.cur = ''; + let ortb2Config = utils.deepClone(CONFIG); + ortb2Config.endpoint = 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction'; + config.setConfig({ s2sConfig: ortb2Config }); + server.respondWith(JSON.stringify(modifiedResponse)); + adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); + server.respond(); + sinon.assert.calledOnce(addBidResponse); + const pbjsResponse = addBidResponse.firstCall.args[1]; + expect(pbjsResponse).to.have.property('currency', 'USD'); + }); + it('should pass through default adserverTargeting if present in bidObject', function () { server.respondWith(JSON.stringify(RESPONSE)); - config.setConfig({ s2sConfig: CONFIG }); adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); server.respond();