Introduction
This article explains how to retrieve information about user accounts from Billing, which may be needed for the proper operation of domain registrar plug-ins written in PHP.
Instruction
Use the
pem.getDomainByName
method to determine the domain owner's ID.>>> oapi.pem.getDomainByName(domain_name = 'example.com') 2019-07-01 07:48:38.046 [DEBUG] call method pem.getDomainByName({'domain_name': 'example.com'}) 2019-07-01 07:48:38.081 [DEBUG] return {'status': 0, 'result': {'owner_id': 1000001, 'domain_id': 2, 'name': 'example.com'}} {'domain_id': 2, 'name': 'example.com', 'owner_id': 1000001
Use the
BM.GetUsersListForAccount
method to find the account’s staff members.>>> bapi.BM.GetUsersListForAccount(1000001,0) 2019-07-01 07:49:00.937 [DEBUG] Billing API call BM::GetUsersListForAccount (1000001, 0) 2019-07-01 07:49:00.949 [DEBUG] Billing API response: {'UserID': -1, 'Result': [[[1000002, 'mail@example.com', 'Staff', 'member', 0], [1000001, 'mail@example.com', 'John', 'Doe', 0]]]} {'UserID': -1, 'Result': [[[1000002, 'mail@example.com', 'Staff', 'member', 0], [1000001, 'mail@example.com', 'John', 'Doe', 0]]]}
Use the
BM.SalesOrderGetCustomerOrderListByAccount
method to find the account’s orders. The second parameter is SortNo. It also allows calling for a particular order ID (for example, bapi.BM.SalesOrderGetCustomerOrderListByAccount(1000001,0, 1000003)):>>> bapi.BM.SalesOrderGetCustomerOrderListByAccount(1000001,0) 2019-07-01 07:50:02.491 [DEBUG] Billing API call BM::SalesOrderGetCustomerOrderListByAccount (1000001, 0) 2019-07-01 07:50:02.505 [DEBUG] Billing API response: {'UserID': -1, 'Result': [[[1000003, 'SO000002', 'Sales Order', 'John Doe', 1561669200, '/images/icons/16-state-yes.gif', 'Completed', 'USD 14.9900', 247887, 'system'], [1000001, 'SO000001', 'Sales Order', 'John Doe', 1561669200, '/images/icons/16-state-alerted.gif', 'Provisioning Failed', 'USD 10.0000', 248288, 'system']]]} {'UserID': -1, 'Result': [[[1000003, 'SO000002', 'Sales Order', 'John Doe', 1561669200, '/images/icons/16-state-yes.gif', 'Completed', 'USD 14.9900', 247887, 'system'], [1000001, 'SO000001', 'Sales Order', 'John Doe', 1561669200, '/images/icons/16-state-alerted.gif', 'Provisioning Failed', 'USD 10.0000', 248288, 'system']]]}
Use the
BM. GetObjAttrList_API
method to retrieve custom attributes of account's items. The first parameter stands for an account (0), a user (1) or an order (2). The last one is an integer number.>>> bapi.BM.GetObjAttrList_API(0 ,1000001, 0) 2019-07-01 07:49:28.196 [DEBUG] Billing API call BM::GetObjAttrList_API (0, 1000001, 0) 2019-07-01 07:49:28.212 [DEBUG] Billing API response: {'UserID': -1, 'Result': [[['Hn', 'test001att', 'COMP, PERS']]]} {'UserID': -1, 'Result': [[['Hn', 'test001att', 'COMP, PERS']]]} >>> bapi.BM.GetObjAttrList_API(1 ,1000001, 0) 2019-07-01 07:49:32.286 [DEBUG] Billing API call BM::GetObjAttrList_API (1, 1000001, 0) 2019-07-01 07:49:32.305 [DEBUG] Billing API response: {'UserID': -1, 'Result': [[['ID', 'asd', 'COMP, PERS']]]} {'UserID': -1, 'Result': [[['IDIDIDI', 'asd', 'COMP, PERS']]]} >>> bapi.BM.GetObjAttrList_API(2 ,1000002, 0) 2019-07-01 07:49:45.541 [DEBUG] Billing API call BM::GetObjAttrList_API (2, 1000002, 0) 2019-07-01 07:49:45.560 [DEBUG] Billing API response: {'UserID': -1, 'Result': [[['OrderID', '', 'COMP, PERS']]]} {'UserID': -1, 'Result': [[['OrderID', '', 'COMP, PERS']]]}