Customer Balances

Account balances are simply a way to directly set how much a customer owes or is owed.

You can establish an account balance when you create the customer:

# Set your secret key: remember to change this to your live secret key in production
# See your keys here: https://dashboard.stripe.com/account/apikeys
Stripe.api_key = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"

Stripe::Customer.create(
  :source => token, # obtained with Stripe.js
  :plan => "basic_monthly",
  :email => "[email protected]",
  :account_balance => 1000
)
# Set your secret key: remember to change this to your live secret key in production
# See your keys here: https://dashboard.stripe.com/account/apikeys
stripe.api_key = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"

stripe.Customer.create(
  source=token, # obtained with Stripe.js
  plan="basic_monthly",
  email="[email protected]",
  account_balance=1000
)
// Set your secret key: remember to change this to your live secret key in production
// See your keys here: https://dashboard.stripe.com/account/apikeys
\Stripe\Stripe::setApiKey("sk_test_BQokikJOvBiI2HlWgH4olfQ2");

$customer = \Stripe\Customer::create(array(
  "source" => $token,
  "plan" => "basic_monthly",
  "email" => "[email protected]",
  "account_balance" => 1000
));
// Set your secret key: remember to change this to your live secret key in production
// See your keys here: https://dashboard.stripe.com/account/apikeys
var stripe = require("stripe")("sk_test_BQokikJOvBiI2HlWgH4olfQ2");

stripe.customers.create({
  source: token,
  plan: "basic_monthly",
  email: "[email protected]",
  account_balance: 1000
}, function(err, customer) {
  // asynchronously called
});
// Set your secret key: remember to change this to your live secret key in production
// See your keys here: https://dashboard.stripe.com/account/apikeys
Stripe.apiKey = "sk_test_BQokikJOvBiI2HlWgH4olfQ2";

Map<String, Object> customerParams = new HashMap<String, Object>();
customerParams.put("source", token);
customerParams.put("plan", "basic_monthly");
customerParams.put("email", "[email protected]");
customerParams.put("account_balance", 1000);

Customer customer = Customer.create(customerParams);

The amount needs to be an integer in cents. Like invoice items, customer account balances will automatically be factored into the next invoice. A positive amount as a customer balance increases the amount of the next invoice. A negative amount becomes a credit that decreases the amount of the next invoice.

You can also set the account balance by updating a customer:

# Set your secret key: remember to change this to your live secret key in production
# See your keys here: https://dashboard.stripe.com/account/apikeys
Stripe.api_key = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"

cu = Stripe::Customer.retrieve("cus_3R1W8PG2DmsmM9")
cu.account_balance = 1000
cu.save
# Set your secret key: remember to change this to your live secret key in production
# See your keys here: https://dashboard.stripe.com/account/apikeys
stripe.api_key = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"

cu = stripe.Customer.retrieve("cus_3R1W8PG2DmsmM9")
cu.account_balance = 1000
cu.save()
// Set your secret key: remember to change this to your live secret key in production
// See your keys here: https://dashboard.stripe.com/account/apikeys
\Stripe\Stripe::setApiKey("sk_test_BQokikJOvBiI2HlWgH4olfQ2");

$cu = \Stripe\Customer::retrieve("cus_3R1W8PG2DmsmM9");
$cu->account_balance = 1000;
$cu->save();
// Set your secret key: remember to change this to your live secret key in production
// See your keys here: https://dashboard.stripe.com/account/apikeys
var stripe = require("stripe")("sk_test_BQokikJOvBiI2HlWgH4olfQ2");

stripe.customers.update("cus_3R1W8PG2DmsmM9", {
  account_balance: 1000
}, function(err, customer) {
  // asynchronously called
});
// Set your secret key: remember to change this to your live secret key in production
// See your keys here: https://dashboard.stripe.com/account/apikeys
Stripe.apiKey = "sk_test_BQokikJOvBiI2HlWgH4olfQ2";

Customer cu = Customer.retrieve("cus_3R1W8PG2DmsmM9");

Map<String, Object> customerParams = new HashMap<String, Object>();
customerParams.put("account_balance", "1000");

cu.update(customerParams);

Account balances are easy to implement and understand–and they don’t impact one-off charges. The main downside to manipulating amounts charged via account balances is that they don’t provide a way to document the adjustment, as you can using the description on an invoice item or by applying a discount.

Next up