PHP code example of murillofrazaocunha / hbank-sdk-php

1. Go to this page and download the library: Download murillofrazaocunha/hbank-sdk-php 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/ */

    

murillofrazaocunha / hbank-sdk-php example snippets




use HBank\Api\PaymentService;

$apiKey = 'sua-chave-de-api'; // Substitua pela sua chave de API
$paymentService = new PaymentService($apiKey);

use HBank\Api\PaymentService;
use HBank\Models\Payment;

ve de API
$paymentService = new PaymentService($apiKey);

try {
    // Dados para criar o link de pagamento
    $paymentData = Payment::createPaymentLinkRequest(
        '100.00', // Valor do pagamento
        'Teste',  // Descrição do pagamento
        'https://hightpanel.com.br', // URL de notificação
        'https://hightpanel.com.br', // URL de redirecionamento
        ['TESTE' => '20%'] // Cupons de desconto
    );

    // Cria o link de pagamento
    $paymentLink = $paymentService->createPaymentLink($paymentData);
    echo "Link de pagamento criado: " . $paymentLink['link'] . "\n";

    // Verifica o status do pagamento
    $paymentStatus = $paymentService->getPaymentStatus($paymentLink['id']);
    echo "Status do pagamento: " . $paymentStatus['pstatus'] . "\n";
} catch (\Exception $e) {
    echo "Erro: " . $e->getMessage() . "\n";
}

try {
    $paymentLink = $paymentService->createPaymentLink($paymentData);
    echo "Link de pagamento criado: " . $paymentLink['link'] . "\n";
} catch (\Exception $e) {
    echo "Erro: " . $e->getMessage() . "\n";
}