Voucher

Para criar uma cobrança ou um pedido com voucher, devemos incluir o objeto voucher dentro do nó payment, assim como a propriedade "payment_method": "voucher". O objeto voucher contém as seguintes propriedades:

AtributosTipoDescrição
statement_descriptorstringTexto exibido na fatura do cartão. Max: 22 caracteres.
card, card_id ou card_tokenobjectCartão de crédito.
card_id é o identificador do cartão de um cliente.
***card_token*** é o token do cartão gerado pelo checkout transparente. Saiba mais sobre cartões.
card.holder_documentstringNúmero do documento do portador do cartão. Este campo deverá ser enviado dentro do objeto card e é obrigatório para voucher.
metadataobjectObjeto chave/valor utilizado para armazenar informações adicionais sobre o pagamento.Saiba mais sobre metadata.
{
	"items": [{
			"amount": 2990,
			"description": "Chaveiro do Tesseract",
			"quantity": 1
		}
	],
	"customer": {
		"name": "Tony Stark",
		"email": "[email protected]"
	},
	"payments": [{
			"payment_method": "voucher",
			"voucher": {
				"statement_descriptor": "AVENGERS",
				"card": {
					"number": "4000000000000010",
					"holder_name": "Tony Stark",
					"holder_document": "93095135270",
					"exp_month": 1,
					"exp_year": 30,
					"cvv": "351",
					"billing_address": {
						"line_1": "10880, Malibu Point, Malibu Central",
						"zip_code": "90265",
						"city": "Malibu",
						"state": "CA",
						"country": "US"
					}
				}
			}
		}
	]
}
{
	"id": "or_rW4pw5yck1fwdD7O",
	"code": "0WX7TE6BJ6",
	"amount": 2990,
	"currency": "BRL",
	"closed": true,
	"items": [{
			"id": "oi_D3XEBzJuE9hABb1a",
			"description": "Chaveiro do Tesseract",
			"amount": 2990,
			"quantity": 1,
			"status": "active",
			"created_at": "2019-01-22T14:20:18Z",
			"updated_at": "2019-01-22T14:20:18Z",
			"order": {
				"id": "or_rW4pw5yck1fwdD7O",
				"code": "0WX7TE6BJ6",
				"amount": 2990,
				"closed": true,
				"created_at": "2019-01-22T14:20:18Z",
				"updated_at": "2019-01-22T14:20:19Z",
				"closed_at": "2019-01-22T14:20:18Z",
				"currency": "BRL",
				"status": "paid",
				"customer_id": "cus_n3bqEzdsZUmNA7Qp",
				"items": [{
						"id": "oi_D3XEBzJuE9hABb1a",
						"description": "Chaveiro do Tesseract",
						"amount": 2990,
						"quantity": 1,
						"status": "active"
					}
				]
			}
		}
	],
	"customer": {
		"id": "cus_n3bqEzdsZUmNA7Qp",
		"name": "Tony Stark",
		"email": "[email protected]",
		"delinquent": false,
		"address": {
			"id": "addr_yEd4rG0HJNupdX2m",
			"line_1": "375, Av. General Justo, Centro",
			"line_2": "8º andar",
			"zip_code": "20021130",
			"city": "Rio de Janeiro",
			"state": "RJ",
			"country": "BR",
			"status": "active",
			"created_at": "2019-01-21T18:44:17Z",
			"updated_at": "2019-01-21T18:44:17Z",
			"metadata": {
				"id": "my_address_id"
			}
		},
		"created_at": "2019-01-21T18:36:30Z",
		"updated_at": "2019-01-21T18:44:17Z",
		"phones": {}
	},
	"status": "paid",
	"created_at": "2019-01-22T14:20:18Z",
	"updated_at": "2019-01-22T14:20:19Z",
	"closed_at": "2019-01-22T14:20:18Z",
	"charges": [{
			"id": "ch_dZWwGNQIgCgXyO14",
			"code": "0WX7TE6BJ6",
			"amount": 2990,
			"paid_amount": 2990,
			"status": "paid",
			"currency": "BRL",
			"payment_method": "voucher",
			"paid_at": "2019-01-22T14:20:19Z",
			"created_at": "2019-01-22T14:20:18Z",
			"updated_at": "2019-01-22T14:20:18Z",
			"customer": {
				"id": "cus_n3bqEzdsZUmNA7Qp",
				"name": "Tony Stark",
				"email": "[email protected]",
				"delinquent": false,
				"address": {
					"id": "addr_yEd4rG0HJNupdX2m",
					"line_1": "375, Av. General Justo, Centro",
					"line_2": "8º andar",
					"zip_code": "20021130",
					"city": "Rio de Janeiro",
					"state": "RJ",
					"country": "BR",
					"status": "active",
					"created_at": "2019-01-21T18:44:17Z",
					"updated_at": "2019-01-21T18:44:17Z",
					"metadata": {
						"id": "my_address_id"
					}
				},
				"created_at": "2019-01-21T18:36:30Z",
				"updated_at": "2019-01-21T18:44:17Z",
				"phones": {}
			},
			"last_transaction": {
				"id": "tran_x30Ml3TVkUan61vl",
				"transaction_type": "voucher",
				"gateway_id": "abe20e9d-fc1f-4458-86c0-b5e21a172ed8",
				"amount": 2990,
				"status": "captured",
				"success": true,
				"statement_descriptor": "AVENGERS",
				"acquirer_tid": "f55f99cd-fdc0-4271-a8f8-5be39c496fce",
				"acquirer_nsu": "f55f99cd-fdc0-4271-a8f8-5be39c496fce",
				"acquirer_message": "Transação capturada com sucesso",
				"acquirer_return_code": "00",
				"operation_type": "auth_and_capture",
				"card": {
					"id": "card_apxQeXJsV2fGVwPL",
					"first_six_digits": "400000",
					"last_four_digits": "0010",
					"brand": "Visa",
					"holder_name": "Tony Stark",
					"holder_document": "93095135270",
					"exp_month": 1,
					"exp_year": 2030,
					"status": "active",
					"type": "credit",
					"created_at": "2019-01-21T18:37:48Z",
					"updated_at": "2019-01-22T14:20:18Z",
					"billing_address": {
						"zip_code": "90265",
						"city": "Malibu",
						"state": "CA",
						"country": "US",
						"line_1": "10880, Malibu Point, Malibu Central"
					},
					"customer": {
						"id": "cus_n3bqEzdsZUmNA7Qp",
						"name": "Tony Stark",
						"email": "[email protected]",
						"delinquent": false,
						"address": {
							"id": "addr_yEd4rG0HJNupdX2m",
							"line_1": "375, Av. General Justo, Centro",
							"line_2": "8º andar",
							"zip_code": "20021130",
							"city": "Rio de Janeiro",
							"state": "RJ",
							"country": "BR",
							"status": "active",
							"created_at": "2019-01-21T18:44:17Z",
							"updated_at": "2019-01-21T18:44:17Z",
							"metadata": {
								"id": "my_address_id"
							}
						},
						"created_at": "2019-01-21T18:36:30Z",
						"updated_at": "2019-01-21T18:44:17Z",
						"phones": {}
					}
				},
				"created_at": "2019-01-22T14:20:19Z",
				"updated_at": "2019-01-22T14:20:19Z",
				"gateway_response": {
					"code": "200"
				}
			}
		}
	],
	"checkouts": []
}
//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";

