eu faço assim:
ts
import as EfiPay from "payment-token-efi"
export type CreditCardProps = {
brand: string
cardNumber: string
cvv: string
expirationMonth: string
expirationYear: string
}
interface PaymentTokenResponse {
card_mask: string
payment_token: string
}
export const getPaymentToken = async (card: CreditCardProps): Promise => {
try {
const creditCard = EfiPay.default.CreditCard
.setAccount(import.meta.env.VITE_EFI_BANK_PAYEE_CODE)
.setEnvironment(import.meta.env.VITE_EFI_BANK_ENVIRONMEN)
.setCreditCardData({
brand: card.brand,
number: card.cardNumber,
cvv: card.cvv,
expirationMonth: card.expirationMonth,
expirationYear: card.expirationYear,
reuse: false
})
return await creditCard.getPaymentToken() as PaymentTokenResponse
} catch (error: any) {
console.log('Código: ', error.code);
console.log('Nome: ', error.error);
console.log('Mensagem: ', error.error_description);
}
}