API Reference
API Reference

Como mandar uma requisição completa!

#region Monta a requisicao

var boletoTransaction = new BoletoTransaction() {
    AmountInCents = 10000,
    BankNumber = "237",
    BillingAddress = new BillingAddress() {
        City = "Tatooine",
        Complement = "",
        Country = CountryEnum.Brazil.ToString(),
        Number = "123",
        District = "Mos Eisley",
        State = "RJ",
        Street = "Mos Eisley Cantina",
        ZipCode = "20001000"
    },
    DocumentNumber = "12345678901",
    Instructions = "Pagar antes do vencimento",
    Options = new BoletoTransactionOptions() {
        CurrencyIso = CurrencyIsoEnum.BRL,
        DaysToAddInBoletoExpirationDate = 5
    },
    TransactionReference = "NumeroDaTransacao"
};

// Cria o comprador.
Buyer buyer = new Buyer() {
    AddressCollection = new Collection<BuyerAddress>(),
    Birthdate = new DateTime(1990, 8, 20),
    BuyerCategory = BuyerCategoryEnum.Normal,
    BuyerReference = "C3PO",
    CreateDateInMerchant = DateTime.Now,
    DocumentNumber = "12345678901",
    DocumentType = DocumentTypeEnum.CPF,
    Email = "[email protected]",
    EmailType = EmailTypeEnum.Personal,
    FacebookId = "lukeskywalker8917",
    Gender = GenderEnum.M,
    HomePhone = "(21)123456789",
    MobilePhone = "(21)987654321",
    Name = "Luke Skywalker",
    PersonType = PersonTypeEnum.Person,
    TwitterId = "@lukeskywalker8917",
    WorkPhone = "(21)28467902"
};
// Adiciona um endereço para o comprador.
buyer.AddressCollection.Add(new BuyerAddress() {
    AddressType = AddressTypeEnum.Residential,
    City = "Tatooine",
    Complement = "",
    Country = CountryEnum.Brazil.ToString(),
    District = "Mos Eisley",
    Number = "123",
    State = "RJ",
    Street = "Mos Eisley Cantina",
    ZipCode = "20001000"
});

// Cria a transação de cartão de crédito.
var creditCardTransaction = new CreditCardTransaction() {
    AmountInCents = 10000,
    CreditCard = new CreditCard() {
        BillingAddress = new BillingAddress() {
            City = "Tatooine",
            Complement = "",
            Country = CountryEnum.Brazil.ToString(),
            District = "Mos Eisley",
            Number = "123",
            State = "RJ",
            Street = "Mos Eisley Cantina",
            ZipCode = "20001000"
        },
        CreditCardBrand = CreditCardBrandEnum.Visa,
        CreditCardNumber = "4111111111111111",
        ExpMonth = 10,
        ExpYear = 22,
        HolderName = "LUKE SKYWALKER",
        SecurityCode = "123"
    },
    CreditCardOperation = CreditCardOperationEnum.AuthOnly,
    InstallmentCount = 1,
    Options = new CreditCardTransactionOptions() {
        CurrencyIso = CurrencyIsoEnum.BRL,
        PaymentMethodCode = 1,
        SoftDescriptorText = "Jedi Mega Store"
    },
    TransactionReference = "NumeroDaTransacao"
};

// Dados da loja.
Merchant merchant = new Merchant() {
    MerchantReference = "IdDaLojaPlataforma"
};

// Opções da requisição.
SaleOptions saleOptions = new SaleOptions() {
    AntiFraudServiceCode = 0,
    CurrencyIso = CurrencyIsoEnum.BRL,
    IsAntiFraudEnabled = true, // Habilita a integração com o serviço de anti fraude
    Retries = 1 // Quantidade máxima de retentativas para o cartão de crédito.
};

// Dados da requisição no site da loja.
RequestData requestData = new RequestData() {
    EcommerceCategory = EcommerceCategoryEnum.B2C,
    IpAddress = "127.0.0.1",
    Origin = "SiteDeCompra",
    SessionId = "IdSesssaoNoSite"
};

// Cria o carrinho de compras.
ShoppingCart shoppintCart = new ShoppingCart() {
    DeliveryAddress = new DeliveryAddress() {
        City = "Galaxy far far away",
        Complement = "Bridge",
        Country = CountryEnum.Brazil.ToString(),
        District = "Command Room",
        Number = "321",
        State = "RJ",
        Street = "Death Star",
        ZipCode = "10002000"
    },
    DeliveryDeadline = DateTime.Now.AddDays(3),
    EstimatedDeliveryDate = DateTime.Now.AddDays(3),
    FreightCostInCents = 2000,
    ShippingCompany = "Empire",
    ShoppingCartItemCollection = new Collection<ShoppingCartItem>()
};

// Adiciona um produto no carrinho de compras.
shoppintCart.ShoppingCartItemCollection.Add(new ShoppingCartItem() {
    Description = "Red Lightsaber",
    DiscountAmountInCents = 0,
    ItemReference = "NumeroDoProduto",
    Name = "Lightsaber",
    Quantity = 1,
    TotalCostInCents = 18000,
    UnitCostInCents = 18000
});

