S

Developer Docs

Discover how to get the most out of Divhunt for your unique needs, and explore the possibilities of building plugins to make Divhunt a better tool for everyone.

Balance

Get Balance

Get client organization total balance

sv_billing.Fn('balance.get').then((balance) => 
{
    alert(balance);
});

Check Balance

Check if client organization has enough balance for purchase

sv_billing.Fn('balance.check', 0).then((check) => 
{
    if(check.has)
    {
        // Has balance
    }
    else 
    {
        // Missing balance: ${check.missing}
    }
});

Add Balance

Request from user to add funds to balance using Stripe checkout method

let data = {
    amount: 550, // $5.5
    description: 'Wallet Top-up'
};

sv_billing.Fn('balance.add', data).then((response) => 
{
    $(this).find('button').html('Waiting for payment to be completed.');

    window.open(response.recharge.url, '_BLANK');

    response.payment.then((paid) => 
    {
        if(paid)
        {
            $(this).find('button').html('Completed.');
        }
        else 
        {
            $(this).find('button').html('Session expired after ±120 seconds.');
        }
    })
    .catch((message) => 
    {
        alert(message);
    });
})
.catch((message) => 
{
    alert(message);
});

Balance Modal

sv_billing.Fn('balance.modal', {
    amount: 105
});
Built with Divhunt