Billing APIs

Introduction
Billing API is a RESTful API that allows setting up customers, collecting payments and maintaining balances for these customers, as well as creating recurring billing subscriptions.

Billing API documentation includes the following sections:

Objects - lists all recurring billing objects. The purpose of this section is to describe all object fields, their format and usage, provide the links to the corresponding database tables.

Type Enumerations – lists possible values that can be used in the respective fields within Billing API requests and responses. The purpose of this section is to provide an explanation of all enumerations used for API calls.

Actions - lists all actions that can be performed with key recurring billing objects. The purpose of this section is to describe the methods and format of API requests and the format of responses.

Integration Notes – lists integration notes associated with the Billing API objects and actions. The purpose of this section is to provide explicit information about the peculiarities of specific actions and object fields.

Code samples - provides examples of recurring billing use cases (creating billing plans, subscriptions, freeing or canceling subscriptions, reversing transactions, etc) and their implementation in JSON, XML, XURL formats. The purpose of this section is to provide examples that can be used for testing of the integration with the gateway.

To learn how to work with the Billing API, we recommend reviewing the integration notes first. Key recurring billing module terms are available here.
For more detailed information about the recurring billing configurations and management, check the Recurring Billing Guide.


Billing APIs Code Samples

Sell physical goods to an existing Customer via a Credit Card

The customer that has already signed up for the gym membership is buying two T-shirts in the gym: the first one for $20, and the second one for $15. Payments are made via credit card.


View Implementation:

1) Creating the first invoice for the existing customer)
Method: PUT
Path: [version]/customers/[customer-id]/transactions/~create
Value Name
code invoice1
amount 2000
note T-Shirt
type RI
{
"code":"invoice1",
"amount":"2000",
"note":"T-Shirt",
"type":"RI"
}
2) Collecting the first payment
Method: POST
Path: [version]/customers/[customer-id]/transactions/~process
Value Name
holderName John Smith
accountNumber 4111111111111111
accountAccessory 0422
csc 999
street 233 12th Street
city New York
state NY
zipCode 31909
phone 2129856472
email test@yahoo.com
accountType VC
amount 2000
note T-Shirt
{
"holderName":"John Smith",
"accountNumber":"4111111111111111",
"accountAccessory":"0422",
"csc":"999",
"street":"233 12th Street",
"city":"New York",
"state":"NY",
"zipCode":"31909",
"phone":"2129856472",
"email":"test@yahoo.com",
"accountType":"VC",
"amount":"2000",
"note":"T-Shirt"
}
3) Creating the second invoice for the existing customer
Method: PUT
Path: [version]/customers/[customer-id]/transactions/~create
Value Name
code invoice2
type RI
amount 1500
note T-Shirt
{
"code":"invoice2",
"type":"RI",
"amount":"1500",
"note":"T-Shirt"
}
4) Collecting the second payment
Method: POST
Path: [version]/customers/[customer-id]/transactions/~process
Value Name
holderName John Smith
accountNumber 4111111111111111
accountAccessory 0422
csc 999
street 233 12th Street
city New York
state NY
zipCode 31909
phone 2129856472
email test@yahoo.com
type AP
accountType VC
amount 1500
note T-Shirt
{
"holderName":"John Smith",
"accountNumber":"4111111111111111",
"accountAccessory":"0422",
"csc":"999",
"street":"233 12th Street",
"city":"New York",
"state":"NY",
"zipCode":"31909",
"phone":"2129856472",
"email":"test@yahoo.com",
"type":"AP",
"accountType":"VC",
"amount":"1500",
"note":"T-Shirt"
}
1) Creating the first invoice for the existing customer)
Method: PUT
Path: [version]/customers/[customer-id]/transactions/~create
Value Name
code invoice1
amount 2000
note T-Shirt
type RI
<transaction
    code = "invoice1" 
    amount = "2000" 
    note = "T-Shirt" 
    type = "RI" 
/>
2) Collecting the first payment
Method: POST
Path: [version]/customers/[customer-id]/transactions/~process
Value Name
holderName John Smith
accountNumber 4111111111111111
accountAccessory 0422
csc 999
street 233 12th Street
city New York
state NY
zipCode 31909
phone 2129856472
email test@yahoo.com
accountType VC
amount 2000
note T-Shirt
<transaction
    holderName = "John Smith" 
    accountNumber = "4111111111111111" 
    accountAccessory = "0422" 
    csc = "999" 
    street = "233 12th Street" 
    city = "New York" 
    state = "NY" 
    zipCode = "31909" 
    phone = "2129856472" 
    email = "test@yahoo.com" 
    accountType = "VC" 
    amount = "2000" 
    note = "T-Shirt" 
/>
3) Creating the second invoice for the existing customer
Method: PUT
Path: [version]/customers/[customer-id]/transactions/~create
Value Name
code invoice2
type RI
amount 1500
note T-Shirt
<transaction
    code = "invoice2" 
    type = "RI" 
    amount = "1500" 
    note = "T-Shirt" 
/>
4) Collecting the second payment
Method: POST
Path: [version]/customers/[customer-id]/transactions/~process
Value Name
holderName John Smith
accountNumber 4111111111111111
accountAccessory 0422
csc 999
street 233 12th Street
city New York
state NY
zipCode 31909
phone 2129856472
email test@yahoo.com
type AP
accountType VC
amount 1500
note T-Shirt
<transaction
    holderName = "John Smith" 
    accountNumber = "4111111111111111" 
    accountAccessory = "0422" 
    csc = "999" 
    street = "233 12th Street" 
    city = "New York" 
    state = "NY" 
    zipCode = "31909" 
    phone = "2129856472" 
    email = "test@yahoo.com" 
    type = "AP" 
    accountType = "VC" 
    amount = "1500" 
    note = "T-Shirt" 
/>
1) Creating the first invoice for the existing customer)
Method: PUT
Path: [version]/customers/[customer-id]/transactions/~create
Parameters: code=invoice1&amount=2000&note=T-Shirt&type=RI
Value Name
code invoice1
amount 2000
note T-Shirt
type RI
2) Collecting the first payment
Method: POST
Path: [version]/customers/[customer-id]/transactions/~process
Parameters: holderName=John+Smith&accountNumber=4111111111111111&accountAccessory=0422&csc=999&street=233+12th+Street&city=New+York&state=NY&zipCode=31909&phone=2129856472&email=test%40yahoo.com&accountType=VC&amount=2000&note=T-Shirt
Value Name
holderName John Smith
accountNumber 4111111111111111
accountAccessory 0422
csc 999
street 233 12th Street
city New York
state NY
zipCode 31909
phone 2129856472
email test@yahoo.com
accountType VC
amount 2000
note T-Shirt
3) Creating the second invoice for the existing customer
Method: PUT
Path: [version]/customers/[customer-id]/transactions/~create
Parameters: code=invoice2&type=RI&amount=1500&note=T-Shirt
Value Name
code invoice2
type RI
amount 1500
note T-Shirt
4) Collecting the second payment
Method: POST
Path: [version]/customers/[customer-id]/transactions/~process
Parameters: holderName=John+Smith&accountNumber=4111111111111111&accountAccessory=0422&csc=999&street=233+12th+Street&city=New+York&state=NY&zipCode=31909&phone=2129856472&email=test%40yahoo.com&type=AP&accountType=VC&amount=1500&note=T-Shirt
Value Name
holderName John Smith
accountNumber 4111111111111111
accountAccessory 0422
csc 999
street 233 12th Street
city New York
state NY
zipCode 31909
phone 2129856472
email test@yahoo.com
type AP
accountType VC
amount 1500
note T-Shirt