pagarme-js icon indicating copy to clipboard operation
pagarme-js copied to clipboard

Checkout transparente backend

Open BrenoMazieiro opened this issue 3 years ago • 2 comments

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?

BrenoMazieiro avatar Oct 18 '21 19:10 BrenoMazieiro

Estou na mesma, na doc deles não tem nada dizendo sobre isso

augusto3691 avatar Oct 19 '21 11:10 augusto3691

Infelizmente de uns 2 anos pra cá, a documentação deles ficou muito ruim.

jhonathas avatar Jun 29 '22 13:06 jhonathas