Desc: adds a single or more credit lines to a specific customer. This API changed on Version 5.3. Credit row must have “aprice” or “usagev”+”usaget”, but not all 3
Path: http://host/api/credit
HTTP Method:POST
Input (POST):
- action - the action to execute:
- In case you didn’t send an “action” field, the default action will be credit.
Parameters:
- query: = (JSON) query to get wanted invoices.
- aid - Customer identifier
- sid- Subscription identifier (in case of customer level credit, use sid=0)
- rate - the key of the rate for the credit/debit.
- aprice - price to credit/debit (float) - mandatory if “usagev” and “usaget” were not sent.
- usagev - volume to credit/debit (float, for rating purposes) - mandatory.
- usaget - type of the credit/debit line (for rating purposes) - mandatory if “aprice” was not sent.
- credit_type - charge/refund - in case "aprice" was not sent, this will determine if it's a charge or refund. Default value is refund.
- credit_time - unix timestamp or other formats supported by Zend_date (unix timestamp or YYYY-mm-dd HH:ii:ss). Timezone is based on server if not specified.
- installments (optional) - number of installments of the credit (can only be applied to credit by price)
- label (optional) - string. The label to be displayed in the invoice
- “prepone” - prepone future installments to the requested subscriber.
Parameters:
- aid - customer identifier
- sid - Subscription identifier (in case of account level installments, use sid=0)
Output format : JSON
Output structure:
- status - 1 or 0 (int) - success or failed
- desc - returns information on success or error description on failure
- stamp - unique value that the API call generates for the action (defined by the input)
- input - the input sent to the API call
Error output:
- all errors will have the “status” field === 0.
- all errors will have the “desc” field contain the error description.
- Possible errors :
- “failed to store into DB lines” : When there was an error storing a credit line into the DB lines collection.
- “failed to store into DB queue” : When there was an error storing a credit line into the DB queue collection for further processing.
- “Error with credit row” : When there was an error parsing the provided credit row.
Examples:
- http://host/api/credit?sid=777777777&aid=11111&rate=TEST_RATE&usagev=3&credit_time=2017-02-10T10:00&usaget=call
- http://host/api/credit?sid=777777777&aid=11111&rate=TEST_RATE&aprice=0.5&credit_time=2017-02-10T10:00
- http://billrun/api/credit?sid=17853&aid=17853,&rate=INTERNATIONAL_AFGHANISTAN_FIXED_CALL&aprice=24&credit_time=2020-01-20T10:00:00Z&installments=3&usagev=1
Desc: adds multiple credit lines (credit ,aka refund, or debit ,aka charge) to customer
Path: http://<host>/api/bulkcredit
HTTP Method: POST
Input parameters for the bulk credit action (POST requests only):
- operation - "credit" (string)
- credits - credit lines array in JSON format. Format of each credit line
- credit_type - "charge" or "refund" (string)
- amount_without_vat - the amount (double. could be positive/negative)
- reason - credit line reason.
- service_name - This will be used in the invoice (string .according to invoice XML string).
- account_id - positive int
- subscriber_id - positive int
- credit_time - unix timestamp or other formats supported by Zend_date (unix timestamp or YYYY-mm-dd HH:ii:ss). Timezone is based on server if not specified.
- Optional fields:
- vatable - 0 or 1 (0 - no, 1 - yes. Defaults to 1)
- additional - mixed (can be any variable) - additional information that can be added to the row.
Output format: JSON
Output structure:
- status - 1 on success result else 0 on failure
- desc - short description on failure
- stamp - unique stamp to keep this action. The format is <filename>.JSON. This stamp used to query your this action and its progress.
Notes:
- Executing this command actually creates a JSON file in the server (it is equivalent to the receiving of a cdr file).
- If the file contains duplicates of already processed lines they won't be re-processed.
- Please send a maximum of 100,000 lines in one request.
---------
In order to query the bulk credit action (POST requests only), use the following input parameters:
- operation - "query" (string)
- stamp - filename received from the previous method (string)
- details - whether to show lines information (boolean. defaults to false)
Output:
- operation - "query" or “credit”
- stamp - filename.JSON
- status - log db status (received / in progress / done)
- details - lines information (array in JSON format. Shown if "details" = true)
- count - lines count (int. Shown if "details" = true)
Notes:
- The file is expected to be processed after about 30 minutes.
Error output:
- all errors will have the “status” field === 0.
- all errors will have the “desc” field contain the error description.
- Possible errors:
- “Unrecognized operation” : When the operation field wasn’t specified correctly.
- “Input JSON is invalid” : When one of the credit provided wasn’t constructed correctly.
- “Couldn't receive file” : Indicate that there was some error in reception/creation of the credit file to the billing workspace.
- “Receiver cannot be loaded” : indicates that there was a fault in creating the credit receiver class.
- “Stamp is missing” : When the stamp field is missing from the input.
- “details could be either 0 or 1” : (when operation=”query”) the details field contained illegal information.
- “File <X> not found” : (when operation=”query”) File not found in billing workspace.