This repository has been archived by the owner on Oct 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
615 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,6 @@ | |
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/9e877cf78f844b9a9e40cec175c3aa5a)](https://www.codacy.com/app/jeancesargarcia/moip-sdk-php?utm_source=github.com&utm_medium=referral&utm_content=moip/moip-sdk-php&utm_campaign=Badge_Grade) | ||
[![StyleCI](https://styleci.io/repos/19941899/shield)](https://styleci.io/repos/19941899) | ||
[![Build Status](https://travis-ci.org/moip/moip-sdk-php.svg?branch=master)](https://travis-ci.org/moip/moip-sdk-php) | ||
[![Circleci Status](https://circleci.com/gh/moip/moip-sdk-php/tree/analysis-qg67K6.svg?style=shield)](#) | ||
|
||
> Estatísticas | ||
|
@@ -34,6 +33,8 @@ | |
- [Clientes](#clientes) | ||
- [Criação](#criando-um-comprador) | ||
- [Consulta](#consultando-os-dados-de-um-comprador) | ||
- [Adicionar cartão de crédito](#adicionar-cartão-de-crédito) | ||
- [Deletar cartão de crédito](#deletar-cartão-de-crédito) | ||
- [Pedidos](#pedidos) | ||
- [Criação](#criando-um-pedido-com-o-comprador-que-acabamos-de-criar) | ||
- [Consulta](#consultando-um-pedido) | ||
|
@@ -55,7 +56,12 @@ | |
- [Consulta](#consultando-um-multipedido) | ||
- [Multipagamentos](#multipagamentos) | ||
- [Criação](#criando-um-multipagamento) | ||
- [Webhooks](#webhooks) | ||
- [Conta Moip](#conta-moip) | ||
- [Criação](#criação) | ||
- [Consulta](#consulta-3) | ||
- [Verifica se usuário já possui Conta Moip](#verifica-se-usuário-já-possui-conta-moip) | ||
- [Webhooks](#webhooks) | ||
- [Consulta](#consulta-4) | ||
- [Packages](#packages) | ||
- [Documentação](#documentação) | ||
- [Testes](#testes) | ||
|
@@ -144,6 +150,33 @@ try { | |
} | ||
``` | ||
|
||
### 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()); | ||
} | ||
``` | ||
|
||
### Deletar cartão de crédito | ||
```php | ||
try { | ||
$moip->customers()->creditCard()->delete(CREDIT_CARD_ID); | ||
} catch (Exception $e) { | ||
printf($e->__toString()); | ||
} | ||
``` | ||
|
||
## Pedidos | ||
### Criando um pedido com o comprador que acabamos de criar | ||
Nesse exemplo com vários produtos e ainda especificando valor de frete, valor adicional e ainda valor de desconto. | ||
|
@@ -350,16 +383,75 @@ 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); | ||
->setInstallmentCount(3) | ||
->setStatementDescriptor('teste de pag') | ||
->setDelayCapture(false) | ||
->execute(); | ||
print_r($payment); | ||
} catch (Exception $e) { | ||
printf($e->__toString()); | ||
} | ||
``` | ||
|
||
## Conta Moip | ||
|
||
### Criação | ||
```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('[email protected]') | ||
->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); | ||
} catch (Exception $e) { | ||
printf($e->__toString()); | ||
} | ||
``` | ||
|
||
### Consulta | ||
```php | ||
try { | ||
$account = $moip->accounts()->get(ACCOUNT_ID); | ||
print_r($account); | ||
} catch (Exception $e) { | ||
printf($e->__toString()); | ||
} | ||
``` | ||
|
||
### 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); | ||
``` | ||
|
||
## Webhooks | ||
> O PHP, por padrão, está preparado para receber apenas alguns tipos de `content-type` (`application/x-www-form-urlencoded` e `multipart/form-data`). A plataforma do Moip, no entanto, envia dados no formato JSON, o qual a linguagem não está preparada para receber por padrão. | ||
Para receber e acessar os dados enviados pelo Moip, você precisa adicionar o seguinte código ao seu arquivo que receberá os webhooks: | ||
|
@@ -371,6 +463,18 @@ $json = file_get_contents('php://input'); | |
$response = json_decode($json, true); | ||
``` | ||
|
||
### Consulta | ||
|
||
#### Sem paginação ou filtro por resource/evento | ||
```php | ||
$moip->webhooks()->get(); | ||
``` | ||
|
||
#### Com paginação e filtros por resource/evento | ||
```php | ||
$moip->webhooks()->get(new Pagination(10, 0), 'ORD-ID', 'ORDER.PAID'); | ||
``` | ||
|
||
## Documentação | ||
|
||
[Documentação oficial](https://documentao-moip.readme.io/v2.0/reference) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,14 @@ | |
{ | ||
"name": "Joao Batista Neto", | ||
"email": "[email protected]" | ||
}, | ||
{ | ||
"name": "Caio Gaspar", | ||
"email": "[email protected]" | ||
}, | ||
{ | ||
"name": "João Lucas Lucchetta", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"require": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.