Billing API
Your Private Information
To get your private key, please Sign In as an operator
API Description
Billing API allows you to operate with your customer's records in automatic mode.
The following possibilites are available:
  • Add / View / Edit / Delete a customer
  • Subscribe a customer
  • View customer's payment history
  • View the customers list
Possible errors:
  • api_version_incorrect – Wrong API version
  • ip_not_trusted – IP not trusted(operator settings)
  • signature_error – Signature error
  • no_such_operator - Incorrect operator_id
  • no_such_customer - Incorrect customer_id
  • not_enough_money - Not enough money on your balance
Billing API review
Common API package view:
<?xml version="1.0" encoding="UTF-8"?>
<request>
  <version>1.0</version>
    <operation_envelope> <!--Package which consists of XML and a signature-->
      	<operation_xml><!--XML of operation-->
            wersadfweorksladfhlkjhFDfsdFSfadfsafdeasfrtty==
        </operation_xml>
        <signature><!--Signature-->
	    werewrgsadeww=
        </signature>
    </operation_envelope>    
</request>
Inside of the <operation_xml> tags located XML which specifies the operation needs.
Example (customer add XML):
<request>
      <action>customer_add</action>      
      <operator_id>6543</operator_id>
      <customer>
      <first_name>Joe</first_name>
      <last_name>Shmoe</last_name>
      <username>joe</username>
      <email>joe.shmoe@gmail.com</email>
      <dealer_id>0</dealer_id>
      <address>120 Mills Ave</address>
      <city>San Francisco</city>
      <zip_code>94121</zip_code>
      <phone>+11234561234</phone>
      <country>USA</country>
      <tag>hotel1</tag>
      <auth_method>all, device, login</auth_method> 
      <device1_id>A00332FA34</device1_id>
      <status>active</status>       
      <md5_password>AD432355FD34355FD324A324</md5_password>
      </customer>
</request>
Source text of this XML is used for generation of a signature which located in <signature/> tags;
To generate this signature, do the following:

PHP: $sign = base64_encode(sha1($oper_sign.$xml.$oper_sign,1));
Perl: $sign = encode_base64(sha1($oper_sign.$xml.$oper_sign,1));

User Base64 function (base64_encode(PHP) or encode_base64(Perl)) to pack the signed XML.

Perl: $xml_encoded = encode_base64($xml);
PHP: $xml_encoded = base64_encode($xml);

Now we have everything we need to create our API operation:
<?xml version="1.0" encoding="UTF-8"?>
<request>
  <version>1.0</version>
    <operation_envelope>
     <operation_xml>$xml_encoded</operation_xml>
     <signature>$signature</signature>
    </operation_envelope>    
</request>
Created request is to be sent by following URL: http://tv.broadlink.com.np /api/engine
Response package:
<?xml version="1.0" encoding="UTF-8"?>
<response>
  <version>1.0</version>
    <operation_envelope>
      	<operation_xml>awerawerlkhWFEfdasfEWAFfdsafFEDFLksdj==</operation_xml>
     	<signature>sdfEFDfdsfd=</signature>
    </operation_envelope>    
</response>
Result checking:
1) Unpack the contents of <operation_xml/> tag
2) Generate a signature
3) Compare the generated signature with the received one (<signature/>)
4) If signatures are equal - process the package, otherwise drop it

Login API
To login a customer in the system you just need to send an HTTP GET request by the following URL: http://tv.broadlink.com.np/channels/list
Additional HTTP headers must be included:
time = current time in UTC
user = username or email of the customer
hash = md5(time + '*' + md5(password))
You will get an XML with unique temporary url to watch live channels, thumbs, information about servers, VoD, etc...

Subscription renew types
0 = No auto renew
1 = Renew when finished, if user has enough balance
2 = Renew when finished, even user has not enough balance
3 = Charge every day, until user has enough balance
4 = Charge every day, even user has not enough balance
Request and Response examples:
  • Customer Add
  • Customer View
  • Customer Edit
  • Customer Delete
  • Add a subscription for a customer
  • Get package list
  • Change balance of a user
  • View Customer's Payment History
  • View Customers List
  • Add unique subscription to a plan. Used for external billings which need to open permanent access to selected plan. This method checks if subscription already exists.
  • Update unique subscription expiration date.
  • Stop subscription by plan. Used for external billings which need to close access to selected plan. If customer has few subscriptions to selected plan - latest will be deleted.
  • Stop subscription renew by plan. Use it to cancel subscription renew when customer has not enough funds in your system, etc.
  • Start subscription renew by plan. Use it to continue subscription renew when customer has added funds to balance, etc.
  • PHP example (add subscription)