Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle subaccount case in gaec #3876

Open
wants to merge 2 commits into
base: hotfix/13112024
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,9 @@ const responseBuilder = async (metadata, message, { Config }, payload) => {
let { customerId, loginCustomerId } = Config;
const { configData } = Config;

if (isDefinedAndNotNull(configData)) {
const configDetails = JSON.parse(configData);
const configDetails = isDefinedAndNotNull(configData) ? JSON.parse(configData) : {};
if (configDetails.customerId) {
customerId = configDetails.customerId;
if (isDefined(configDetails.loginCustomerId)) {
loginCustomerId = configDetails.loginCustomerId;
}
}

if (isNumber(customerId)) {
Expand All @@ -70,7 +67,8 @@ const responseBuilder = async (metadata, message, { Config }, payload) => {
'developer-token': getValueFromMessage(metadata, 'secret.developer_token'),
};
response.params = { event, customerId: filteredCustomerId };
if (subAccount) {

if (subAccount && !isDefined(configDetails.loginCustomerId)) {
if (!loginCustomerId) {
throw new ConfigurationError(`loginCustomerId is required as subAccount is true.`);
}
Expand All @@ -84,7 +82,9 @@ const responseBuilder = async (metadata, message, { Config }, payload) => {
response.headers['login-customer-id'] = filteredLoginCustomerId;
}

if (loginCustomerId) {
// isDefined and non empty loginCustomerId
if (isDefined(configDetails.loginCustomerId) && configDetails.loginCustomerId) {
loginCustomerId = configDetails.loginCustomerId;
const filteredLoginCustomerId = removeHyphens(loginCustomerId);
response.headers['login-customer-id'] = filteredLoginCustomerId;
}
Expand Down
Loading
Loading