#endregion

// Cria requisição.
var createSaleRequest = new CreateSaleRequest() {
    // Adiciona o boleto na requisição.
    BoletoTransactionCollection = new Collection<BoletoTransaction>(new BoletoTransaction[] { boletoTransaction }),
    Buyer = buyer,
    // Adiciona a transação de cartão de crédito na requisição.
    CreditCardTransactionCollection = new Collection<CreditCardTransaction>(new CreditCardTransaction[] { creditCardTransaction }),
    Merchant = merchant,
    Options = saleOptions,
    Order = new Order() {
        OrderReference = "NumeroDoPedido"
    },
    RequestData = requestData,
    ShoppingCartCollection = new Collection<ShoppingCart>(new ShoppingCart[] { shoppintCart })
};

// Coloque a sua MerchantKey aqui.
Guid merchantKey = Guid.Parse("00000000-0000-0000-0000-000000000000");

// Cria o client que enviará a transação.
var serviceClient = new GatewayServiceClient(merchantKey, new Uri("https://sandbox.mundipaggone.com"));

// Autoriza a transação e recebe a resposta do gateway.
var httpResponse = serviceClient.Sale.Create(createSaleRequest);

Console.WriteLine("Código retorno: {0}", httpResponse.HttpStatusCode);
Console.WriteLine("Chave do pedido: {0}", httpResponse.Response.OrderResult.OrderKey);
if (httpResponse.Response.CreditCardTransactionResultCollection != null) {
    Console.WriteLine("Status transação de cartão: {0}", httpResponse.Response.CreditCardTransactionResultCollection.FirstOrDefault().CreditCardTransactionStatus);
}
if (httpResponse.Response.BoletoTransactionResultCollection != null) {
                Console.WriteLine("Status transação de boleto: {0}", httpResponse.Response.BoletoTransactionResultCollection.FirstOrDefault().BoletoTransactionStatus);
            }
