PHP code example of basementdevs / abacatepay-php-sdk
1. Go to this page and download the library: Download basementdevs/abacatepay-php-sdk 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/ */
basementdevs / abacatepay-php-sdk example snippets
$request = new CreatePixQrCodeRequest(
10000, 3600, 'Pagamento de assinatura',
new PixCustomerRequest('Maria', '+55...', '[email protected] ', '123'),
new PixMetadataRequest('order-abc-123')
);
$pixQr = CreatePixQrCodeRequest::builder()
->amount(10000)
->expiresIn(3600)
->description('Pagamento de assinatura')
->customer(
PixCustomerRequest::builder()
->name('Maria Oliveira')
->cellphone('+5511988887777')
->email('[email protected] ')
->taxId('12345678900')
->build()
)
->metadata(
PixMetadataRequest::builder()
->externalId('order-abc-123')
->build()
)
->build();
$client = new AbacatePayClient('test_key');
$product = ProductRequest::builder()
->externalId('prod-123')
->name('Garrafa Térmica 500ml')
->description('Mantém bebidas quentes ou frias por até 8h')
->quantity(2)
->price(8900)
->build();
$response = $client->billing()
->create(
CreateBillingRequest::multipleTimes()
->creditCard()
->completionUrl('https://exemplo.com/sucesso')
->returnUrl('https://exemplo.com/retorno')
->forCustomerId('cust_abc123')
->externalId('billing-001')
->addProduct($product)
->build()
);
$createCustomer = CreateCustomerRequest::builder()
->name('João Silva')
->cellphone('+5511999999999')
->email('[email protected] ')
->taxId('12345678900')
->build();
$response = $client->customers()->create($createCustomer);
$pixCustomer = PixCustomerRequest::builder()
->name('Maria Oliveira')
->cellphone('+5511988887777')
->email('[email protected] ')
->taxId('12345678900')
->build();
$metadata = PixMetadataRequest::builder()
->externalId('order-abc-123')
->build();
$pixQr = CreatePixQrCodeRequest::builder()
->amount(10000)
->expiresIn(3600)
->description('Pagamento de assinatura')
->customer($pixCustomer)
->metadata($metadata)
->build();
$response = $client->pix()->createQrCode($pixQr);
$pix = WithdrawPixRequest::builder()
->type(WithdrawPixTypeEnum::Email)
->key('[email protected] ')
->build();
$request = CreateWithdrawRequest::builder()
->externalId('withdraw-001')
->method(WithdrawMethodsEnum::Pix)
->amount(15000)
->pix($pix)
->description('Saque de teste')
->build();
$response = $client->withdraw()->create($request);
bash
composer