Checkout

Para criar um pedido com checkout, é necessário fazer uma requisição para a nossa API de checkout. O objeto checkout contêm as seguintes propriedades:

AtributosTipoDescrição
accepted_payment_methodsarray of stringMeios de pagamento aceitos para o checkout. Valores possíveis: credit_card, debit_card, boleto, voucher e bank_transfer, pix.
accepted_multi_payment_methodsarray of array of stringMeios de pagamentos aceitos para permitir ao cliente a opção de multimeios. Valores possíveis: credit_card, boleto e credit_card, credit_card .
default_payment_methodstringMeio de pagamento padrão.
success_urlstringURL para redirecionamento de sucesso.
debit_cardobject_Configurações para pagamento com cartão de débito. Saiba mais sobre cartão de débito.
credit_cardobjectConfigurações para pagamento com cartão de crédito. Saiba mais sobre cartão de crédito
credit_card.capturebooleanIndica se a transação deve ser capturada ou somente autorizada. Caso seja true, o valor é capturado simultaneamente à autorização.
credit_card.statement_descriptorstringTexto da fatura do cartão.
credit_card.installmentsarray of objectsArray de configurações de parcelas.
credit_card.installments.numbernumberQuantidade de parcelas.
credit_card.installments.totalnumberValor total referente à quantidade de parcelas.
boletoobjectConfigurações para pagamento com boleto.
boleto.due_atstringData de vencimento do boleto.
boleto.instructionsstringInstruções do boleto.
skip_checkout_success_pagebooleanPermite pular a tela de redirecionamento pós pagamento.
customer_editablebooleanTorna o objeto do cliente editável.
metadataobjectObjeto chave/valor utilizado para armazenar informações adicionais sobre o pagamento.Saiba mais sobre metadata.
bank_transferobjectConfigurações para pagamento via transferência bancária.
bank_transfer.bankarray of objectsArray de configurações para indicar quais bancos serão utilizados para a transferência bancária.
expires_inintegerTempo, em minutos, para a expiração do checkout. Caso não seja enviado, o checkout não irá expirar.
billing_address_editablebooleanTorna o objeto billing address editável.
billing_addressobjectConfiguração para endereço de cobrança.
voucherobjectConfigurações para pagamento com voucher. Saiba mais sobre voucher.
pixobjectConfigurações para pagamento com PIX
[Saiba mais sobre PIX]
(https://docs.pagar.me/v5/reference#pix-1)
{
   "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", "pix", "bank_transfer", "voucher","debit_card"],
           "accepted_multi_payment_methods": [ 
		      		["credit_card","credit_card"],
		      		["credit_card","boleto"]
		   			],
           "success_url": "https://www.pagar.me",
           "bank_transfer": {
             "bank": ["237", "001", "341"]
           },
           "boleto": {
             "bank": "033",
             "instructions": "Pagar até o vencimento",
             "due_at": "2020-07-25T00:00:00Z"
         },
           "credit_card": {
              "capture": true,
              "statement_descriptor": "Desc na fatura",
              "installments": [
                {
                  "number": 1,
                  "total": 2000
                },
                {
                  "number": 2,
                  "total": 2500
                }
             ]
           },"pix": {
           		"expires_in": 100000
           },"voucher":{
           		"capture": true,
           		"statement_descriptor": "pagar.me"
           },
          "debit_card": {
             "authentication":{
               "statement_descriptor": "Desc na fatura",
               "type":"threed_secure",
               "threed_secure":{
                 "mpi":"acquirer",
                 "success_url":"http://www.pagar.me"
               }
             }
           }
         }
      }
   ]
}
{
  "id": "or_3AQ5bRgsyzfe5KEr",
  "code": "Z9GQZSVHX8",
  "amount": 2990,
  "currency": "BRL",
  "closed": false,
  "items": [
    {
      "id": "oi_1Y6DxKAUNXtvgMOW",
      "type": "product",
      "description": "Chaveiro do Tesseract",
      "amount": 2990,
      "quantity": 1,
      "status": "active",
      "created_at": "2020-07-06T22:53:47Z",
      "updated_at": "2020-07-06T22:53:47Z"
    }
  ],
  "customer": {
    "id": "cus_QaJd1LRfxF0g3KDP",
    "name": "Tony Stark",
    "email": "[email protected]",
    "delinquent": false,
    "created_at": "2020-07-06T22:42:09Z",
    "updated_at": "2020-07-06T22:42:09Z",
    "phones": {}
  },
  "status": "pending",
  "created_at": "2020-07-06T22:53:47Z",
  "updated_at": "2020-07-06T22:53:47Z",
  "checkouts": [
    {
      "id": "chk_GmMAkj7h2U6ONrW5",
      "currency": "BRL",
      "amount": 2000,
      "status": "open",
      "success_url": "https://www.pagar.me",
      "payment_url": "https://api.pagar.me/checkout/v1/orders/chk_GmMAkj7h2U6ONrW5",
      "customer_editable": false,
      "billing_address_editable": true,
      "skip_checkout_success_page": true,
      "shippable": false,
      "created_at": "2020-07-06T22:53:47Z",
      "updated_at": "2020-07-06T22:53:47Z",
      "accepted_payment_methods": [
        "credit_card",
        "boleto",
        "bank_transfer",
        "voucher",
        "debit_card"
      ],
      "accepted_multi_payment_methods": [
        [
          "credit_card",
          "credit_card"
        ],
        [
          "credit_card",
          "boleto"
        ]
      ],
      "customer": {
        "id": "cus_QaJd1LRfxF0g3KDP",
        "name": "Tony Stark",
        "email": "[email protected]",
        "delinquent": false,
        "created_at": "2020-07-06T22:42:09Z",
        "updated_at": "2020-07-06T22:42:09Z",
        "phones": {}
      },
      "credit_card": {
        "capture": true,
        "statementDescriptor": "Desc na fatura",
        "statement_descriptor": "Desc na fatura",
        "authentication": {
          "type": "none",
          "threed_secure": {}
        },
        "installments": [
          {
            "number": 1,
            "total": 2000
          },
          {
            "number": 2,
            "total": 2500
          }
        ]
      },
      "debit_card": {
        "authentication": {
          "type": "threed_secure",
          "threed_secure": {
            "mpi": "acquirer",
            "success_url": "http://www.pagar.me"
          }
        }
      },
      "boleto": {
        "due_at": "2020-07-25T00:00:00Z",
        "instructions": "Pagar até o vencimento"
      },
      "voucher": {
        "capture": true,
        "statement_descriptor": "pagar.me"
      },
      "billing_address": {},
      "metadata": {}
    }
  ]
}
//This example was built using MundiAPI-PHP SDK.
//For more information, please refer to https://github.com/mundipagg/MundiAPI-PHP