<?php
try
{
    // Carrega dependências
    require_once(dirname(__FILE__) . '\vendor\autoload.php');

    // Define a url utilizada
    \Gateway\ApiClient::setBaseUrl("https://sandbox.mundipaggone.com");

    // Define a chave de loja
    \Gateway\ApiClient::setMerchantKey("85328786-8BA6-420F-9948-5352F5A183EB");

    // Cria objeto da requisição
    $request = new \Gateway\One\DataContract\Request\CreateSaleRequest();

    // Dados da transação de boleto
    $boletoTransaction = new \Gateway\One\DataContract\Request\CreateSaleRequestData\BoletoTransaction();
    
    $boletoTransaction
    ->setAmountInCents(10000)
    ->setBankNumber(\Gateway\One\DataContract\Enum\BankEnum::BRADESCO)
    ->setDocumentNumber("12345678901")
    ->setInstructions("Pagar antes do vencimento")
    ->setTransactionReference("NumeroDaTransacao")
    ->getOptions()
    ->setCurrencyIso(\Gateway\One\DataContract\Enum\CurrencyIsoEnum::BRL)
    ->setDaysToAddInBoletoExpirationDate(5);

    // Endereço de cobrança da transação de boleto
    $boletoTransaction->getBillingAddress()
    ->setAddressType(\Gateway\One\DataContract\Enum\AddressTypeEnum::BILLING)
    ->setStreet("Mos Eisley Cantina")
    ->setNumber("123")
    ->setComplement("")
    ->setDistrict("Mos Eisley")
    ->setCity("Tatooine")
    ->setState("RJ")
    ->setZipCode("20001000")
    ->setCountry(\Gateway\One\DataContract\Enum\CountryEnum::BRAZIL);

    $request->addBoletoTransaction($boletoTransaction);

    // Dados do comprador
    $request->getBuyer()
    ->setName("Luke Skywalker")
    ->setPersonType(\Gateway\One\DataContract\Enum\PersonTypeEnum::PERSON)
    ->setBuyerReference("C3PO")
    ->setDocumentNumber("12345678901")
    ->setDocumentType(\Gateway\One\DataContract\Enum\DocumentTypeEnum::CPF)
    ->setEmail("[email protected]")
    ->setEmailType(\Gateway\One\DataContract\Enum\EmailTypeEnum::PERSONAL)
    ->setGender(\Gateway\One\DataContract\Enum\GenderEnum::MALE)
    ->setHomePhone("(21)123456789")
    ->setMobilePhone("(21)987654321")
    ->setWorkPhone("(21)28467902")
    ->setBirthDate(\DateTime::createFromFormat('d/m/Y', '20/08/1990'))
    ->setFacebookId("lukeskywalker8917")
    ->setTwitterId("@lukeskywalker8917")
    ->setCreateDateInMerchant(new \DateTime())
    ->addAddress()
    ->setAddressType(\Gateway\One\DataContract\Enum\AddressTypeEnum::RESIDENTIAL)
    ->setStreet("Mos Eisley Cantina")
    ->setNumber("123")
    ->setComplement("")
    ->setDistrict("Mos Eisley")
    ->setCity("Tatooine")
    ->setState("RJ")
    ->setZipCode("20001000")
    ->setCountry(\Gateway\One\DataContract\Enum\CountryEnum::BRAZIL);

    // Dados da transação de cartão de crédito
    $creditCardTransaction = new \Gateway\One\DataContract\Request\CreateSaleRequestData\CreditCardTransaction();
    $request->addCreditCardTransaction($creditCardTransaction);
    $creditCardTransaction
    ->setAmountInCents(10000)
    ->setInstallmentCount(1)
    ->setCreditCardOperation(\Gateway\One\DataContract\Enum\CreditCardOperationEnum::AUTH_ONLY)
    ->setTransactionDateInMerchant(new DateTime())
    ->setTransactionReference("NumeroDaTransacao")
    ->getCreditCard()
    ->setCreditCardBrand(\Gateway\One\DataContract\Enum\CreditCardBrandEnum::VISA)
    ->setCreditCardNumber("4111111111111111")
    ->setExpMonth(10)
    ->setExpYear(2022)
    ->setHolderName("LUKE SKYWALKER")
    ->setSecurityCode("123")
    ->getBillingAddress()
    ->setAddressType(\Gateway\One\DataContract\Enum\AddressTypeEnum::BILLING)
    ->setStreet("Mos Eisley Cantina")
    ->setNumber("123")
    ->setComplement("")
    ->setDistrict("Mos Eisley")
    ->setCity("Tatooine")
    ->setState("RJ")
    ->setZipCode("20001000")
    ->setCountry(\Gateway\One\DataContract\Enum\CountryEnum::BRAZIL);

    // Opções da transação de cartão de crédito
    $creditCardTransaction->getOptions()
    ->setCurrencyIso(\Gateway\One\DataContract\Enum\CurrencyIsoEnum::BRL)
    ->setPaymentMethodCode(\Gateway\One\DataContract\Enum\PaymentMethodEnum::SIMULATOR)
    ->setSoftDescriptorText("Jedi Mega Store");

    $request->getMerchant()
    ->setMerchantReference("IdDaLojaPlataforma");

    //Opções do pedido
    $request->getOptions()
    ->setAntiFraudServiceCode(0)
    ->setCurrencyIso(\Gateway\One\DataContract\Enum\CurrencyIsoEnum::BRL)
    ->enableAntiFraud()
    ->setRetries(1);

    //Dados do pedido
    $request->getOrder()
    ->setOrderReference("NumeroDoPedido");            

    //Dados da requisição
    $request->getRequestData()
    ->setEcommerceCategory("B2C")
    ->setIpAddress("127.0.0.1")
    ->setOrigin("SiteDeCompra")
    ->setSessionId("IdSessaoNoSite");

    //Dados do Carrinho de compras
    $shoppingCart = $request->addShoppingCart();
    $shoppingCart->setDeliveryDeadline(DateTime::createFromFormat("Y-m-d H:i:s", '2015-12-14 18:36:45'));
    $shoppingCart->setEstimatedDeliveryDate(DateTime::createFromFormat("Y-m-d H:i:s", '2015-12-14 18:36:45'));
    $shoppingCart->setFreightCostInCents(2000);
    $shoppingCart->setShippingCompany("Empire");
    $shoppingCart->getDeliveryAddress()
    ->setAddressType(\Gateway\One\DataContract\Enum\AddressTypeEnum::SHIPPING)
    ->setStreet("Death Star")
    ->setNumber("321")
    ->setComplement("Bridge")
    ->setDistrict("Command Room")
    ->setCity("Galaxy far far away")
    ->setState("RJ")
    ->setZipCode("10002000")
    ->setCountry(\Gateway\One\DataContract\Enum\CountryEnum::BRAZIL);

    //Adiciona um item ao carrinho
    $shoppingCart->addShoppingCartItem()
    ->setDescription("Red Lightsaber")
    ->setDiscountAmountInCents(0)
    ->setItemReference("NumeroDoProduto")
    ->setName("Lightsaber")
    ->setQuantity(1)
    ->setUnitCostInCents(18000)
    ->setTotalCostInCents(18000);

    // Cria um novo objeto ApiClient
    $client = new Gateway\ApiClient();

    // Faz a chamada de criação
    $response = $client->createSale($request);

}
catch (\Gateway\One\DataContract\Report\CreditCardError $error)
{
    $response = array("message" => $error->getMessage());
}
catch (\Gateway\One\DataContract\Report\ApiError $error)
{
    $response = array("message" => $error->errorCollection->ErrorItemCollection[0]->Description);
}
catch (\Exception $ex)
{
    $response = array("message" => "Ocorreu um erro inesperado.");
}
finally
{
    header('Content-Type: application/json');
    print json_encode($response->getData());
}
require 'mundipagg_sdk'

# variable with merchant key
merchantKey = '85328786-8BA6-420F-9948-5352F5A183EB'

# instantiate class with request methods
# :sandbox for sandbox ambient 
# :production for production ambient
gateway = Gateway::Gateway.new(:sandbox, merchantKey)

