diff --git a/app/controllers/charge_controller.js b/app/controllers/charge_controller.js
index d442f4116..c17a56571 100644
--- a/app/controllers/charge_controller.js
+++ b/app/controllers/charge_controller.js
@@ -122,7 +122,7 @@ module.exports = {
const cardModel = Card(req.chargeData.gateway_account.card_types, req.chargeData.gateway_account.block_prepaid_cards, req.headers[CORRELATION_HEADER])
const chargeOptions = {
email_collection_mode: charge.gatewayAccount.emailCollectionMode,
- collect_billing_address: res.locals.service.collectBillingAddress
+ collect_billing_address: res.locals.collectBillingAddress
}
const validator = chargeValidator(i18n.__('fieldErrors'), logger, cardModel, chargeOptions, getLoggingFields(req))
@@ -185,7 +185,7 @@ module.exports = {
const correlationId = req.headers[CORRELATION_HEADER] || ''
const payload = normalise.apiPayload(req, card)
- if (res.locals.service.collectBillingAddress === false) {
+ if (res.locals.collectBillingAddress === false) {
delete payload.address
}
try {
diff --git a/app/middleware/resolve_service.js b/app/middleware/resolve_service.js
index 89d5e59b8..2f4f8a6f9 100644
--- a/app/middleware/resolve_service.js
+++ b/app/middleware/resolve_service.js
@@ -25,6 +25,7 @@ module.exports = function resolveServiceMiddleware (req, res, next) {
const cachedService = serviceCache.get(gatewayAccountId)
if (cachedService) {
res.locals.service = cachedService
+ res.locals.collectBillingAddress = res.locals.service.collectBillingAddress && !req.chargeData.moto
next()
} else {
// @FIXME(sfount) tests shouldn't rely on middleware returning a value if
@@ -34,6 +35,7 @@ module.exports = function resolveServiceMiddleware (req, res, next) {
.then(service => {
serviceCache.put(gatewayAccountId, service, SERVICE_CACHE_MAX_AGE)
res.locals.service = service
+ res.locals.collectBillingAddress = res.locals.service.collectBillingAddress && !req.chargeData.moto
next()
})
.catch((err) => {
diff --git a/app/views/charge.njk b/app/views/charge.njk
index f113e0bf6..96a23d9b6 100644
--- a/app/views/charge.njk
+++ b/app/views/charge.njk
@@ -272,7 +272,7 @@
- {% if service.collectBillingAddress %}
+ {% if collectBillingAddress %}