Skip to content

Commit 9b28809

Browse files
committed
feat: set client_user_agent on new order body
get client ip from requet ip instead
1 parent e9bccda commit 9b28809

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

bin/web.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,8 @@ function middleware (id, meta, body, respond, req, res, resource, verb, endpoint
5858
respond({}, null, 403, 121, 'Undefined or invalid Store ID')
5959
return
6060
}
61-
6261
// pass to endpoint
63-
endpoint(id, meta, body, respond, storeId, ip)
62+
endpoint(id, meta, body, respond, storeId, ip, req.headers['user-agent'])
6463
} else {
6564
respond({}, null, 403, 100, 'Who are you? Unknown IP address')
6665
}

routes/#checkout.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ module.exports = (checkoutBody, checkoutRespond, storeId) => {
134134
'utm',
135135
'affiliate_code',
136136
'browser_ip',
137+
'client_user_agent',
137138
'channel_id',
138139
'channel_type',
139140
'domain',

routes/@checkout.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,11 @@ const schema = {
853853
'maxLength': 50,
854854
'description': 'IP address of the browser used by the customer when placing the order'
855855
},
856+
'client_user_agent': {
857+
'type': 'string',
858+
'maxLength': 255,
859+
'description': 'User-Agent of the browser (if any) used by the customer'
860+
},
856861
'channel_id': {
857862
'type': 'integer',
858863
'min': 10000,
@@ -1053,7 +1058,7 @@ const GET = (id, meta, body, respond) => {
10531058
}
10541059
}
10551060

1056-
const POST = (id, meta, body, respond, storeId, ip) => {
1061+
const POST = (id, meta, body, respond, storeId, ip, userAgent) => {
10571062
// logger.log(JSON.stringify(body, null, 2))
10581063
// ajv
10591064
const valid = validate(body)
@@ -1062,9 +1067,8 @@ const POST = (id, meta, body, respond, storeId, ip) => {
10621067
} else {
10631068
// request body validated
10641069
// handle checkout
1065-
if (!body.browser_ip && ip) {
1066-
body.browser_ip = ip
1067-
}
1070+
body.browser_ip = ip || body.browser_ip
1071+
body.client_user_agent = userAgent || body.client_user_agent
10681072
checkout(body, respond, storeId)
10691073
}
10701074
}

routes/create_transaction.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,11 @@ const schema = {
609609
'maxLength': 50,
610610
'description': 'IP address of the browser used by the customer when placing the order'
611611
},
612+
'client_user_agent': {
613+
'type': 'string',
614+
'maxLength': 255,
615+
'description': 'User-Agent of the browser (if any) used by the customer'
616+
},
612617
'channel_id': {
613618
'type': 'integer',
614619
'min': 10000,

0 commit comments

Comments
 (0)