Skip to content

Commit b6221ea

Browse files
committed
Merge branch 'api_key_identifier_22.7' into 'compatibility-22.7-latest'
api key identifier change for 22.7 See merge request sfcc/zinrelo-cyntexa!75
2 parents ca23eb4 + becabe5 commit b6221ea

3 files changed

Lines changed: 21 additions & 1 deletion

File tree

cartridges/int_zinrelo_sfra/cartridge/scripts/helpers/zinreloAuthDataHelpers.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,13 @@ function getZinreloMemberID(customer) {
3838
* @returns {Object} user data for JWT
3939
*/
4040
function generateUserDataForJWT(customer) {
41+
const { getAPIKeyIdentifier } = require('*/cartridge/scripts/helpers/zinreloPreferencesHelpers');
4142
var userData = {};
4243

4344
if (customer) {
4445
userData = {
4546
member_id: getZinreloMemberID(customer),
47+
sub: getAPIKeyIdentifier(),
4648
email_address: customer.email,
4749
first_name: customer.firstName || '',
4850
last_name: customer.lastName || '',

cartridges/int_zinrelo_sfra/cartridge/scripts/helpers/zinreloPreferencesHelpers.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ function getAPIKey() {
3737
return apiKey;
3838
}
3939

40+
/**
41+
* Gets API key from the preferences
42+
* @returns {string} API key identifier
43+
*/
44+
function getAPIKeyIdentifier() {
45+
var apiKey = currentSite.getCustomPreferenceValue('zinreloAPIKeyIdentifier') || '';
46+
return apiKey;
47+
}
48+
4049
/**
4150
* Checks whether Zinrelo is enabled in the preferences or not
4251
* @returns {boolean} whether Zinrelo is enabled
@@ -110,5 +119,6 @@ module.exports = {
110119
isZinreloRewardsEnabledOnPDP: isZinreloRewardsEnabledOnPDP,
111120
isZinreloOrderCreationEventEnabled: isZinreloOrderCreationEventEnabled,
112121
isZinreloOrderPlacedEventEnabled: isZinreloOrderPlacedEventEnabled,
113-
getZinreloCartSessionTimeout: getZinreloCartSessionTimeout
122+
getZinreloCartSessionTimeout: getZinreloCartSessionTimeout,
123+
getAPIKeyIdentifier: getAPIKeyIdentifier
114124
};

metadata/meta/system-objecttype-extensions.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,13 @@
158158
<externally-managed-flag>false</externally-managed-flag>
159159
<min-length>0</min-length>
160160
</attribute-definition>
161+
<attribute-definition attribute-id="zinreloAPIKeyIdentifier">
162+
<display-name xml:lang="x-default">Zinrelo API Key Identifier</display-name>
163+
<type>string</type>
164+
<mandatory-flag>false</mandatory-flag>
165+
<externally-managed-flag>false</externally-managed-flag>
166+
<min-length>0</min-length>
167+
</attribute-definition>
161168
<attribute-definition attribute-id="zinreloCartSessionTimeout">
162169
<display-name xml:lang="x-default">Cart Session Timeout (In minutes)</display-name>
163170
<type>int</type>
@@ -236,6 +243,7 @@
236243
<attribute attribute-id="zinreloEnableLoyalty"/>
237244
<attribute attribute-id="zinreloPartnerID"/>
238245
<attribute attribute-id="zinreloAPIKey"/>
246+
<attribute attribute-id="zinreloAPIKeyIdentifier"/>
239247
<attribute attribute-id="zinreloWebhookURL"/>
240248
<attribute attribute-id="zinreloEnableInCartRedemption"/>
241249
<attribute attribute-id="zinreloEnableRewardsOnPDP"/>

0 commit comments

Comments
 (0)