lifenpag / asaas-php
LifenPag's Asaas PHP Library
Installs: 2 008
Dependents: 0
Suggesters: 0
Security: 0
Stars: 7
Watchers: 1
Forks: 0
Open Issues: 1
Requires
- php: >=7.3
- guzzlehttp/guzzle: >=7
Requires (Dev)
- fzaninotto/faker: ^1.9.1
- phploc/phploc: *
- phpmd/phpmd: ^2.8
- phpstan/phpstan: ^0.12.48
- phpunit/phpunit: ^9
- sebastian/phpcpd: ^5.0
- slevomat/coding-standard: ^6.3
- squizlabs/php_codesniffer: ^3.5
README
This is not an official Asaas library
Installation
composer require lifenpag/asaas-php
Create Client
<?php 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
Create Customer By Entity
$customer = new CustomerEntity(); $customer->name = 'Homer Simpson'; $customer->email = 'homer.simpson@lifenpag.com'; $customerCreated = $customer->create();
Create Customer By Domain
$customer = new CustomerEntity(); $customer->name = 'Homer Simpson'; $customer->email = 'homer.simpson@lifenpag.com'; $customerCreated = CustomerDomain::create($customer)->get(); // or $customer = new CustomerEntity((object) ["name" => "test", "email" => "email@test.com"]; $customerCreated = CustomerDomain::create($customer)->get();
Update Customer
$customerEntity = CustomerDomain::update(['name' => 'Homer Simpson Updated'], 'customer_id')->get();
Update Customer Nested
$customerEntity = new CustomerEntity(); $customerEntity->name = 'Homer Simpson'; $customerEntity->email = 'homer.simpson@lifenpag.com'; $customerEntity->cpfCnpj = '85267610054'; // Creating customer $customer = CustomerDomain::create($customerEntity)->get(); // Updating object customer $customerUpdated = $customer->update(['name' =>'Homer Jay Simpson']);
Delete Customer
$customerEntity = CustomerDomain::delete('customer_id')->get();
Delete Customer Nested
$customerEntity = CustomerDomain::find('customer_id')->get(); $customerEntityDeleted = $customerEntity->delete();
Restore Customer
$customerEntity = CustomerDomain::restore('customer_id')->get();
Restore Customer Nested
$customerEntity = CustomerDomain::find('customer_id')->get(); $customerEntityRestored = $customerEntity->restore();
Get All Customers
$customerCollection = CustomerDomain::all();
Get Customers By Filters
$customerCollection = CustomerDomain::where(['limit' => 3]);
Update in loop Example
$customerCollection = CustomerDomain::where(['limit' => 3]); $customerCollection->map(function ($customer) { $customerUpdated = $customer->update(['name' => 'nested updated']); });
Payment
Create Payment By Entity
$payment = new PaymentEntity(); $payment->customer = 'customer_id'; $payment->billingType = 'BOLETO'; $payment->value = 100; $payment->dueDate = (new DateTime())->format('Y-m-d'); $paymentCreated = $payment->create();
Create Payment By Customer Domain (doPayment)
$customer = new CustomerEntity(); $customer->name = 'Homer Simpson'; $customer->email = 'homer.simpson@lifenpag.com'; $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);
Get Payment
$payment = PaymentDomain::find('pay_id')->get();
Get Payment With Digitable Line
$payment = PaymentDomain::find('pay_id')->get()->populateDigitableLine();
Credits
This project was created by Breno Vieira Soares from LifenPag. Feel free to contribute to the project