adrianovcar/asaas-php-sdk

Asaas.com PHP API v3 包装器

v2.5.1 2024-07-10 20:03 UTC

This package is auto-updated.

Last update: 2024-09-10 20:20:05 UTC


README

Latest Version on Packagist Total Downloads

用于集成 www.asaas.com 服务API的SDK

除了提供支付网关服务外,ASAAS还提供其他金融服务,包括作为BaaS(银行即服务)。此SDK的开发重点在于最频繁的操作,请查看功能

  • 客户

    • 检查客户是否“欠款” (新)
    • 获取所有客户“欠款”的付款 (新)
    • 按id获取
    • 按客户电子邮件获取
    • 列出所有客户付款
    • 列出所有
    • 创建
    • 更新
    • 删除
  • 付款

    • 按id获取
    • 通过客户id获取所有付款
    • 通过订阅id获取所有付款
    • 生成付款的QrCode
    • 列出所有
    • 创建新的付款(收据、信用卡或PIX)
    • 更新
    • 删除
  • 订阅

    • 检查订阅是否“欠款” (新)
    • 获取所有订阅“欠款”的付款 (新)
    • 评估下一个到期日期(基于比例余额) (新)
    • 更改计划(具有升级和降级功能) (新)
    • 按客户id获取
    • 按订阅id获取
    • 通过订阅id获取所有付款
    • 列出所有
    • 创建
    • 更新
    • 删除
  • PIX-KEY

    • 创建
    • 列表
    • 按id获取
    • 删除
  • PIX-QRCODE

    • 创建
  • 城市

    • 列表
    • 按id获取城市
  • 通知

    • 通知实体已弃用,将在未来几周内改进

安装

可以使用composer依赖管理器安装此库。要安装库及其所有依赖项,请运行

composer require adrianovcar/asaas-php-sdk

提示

此库旨在简化与ASAAS的通信,为您的SaaS创建自己的业务规则,并将此库与付款结合使用。

AsaaS拥有强大的支付和订阅状态通知工具,它将通过webhooks与您的应用程序通信。您需要在ASAAS中直接配置要指向webhook请求的端点(此处配置

示例

<?php

require 'vendor/autoload.php';

use Adrianovcar\Asaas\Adapter\GuzzleHttpAdapter;
use Adrianovcar\Asaas\Asaas;

$adapter = new GuzzleHttpAdapter('your_access_token');

// Instantiate the Asaas client using the previously created adapter instance.
$asaas = new Asaas($adapter);

端点

如果您想在测试模式下使用API,只需在客户端实例化时指定环境即可。

// Note: If the second parameter is not informed, the API enters production mode
$asaas = new Asaas($adapter, 'sandbox|production');

客户

// Returns the list of customers according to the filter used (https://docs.asaas.com/reference/listar-clientes)
$clientes = $asaas->customer()->getAll(array $filtros);

// Returns the customer's data according to the Id
$cobranca = $asaas->customer()->getById('cus_123123');

// Returns the customer's data according to the email
$clientes = $asaas->customer()->getByEmail('email@mail.com');

// Inserts a new customer
$cobranca = $asaas->customer()->create(array $dadosCliente);

// Updates the customer's data
$cobranca = $asaas->customer()->update('cus_123123', array $dadosCliente);

// Deletes a customer
$asaas->customer()->delete('cus_123123');

付款

// Returns the list of payments
$cobrancas = $asaas->payment()->getAll(array $filtros);

// Returns the payment data according to the Id
$cobranca = $asaas->payment()->getById('pay_123123');

// Returns the list of payments according to the Customer Id
$cobrancas = $asaas->payment()->getByCustomer($customer_id);

// Returns the list of payments according to the Subscriptions Id
$cobrancas = $asaas->payment()->getBySubscription($subscription_id);

// Inserts a new payment
$cobranca = $asaas->payment()->create(array $dadosCobranca);

// Updates the payment data
$cobranca = $asaas->payment()->update('pay_123123', array $dadosCobranca);

// Deletes a payment
$asaas->payment()->delete('pay_123123');

订阅

// Returns the list of subscriptions
$assinaturas = $asaas->subscription()->getAll(array $filtros);

// Returns the subscription data according to the Id
$assinatura = $asaas->subscription()->getById('sub_123123');

// Returns the list of subscriptions according to the Customer Id
$assinaturas = $asaas->subscription()->getByCustomer($customer_id);

// Inserts a new subscription
$assinatura = $asaas->subscription()->create(array $dadosAssinatura);

// Updates the subscription data
$assinatura = $asaas->subscription()->update('sub_123123', array $dadosAssinatura);

// Deletes a subscription
$asaas->subscription()->delete('sub_123123');

通知

// Returns the list of notifications
$notificacoes = $asaas->notification()->getAll(array $filtros);

// Returns the notification data according to the Id
$notificacao = $asaas->notification()->getById('not_123123');

// Returns the list of notifications according to the Customer Id
$notificacoes = $asaas->notification()->getByCustomer($customer_id);

// Inserts a new notification
$notificacao = $asaas->notification()->create(array $dadosNotificacao);

// Updates the notification data
$notificacao = $asaas->notification()->update('not_123123', array $dadosNotificacao);

// Deletes a notification
$asaas->notification()->delete('not_123123');

城市

// Returns the list of cities
$cidades = $asaas->city()->getAll(array $filtros);

// Returns the city data according to the Id
$action123 = $asaas->city()->getById(123);

官方文档

ASAAS文档非常全面。有关每个端点的详细信息,请参阅官方文档

致谢

变更日志

请参阅此SDK的更新变更日志

支持

要报告新的错误,请在github上打开新的问题

许可证

在MIT许可证下分发。复制、粘贴、修改、改进和分享无需担忧 ;)