PHP code example of phpay-io / phpay

1. Go to this page and download the library: Download phpay-io/phpay 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/ */

    

phpay-io / phpay example snippets


composer 

/**
 * instance with gateway inject
 * @var AsaasGateway $phpay
 */
$phpay = (new PHPay(new AsaasGateway(TOKEN_ASAAS_SANDBOX)));

/**
 * instance with gateway inject and resource call
 *
 * @var Charge $phpay
 */
$phpay = (new PHPay(new AsaasGateway(TOKEN_ASAAS_SANDBOX)))->charge();

/**
 * create charge
 */
$phpay
    ->setCharge($charge)
    ->setCustomer($customer)
    ->create();

/**
 * find charge
 */
$phpay->find($chargeId);

/**
 * get all charges
 */
$phpay->getAll();

/**
 * get all charges with filters
 */
$phpay
    ->setQueryParams(['limit' => 2])
    ->getAll();

/**
 * update charge
 */
$phpay->update($chargeId, $data);

/**
 * destroy charge
 */
$phpay->destroy($chargeId);

/**
 * restore charge
 */
$phpay->restore($chargeId);

/**
 * get status charge
 */
$phpay->getStatus($chargeId);

/**
 * get digitable line charge
 */
$phpay->getDigitableLine($chargeId);

/**
 * get qrcode charge
 */
$phpay->getQrCodePix($chargeId);

/**
 * confirm receipt charge
 */
$phpay->confirmReceipt($chargeId, [
    'paymentDate'    => date('Y-m-d'),
    'value'          => 100.00,
    'notifyCustomer' => true,
]);

/**
 * undo confirm receipt
 */
$phpay->undoConfirmReceipt($chargeId);


/**
 * @var Subscription $phpay
 */
$phpay = PHPay::gateway(new AsaasGateway(TOKEN_ASAAS_SANDBOX))->subscription();

/**
 * create a new subscription
 */
$phpay->setCustomer($customer)->create([
    'billingType' => 'BOLETO',
    'value'       => 100,
    'nextDueDate' => '2025-04-09',
]);