# creates boleto transaction object
boletoTransaction = Gateway::BoletoTransaction.new

# 100 reais in cents
boletoTransaction.AmountInCents = 10000
boletoTransaction.BankNumber = '237'
boletoTransaction.BillingAddress.City = 'Tatooine'
boletoTransaction.BillingAddress.Complement = ''
boletoTransaction.BillingAddress.Country = 'Brazil'
boletoTransaction.BillingAddress.District = 'Mos Eisley'
boletoTransaction.BillingAddress.Number = '123'
boletoTransaction.BillingAddress.State = 'RJ'
boletoTransaction.BillingAddress.Street = 'Mos Eisley Cantina'
boletoTransaction.BillingAddress.ZipCode = '20001000'
boletoTransaction.DocumentNumber = '12345678901'
boletoTransaction.Instructions = 'Pagar antes do vencimento'
boletoTransaction.Options.CurrencyIso = 'BRL'
boletoTransaction.Options.DaysToAddInBoletoExpirationDate = 5
boletoTransaction.TransactionReference = 'NumeroDaTransacao'


# create credit card transaction object
creditCardTransaction = Gateway::CreditCardTransaction.new

# 100 reais in cents 
creditCardTransaction.AmountInCents = 10000
creditCardTransaction.CreditCard.BillingAddress.City = 'Tatooine'
creditCardTransaction.CreditCard.BillingAddress.Complement = ''
creditCardTransaction.CreditCard.BillingAddress.Country = 'Brazil'
creditCardTransaction.CreditCard.BillingAddress.District = 'Mos Eisley'
creditCardTransaction.CreditCard.BillingAddress.Number = '123'
creditCardTransaction.CreditCard.BillingAddress.State = 'RJ'
creditCardTransaction.CreditCard.BillingAddress.Street = 'Mos Eisley Cantina'
creditCardTransaction.CreditCard.BillingAddress.ZipCode = '20001000'
creditCardTransaction.CreditCard.CreditCardBrand = 'Visa'
creditCardTransaction.CreditCard.CreditCardNumber = '4111111111111111'
creditCardTransaction.CreditCard.ExpMonth = 10
creditCardTransaction.CreditCard.ExpYear = 22
creditCardTransaction.CreditCard.HolderName = 'LUKE SKYWALKER'
creditCardTransaction.CreditCard.SecurityCode = '123'
creditCardTransaction.CreditCardOperation = 'AuthOnly'
creditCardTransaction.InstallmentCount = 1
creditCardTransaction.Options.CurrencyIso = 'BRL'
creditCardTransaction.Options.PaymentMethodCode = 1
creditCardTransaction.Options.SoftDescriptorText = 'Jedi Mega Store'

shoppingCartItem = Gateway::ShoppingCartItemCollection.new
shoppingCartItem.Description = 'Red Lightsaber'
shoppingCartItem.DiscountAmountInCents = 0
shoppingCartItem.ItemReference = 'NumeroDoProduto'
shoppingCartItem.Name = 'Lightsaber'
shoppingCartItem.Quantity = 1
shoppingCartItem.TotalCostInCents = 18000
shoppingCartItem.UnitCostInCents = 18000

shoppingCartCollection = Gateway::ShoppingCartCollection.new
shoppingCartCollection.DeliveryAddress.City = 'Galaxy far far away'
shoppingCartCollection.DeliveryAddress.Complement = 'Bridge'
shoppingCartCollection.DeliveryAddress.Country = 'Brazil'
shoppingCartCollection.DeliveryAddress.District = 'Command Room'
shoppingCartCollection.DeliveryAddress.Number = '321'
shoppingCartCollection.DeliveryAddress.State = 'RJ'
shoppingCartCollection.DeliveryAddress.Street = 'Death Star'
shoppingCartCollection.DeliveryAddress.ZipCode = '10002000'
shoppingCartCollection.DeliveryDeadline = DateTime.new(2015, 12, 14, 18, 36, 45).strftime("%Y-%m-%dT%H:%M:%S")
shoppingCartCollection.EstimatedDeliveryDate = DateTime.new(2015, 12, 14, 18, 36, 45).strftime("%Y-%m-%dT%H:%M:%S")
shoppingCartCollection.FreighCostInCents = 2000
shoppingCartCollection.ShippingCompany = 'Empire'
shoppingCartCollection.ShoppingCartItemCollection << shoppingCartItem

# creates request object for transaction creation
createSaleRequest = Gateway::CreateSaleRequest.new

# adds to the boleto transaction collection
createSaleRequest.BoletoTransactionCollection << boletoTransaction

buyerAddress = Gateway::BuyerAddress.new
buyerAddress.AddressType = 'Residential'
buyerAddress.City = 'Tatooine'
buyerAddress.Complement = ''
buyerAddress.Country = 'Brazil'
buyerAddress.District = 'Mos Eisley'
buyerAddress.Number = '123'
buyerAddress.State = 'RJ'
buyerAddress.Street = 'Mos Eisley Cantina'
buyerAddress.ZipCode = '20001000'

