For tokenization of existing customer credit cards, it is required to export stored credit cards.
For tokenization of existing customer credit cards, it is required to export stored credit cards.
Exporting credit card data can be accomplished via custom job as outlined below:
1. Create an RSA key-pair
openssl req -x509 -newkey rsa:2048 -keyout nopass.key -out nopass.crt -days 365 -nodes
openssl pkcs12 -export -out nopass.p12 -inkey nopass.key -in nopass.crt
2. Upload the nopass.crt (certificate) and nopass.p12 (private key) into Business Manager via Administration > Operations > Private Keys and Certificates.
3. Create a job through the customer base and export the credit card data via getEncryptedCreditCardNumber.
var profile : dw.customer.Profile = dw.customer.CustomerMgr.getProfile('00000003');
var instruments : Collection = profile.getWallet().getPaymentInstruments(dw.order.PaymentInstrument.METHOD_CREDIT_CARD);
var certRef : dw.crypto.CertificateRef = new dw.crypto.CertificateRef("server");
var keyRef : dw.crypto.CertificateRef = new dw.crypto.KeyRef("private");
var custPay : PaymentInstrument = null;
var cipher : Cipher = null;
var encryCC = '';
var decCC = '';
for each (var e : PaymentInstrument in instruments){
encryCC = e.getEncryptedCreditCardNumber(dw.order.PaymentInstrument.ENCRYPTION_ALGORITHM_RSA, certRef);
if(!empty(encryCC)){
dw.system.Logger.error("CC " + encryCC);
}
}
4. You can decrypt the CC data using the imported private key.
cipher = new Cipher();
decCC = cipher.decrypt(encryCC, keyRef, dw.order.PaymentInstrument.ENCRYPTION_ALGORITHM_RSA, null, 0);
dw.system.Logger.error("CC_decrypted " + decCC);
Please note that the above is just an example. You should never store credit card information in plain text in log files, or anywhere else!
5. The exported encrypted data can be decrypted on the provider side with the private key.
//textCC.txt has the encrypted data cat textCC.txt | base64 -D | openssl rsautl -decrypt -inkey nopass.p12
The same procedure can be done for order payment instruments. You can use an API method to tokenize credit cards, as shown in the documentation PaymentInstrument.setCreditCardToken(token : String)
Exporting credit card data can be accomplished via custom job as outlined below:
1. Create an RSA key-pair
openssl req -x509 -newkey rsa:2048 -keyout nopass.key -out nopass.crt -days 365 -nodes
openssl pkcs12 -export -out nopass.p12 -inkey nopass.key -in nopass.crt
2. Upload the nopass.crt (certificate) and nopass.p12 (private key) into Business Manager via Administration > Operations > Private Keys and Certificates.
3. Create a job through the customer base and export the credit card data via getEncryptedCreditCardNumber.
var profile : dw.customer.Profile = dw.customer.CustomerMgr.getProfile('00000003');
var instruments : Collection = profile.getWallet().getPaymentInstruments(dw.order.PaymentInstrument.METHOD_CREDIT_CARD);
var certRef : dw.crypto.CertificateRef = new dw.crypto.CertificateRef("server");
var keyRef : dw.crypto.CertificateRef = new dw.crypto.KeyRef("private");
var custPay : PaymentInstrument = null;
var cipher : Cipher = null;
var encryCC = '';
var decCC = '';
for each (var e : PaymentInstrument in instruments){
encryCC = e.getEncryptedCreditCardNumber(dw.order.PaymentInstrument.ENCRYPTION_ALGORITHM_RSA, certRef);
if(!empty(encryCC)){
dw.system.Logger.error("CC " + encryCC);
}
}
4. You can decrypt the CC data using the imported private key.
cipher = new Cipher();
decCC = cipher.decrypt(encryCC, keyRef, dw.order.PaymentInstrument.ENCRYPTION_ALGORITHM_RSA, null, 0);
dw.system.Logger.error("CC_decrypted " + decCC);
Please note that the above is just an example. You should never store credit card information in plain text in log files, or anywhere else!
5. The exported encrypted data can be decrypted on the provider side with the private key.
//textCC.txt has the encrypted data cat textCC.txt | base64 -D | openssl rsautl -decrypt -inkey nopass.p12
The same procedure can be done for order payment instruments. You can use an API method to tokenize credit cards, as shown in the documentation PaymentInstrument.setCreditCardToken(token : String)
000391673

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.