コード例 #1
0
ファイル: register.php プロジェクト: anggagewor/whmcs-api
<?php

/**
* hanya menerima method POST;
* selain POST maka akan result 0
*/
if ($_POST) {
    /**
     * untuk mengecek apakah card id sudah terdaftar atau tidak.
     */
    $custom = new custom();
    $cekCardId = $custom->cekCardId($_POST['companyname']);
    if ($cekCardId == 0) {
        /**
         * untuk me-register client.
         */
        $client = new client();
        $registerClient = json_decode($client->Add_Client($_POST));
        if ($registerClient->result == 1) {
            $result['result'] = 1;
            echo json_encode($result);
        } else {
            $result['result'] = 0;
            echo json_encode($result);
        }
    } else {
        $result['result'] = 0;
        echo json_encode($result);
    }
} else {
    $result['result'] = 0;
コード例 #2
0
ファイル: topup.php プロジェクト: anggagewor/whmcs-api
<?php

// start $_POST
if ($_POST) {
    /**
     * untuk mengecek apakah card id sudah terdaftar atau tidak.
     */
    $custom = new custom();
    $cekCardId = $custom->cekCardId($_POST['card_id']);
    // start $cekCardId
    if ($cekCardId != 0) {
        $param["clientid"] = $custom->byCardId($_POST['card_id']);
        $param["amount"] = $_POST['nominal'];
        $param["description"] = "Topup Saldo {$param["amount"]}";
        // start $param["clientid"]
        if (!$param["clientid"] == false) {
            // tambah credit
            $payments = new payments();
            $topup = json_decode($payments->Add_Credit($param));
            //membuat invoice
            $invoice["userid"] = $param["clientid"];
            $invoice["date"] = date("Ymd");
            $invoice["duedate"] = date("Ymd");
            $invoice["sendinvoice"] = false;
            $invoice["itemdescription1"] = $param["description"];
            $invoice["itemamount1"] = $param["amount"];
            $createInvoice = json_decode($payments->Create_Invoice($invoice));
            // update invoice
            $postfields["invoiceid"] = $createInvoice->invoiceid;
            $postfields["status"] = 'Paid';
            $updateInvoice = json_decode($payments->Update_Invoice($postfields));
コード例 #3
0
<?php

if ($_POST) {
    $cardid = $_POST['cardid'];
    $invoiceid = $_POST['invoiceid'];
    $nominal = $_POST['nominal'];
    $custom = new custom();
    $cekCardId = $custom->cekCardId($cardid);
    if ($cekCardId != 0) {
        $clientid = $custom->byCardId($cardid);
        $client = new client();
        $details = json_decode($client->Get_Clients_Details($clientid));
        $credit = explode('.', $details->client->credit);
        $credit = $credit['0'];
        if ($credit < $nominal) {
            $result['result'] = 0;
            $result['message'] = "Your Balance is not enought";
            echo json_encode($result);
        } else {
            $payments = new payments();
            $custom->updateInvoiceUserId($clientid, $invoiceid);
            $token['client_id'] = $clientid;
            $token['invoiceid'] = $invoiceid;
            $rtoken = $custom->rToken($token);
            if ($rtoken != 0) {
                $result['result'] = 1;
                $result['invoiceid'] = $invoiceid;
                $result['amount'] = $nominal;
                echo json_encode($result);
            } else {
                $result['result'] = 0;