createSaleRequest.Buyer.AddressCollection << buyerAddress
createSaleRequest.Buyer.Birthdate = DateTime.new(1990,8,20,0,0,0).strftime("%Y-%m-%dT%H:%M:%S")
createSaleRequest.Buyer.BuyerCategory = 'Normal'
createSaleRequest.Buyer.BuyerReference = 'C3PO'
createSaleRequest.Buyer.CreateDateInMerchant = DateTime.new(2015,12,11,18,36,45).strftime("%Y-%m-%dT%H:%M:%S")
createSaleRequest.Buyer.DocumentNumber = '12345678901'
createSaleRequest.Buyer.DocumentType = 'CPF'
createSaleRequest.Buyer.Email = '[email protected]'
createSaleRequest.Buyer.EmailType = 'Personal'
createSaleRequest.Buyer.FacebookId = 'lukeskywalker8917'
createSaleRequest.Buyer.Gender = 'M'
createSaleRequest.Buyer.HomePhone = '(21)123456789'
createSaleRequest.Buyer.MobilePhone = '(21)987654321'
createSaleRequest.Buyer.Name = 'Luke Skywalker'
createSaleRequest.Buyer.PersonType = 'Person'
createSaleRequest.Buyer.TwitterId = '@lukeskywalker8917'
createSaleRequest.Buyer.WorkPhone = '(21)28467902'

# adds to the credit card transaction collection
createSaleRequest.CreditCardTransactionCollection << creditCardTransaction
createSaleRequest.Merchant.MerchantReference = 'IdDaLojaPlataforma'
createSaleRequest.Options.AntiFraudServiceCode = 0
createSaleRequest.Options.CurrencyIso = 'BRL'
createSaleRequest.Options.IsAntiFraudEnabled = true
createSaleRequest.Options.Retries = 1
createSaleRequest.Order.OrderReference = 'NumeroDoPedido'
createSaleRequest.RequestData.EcommerceCategory = 'B2C'
createSaleRequest.RequestData.IpAddress = '127.0.0.1'
createSaleRequest.RequestData.Origin = 'SiteDeCompra'
createSaleRequest.RequestData.SessionId = 'IdSesssaoNoSite'

# adds shopping cart collection in the request
createSaleRequest.ShoppingCartCollection << shoppingCartCollection

# make the request and returns a response hash
response = gateway.CreateSale(createSaleRequest)

# prints the response
puts response
# -*- coding: utf-8 -*-

from uuid import UUID
from data_contracts import creditcard, creditcard_transaction, creditcard_transaction_options, create_sale_request, order, buyer_address, buyer, billing_address,sale_options, delivery_address, shopping_cart_item, shopping_cart, boleto_transaction_options, boleto_transaction, merchant, request_data
from mundipaggOnePython import GatewayServiceClient
from enum_types import PlatformEnvironment, HttpContentTypeEnum
from datetime import datetime

# Cria o endereco do comprador
buyer_address_collection_data = [buyer_address(address_type = 'Residential', city = 'Tatooine', complement = '', country = 'Brazil', district = 'Mos Eisley', number = '123', state = 'RJ', street = 'Mos Eisley Cantina', zip_code = '20001000')]

#Cria o comprador
buyer_data = buyer(address_collection = buyer_address_collection_data, birth_date = '1990-08-20T00:00:00',buyer_category = 'Normal', buyer_reference = 'C3PO', create_date_in_merchant = datetime.now().strftime("%Y-%m-%dT%H:%M:%S"), document_number = '12345678901' , document_type = 'CPF', email = '[email protected]', email_type = 'Personal',facebook_id = 'lukeskywalker8917', gender = 'M', home_phone = '(21)123456789', mobile_phone = '(21)987654321', name = 'Luke Skywalker', person_type = 'Person', twitter_id = '@lukeskywalker8917', work_phone = '(21)28467902')

# Cria o endereco de cobranca
billing_address_data = billing_address(city = 'Tatooine', complement = '', country = 'Brazil', district = 'Mos Eisley', number = '123', state = 'RJ', street = 'Mos Eisley Cantina', zip_code = '20001000')

# Criando a transacao de cartao de credito.
##Coleta os dados do cartão.
creditcard_data = creditcard(billing_address= billing_address_data, creditcard_number='4111111111111111', creditcard_brand='Visa', exp_month=10, exp_year=22,
                             security_code='123', holder_name='LUKE SKYWALKER')

## Cria as opcoes do cartao de credito
creditcard_transaction_options_data = creditcard_transaction_options(payment_method_code = 1, soft_descriptor_text = 'Jedi Mega Store', currency_iso = 'BRL')

## Cria a transação de cartao de credito.
credit_card_transaction_collection_data = [creditcard_transaction(10000, creditcard_data, 'AuthOnly', installment_count = 1, options = creditcard_transaction_options_data, transaction_reference = 'NumeroDaTransacao')]

# Criando a transacao de boleto
boleto_options = boleto_transaction_options(currency_iso = 'BRL', days_to_add_in_boleto_expiration_date = 5)

