diff --git a/CHANGELOG.md b/CHANGELOG.md index 985a3eb..fc4ccf6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,24 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). + +# [](https://github.com/moip/moip-sdk-php/compare/v2.0.0...v2.1.0) (2017-10-09) + +### Bug Fixes + +* Prevent notice when tax document or receivers are not returned ([6f6c10b](https://github.com/moip/moip-sdk-php/commit/6f6c10b)) + +### Features + +* **Account:** Create method to check if an account exists ([17e6cd2](https://github.com/moip/moip-sdk-php/commit/17e6cd2)) +* **Keys:** adds method to get public key from moip account ([fc2143a](https://github.com/moip/moip-sdk-php/commit/fc2143a)) +* **NotificationPreferences:** Added method to get a list of notifications ([9be2ae4](https://github.com/moip/moip-sdk-php/commit/9be2ae4)) +* **NotificationPreferences:** added method to get a notification preference ([d9f4062](https://github.com/moip/moip-sdk-php/commit/d9f4062)) +* **Payment:** add method 'cancel' to cancel pre-authorized payments ([858cece](https://github.com/moip/moip-sdk-php/commit/858cece)) +* **Payment:** changed 'capture' method to allow multipayments ([32d70e7](https://github.com/moip/moip-sdk-php/commit/32d70e7)) +* **Payment:** changed 'get' method to allow get a payment without get an order first ([7874a7e](https://github.com/moip/moip-sdk-php/commit/7874a7e)) + + ### [2.0.0](https://github.com/moip/moip-sdk-php/compare/v1.3.2...v2.0.0) (2017-09-29) diff --git a/README.md b/README.md index ebbd10f..62e83bd 100644 --- a/README.md +++ b/README.md @@ -38,11 +38,21 @@ - [Pedidos](#pedidos) - [Criação](#criando-um-pedido-com-o-comprador-que-acabamos-de-criar) - [Consulta](#consultando-um-pedido) + - [Pedido Específico](#pedido-específico) + - [Todos os Pedidos](#todos-os-pedidos) + - [Sem Filtro](#sem-filtro) + - [Com Filtros](#com-filtros) + - [Com Paginação](#com-paginação) + - [Consulta Valor Específico](#consulta-valor-específico) - [Pagamentos](#pagamentos) - - [Cartão de Crédito](#cartão-de-crédito) - - [Com Hash](#com-hash) - - [Com Dados do Cartão](#com-dados-do-cartão) - - [Com Boleto](#criando-um-pagamento-com-boleto) + - [Criação](#criação) + - [Cartão de Crédito](#cartão-de-crédito) + - [Com Hash](#com-hash) + - [Com Dados do Cartão](#com-dados-do-cartão) + - [Com Boleto](#criando-um-pagamento-com-boleto) + - [Consulta](#consulta) + - [Capturar pagamento pré-autorizado](#capturar-pagamento-pré-autorizado) + - [Cancelar pagamento pré-autorizado](#cancelar-pagamento-pré-autorizado) - [Reembolsos](#reembolsos) - [Cartão de crédito](#cartão-de-crédito-1) - [Valor Total](#valor-total) @@ -50,19 +60,27 @@ - [Conta Bancária](#conta-bancária) - [Valor Total](#valor-total-1) - [Valor Parcial](#valor-parcial-1) - - [Consulta](#consulta-2) + - [Consulta](#consulta-1) - [Multipedidos](#multipedidos) - [Criação](#criando-um-multipedido) - [Consulta](#consultando-um-multipedido) - [Multipagamentos](#multipagamentos) - [Criação](#criando-um-multipagamento) + - [Consulta](#consulta-2) - [Conta Moip](#conta-moip) - - [Criação](#criação) + - [Criação](#criação-1) - [Consulta](#consulta-3) - [Verifica se usuário já possui Conta Moip](#verifica-se-usuário-já-possui-conta-moip) + - [Obter chave pública de uma Conta Moip](#obter-chave-pública-de-uma-conta-moip) + - [Preferências de Notificação](#preferências-de-notificação) + - [Criação](#criação-2) + - [Consulta](#consulta-4) + - [Exclusão](#exclusão) + - [Listagem](#listagem) - [Webhooks](#webhooks) - - [Consulta](#consulta-4) + - [Consulta](#consulta-5) - [Packages](#packages) +- [Tratamento de exceções](#tratamento-de-exceções) - [Documentação](#documentação) - [Testes](#testes) - [Licença](#licença) @@ -117,64 +135,48 @@ $moip = new Moip(new OAuth($access_token), Moip::ENDPOINT_SANDBOX); ### Criando um comprador Nesse exemplo será criado um pedido com dados do cliente - Com endereço de entrega e de pagamento. ```php -try { - $customer = $moip->customers()->setOwnId(uniqid()) - ->setFullname('Fulano de Tal') - ->setEmail('fulano@email.com') - ->setBirthDate('1988-12-30') - ->setTaxDocument('22222222222') - ->setPhone(11, 66778899) - ->addAddress('BILLING', - 'Rua de teste', 123, - 'Bairro', 'Sao Paulo', 'SP', - '01234567', 8) - ->addAddress('SHIPPING', - 'Rua de teste do SHIPPING', 123, - 'Bairro do SHIPPING', 'Sao Paulo', 'SP', - '01234567', 8) - ->create(); - print_r($customer); -} catch (Exception $e) { - printf($e->__toString()); -} +$customer = $moip->customers()->setOwnId(uniqid()) + ->setFullname('Fulano de Tal') + ->setEmail('fulano@email.com') + ->setBirthDate('1988-12-30') + ->setTaxDocument('22222222222') + ->setPhone(11, 66778899) + ->addAddress('BILLING', + 'Rua de teste', 123, + 'Bairro', 'Sao Paulo', 'SP', + '01234567', 8) + ->addAddress('SHIPPING', + 'Rua de teste do SHIPPING', 123, + 'Bairro do SHIPPING', 'Sao Paulo', 'SP', + '01234567', 8) + ->create(); +print_r($customer); ``` ### Consultando os dados de um comprador ```php -try { - $customer_id = 'CUS-Q3BL0CAJ2G33'; - $customer = $moip->customers()->get($customer_id); - print_r($customer); -} catch (Exception $e) { - printf($e->__toString()); -} +$customer = $moip->customers()->get('CUS-Q3BL0CAJ2G33'); +print_r($customer); ``` ### Adicionar cartão de crédito ```php -try { - $customer = $moip->customers()->creditCard() - ->setExpirationMonth('05') - ->setExpirationYear(2018) - ->setNumber('4012001037141112') - ->setCVC('123') - ->setFullName('Jose Portador da Silva') - ->setBirthDate('1988-12-30') - ->setTaxDocument('CPF', '33333333333') - ->setPhone('55','11','66778899') - ->create(CUSTOMER_ID); -} catch (Exception $e) { - printf($e->__toString()); -} +$customer = $moip->customers()->creditCard() + ->setExpirationMonth('05') + ->setExpirationYear(2018) + ->setNumber('4012001037141112') + ->setCVC('123') + ->setFullName('Jose Portador da Silva') + ->setBirthDate('1988-12-30') + ->setTaxDocument('CPF', '33333333333') + ->setPhone('55','11','66778899') + ->create(CUSTOMER_ID); +print_r($customer); ``` ### Deletar cartão de crédito ```php -try { - $moip->customers()->creditCard()->delete(CREDIT_CARD_ID); -} catch (Exception $e) { - printf($e->__toString()); -} +$moip->customers()->creditCard()->delete(CREDIT_CARD_ID); ``` ## Pedidos @@ -182,90 +184,130 @@ try { Nesse exemplo com vários produtos e ainda especificando valor de frete, valor adicional e ainda valor de desconto. ```php -try { - $order = $moip->orders()->setOwnId(uniqid()) - ->addItem("bicicleta 1",1, "sku1", 10000) - ->addItem("bicicleta 2",1, "sku2", 11000) - ->addItem("bicicleta 3",1, "sku3", 12000) - ->addItem("bicicleta 4",1, "sku4", 13000) - ->addItem("bicicleta 5",1, "sku5", 14000) - ->addItem("bicicleta 6",1, "sku6", 15000) - ->addItem("bicicleta 7",1, "sku7", 16000) - ->addItem("bicicleta 8",1, "sku8", 17000) - ->addItem("bicicleta 9",1, "sku9", 18000) - ->addItem("bicicleta 10",1, "sku10", 19000) - ->setShippingAmount(3000)->setAddition(1000)->setDiscount(5000) - ->setCustomer($customer) - ->create(); - - print_r($order); -} catch (Exception $e) { - printf($e->__toString()); -} +$order = $moip->orders()->setOwnId(uniqid()) + ->addItem("bicicleta 1",1, "sku1", 10000) + ->addItem("bicicleta 2",1, "sku2", 11000) + ->addItem("bicicleta 3",1, "sku3", 12000) + ->addItem("bicicleta 4",1, "sku4", 13000) + ->addItem("bicicleta 5",1, "sku5", 14000) + ->addItem("bicicleta 6",1, "sku6", 15000) + ->addItem("bicicleta 7",1, "sku7", 16000) + ->addItem("bicicleta 8",1, "sku8", 17000) + ->addItem("bicicleta 9",1, "sku9", 18000) + ->addItem("bicicleta 10",1, "sku10", 19000) + ->setShippingAmount(3000)->setAddition(1000)->setDiscount(5000) + ->setCustomer($customer) + ->create(); +print_r($order); ``` ### Consultando um pedido +#### Pedido específico ```php -try { - $order_id = 'ORD-KZCH1S1ORAH23'; - $order = $moip->orders()->get($order_id); - print_r($order); -} catch (Exception $e) { - printf($e->__toString()); -} +$order = $moip->orders()->get('ORD-KZCH1S1ORAH23'); +print_r($order); +``` + +#### Todos os Pedidos +##### Sem Filtro +```php +$orders = $this->moip->orders()->getList(); +``` + +##### Com Filtros +```php +$filters = new Filters(); +$filters->greaterThanOrEqual(OrdersList::CREATED_AT, '2017-08-17'); +$filters->in(OrdersList::PAYMENT_METHOD, ['BOLETO', 'DEBIT_CARD']); +$filters->lessThan(OrdersList::VALUE, 100000); + +$orders = $this->moip->orders()->getList(null, $filters); +``` + +##### Com Paginação +```php +$orders = $this->moip->orders()->getList(new Pagination(10,0)); +``` + +##### Consulta Valor Específico +```php +$orders = $this->moip->orders()->getList(null, null, 'josé silva'); +``` + +> Também é possível usar paginação, filtros e consulta de valor específico juntos + +```php +$filters = new Filters(); +$filters->greaterThanOrEqual(OrdersList::CREATED_AT, '2017-08-17'); +$filters->lessThan(OrdersList::VALUE, 100000); + +$orders = $this->moip->orders()->getList(new Pagination(10,0), $filters, 'josé silva'); ``` ## Pagamentos -### Cartão de crédito + +### Criação +#### Cartão de crédito Após criar o pedido basta criar um pagamento nesse pedido. -#### Com hash +##### Com hash > Para mais detalhes sobre a geração de hash com os dados do cartão [consulte a documentação.](https://dev.moip.com.br/docs/criptografia-de-cartao) ```php -try { - $hash = 'i1naupwpTLrCSXDnigLLTlOgtm+xBWo6iX54V/hSyfBeFv3rvqa1VyQ8/pqWB2JRQX2GhzfGppXFPCmd/zcmMyDSpdnf1GxHQHmVemxu4AZeNxs+TUAbFWsqEWBa6s95N+O4CsErzemYZHDhsjEgJDe17EX9MqgbN3RFzRmZpJqRvqKXw9abze8hZfEuUJjC6ysnKOYkzDBEyQibvGJjCv3T/0Lz9zFruSrWBw+NxWXNZjXSY0KF8MKmW2Gx1XX1znt7K9bYNfhA/QO+oD+v42hxIeyzneeRcOJ/EXLEmWUsHDokevOkBeyeN4nfnET/BatcDmv8dpGXrTPEoxmmGQ=='; - $payment = $order->payments() - ->setCreditCardHash($hash, $customer) - ->setInstallmentCount(3) - ->setStatementDescriptor('teste de pag') - ->setDelayCapture(false) - ->execute(); - print_r($payment); -} catch (Exception $e) { - printf($e->__toString()); -} +$hash = 'i1naupwpTLrCSXDnigLLTlOgtm+xBWo6iX54V/hSyfBeFv3rvqa1VyQ8/pqWB2JRQX2GhzfGppXFPCmd/zcmMyDSpdnf1GxHQHmVemxu4AZeNxs+TUAbFWsqEWBa6s95N+O4CsErzemYZHDhsjEgJDe17EX9MqgbN3RFzRmZpJqRvqKXw9abze8hZfEuUJjC6ysnKOYkzDBEyQibvGJjCv3T/0Lz9zFruSrWBw+NxWXNZjXSY0KF8MKmW2Gx1XX1znt7K9bYNfhA/QO+oD+v42hxIeyzneeRcOJ/EXLEmWUsHDokevOkBeyeN4nfnET/BatcDmv8dpGXrTPEoxmmGQ=='; +$payment = $order->payments() + ->setCreditCardHash($hash, $customer) + ->setInstallmentCount(3) + ->setStatementDescriptor('teste de pag') + ->setDelayCapture(false) + ->execute(); +print_r($payment); ``` -#### Com dados do cartão +##### Com dados do cartão > Esse método requer certificação PCI. [Consulte a documentação.](https://documentao-moip.readme.io/v2.0/reference#criar-pagamento) ```php -try { - $payment = $order->payments()->setCreditCard(12, 21, '4073020000000002', '123', $customer) - ->execute(); - - print_r($payment); -} catch (Exception $e) { - printf($e->__toString()); -} +$payment = $order->payments()->setCreditCard(12, 21, '4073020000000002', '123', $customer) + ->execute(); +print_r($payment); ``` - -### Criando um pagamento com boleto +#### Criando um pagamento com boleto ```php $logo_uri = 'https://cdn.moip.com.br/wp-content/uploads/2016/05/02163352/logo-moip.png'; $expiration_date = new DateTime(); $instruction_lines = ['INSTRUÇÃO 1', 'INSTRUÇÃO 2', 'INSTRUÇÃO 3']; +$payment = $order->payments() + ->setBoleto($expiration_date, $logo_uri, $instruction_lines) + ->execute(); +print_r($payment); +``` + +### Consulta +```php +$payment = $moip->payments()->get('PAYMENT-ID'); +print_r($payment); +``` + +### Capturar pagamento pré-autorizado +```php try { - $payment = $order->payments() - ->setBoleto($expiration_date, $logo_uri, $instruction_lines) - ->execute(); - print_r($payment); + $captured_payment = $payment->capture(); + print_r($captured_payment); } catch (Exception $e) { printf($e->__toString()); } ``` +### Cancelar pagamento pré-autorizado + +> O método `avoid` usado para cancelamento de pagamentos pré-autorizados foi substituído por `cancel`. + +```php +$payment = $payment->cancel(); +print_r($payment); +``` + ## Reembolsos Para fazer reembolsos é necessário ter o objeto **```Payment```** do pagamento que você deseja reembolsar. @@ -273,183 +315,208 @@ Para fazer reembolsos é necessário ter o objeto **```Payment```** do pagamento ### Cartão de crédito #### Valor Total ```php -try { - $refund = $payment->refunds()->creditCardFull(); - print_r($refund); -} catch (Exception $e) { - printf($e->__toString()); -} +$refund = $payment->refunds()->creditCardFull(); +print_r($refund); ``` #### Valor Parcial ```php -try { - $amount = 30000; - $refund = $payment->refunds()->creditCardPartial($amount); - print_r($refund); -} catch (Exception $e) { - printf($e->__toString()); -} +$refund = $payment->refunds()->creditCardPartial(30000); +print_r($refund); ``` ### Conta bancária #### Valor Total ```php -try { - $type = 'CHECKING'; - $bank_number = '001'; - $agency_number = 4444444; - $agency_check_number = 2; - $account_number = 1234; - $account_check_number = 4; - $refund = $payment->refunds() - ->bankAccountFull($type, $bank_number, $agency_number, $agency_check_number, $account_number, $account_check_number, $customer); - print_r($refund); -} catch (Exception $e) { - printf($e->__toString()); -} +$type = 'CHECKING'; +$bank_number = '001'; +$agency_number = 4444444; +$agency_check_number = 2; +$account_number = 1234; +$account_check_number = 4; +$refund = $payment->refunds() + ->bankAccountFull( + $type, + $bank_number, + $agency_number, + $agency_check_number, + $account_number, + $account_check_number, + $customer + ); +print_r($refund); ``` #### Valor Parcial ```php -try { - $amount = 30000; - $type = 'SAVING'; - $bank_number = '001'; - $agency_number = 4444444; - $agency_check_number = 2; - $account_number = 1234; - $account_check_number = 4; - $refund = $payment->refunds() - ->bankAccountPartial($amount, $type, $bank_number, $agency_number, $agency_check_number, $account_number, $account_check_number, $customer); - print_r($refund); -} catch (Exception $e) { - printf($e->__toString()); -} +$amount = 30000; +$type = 'SAVING'; +$bank_number = '001'; +$agency_number = 4444444; +$agency_check_number = 2; +$account_number = 1234; +$account_check_number = 4; +$refund = $payment->refunds() + ->bankAccountPartial( + $amount, + $type, + $bank_number, + $agency_number, + $agency_check_number, + $account_number, + $account_check_number, + $customer + ); +print_r($refund); ``` ## Multipedidos ### Criando um multipedido ```php -try { - $order = $moip->orders()->setOwnId(uniqid()) - ->addItem("bicicleta 1",1, "sku1", 10000) - ->addItem("bicicleta 2",1, "sku2", 11000) - ->addItem("bicicleta 3",1, "sku3", 12000) - ->addItem("bicicleta 4",1, "sku4", 13000) - ->setShippingAmount(3000) - ->setAddition(1000) - ->setDiscount(5000) - ->setCustomer($customer) - ->addReceiver('MPA-VB5OGTVPCI52', 'PRIMARY', NULL); - $order2 = $moip->orders()->setOwnId(uniqid()) - ->addItem("bicicleta 1",1, "sku1", 10000) - ->addItem("bicicleta 2",1, "sku2", 11000) - ->addItem("bicicleta 3",1, "sku3", 12000) - ->setShippingAmount(3000) - ->setAddition(1000) - ->setDiscount(5000) - ->setCustomer($customer) - ->addReceiver('MPA-IFYRB1HBL73Z', 'PRIMARY', NULL); - - $multiorder = $this->moip->multiorders() - ->setOwnId(uniqid()) - ->addOrder($order) - ->addOrder($order2) - ->create(); - print_r($multiorder); -} catch (Exception $e) { - printf($e->__toString()); -} +$order = $moip->orders()->setOwnId(uniqid()) + ->addItem("bicicleta 1",1, "sku1", 10000) + ->addItem("bicicleta 2",1, "sku2", 11000) + ->addItem("bicicleta 3",1, "sku3", 12000) + ->addItem("bicicleta 4",1, "sku4", 13000) + ->setShippingAmount(3000) + ->setAddition(1000) + ->setDiscount(5000) + ->setCustomer($customer) + ->addReceiver('MPA-VB5OGTVPCI52', 'PRIMARY', NULL); +$order2 = $moip->orders()->setOwnId(uniqid()) + ->addItem("bicicleta 1",1, "sku1", 10000) + ->addItem("bicicleta 2",1, "sku2", 11000) + ->addItem("bicicleta 3",1, "sku3", 12000) + ->setShippingAmount(3000) + ->setAddition(1000) + ->setDiscount(5000) + ->setCustomer($customer) + ->addReceiver('MPA-IFYRB1HBL73Z', 'PRIMARY', NULL); + +$multiorder = $this->moip->multiorders() + ->setOwnId(uniqid()) + ->addOrder($order) + ->addOrder($order2) + ->create(); +print_r($multiorder); ``` ### Consultando um multipedido ```php -try { - $multiorder_id = 'ORD-KZCH1S1ORAH25'; - $multiorder = $moip->multiorders()->get($multiorder_id); - print_r($multiorder); -} catch (Exception $e) { - printf($e->__toString()); -} +$multiorder_id = 'ORD-KZCH1S1ORAH25'; +$multiorder = $moip->multiorders()->get($multiorder_id); +print_r($multiorder); ``` ## Multipagamentos ### Criando um multipagamento ```php -try { - $hash = 'i1naupwpTLrCSXDnigLLTlOgtm+xBWo6iX54V/hSyfBeFv3rvqa1VyQ8/pqWB2JRQX2GhzfGppXFPCmd/zcmMyDSpdnf1GxHQHmVemxu4AZeNxs+TUAbFWsqEWBa6s95N+O4CsErzemYZHDhsjEgJDe17EX9MqgbN3RFzRmZpJqRvqKXw9abze8hZfEuUJjC6ysnKOYkzDBEyQibvGJjCv3T/0Lz9zFruSrWBw+NxWXNZjXSY0KF8MKmW2Gx1XX1znt7K9bYNfhA/QO+oD+v42hxIeyzneeRcOJ/EXLEmWUsHDokevOkBeyeN4nfnET/BatcDmv8dpGXrTPEoxmmGQ=='; - $payment = $multiorder->multipayments() - ->setCreditCardHash($hash, $customer) - ->setInstallmentCount(3) - ->setStatementDescriptor('teste de pag') - ->setDelayCapture(false) - ->execute(); - print_r($payment); -} catch (Exception $e) { - printf($e->__toString()); -} +$hash = 'i1naupwpTLrCSXDnigLLTlOgtm+xBWo6iX54V/hSyfBeFv3rvqa1VyQ8/pqWB2JRQX2GhzfGppXFPCmd/zcmMyDSpdnf1GxHQHmVemxu4AZeNxs+TUAbFWsqEWBa6s95N+O4CsErzemYZHDhsjEgJDe17EX9MqgbN3RFzRmZpJqRvqKXw9abze8hZfEuUJjC6ysnKOYkzDBEyQibvGJjCv3T/0Lz9zFruSrWBw+NxWXNZjXSY0KF8MKmW2Gx1XX1znt7K9bYNfhA/QO+oD+v42hxIeyzneeRcOJ/EXLEmWUsHDokevOkBeyeN4nfnET/BatcDmv8dpGXrTPEoxmmGQ=='; +$payment = $multiorder->multipayments() + ->setCreditCardHash($hash, $customer) + ->setInstallmentCount(3) + ->setStatementDescriptor('teste de pag') + ->setDelayCapture(false) + ->execute(); +print_r($payment); +``` + +### Consulta +```php +$payment = $moip->payments()->get('MULTIPAYMENT-ID'); +print_r($payment); ``` ## Conta Moip ### Criação ```php +$street = 'Rua de teste'; +$number = 123; +$district = 'Bairro'; +$city = 'Sao Paulo'; +$state = 'SP'; +$zip = '01234567'; +$complement = 'Apt. 23'; +$country = 'BRA'; +$area_code = 11; +$phone_number = 66778899; +$country_code = 55; +$identity_document = '4737283560'; +$issuer = 'SSP'; +$issue_date = '2015-06-23'; +$account = $moip->accounts() + ->setName('Fulano') + ->setLastName('De Tal') + ->setEmail('fulano@email2.com') + ->setIdentityDocument($identity_document, $issuer, $issue_date) + ->setBirthDate('1988-12-30') + ->setTaxDocument('16262131000') + ->setType('MERCHANT') + ->setPhone($area_code, $phone_number, $country_code) + ->addAlternativePhone(11, 66448899, 55) + ->addAddress($street, $number, $district, $city, $state, $zip, $complement, $country) + ->setCompanyName('Empresa Teste', 'Teste Empresa ME') + ->setCompanyOpeningDate('2011-01-01') + ->setCompanyPhone(11, 66558899, 55) + ->setCompanyTaxDocument('69086878000198') + ->setCompanyAddress('Rua de teste 2', 123, 'Bairro Teste', 'Sao Paulo', 'SP', '01234567', 'Apt. 23', 'BRA') + ->setCompanyMainActivity('82.91-1/00', 'Atividades de cobranças e informações cadastrais') + ->create(); +print_r($account); +``` + +### Consulta +```php +$account = $moip->accounts()->get(ACCOUNT_ID); +print_r($account); +``` + +### Verifica se usuário já possui conta Moip +```php +// retorna verdadeiro se já possui e falso caso não possuir conta Moip +$moip->accounts()->checkAccountExists(CPF); +``` + +### Obter chave pública de uma Conta Moip +```php try { - $street = 'Rua de teste'; - $number = 123; - $district = 'Bairro'; - $city = 'Sao Paulo'; - $state = 'SP'; - $zip = '01234567'; - $complement = 'Apt. 23'; - $country = 'BRA'; - $area_code = 11; - $phone_number = 66778899; - $country_code = 55; - $identity_document = '4737283560'; - $issuer = 'SSP'; - $issue_date = '2015-06-23'; - $account = $moip->accounts() - ->setName('Fulano') - ->setLastName('De Tal') - ->setEmail('fulano@email2.com') - ->setIdentityDocument($identity_document, $issuer, $issue_date) - ->setBirthDate('1988-12-30') - ->setTaxDocument('16262131000') - ->setType('MERCHANT') - ->setPhone($area_code, $phone_number, $country_code) - ->addAlternativePhone(11, 66448899, 55) - ->addAddress($street, $number, $district, $city, $state, $zip, $complement, $country) - ->setCompanyName('Empresa Teste', 'Teste Empresa ME') - ->setCompanyOpeningDate('2011-01-01') - ->setCompanyPhone(11, 66558899, 55) - ->setCompanyTaxDocument('69086878000198') - ->setCompanyAddress('Rua de teste 2', 123, 'Bairro Teste', 'Sao Paulo', 'SP', '01234567', 'Apt. 23', 'BRA') - ->setCompanyMainActivity('82.91-1/00', 'Atividades de cobranças e informações cadastrais') - ->create(); - print_r($account); + $keys = $moip->keys()->get(); + print_r($keys); } catch (Exception $e) { printf($e->__toString()); } ``` +## Preferências de notificação + +### Criação +```php +$notification = $moip->notifications()->addEvent('ORDER.*') + ->addEvent('PAYMENT.AUTHORIZED') + ->setTarget('http://requestb.in/1dhjesw1') + ->create(); +print_r($notification); +``` + ### Consulta ```php -try { - $account = $moip->accounts()->get(ACCOUNT_ID); - print_r($account); -} catch (Exception $e) { - printf($e->__toString()); -} +$notification = $this->moip->notifications()->get('NPR-N6QZE3223P98'); +print_r($notification); ``` -### Verifica se usuário já possui conta Moip +### Exclusão ```php -// retorna verdadeiro se já possui e falso caso não possuir conta Moip -$moip->accounts()->checkAccountExists(CPF); +$notification = $moip->notifications()->delete('NOTIFICATION-ID'); +print_r($notification); +``` + +### Listagem +```php +$notifications = $moip->notifications()->getList(); +print_r($notifications); ``` ## Webhooks @@ -475,6 +542,30 @@ $moip->webhooks()->get(); $moip->webhooks()->get(new Pagination(10, 0), 'ORD-ID', 'ORDER.PAID'); ``` +## Tratamento de Exceções + +Quando ocorre algum erro na API, é lançada a exceção `UnexpectedException` para erros inesperados, `UnautorizedException` para erros de autenticação e `ValidationException` +para erros de validação. + +```php +try { + $moip->customers()->setOwnId(uniqid()) + ->setFullname('Fulano de Tal') + ->setEmail('fulano@email.com') + //... + ->create(); +} catch (\Moip\Exceptions\UnautorizedException $e) { + //StatusCode 401 + echo $e->getMessage(); +} catch (\Moip\Exceptions\ValidationException $e) { + //StatusCode entre 400 e 499 (exceto 401) + printf($e->__toString()); +} catch (\Moip\Exceptions\UnexpectedException $e) { + //StatusCode >= 500 + echo $e->getMessage(); +} +``` + ## Documentação [Documentação oficial](https://documentao-moip.readme.io/v2.0/reference) diff --git a/src/Moip.php b/src/Moip.php index b969384..00ad4cb 100644 --- a/src/Moip.php +++ b/src/Moip.php @@ -6,6 +6,7 @@ use Moip\Resource\Account; use Moip\Resource\Customer; use Moip\Resource\Entry; +use Moip\Resource\Keys; use Moip\Resource\Multiorders; use Moip\Resource\NotificationPreferences; use Moip\Resource\Orders; @@ -213,6 +214,16 @@ public function webhooks() return new WebhookList($this); } + /** + * Create a new Keys instance. + * + * @return Keys + */ + public function keys() + { + return new Keys($this); + } + /** * Get the endpoint. * diff --git a/src/Resource/Customer.php b/src/Resource/Customer.php index f012794..54fb5bf 100644 --- a/src/Resource/Customer.php +++ b/src/Resource/Customer.php @@ -258,8 +258,8 @@ protected function populate(stdClass $response) $customer->data->phone->number = $this->getIfSet('number', $phone); $customer->data->birthDate = $this->getIfSet('birthDate', $response); $customer->data->taxDocument = new stdClass(); - $customer->data->taxDocument->type = $this->getIfSet('type', $response->taxDocument); - $customer->data->taxDocument->number = $this->getIfSet('number', $response->taxDocument); + $customer->data->taxDocument->type = $this->getIfSet('type', $this->getIfSet('taxDocument', $response)); + $customer->data->taxDocument->number = $this->getIfSet('number', $this->getIfSet('taxDocument', $response)); $customer->data->addresses = []; $customer->data->shippingAddress = $this->getIfSet('shippingAddress', $response); $customer->data->billingAddress = $this->getIfSet('billingAddress', $response); diff --git a/src/Resource/Keys.php b/src/Resource/Keys.php new file mode 100644 index 0000000..d1f4d40 --- /dev/null +++ b/src/Resource/Keys.php @@ -0,0 +1,72 @@ +data = new stdClass(); + } + + /** + * Mount keys structure. + * + * @param \stdClass $response + * + * @return $this + */ + protected function populate(stdClass $response) + { + $keys = clone $this; + + $resp = $response->keys; + $keys->data->basicAuth = $this->getIfSet('basicAuth', $resp); + $keys->data->encryption = $this->getIfSet('encryption', $resp); + + return $keys; + } + + /** + * Get encryption. + * + * @return string + */ + public function getEncryption() + { + return $this->getIfSet('encryption'); + } + + /** + * Get Basic Auth. + * + * @return stdClass + */ + public function getBasicAuth() + { + return $this->getIfSet('basicAuth'); + } + + /** + * Get keys. + * + * @return stdClass + */ + public function get() + { + return $this->getByPath(sprintf('/%s/%s', MoipResource::VERSION, self::PATH)); + } +} diff --git a/src/Resource/MoipResource.php b/src/Resource/MoipResource.php index f6def8c..1c7712d 100644 --- a/src/Resource/MoipResource.php +++ b/src/Resource/MoipResource.php @@ -266,6 +266,10 @@ public function getByPath($path) { $response = $this->httpRequest($path, Requests::GET); + if (is_array($response)) { + $response = (object) $response; + } + return $this->populate($response); } diff --git a/src/Resource/NotificationPreferences.php b/src/Resource/NotificationPreferences.php index dc7e5cb..415b178 100644 --- a/src/Resource/NotificationPreferences.php +++ b/src/Resource/NotificationPreferences.php @@ -64,13 +64,33 @@ public function setTarget($target) /** * Returns target. * - * @return stdClass + * @return string */ public function getTarget() { return $this->data->target; } + /** + * Returns media. + * + * @return string + */ + public function getMedia() + { + return $this->data->media; + } + + /** + * Returns events. + * + * @return array + */ + public function getEvents() + { + return $this->data->events; + } + /** * Returns notification id. * @@ -113,6 +133,18 @@ public function get($notification_id) return $this->getByPath($this->generatePath('notifications', $notification_id)); } + /** + * Create a new Notifications List instance. + * + * @return \Moip\Resource\NotificationPreferencesList + */ + public function getList() + { + $notificationList = new NotificationPreferencesList($this->moip); + + return $notificationList->get(); + } + /** * Delete. * diff --git a/src/Resource/NotificationPreferencesList.php b/src/Resource/NotificationPreferencesList.php new file mode 100644 index 0000000..5b19b8e --- /dev/null +++ b/src/Resource/NotificationPreferencesList.php @@ -0,0 +1,49 @@ +data = new stdClass(); + } + + /** + * Get notifications. + * + * @return array + */ + public function getNotifications() + { + return $this->data->notifications; + } + + /** + * Get a notification list. + * + * @return stdClass + */ + public function get() + { + return $this->getByPath(sprintf('/%s/%s/%s', MoipResource::VERSION, self::PATH, 'notifications')); + } + + protected function populate(stdClass $response) + { + $notificationsList = clone $this; + + $notificationsList->data = new stdClass(); + + $notificationsList->data->notifications = $response; + + return $notificationsList; + } +} diff --git a/src/Resource/Orders.php b/src/Resource/Orders.php index 3a247af..6b58c2f 100644 --- a/src/Resource/Orders.php +++ b/src/Resource/Orders.php @@ -161,7 +161,7 @@ protected function populate(stdClass $response) $this->orders->data->events = $this->structure($response, Event::PATH, Event::class); $this->orders->data->items = $response->items; - $this->orders->data->receivers = $response->receivers; + $this->orders->data->receivers = $this->getIfSet('receivers', $response); $this->orders->data->createdAt = $response->createdAt; $this->orders->data->status = $response->status; $this->orders->data->_links = $response->_links; diff --git a/src/Resource/Payment.php b/src/Resource/Payment.php index f4f684e..38ef518 100644 --- a/src/Resource/Payment.php +++ b/src/Resource/Payment.php @@ -152,11 +152,11 @@ public function execute() */ public function get($id_moip) { - if ($this->order !== null) { - return $this->getByPath(sprintf('/%s/%s/%s', MoipResource::VERSION, self::PATH, $id_moip)); + if ($this->isMultipayment($id_moip)) { + return $this->getByPath(sprintf('/%s/%s/%s', MoipResource::VERSION, self::MULTI_PAYMENTS_PATH, $id_moip)); } - return $this->getByPath(sprintf('/%s/%s/%s', MoipResource::VERSION, self::MULTI_PAYMENTS_PATH, $id_moip)); + return $this->getByPath(sprintf('/%s/%s/%s', MoipResource::VERSION, self::PATH, $id_moip)); } /** @@ -189,6 +189,7 @@ protected function populate(stdClass $response) $payment->data->amount->currency = $this->getIfSet('currency', $response->amount); $payment->data->installmentCount = $this->getIfSet('installmentCount', $response); $payment->data->fundingInstrument = $this->getIfSet('fundingInstrument', $response); + $payment->data->payments = $this->getIfSet('payments', $response); $payment->data->escrows = $this->getIfSet('escrows', $response); $payment->data->fees = $this->getIfSet('fees', $response); $payment->data->refunds = $this->getIfSet('refunds', $response); @@ -340,6 +341,16 @@ public function getInstallmentCount() return $this->data->installmentCount; } + /** + * Get payments. + * + * @return array + */ + public function getPayments() + { + return $this->getIfSet('payments'); + } + /** * Set means of payment. * @@ -593,10 +604,10 @@ public function setEscrow($description) */ public function capture() { - if (is_null($this->order)) { - throw new \Exception('Sorry, multipayment capture is not available on this version'); - } $path = sprintf('/%s/%s/%s/%s', MoipResource::VERSION, self::PATH, $this->getId(), 'capture'); + if ($this->isMultipayment($this->getId())) { + $path = sprintf('/%s/%s/%s/%s', MoipResource::VERSION, self::MULTI_PAYMENTS_PATH, $this->getId(), 'capture'); + } $response = $this->httpRequest($path, Requests::POST, $this); @@ -604,24 +615,38 @@ public function capture() } /** - * Avoid a pre-authorized amount on a credit card payment. + * Cancel a pre-authorized amount on a credit card payment. * * @throws \Exception * * @return Payment */ - public function avoid() + public function cancel() { - if (is_null($this->order)) { - throw new \Exception('Sorry, multipayment capture is not available on this version'); - } $path = sprintf('/%s/%s/%s/%s', MoipResource::VERSION, self::PATH, $this->getId(), 'void'); + if ($this->isMultipayment($this->getId())) { + $path = sprintf('/%s/%s/%s/%s', MoipResource::VERSION, self::MULTI_PAYMENTS_PATH, $this->getId(), 'void'); + } $response = $this->httpRequest($path, Requests::POST, $this); return $this->populate($response); } + /** + * Cancel a pre-authorized amount on a credit card payment. + * + * @throws \Exception + * + * @return Payment + */ + public function avoid() + { + trigger_error('The function \'avoid\' is deprecated, use \'cancel\' instead', E_USER_NOTICE); + + return $this->cancel(); + } + /** * Authorize a payment (Available only in sandbox to credit card payment with status IN_ANALYSIS and billet payment with status WAITING). * @@ -641,4 +666,9 @@ public function authorize($amount = null) return false; } + + private function isMultipayment($paymentId) + { + return 0 === strpos($paymentId, 'MPY'); + } } diff --git a/tests/Resource/CustomerTest.php b/tests/Resource/CustomerTest.php index b060266..9ae8fc6 100644 --- a/tests/Resource/CustomerTest.php +++ b/tests/Resource/CustomerTest.php @@ -47,6 +47,8 @@ public function testCustomerCreate() $this->assertEquals($customer_original->getFullname(), $customer->getFullname()); $this->assertEquals($customer_original->getPhoneNumber(), $customer->getPhoneNumber()); $this->assertEquals($customer_original->getBirthDate(), $customer->getBirthDate()); + $this->assertEquals($customer_original->getTaxDocumentType(), $customer->getTaxDocumentType()); + $this->assertEquals($customer_original->getTaxDocumentNumber(), $customer->getTaxDocumentNumber()); } /** diff --git a/tests/Resource/KeyTest.php b/tests/Resource/KeyTest.php new file mode 100644 index 0000000..075fb81 --- /dev/null +++ b/tests/Resource/KeyTest.php @@ -0,0 +1,19 @@ +mockHttpSession($this->body_keys); + + $keys = $this->moip->keys()->get(); + + $this->assertNotNull($keys->getBasicAuth()->token); + $this->assertNotNull($keys->getBasicAuth()->secret); + $this->assertNotNull($keys->getEncryption()); + } +} diff --git a/tests/Resource/NotificationPreferencesListTest.php b/tests/Resource/NotificationPreferencesListTest.php new file mode 100644 index 0000000..b3e03bb --- /dev/null +++ b/tests/Resource/NotificationPreferencesListTest.php @@ -0,0 +1,17 @@ +mockHttpSession($this->body_notification_list); + + $notifications = $this->moip->notifications()->getList(); + + $this->assertNotNull($notifications->getNotifications()); + } +} diff --git a/tests/Resource/NotificationPreferencesTest.php b/tests/Resource/NotificationPreferencesTest.php index 01a8287..e08d9ba 100644 --- a/tests/Resource/NotificationPreferencesTest.php +++ b/tests/Resource/NotificationPreferencesTest.php @@ -22,4 +22,16 @@ public function testShouldCreateNotificationPreference() $notification = $this->createNotification(); $this->assertNotEmpty($notification->getId()); } + + public function testShouldGetNotificationPreference() + { + $this->mockHttpSession($this->body_notification_preference); + + $notification = $this->moip->notifications()->get('NPR-N6QZE3223P98'); + $this->assertEquals('NPR-N6QZE3223P98', $notification->getId()); + $this->assertEquals('WEBHOOK', $notification->getMedia()); + $this->assertEquals('994e3ffae9214fbc806d01de2dd5d341', $notification->getToken()); + $this->assertEquals('http://requestb.in/1dhjesw1', $notification->getTarget()); + $this->assertEquals(['ORDER.*', 'PAYMENT.AUTHORIZED', 'PAYMENT.CANCELLED'], $notification->getEvents()); + } } diff --git a/tests/Resource/PaymentTest.php b/tests/Resource/PaymentTest.php index ae5995c..f16025d 100644 --- a/tests/Resource/PaymentTest.php +++ b/tests/Resource/PaymentTest.php @@ -60,4 +60,126 @@ public function testShouldCreateEscrowPaymentWithCreditCard() ->execute(); $this->assertEquals('teste de descricao', $payment->getEscrow()->description); } + + /** + * MoipTest creating a credit card multipayment, passing all credit card data. + */ + public function testMultipaymentCreditCardPCI() + { + $this->mockHttpSession($this->body_multiorder); + $order = $this->createMultiorder()->create(); + $this->mockHttpSession($this->body_cc_multipay); + $cc = '4012001037141112'; + $payment = $order->multipayments()->setCreditCard(5, 2018, $cc, 123, $this->createCustomer())->execute(); + + $first6 = $payment->getPayments()[0]->fundingInstrument->creditCard->first6; + $last4 = $payment->getPayments()[0]->fundingInstrument->creditCard->last4; + $this->assertEquals($first6, substr($cc, 0, 6)); + $this->assertEquals($last4, substr($cc, -4)); + } + + /** + * MoipTest creating a billet multipayment. + */ + public function testMultipaymentBillet() + { + $this->mockHttpSession($this->body_multiorder); + $order = $this->createMultiorder()->create(); + $this->mockHttpSession($this->body_billet_multipay); + $payment = $order->multipayments()->setBoleto(new \DateTime('today +1day'), 'http://dev.moip.com.br/images/logo-header-moip.png')->execute(); + $this->assertNotEmpty($payment->getFundingInstrument()->boleto); + } + + public function testCapturePreAuthorizedPayment() + { + $this->mockHttpSession($this->body_order); + $order = $this->createOrder()->create(); + $this->mockHttpSession($this->body_cc_delay_capture); + $payment = $order->payments() + ->setCreditCard(5, 2018, '5555666677778884', 123, $this->createCustomer(), false) + ->setDelayCapture(true) + ->execute(); + + $this->mockHttpSession($this->body_capture_pay); + $captured_payment = $payment->capture(); + + $this->assertEquals('AUTHORIZED', $captured_payment->getStatus()); + } + + public function testCapturePreAuthorizedMultiPayment() + { + $this->mockHttpSession($this->body_multiorder); + $order = $this->createMultiorder()->create(); + $this->mockHttpSession($this->body_cc_multipay); + $payment = $order->multipayments() + ->setCreditCard(5, 2018, '4012001037141112', 123, $this->createCustomer()) + ->setDelayCapture(true) + ->execute(); + + $this->mockHttpSession($this->body_capture_multipay); + $captured_payment = $payment->capture(); + + $this->assertEquals('AUTHORIZED', $captured_payment->getStatus()); + } + + public function testCancelPreAuthorizedMultiPayment() + { + $this->mockHttpSession($this->body_multiorder); + $order = $this->createMultiorder()->create(); + $this->mockHttpSession($this->body_cc_multipay); + $payment = $order->multipayments() + ->setCreditCard(5, 2018, '4012001037141112', 123, $this->createCustomer()) + ->setDelayCapture(true) + ->execute(); + + $this->mockHttpSession($this->body_cancel_multipay); + $cancelled_payment = $payment->cancel(); + + $this->assertEquals('CANCELLED', $cancelled_payment->getStatus()); + } + + public function testCancelPreAuthorizedPayment() + { + $this->mockHttpSession($this->body_order); + $order = $this->createOrder()->create(); + $this->mockHttpSession($this->body_cc_delay_capture); + $payment = $order->payments() + ->setCreditCard(5, 2018, '5555666677778884', 123, $this->createCustomer(), false) + ->setDelayCapture(true) + ->execute(); + + $this->mockHttpSession($this->body_cancel_pay); + $cancelled_payment = $payment->cancel(); + + $this->assertEquals('CANCELLED', $cancelled_payment->getStatus()); + } + + public function testGetPayment() + { + $this->mockHttpSession($this->body_order); + $order = $this->createOrder()->create(); + $this->mockHttpSession($this->body_cc_pay_pci); + $payment = $order->payments()->setCreditCard(5, 2018, '5555666677778884', 123, $this->createCustomer())->execute(); + + $this->mockHttpSession($this->body_get_pay); + $payment_get = $this->moip->payments()->get($payment->getId()); + + $this->assertEquals($payment_get->getAmount()->total, 102470); + $this->assertEquals($payment_get->getFundingInstrument()->method, 'CREDIT_CARD'); + $this->assertEquals($payment_get->getInstallmentCount(), 1); + } + + public function testGetMultiPayment() + { + $this->mockHttpSession($this->body_multiorder); + $order = $this->createMultiorder()->create(); + $this->mockHttpSession($this->body_cc_multipay); + $payment = $order->multipayments()->setCreditCard(5, 2018, '4012001037141112', 123, $this->createCustomer())->execute(); + + $this->mockHttpSession($this->body_get_multipay); + $payment_get = $this->moip->payments()->get($payment->getId()); + + $this->assertEquals($payment_get->getAmount()->total, 77000); + $this->assertNotNull($payment_get->getPayments()); + } } diff --git a/tests/TestCase.php b/tests/TestCase.php index 718e6db..b6074df 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -100,6 +100,11 @@ abstract class TestCase extends PHPUnit_Framework_TestCase */ protected $body_order_list; + /** + * @var string response from moip API. + */ + protected $body_notification_list; + /** * @var string holds the last generated customer ownId. In mock mode it'll be always the default, but it changes on sandbox mode. */ @@ -131,6 +136,10 @@ public function __construct() $this->body_billet_pay = $this->readJsonFile('jsons/payment/create_billet'); + $this->body_billet_multipay = $this->readJsonFile('jsons/multipayment/create_billet'); + + $this->body_cc_multipay = $this->readJsonFile('jsons/multipayment/create_cc'); + $this->body_refund_full_bankaccount = $this->readJsonFile('jsons/refund/full_bankaccount'); $this->body_refund_partial_bankaccount = $this->readJsonFile('jsons/refund/partial_bankaccount'); @@ -148,6 +157,26 @@ public function __construct() $this->body_list_webhook_pagination = $this->readJsonFile('jsons/webhooks/get_pagination'); $this->body_list_webhook_all_filters = $this->readJsonFile('jsons/webhooks/get_all_filters'); + + $this->body_notification_list = $this->readJsonFile('jsons/notification/list'); + + $this->body_multiorder = $this->readJsonFile('jsons/multiorder/create'); + + $this->body_cc_delay_capture = $this->readJsonFile('jsons/payment/create_cc_delay_capture'); + + $this->body_capture_pay = $this->readJsonFile('jsons/payment/capture'); + + $this->body_capture_multipay = $this->readJsonFile('jsons/multipayment/capture'); + + $this->body_cancel_pay = $this->readJsonFile('jsons/payment/cancel_pre_authorized'); + + $this->body_cancel_multipay = $this->readJsonFile('jsons/multipayment/cancel_pre_authorized'); + + $this->body_get_pay = $this->readJsonFile('jsons/payment/get'); + + $this->body_get_multipay = $this->readJsonFile('jsons/multipayment/get'); + + $this->body_keys = $this->readJsonFile('jsons/keys/get'); } /** @@ -176,7 +205,7 @@ public function setUp() */ public function readJsonFile($filename) { - return file_get_contents("$filename.json", FILE_USE_INCLUDE_PATH); + return file_get_contents($filename.'.json', FILE_USE_INCLUDE_PATH); } /** @@ -272,6 +301,48 @@ public function createOrder() return $order; } + /** + * Creates a multiorder. + * + * @return Multiorders + */ + public function createMultiorder() + { + if ($this->sandbox_mock == self::SANDBOX) { + $this->last_ord_id = uniqid('MOR-'); + } else { + $this->last_ord_id = 'meu_id_pedido'; + } + + $order = $this->moip->orders()->setOwnId(uniqid()) + ->addItem('bicicleta 1', 1, 'sku1', 10000) + ->addItem('bicicleta 2', 1, 'sku2', 11000) + ->addItem('bicicleta 3', 1, 'sku3', 12000) + ->addItem('bicicleta 4', 1, 'sku4', 13000) + ->setShippingAmount(3000) + ->setAddition(1000) + ->setDiscount(5000) + ->setCustomer($this->createCustomer()) + ->addReceiver('MPA-VB5OGTVPCI52', 'PRIMARY', null); + + $order2 = $this->moip->orders()->setOwnId(uniqid()) + ->addItem('bicicleta 1', 1, 'sku1', 10000) + ->addItem('bicicleta 2', 1, 'sku2', 11000) + ->addItem('bicicleta 3', 1, 'sku3', 12000) + ->setShippingAmount(3000) + ->setAddition(1000) + ->setDiscount(5000) + ->setCustomer($this->createCustomer()) + ->addReceiver('MPA-IFYRB1HBL73Z', 'PRIMARY', null); + + $multiorder = $this->moip->multiorders() + ->setOwnId(uniqid()) + ->addOrder($order) + ->addOrder($order2); + + return $multiorder; + } + /** * Tears down the fixture, for example, close a network connection. * This method is called after a test is executed. diff --git a/tests/jsons/keys/get.json b/tests/jsons/keys/get.json new file mode 100644 index 0000000..b14270d --- /dev/null +++ b/tests/jsons/keys/get.json @@ -0,0 +1 @@ +{"keys":{"basicAuth":{"secret":"ABABABABABABABABABABABABABABABABABABABAB","token":"01010101010101010101010101010101"},"encryption":"-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoBttaXwRoI1Fbcond5mS\n7QOb7X2lykY5hvvDeLJelvFhpeLnS4YDwkrnziM3W00UNH1yiSDU+3JhfHu5G387\nO6uN9rIHXvL+TRzkVfa5iIjG+ap2N0\/toPzy5ekpgxBicjtyPHEgoU6dRzdszEF4\nItimGk5ACx\/lMOvctncS5j3uWBaTPwyn0hshmtDwClf6dEZgQvm\/dNaIkxHKV+9j\nMn3ZfK\/liT8A3xwaVvRzzuxf09xJTXrAd9v5VQbeWGxwFcW05oJulSFjmJA9Hcmb\nDYHJT+sG2mlZDEruCGAzCVubJwGY1aRlcs9AQc1jIm\/l8JwH7le2kpk3QoX+gz0w\nWwIDAQAB\n-----END PUBLIC KEY-----\n"}} \ No newline at end of file diff --git a/tests/jsons/multiorder/create.json b/tests/jsons/multiorder/create.json new file mode 100644 index 0000000..92d9af2 --- /dev/null +++ b/tests/jsons/multiorder/create.json @@ -0,0 +1 @@ +{"id":"MOR-J1G1C9W4P1SD","ownId":"meu_multiorder_id","status":"CREATED","createdAt":"2017-09-29T10:26:21.266-03","updatedAt":"","amount":{"total":8000,"gross":8000,"currency":"BRL"},"orders":[{"id":"ORD-740WQDF7K50X","ownId":"pedido_1_id","status":"CREATED","platform":"V2","createdAt":"2017-09-29T10:26:21.266-03","updatedAt":"2017-09-29T10:26:21.266-03","amount":{"paid":0,"total":4000,"fees":0,"refunds":0,"liquid":0,"otherReceivers":3500,"currency":"BRL","subtotals":{"shipping":2000,"addition":0,"discount":0,"items":2000}},"items":[{"product":"Camisa Verde e Amarelo - Brasil","price":2000,"detail":"Seleção Brasileira","quantity":1}],"customer":{"id":"CUS-02ZE76RXIG24","ownId":"customer[1234]","fullname":"Joao Sousa","createdAt":"2017-06-21T11:02:24.000-03","birthDate":"1988-12-30","email":"joao.sousa@email.com","fundingInstrument":{"creditCard":{"id":"CRC-UARTCOXFHAQI","brand":"VISA","first6":"401200","last4":"1112","store":true},"method":"CREDIT_CARD"},"phone":{"countryCode":"55","areaCode":"11","number":"66778899"},"taxDocument":{"type":"CPF","number":"22222222222"},"shippingAddress":{"zipCode":"01234000","street":"Avenida Faria Lima","streetNumber":"2927","complement":"8","city":"Sao Paulo","district":"Itaim","state":"SP","country":"BRA"},"moipAccount":{"id":"MPA-PQ0H8UZYNNWY"},"_links":{"self":{"href":"https://sandbox.moip.com.br/v2/customers/CUS-02ZE76RXIG24"},"hostedAccount":{"redirectHref":"https://hostedaccount-sandbox.moip.com.br?token=22e9ac2f-3cbd-4fa1-b143-8c0277565b39&id=CUS-02ZE76RXIG24&mpa=MPA-8D5DBB4EF8B8"}},"fundingInstruments":[{"creditCard":{"id":"CRC-UARTCOXFHAQI","brand":"VISA","first6":"401200","last4":"1112","store":true},"method":"CREDIT_CARD"}]},"payments":[],"escrows":[],"refunds":[],"entries":[],"events":[{"type":"ORDER.CREATED","createdAt":"2017-09-29T10:26:21.266-03","description":""}],"receivers":[{"moipAccount":{"id":"MPA-E3C8493A06AE","login":"marcos150895@gmail.com","fullname":"Marcos Santana Santos"},"type":"PRIMARY","amount":{"total":3500,"refunds":0}},{"moipAccount":{"id":"MPA-8D5DBB4EF8B8","login":"caio.gaspar@moip.com.br","fullname":"Caio Gaspar"},"type":"SECONDARY","amount":{"total":500,"refunds":0}}],"shippingAddress":{"zipCode":"01234000","street":"Avenida Faria Lima","streetNumber":"2927","complement":"8","city":"Sao Paulo","district":"Itaim","state":"SP","country":"BRA"},"_links":{"self":{"href":"https://sandbox.moip.com.br/v2/orders/ORD-740WQDF7K50X"}}},{"id":"ORD-JR07AW1L8BZS","ownId":"pedido_2_id","status":"CREATED","platform":"V2","createdAt":"2017-09-29T10:26:21.279-03","updatedAt":"2017-09-29T10:26:21.279-03","amount":{"paid":0,"total":4000,"fees":0,"refunds":0,"liquid":0,"otherReceivers":0,"currency":"BRL","subtotals":{"shipping":3000,"addition":0,"discount":0,"items":1000}},"items":[{"product":"Camisa Preta - Alemanha","price":1000,"detail":"Camiseta da Copa 2014","quantity":1}],"customer":{"id":"CUS-02ZE76RXIG24","ownId":"customer[1234]","fullname":"Joao Sousa","createdAt":"2017-06-21T11:02:24.000-03","birthDate":"1988-12-30","email":"joao.sousa@email.com","fundingInstrument":{"creditCard":{"id":"CRC-UARTCOXFHAQI","brand":"VISA","first6":"401200","last4":"1112","store":true},"method":"CREDIT_CARD"},"phone":{"countryCode":"55","areaCode":"11","number":"66778899"},"taxDocument":{"type":"CPF","number":"22222222222"},"shippingAddress":{"zipCode":"01234000","street":"Avenida Faria Lima","streetNumber":"2927","complement":"8","city":"Sao Paulo","district":"Itaim","state":"SP","country":"BRA"},"moipAccount":{"id":"MPA-PQ0H8UZYNNWY"},"_links":{"self":{"href":"https://sandbox.moip.com.br/v2/customers/CUS-02ZE76RXIG24"},"hostedAccount":{"redirectHref":"https://hostedaccount-sandbox.moip.com.br?token=22e9ac2f-3cbd-4fa1-b143-8c0277565b39&id=CUS-02ZE76RXIG24&mpa=MPA-8D5DBB4EF8B8"}},"fundingInstruments":[{"creditCard":{"id":"CRC-UARTCOXFHAQI","brand":"VISA","first6":"401200","last4":"1112","store":true},"method":"CREDIT_CARD"}]},"payments":[],"escrows":[],"refunds":[],"entries":[],"events":[{"type":"ORDER.CREATED","createdAt":"2017-09-29T10:26:21.279-03","description":""}],"receivers":[{"moipAccount":{"id":"MPA-8D5DBB4EF8B8","login":"caio.gaspar@moip.com.br","fullname":"Caio Gaspar"},"type":"PRIMARY","amount":{"total":4000,"fees":0,"refunds":0},"feePayor":true}],"shippingAddress":{"zipCode":"01234000","street":"Avenida Faria Lima","streetNumber":"2927","complement":"8","city":"Sao Paulo","district":"Itaim","state":"SP","country":"BRA"},"_links":{"self":{"href":"https://sandbox.moip.com.br/v2/orders/ORD-JR07AW1L8BZS"}}}],"_links":{"self":{"href":"https://sandbox.moip.com.br/v2/orders/MOR-J1G1C9W4P1SD"},"checkout":{"payCreditCard":{"redirectHref":"https://checkout-sandbox.moip.com.br/creditcard/MOR-J1G1C9W4P1SD"},"payBoleto":{"redirectHref":"https://checkout-sandbox.moip.com.br/boleto/MOR-J1G1C9W4P1SD"},"payOnlineBankDebitItau":{"redirectHref":"https://checkout-sandbox.moip.com.br/debit/itau/MOR-J1G1C9W4P1SD"}}}} \ No newline at end of file diff --git a/tests/jsons/multipayment/cancel_pre_authorized.json b/tests/jsons/multipayment/cancel_pre_authorized.json new file mode 100644 index 0000000..50506c8 --- /dev/null +++ b/tests/jsons/multipayment/cancel_pre_authorized.json @@ -0,0 +1 @@ +{"id":"MPY-PFE3PI6WCOSJ","status":"CANCELLED","amount":{"total":8000,"gross":8000,"currency":"BRL"},"installmentCount":1,"payments":[{"id":"PAY-247DYOI8PS0J","status":"CANCELLED","delayCapture":true,"cancellationDetails":{"code":"7","description":"Política do Moip","cancelledBy":"MOIP"},"amount":{"total":4000,"gross":4000,"fees":289,"refunds":0,"liquid":3711,"currency":"BRL"},"installmentCount":1,"fundingInstrument":{"creditCard":{"id":"CRC-UARTCOXFHAQI","brand":"VISA","first6":"401200","last4":"1112","store":true,"holder":{"birthdate":"1988-12-30","birthDate":"1988-12-30","taxDocument":{"type":"CPF","number":"22222222222"},"fullname":"Jose Portador da Silva"}},"method":"CREDIT_CARD"},"fees":[{"type":"TRANSACTION","amount":289}],"escrows":[{"id":"ECW-1HE2AH5DLGUI","status":"HOLD_PENDING","description":"Teste","amount":4000,"createdAt":"2017-10-02T09:59:17.000-03","updatedAt":"2017-10-02T09:59:17.000-03","_links":{"self":{"href":"https://sandbox.moip.com.br/v2/escrows/ECW-1HE2AH5DLGUI"},"order":{"href":"https://sandbox.moip.com.br/v2/orders/ORD-X0D0J868YSNU","title":"ORD-X0D0J868YSNU"},"payment":{"href":"https://sandbox.moip.com.br/v2/payments/PAY-247DYOI8PS0J","title":"PAY-247DYOI8PS0J"}}}],"events":[{"type":"PAYMENT.CANCELLED","createdAt":"2017-10-02T10:08:03.603-03"},{"type":"PAYMENT.PRE_AUTHORIZED","createdAt":"2017-10-02T09:59:18.000-03"},{"type":"PAYMENT.CREATED","createdAt":"2017-10-02T09:59:17.000-03"},{"type":"PAYMENT.IN_ANALYSIS","createdAt":"2017-10-02T09:59:17.000-03"},{"type":"PAYMENT.WAITING","createdAt":"2017-10-02T09:59:17.000-03"}],"receivers":[{"moipAccount":{"id":"MPA-E3C8493A06AE","login":"marcos150895@gmail.com","fullname":"Marcos Santana Santos"},"type":"PRIMARY","amount":{"total":3500,"refunds":0}},{"moipAccount":{"id":"MPA-8D5DBB4EF8B8","login":"caio.gaspar@moip.com.br","fullname":"Caio Gaspar"},"type":"SECONDARY","amount":{"total":500,"fees":0,"refunds":0},"feePayor":false}],"_links":{"self":{"href":"https://sandbox.moip.com.br/v2/payments/PAY-247DYOI8PS0J"},"order":{"href":"https://sandbox.moip.com.br/v2/orders/ORD-X0D0J868YSNU","title":"ORD-X0D0J868YSNU"}},"createdAt":"2017-10-02T09:59:17.000-03","updatedAt":"2017-10-02T10:08:03.602-03"},{"id":"PAY-AQEO6Q1N1941","status":"CANCELLED","delayCapture":true,"cancellationDetails":{"code":"7","description":"Política do Moip","cancelledBy":"MOIP"},"amount":{"total":4000,"gross":4000,"fees":289,"refunds":0,"liquid":3711,"currency":"BRL"},"installmentCount":1,"fundingInstrument":{"creditCard":{"id":"CRC-UARTCOXFHAQI","brand":"VISA","first6":"401200","last4":"1112","store":true,"holder":{"birthdate":"1988-12-30","birthDate":"1988-12-30","taxDocument":{"type":"CPF","number":"22222222222"},"fullname":"Jose Portador da Silva"}},"method":"CREDIT_CARD"},"fees":[{"type":"TRANSACTION","amount":289}],"escrows":[{"id":"ECW-5RAZGXIV4RSI","status":"HOLD_PENDING","description":"Teste","amount":4000,"createdAt":"2017-10-02T09:59:17.000-03","updatedAt":"2017-10-02T09:59:17.000-03","_links":{"self":{"href":"https://sandbox.moip.com.br/v2/escrows/ECW-5RAZGXIV4RSI"},"order":{"href":"https://sandbox.moip.com.br/v2/orders/ORD-7ZCLI7U7K17B","title":"ORD-7ZCLI7U7K17B"},"payment":{"href":"https://sandbox.moip.com.br/v2/payments/PAY-AQEO6Q1N1941","title":"PAY-AQEO6Q1N1941"}}}],"events":[{"type":"PAYMENT.CANCELLED","createdAt":"2017-10-02T10:08:03.604-03"},{"type":"PAYMENT.PRE_AUTHORIZED","createdAt":"2017-10-02T09:59:18.000-03"},{"type":"PAYMENT.CREATED","createdAt":"2017-10-02T09:59:17.000-03"},{"type":"PAYMENT.IN_ANALYSIS","createdAt":"2017-10-02T09:59:17.000-03"},{"type":"PAYMENT.WAITING","createdAt":"2017-10-02T09:59:17.000-03"}],"receivers":[{"moipAccount":{"id":"MPA-8D5DBB4EF8B8","login":"caio.gaspar@moip.com.br","fullname":"Caio Gaspar"},"type":"PRIMARY","amount":{"total":4000,"refunds":0}}],"_links":{"self":{"href":"https://sandbox.moip.com.br/v2/payments/PAY-AQEO6Q1N1941"},"order":{"href":"https://sandbox.moip.com.br/v2/orders/ORD-7ZCLI7U7K17B","title":"ORD-7ZCLI7U7K17B"}},"createdAt":"2017-10-02T09:59:17.000-03","updatedAt":"2017-10-02T10:08:03.603-03"}],"_links":{"self":{"href":"https://sandbox.moip.com.br/v2/multipayments/MPY-PFE3PI6WCOSJ"},"multiorder":{"href":"https://sandbox.moip.com.br/v2/multiorders/MOR-T6AK5UX6EBXX"}}} \ No newline at end of file diff --git a/tests/jsons/multipayment/capture.json b/tests/jsons/multipayment/capture.json new file mode 100644 index 0000000..90fc51c --- /dev/null +++ b/tests/jsons/multipayment/capture.json @@ -0,0 +1 @@ +{"id":"MPY-NKZBOXU4B44U","status":"AUTHORIZED","amount":{"total":8000,"gross":8000,"currency":"BRL"},"installmentCount":1,"payments":[{"id":"PAY-LBUR73TATCIC","status":"AUTHORIZED","delayCapture":true,"amount":{"total":4000,"gross":4000,"fees":289,"refunds":0,"liquid":3711,"currency":"BRL"},"installmentCount":1,"fundingInstrument":{"creditCard":{"id":"CRC-UARTCOXFHAQI","brand":"VISA","first6":"401200","last4":"1112","store":true,"holder":{"birthdate":"1988-12-30","birthDate":"1988-12-30","taxDocument":{"type":"CPF","number":"22222222222"},"fullname":"Jose Portador da Silva"}},"method":"CREDIT_CARD"},"fees":[{"type":"TRANSACTION","amount":289}],"escrows":[{"id":"ECW-ITVY5KCWP3BF","status":"HOLD_PENDING","description":"Teste","amount":4000,"createdAt":"2017-10-02T10:12:24.000-03","updatedAt":"2017-10-02T10:12:24.000-03","_links":{"self":{"href":"https://sandbox.moip.com.br/v2/escrows/ECW-ITVY5KCWP3BF"},"order":{"href":"https://sandbox.moip.com.br/v2/orders/ORD-VQ9OAU9CVLRT","title":"ORD-VQ9OAU9CVLRT"},"payment":{"href":"https://sandbox.moip.com.br/v2/payments/PAY-LBUR73TATCIC","title":"PAY-LBUR73TATCIC"}}}],"events":[{"type":"PAYMENT.AUTHORIZED","createdAt":"2017-10-02T10:13:21.427-03"},{"type":"PAYMENT.IN_ANALYSIS","createdAt":"2017-10-02T10:12:25.000-03"},{"type":"PAYMENT.PRE_AUTHORIZED","createdAt":"2017-10-02T10:12:25.000-03"},{"type":"PAYMENT.CREATED","createdAt":"2017-10-02T10:12:24.000-03"},{"type":"PAYMENT.WAITING","createdAt":"2017-10-02T10:12:24.000-03"}],"receivers":[{"moipAccount":{"id":"MPA-E3D8493A06AE","login":"test@moip.com.br","fullname":"Moip Test"},"type":"PRIMARY","amount":{"total":3500,"refunds":0}},{"moipAccount":{"id":"MPA-8D5DCB4EF8B8","login":"test2@moip.com.br","fullname":"Moip Test2"},"type":"SECONDARY","amount":{"total":500,"fees":0,"refunds":0},"feePayor":false}],"_links":{"self":{"href":"https://sandbox.moip.com.br/v2/payments/PAY-LBUR73TATCIC"},"order":{"href":"https://sandbox.moip.com.br/v2/orders/ORD-VQ9OAU9CVLRT","title":"ORD-VQ9OAU9CVLRT"}},"createdAt":"2017-10-02T10:12:24.000-03","updatedAt":"2017-10-02T10:13:21.426-03"},{"id":"PAY-6ICL332BUEXT","status":"AUTHORIZED","delayCapture":true,"amount":{"total":4000,"gross":4000,"fees":289,"refunds":0,"liquid":3711,"currency":"BRL"},"installmentCount":1,"fundingInstrument":{"creditCard":{"id":"CRC-UARTCOXFHAQI","brand":"VISA","first6":"401200","last4":"1112","store":true,"holder":{"birthdate":"1988-12-30","birthDate":"1988-12-30","taxDocument":{"type":"CPF","number":"22222222222"},"fullname":"Jose Portador da Silva"}},"method":"CREDIT_CARD"},"fees":[{"type":"TRANSACTION","amount":289}],"escrows":[{"id":"ECW-OX2Z8PFN6EG5","status":"HOLD_PENDING","description":"Teste","amount":4000,"createdAt":"2017-10-02T10:12:24.000-03","updatedAt":"2017-10-02T10:12:24.000-03","_links":{"self":{"href":"https://sandbox.moip.com.br/v2/escrows/ECW-OX2Z8PFN6EG5"},"order":{"href":"https://sandbox.moip.com.br/v2/orders/ORD-CMBFPT9AIVPC","title":"ORD-CMBFPT9AIVPC"},"payment":{"href":"https://sandbox.moip.com.br/v2/payments/PAY-6ICL332BUEXT","title":"PAY-6ICL332BUEXT"}}}],"events":[{"type":"PAYMENT.AUTHORIZED","createdAt":"2017-10-02T10:13:21.428-03"},{"type":"PAYMENT.IN_ANALYSIS","createdAt":"2017-10-02T10:12:25.000-03"},{"type":"PAYMENT.PRE_AUTHORIZED","createdAt":"2017-10-02T10:12:25.000-03"},{"type":"PAYMENT.CREATED","createdAt":"2017-10-02T10:12:24.000-03"},{"type":"PAYMENT.WAITING","createdAt":"2017-10-02T10:12:24.000-03"}],"receivers":[{"moipAccount":{"id":"MPA-8D5DBB4EF8B8","login":"caio.gaspar@moip.com.br","fullname":"Caio Gaspar"},"type":"PRIMARY","amount":{"total":4000,"refunds":0}}],"_links":{"self":{"href":"https://sandbox.moip.com.br/v2/payments/PAY-6ICL332BUEXT"},"order":{"href":"https://sandbox.moip.com.br/v2/orders/ORD-CMBFPT9AIVPC","title":"ORD-CMBFPT9AIVPC"}},"createdAt":"2017-10-02T10:12:24.000-03","updatedAt":"2017-10-02T10:13:21.427-03"}],"_links":{"self":{"href":"https://sandbox.moip.com.br/v2/multipayments/MPY-NKZBOXU4B44U"},"multiorder":{"href":"https://sandbox.moip.com.br/v2/multiorders/MOR-GZ5OKB7R36GO"}}} \ No newline at end of file diff --git a/tests/jsons/multipayment/create_billet.json b/tests/jsons/multipayment/create_billet.json new file mode 100644 index 0000000..ba085d1 --- /dev/null +++ b/tests/jsons/multipayment/create_billet.json @@ -0,0 +1 @@ +{"id":"MPY-V5CEK24WDD27","status":"WAITING","amount":{"total":8000,"gross":8000,"currency":"BRL"},"installmentCount":1,"fundingInstrument":{"boleto":{"expirationDate":"2017-09-30","lineCode":"23793.3912660000.13014077001.747904672980000008000","logoUri":"http://","instructionLines":{"first":"Primeiralinhaseinstrução","second":"Segundalinhaseinstrução","third":"Terceiralinhaseinstrução"}},"method":"BOLETO"},"payments":[{"id":"PAY-ATNIHH3XI4KJ","status":"WAITING","delayCapture":false,"amount":{"total":4000,"gross":4000,"fees":0,"refunds":0,"liquid":4000,"currency":"BRL"},"installmentCount":1,"fundingInstrument":{"boleto":{"expirationDate":"2017-09-30","lineCode":"23793.3912660000.13014077001.747904672980000008000","logoUri":"http://","instructionLines":{"first":"Primeiralinhaseinstrução","second":"Segundalinhaseinstrução","third":"Terceiralinhaseinstrução"}},"method":"BOLETO"},"fees":[{"type":"TRANSACTION","amount":0}],"events":[{"type":"PAYMENT.CREATED","createdAt":"2017-09-29T10:33:46.000-03"},{"type":"PAYMENT.WAITING","createdAt":"2017-09-29T10:33:46.000-03"}],"receivers":[{"moipAccount":{"id":"MPA-E3C8493A06AE","login":"marcos150895@gmail.com","fullname":"MarcosSantanaSantos"},"type":"PRIMARY","amount":{"total":3500,"refunds":0}},{"moipAccount":{"id":"MPA-8D5DBB4EF8B8","login":"caio.gaspar@moip.com.br","fullname":"CaioGaspar"},"type":"SECONDARY","amount":{"total":500,"fees":0,"refunds":0},"feePayor":false}],"_links":{"self":{"href":"https://sandbox.moip.com.br/v2/payments/PAY-ATNIHH3XI4KJ"},"order":{"href":"https://sandbox.moip.com.br/v2/orders/ORD-U15QTT5DPYSZ","title":"ORD-U15QTT5DPYSZ"}},"createdAt":"2017-09-29T10:33:46.000-03","updatedAt":"2017-09-29T10:33:46.000-03"},{"id":"PAY-4YIMXKU1SNHW","status":"WAITING","delayCapture":false,"amount":{"total":4000,"gross":4000,"fees":0,"refunds":0,"liquid":4000,"currency":"BRL"},"installmentCount":1,"fundingInstrument":{"boleto":{"expirationDate":"2017-09-30","lineCode":"23793.3912660000.13014077001.747904672980000008000","logoUri":"http://","instructionLines":{"first":"Primeiralinhaseinstrução","second":"Segundalinhaseinstrução","third":"Terceiralinhaseinstrução"}},"method":"BOLETO"},"fees":[{"type":"TRANSACTION","amount":0}],"events":[{"type":"PAYMENT.CREATED","createdAt":"2017-09-29T10:33:46.000-03"},{"type":"PAYMENT.WAITING","createdAt":"2017-09-29T10:33:46.000-03"}],"receivers":[{"moipAccount":{"id":"MPA-8D5DCB4EF8B8","login":"test@moip.com.br","fullname":"MoipTest"},"type":"PRIMARY","amount":{"total":4000,"refunds":0}}],"_links":{"self":{"href":"https://sandbox.moip.com.br/v2/payments/PAY-4YIMXKU1SNHW"},"order":{"href":"https://sandbox.moip.com.br/v2/orders/ORD-Q3R12CHPQPGO","title":"ORD-Q3R12CHPQPGO"}},"createdAt":"2017-09-29T10:33:46.000-03","updatedAt":"2017-09-29T10:33:46.000-03"}],"_links":{"self":{"href":"https://sandbox.moip.com.br/v2/multipayments/MPY-V5CEK24WDD27"},"multiorder":{"href":"https://sandbox.moip.com.br/v2/multiorders/MOR-R0T7IYR36W3T"},"checkout":{"payBoleto":{"printHref":"https://checkout-sandbox.moip.com.br/boleto/MPY-V5CEK24WDD27/print","redirectHref":"https://checkout-sandbox.moip.com.br/boleto/MPY-V5CEK24WDD27"}}}} \ No newline at end of file diff --git a/tests/jsons/multipayment/create_cc.json b/tests/jsons/multipayment/create_cc.json new file mode 100644 index 0000000..174c3bd --- /dev/null +++ b/tests/jsons/multipayment/create_cc.json @@ -0,0 +1 @@ +{"id":"MPY-1PUFJXHYNREW","status":"WAITING","amount":{"total":8000,"gross":8000,"currency":"BRL"},"installmentCount":1,"payments":[{"id":"PAY-A26ANBMOC22W","status":"WAITING","delayCapture":true,"amount":{"total":4000,"gross":4000,"fees":0,"refunds":0,"liquid":4000,"currency":"BRL"},"installmentCount":1,"fundingInstrument":{"creditCard":{"id":"CRC-UARTCOXFHAQI","brand":"VISA","first6":"401200","last4":"1112","store":true,"holder":{"birthdate":"1988-12-30","birthDate":"1988-12-30","taxDocument":{"type":"CPF","number":"22222222222"},"fullname":"Jose Portador da Silva"}},"method":"CREDIT_CARD"},"fees":[{"type":"TRANSACTION","amount":0}],"escrows":[{"id":"ECW-6AM3SM03KEEK","status":"HOLD_PENDING","description":"Teste","amount":4000,"createdAt":"2017-10-02T09:13:36.000-03","updatedAt":"2017-10-02T09:13:36.000-03","_links":{"self":{"href":"https://sandbox.moip.com.br/v2/escrows/ECW-6AM3SM03KEEK"},"order":{"href":"https://sandbox.moip.com.br/v2/orders/ORD-FTD2TF7ZMGH6","title":"ORD-FTD2TF7ZMGH6"},"payment":{"href":"https://sandbox.moip.com.br/v2/payments/PAY-A26ANBMOC22W","title":"PAY-A26ANBMOC22W"}}}],"events":[{"type":"PAYMENT.CREATED","createdAt":"2017-10-02T09:13:36.000-03"},{"type":"PAYMENT.WAITING","createdAt":"2017-10-02T09:13:36.000-03"}],"receivers":[{"moipAccount":{"id":"MPA-E3C8494A06AE","login":"test2@moip.com.br","fullname":"Moip Test2"},"type":"PRIMARY","amount":{"total":3500,"refunds":0}},{"moipAccount": {"id": "MPA-8D5DCB4EF8B8","login": "test@moip.com.br","fullname": "Moip Test"},"type":"SECONDARY","amount":{"total":500,"fees":0,"refunds":0},"feePayor":false}],"_links":{"self":{"href":"https://sandbox.moip.com.br/v2/payments/PAY-A26ANBMOC22W"},"order":{"href":"https://sandbox.moip.com.br/v2/orders/ORD-FTD2TF7ZMGH6","title":"ORD-FTD2TF7ZMGH6"}},"createdAt":"2017-10-02T09:13:36.000-03","updatedAt":"2017-10-02T09:13:36.000-03"},{"id":"PAY-2IGF8GV63T34","status":"WAITING","delayCapture":true,"amount":{"total":4000,"gross":4000,"fees":0,"refunds":0,"liquid":4000,"currency":"BRL"},"installmentCount":1,"fundingInstrument":{"creditCard":{"id":"CRC-UARTCOXFHAQI","brand":"VISA","first6":"401200","last4":"1112","store":true,"holder":{"birthdate":"1988-12-30","birthDate":"1988-12-30","taxDocument":{"type":"CPF","number":"22222222222"},"fullname":"Jose Portador da Silva"}},"method":"CREDIT_CARD"},"fees":[{"type":"TRANSACTION","amount":0}],"escrows":[{"id":"ECW-98BNMEVEGPUH","status":"HOLD_PENDING","description":"Teste","amount":4000,"createdAt":"2017-10-02T09:13:36.000-03","updatedAt":"2017-10-02T09:13:36.000-03","_links":{"self":{"href":"https://sandbox.moip.com.br/v2/escrows/ECW-98BNMEVEGPUH"},"order":{"href":"https://sandbox.moip.com.br/v2/orders/ORD-2Q0NPHVH0WD0","title":"ORD-2Q0NPHVH0WD0"},"payment":{"href":"https://sandbox.moip.com.br/v2/payments/PAY-2IGF8GV63T34","title":"PAY-2IGF8GV63T34"}}}],"events":[{"type":"PAYMENT.CREATED","createdAt":"2017-10-02T09:13:36.000-03"},{"type":"PAYMENT.WAITING","createdAt":"2017-10-02T09:13:36.000-03"}],"receivers":[{"moipAccount":{"id":"MPA-8D5DBB4EF8B8","login":"caio.gaspar@moip.com.br","fullname":"Caio Gaspar"},"type":"PRIMARY","amount":{"total":4000,"refunds":0}}],"_links":{"self":{"href":"https://sandbox.moip.com.br/v2/payments/PAY-2IGF8GV63T34"},"order":{"href":"https://sandbox.moip.com.br/v2/orders/ORD-2Q0NPHVH0WD0","title":"ORD-2Q0NPHVH0WD0"}},"createdAt":"2017-10-02T09:13:36.000-03","updatedAt":"2017-10-02T09:13:36.000-03"}],"_links":{"self":{"href":"https://sandbox.moip.com.br/v2/multipayments/MPY-1PUFJXHYNREW"},"multiorder":{"href":"https://sandbox.moip.com.br/v2/multiorders/MOR-PNK44ZCR3PVK"}}} \ No newline at end of file diff --git a/tests/jsons/multipayment/get.json b/tests/jsons/multipayment/get.json new file mode 100644 index 0000000..138b46d --- /dev/null +++ b/tests/jsons/multipayment/get.json @@ -0,0 +1 @@ +{"id":"MPY-BTFCRTZYEVXU","status":"IN_ANALYSIS","amount":{"total":77000,"gross":77000,"currency":"BRL"},"installmentCount":1,"payments":[{"id":"PAY-51DUCPZH7T4O","status":"AUTHORIZED","delayCapture":false,"amount":{"total":45000,"gross":45000,"fees":3369,"refunds":0,"liquid":41631,"currency":"BRL"},"installmentCount":1,"fundingInstrument":{"creditCard":{"id":"CRC-YIWYYPV0W6KJ","brand":"VISA","first6":"401200","last4":"1112","store":true,"holder":{"birthdate":"1989-06-01","birthDate":"1989-06-01","taxDocument":{"type":"CPF","number":"22222222222"},"fullname":"Jose Silva"}},"method":"CREDIT_CARD"},"fees":[{"type":"TRANSACTION","amount":3369}],"events":[{"type":"PAYMENT.AUTHORIZED","createdAt":"2017-10-02T11:49:29.000-03"},{"type":"PAYMENT.CREATED","createdAt":"2017-10-02T11:49:28.000-03"},{"type":"PAYMENT.IN_ANALYSIS","createdAt":"2017-10-02T11:49:28.000-03"},{"type":"PAYMENT.WAITING","createdAt":"2017-10-02T11:49:28.000-03"}],"receivers":[{"moipAccount":{"id":"MPA-VB5OGTVPCI52","login":"lojista_1@labs.moip.com.br","fullname":"Chris Coyier Moip"},"type":"PRIMARY","amount":{"total":45000,"refunds":0}}],"_links":{"self":{"href":"https://sandbox.moip.com.br/v2/payments/PAY-51DUCPZH7T4O"},"order":{"href":"https://sandbox.moip.com.br/v2/orders/ORD-8AHAZIHUH2SH","title":"ORD-8AHAZIHUH2SH"}},"createdAt":"2017-10-02T11:49:28.000-03","updatedAt":"2017-10-02T11:49:29.000-03"},{"id":"PAY-AVX93WB7A10U","status":"AUTHORIZED","delayCapture":false,"amount":{"total":32000,"gross":32000,"fees":2407,"refunds":0,"liquid":29593,"currency":"BRL"},"installmentCount":1,"fundingInstrument":{"creditCard":{"id":"CRC-KW5IN75IRUHT","brand":"VISA","first6":"401200","last4":"1112","store":true,"holder":{"birthdate":"1989-06-01","birthDate":"1989-06-01","taxDocument":{"type":"CPF","number":"22222222222"},"fullname":"Jose Silva"}},"method":"CREDIT_CARD"},"fees":[{"type":"TRANSACTION","amount":2407}],"events":[{"type":"PAYMENT.AUTHORIZED","createdAt":"2017-10-02T11:49:29.000-03"},{"type":"PAYMENT.CREATED","createdAt":"2017-10-02T11:49:28.000-03"},{"type":"PAYMENT.IN_ANALYSIS","createdAt":"2017-10-02T11:49:28.000-03"},{"type":"PAYMENT.WAITING","createdAt":"2017-10-02T11:49:28.000-03"}],"receivers":[{"moipAccount":{"id":"MPA-IFYRB1HBL73Z","login":"lojista_3@labs.moip.com.br","fullname":"Lojista 3 Moip"},"type":"PRIMARY","amount":{"total":32000,"refunds":0}}],"_links":{"self":{"href":"https://sandbox.moip.com.br/v2/payments/PAY-AVX93WB7A10U"},"order":{"href":"https://sandbox.moip.com.br/v2/orders/ORD-6RX3N3FK37XE","title":"ORD-6RX3N3FK37XE"}},"createdAt":"2017-10-02T11:49:28.000-03","updatedAt":"2017-10-02T11:49:29.000-03"}],"_links":{"self":{"href":"https://sandbox.moip.com.br/v2/multipayments/MPY-BTFCRTZYEVXU"},"multiorder":{"href":"https://sandbox.moip.com.br/v2/multiorders/MOR-QVK65HN7MF34"}}} \ No newline at end of file diff --git a/tests/jsons/notification/list.json b/tests/jsons/notification/list.json new file mode 100644 index 0000000..bf690d6 --- /dev/null +++ b/tests/jsons/notification/list.json @@ -0,0 +1 @@ +[{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"9fb71e1c78d447aeb432984019b6cd1c","id":"NPR-KINZC2J1C3LJ"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"d6e96361aeb6413693f66fcd715e0759","id":"NPR-UCB2YMKAKMHK"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"f4ba624292304677ab8b57cac2e41e08","id":"NPR-DM7R6Y62KZTF"},{"events":["ORDER.*","PAYMENT.AUTHORIZED","PAYMENT.CANCELLED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"994e3ffae9214fbc806d01de2dd5d341","id":"NPR-N6QZE3223P98"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"ee6e5e5ed1594c13b0099405a3b763da","id":"NPR-AXU5UMEW0H1J"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"27861e39f9194c5fab4a15076bb8485b","id":"NPR-LCUIYBWHN87X"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"3979fcb3d9b442be909a0e6af645d77c","id":"NPR-9M4DOIMJKTD0"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"79043e301cda4352b1d2a6f8aaa74ec6","id":"NPR-TDQEVITWYFNC"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"5c7660eefe3147efbf4aca659c7c9664","id":"NPR-QXURMMX2NDTS"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"19247f6a7aaf4a5f88daa5e313d6f14b","id":"NPR-OOOUBBYSRARU"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"3d4dd9da493b4b2493ceea74b342cf12","id":"NPR-MD8GVRNPQ9UU"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"6e56c6c250a848279be50295fa31c143","id":"NPR-OMX7ESYZ7I5Y"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"21bdff2351ae4cdcb055ae9600855a9a","id":"NPR-LX1KDOG3N1B8"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"dce54b9a74f644a6bce365b11dba7305","id":"NPR-62XGYKQ8ND6D"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"6942684acd2e466684494987f3915640","id":"NPR-CUFWH9HD6YJI"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"db2007d2d2d7469c99c45f47b0222b52","id":"NPR-KTT2HSU8M9MS"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"0648a9f8597340eaa20846e07e8cf727","id":"NPR-ZA65T8ID4SRI"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"d116a5ba94cf47149e32d10de0c30804","id":"NPR-8FTEQQYDITMI"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"46fe492fe5b54771ae4f26a712042877","id":"NPR-APLZQC61QAC8"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"691d8984c7c7472db15982321d7356fd","id":"NPR-AZQ8H3OSJZZM"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"20edafe347a84b1da811d132066e7db3","id":"NPR-YRFC1U7ZTXOZ"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"37d28a471427456988a20cd6e3066f66","id":"NPR-AMXRU43TV5H4"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"0e1b55ad3739402e9c62819fd452d536","id":"NPR-4BYGXJA4OZY5"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"564c3c4ffcaa41609d950c76379c0236","id":"NPR-E9JII4MXVW80"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"ff53792cc28a4b9e946091a81206e1f8","id":"NPR-OADQ2V0Z3CNX"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"7092753891fb422bbcd1871fc5270d13","id":"NPR-W2LNO1G3S1M6"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"4334dd9cd7f84d998c956be53321a105","id":"NPR-JKTB1RCUL7KZ"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"c30b3dcd059f46ca85ad463a53b1f02b","id":"NPR-0RTKP8N22R73"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"876767c86f124c0cb4a2e6a49712ddd3","id":"NPR-LMHP82ENEMQC"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"8ac2ef95425941219efcab8ff4a1c84e","id":"NPR-W2Z749SUV786"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"5413baf06ffc4e0da0f6bacde1fbb13f","id":"NPR-BY3M594QVZX8"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"5a97600a7bdf49ad86a3249aeb5c4826","id":"NPR-K1HDB87HJDDK"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"0742e60d58ab4b0db328f25fce90f563","id":"NPR-UC236MNILF7F"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"6fcac08ee74e4a1e95dce4a009864e33","id":"NPR-6OVADI0VQ9QJ"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"dd76e300f66c465080d440974c1fa8e9","id":"NPR-HLKEYO81TN6Z"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"60be5a9637f4413fb7b03e819415571b","id":"NPR-26XXICM9E83G"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"2ed63af64a0c4f11ad49cde88ca0d4a1","id":"NPR-AWE5W11ZY2AK"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"03de69011ebc4b318a7885eee11aab53","id":"NPR-7KTTWSDFBMOE"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"57baa1ffeecb4d1292b5eea2c73bac47","id":"NPR-UN18OZE08CSU"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"ad7bb585433b4563a712913364a8e315","id":"NPR-6V51HPWS96RK"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"8b55c8bd5f4f45b381744e6d748fc60b","id":"NPR-098GW9EO9J1E"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"f322e2caddaa49d3a4f91c21c912c07e","id":"NPR-CRGZH171YIGR"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"7b114be749594697b4aee72979ce1d33","id":"NPR-GD646ST62E1P"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"39b3e50dfa2140deb22431ea42c4fe36","id":"NPR-YSLIAAHAWG51"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"8ed04b8fc3e64d6096412e885fba97be","id":"NPR-39JQFXWNW7OA"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"93ab7dafbef54edc92189fa3f0dee53e","id":"NPR-QXSR0QQ8SFKH"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"6f8444468edd421caac3ebf7de614763","id":"NPR-GZSUGFB60O3J"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"368decbeeccd4f44937aeeb16d8c9508","id":"NPR-KHSTDYIGSHTI"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"6caf5a1226514ebcbdfa9abd1ae67ab8","id":"NPR-K6LDRPUU6VGG"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"062333b61e3b4b3eb858d976215ac18c","id":"NPR-JXKPDVTMG9Z0"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"aee22a0d2c3546f98a99f4c83f8e906e","id":"NPR-4Y4SRN4LGTSH"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"591f7bab64514b49aea42a3478818458","id":"NPR-V5OPQHQIK16H"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"d6851d3c0c1241b2b298dbe575514557","id":"NPR-X1YI98EB6WEC"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"f0754d49a7924e70acfdcc7d2d93e194","id":"NPR-NI0PWKT570GC"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"eb5c6750181145b3bb74824e31d52bec","id":"NPR-Z9ZE6SZ03AUT"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"53672043afc14fcdb3e78aec07562f05","id":"NPR-26FYSJM13G2M"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"2d184651dc234b92962df7af490af11f","id":"NPR-UA7ZEQP40FFQ"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"ca10aaef17be498e86cd7b340fd527ed","id":"NPR-QDLPJNRXGOJ7"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"58026651ed7e4cf5916617ea0d61e2c7","id":"NPR-PGIL2GXSVKMN"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"ff8a490ffbc7411daa13d7476a8d9a19","id":"NPR-W1OQUJU4OFGU"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"893738293f4c4343bb8590053df1c785","id":"NPR-WPHTKMHV071L"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"b086fce87d4a4ba088487b4af46f7c13","id":"NPR-QS3N69D2HG4E"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"9978c5f706434314870e77200451da4b","id":"NPR-QAXHK7LPN716"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"f345126fce614830a5d21176d84d1d9c","id":"NPR-SVV0EDLPPGDJ"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"a042ffaffab54b7d8f7d00ca930956c5","id":"NPR-J71UXTDZ1U0E"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"1e30022c4a1248ce9f2ba5774aff12d3","id":"NPR-IW8EHEQ5HXFJ"},{"events":["ORDER.*","PAYMENT.AUTHORIZED","PAYMENT.CANCELLED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"73310eaeefb74663b2b0b6c8179cb60a","id":"NPR-GCK9RHJNGOO1"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"651d99788ba54f8ca6bae712aa2ced33","id":"NPR-P2AMHXY6D8JU"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"4230cb09dc3b43c380b11cd01e863a32","id":"NPR-X6B42JSV1AMJ"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"78ef95e394f84e84a0c3ce764addd5e0","id":"NPR-RYK4TK46QZMC"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"74fdbb998c984f1a9ac8a9963a21f235","id":"NPR-7V5NYS2KMHQI"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"affccd48cdc840e7acd30c6d5d402685","id":"NPR-5L16967V3O7G"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"3ae7c191af6f44a5a097912ee6ed07d0","id":"NPR-4XS1A96UMPQX"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"8890fe37360f4cb8878b5ab72a53cdd8","id":"NPR-9DASUH8088LC"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"3ffcda9a4c9746fdb09dacb573700008","id":"NPR-4560KR3RC6ZR"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"058afed779d74b91aebb323e0b8a386b","id":"NPR-S2NX0DEEVLC8"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"537d98432b474856a77b21bd2b92313a","id":"NPR-GXNB5QHWXDIT"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"bfad4a4af62d4a29a4f5aeb581f2ef6a","id":"NPR-TOBPZSF39CWE"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"46e53674a681439ea07783489df4787c","id":"NPR-677UK9JHO0DF"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"b3454acba0dc41a9b1c30139033e0cba","id":"NPR-PWFXFJVNR5NE"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"b0df0a532d584403bdc12b96562268be","id":"NPR-KHXOP3ZMTOUD"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"4659bbe6b9684f14917be2a47d3e9638","id":"NPR-M8ZYXK4BZH2D"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"91e077ddc08b480199df53d2291d27f3","id":"NPR-NV7V5ENXZKK2"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"5f287329916d428c88917d835356f88c","id":"NPR-RRX4J4TPC3DO"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"60a5a62afca74132b6a0f664c80c5014","id":"NPR-CU8S3CZX1U2Y"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"a0e82c80bf074b3482a5828d16b12d98","id":"NPR-GGGQICGHKSZP"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"c1671a7e84844554a6dca63e92853454","id":"NPR-ZK3K0R2FWZ2Z"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"8b2ff4fbdd4345b19bb6c352d580b088","id":"NPR-C61H710YWSB7"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"690e9455e1914c84854da09b68a81d4d","id":"NPR-ONE4XT0V9ASE"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"f4a25d42128e4b77beaaeb7f7a64b671","id":"NPR-CG3SX16KPCWZ"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"678218ec84854083958c7300c2d852ab","id":"NPR-MSEV0V28LKJT"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"4131bed16a9d417eb36456db41f7c707","id":"NPR-HUF0NLFHUUJI"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"32ff3854f7cb473e9ee78268d9fdf522","id":"NPR-A44ZFZ4Q45NS"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"893bf80424ba4959a0ca83c61043020a","id":"NPR-PKGU3PH5SNPR"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"2ed92abc4c8e40e9b379450aff68f52d","id":"NPR-LPHWRZO4O4IF"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"8103726767254bb58247f87d5791195b","id":"NPR-E47QJLD7FY18"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"ab244a1915784df991aa6adced7ee5f2","id":"NPR-YAQB4T2OPA45"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"f11046efb9fe49849519006668196a05","id":"NPR-LCR9Z9NMNO07"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"a7242ee791504c7880d11c54be137fe9","id":"NPR-7X3CCX63BUZG"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"ad7e3b62577147d386cd738da5259d5d","id":"NPR-49UFVUYK12I4"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"f16eab2670fa437a82ff4d71d68d8432","id":"NPR-JOLNJYMUNWZQ"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"10f3d17b9257418d9ec5fc67d73bcce4","id":"NPR-1EVHBB08KDMI"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"b26af4d897f64327b290a3a55ef6fe7d","id":"NPR-XK9WUEIKSW6V"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"7319e57754734f64a0ca1fa02dfda74f","id":"NPR-UY5TJ6I9QBKH"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"00d17cf75b914031bce92b6eaec3179f","id":"NPR-RNAAU80BAPCT"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"74a63ae3e758424ba8371bbaaedd8928","id":"NPR-0M4IT8GBF5NL"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"8c243d09fdac4e66a3586fd201d842b3","id":"NPR-X1UE6Z6I0VKF"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"1116d4e0264c4d619f3fc83bd0428353","id":"NPR-VHL76E78APQN"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"0eda8addc4774eba82f74d3f5c461b59","id":"NPR-WYOAZER5S8MD"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"d39d3e65c43e473ca226ef6ea3fa2207","id":"NPR-20GID49GT4JB"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"0d196a21414c45f2a29989816ff69950","id":"NPR-0I2IVE8ZP4NX"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"97d4825469dc44c7bd3a7ae78618a431","id":"NPR-UHJMOBHZZT3F"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"5918e827d6d7489995d469ca39d88ad4","id":"NPR-88URNN1G722U"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"ce9ba74b67d74acf9d01bb653011abfb","id":"NPR-NG7TB92ID5ZH"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"fbc423dc31b24314a3665bab23e0175b","id":"NPR-DJSJGW94BJR4"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"2ffd2b3c00124008b379d7db4fdd1907","id":"NPR-XAJOL6OXLVIG"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"aa2bd3eae9f546668e1f46a3036e422d","id":"NPR-DV44MG3RRQZ2"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"19800ec432a0467c9f2fcc24283247f9","id":"NPR-5EZETJMQ1VF0"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"3e4fb0f68f504f0ca4c9f23d64fb5e7f","id":"NPR-RDUTIISLYTOF"},{"events":["ORDER.*","PAYMENT.AUTHORIZED"],"target":"http://requestb.in/1dhjesw1","media":"WEBHOOK","token":"45dd8eaf64f24fada2d8a119ce005825","id":"NPR-UK8S9PM51B7B"}] \ No newline at end of file diff --git a/tests/jsons/payment/cancel_pre_authorized.json b/tests/jsons/payment/cancel_pre_authorized.json new file mode 100644 index 0000000..b72f23f --- /dev/null +++ b/tests/jsons/payment/cancel_pre_authorized.json @@ -0,0 +1 @@ +{"id":"PAY-OJ6HY61197IH","status":"CANCELLED","delayCapture":true,"cancellationDetails":{"code":"7","description":"Política do Moip","cancelledBy":"MOIP"},"amount":{"total":7300,"gross":7300,"fees":470,"refunds":0,"liquid":6830,"currency":"BRL"},"installmentCount":1,"fundingInstrument":{"creditCard":{"id":"CRC-7D197TPTPYWQ","brand":"VISA","first6":"401200","last4":"1112","store":true,"holder":{"birthdate":"1988-12-30","birthDate":"1988-12-30","taxDocument":{"type":"CPF","number":"22222222222"},"fullname":"Jose Portador da Silva"}},"method":"CREDIT_CARD"},"fees":[{"type":"TRANSACTION","amount":470}],"events":[{"type":"PAYMENT.CANCELLED","createdAt":"2017-10-02T09:54:51.928-03"},{"type":"PAYMENT.CREATED","createdAt":"2017-10-02T09:54:30.000-03"},{"type":"PAYMENT.IN_ANALYSIS","createdAt":"2017-10-02T09:54:30.000-03"},{"type":"PAYMENT.PRE_AUTHORIZED","createdAt":"2017-10-02T09:54:30.000-03"}],"receivers":[{"moipAccount":{"id":"MPA-8D5DCB4EF8B8","login":"test@moip.com.br","fullname":"Moip Test"},"type":"PRIMARY","amount":{"total":7300,"fees":0,"refunds":0},"feePayor":true}],"_links":{"self":{"href":"https://sandbox.moip.com.br/v2/payments/PAY-OJ6HY61197IH"},"order":{"href":"https://sandbox.moip.com.br/v2/orders/ORD-QSIHV6257YJK","title":"ORD-QSIHV6257YJK"}},"createdAt":"2017-10-02T09:54:30.000-03","updatedAt":"2017-10-02T09:54:51.927-03"} \ No newline at end of file diff --git a/tests/jsons/payment/capture.json b/tests/jsons/payment/capture.json new file mode 100644 index 0000000..5a7ddcc --- /dev/null +++ b/tests/jsons/payment/capture.json @@ -0,0 +1 @@ +{"id":"PAY-SNZZN80MZHPX","status":"AUTHORIZED","delayCapture":true,"amount":{"total":7300,"gross":7300,"fees":470,"refunds":0,"liquid":6830,"currency":"BRL"},"installmentCount":1,"fundingInstrument":{"creditCard":{"id":"CRC-7D197TPTPYWQ","brand":"VISA","first6":"401200","last4":"1112","store":true,"holder":{"birthdate":"1988-12-30","birthDate":"1988-12-30","taxDocument":{"type":"CPF","number":"22222222222"},"fullname":"Jose Portador da Silva"}},"method":"CREDIT_CARD"},"fees":[{"type":"TRANSACTION","amount":470}],"events":[{"type":"PAYMENT.AUTHORIZED","createdAt":"2017-10-02T09:40:12.879-03"},{"type":"PAYMENT.IN_ANALYSIS","createdAt":"2017-10-02T09:31:31.000-03"},{"type":"PAYMENT.PRE_AUTHORIZED","createdAt":"2017-10-02T09:31:31.000-03"},{"type":"PAYMENT.CREATED","createdAt":"2017-10-02T09:31:30.000-03"}],"receivers":[{"moipAccount":{"id":"MPA-8D5DCB4EF8B8","login":"test@moip.com.br","fullname":"Moip Test"},"type":"PRIMARY","amount":{"total":7300,"fees":470,"refunds":0},"feePayor":true}],"_links":{"self":{"href":"https://sandbox.moip.com.br/v2/payments/PAY-SNZZN80MZHPX"},"order":{"href":"https://sandbox.moip.com.br/v2/orders/ORD-M91RU6997NRD","title":"ORD-M91RU6997NRD"}},"createdAt":"2017-10-02T09:31:30.000-03","updatedAt":"2017-10-02T09:40:12.878-03"} \ No newline at end of file diff --git a/tests/jsons/payment/create_cc_delay_capture.json b/tests/jsons/payment/create_cc_delay_capture.json new file mode 100644 index 0000000..1b5df02 --- /dev/null +++ b/tests/jsons/payment/create_cc_delay_capture.json @@ -0,0 +1 @@ +{"id":"PAY-SNZZN80MZHPX","status":"IN_ANALYSIS","delayCapture":true,"amount":{"total":7300,"gross":7300,"fees":0,"refunds":0,"liquid":7300,"currency":"BRL"},"installmentCount":1,"fundingInstrument":{"creditCard":{"id":"CRC-7D197TPTPYWQ","brand":"VISA","first6":"401200","last4":"1112","store":true,"holder":{"birthdate":"1988-12-30","birthDate":"1988-12-30","taxDocument":{"type":"CPF","number":"22222222222"},"fullname":"Jose Portador da Silva"}},"method":"CREDIT_CARD"},"fees":[{"type":"TRANSACTION","amount":0}],"events":[{"type":"PAYMENT.IN_ANALYSIS","createdAt":"2017-10-02T09:31:31.080-03"},{"type":"PAYMENT.CREATED","createdAt":"2017-10-02T09:31:30.955-03"}],"receivers":[{"moipAccount":{"id":"MPA-8D5DCB4EF8B8","login":"test@moip.com.br","fullname":"Moip Test"},"type":"PRIMARY","amount":{"total":7300,"refunds":0}}],"_links":{"self":{"href":"https://sandbox.moip.com.br/v2/payments/PAY-SNZZN80MZHPX"},"order":{"href":"https://sandbox.moip.com.br/v2/orders/ORD-M91RU6997NRD","title":"ORD-M91RU6997NRD"}},"createdAt":"2017-10-02T09:31:30.953-03","updatedAt":"2017-10-02T09:31:31.080-03"} \ No newline at end of file diff --git a/tests/jsons/payment/get.json b/tests/jsons/payment/get.json new file mode 100644 index 0000000..bbceb7d --- /dev/null +++ b/tests/jsons/payment/get.json @@ -0,0 +1 @@ +{"id":"PAY-KT5OSI01X8QU","status":"SETTLED","delayCapture":true,"amount":{"total":102470,"gross":102470,"fees":7622,"refunds":0,"liquid":94848,"currency":"BRL"},"installmentCount":1,"fundingInstrument":{"creditCard":{"id":"CRC-Y193W7M06F08","brand":"VISA","first6":"401200","last4":"1112","store":true,"holder":{"birthdate":"1988-12-30","birthDate":"1988-12-30","taxDocument":{"type":"CPF","number":"22222222222"},"fullname":"Jose Portador da Silva"}},"method":"CREDIT_CARD"},"fees":[{"type":"TRANSACTION","amount":7622}],"events":[{"type":"PAYMENT.SETTLED","createdAt":"2017-09-06T00:22:25.000-03"},{"type":"PAYMENT.AUTHORIZED","createdAt":"2017-09-04T14:25:11.000-03"},{"type":"PAYMENT.PRE_AUTHORIZED","createdAt":"2017-09-04T14:17:35.000-03"},{"type":"PAYMENT.CREATED","createdAt":"2017-09-04T14:17:34.000-03"},{"type":"PAYMENT.IN_ANALYSIS","createdAt":"2017-09-04T14:17:34.000-03"}],"receivers":[{"moipAccount":{"id":"MPA-CULBBYHD11","login":"integracao@labs.moip.com.br","fullname":"Moip SandBox"},"type":"PRIMARY","amount":{"total":102470,"fees":7622,"refunds":0},"feePayor":true}],"_links":{"self":{"href":"https://sandbox.moip.com.br/v2/payments/PAY-KT5OSI01X8QU"},"order":{"href":"https://sandbox.moip.com.br/v2/orders/ORD-5N85DL9MNDSS","title":"ORD-5N85DL9MNDSS"}},"createdAt":"2017-09-04T14:17:34.000-03","updatedAt":"2017-09-06T00:22:25.000-03"} \ No newline at end of file