SandBox Mode

To use sandbox mode, please register an account at https://dev.toyyibpay.com. Here you can create dummy bills and make test payments via Bank Simulators.

For API testing purpose, replace the URL 'toyyibpay.com' with 'dev.toyyibpay.com' together with your sandbox account credentials.

For online banking transaction test, please use the following banks only:

  • SBI BANK A (success transaction)
  • SBI BANK B (fail transaction; insufficient fund)
  • SBI BANK C (Pending Return / Callback from bank - 30 min)

  • Username : 1234
    Password : 1234

    Basic Information

    You will interact a lot with Category and Bill.

    Category is a group of bills. You can create a category based on bills type. e.g. House rental, Subscription fees.

    A bill is an invoice for your customer. A bill must belong to a Category

    To start using the API, you would have to create a Category. Then the payment flow will kicks in as per below:

  • Customer visits your site.
  • Customer chooses to make payment.
  • Your site creates a Bill via API call.
  • toyyibPay API returns Bill's code.
  • Your site redirects the customer to Bill's URL.
  • The customer makes payment via payment option of choice.
  • toyyibPay sends a server-side update (Payment Completion) to your site on Bill's status on payment failure or success.
  • Your site can check payment status via API call
  • APIs (All Users)

    Category is a collection of bills. As an example, you may create a 'Rental' Category for bill related to rental. User Secret Key is required in order to create a Category. Please login to toyyibPay to get User Secret Key.

    In the example below, we will show you how to create a Category. You need to pass the following parameters to generate category code. For Content-Type you should use multipart/form-data or x-www-form-urlencoded.

    • catname - Category Name
    • catdescription - Category Description
    • userSecretKey - User Secret Key

    Our API system will return Category Code in JSON format.

    Sample code

    
    <?php
      $some_data = array(
        'catname' => 'toyyibPay General 2', //CATEGORY NAME
        'catdescription' => 'toyyibPay General Category, For toyyibPay Transactions 2', //PROVIDE YOUR CATEGORY DESCRIPTION
        'userSecretKey' => 'w5x7srq7-rx5r-3t89-2ou2-k7361x2jewhn' //PROVIDE USER SECRET KEY HERE
      );  
    
      $curl = curl_init();
    
      curl_setopt($curl, CURLOPT_POST, 1);
      curl_setopt($curl, CURLOPT_URL, 'https://toyyibpay.com/index.php/api/createCategory');  //PROVIDE API LINK HERE
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($curl, CURLOPT_POSTFIELDS, $some_data);
    
      $result = curl_exec($curl);
    
      $info = curl_getinfo($curl);  
      curl_close($curl);
    
      $obj = json_decode($result);
      echo $result;
    											

    Sample result

    
    [{"CategoryCode":"j0tzqhka"}]
    											

    Bill serves as an invoice to your customer.

    In the example below, we will show you how to create a Bill. You need to pass the following parameters to generate category code. For Content-Type you should use multipart/form-data or x-www-form-urlencoded.

    • userSecretKey - User Secret Key
    • categoryCode - Category Code. Get your Category Code from Create Category API
    • billName - Your bill name. Bill Name will be displayed as bill title
      * Max 30 alphanumeric characters, space and '_' only
    • billDescription- Your bill description.
      * Max 100 alphanumeric characters, space and '_' only
    • billPriceSetting - For fixed amount bill, set it to 1 and insert bill amount. For dynamic bill (user can insert the amount to pay), set it to 0.
    • billPayorInfo - If you want to create open bill without require payer information, set it to 0. If you need payer information, set it to 1
    • billAmount - Key in the bill amount. The amount is in cent. e.g. 100 = RM1. If you set billPriceSetting to 1 (dynamic bill), please put 0
    • billReturnUrl - Key in return Url if you need the bill to be redirected to your own page upon payment completion.
    • billCallbackUrl - Key in callback url if you need the bill to be redirected to your callback page upon sucessful of payment transaction.
    • billExternalReferenceNo - Provide your own system reference no if you think it is required. You may use this reference no to check the payment status for the bill.
    • billTo - If you intend to provide the bill to specific person, you may fill the person nam in this field. If not, please leave it blank.
    • billEmail - Provide your customer email here
    • billPhone - Provide your customer phone number here.
    • billSplitPayment - [OPTIONAL] Set 1 if the you need the payment to be splitted to other toyyibPay users.
    • billSplitPaymentArgs - [OPTIONAL] Provide JSON for split payment. e.g. [{"id":"johndoe","amount":"200"}]
    • billPaymentChannel - Set 0 for FPX, 1 Credit Card and 2 for both FPX & Credit Card.
    • billContentEmail - [OPTIONAL] Provide additional messages by sending an extra email to your customer. Limited to 1000 characters only.
    • billChargeToCustomer - [OPTIONAL] Below are the values available :

      1. Leave blank to set charges for both FPX and Credit Card on bill owner.
      2. Set "0" to charge FPX to customer, Credit Card to bill owner.
      3. Set "1" to charge FPX bill owner, Credit Card to customer.
      4. Set "2" to charge both FPX and Credit Card to customer.

    Our API system will return Bill Code in JSON format. In this example, the API return gcbhict9 as bill code. Hence, your payment url will be:- https://toyyibpay.com/gcbhict9

    Sample code

    
    <?php
      $some_data = array(
        'userSecretKey'=>'w5x7srq7-rx5r-3t89-2ou2-k7361x2jewhn',
        'categoryCode'=>'gcbhict9',
        'billName'=>'Car Rental WXX123',
        'billDescription'=>'Car Rental WXX123 On Sunday',
        'billPriceSetting'=>0,
        'billPayorInfo'=>1,
        'billAmount'=>100,
        'billReturnUrl'=>'http://bizapp.my',
        'billCallbackUrl'=>'http://bizapp.my/paystatus',
        'billExternalReferenceNo' => 'AFR341DFI',
        'billTo'=>'John Doe',
        'billEmail'=>'[email protected]',
        'billPhone'=>'0194342411',
        'billSplitPayment'=>0,
        'billSplitPaymentArgs'=>'',
        'billPaymentChannel'=>'0',
        'billContentEmail'=>'Thank you for purchasing our product!',
        'billChargeToCustomer'=>1
      );  
    
      $curl = curl_init();
      curl_setopt($curl, CURLOPT_POST, 1);
      curl_setopt($curl, CURLOPT_URL, 'https://toyyibpay.com/index.php/api/createBill');  
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($curl, CURLOPT_POSTFIELDS, $some_data);
    
      $result = curl_exec($curl);
      $info = curl_getinfo($curl);  
      curl_close($curl);
      $obj = json_decode($result);
      echo $result;
    											

    Sample result

    
    [{"BillCode":"gcbhict9"}]
    											

    Please note that Callback URL cannot be received in localhost. Callback URL will be supplied with the following datas in POST format:-

    refno : Payment reference no

    status : Payment status. 1= success, 2=pending, 3=fail

    reason : Reason for the status received

    billcode : Your billcode / permanent link

    order_id : Your external payment reference no, if specified

    amount : Payment amount received

    transaction_time : Datetime of the transaction status received.

    Return URL will be supplied with the following datas in GET format:-

    status_id : Payment status. 1= success, 2=pending, 3=fail

    billcode: Your billcode / permanent link

    order_id : Your external payment reference no, if specified

    You may check bill payment status by submitting Bill Code and Bill Payment Status(Optional). Bill payment status code description as follows:-

    • 1 - Successful transaction
    • 2 - Pending transaction
    • 3 - Unsuccessful transaction
    • 4 - Pending

    Sample code

    
    <?php
      $some_data = array(
        'billCode' => 'td8bfqv7',
        'billpaymentStatus' => '1'
      );  
    
      $curl = curl_init();
    
      curl_setopt($curl, CURLOPT_POST, 1);
      curl_setopt($curl, CURLOPT_URL, 'https://toyyibpay.com/index.php/api/getBillTransactions');  
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($curl, CURLOPT_POSTFIELDS, $some_data);
    
      $result = curl_exec($curl);
      $info = curl_getinfo($curl);  
      curl_close($curl);
    
      echo $result;
    ?>
    											

    Sample result

    
    [
       {
    	"billName": "Payment_for_order_51",
    	"billDescription": "Payment_for_order_51",
    	"billTo": "",
    	"billEmail": "",
    	"billPhone": "",
    	"billStatus": "1",
    	"billPermalink": "zyq1pq6s",
    	"categoryCode": "vkptzhxe",
    	"categoryName": "Wordpress",
    	"userName": "fitweb",
    	"billpaymentChannel": "FPX",
    	"billSplitPayment": null,
    	"billSplitPaymentArgs": null,
    	"billpaymentSettlement": "Settlement Done",
    	"billpaymentSettlementDate": "2020-03-04 08:53:13",
    	"billPaymentDate": "03-03-2020 06:24:08"
    	"billpaymentStatus": "3",
    	"billpaymentAmount": "1.00",
    	"billpaymentInvoiceNo": "B00040-288-424703111018"
       }
    ]
    											

    In the example below, we will show you how to get category information. You need to pass the following parameters :

    • userSecretKey - User Secret Key
    • categoryCode - Category Code

    Our API system will return information in JSON format.

    Sample code

    
    <?php
      $some_data = array(
        'userSecretKey' => 'w5x7srq7-rx5r-3t89-2ou2-k7361x2jewhn' //PROVIDE USER SECRET KEY HERE
        'categoryCode' => 'Ajdiufd345f' //PROVIDE CATEGORY CODE HERE
      );  
    
      $curl = curl_init();
    
      curl_setopt($curl, CURLOPT_POST, 1);
      curl_setopt($curl, CURLOPT_URL, 'https://toyyibpay.com/index.php/api/getCategoryDetails'); 
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($curl, CURLOPT_POSTFIELDS, $some_data);
    
      $result = curl_exec($curl);
    
      $info = curl_getinfo($curl);  
      curl_close($curl);
    
      $obj = json_decode($result);
      echo $result;
    											

    Sample result

    
    [
        {
            "categoryName": "Makanan",
            "categoryDescription": "Kuih Cara",
            "categoryStatus": "1"
        }
    ]
    											

    APIs (Enterprise Partner)

    This API will show how to create toyyibPay user from API. This API will return User Secret Key which later will be used for creating Category and Bill.

    You need to pass the following parameters to create user. For Content-Type you should use multipart/form-data or x-www-form-urlencoded.

    • enterpriseUserSecretKey - Enterprise user secret key
    • Fullname - User full name
    • User name - User name to access or login
    • Email - User Email OR User Id (not necessary in email format)
    • Password - User Password
    • Phone - User Phone
    • Bank - User Bank Selection
    • Account No - User Bank Account No
    • Account Holder Name - User Account Holder Name
    • Registration No [OPTIONAL] - User Company / Business / Organization Registration No
    • Package - User Package
    • userStatus [OPTIONAL] - Set to 2 if you want the account status to be active without click the link in confirmation email.

    Our API system will return User Secret Key in JSON format. It will return error if the email already exist.

    Sample code

    
    <?php
      $some_data = array(
        'enterpriseUserSecretKey' => 'abcdef-ghijk-lmnop-qrstu',
        'fullname' => 'John Doe Sdn Bhd',
        'username' => 'johndoe',
        'email' => '[email protected]',
        'password' => '123456',
        'phone' => '0134342400',
        'bank'=>1,
        'accountNo'=>'162263282063',
        'accountHolderName'=>'John Doe,
        'registrationNo'=>'BBYUUI',
        'package' => 1
      );
    
      $curl = curl_init();
      curl_setopt($curl, CURLOPT_POST, 1);
      curl_setopt($curl, CURLOPT_URL, 'https://toyyibpay.com/index.php/api/createAccount');  
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($curl, CURLOPT_POSTFIELDS, $some_data);
    
      $result = curl_exec($curl);
      $info = curl_getinfo($curl);  
      curl_close($curl);
      $obj = json_decode($result);
      echo $result;
    									

    Sample result

    
    [
      {
      	"UserSecretKey" : "vrbl86xf-wj1h-q0l3-95kk-4q4erulvsc0h"
      }
    ]
    									

    Get Bank API is useful for you to get bank information which are accepted to be used with toyyibPay. Bank information is required when you create a user from API

    Our API system will return bank information in JSON format.

    Sample code

    
    <?php
      $curl = curl_init();
    
      curl_setopt($curl, CURLOPT_POST, 0);
      curl_setopt($curl, CURLOPT_URL, 'https://toyyibpay.com/index.php/api/getBank');  
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    
      $result = curl_exec($curl);
      $info = curl_getinfo($curl);  
      curl_close($curl);
    
      echo $result;
    ?>
    										

    Sample result

    
    [{"id":"1","bank":"Maybank","status":"1"},{"id":"2","bank":"CIMB Bank","status":"1"},{"id":"3","bank":"Bank Islam","status":"1"},{"id":"4","bank":"Bank RBS","status":"1"},{"id":"5","bank":"Bank Mandiri","status":"1"}]
    										

    You may check user account status by submitting user email and enterprise user secret key. Status code description as follows:-

    • 0 - Inactive
    • 1 - New-Pending Approval
    • 2 - Active

    Sample code

    
    <?php
      $some_data = array(
        'username' => 'johndoe',
        'enterpriseUserSecretKey' => 'h9ijfq4y-hrha-jsmj-s4br-r5hll1g29ty'
      );  
    
      $curl = curl_init();
    
      curl_setopt($curl, CURLOPT_POST, 1);
      curl_setopt($curl, CURLOPT_URL, 'https://toyyibpay.com/index.php/api/getUserStatus');  
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($curl, CURLOPT_POSTFIELDS, $some_data);
    
      $result = curl_exec($curl);
    
      $info = curl_getinfo($curl);  
    
      curl_close($curl);
      echo $result;
    ?>
    										

    Sample result

    
    [{"status":"1"}]
    										

    You may get all settlement summary information by submitting as follows:-

    • userSecretKey - Secret key for Enterprise User Only
    • userName - Sample Username

    Sample code

    
    <?php
    $some_data = array(
    'userSecretKey' => 'td8bfqv7',
    'userName' => "Sample Username"
    );  
    
    $curl = curl_init();
    
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_URL, 'https://toyyibpay.com/api/getSettlementSummary');  
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $some_data);
    
    $result = curl_exec($curl);
    $info = curl_getinfo($curl);  
    curl_close($curl);
    
    echo $result;
    ?>
    				

    Sample Result

    
    [
    	{
    		"userID": "44",
    		"userName": "fitweb",
    		"today": "19-10-31",
    		"Amount_Pending": "1.00",
    		"Amount_settle": "5.00",
    		"AmountNett_Pending": "1.00",
    		"AmountNett_Settle": "0.00",
    		"Different_Pending": "0.00",
    		"Different_Settle": "5.00",
    		"Standard_Pending": "0.00",
    		"Standard_Settle": "0.00",
    		"Santai_Pending": "1.00",
    		"Santai_Settle": "5.00",
    		"Creditcard_Pending": "0.00",
    		"Creditcard_settle": "0.00",
    		"Transaction_Pending": "6",
    		"Trnsaction_Settle": "6"
    	}
    ]