boleto_transaction_collection_data = [ boleto_transaction(10000, bank_number = '237', document_number='12345678901', instructions='Pagar antes do vencimento', options = boleto_options,billing_address = billing_address_data )]

# Habilita o antiFraud
sale_options_data = sale_options(is_anti_fraud_enabled = True, anti_fraud_service_code = 0, retries = 1, currency_iso_field = 'BRL')

##Cria o numero do pedido
order_data = order(order_reference='NumeroDoPedido')

# Criando o carrinho de compra
## Cria o endereco de entrega para o carrinho de compras
delivery_address_data = delivery_address(city = 'Galaxy far far away', complement = 'Bridge', country = 'Brazil', district = 'Command Room', number = '321', state = 'RJ', street = 'Death Star', zip_code = '10002000')

## Cria a colecao de item do carrinho de compras 
shopping_cart_item_collection_data = [shopping_cart_item(description = 'Red Lightsaber', discount_amount_in_cents = 0, item_reference = 'NumeroDoProduto', name = 'Lightsaber', quantity = 1, total_cost_in_cents = 18000, unit_cost_in_cents = 18000)]

## Cria o carrinho de compra
shopping_cart_collection_data = [shopping_cart(delivery_address = delivery_address_data, delivery_deadline = datetime.now().strftime("%Y-%m-%dT%H:%M:%S"), estimated_delivery_date = datetime.now().strftime("%Y-%m-%dT%H:%M:%S"), freight_cost_in_cents = 2000,shipping_company = 'Empire',  shopping_cart_item_collection = shopping_cart_item_collection_data)]

# Cria o merchant
merchant_data = merchant(merchant_reference = 'IdDaLojaPlataforma')

# Cria os dados da requisição
request_data_data = request_data(ecommerce_category = 'B2C', ip_address = '127.0.0.1', origin = 'SiteDeCompra', session_id = 'IdSesssaoNoSite')

# Cria a requisicao
request = create_sale_request(creditcard_transaction_collection = credit_card_transaction_collection_data, boleto_transaction_collection = boleto_transaction_collection_data, order = order_data, buyer = buyer_data, shopping_cart_collection = shopping_cart_collection_data, options = sale_options_data, merchant = merchant_data, request_data = request_data_data)

# Coloque sua MerchantKey aqui.
merchant_key = UUID('85328786-8BA6-420F-9948-5352F5A183EB')
end_point = "https://sandbox.mundipaggone.com"
service_client = GatewayServiceClient(merchant_key, PlatformEnvironment.sandbox, HttpContentTypeEnum.json, end_point)

# envia a transação e recebe a resposta do gateway.
http_response = service_client.sale.create_with_request(request)

#Obtem a resposta em json.
json_response = http_response.json()
// Define loja
UUID merchantKey = UUID.fromString("85328786-8BA6-420F-9948-5352F5A183EB"); // Chave da Loja - MerchantKey

// Cria objeto do endereço
BillingAddress billingAddress= new BillingAddress();
billingAddress.setCity("Tatooine");
billingAddress.setComplement("");
billingAddress.setCountry(CountryEnum.Brazil);
billingAddress.setDistrict("Mos Eisley");
billingAddress.setNumber("123");
billingAddress.setState("RJ");
billingAddress.setStreet("Mos Eisley Cantina");
billingAddress.setZipCode("20001000");

// Cria um objeto de transação de boleto
BoletoTransaction boletoTransaction = new BoletoTransaction();
boletoTransaction.setAmountInCents(10000L);
boletoTransaction.setBankNumber("237");
boletoTransaction.setBillingAddress(billingAddress);
boletoTransaction.setDocumentNumber("12345678901");
boletoTransaction.setInstructions("Pagar antes do vencimento");
boletoTransaction.setTransactionReference("NumeroDaTransacao");

// Cria o objeto de options
BoletoTransactionOptions boletoTransactionOptions = new BoletoTransactionOptions();
boletoTransactionOptions.setCurrencyIso(CurrencyIsoEnum.BRL);
boletoTransactionOptions.setDaysToAddInBoletoExpirationDate(5);
boletoTransaction.setOptions(boletoTransactionOptions);

// Cria objeto de endereço do Buyer
BuyerAddress buyerAddress = new BuyerAddress();
buyerAddress.setAddressType(AddressTypeEnum.Residential);
buyerAddress.setCity("Tatooine");
buyerAddress.setComplement("");
buyerAddress.setCountry(CountryEnum.Brazil);
buyerAddress.setDistrict("Mos Eisley");
buyerAddress.setNumber("123");
buyerAddress.setState("RJ");
buyerAddress.setStreet("Mos Eisley Cantina");
buyerAddress.setZipCode("20001000");

// Cria coleção de endereços do buyer
ArrayList<BuyerAddress> buyerAddressCollection = new ArrayList<BuyerAddress>();
buyerAddressCollection.add(buyerAddress);

