PHP code example of tio-jobs / asaas-php
1. Go to this page and download the library: Download tio-jobs/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/ */
tio-jobs / asaas-php example snippets
$response = \TioJobs\AsaasPhp\Facades\AsaasPhp::make()->customer()->list();
dd($response);
$response = \TioJobs\AsaasPhp\Facades\AsaasPhp::make()->customer()->create(
name: 'Teste Usuário',
cpfCnpj: sanitize("012.345.678-90"),
email: str("[email protected] ")->lower()->toString(),
mobilePhone: sanitize("(16) 99222-2222")
);
dd($response);
$response = \TioJobs\AsaasPhp\Facades\AsaasPhp::make()->customer()->get(id: 'cus_000005500564');
dd($response);
$response = \TioJobs\AsaasPhp\Facades\AsaasPhp::make()->customer()->findByDocument(document: '01234567890');
dd($response);
$response = \TioJobs\AsaasPhp\Facades\AsaasPhp::make()->customer()->update(id: 'cus_000005824295', mobilePhone: sanitize("(11) 91111-1111"));
dd($response);
$response = \TioJobs\AsaasPhp\Facades\AsaasPhp::make()->customer()->delete(id: 'cus_000005824295');
dd($response);
$response = \TioJobs\AsaasPhp\Facades\AsaasPhp::make()->customer()->restore(id: 'cus_000005824295',);
dd($response);
$response = \TioJobs\AsaasPhp\Facades\AsaasPhp::make()->customer()->notifications( id: 'cus_000005824295',);
dd($response);
$data = new \TioJobs\AsaasPhp\DataTransferObjects\Charges\Billet\DirectBilletDTO(
customerId: 'cus_000005824295',
value: 19.25,
);
$response = \TioJobs\AsaasPhp\Facades\AsaasPhp::make()->charge()->directByBillet(DTO: $data);
dd($response, $resource->getBilletUrl($response));
$data = new \TioJobs\AsaasPhp\DataTransferObjects\Charges\Pix\DynamicPixDTO(
customerId: 'cus_000005824295',
value: 29.99,
);
$response = \TioJobs\AsaasPhp\Facades\AsaasPhp::make()->charge()->pixDynamic(DTO: $data);
dd($response, $resource->getPixPaymentData($response));
$data = new \TioJobs\AsaasPhp\DataTransferObjects\Charges\Pix\StaticPixDTO(
description: 'Pix Estático - Descrição do Teste',
value: 19.90,
);
$response = \TioJobs\AsaasPhp\Facades\AsaasPhp::make()->charge()->pixStatic(DTO: $data);
dd($response);
$creditCardDTO = new \TioJobs\AsaasPhp\DataTransferObjects\Charges\CreditCard\CreditCardDTO(
holderName: 'marcelo h almeida',
number: '5162306219378829',
expiryMonth: '05',
expiryYear: '2024',
ccv: '318',
);
$creditCardHolderInfoDTO = new \TioJobs\AsaasPhp\DataTransferObjects\Charges\CreditCard\CreditCardHolderInfoDTO(
name: 'Marcelo Henrique Almeida',
email: '[email protected] ',
document: '24971563792',
postalCode: '89223-005',
addressNumber: '277',
phone: '4738010919',
mobilePhone: '47998781877',
addressComplement: '',
);
$directCreditCardDTO = new \TioJobs\AsaasPhp\DataTransferObjects\Charges\CreditCard\DirectCreditCardDTO(
customerId: 'cus_000005824295',
value: 29.99,
creditCardDTO: $creditCardDTO,
creditCardHolderInfoDTO: $creditCardHolderInfoDTO,
);
$response = \TioJobs\AsaasPhp\Facades\AsaasPhp::make()->charge()->directByCreditCard(DTO: $directCreditCardDTO);
dd($response);
$creditCardDTO = new \TioJobs\AsaasPhp\DataTransferObjects\Charges\CreditCard\CreditCardDTO(
holderName: 'marcelo h almeida',
number: '5162306219378829',
expiryMonth: '05',
expiryYear: '2024',
ccv: '318',
);
$creditCardHolderInfoDTO = new \TioJobs\AsaasPhp\DataTransferObjects\Charges\CreditCard\CreditCardHolderInfoDTO(
name: 'Marcelo Henrique Almeida',
email: '[email protected] ',
document: '24971563792',
postalCode: '89223-005',
addressNumber: '277',
phone: '4738010919',
mobilePhone: '47998781877',
addressComplement: '',
);
$partialCreditCardDTO = new \TioJobs\AsaasPhp\DataTransferObjects\Charges\CreditCard\PartialCreditCardDTO(
customerId: 'cus_000005824295',
value: 30.00,
installments: 2,
installmentValue: 15.00,
creditCardDTO: $creditCardDTO,
creditCardHolderInfoDTO: $creditCardHolderInfoDTO,
);
$response = \TioJobs\AsaasPhp\Facades\AsaasPhp::make()->charge()->partialCreditCard(DTO: $partialCreditCardDTO);
dd($response);
$response = \TioJobs\AsaasPhp\Facades\AsaasPhp::make()->charge()->all(limit: 10, offset: 0);
dd($response);
$response = \TioJobs\AsaasPhp\Facades\AsaasPhp::make()->charge()->delete( id: 'pay_t7b3b3fvioxuqx4e',);
dd($response);
$response = \TioJobs\AsaasPhp\Facades\AsaasPhp::make()->charge()->update(
id: 'pay_j875qgxq8ycbl42i',
data: [
'dueDate' => \Carbon\Carbon::now()->addDay()->format('Y-m-d'),
],
);
dd($response);
$response = \TioJobs\AsaasPhp\Facades\AsaasPhp::make()->charge()->uploadDocument(
id: 'pay_j875qgxq8ycbl42i',
data: [
'availableAfterPayment' => true,
'type' => \TioJobs\AsaasPhp\Enums\DocumentTypeEnum::DOCUMENT->value,
attach(filePath: base_path('packages/tio-jobs/asaas-php/examples/files/test-document.pdf'), fieldName: 'file')),
],
);
dd($response);
$response = \TioJobs\AsaasPhp\Facades\AsaasPhp::make()->charge()->deleteDocument( id: 'pay_j875qgxq8ycbl42i', document: '4b052313-ec78-42ae-8374-42a1718aab75',);
dd($response);
$subAccountDto = new \TioJobs\AsaasPhp\DataTransferObjects\SubAccounts\SubAccountDTO(
name: 'Larissa e Helena Advocacia Ltda',
email: '[email protected] ',
document: '88.354.691/0001-72',
companyType: \TioJobs\AsaasPhp\Enums\CompanyTypeEnum::INDIVIDUAL,
mobilePhone: '(11) 99173-6850',
postalCode: '14015-000',
address: 'Rua Visconde do Rio Branco',
addressNumber: '123',
province: 'Centro',
subAccountWebhooksDTO: new SubAccountWebhooksDTO(),
complement: '',
site: 'https://www.larissaehelenaadvocacialtda.com.br',
);
$response = \TioJobs\AsaasPhp\Facades\AsaasPhp::make()->subAccount()->create(DTO: $subAccountDto);
dd($response);
$response = \TioJobs\AsaasPhp\Facades\AsaasPhp::make()->subAccount()->all()
dd($response);
$response = \TioJobs\AsaasPhp\Facades\AsaasPhp::make()->subAccount()->checkPendingDocuments()
dd($response);
$response = \TioJobs\AsaasPhp\Facades\AsaasPhp::make()->subAccount()->updateDocument(
documentId: 'b445460f-4bd5-41cc-8493-712b6e0966f2',
type: \TioJobs\AsaasPhp\Enums\FileDocumentTypeEnum::ENTREPRENEUR_REQUIREMENT,
documentFile: attach(base_path('packages/tio-jobs/asaas-php/examples/files/test-document.pdf'), 'documentFile'),
)
dd($response);
$response = \TioJobs\AsaasPhp\Facades\AsaasPhp::make()->subAccount()->getDocument(documentId: '37106b34-21b6-497f-bb12-87d924b34b16');
dd($response);
$response = \TioJobs\AsaasPhp\Facades\AsaasPhp::make()->subAccount()->updateDocument(
documentId: '09f4903c-55fe-452e-bd4e-129780143214',
documentFile: attach(filePath: base_path('packages/tio-jobs/asaas-php/examples/files/test-document.pdf'), fieldName: 'documentFile'),
);
dd($response);
$response = \TioJobs\AsaasPhp\Facades\AsaasPhp::make()->subAccount()->deleteDocument( documentId: '09f4903c-55fe-452e-bd4e-129780143214',);
dd($response);
$response = \TioJobs\AsaasPhp\Facades\AsaasPhp::make()->bank()->getStatement(
startDate: now()->subMonths(3)->format('Y-m-d'),
endDate: now()->format('Y-m-d'),
offset: 0,
limit: 10,
);
dd($response);
$bankAccountDTO = new \TioJobs\AsaasPhp\DataTransferObjects\BankServices\BankAccountDTO(
bankCode: '111',
accountName: 'Conta do Bradesco Teste',
ownerName: 'Larissa e Helena Advocacia Ltda',
document: '01234567890',
agency: '1111',
accountNumber: '111111',
accountDigit: '1',
bankAccountTypeEnum: \TioJobs\AsaasPhp\Enums\BankAccountTypeEnum::CONTA_CORRENTE,
);
$response = \TioJobs\AsaasPhp\Facades\AsaasPhp::make()->bank()->otherTransfer(
value: 10.00,
operationTypeEnum: \TioJobs\AsaasPhp\Enums\OperationTypeEnum::TED,
bankAccountDTO: $bankAccountDTO,
pixKey: null,
pixTypeEnum: null,
descriptionForPix: null,
scheduleDate: null, // if null, send immediately!
)
dd($response);
$response = \TioJobs\AsaasPhp\Facades\AsaasPhp::make()->bank()->transferToAsaas( walletId: 'a45e79db-36ab-48e2-a278-d438cf14329f', value: 49.90,);
dd($response);
$response = \TioJobs\AsaasPhp\Facades\AsaasPhp::make()->bank()->getTransfer(transferId: 'be0ae5ad-a93e-4f82-8e12-964e5303627a');
dd($response);
$response = \TioJobs\AsaasPhp\Facades\AsaasPhp::make()->bank()->getAllTransfers();
dd($response);
$response = \TioJobs\AsaasPhp\Facades\AsaasPhp::make()->notifications()->update(
notificationId: 'not_3xd6o7qmx475t333',
DTO: new \TioJobs\AsaasPhp\DataTransferObjects\Notifications\UpdateNotificationDTO(
enabled: false,
emailEnabledForProvider: false,
smsEnabledForProvider: false,
emailEnabledForCustomer: true,
smsEnabledForCustomer: true,
phoneCallEnabledForCustomer: false,
whatsappEnabledForCustomer: true,
//scheduleOffset: \TioJobs\AsaasPhp\Enums\ScheduleOffsetEnum::FIVE, // only valid to PAYMENT_DUEDATE_WARNING
),
);
dd($response);
$notifications = [
new \TioJobs\AsaasPhp\DataTransferObjects\Notifications\UpdateNotificationDTO(
notificationId: 'not_3xd6o7qmx475t333',
enabled: false,
emailEnabledForProvider: false,
smsEnabledForProvider: false,
emailEnabledForCustomer: true,
smsEnabledForCustomer: true,
phoneCallEnabledForCustomer: false,
whatsappEnabledForCustomer: true,
//scheduleOffset: \TioJobs\AsaasPhp\Enums\ScheduleOffsetEnum::FIVE, // only valid to PAYMENT_DUEDATE_WARNING
),
new \TioJobs\AsaasPhp\DataTransferObjects\Notifications\UpdateNotificationDTO(
notificationId: 'not_622b0ypi6ocj6ss4',
enabled: false,
emailEnabledForProvider: false,
smsEnabledForProvider: false,
emailEnabledForCustomer: true,
smsEnabledForCustomer: true,
phoneCallEnabledForCustomer: false,
whatsappEnabledForCustomer: true,
//scheduleOffset: \TioJobs\AsaasPhp\Enums\ScheduleOffsetEnum::FIVE, // only valid to PAYMENT_DUEDATE_WARNING
)
];
$response = \TioJobs\AsaasPhp\Facades\AsaasPhp::make()->notifications()->batchUpdate(
customerId: 'cus_000005824295',
DTO: $notifications
);
dd($response);
Route::post('/webhooks/asaas', function (Request $request) {
// your business logic here!
\Illuminate\Support\Facades\Log::info('/webhooks/asaas', $request->all());
});
bash
composer ser