API: Charges

Charges in Recharge are sets of billing information owned by Customers that Recharge uses to manage recurring billing.

Each charge contains information on how much to charge a customer, how often, which payment method to use, when to stop collecting, etc.

 

Charge Attributes

Parameter Description
id The unique identifier for the Payment Method.
customer ID of the customer that the new recurring charge should be added to.
payMethod ID of the payment method Recharge should use for this charge.
billingStartDate Date and time of the first payment. Can be text ('today', 'tomorrow'), or calendar dates
billingEndDate Date and time of the last payment. Cards will not be charged past this date. Can be text ('today', 'tomorrow'), or calendar dates
billingEndAmount Amount that, when reached, will end all future recurring charges.
product Predefined product to use with this recurring charge. If this value is set, price, intervalValue and intervalUnit are not required.
price Overrides any predefined products and sets a custom price for the recurring charge. If this value is set, intervalValue and intervalUnit are required.
intervalValue Recurring charge interval value. Would be the "1" in "bill every 1 month." Must be at least 1.
intervalUnit Recurring charge interval unit. Either "m" for month or "d" for day.
nextChargeDate Date and time the system will attempt to collect the next payment.
totalRevenue Total revenue collected for this charge to date.
pubID The Charge's Public ID, used in customer portal URLs. For example: if the pubID is '1234', the update payment URL would be https://www.rechargebilling.com/update/1234
oneTime Indicates that a charge was a one-time only transaction. When specified as '1' in your POST request, Recharge will process the charge immediately and return a <transaction> element describing the charge result.

 

Create Charge

POST /charges

Creates a new recurring charge in Recharge, assigns it to a Customer and returns information about it.

If the billing start date is before or equal to today, Recharge will attempt the first charge.

Request

$fields['customer'] = "cu4e8adefb8c96f"; 
$fields['payMethod'] = "pm4e8ae6d5b9e23"; 
$fields['billingStartDate'] = "09/25/2023"; 
$fields['billingEndDate'] = ""; 
$fields['billingEndAmount'] = ""; 
$fields['product'] = "pr4e8ade1abbf67"; 
$fields['price'] = ""; 
$fields['intervalValue'] = ""; 
$fields['intervalUnit'] = ""; 
$fields['oneTime'] = "0";

Response

<charge id="ch4ea213331cba2">
	<id>ch4ea213331cba2</id> 
	<product>pr4e8ade1abbf67</product>  
	<payMethod>pm4e8ae6d5b9e23</payMethod> 
	<billingStartDate>09/25/2023 12:00 AM</billingStartDate> 
	<billingEndDate></billingEndDate> 
	<billingEndAmount></billingEndAmount> 
	<price>1.00</price>   
	<intervalValue>1</intervalValue> 
	<intervalUnit>m</intervalUnit> 
	<nextChargeDate>09/25/2023 12:00 AM</nextChargeDate> 
	<totalRevenue>0.00</totalRevenue> 
	<pubID>4d74a400da49be88622990448af17706edc5a722</pubID> 
</charge>

 

Get Charge Details

GET /charges/<charge_id>

Returns information about a specific Charge.

Response

<charge id="ch4ea213331cba2">
	<id>ch4ea213331cba2</id> 
	<product>pr4e8ade1abbf67</product>  
	<payMethod>pm4e8ae6d5b9e23</payMethod> 
	<billingStartDate>09/25/2023 12:00 AM</billingStartDate> 
	<billingEndDate></billingEndDate> 
	<billingEndAmount></billingEndAmount> 
	<price>1.00</price>   
	<intervalValue>1</intervalValue> 
	<intervalUnit>m</intervalUnit> 
	<nextChargeDate>09/25/2023 12:00 AM</nextChargeDate> 
	<totalRevenue>0.00</totalRevenue> 
	<pubID>4d74a400da49be88622990448af17706edc5a722</pubID> 
</charge>

 

Edit Charge

POST /charges/<charge_id>

Edits a Charge and returns current information about it.

The example below changes the card that should be used for this charge.

Request

$fields['payMethod'] = "pm4ea2162f9a160";

Response

<charge id="ch4ea213331cba2">
	<id>ch4ea213331cba2</id> 
	<product>pr4e8ade1abbf67</product>  
	<payMethod>pm4ea2162f9a160</payMethod> 
	<billingStartDate>09/25/2023 12:00 AM</billingStartDate> 
	<billingEndDate></billingEndDate> 
	<billingEndAmount></billingEndAmount> 
	<price>1.00</price>   
	<intervalValue>1</intervalValue> 
	<intervalUnit>m</intervalUnit> 
	<nextChargeDate>09/25/2023 12:00 AM</nextChargeDate> 
	<totalRevenue>0.00</totalRevenue> 
	<pubID>4d74a400da49be88622990448af17706edc5a722</pubID> 
</charge>

 

Delete Charge

DELETE /charges/<charge_id>

Deletes the Charge from Recharge and cancels all future transactions. Does not delete the Customer or any associated Payment Methods.