PHP code example of artesaos / moip
1. Go to this page and download the library: Download artesaos/moip library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
artesaos / moip example snippets
'providers' => array(
Illuminate\Foundation\Providers\ArtisanServiceProvider::class,
Illuminate\Auth\AuthServiceProvider::class,
...
Artesaos\Moip\Providers\MoipServiceProvider::class,
...
),
// file START ommited
$app->register(Artesaos\Moip\Providers\MoipServiceProvider::class);
// file END ommited
'aliases' => array(
'App' => Illuminate\Support\Facades\App::class,
'Artisan' => Illuminate\Support\Facades\Artisan::class,
...
'Moip' => Artesaos\Moip\Facades\Moip::class,
),
$moip = Moip::start();
try {
$customer = $moip->customers()->setOwnId(uniqid())
->setFullname('Fulano de Tal')
->setEmail('[email protected] ')
->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());
}
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());
}
try {
$payment = $order->payments()->setCreditCard(12, 21, '4073020000000002', '123', $customer)
->execute();
dd($payment);
} catch (Exception $e) {
dd($e->__toString());
}
shell
php artisan vendor:publish
shell
php artisan vendor:publish --provider="Artesaos\Moip\Providers\MoipServiceProvider"
shell
php artisan vendor:publish --provider="Artesaos\Moip\Providers\MoipServiceProvider" --force