Guides
Credit card
Create a test payment_token, charge a card, handle refusals by the last digit, retry and refund.
With a card, Efí analyzes the charge right away and answers approved or refused in the same call. Card data never reaches your server: Efí's JavaScript library exchanges it for a 40-character hexadecimal payment_token, and that's what you send. Authentication and host are in Boleto and Bolix.
1. Create a payment_token
In Mimicr, the cobrancas.card_token action plays the JavaScript library:
curl --request POST \
--url https://api.mimicr.dev/v1/efi/actions/cobrancas.card_token \
--header 'Authorization: Bearer mk_...' \
--header 'Content-Type: application/json' \
--data '{ "number": "4111111111111115", "brand": "visa" }'{ "ok": true, "action": "cobrancas.card_token", "message": "payment_token: 3f9c…5", "data": { "payment_token": "3f9c…5" } }With the CLI: npx mimicr action efi cobrancas.card_token number=4111111111111115 brand=visa. brand accepts visa, mastercard, amex, elo, diners and hipercard. The token keeps the brand, the BIN and the last 4 digits, which show up in mask (411111XXXXXX1115).
In homologation, the card's last digit decides the analysis:
| Last digit | Result | refusal.reason | retry |
|---|---|---|---|
1 | Refused | Dados do cartão inválidos. | false |
2 | Refused | Transação não autorizada por motivos de segurança. | false |
3 | Refused | Transação não autorizada, tente novamente mais tarde. | true |
| other | Approved |
Any 40-character hexadecimal payment_token is accepted. A token that didn't come from the action is treated as Visa, and its last character plays the last digit (letters count as their hex value modulo 10: a approves, b refuses like 1). The retry value of each refusal is Mimicr's choice; Efí doesn't document it.
2. Charge the card
curl --request POST \
--url https://cobrancas.efi.mimicr.dev/v1/charge/one-step \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"items": [{ "name": "Meu Produto", "value": 5990, "amount": 1 }],
"metadata": { "notification_url": "https://sua-app.dev/webhooks/efi" },
"payment": {
"credit_card": {
"customer": { "name": "Gorbadoc Oldbuck", "cpf": "94271564656", "email": "oldbuck@efipay.com.br", "phone_number": "5144916523", "birth": "1977-01-15" },
"installments": 1,
"payment_token": "<payment_token>",
"billing_address": { "street": "Avenida Juscelino Kubitschek", "number": "909", "neighborhood": "Bauxita", "zipcode": "35400000", "city": "Ouro Preto", "state": "MG" }
}
}
}'Approved:
{ "code": 200, "data": { "installments": 1, "installment_value": 5990, "charge_id": 1000007, "status": "approved", "total": 5990, "payment": "credit_card" } }approved becomes paid about 4 seconds later (the capture), with a notification for each change. Refused, the response is still HTTP 200:
{ "code": 200, "data": { "installments": 1, "installment_value": 5990, "charge_id": 1000004, "status": "unpaid", "refusal": { "retry": false, "reason": "Dados do cartão inválidos." }, "total": 5990, "payment": "credit_card" } }A card requires the payer's email and phone_number; without them, 3500034. installments goes from 1 to 12 (4600089 above that). The two-step flow is the same as the boleto's: Create a charge and Set the payment method with credit_card.
To show the installments to the payer first, use List card installments:
curl --url 'https://cobrancas.efi.mimicr.dev/v1/installments?brand=visa&total=47988' \ --header 'Authorization: Bearer <token>'
In Mimicr, up to 2 installments have no interest; from 3 to 12, 1.99% a month (interest_percentage: 199).
3. Retry a refusal
An unpaid card charge accepts a new attempt with another token:
curl --request POST \
--url https://cobrancas.efi.mimicr.dev/v1/charge/1000004/retry \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"payment": {
"credit_card": {
"customer": { "name": "Gorbadoc Oldbuck", "cpf": "94271564656", "email": "oldbuck@efipay.com.br", "phone_number": "5144916523" },
"billing_address": { "street": "Avenida Juscelino Kubitschek", "number": "909", "neighborhood": "Bauxita", "zipcode": "35400000", "city": "Ouro Preto", "state": "MG" },
"payment_token": "<new payment_token>"
}
}
}'The response has the same shape. Outside unpaid, the answer is 3500081 invalid_status. Reference: Retry a card payment.
4. Refund
curl --request POST \
--url https://cobrancas.efi.mimicr.dev/v1/charge/card/1000007/refund \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "amount": 1000 }'{ "code": 200, "data": "Reembolso em processamento" }Without amount, the whole total is refunded. Only paid charges, without marketplace, one refund at a time (3500081 or 3500101). In Mimicr, the charge becomes refunded a few seconds later. Reference: Refund a card payment.
The other side
| Action | Effect |
|---|---|
cobrancas.charge with action=contestar | The payer disputes (chargeback): paid becomes contested |
cobrancas.charge with action=reembolsar | Full refund from Efí's side; becomes refunded shortly |
cobrancas chaos with opsFailRate | Refuses the analysis with production reasons (for example "Transação não autorizada. Cartão inválido") and retry: true |
See Sandbox control for chaos and the control API.
new ──pay(card)──▶ waiting ──analysis──▶ approved ──~4 s──▶ paid ──refund──▶ refunded
└──refusal──▶ unpaid ──retry──▶ waiting ──▶ …
paid ──contestar──▶ contested