PHP code example of lifenpag / asaas-php

1. Go to this page and download the library: Download lifenpag/asaas-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/ */

    

lifenpag / asaas-php example snippets



use LifenPag\Asaas\V3\Client;
use LifenPag\Asaas\V3\Domains\Customer as CustomerDomain;
use LifenPag\Asaas\V3\Entities\Customer as CustomerEntity;
use LifenPag\Asaas\V3\Collections\Customer as CustomerCollection;

Client::connect('your_api_key', 'sandbox|production');

$customer = new CustomerEntity();
$customer->name = 'Homer Simpson';
$customer->email = '[email protected]';

$customerCreated = $customer->create();

$customer = new CustomerEntity();
$customer->name = 'Homer Simpson';
$customer->email = '[email protected]';

$customerCreated = CustomerDomain::create($customer)->get();
// or
$customer = new CustomerEntity((object) ["name" => "test", "email" => "[email protected]"];

$customerCreated = CustomerDomain::create($customer)->get();

$customerEntity = CustomerDomain::update(['name' => 'Homer Simpson Updated'], 'customer_id')->get();

$customerEntity = new CustomerEntity();
$customerEntity->name = 'Homer Simpson';
$customerEntity->email = '[email protected]';
$customerEntity->cpfCnpj = '85267610054';

// Creating customer
$customer = CustomerDomain::create($customerEntity)->get();

// Updating object customer
$customerUpdated = $customer->update(['name' =>'Homer Jay Simpson']);

$customerEntity = CustomerDomain::delete('customer_id')->get();

$customerEntity = CustomerDomain::find('customer_id')->get();

$customerEntityDeleted = $customerEntity->delete();

$customerEntity = CustomerDomain::restore('customer_id')->get();

$customerEntity = CustomerDomain::find('customer_id')->get();

$customerEntityRestored = $customerEntity->restore();

$customerCollection = CustomerDomain::all();

$customerCollection = CustomerDomain::where(['limit' => 3]);

$customerCollection = CustomerDomain::where(['limit' => 3]);

$customerCollection->map(function ($customer) {
	$customerUpdated = $customer->update(['name' => 'nested updated']);
});

$payment = new PaymentEntity();
$payment->customer = 'customer_id';
$payment->billingType = 'BOLETO';
$payment->value = 100;
$payment->dueDate = (new DateTime())->format('Y-m-d');
$paymentCreated = $payment->create();

$customer = new CustomerEntity();
$customer->name = 'Homer Simpson';
$customer->email = '[email protected]';
$customer->cpfCnpj = '85267610054';

$payment = new PaymentEntity();
$payment->billingType = 'BOLETO';
$payment->value = 100;
$payment->dueDate = (new DateTime())->format('Y-m-d');

$paymentCreated = CustomerDomain::create($customer)->doPayment($payment);

$payment = PaymentDomain::find('pay_id')->get();

$payment = PaymentDomain::find('pay_id')->get()->populateDigitableLine();

composer