2017 © Pedro Peláez
 

symfony-bundle moip-bundle

Integration of the MoIP with Symfony PHP

image

tear/moip-bundle

Integration of the MoIP with Symfony PHP

  • Tuesday, October 24, 2017
  • by leonnleite
  • Repository
  • 1 Watchers
  • 2 Stars
  • 1,181 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 4 Versions
  • 2 % Grown

The README.md

MoipBundle

Build Status, (*1)

Instalação

composer require tear/moip-bundle, (*2)

Adicione ao seu appKernel

php // app/AppKernel.php public function registerBundles() { return [ // ... new LeonnLeite\MoipBundle\MoipBundle(), // ... ]; }, (*3)

Configuração:

a configuração inicial, é só colocar token e key, (*4)

// app/config/config.yml

moip:
    credential:
        token: 01010101010101010101010101010101
        key: ABABABABABABABABABABABABABABABABABABABAB 

Se você conecta por OAuth

Para oauth, key não é necessário. O Token, se torna o papel de accessToken, (*5)

// app/config/config.yml

moip:
    credential:
        token: 01010101010101010101010101010101
    authentication_mode: OAuth

Se você deseja colocar em produção

Colocar o parametro production: true, (*6)

// app/config/config.yml

moip:
    credential:
        token: 01010101010101010101010101010101
        key: ABABABABABABABABABABABABABABABABABABABAB 
    production: true

Utilização

Use as service moip

//...
class AcmeController extends Controller
{
    public function indexAction()
    {
        try {
            $customer = $this->get('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());
        }
//...

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., (*7)

try {
    $order = $this->get('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());
}

Criando o pagamento

Após criar o pedido basta criar um pagamento nesse pedido. Nesse exemplo estamos pagando com Cartão de Crédito., (*8)

try {
    $payment = $order->payments()->setCreditCard(12, 21, '4073020000000002', '123', $customer)
        ->execute();

    print_r($payment);
} catch (Exception $e) {
    printf($e->__toString());
}

Documentação

Documentação oficial, (*9)

Moip SDK, (*10)

The Versions

24/10 2017

dev-master

9999999-dev

Integration of the MoIP with Symfony PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Leonn Leite

bundle symfony moip

24/10 2017

1.0.1

1.0.1.0

Integration of the MoIP with Symfony PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Leonn Leite

bundle symfony moip

24/10 2017

dev-fix/moip-namespace

dev-fix/moip-namespace

Integration of the MoIP with Symfony PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Leonn Leite

bundle symfony moip

27/10 2016

1.0

1.0.0.0

Integration of the MoIP with Symfony PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Leonn Leite

bundle symfony moip