PHP code example of raniellyferreira / moip-sdk-php

1. Go to this page and download the library: Download raniellyferreira/moip-sdk-php 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/ */

    

raniellyferreira / moip-sdk-php example snippets




use Moip\Moip;
use Moip\MoipBasicAuth;

$token = '01010101010101010101010101010101';
$key = 'ABABABABABABABABABABABABABABABABABABABAB';

$moip = new Moip(new MoipBasicAuth($token, $key), Moip::ENDPOINT_SANDBOX);

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

$order = $moip->orders()->setOwnId(uniqid())
                        ->addItem('Bicicleta Specialized Tarmac 26 Shimano Alivio', 1, 'uma linda bicicleta', 10000)
                        ->setCustomer($customer)
                        ->create();

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