-
Since using SecureFields injects iframe's to protect card data, we are unable to access those card values. Then, how am I supposed to fill In the docs you are using async function createCardToken(event) {
try {
const tokenElement = document.getElementById('token');
if (!tokenElement.value) {
event.preventDefault();
const token = await mp.fields.createCardToken({
cardholderName: document.getElementById('form-checkout__cardholderName').value,
identificationType: document.getElementById('form-checkout__identificationType').value,
identificationNumber: document.getElementById('form-checkout__identificationNumber').value,
});
tokenElement.value = token.id;
formElement.requestSubmit();
}
} catch (e) {
console.error('error creating card token: ', e)
}
} but with iframes Any alternatives? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Hello @ihojmanb 😸 Please take a look at https://github.com/mercadopago/sdk-js/blob/main/API/fields.md#mp-instancefieldscreatecardtokennonpcidata |
Beta Was this translation helpful? Give feedback.
Hello @ihojmanb 😸
Secure Fields use iFrames to do not expose PCI data such as
cardNumber
,expirationDate
andsecurityCode
, so you do not need to worry about it onmp.fields.createCardToken
method. This is actually the reason for the iframes to exist. About you getting undefined, please make sure the page is loading properly, I’ve tested on a local example, and I was able to get the data fromdocument.getElementById('form-checkout__cardholderName').value
Please take a look at https://github.com/mercadopago/sdk-js/blob/main/API/fields.md#mp-instancefieldscreatecardtokennonpcidata