$voucher = new \MundiAPILib\Models\CreateVoucherPaymentRequest();
$voucher->capture = True;
$voucher->installments = 2;
$voucher->statementDescriptor = "AVENGERS";
$voucher->card = new \MundiAPILib\Models\CreateCardRequest();
$voucher->card->number = "4000000000000010";
$voucher->card->holderName = "Tony Stark";
$voucher->card->expMonth = 1;
$voucher->card->expYear = 2030;
$voucher->card->cvv = "351";

$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]->paymentMethod = "voucher";
$request->payments[0]->voucher = $voucher;
$request->customer = $customer;

$result = $orderController->createOrder($request);

echo json_encode($result, JSON_PRETTY_PRINT);
package examples.order;

import com.mundipagg.api.MundiAPIClient;
import com.mundipagg.api.controllers.OrdersController;
import com.mundipagg.api.http.client.*;
import com.mundipagg.api.models.*;

import java.util.ArrayList;

public class CreateOrderVoucher {
	
	public static void main(String[] args) {

        String basicAuthUserName = "sk_test_q73YODBFQhyV9mod"; // The username to use with basic authentication
        String basicAuthPassword = ""; // The password to use with basic authentication

        MundiAPIClient client = new MundiAPIClient(basicAuthUserName, basicAuthPassword);

        OrdersController orders_controller = new OrdersController();

        CreateCustomerRequest customer = new CreateCustomerRequest();
        customer.setName("sdk customer order");
        customer.setEmail("[email protected]");

        CreateVoucherPaymentRequest create_voucher_payment_request = new CreateVoucherPaymentRequest();

        create_voucher_payment_request.setStatementDescriptor("test descriptor");
        create_voucher_payment_request.setCard(new CreateCardRequest());
        create_voucher_payment_request.getCard().setNumber("4000000000000010");
        create_voucher_payment_request.getCard().setHolderName("Tony Stark");
        create_voucher_payment_request.getCard().setExpMonth(1);
        create_voucher_payment_request.getCard().setExpYear(2030);
        create_voucher_payment_request.getCard().setCvv("123");

        CreateOrderRequest request = new CreateOrderRequest();

        CreateOrderItemRequest orderItem = new CreateOrderItemRequest();
        orderItem.setDescription("Tesseract Bracelet");
        orderItem.setQuantity(3);
        orderItem.setAmount(1490);
        ArrayList<CreateOrderItemRequest> listOrderItem = new ArrayList<CreateOrderItemRequest>();
        listOrderItem.add(orderItem);
        request.setItems(listOrderItem);

        CreatePaymentRequest paymentItem = new CreatePaymentRequest();
        paymentItem.setPaymentMethod("voucher");
        paymentItem.setVoucher(create_voucher_payment_request);
        request.setCustomer(customer);
        ArrayList<CreatePaymentRequest> lisPaymentItem = new ArrayList<CreatePaymentRequest>();
        lisPaymentItem.add(paymentItem);
        request.setPayments(lisPaymentItem);


        orders_controller.createOrderAsync(request, new APICallBack<GetOrderResponse>() {
            public void onSuccess(HttpContext context, GetOrderResponse response) {

                System.out.println("Order credit voucher !");
                System.out.println("Status response: " + context.getResponse().getStatusCode());
                System.out.println("Order result status: " + response.getStatus());
                System.out.println("Order id: " + response.getId());

            }

            public void onFailure(HttpContext context, Throwable error) {

                System.out.println("Status response: " + context.getResponse().getStatusCode());
                System.out.println(error.getMessage());
                error.printStackTrace();

            }
        });
    }

}
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 = "sdk customer test"
customer.email = "[email protected]"

