use AbacatePay\Clients\BillingClient;
use AbacatePay\Resources\Billing;
use AbacatePay\Resources\Billing\Product;
use AbacatePay\Resources\Billing\Metadata as BillingMetadata;
use AbacatePay\Enums\Billing\Methods;
use AbacatePay\Enums\Billing\Frequencies;
use AbacatePay\Resources\Customer;
use AbacatePay\Resources\Customer\Metadata as CustomerMetadata;
$billingClient = new BillingClient();
// Criando uma Cobrança Única
$billing = $billingClient->create(new Billing([
'frequency' => Frequencies::ONE_TIME,
'methods' => [Methods::PIX],
'products' => [
new Product([
'external_id' => 'PRO-PLAN',
'name' => 'Pro plan',
'description' => 'Pro plan subscription',
'quantity' => 1,
'price' => 1000 // Preço em centavos
])
],
'metadata' => new BillingMetadata([
'return_url' => 'https://yoursite.com/app',
'completion_url' => 'https://yoursite.com/payment/success'
]),
'customer' => new Customer([
'metadata' => new CustomerMetadata([
'name' => 'Customer Name',
'cellphone' => '11999999999',
'email' => 'customer@example.com',
'tax_id' => '09240529020'
])
])
]));
echo $billing->url; // URL de pagamento para seu cliente