$secretKey = 'sk_test_4tdVXpseumRmqbo'; //the secret key will be provided by MundiPagg.
$basicAuthPassword = ''; //fill it with an empty string

$apiClient = new \MundiAPILib\MundiAPIClient(
    $secretKey,
    $basicAuthPassword
);

$orderController = $apiClient->getOrders();

$customer = new \MundiAPILib\Models\CreateCustomerRequest();
$customer->name = "Tony Stark";
$customer->email = "[email protected]";

$checkout = new \MundiAPILib\Models\CreateCheckoutPaymentRequest();
$checkout->customerEditable = false;
$checkout->skipCheckoutSuccessPage = true;
$checkout->acceptedPaymentMethods = ["credit_card", "boleto", "bank_transfer", "debit_card"];
$checkout->acceptedMultiPaymentMethods = [["credit_card", "credit_card"], ["credit_card", "boleto"]];
$checkout->successUrl = "https://www.mundipagg.com";

//Bank transfer payment Setup;
$checkout->bankTransfer = new \MundiAPILib\Models\CreateCheckoutBankTransferRequest();
$checkout->bankTransfer->bank = ["237", "001", "341"];

//Boleto Payment Setup;
$checkout->boleto = new \MundiAPILib\Models\CreateCheckoutBoletoPaymentRequest();
$checkout->boleto->bank = "033";
$checkout->boleto->instructions ="Pagar ate o vencimento";
$checkout->boleto->dueAt = new \DateTime("2021-07-25T00:00:00Z");

//Credit Card Payment Setup;
$checkout->creditCard = new \MundiAPILib\Models\CreateCheckoutCreditCardPaymentRequest();
$checkout->creditCard->capture = true;
$checkout->creditCard->statement_descriptor = "Descriptor example";
$checkout->creditCard->installments = [ //Credit card installments Setup
    new \MundiAPILib\Models\CreateCheckoutCardInstallmentOptionRequest(),
    new \MundiAPILib\Models\CreateCheckoutCardInstallmentOptionRequest()
];
// installment 1;
$checkout->creditCard->installments[0]->number = 1;
$checkout->creditCard->installments[0]->total = 2000;
// installment 2 with extra tax of 500;
$checkout->creditCard->installments[1]->number = 1;
$checkout->creditCard->installments[1]->total = 2500;

// Debit Card Payment Setup;
$checkout->debitCard = new \MundiAPILib\Models\CreateCheckoutDebitCardPaymentRequest();
// Debit card Authentication Setup;
$checkout->debitCard->authentication = new \MundiAPILib\Models\CreatePaymentAuthenticationRequest();
$checkout->debitCard->authentication->type = 'threed_secure';
$checkout->debitCard->authentication->threedSecure = new \MundiAPILib\Models\CreateThreeDSecureRequest();
$checkout->debitCard->authentication->threedSecure->mpi = "acquirer";
$checkout->debitCard->authentication->threedSecure->successUrl = "https://www.mundipagg.com";

$request = new \MundiAPILib\Models\CreateOrderRequest();

$request->items = [new \MundiAPILib\Models\CreateOrderItemRequest()];
$request->items[0]->description = "Tesseract Bracelet";
$request->items[0]->quantity = 1;
$request->items[0]->amount = 2990; // this value should be in cents

