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.

NameTypeDescriptionRequiredDefault value
auth_usernameStringAuthentication username.Yes
auth_passwordStringAuthentication password.Yes
nameStringName.Yes
customerIntegerID of customer to charge.Yes, unless plan is specified.0
planIntegerID of rate plan to charge all customers on.Yes, unless customer is specified.0
amountDecimalAmount to charge customer, excluding taxes.NoCurrent value.
buyDecimalAmount item cost, excluding taxes. Used for calculating profits.NoCurrent value.
currencyStringCurrency amount and buy are in.NoCurrent value.
descriptionStringDescription.NoCurrent value.
endIntegerEnd Unix timestamp.NoCurrent value.
numberIntegerNumber of times to charge.NoCurrent value.
periodStringPeriod. "once", "monthly", "quarterly", "annually", or empty string for immediately.NoCurrent value.
startIntegerStart Unix timestamp.NoCurrent value.
validationInteger1 to validate input then return, 0 for full action.No0

Specify either customer or plan, but not both.

Responses

CodeDescription
200Success.
201Input passed validation. Only returned if validation=1.
400Invalid input parameters specified. Check the key and message fields for more details.
401The authentication details provided are invalid.
402Your role does not allow this.
404The 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

VersionChanges
3.13Function added.