PHP code example of broxman / fbapi

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

    

broxman / fbapi example snippets



try {
    $fbl = new \Broxman\Fbapi\Fbapi('https://secure.fusebill.com/v1', 'APIKEY');
    // ...
}
catch (Exception $e){
    echo $e->getMessage() . "\n";
}


    $Customer = $fbl->postCustomers(null, null, [
        'firstName' => 'FirstName',
        'lastName' => 'LastName',
        'primaryEmail' => '[email protected]',
        'primaryPhone' => '0000000',
        'reference' => '123456',
        'customerReference' => [
            'reference3' => 'Additional Reference Field',
        ],
    ]);
    print_r($Customer);


    $Customer = $fbl->postCustomerActivation(null, null, [
        "customerId" => 123456,
        "activateAllSubscriptions" => true,
        "activateAllDraftPurchases" => true,
        "temporarilyDisableAutoPost" => false,
    ]);
    print_r($Customer);


    $Customer = $fbl->putcustomers(null, null, [
        'id' => 123456,
        'firstName' => 'FirstName',
        'lastName' => 'LastName',
        'primaryEmail' => '[email protected]',
        'primaryPhone' => '0000000',
        'reference' => '123456',
        'customerReference' => [
            'reference3' => 'Additional Reference Field',
        ],
        'status' => 'Active',
    ]);
    print_r($Customer);


    $Customer = $fbl->getcustomers(123456);
    print_r($Customer);


    $Purchase = $fbl->postPurchases(null, null, [
        'customerId' => 123456,
        'productId' => 123,
        'name' => 'Package Name',
        'quantity' => 1,
    ]);
    print_r($Purchase);


    $Purchase = $fbl->postPurchases('Purchase',[
//        'buyNow' => 'true',
        'preview' => 'false',
        'showZeroDollarCharges' => 'false',
        'temporarilyDisableAutoPost' => 'false',
    ], [
        'customerId' => 123456,
        'purchaseIds' => [
            12345,
        ],
        'invoiceCollectOptions' => [
            "useAnyAvailableFundsFirst" => 'true',
            "rollbackOnFailedPayment" => 'true',
            "paymentMethod" => "UseDefaultPaymentMethod",
//            "paymentMethodId" => '1234',
        ],
    ]);
    print_r($Purchase);


    $fbl->deletePurchases(12345);


    $Invoices = $fbl->getCustomers([123456, 'Invoices']);
    foreach ($Invoices as $j => $Invoice) {
        echo "{$j}. {$Invoice->id}\n";
    }


    $Invoice = $fbl->getInvoices(1234567);
    print_r($Invoice);


    $Invoicepdf = $fbl->getInvoices(['pdf', 1234567]);
    file_put_contents('invoice.pdf', $Invoicepdf);


    // Create the handler
    $json_handler = new \Httpful\Handlers\JsonHandler(array('decode_as_array' => true));
    // Register it with Httpful
    \Httpful\Httpful::register('application/json', $json_handler);