$request->payments = [new \MundiAPILib\Models\CreatePaymentRequest()];
$request->payments[0]->amount = 2000; // this value should be in cents
$request->payments[0]->paymentMethod = "checkout";
$request->payments[0]->checkout = $checkout;
$request->customer = $customer;

$result = new \MundiAPILib\Models\GetOrderResponse();
$result->checkouts = [new \MundiAPILib\Models\GetCheckoutPaymentResponse()];
$result = $orderController->createOrder($request);

echo json_encode($result, JSON_PRETTY_PRINT);
from mundiapi.mundiapi_client import MundiapiClient
from mundiapi.models import *
from mundiapi.controllers import *
from mundiapi.exceptions.error_exception import *

MundiapiClient.config.basic_auth_user_name = "SUA_SECRET_KEY:"
orders_controller = orders_controller.OrdersController()

customer = create_customer_request.CreateCustomerRequest()
customer.name = "Tony Stark"
customer.email = "[email protected]"

checkout = create_checkout_payment_request.CreateCheckoutPaymentRequest()
checkout.customer_editable = False
checkout.skip_checkout_success_page = True
checkout.accepted_payment_methods = ["credit_card", "boleto", "bank_transfer", "debit_card"]
checkout.accepted_multi_payment_methods = [["credit_card", "credit_card"], ["credit_card", "boleto"]]
checkout.success_url = "https://www.mundipagg.com"

#Bank transfer payment Setup
checkout.bank_transfer = create_checkout_bank_transfer_request.CreateCheckoutBankTransferRequest()
checkout.bank_transfer.bank = ["237", "001", "341"]

#Boleto Payment Setup
checkout.boleto = create_checkout_boleto_payment_request.CreateCheckoutBoletoPaymentRequest()
checkout.boleto.bank = "033"
checkout.boleto.instructions ="Pagar ate o vencimento"
checkout.boleto.due_at = "2021-07-25T00:00:00Z"

#Credit Card Payment Setup
checkout.credit_card = create_checkout_credit_card_payment_request.CreateCheckoutCreditCardPaymentRequest()
checkout.credit_card.capture = True
checkout.credit_card.statement_descriptor = "Descriptor example"
checkout.credit_card.installments = [ # Credit card installments Setup
    create_checkout_card_installment_option_request.CreateCheckoutCardInstallmentOptionRequest(),
    create_checkout_card_installment_option_request.CreateCheckoutCardInstallmentOptionRequest()]
# installment 1
checkout.credit_card.installments[0].number = 1
checkout.credit_card.installments[0].total = 2000
# installment 2 with extra tax of 500
checkout.credit_card.installments[1].number = 1
checkout.credit_card.installments[1].total = 2500

# Debit Card Payment Setup
checkout.debit_card = create_checkout_debit_card_payment_request.CreateCheckoutDebitCardPaymentRequest()
# Debit card Authentication Setup
checkout.debit_card.authentication = create_payment_authentication_request.CreatePaymentAuthenticationRequest()
checkout.debit_card.authentication.mtype = 'none'
checkout.debit_card.authentication.threed_secure = create_three_d_secure_request.CreateThreeDSecureRequest()
checkout.debit_card.authentication.threed_secure.mpi = "acquirer"
checkout.debit_card.authentication.threed_secure.success_url = "https://www.mundipagg.com"

request = create_order_request.CreateOrderRequest()
request.code = "test-SDK-python"
request.items = [create_order_item_request.CreateOrderItemRequest()]
request.items[0].description = "Tesseract Bracelet"
request.items[0].quantity = 1
request.items[0].amount = 2990

request.payments = [create_payment_request.CreatePaymentRequest()]
request.payments[0].amount = 2000
request.payments[0].payment_method = "checkout"
request.payments[0].checkout = checkout
request.customer = customer

try:
    result = get_order_response.GetOrderResponse()
    result.checkouts = [get_checkout_payment_response.GetCheckoutPaymentResponse()]
    result = orders_controller.create_order(request)
    print("Order id: ", result.id)
    print("Checkout id: ", result.checkouts[0].id)
    print("Order result status: ", result.status)
    print("Checkout payment url: ", result.checkouts[0].payment_url)
    assert result.status == "pending"
    assert result.checkouts[0].boleto is not None
    assert result.checkouts[0].credit_card is not None
    assert result.checkouts[0].debit_card is not None
    assert result.checkouts[0].bank_transfer is not None
    assert result.checkouts[0].payment_url is not None
except ErrorException as ex:
    print("\n")
    print("Error Message: ", ex.message)
    print("Status code Response: ", ex.response_code)
    if(ex.errors is not None):
        print("Errors: ", ex.errors)
except Exception as ex:
    raise ex

❗️

CHECKOUT APLICA-SE APENAS A PEDIDOS

É importante notar que o meio de pagamento checkout é suportado somente por pedidos, não podendo ser utilizado em cobranças.