voucher = create_voucher_payment_request.CreateVoucherPaymentRequest()
voucher.capture = True
voucher.installments = 2
voucher.statement_descriptor = "test descriptor"
voucher.card = create_card_request.CreateCardRequest()
voucher.card.number = "4000000000000010"
voucher.card.holder_name = "Tony Stark"
voucher.card.exp_month = 1
voucher.card.exp_year = 2030
voucher.card.cvv = "123"

request = create_order_request.CreateOrderRequest()

request.items = [create_order_item_request.CreateOrderItemRequest()]
request.items[0].description = "Tesseract Bracelet"
request.items[0].quantity = 3
request.items[0].amount = 1490

request.payments = [create_payment_request.CreatePaymentRequest()]
request.payments[0].payment_method = "voucher"
request.payments[0].voucher = voucher
request.customer = customer

try:
    result = orders_controller.create_order(request)
    assert result.status == "paid"
	print("Order id is: ", result.id)
    print("Order result status: ", result.status)
except ErrorException as ex:
    print(ex.message)
    print("Errors: ", ex.errors)
except Exception as ex:
    raise ex

Status das transações de Voucher (Transaction)

As transações de Voucher podem possuir os seguintes status:

StatusDescrição
authorized_pending_captureAutorizada pendente de captura
not_authorizedNão autorizada
capturedCapturada
partial_captureCapturada parcialmente
refundedEstornada
voidedCancelada
partial_refundedEstornada parcialmente
partial_voidCancelada parcialemente
error_on_voidingErro no cancelamento
error_on_refundingErro no estorno
waiting_cancellationAguardando cancelamento
with_errorCom erro
failedFalha