cancel
Showing results for 
Search instead for 
Did you mean: 

Interceptor not executed during impex import (impex.legacy.mode is false)

Former Member
0 Kudos

Hi All,

We have a requirement where we have to use the Encryption key from a Third Party Engine and encrypt the credit card number using that key. We have disabled the OOB credit card number encryption as mentioned in the below link https://wiki.hybris.com/display/forum/INFO+How+to+disable+encryption+of+creditcard+numbers

To encrypt the credit card number, we have written a PrepareInterceptor on CreditCardPaymenInfo item type. This interceptor will encrypt the credit card number from the Third party engine. Similarly we have created one LoadInterceptor that will decrypt the credit card number from the Third party engine.

Interceptor beans in customextension-spring.xml file:

 <property name="interceptor" ref="creditCardPaymentInfoPrepareInterceptor"/>
 <property name="typeCode" value="CreditCardPaymentInfo"/>
 
 

 

 <property name="interceptor" ref="creditCardPaymentInfoLoadInterceptor"/>
 <property name="typeCode" value="CreditCardPaymentInfo"/>
 

The interceptors are getting called while creating/viewing the credit cards from the storefront(checkout process) and hmc.

Issue: The interceptors are not getting called when we import the impex for CreditCardPaymenInfo and hence the credit card number got saved as a plain text in database. Also, impex.legacy.mode is false but still the issue persists.

Former Member
0 Kudos

Interceptor beans in customextension-spring.xml file:

 <bean id="creditCardPaymentInfoPrepareInterceptorMapping" class="de.hybris.platform.servicelayer.interceptor.impl.InterceptorMapping" scope="tenant">
     <property name="interceptor" ref="creditCardPaymentInfoPrepareInterceptor"/>
     <property name="typeCode" value="CreditCardPaymentInfo"/>
 </bean> 
 

 <bean id="creditCardPaymentInfoLoadInterceptor" class="com.unifirst.core.interceptor.UNFCreditCardPaymentInfoLoadInterceptor" scope="tenant" autowire="byName"/>
 
 <bean id="creditCardPaymentInfoLoadInterceptorMapping" class="de.hybris.platform.servicelayer.interceptor.impl.InterceptorMapping" scope="tenant">
     <property name="interceptor" ref="creditCardPaymentInfoLoadInterceptor"/>
     <property name="typeCode" value="CreditCardPaymentInfo"/>
 </bean> 

Accepted Solutions (1)

Accepted Solutions (1)

Former Member

Ruchi,

Since hybris Commerce Suite version 5.1.1, import will switch dynamically to the legacy mode if it encounters "allownull" or "forceWrite" as parameter of header line.

This is written in TIp of Attribute-Related Modifiers section of the following wiki page https://wiki.hybris.com/display/release5/ImpEx+Syntax

All the impex import you have specified about has allownull in the header. If you are using hybris version 5.1.1 and above you will see this issue.

Thanks, Sachin

Answers (4)

Answers (4)

Former Member
0 Kudos

Sachin/Ruchi -- Can you think of any reason for not generating a separate jalo class for CreditCardPaymentInfo ?

bikrambsinha
Participant
0 Kudos

Hi Ruchi,

First of all, storing credit card information in Hybris is not a good option and PCI compliance doesn't recommend the same. Why do you want to store the Credit card information ?

Please try the following if you have the right requirement. de.hybris.platform.jalo.order.payment.PaymentInfo with the custom logic like the below. You can plug-in your own encryption and decryption logic in setProperty() and getProperty() methods.

Please refer to the below link.

https://wiki.hybris.com/display/forum/Encryption+of+CreditCard+Numbers?focusedCommentId=42796059#com...

bikrambsinha
Participant
0 Kudos

First of all, storing credit card information in Hybris is not a good option and PCI compliance doesn't recommend the same. Why do you want to store the Credit card information ?

Please try the following if you have the right requirement. de.hybris.platform.jalo.order.payment.PaymentInfo with the custom logic like the below. You can plug-in your own encryption and decryption logic in setProperty() and getProperty() methods.

Please refer to the below link.

https://wiki.hybris.com/display/forum/Encryption+of+CreditCard+Numbers?focusedCommentId=42796059#com...

Former Member
0 Kudos

exactly what I thought, if you search for CreditCardPaymentInfo in core-items.xml file, you will realize that on item type definition, generate modifier is set to 'false' and the parent class is PaymentInfo. this means that jalo class will get generated for PaymentInfo but not for CreditCardPaymentInfo,


With a decompiler if you delve into paymentInfo.class file, you will see CreditCardPaymentInfo as a static public class. The intricacies of Impex Framework is still a mystery to me and not sure why jalo layer is still so tightly linked. It would be great if someone can explain us in detail. anyways, back to the solution

  • Writing your own version of CreditCardPaymentInfo and keeping generate modifier = true
  • Define UNFCreditCardPaymentInfo extends CreditCartPaymentInfo and generate = true
  • Write your logic at a common place and call it from your Controller code and translator code
  • Modify core-items.xml file, bad idea
Former Member
0 Kudos

Thanks Saurabh.

I found the same issue in the CreditCardPaymentInfo and PaymentInfo classes. There is no separate jalo class for CreditCardPaymentInfo and may be that is the issue. I have written a translator for the same now. Though I am still not very clear why the interceptor did not execute for CreditCardPaymentInfo as interceptors are supposed to work at Model Layer and not the Jalo layer.

Former Member
0 Kudos

Thanks Saurabh,

As per wiki, https://wiki.hybris.com/display/release5/Interceptors#Interceptors-ImplementanInterceptor "Prepare interceptor is called before the impex translators."

We have custom prepare interceptors for B2BCustomer item type as well and it is getting executed when I import the B2BCustomer impex.

But when we import the credit card impex, the CreditCardPaymentInfo interceptor does not execute. We are using the below impex for credit cards:

$cardtype=type(code) INSERT_UPDATE CreditCardPaymentInfo;code[unique=true];user(B2BCustomer.uid);paymentName;number[allownull=true];$cardtype;ccOwner[allownull=true];validToMonth[allownull=true];validToYear[allownull=true];issueNumber;billingAddress(unfAddressId); ;TestCC1;C21546;VISA Ruchi;4444333322226666;visa;;12;2019;0;

Former Member
0 Kudos

Ruchi, What is the hybris version you are using?

Former Member
0 Kudos

Check the post by Luke GJ Potter at the link below

https://answers.sap.com/questions/12756513/how-to-intercept-a-relation-after-changing-model.html

you can write an impex translator and impement your business logic in performImport method. if you do modelService.save() from within this method, your interceptor should get called.