pagarme-js
pagarme-js copied to clipboard
Checkout transparente backend
Description
Estou tentando implementar um checkout transparente
import pagarme from 'pagarme'
const body = {
"items": [{
"amount": 2990,
"description": "Chaveiro do Tesseract",
"quantity": 1
}],
"customer": {
"name": "Tony Stark",
"email": "[email protected]"
},
"payments": [{
"payment_method": "checkout",
"amount": 2000,
"checkout": {
"customer_editable": false,
"skip_checkout_success_page": true,
"accepted_payment_methods": ["credit_card", "boleto", "bank_transfer", "voucher", "debit_card"],
"accepted_multi_payment_methods": [
["credit_card", "credit_card"],
["credit_card", "boleto"]
],
"success_url": "https://www.meusite.com",
"credit_card": {
"capture": true,
"statement_descriptor": "Desc na fatura",
"installments": [{
"number": 1,
"total": 2000
},
{
"number": 2,
"total": 2500
}
]
},
}
}]
};
pagarme.client.connect({ api_key: 'ak_test_YOURKEY' })
.then(client => client.transactions.all(body))
.then(transactions => console.log({ transactions }))
.catch(error => {
console.log(error?.response?.errors || error)
})
My Setup
- Operating System: Linux
- Project Version:
- [ X ] I have tested with the latest version
- [ X ] I can simulate the issue easily
Current Behavior
Recebo { transactions: [] }
como retorno
Expected Behavior
Deveria receber o que está descrito no manual (https://docs.pagar.me/reference#checkout-pagarme):
{
"id": "or_GqAlNNOsDLcAlvbP",
"code": "LKKMFJPU9M",
"amount": 3000,
"currency": "BRL",
"closed": false,
"items": [...],
"customer": {...},
"status": "pending",
"created_at": "2018-03-28T18:48:49Z",
"updated_at": "2018-03-28T18:48:49Z",
"checkouts": [
{
"id": "chk_ON0Q6MU8EIWGY386",
"amount": 3000,
"status": "open",
"success_url": "https://www.meusite.com",
"payment_url": "https://api.pagar.me/checkout/v5/orders/chk_ON0Q6MU8EIWGY386",
"customer_editable": true,
"billing_address_editable": true,
"skip_checkout_success_page": false,
"created_at": "2018-03-28T18:48:49Z",
"updated_at": "2018-03-28T18:48:49Z",
"expires_at": "2018-03-28T20:48:49Z",
"accepted_payment_methods": ["credit_card"],
"customer": {...},
"credit_card": {...},
"billing_address": {...},
"shippable": false,
"currency": "BRL",
"metadata": {...}
}
]
}
Se ao inves de usar client.transactions.all
utilizo client.transactions.create
Recebo como resposta
[
{
type: 'validation_error',
parameter_name: 'billing',
message: '"value" is required'
}
]
O que não faz sentido, uma vez que eu vou ter o link no qual o usuário vai fazer todo o cadastro de pagamento como na foto também disponÃvel em https://docs.pagar.me/reference#checkout-pagarme
Como proceder?
Estou na mesma, na doc deles não tem nada dizendo sobre isso
Infelizmente de uns 2 anos pra cá, a documentação deles ficou muito ruim.