mundipagg/onlinedebit

This package is abandoned and no longer maintained. No replacement package was suggested.

Mundipagg Online Debit PHP Library

v1.3 2016-02-26 18:36 UTC

This package is not auto-updated.

Last update: 2018-04-28 13:24:30 UTC


README

Download it on Packadist

Use Compsoser!

composer require mundipagg/onlinedebit

Making a request [Production]

<?php
require_once(dirname(__FILE__) . '\..\init.php');
try {
	
	$client = new \Gateway\ApiClientOnlineDebit();
	// Cria objeto requisição
	$request = new \Gateway\OnlineDebit\DataContract\Request\OnlineDebitSaleRequest();
    // Dados da transação do Online Debit
	$request
	->setAmountInCents(100)
	->setBank("BradescoStaging")
	->setInstallmentCount(1)
	->setMerchantKey("00000000-0000-0000-0000-000000000000")
	->setOrderKey("00000000-0000-0000-0000-000000000000")
	->setPaymentMethod(null)
	->setPaymentType(null)
	->setInstallmentCount(1)
	->setRequestKey("00000000-0000-0000-0000-000000000000")
	->setTransactionReference("TesteReference");
	// Dados do comprador
	$buyer = $request->getBuyer();
	$buyer
	->setName("Fulano Teste da Silva")
	->setBuyerReference("TesteReference")
	->setEmail("teste@teste.com")
	->setGenderEnum(\Gateway\OnlineDebit\DataContract\Enum\GenderEnum::MALE)
	->setTaxDocumentTypeEnum(\Gateway\OnlineDebit\DataContract\Enum\DocumentTypeEnum::CPF)
	->setTaxDocumentNumber("22222222222")
	->addBuyerAddress()
	->setAddressTypeEnum(\Gateway\OnlineDebit\DataContract\Enum\AddressTypeEnum::RESIDENTIAL)
	->setCity("Rio de Janeiro")
	->setComplement("apt 200")
	->setCountryEnum(\Gateway\OnlineDebit\DataContract\Enum\CountryEnum::BRAZIL)
	->setDistrict("Copacabana")
	->setNumber("22")
	->setState("Rio de Janeiro")
	->setStreet("Rua teste")
	->setZipCode("22222222");
	$buyer
	->addPhoneRequest()
	->setAreaCode("021")
	->setCountryCode("055")
	->setExtension("")
	->setPhoneNumber("22222222")
	->setPhoneTypeEnum(\Gateway\OnlineDebit\DataContract\Enum\PhoneTypeEnum::COMERCIAL);
	$request->getShoppingCart()
	->setDeliveryDeadLine(new DateTime())
	->setEstimatedDeliveryDate(new DateTime())
	->setFreightCostInCents(0)
	->setShippingCompany("Sedex")
	->addShoppingCartItem()
	->setDescription("Gateway de Pagamento")
	->setDiscountAmountInCents(10)
	->setItemReference("003")
	->setName("Mundipagg")
	->setQuantity(1)
	->setTotalCostInCents(100)
	->setUnitCostInCents(100);
	$request->getOrderRequest()
	->setAmountInCents(100)
	->setOrderReference("Pedido Teste");
	// Imprime request
    print "<pre>";
    print json_encode($request->getData(), JSON_PRETTY_PRINT);
    print "</pre>";
	$response = $client->createSaleOnlineDebit($request);
	// Imprime resposta
    print "<pre>";
    print json_encode(array('success' => $response->isSuccess(), 'data' => $response->getData()), JSON_PRETTY_PRINT);
    print "</pre>";
} catch (Exception $e) {
	// Imprime json
    print "<pre>";
    print var_dump($e);
    print "</pre>";
}

Making a request [Sandbox]

<?php
require_once(dirname(__FILE__) . '\..\init.php');
try {
	
	$client = new \Gateway\ApiClientOnlineDebit(\Gateway\OnlineDebit\DataContract\Enum\ApiEnvironmentEnum::SANDBOX);
	// Cria objeto requisição
	$request = new \Gateway\OnlineDebit\DataContract\Request\OnlineDebitSaleRequest();
    // Dados da transação do Online Debit
	$request
	->setAmountInCents(100)
	->setBank("BradescoStaging")
	->setInstallmentCount(1)
	->setMerchantKey("00000000-0000-0000-0000-000000000000")
	->setOrderKey("00000000-0000-0000-0000-000000000000")
	->setPaymentMethod(null)
	->setPaymentType(null)
	->setInstallmentCount(1)
	->setRequestKey("00000000-0000-0000-0000-000000000000")
	->setTransactionReference("TesteReference");
	// Dados do comprador
	$buyer = $request->getBuyer();
	$buyer
	->setName("Fulano Teste da Silva")
	->setBuyerReference("TesteReference")
	->setEmail("teste@teste.com")
	->setGenderEnum(\Gateway\OnlineDebit\DataContract\Enum\GenderEnum::MALE)
	->setTaxDocumentTypeEnum(\Gateway\OnlineDebit\DataContract\Enum\DocumentTypeEnum::CPF)
	->setTaxDocumentNumber("22222222222")
	->addBuyerAddress()
	->setAddressTypeEnum(\Gateway\OnlineDebit\DataContract\Enum\AddressTypeEnum::RESIDENTIAL)
	->setCity("Rio de Janeiro")
	->setComplement("apt 200")
	->setCountryEnum(\Gateway\OnlineDebit\DataContract\Enum\CountryEnum::BRAZIL)
	->setDistrict("Copacabana")
	->setNumber("22")
	->setState("Rio de Janeiro")
	->setStreet("Rua teste")
	->setZipCode("22222222");
	$buyer
	->addPhoneRequest()
	->setAreaCode("021")
	->setCountryCode("055")
	->setExtension("")
	->setPhoneNumber("22222222")
	->setPhoneTypeEnum(\Gateway\OnlineDebit\DataContract\Enum\PhoneTypeEnum::COMERCIAL);
	$request->getShoppingCart()
	->setDeliveryDeadLine(new DateTime())
	->setEstimatedDeliveryDate(new DateTime())
	->setFreightCostInCents(0)
	->setShippingCompany("Sedex")
	->addShoppingCartItem()
	->setDescription("Gateway de Pagamento")
	->setDiscountAmountInCents(10)
	->setItemReference("003")
	->setName("Mundipagg")
	->setQuantity(1)
	->setTotalCostInCents(100)
	->setUnitCostInCents(100);
	$request->getOrderRequest()
	->setAmountInCents(100)
	->setOrderReference("Pedido Teste");
	// Imprime request
    print "<pre>";
    print json_encode($request->getData(), JSON_PRETTY_PRINT);
    print "</pre>";
	$response = $client->createSaleOnlineDebit($request);
	// Imprime resposta
    print "<pre>";
    print json_encode(array('success' => $response->isSuccess(), 'data' => $response->getData()), JSON_PRETTY_PRINT);
    print "</pre>";
} catch (Exception $e) {
	// Imprime json
    print "<pre>";
    print var_dump($e);
    print "</pre>";
}