exports.paymentToken = async (req, res, next) => {
EfiJs.CreditCard.debugger(true);
try {
const result = await EfiJs.CreditCard
.setAccount('')
.setEnvironment('sandbox') // 'production' or 'sandbox'
.setCreditCardData({
brand: 'visa',
number: '4485785674290087',
cvv: '123',
expirationMonth: '05',
expirationYear: '2029',
reuse: false
}) .getPaymentToken();
console.log('result', result);
const payment_token = result.payment_token;
const card_mask = result.card_mask;
console.log('payment_token', payment_token);
console.log('card_mask', card_mask);
return res.send({
request: true,
success: true,
message: 'Pagamento cartão!',
payment_token:payment_token,
card_mask:card_mask
});
} catch (error) {
console.log('Código: ', error.code);
console.log('Nome: ', error.error);
console.log('Mensagem: ', error.error_description);
return res.send({
request: true,
success: false,
message: 'Pagamento cartão!',
});
}