### Install Asaas SDK with Composer Source: https://github.com/codephix/asaas-sdk/blob/2.0.6/README.md Use Composer to install the Asaas SDK package. ```bash composer require codephix/asaas-sdk ``` -------------------------------- ### Manage Asaas Clients Source: https://github.com/codephix/asaas-sdk/blob/2.0.6/README.md Examples for retrieving, creating, updating, restoring, and deleting clients using the Asaas SDK. ```php // Retorna a listagem de clientes $clientes = $asaas->Cliente()->getAll(array $filtros); ``` ```php // Retorna os dados do cliente de acordo com o Id $clientes = $asaas->Cliente()->getById(123); ``` ```php // Retorna os dados do cliente de acordo com o Email $clientes = $asaas->Cliente()->getByEmail('email@mail.com'); ``` ```php // Insere um novo cliente $clientes = $asaas->Cliente()->create(array $dadosCliente); ``` ```php // Atualiza os dados do cliente $clientes = $asaas->Cliente()->update(123, array $dadosCliente); ``` ```php // Restaura um cliente $asaas->Cliente()->restaura(123); ``` ```php // Deleta uma cliente $asaas->Cliente()->delete(123); ``` -------------------------------- ### Get Account Details Source: https://github.com/codephix/asaas-sdk/blob/2.0.6/README.md Retrieves the commercial data for the account. ```php //Recuperar dados comerciais $MinhaConta = $asaas->MinhaConta()->get(); ``` -------------------------------- ### Get Customization Settings Source: https://github.com/codephix/asaas-sdk/blob/2.0.6/README.md Retrieves the account's customization settings. ```php // Recuperar configurações de personalização $MinhaConta = $asaas->MinhaConta()->getConf(); ``` -------------------------------- ### Manage Asaas Charges Source: https://github.com/codephix/asaas-sdk/blob/2.0.6/README.md Examples for retrieving, creating, updating, restoring, estoring, confirming, and deleting charges using the Asaas SDK. ```php // Retorna a listagem de cobranças $cobrancas = $asaas->Cobranca()->getAll(array $filtros); ``` ```php // Retorna os dados da cobrança de acordo com o Id $cobranca = $asaas->Cobranca()->getById(123); ``` ```php // Retorna a listagem de cobranças de acordo com o Id do Cliente $cobrancas = $asaas->Cobranca()->getByCustomer($customer_id); ``` ```php // Retorna a listagem de cobranças de acordo com o Id da Assinaturas $cobrancas = $asaas->Cobranca()->getBySubscription($subscription_id); ``` ```php // Insere uma nova cobrança / cobrança parcelada / cobrança split $cobranca = $asaas->Cobranca()->create(array $dadosCobranca); ``` ```php // Atualiza os dados da cobrança $cobranca = $asaas->Cobranca()->update(123, array $dadosCobranca); ``` ```php // Restaura cobrança removida $cobranca = $asaas->Cobranca()->restore(id); ``` ```php // Estorna cobrança $cobranca = $asaas->Cobranca()->estorno(id); ``` ```php // Confirmação em dinheiro $cobranca = $asaas->Cobranca()->confirmacao(id); ``` ```php // Desfazer confirmação de recebimento em dinheiro $cobranca = $asaas->Cobranca()->dezconfirmacao(id); ``` ```php // Deleta uma cobrança $asaas->Cobranca()->delete(123); ``` -------------------------------- ### Create Anticipation Source: https://github.com/codephix/asaas-sdk/blob/2.0.6/README.md Creates a new anticipation request. Requires payment ID, and optionally installment, documents, and agreement signature. ```php $Antecipacao = $Asaas->Antecipacao()->create($dados); ``` -------------------------------- ### Manage Checkout Sessions with Asaas SDK Source: https://context7.com/codephix/asaas-sdk/llms.txt Use these examples to create and cancel Asaas-hosted checkout sessions. Ensure the customer ID and payment details are correct. ```php Checkout()->create([ 'customer' => 'cus_000000001766', 'billingType' => 'UNDEFINED', 'value' => 199.90, 'dueDate' => '2024-12-31', 'description' => 'Compra na loja virtual', ]); // Cancelar sessão de checkout $asaas->Checkout()->cancel('checkout_abc123'); ``` -------------------------------- ### Manage Webhooks with Asaas SDK Source: https://context7.com/codephix/asaas-sdk/llms.txt Use this snippet to create, list, get, update, and delete webhooks. Ensure the Asaas SDK is initialized with your API token. ```php Webhook()->create([ 'url' => 'https://seusite.com.br/webhook/asaas', 'email' => 'ti@empresa.com', 'apiVersion' => 3, 'enabled' => true, 'interrupted' => false, 'authToken' => 'token_secreto_webhook', 'events' => [ 'PAYMENT_RECEIVED', 'PAYMENT_CONFIRMED', 'PAYMENT_OVERDUE', 'PAYMENT_REFUNDED', ], ]); // Listar webhooks configurados $lista = $asaas->Webhook()->getAll([]); // Buscar webhook por ID $wh = $asaas->Webhook()->getById('webhook_abc123'); // Atualizar webhook $asaas->Webhook()->update('webhook_abc123', ['enabled' => false]); // Deletar webhook $asaas->Webhook()->delete('webhook_abc123'); ``` -------------------------------- ### Assinatura Source: https://github.com/codephix/asaas-sdk/blob/2.0.6/README.md Operations for managing subscriptions, including retrieving lists, getting by ID, creating, updating, and deleting. ```APIDOC ## Assinatura ### Description Operations for managing subscriptions, including retrieving lists, getting by ID, creating, updating, and deleting. ### Methods - `getAll(filtros)`: Retrieves a list of subscriptions with optional filters. - `getById(id)`: Retrieves a specific subscription by its ID. - `getByCustomer(customerId)`: Retrieves a list of subscriptions for a given customer ID. - `create(dadosAssinatura)`: Creates a new subscription with provided data. - `update(id, dadosAssinatura)`: Updates an existing subscription. - `getNotaFiscal(id, parametros)`: Retrieves fiscal notes for a subscription. - `delete(id)`: Deletes a subscription. ### Subscription Types - **Boleto**: Subscription paid via bank slip. - **CREDIT_CARD**: Subscription paid via credit card. ``` -------------------------------- ### Manage Asaas Payment Links Source: https://github.com/codephix/asaas-sdk/blob/2.0.6/README.md Examples for retrieving and creating payment links. When creating a payment link, specify details like name, description, end date, value, billing type, and charge type. ```php // Retorna a listagem de cobranças $LinkPagamento = $asaas->LinkPagamento()->getAll(array $filtros); ``` ```php // Retorna os dados da cobrança de acordo com o Id $LinkPagamento = $asaas->LinkPagamento()->getById($id); ``` ```php // Insere uma nova cobrança / cobrança parcelada / cobrança split $LinkPagamento = $asaas->LinkPagamento()->create(array $dadosLink); ``` ```php $dadosLink = array( 'name' => 'Nome do link de pagamentos -> String required', 'description' => 'Descrição do link de pagamentos -> String', 'endDate' => 'Data de encerramento, a partir desta data o seu link de pagamentos será desativado automaticamente', 'value' => 'Valor do link de pagamentos, caso não informado o pagador poderá informar o quanto deseja pagar', /* Forma de pagamento permitida BOLETO -> Boleto Bancário CREDIT_CARD -> Cartão de Crédito UNDEFINED -> Perguntar ao Cliente */ 'billingType' => 'UNDEFINED', //required /* Forma de cobrança DETACHED -> Avulsa RECURRENT -> Assinatura INSTALLMENT -> Parcelamento */ 'chargeType' => 'DETACHED' //required /* Caso seja possível o pagamento via boleto bancário, define a quantidade de dias úteis que o seu cliente poderá pagar o boleto após gerado */ 'dueDateLimitDays' => '10', /* Periodicidade da cobrança, envio obrigatório caso a forma de cobrança selecionado seja Assinatura WEEKLY -> Semanal BIWEEKLY -> Quinzenal (2 semanas) MONTHLY -> Mensal QUARTERLY -> Trimestral SEMIANNUALLY -> Semestral YEARLY -> Anual 'subscriptionCycle' => 'MONTHLY', */ /* ``` -------------------------------- ### Get Fiscal Information Source: https://github.com/codephix/asaas-sdk/blob/2.0.6/README.md Retrieves the current fiscal information for the account. ```php //Recuperar Informações Fiscais $InformacoesFiscais = $asaas->InformacoesFiscais()->get(); ``` -------------------------------- ### Get Anticipation by ID Source: https://github.com/codephix/asaas-sdk/blob/2.0.6/README.md Retrieves the details of a specific anticipation using its unique identifier. ```php $Asaas = $Asaas->Antecipacao()->getBy($id); ``` -------------------------------- ### List Anticipations Source: https://github.com/codephix/asaas-sdk/blob/2.0.6/README.md Retrieves a list of anticipations. Supports filtering by payment, installment, status, offset, and limit. ```php $Antecipacao = $Asaas->Antecipacao()->getAll($filtro); ``` -------------------------------- ### Get Notifications By Customer Source: https://github.com/codephix/asaas-sdk/blob/2.0.6/README.md Retrieves all notifications associated with a specific customer ID. ```php // Retorna a listagem de notificações de acordo com o Id do Cliente $notificacoes = $asaas->Notificacao()->getByCustomer($customer_id); ``` -------------------------------- ### Manage Receivables Anticipation with Asaas SDK Source: https://context7.com/codephix/asaas-sdk/llms.txt Use this to request anticipation of receivables from charges or installments. Allows filtering by payment, status, and provides details on fees and net value. ```php Antecipacao()->getAll([ 'payment' => 'pay_626366773834', 'status' => 'PENDING', 'offset' => 0, 'limit' => 10, ]); ``` ```php // Solicitar antecipação de uma cobrança $antecipacao = $asaas->Antecipacao()->create([ 'agreementSignature' => 'João da Silva', 'payment' => 'pay_626366773834', 'installment' => null, ]); ``` ```php // Recuperar uma antecipação por ID $antecipacao = $asaas->Antecipacao()->getBy('9e7d8639-350f-45c0-8bc3-d4ddc5f4ebac'); ``` -------------------------------- ### Link de Pagamento — `LinkPagamento()` Source: https://context7.com/codephix/asaas-sdk/llms.txt Create public payment links that can be shared with customers, supporting one-time, installment, or recurring charges. ```APIDOC ## Link de Pagamento — `LinkPagamento()` ### Description Create public payment links that can be shared with customers, supporting one-time, installment, or recurring charges. ### Create One-Time Payment Link ```php $link = $asaas->LinkPagamento()->create([ 'name' => 'Venda de Curso Online', 'description' => 'Acesso vitalício ao curso PHP Avançado', 'endDate' => '2025-06-30', 'value' => 297.00, 'billingType' => 'UNDEFINED', 'chargeType' => 'DETACHED', 'dueDateLimitDays' => 7, 'maxInstallmentCount' => 6, ]); ``` ### Create Recurring Monthly Payment Link ```php $linkRecorrente = $asaas->LinkPagamento()->create([ 'name' => 'Plano Mensal', 'billingType' => 'CREDIT_CARD', 'chargeType' => 'RECURRENT', 'subscriptionCycle'=> 'MONTHLY', 'value' => 49.90, ]); ``` ### List Payment Links ```php $lista = $asaas->LinkPagamento()->getAll(['offset' => 0, 'limit' => 10]); ``` ### Get Payment Link by ID ```php $link = $asaas->LinkPagamento()->getById('pay_link_abc123'); ``` ### Update Payment Link ```php $asaas->LinkPagamento()->update('pay_link_abc123', ['endDate' => '2025-12-31']); ``` ### Restore Deleted Payment Link ```php $asaas->LinkPagamento()->restore('pay_link_abc123'); ``` ### Delete Payment Link ```php $asaas->LinkPagamento()->delete('pay_link_abc123'); ``` ``` -------------------------------- ### Antecipação de Recebíveis — `Antecipacao()` Source: https://context7.com/codephix/asaas-sdk/llms.txt Request anticipation of receivables from charges or installments, with status checks and applied fees. ```APIDOC ## Antecipação de Recebíveis — `Antecipacao()` ### Description Request anticipation of receivables from charges or installments, with status checks and applied fees. ### List Anticipations with Filters ```php $lista = $asaas->Antecipacao()->getAll([ 'payment' => 'pay_626366773834', // opcional: filtrar por cobrança 'status' => 'PENDING', // PENDING | APPROVED | DENIED 'offset' => 0, 'limit' => 10, ]); ``` ### Request Anticipation of a Charge ```php $antecipacao = $asaas->Antecipacao()->create([ 'agreementSignature' => 'João da Silva', 'payment' => 'pay_626366773834', 'installment' => null, ]); ``` ### Get Anticipation by ID ```php $antecipacao = $asaas->Antecipacao()->getBy('9e7d8639-350f-45c0-8bc3-d4ddc5f4ebac'); ``` ``` -------------------------------- ### Create and Manage Payment Links with Asaas SDK Source: https://context7.com/codephix/asaas-sdk/llms.txt Use this to create public payment links for one-time, installment, or recurring charges. Ensure correct `chargeType` and `billingType` are specified for the desired payment flow. ```php LinkPagamento()->create([ 'name' => 'Venda de Curso Online', 'description' => 'Acesso vitalício ao curso PHP Avançado', 'endDate' => '2025-06-30', 'value' => 297.00, 'billingType' => 'UNDEFINED', 'chargeType' => 'DETACHED', 'dueDateLimitDays' => 7, 'maxInstallmentCount' => 6, ]); ``` ```php // Criar link de assinatura mensal $linkRecorrente = $asaas->LinkPagamento()->create([ 'name' => 'Plano Mensal', 'billingType' => 'CREDIT_CARD', 'chargeType' => 'RECURRENT', 'subscriptionCycle'=> 'MONTHLY', 'value' => 49.90, ]); ``` ```php // Listar links de pagamento $lista = $asaas->LinkPagamento()->getAll(['offset' => 0, 'limit' => 10]); ``` ```php // Buscar por ID $link = $asaas->LinkPagamento()->getById('pay_link_abc123'); ``` ```php // Atualizar link $asaas->LinkPagamento()->update('pay_link_abc123', ['endDate' => '2025-12-31']); ``` ```php // Restaurar link removido $asaas->LinkPagamento()->restore('pay_link_abc123'); ``` ```php // Deletar link $asaas->LinkPagamento()->delete('pay_link_abc123'); ``` -------------------------------- ### Cobrança - Create Source: https://context7.com/codephix/asaas-sdk/llms.txt Creates individual, installment, or split payment collections. Supports bank slips, credit cards, and Pix. Includes options for fines, interest, and discounts. ```APIDOC ## Cobrança - Create ### Description Creates individual, installment, or split payment collections. Supports bank slips, credit cards, and Pix. Includes options for fines, interest, and discounts. ### Method `create(array $data)` ### Parameters #### Request Body - **customer** (string) - Required - The ID of the customer associated with the payment. - **billingType** (string) - Required - The type of billing (BOLETO, CREDIT_CARD, PIX, UNDEFINED). - **value** (float) - Required - The total value of the payment. - **dueDate** (string) - Required - The due date for the payment (YYYY-MM-DD). - **description** (string) - Optional - A description for the payment. - **externalReference** (string) - Optional - An external reference ID for the payment. - **fine** (object) - Optional - Fine details, including `value` (float). - **interest** (object) - Optional - Interest details, including `value` (float) per month. - **discount** (object) - Optional - Discount details, including `value` (float) and `dueDateLimitDays` (integer). - **installmentCount** (integer) - Optional - Number of installments for credit card payments. - **installmentValue** (float) - Optional - The value of each installment for credit card payments. ### Request Example ```php // Criar cobrança simples via boleto $cobranca = $asaas->Cobranca()->create([ 'customer' => 'cus_000000001766', 'billingType' => 'BOLETO', 'value' => 150.00, 'dueDate' => '2024-12-31', 'description' => 'Produto XYZ', 'externalReference' => 'pedido-001', 'fine' => ['value' => 2], 'interest' => ['value' => 1], 'discount' => ['value' => 5, 'dueDateLimitDays' => 3], ]); // Cobrança parcelada no cartão $parcelada = $asaas->Cobranca()->create([ 'customer' => 'cus_000000001766', 'billingType' => 'CREDIT_CARD', 'value' => 600.00, 'dueDate' => '2024-12-31', 'installmentCount' => 3, 'installmentValue' => 200.00, 'description' => 'Notebook parcelado', ]); ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier for the created payment. - **status** (string) - The current status of the payment (e.g., PENDING, RECEIVED). - **invoiceUrl** (string) - URL to the payment invoice. - **bankSlipUrl** (string) - URL to the bank slip if applicable. ### Response Example ```json { "id": "pay_626366773834", "status": "PENDING", "invoiceUrl": "https://...", "bankSlipUrl": "https://..." } ``` ``` ```APIDOC ## Cobrança - Get By Customer ### Description Retrieves a list of all payment collections associated with a specific customer. ### Method `getByCustomer(string $customerId)` ### Parameters #### Path Parameters - **customerId** (string) - Required - The ID of the customer whose payments are to be retrieved. ### Response #### Success Response (200) - **array** - An array of payment objects associated with the customer. ### Response Example ```php $cobranças = $asaas->Cobranca()->getByCustomer('cus_000000001766'); ``` ``` ```APIDOC ## Cobrança - Get By Subscription ### Description Retrieves a list of all payment collections associated with a specific subscription. ### Method `getBySubscription(string $subscriptionId)` ### Parameters #### Path Parameters - **subscriptionId** (string) - Required - The ID of the subscription whose payments are to be retrieved. ### Response #### Success Response (200) - **array** - An array of payment objects associated with the subscription. ### Response Example ```php $cobranças = $asaas->Cobranca()->getBySubscription('sub_abc123'); ``` ``` ```APIDOC ## Cobrança - Get By ID ### Description Retrieves a specific payment collection by its unique ID. ### Method `getById(string $paymentId)` ### Parameters #### Path Parameters - **paymentId** (string) - Required - The unique ID of the payment collection to retrieve. ### Response #### Success Response (200) - **object** - The payment collection object. ### Response Example ```php $cobranca = $asaas->Cobranca()->getById('pay_626366773834'); ``` ``` ```APIDOC ## Cobrança - Get Info Boleto ### Description Retrieves the bank slip information for a specific payment collection. ### Method `getInfoBoleto(string $paymentId)` ### Parameters #### Path Parameters - **paymentId** (string) - Required - The ID of the payment collection for which to get bank slip info. ### Response #### Success Response (200) - **object** - An object containing bank slip details, including the digitable line. ### Response Example ```php $boleto = $asaas->Cobranca()->getInfoBoleto('pay_626366773834'); ``` ``` ```APIDOC ## Cobrança - Estorno ### Description Initiates a refund for a payment collection. ### Method `estorno(string $paymentId)` ### Parameters #### Path Parameters - **paymentId** (string) - Required - The ID of the payment collection to refund. ### Response #### Success Response (200) - **object** - A confirmation object indicating the refund was processed. ### Response Example ```php $asaas->Cobranca()->estorno('pay_626366773834'); ``` ``` ```APIDOC ## Cobrança - Confirmar Recebimento em Dinheiro ### Description Confirms that a payment has been received in cash for a specific collection. ### Method `confirmacao(string $paymentId, array $data)` ### Parameters #### Path Parameters - **paymentId** (string) - Required - The ID of the payment collection to confirm. #### Request Body - **paymentDate** (string) - Required - The date the payment was received (YYYY-MM-DD). - **value** (float) - Required - The amount received. - **notifyCustomer** (boolean) - Optional - Whether to notify the customer about the confirmation. ### Response #### Success Response (200) - **object** - A confirmation object indicating the cash payment was recorded. ### Response Example ```php $asaas->Cobranca()->confirmacao('pay_626366773834', [ 'paymentDate' => '2024-12-20', 'value' => 150.00, 'notifyCustomer' => true, ]); ``` ``` ```APIDOC ## Cobrança - Desfazer Confirmação em Dinheiro ### Description Reverts the confirmation of a cash payment for a specific collection. ### Method `dezconfirmacao(string $paymentId, array $data)` ### Parameters #### Path Parameters - **paymentId** (string) - Required - The ID of the payment collection to de-confirm. #### Request Body - **(empty array)** - No specific fields required for this operation in the example. ### Response #### Success Response (200) - **object** - A confirmation object indicating the cash payment de-confirmation was processed. ### Response Example ```php $asaas->Cobranca()->dezconfirmacao('pay_626366773834', []); ``` ``` ```APIDOC ## Cobrança - Restaurar ### Description Restores a payment collection that was previously marked as deleted. ### Method `restore(string $paymentId)` ### Parameters #### Path Parameters - **paymentId** (string) - Required - The ID of the payment collection to restore. ### Response #### Success Response (200) - **object** - A confirmation object indicating the payment collection was restored. ### Response Example ```php $asaas->Cobranca()->restore('pay_626366773834'); ``` ``` ```APIDOC ## Cobrança - Deletar ### Description Deletes a payment collection. ### Method `delete(string $paymentId)` ### Parameters #### Path Parameters - **paymentId** (string) - Required - The ID of the payment collection to delete. ### Response #### Success Response (200) - **object** - A confirmation object indicating the payment collection was deleted. ### Response Example ```php $asaas->Cobranca()->delete('pay_626366773834'); ``` ``` -------------------------------- ### Manage Asaas Pix Payments Source: https://github.com/codephix/asaas-sdk/blob/2.0.6/README.md Examples for creating and querying Pix payments. Pix QR codes are generated in base64 and are valid until 23:59 on the same day. Querying payment status is recommended periodically. ```php $Pix = $asaas->Pix()->create($id_cobranca); if($Pix->success){ echo ''; } ``` ```php //Consulta se foi efetivado o pagamento via Pix, (Obs: Recomendo um post a cada 30s, ou um botão para confirmação do pagamento, assim não sobrecarregado o seu sistema e nem o do asaas ;) ). $retorno = $asaas->Pix()->get($id_cobranca); ``` -------------------------------- ### Get All Serasa Consultations Source: https://github.com/codephix/asaas-sdk/blob/2.0.6/README.md Retrieves a list of all Serasa consultations. Supports filtering by creation date range, offset, and limit. The limit for the number of elements is 100. ```php $filtro = array( 'startDate' => 'Filtrar a partir da data de criação -> String', 'endDate' => 'Filtrar até uma data de criação -> String', 'offset' => 'Elemento inicial da lista -> Number', 'limit' => 'Número de elementos da lista (max: 100) -> Number', ); $ConsultaSerasa = $Asaas->ConsultaSerasa()->getAll($filtro); ``` -------------------------------- ### Initialize Asaas Client Source: https://github.com/codephix/asaas-sdk/blob/2.0.6/README.md Instantiate the Asaas client with your access token. Ensure you have autoloading set up. ```php Notificacao()->getAll(array $filtros); ``` -------------------------------- ### Initialize Asaas SDK Client Source: https://context7.com/codephix/asaas-sdk/llms.txt Instantiate the main Asaas client class with your API token. Supports both production and sandbox environments. ```php SubContas()->create([ 'name' => 'Loja Parceira LTDA', 'email' => 'loja@parceira.com', 'loginEmail' => 'loja@parceira.com', 'cpfCnpj' => '12345678000195', 'mobilePhone' => '47999990000', 'address' => 'Rua do Comércio', 'addressNumber' => '200', 'province' => 'Centro', 'postalCode' => '89010-000', 'companyType' => 'LIMITED', // MEI | LIMITED | INDIVIDUAL | ASSOCIATION 'site' => 'https://parceira.com', ]); // Listar subcontas $lista = $asaas->SubContas()->getAll(['offset' => 0, 'limit' => 10]); // Buscar subconta por ID $subconta = $asaas->SubContas()->getByid('acc_abc123'); ``` -------------------------------- ### Get All Invoices Source: https://github.com/codephix/asaas-sdk/blob/2.0.6/README.md Retrieves a list of invoices with optional filtering parameters. ```php $dados = array( 'installment' => 'Filtrar pelo identificador único do parcelamento -> String', 'externalReference' => 'Identificador da nota fiscal no seu sistema -> String', 'status' => 'Filtrar por situação -> Enum', 'offset' => 'Elemento inicial da lista -> Number', 'limit' => 'Número de elementos da lista (max: 100) -> Number', ); $NotaFiscal = $asaas->NotaFiscal()->getAll($dados); ``` -------------------------------- ### Get Notification By ID Source: https://github.com/codephix/asaas-sdk/blob/2.0.6/README.md Retrieves a specific notification using its unique ID. ```php // Retorna os dados da notificação de acordo com o Id $notificacao = $asaas->Notificacao()->getById(123); ``` -------------------------------- ### Get Subscription by ID Source: https://github.com/codephix/asaas-sdk/blob/2.0.6/README.md Retrieves the details of a specific subscription using its unique identifier. ```php $assinatura = $asaas->Assinatura()->getById(123); ``` -------------------------------- ### Pix - Get Key By ID Source: https://context7.com/codephix/asaas-sdk/llms.txt Retrieves details of a specific Pix address key by its ID. ```APIDOC ## Pix - Get Key By ID ### Description Retrieves details of a specific Pix address key by its ID. ### Method `getKeys(string $keyId)` ### Parameters #### Path Parameters - **keyId** (string) - Required - The ID of the Pix address key to retrieve. ### Response #### Success Response (200) - **object** - The Pix address key object. ### Response Example ```php $chave = $asaas->Pix()->getKeys('key_abc123'); ``` ``` -------------------------------- ### Create Subscription (Boleto) Source: https://github.com/codephix/asaas-sdk/blob/2.0.6/README.md Creates a new subscription to be paid via Boleto. Requires customer ID, value, cycle, and other relevant details. ```php $dadosAssinatura = array( "customer" => "{CUSTOMER_ID}", "billingType" => "BOLETO", "nextDueDate" => "2017-05-15", "value" => 19.9, "cycle" => "MONTHLY", "description" => "Assinatura Plano Pró", "discount" => array( "value" => 10, "dueDateLimitDays" => 0 ), "fine" => array( "value": 1 ), "interest" => array( "value": 2 ) ); $assinatura = $asaas->Assinatura()->create(array $dadosAssinatura); ``` -------------------------------- ### Assinaturas — `Assinatura()` Source: https://context7.com/codephix/asaas-sdk/llms.txt Create and manage recurring charges (subscriptions) with support for bank slips, credit cards, and different periodicities. ```APIDOC ## Assinaturas — `Assinatura()` ### Description Create and manage recurring charges (subscriptions) with support for bank slips, credit cards, and different periodicities. ### Create Subscription (Boleto) ```php $assinatura = $asaas->Assinatura()->create([ 'customer' => 'cus_000000001766', 'billingType' => 'BOLETO', 'nextDueDate' => '2024-12-01', 'value' => 99.90, 'cycle' => 'MONTHLY', 'description' => 'Plano Profissional', 'discount' => ['value' => 10, 'dueDateLimitDays' => 0], 'fine' => ['value' => 1], 'interest' => ['value' => 2], ]); ``` ### Create Subscription (Credit Card) ```php $assinatura = $asaas->Assinatura()->create([ 'customer' => 'cus_000000001766', 'billingType' => 'CREDIT_CARD', 'nextDueDate' => '2024-12-01', 'value' => 99.90, 'cycle' => 'MONTHLY', 'description' => 'Plano Profissional', 'creditCard' => [ 'holderName' => 'João da Silva', 'number' => '5162306219378829', 'expiryMonth' => '05', 'expiryYear' => '2026', 'ccv' => '318', ], 'creditCardHolderInfo' => [ 'name' => 'João da Silva', 'email' => 'joao@email.com', 'cpfCnpj' => '24971563792', 'postalCode' => '89223-005', 'addressNumber' => '100', 'phone' => '4738010919', 'mobilePhone' => '47998781877', ], ]); ``` ### List All Subscriptions ```php $lista = $asaas->Assinatura()->getAll(['offset' => 0, 'limit' => 20]); ``` ### List Subscriptions by Customer ```php $lista = $asaas->Assinatura()->getByCustomer('cus_000000001766'); ``` ### List Payments for a Subscription ```php $pagamentos = $asaas->Assinatura()->getByPayment('sub_abc123'); ``` ### Update Subscription ```php $asaas->Assinatura()->update('sub_abc123', ['value' => 119.90]); ``` ### List Invoices for a Subscription ```php $notas = $asaas->Assinatura()->getNotaFiscal('sub_abc123', ['status' => 'AUTHORIZED']); ``` ### Delete Subscription ```php $asaas->Assinatura()->delete('sub_abc123'); ``` ``` -------------------------------- ### Simulate and Pay Bills with Asaas SDK Source: https://context7.com/codephix/asaas-sdk/llms.txt Use `PagarConta()` to simulate and create bill payments. Supports scheduling, discounts, and provides transaction details upon completion. ```php PagarConta()->simulate([ 'identificationField' => '03399.77779 29900.000000 04751.101017 1 81510000002990', // OU: 'barCode' => '03399777792990000000047511010178151000000299', ]); // Pagar uma conta agendada $pagamento = $asaas->PagarConta()->create([ 'identificationField' => '03399.77779 29900.000000 04751.101017 1 81510000002990', 'scheduleDate' => '2024-12-20', 'description' => 'Conta de luz - Dez/2024', 'discount' => 0, 'value' => 149.90, 'dueDate' => '2024-12-20', ]); /* Retorno: { "object": "bill", "id": "f1bce822-...", "status": "PENDING", "value": 149.90, "dueDate": "2024-12-20", "transactionReceiptUrl": "https://www.asaas.com/comprovantes/00016578" } */ // Listar pagamentos de conta $lista = $asaas->PagarConta()->getAll(['offset' => 0, 'limit' => 20]); // Recuperar pagamento por ID $pag = $asaas->PagarConta()->getBy('f1bce822-6f37-4905-8de8-f1af9f2f4bab'); ``` -------------------------------- ### Get Subscriptions by Customer ID Source: https://github.com/codephix/asaas-sdk/blob/2.0.6/README.md Retrieves all subscriptions associated with a particular customer. Requires the customer's ID. ```php $assinaturas = $asaas->Assinatura()->getByCustomer($customer_id); ``` -------------------------------- ### Pix - Create Static QR Code Source: https://context7.com/codephix/asaas-sdk/llms.txt Creates a static Pix QR Code for a direct payment, specifying the address key, description, and value. ```APIDOC ## Pix - Create Static QR Code ### Description Creates a static Pix QR Code for a direct payment, specifying the address key, description, and value. ### Method `qrCodeStatic(array $params)` ### Parameters #### Request Body - **addressKey** (string) - Required - The Pix address key to associate with the QR Code. - **description** (string) - Optional - A description for the payment. - **value** (float) - Required - The value of the payment. ### Response #### Success Response (200) - **object** - An object containing details of the static QR Code. ### Response Example ```php $qrCode = $asaas->Pix()->qrCodeStatic([ 'addressKey' => 'joao@email.com', 'description' => 'Pagamento avulso', 'value' => 50.00, ]); ``` ``` -------------------------------- ### Client Management Source: https://context7.com/codephix/asaas-sdk/llms.txt This section details how to manage clients using the Asaas SDK, including creating, retrieving, updating, restoring, and deleting client records. ```APIDOC ## Client Management ### Description Gerencia o cadastro de clientes (pessoas físicas ou jurídicas) na conta Asaas, com suporte a criação, consulta, atualização, restauração e exclusão. ### Methods #### Create Client **Description:** Creates a new client record. **Usage:** `$asaas->Cliente()->create(array $data) #### Get All Clients **Description:** Retrieves a list of all clients with optional filtering. **Usage:** `$asaas->Cliente()->getAll(array $filters = []) #### Get Client By ID **Description:** Retrieves a specific client by their unique ID. **Usage:** `$asaas->Cliente()->getById(string $clientId) #### Get Client By Email **Description:** Retrieves a client by their email address. **Usage:** `$asaas->Cliente()->getByEmail(string $email) #### Get Client By CPF/CNPJ **Description:** Retrieves a client by their CPF or CNPJ. **Usage:** `$asaas->Cliente()->getByCpfCnpj(string $cpfCnpj) #### Update Client **Description:** Updates an existing client's information. **Usage:** `$asaas->Cliente()->update(string $clientId, array $data) #### Restore Client **Description:** Restores a previously deleted client. **Usage:** `$asaas->Cliente()->restore(string $clientId) #### Delete Client **Description:** Deletes a client record. **Usage:** `$asaas->Cliente()->delete(string $clientId) ### Request Example (Create Client) ```php { "name": "João da Silva", "cpfCnpj": "24971563792", "email": "joao@email.com", "phone": "4738010919", "mobilePhone": "47998781877", "address": "Rua das Flores", "addressNumber": "100", "province": "Centro", "postalCode": "89223-005" } ``` ### Response Example (Get Client) ```json { "id": "cus_000000001766", "name": "João da Silva", "cpfCnpj": "24971563792", "email": "joao@email.com", "phone": "4738010919", "mobilePhone": "47998781877", "address": "Rua das Flores", "addressNumber": "100", "province": "Centro", "postalCode": "89223-005" } ``` ``` -------------------------------- ### Create Subscription (Credit Card) Source: https://github.com/codephix/asaas-sdk/blob/2.0.6/README.md Creates a new subscription to be paid via Credit Card. Requires customer ID, payment details, and card information. ```php $dadosAssinatura = array( "customer" => "{CUSTOMER_ID}", "billingType" => "CREDIT_CARD", "nextDueDate" => "2017-05-15", "value" => 19.9, "cycle" => "MONTHLY", "description" => "Assinatura Plano Pró", "creditCard" => array( "holderName" => "marcelo h almeida", "number" => "5162306219378829", "expiryMonth" => "05", "expiryYear" => "2021", "ccv" => "318" ), "creditCardHolderInfo" => array( "name" => "Marcelo Henrique Almeida", "email" => "marcelo.almeida@gmail.com", "cpfCnpj" => "24971563792", "postalCode" => "89223-005", "addressNumber" => "277", "addressComplement" => null, "phone" => "4738010919", "mobilePhone" => "47998781877" ) ); $assinatura = $asaas->Assinatura()->create(array $dadosAssinatura); ```