JSON API » charges » charges/create
Creates a new charge. The charge is not charged immediately, to give you an opportunity to set any required taxes using taxes/liable/set, so if you wish to charge immediately you should call charges/charge after setting the taxes.
Input parameters
Requires authentication and the administrator or wholesale role privileges.
Name | Type | Description | Required | Default value |
---|---|---|---|---|
auth_username | String | Authentication username. | Yes | |
auth_password | String | Authentication password. | Yes | |
name | String | Name. | Yes | |
customer | Integer | ID of customer to charge. | Yes, unless plan is specified. | 0 |
plan | Integer | ID of rate plan to charge all customers on. | Yes, unless customer is specified. | 0 |
amount | Decimal | Amount to charge customer, excluding taxes. | No | Current value. |
buy | Decimal | Amount item cost, excluding taxes. Used for calculating profits. | No | Current value. |
currency | String | Currency amount and buy are in. | No | Current value. |
description | String | Description. | No | Current value. |
end | Integer | End Unix timestamp. | No | Current value. |
number | Integer | Number of times to charge. | No | Current value. |
period | String | Period. "once", "monthly", "quarterly", "annually", or empty string for immediately. | No | Current value. |
start | Integer | Start Unix timestamp. | No | Current value. |
validation | Integer | 1 to validate input then return, 0 for full action. | No | 0 |
Specify either customer or plan, but not both.
Responses
Code | Description |
---|---|
200 | Success. |
201 | Input passed validation. Only returned if validation=1. |
400 | Invalid input parameters specified. Check the key and message fields for more details. |
401 | The authentication details provided are invalid. |
402 | Your role does not allow this. |
404 | The customer or rate plan does not exist, or you do not have permission to view it. |
Data returned
The ID of the created charge.
Example: With required parameters
http://enswitch.example.com/api/json/charges/create/?auth_username=user;auth_password=password;name=example;customer=123{ "responses":[ { "code":"200", "key":"", "message":"OK" } ], "data":{ "id":123 } }
Change history
Version | Changes |
---|---|
3.13 | Function added. |