2017 © Pedro Peláez
 

libraries moip

Integration of MoIP payment intermediary with Laravel 5

image

artesaos/moip

Integration of MoIP payment intermediary with Laravel 5

  • Saturday, January 13, 2018
  • by vinicius73
  • Repository
  • 14 Watchers
  • 32 Stars
  • 5,125 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 20 Forks
  • 1 Open issues
  • 8 Versions
  • 13 % Grown

The README.md

# Package for API v2 MoIP

Current Status Package, (*1)

Scrutinizer Code Quality Code Climate Build Status Codacy Badge, (*2)

Statistics, (*3)

Total Downloads Monthly Downloads Daily Downloads, (*4)

Version, (*5)

Latest Stable Version Latest Unstable Version, (*6)

Tips, (*7)

Powered by ZenHub, (*8)

License, (*9)

License, (*10)

Installation

Composer

Start by adding the package to require your composer.json, (*11)

composer require artesaos/moip

Having loaded dependencies and installed on your project, we will add ServiceProvider and facade., (*12)

ServiceProvider

You need to update your application configuration in order to register the package so it can be loaded by Framework., (*13)

Laravel

Just update your config/app.php file adding the following code at the end of your 'providers' section:, (*14)

'providers' => array(
    Illuminate\Foundation\Providers\ArtisanServiceProvider::class,
    Illuminate\Auth\AuthServiceProvider::class,
    ...
    Artesaos\Moip\Providers\MoipServiceProvider::class,
    ...
),

Lumen

Go to /bootstrap/app.php file and add this line:, (*15)

// file START ommited
    $app->register(Artesaos\Moip\Providers\MoipServiceProvider::class);
// file END ommited

Facade

Adding a new item on its facade, (*16)

'aliases' => array(
    'App'     => Illuminate\Support\Facades\App::class,
    'Artisan' => Illuminate\Support\Facades\Artisan::class,
    ...
    'Moip'    => Artesaos\Moip\Facades\Moip::class,
),

Settings

To move the MoIP settings file to the Settings folder of your application, simply perform the following command:, (*17)

php artisan vendor:publish

or, (*18)

php artisan vendor:publish --provider="Artesaos\Moip\Providers\MoipServiceProvider"

If you have already published the files, but for some reason need to override them, add the flag '--force' at the end of the previous command., (*19)

php artisan vendor:publish --provider="Artesaos\Moip\Providers\MoipServiceProvider" --force

His .env file, add the following values, (*20)

MOIP_KEY=yourkeyfortheservice
MOIP_TOKEN=yourtokefortheservice
MOIP_HOMOLOGATED=keyshomologatedtrueorfalse

Using

$moip = Moip::start();

Creating a buyer

In this example we will create a request with customer data - With delivery and payment address., (*21)

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();
    dd($customer);
} catch (Exception $e) {
    dd($e->__toString());
}

Creating an application with the buyer we just created

In this example with various products and also specifying freight value, additional value and further discount amount., (*22)

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();

    dd($order);
} catch (Exception $e) {
    dd($e->__toString());
}

Creating payment

After creating the application simply create a payment request. In this example we are paying by credit card., (*23)

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

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

Package for MoIP API v1 - Laravel 4

To use the package with Laravel 4 clique aqui, This package is integrated only with the V1 API MoIP, (*24)

Documentation

Official documentation, (*25)

License

The MIT License, (*26)

The Versions

13/01 2018

dev-master

9999999-dev http://dev.moip.com.br

Integration of MoIP payment intermediary with Laravel 5

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jean Cesar Garcia

laravel payment gateway checkout intermediary moip

13/01 2018

v1.0.3

1.0.3.0 http://dev.moip.com.br

Integration of MoIP payment intermediary with Laravel 5

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jean Cesar Garcia

laravel payment gateway checkout intermediary moip

14/08 2017

v1.0.2

1.0.2.0 http://dev.moip.com.br

Integration of MoIP payment intermediary with Laravel 5

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jean Cesar Garcia

laravel payment gateway checkout intermediary moip

19/06 2017

dev-develop

dev-develop http://dev.moip.com.br

Integration of MoIP payment intermediary with Laravel 5

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jean Cesar Garcia

laravel payment gateway checkout intermediary moip

04/04 2017

dev-tests

dev-tests http://dev.moip.com.br

Integration of MoIP payment intermediary with Laravel 5

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jean Cesar Garcia

laravel payment gateway checkout intermediary moip

09/05 2016

v1.0.1

1.0.1.0

Integration of MoIP payment intermediary with Laravel 5

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jean Cesar Garcia

laravel payment gateway checkout intermediary moip

08/06 2015

1.x-dev

1.9999999.9999999.9999999-dev

Integration of MoIP payment intermediary with Laravel 4

  Sources   Download

MIT

The Requires

 

by Jean C. Garcia

laravel payment gateway checkout intermediary moip

19/05 2015

v1.0.0

1.0.0.0

Integration of MoIP payment intermediary with Laravel 4

  Sources   Download

MIT

The Requires

 

by Jean C. Garcia

laravel payment gateway checkout intermediary moip