File tree Expand file tree Collapse file tree
cartridges/int_zinrelo_sfra/cartridge/scripts/helpers Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -38,11 +38,13 @@ function getZinreloMemberID(customer) {
3838 * @returns {Object } user data for JWT
3939 */
4040function 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 || '' ,
Original file line number Diff line number Diff 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} ;
Original file line number Diff line number Diff line change 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 >
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" />
You can’t perform that action at this time.
0 commit comments