post https://sandbox.mundipaggone.com/Buyer
Guid merchantKey = Guid.Parse("00000000-0000-0000-0000-000000000000");
Guid buyerKey = Guid.Parse("247210dc-e02e-4c2c-9120-652e18aa8de8");
// Cria o cliente para obter os dados do cartão.
var client = new GatewayServiceClient(merchantKey, new Uri("https://sandbox.mundipaggone.com"));
var createBuyerRequest = new CreateBuyerRequest() {
AddressCollection = new Collection<BuyerAddress>() {
new BuyerAddress(){
AddressType = AddressTypeEnum.Residential,
City="Tatooine",
Complement="",
Country="Brazil",
District="Mos Eisley",
Number="123",
State="RJ",
Street="Mos Eisley Cantina",
ZipCode="20001000"
}
},
Birthdate = new DateTime(1990, 08, 20),
BuyerReference = "C3PO",
DocumentNumber = "12345678901",
DocumentType = DocumentTypeEnum.CPF,
Email = "[email protected]",
EmailType = EmailTypeEnum.Personal,
Gender = GenderEnum.M,
HomePhone = "(21)123456789",
MobilePhone = "(21)987654321",
Name = "Luke Skywalker",
PersonType = PersonTypeEnum.Person,
WorkPhone = "(21)28467902"
};
// Obtém os dados do cartão de crédito no gateway.
var httpResponse = client.Buyer.CreateBuyer(createBuyerRequest);
if (httpResponse.HttpStatusCode == HttpStatusCode.Created
&& httpResponse.Response.Success == true) {
Console.WriteLine("Chave do comprador: {0}", httpResponse.Response.BuyerKey);
}
<?php
// Carrega dependências
require_once(dirname(__FILE__) . '\vendor\autoload.php');
try
{
// Define a url utilizada
\Gateway\ApiClient::setBaseUrl("https://sandbox.mundipaggone.com");
// Define a chave da loja
\Gateway\ApiClient::setMerchantKey("85328786-8BA6-420F-9948-5352F5A183EB");
// Cria objeto requisição
$request = new \Gateway\One\DataContract\Request\CreateBuyerRequest();
$request
->setBirthdate(\DateTime::createFromFormat('d/m/Y', '20/08/1990'))
->setBuyerCategory(\Gateway\One\DataContract\Enum\BuyerCategoryEnum::PLUS)
->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")
->setName("Luke Skywalker")
->setPersonType(\Gateway\One\DataContract\Enum\PersonTypeEnum::PERSON)
->setWorkPhone("(21)28467902")
->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);
//Cria um objeto ApiClient
$client = new Gateway\ApiClient();
//var_dump($request->getData());exit;
// Faz a chamada para criação
$response = $client->createBuyer($request);
// Imprime resposta
print "<pre>";
print json_encode(array('success' => $response->isSuccess(), 'data' => $response->getData()), JSON_PRETTY_PRINT);
print "</pre>";
}
catch (\Gateway\One\DataContract\Report\ApiError $error)
{
// Imprime json
print "<pre>";
print json_encode($error, JSON_PRETTY_PRINT);
print "</pre>";
}
catch (Exception $ex)
{
// Imprime json
print "<pre>";
print json_encode($ex, JSON_PRETTY_PRINT);
print "</pre>";
}
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 the address
address = Gateway::BuyerAddress.new
address.AddressType = 'Residential'
address.City = 'Tatooine'
address.Complement = ''
address.Country = 'Brazil'
address.District = 'Mos Eisley'
address.Number = '123'
address.State = 'RJ'
address.Street = 'Mos Eisley Cantina'
address.ZipCode = '20001000'
# Creates the buyer request
buyer_request = Gateway::CreateBuyerRequest.new
buyer_request.AddressCollection << address
buyer_request.Birthdate = DateTime.new(1990,8,20,0,0,0).strftime("%Y-%m-%dT%H:%M:%S")
buyer_request.BuyerReference = 'C3PO'
buyer_request.DocumentNumber = '12345678901'
buyer_request.DocumentType = 'CPF'
buyer_request.Email = '[email protected]'
buyer_request.EmailType = 'Personal'
buyer_request.Gender = 'M'
buyer_request.HomePhone = '(21)123456789'
buyer_request.MobilePhone = '(21)987654321'
buyer_request.Name = 'Luke Skywalker'
buyer_request.PersonType = 'Person'
buyer_request.WorkPhone = '(21)28467902'
response = gateway.CreateBuyer(buyer_request)
puts response
// Define loja
UUID merchantKey = UUID.fromString("85328786-8BA6-420F-9948-5352F5A183EB"); // Chave da Loja - MerchantKey
// Cria o cliente que vai enviar a transação
GatewayServiceClient serviceClient = new GatewayServiceClient(merchantKey, "https://sandbox.mundipaggone.com");
// Monta objeto Address
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");
// Define a chave do InstantBuy
CreateBuyerRequest buyer = new CreateBuyerRequest();
buyer.setAddressCollection(new ArrayList<>());
buyer.getAddressCollection().add(buyerAddress);
buyer.setBirthdate(Date.valueOf("1990-08-20"));
buyer.setBuyerReference("C3PO");
buyer.setDocumentNumber("12345678901");
buyer.setDocumentType(DocumentTypeEnum.CPF);
buyer.setEmail("[email protected]");
buyer.setEmailType(EmailTypeEnum.Personal);
buyer.setGender(GenderEnum.M);
buyer.setHomePhone("(21)987654321");
buyer.setMobilePhone("21555554556");
buyer.setName("Luke Skywalker");
buyer.setPersonType(PersonTypeEnum.Person);
buyer.setWorkPhone("(21)28467902");
// Autoriza a transação e retorna a resposta do gateway
HttpResponseGenerics<CreateBuyerResponse, CreateBuyerRequest> httpResponse
= serviceClient.getBuyer().CreateBuyer(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",
"BuyerReference":"C3PO",
"DocumentNumber":"12345678901",
"DocumentType":"CPF",
"Email":"[email protected]",
"EmailType":"Personal",
"Gender":"M",
"HomePhone":"(21)123456789",
"MobilePhone":"(21)987654321",
"Name":"Luke Skywalker",
"PersonType":"Person",
"WorkPhone":"(21)28467902"
}