// Cria objeto do buyer
Buyer buyer = new Buyer();
buyer.setAddressCollection(buyerAddressCollection);
buyer.setBirthdate(Date.valueOf("1990-12-11"));
buyer.setBuyerCategory(BuyerCategoryEnum.Normal);
buyer.setBuyerReference("C3PO");
buyer.setCreateDateInMerchant(Date.valueOf("2015-12-11"));
buyer.setDocumentNumber("12345678901");
buyer.setDocumentType(DocumentTypeEnum.CPF);
buyer.setEmail("[email protected]");
buyer.setEmailType(EmailTypeEnum.Personal);
buyer.setFacebookId("lukeskywalker8917");
buyer.setGender(GenderEnum.M);
buyer.setHomePhone("(21)123456789");
buyer.setMobilePhone("(21)987654321");
buyer.setName("Luke Skywalker");
buyer.setPersonType(PersonTypeEnum.Person);
buyer.setTwitterId("@lukeskywalker8917");
buyer.setWorkPhone("(21)28467902");

// Cria um cartão de crédito e define endereço de cobrança
CreditCard creditCard = new CreditCard();
creditCard.setBillingAddress(billingAddress);
creditCard.setCreditCardBrand(CreditCardBrandEnum.Visa);
creditCard.setCreditCardNumber("4111111111111111");
creditCard.setExpMonth(10);
creditCard.setExpYear(22);
creditCard.setHolderName("LUKE SKYWALKER");
creditCard.setSecurityCode("123");

// Cria a transação de cartão de crédito e define cartão criado anteriormente
CreditCardTransaction creditCardTransaction = new CreditCardTransaction();
creditCardTransaction.setAmountInCents(10000L);
creditCardTransaction.setCreditCard(creditCard);
creditCardTransaction.setCreditCardOperation(CreditCardOperationEnum.AuthOnly);
creditCardTransaction.setInstallmentCount(1);
creditCardTransaction.setOptions(new CreditCardTransactionOptions());
creditCardTransaction.getOptions().setCurrencyIso(CurrencyIsoEnum.BRL);
creditCardTransaction.getOptions().setPaymentMethodCode(1);
creditCardTransaction.getOptions().setSoftDescriptorText("Jedi Mega Store");
creditCardTransaction.setTransactionReference("NumeroDaTransacao");

// Cria o objeto order para adicionar o Order Reference
Order order = new Order();
order.setOrderReference("NúmeroDoPedido");

// Cria item o shopping cart
ShoppingCartItem shoppingCartItem = new ShoppingCartItem();
shoppingCartItem.setDescription("Red Lightsaber");
shoppingCartItem.setDiscountAmountInCents(0L);
shoppingCartItem.setItemReference("NumeroDoProduto");
shoppingCartItem.setName("Lightsaber");
shoppingCartItem.setQuantity(1);
shoppingCartItem.setTotalCostInCents(18000);
shoppingCartItem.setUnitCostInCents(18000);

// Cria shopping cart
ShoppingCart shoppingCart = new ShoppingCart();
shoppingCart.setDeliveryAddress(new DeliveryAddress());
shoppingCart.getDeliveryAddress().setCity("Galaxy Far Far Away");
shoppingCart.getDeliveryAddress().setComplement("Bridge");
shoppingCart.getDeliveryAddress().setCountry(CountryEnum.Brazil);
shoppingCart.getDeliveryAddress().setDistrict("Command Room");
shoppingCart.getDeliveryAddress().setNumber("321");
shoppingCart.getDeliveryAddress().setState("RJ");
shoppingCart.getDeliveryAddress().setStreet("Death Star");
shoppingCart.getDeliveryAddress().setZipCode("10002000");
shoppingCart.setDeliveryDeadline(Date.valueOf("2015-12-14"));
shoppingCart.setEstimatedDeliveryDate(Date.valueOf("2015-12-14"));
shoppingCart.setFreightCostInCents(2000);
shoppingCart.setShippingCompany("Empire");
shoppingCart.setShoppingCartItemCollection(new ArrayList<>());
shoppingCart.getShoppingCartItemCollection().add(shoppingCartItem);

// Cria o Sale Request para enviar o objeto de request
CreateSaleRequest createSaleRequest = new CreateSaleRequest();
createSaleRequest.setCreditCardTransactionCollection(new ArrayList<>());
createSaleRequest.getCreditCardTransactionCollection().add(creditCardTransaction);
createSaleRequest.setBoletoTransactionCollection(new ArrayList<>());
createSaleRequest.getBoletoTransactionCollection().add(boletoTransaction);
createSaleRequest.setMerchant(new Merchant());
createSaleRequest.getMerchant().setMerchantReference("IdDaLojaPlataforma");
createSaleRequest.setOptions(new SaleOptions());
createSaleRequest.getOptions().setAntiFraudServiceCode(0);
createSaleRequest.getOptions().setCurrencyIso(CurrencyIsoEnum.BRL);
createSaleRequest.getOptions().setIsAntiFraudEnabled(Boolean.TRUE);
createSaleRequest.getOptions().setRetries(1);
createSaleRequest.setOrder(order);
createSaleRequest.setRequestData(new RequestData());
createSaleRequest.getRequestData().setEcommerceCategory(EcommerceCategoryEnum.B2C);
createSaleRequest.getRequestData().setIpAddress("127.0.0.1");
createSaleRequest.getRequestData().setOrigin("SiteDeCompra");
createSaleRequest.getRequestData().setSessionId("IdSessaoNoSite");
createSaleRequest.setShoppingCartCollection(new ArrayList<>());
createSaleRequest.getShoppingCartCollection().add(shoppingCart);

// Cria o cliente que vai enviar a transação
GatewayServiceClient serviceClient = new GatewayServiceClient(merchantKey, "https://sandbox.mundipaggone.com");

// Submete a transação e retorna a resposta do gateway
HttpResponseGenerics<CreateSaleResponse, CreateSaleRequest> httpResponse
        = serviceClient.getSale().Create(createSaleRequest);

return httpResponse.getRawResponse();
{
    "BoletoTransactionCollection": [
        {
            "AmountInCents": 10000,
            "BankNumber": "237",
            "BillingAddress": {
                "City": "Tatooine",
                "Complement": "",
                "Country": "Brazil",
                "District": "Mos Eisley",
                "Number": "123",
                "State": "RJ",
                "Street": "Mos Eisley Cantina",
                "ZipCode": "20001000"
            },
            "DocumentNumber": "12345678901",
            "Instructions": "Pagar antes do vencimento",
            "Options": {
                "CurrencyIso": "BRL",
                "DaysToAddInBoletoExpirationDate": 5
            },
            "TransactionReference": "NumeroDaTransacao"
        }
    ],
    "Buyer": {
        "AddressCollection": [
            {
                "AddressType": "Residential",
                "City": "Tatooine",
                "Complement": "",
                "Country": "Brazil",
                "District": "Mos Eisley",
                "Number": "123",
                "State": "RJ",
                "Street": "Mos Eisley Cantina",
                "ZipCode": "20001000"
            }
        ],
        "Birthdate": "1990-08-20T00:00:00",
        "BuyerCategory": "Normal",
        "BuyerReference": "C3PO",
        "CreateDateInMerchant": "2015-12-11T18:36:45",
        "DocumentNumber": "12345678901",
        "DocumentType": "CPF",
        "Email": "[email protected]",
        "EmailType": "Personal",
        "FacebookId": "lukeskywalker8917",
        "Gender": "M",
        "HomePhone": "(21)123456789",
        "MobilePhone": "(21)987654321",
        "Name": "Luke Skywalker",
        "PersonType": "Person",
        "TwitterId":"@lukeskywalker8917",
        "WorkPhone": "(21)28467902"
    },
    "CreditCardTransactionCollection": [
        {
            "AmountInCents": 10000,
            "CreditCard": {
                "BillingAddress": {
                    "City": "Tatooine",
                    "Complement": "",
                    "Country": "Brazil",
                    "District": "Mos Eisley",
                    "Number": "123",
                    "State": "RJ",
                    "Street": "Mos Eisley Cantina",
                    "ZipCode": "20001000"
                },
                "CreditCardBrand": "Visa",
                "CreditCardNumber": "4111111111111111",
                "ExpMonth": 10,
                "ExpYear": 22,
                "HolderName": "LUKE SKYWALKER",
                "SecurityCode": "123"
            },
            "CreditCardOperation": "AuthOnly",
            "InstallmentCount": 1,
            "Options": {
                "CurrencyIso": "BRL",
                "PaymentMethodCode": 1,
                "SoftDescriptorText": "Jedi Mega Store",
              	"IsRecurringTransaction": "false"
            },
            "TransactionReference": "NumeroDaTransacao"
        }
    ],
    "Merchant": {
        "MerchantReference": "IdDaLojaPlataforma"
    },
    "Options": {
        "AntiFraudServiceCode": 0,
        "CurrencyIso": "BRL",
        "IsAntiFraudEnabled": true,
        "Retries": 1
    },
    "Order": {
        "OrderReference": "NumeroDoPedido"
    },
    "RequestData": {
        "EcommerceCategory": "B2C",
        "IpAddress": "127.0.0.1",
        "Origin": "SiteDeCompra",
        "SessionId": "IdSesssaoNoSite"
    },
    "ShoppingCartCollection": [
        {
            "DeliveryAddress": {
                "City": "Galaxy far far away",
                "Complement": "Bridge",
                "Country": "Brazil",
                "District": "Command Room",
                "Number": "321",
                "State": "RJ",
                "Street": "Death Star",
                "ZipCode": "10002000"
            },
            "DeliveryDeadline": "2015-12-14T18:36:45",
            "EstimatedDeliveryDate": "2015-12-14T18:36:45",
            "FreightCostInCents": 2000,
            "ShippingCompany": "Empire",
            "ShoppingCartItemCollection": [
                {
                    "Description": "Red Lightsaber",
                    "DiscountAmountInCents": 0,
                    "ItemReference": "NumeroDoProduto",
                    "Name": "Lightsaber",
                    "Quantity": 1,
                    "TotalCostInCents": 18000,
                    "UnitCostInCents": 18000
                }
            ]
        }
    ]
}
Language
Website Localization**/