Represents a customer. Subscriptions, Card and Billing Address are associated with the customer resource. Customer resource will be created along with subscription via "Create a Subscription" API. The id of the customer will be same as that of associated subscription id if not explictly set.

The Billing Address is significant especially when EU VAT taxes are involved, for tax calculations will be based on this address. For customers without Billing Address, EU VAT taxes will not be included. Thus ensure to set this properly if you have configured EU VAT Tax.

Note: For the customers who signed up before 1st Mar 2014, Customer's Billing Address and 'vat_number' will be replaced automatically whenever the associated Card gets updated. i.e existing values for Billing Address and 'vat_number' will be cleared and the new values will be set. This behaviour is changed now - The VAT Number should always be passed along Billing Address and not with Card address. Both the addresses have to be dealt separately.

Sample customer [ JSON ]

{ "id": "8avVGOkx8U1MX", "first_name": "Benjamin", "last_name": "Ross", "email": "Benjamin@test.com", "auto_collection": "on", "created_at": 1317407411, "object": "customer", "card_status": "valid", "payment_method": { "object": "payment_method", "type": "card", "gateway": "chargebee", "reference_id": "tok_KyVr8xPHl5BSx1", "status": "valid" }, "account_credits": 0 }

Model Class

ChargeBee_Customer
id
Identifier of the customer.
string, max chars=50
firstName
First name of the customer.
optional, string, max chars=150
lastName
Last name of the customer.
optional, string, max chars=150
email
Email of the customer. Configured email notifications will be sent to this email.
optional, string, max chars=70
phone
Phone number of the customer.
optional, string, max chars=50
company
Company name of the customer.
optional, string, max chars=250
vatNumber
VAT number of this customer. Will be validated using the VIES service. To disable this validation, go to 'Settings -> Site Info' page and select the checkbox 'Disable VAT validation'.
optional, string, max chars=20
autoCollection
Whether payments needs to be collected automatically for this customer.
enumerated string, default=on
Possible values are:
on :Whenever an invoice is created, an automatic attempt to charge the customer's payment method is made.off :Whenever a new invoice is created, there will no attempt made to charge the customer. All payment reconciliations must be recorded offline.
createdAt
Timestamp indicating when this customer resource is created.
timestamp(UTC) in seconds
createdFromIp
The IP address of the customer. Used primarly for referral integration and EU VAT validation.
optional, string, max chars=50
cardStatus
Status of the card on file for this customer.
optional, enumerated string
Possible values are:
no_card :No credit card is associated with the customer.valid :There is a valid card available for this customer.expiring :The credit card is expiring soon. Indicates that the customer has to update the card soon.expired :The card is expired and cannot be used to charge the subscriptions anymore.
invoiceNotes
Invoice Notes for this resource. Read More.
optional, string, max chars=1000
accountCredits
Account credit balance of this customer.
in cents, min=0
billingAddress
Show attributes[+]
Billing address for a customer.
optional, billing_address
Billing addres attributes
firstName
First name.
optional, string, max chars=150
lastName
Last name.
optional, string, max chars=150
email
Email.
optional, string, max chars=70
company
Company name.
optional, string, max chars=250
phone
Phone number.
optional, string, max chars=50
line1
Address line 1.
optional, string, max chars=150
line2
Address line 2.
optional, string, max chars=150
line3
Address line 3.
optional, string, max chars=150
city
City.
optional, string, max chars=50
stateCode
The ISO 3166-2 state/province code. Supported only for countries US and Canada.
optional, string, max chars=50
state
State or Province.
optional, string, max chars=50
country
2-letter ISO 3166 alpha-2 country code.
optional, string, max chars=50
zip
Zip or Postal code.
optional, string, max chars=20
paymentMethod
Show attributes[+]
Payment method of a customer.
optional, payment_method
Payment method attributes
type
Type of payment method.
optional, enumerated string
Possible values are:
card :Card based payment inluding credit cards and debit cards. Details about the card can be obtained from the card resource.paypal_express_checkout :Paypal Express Checkout based payment.amazon_payments :Amazon login and pay based payment.
gateway
Name of the gateway the card is associated with. Applicable only if the type is card.
enumerated string
Possible values are:
chargebee :ChargeBee test gateway.stripe :Stripe payment gateway.braintree :Braintree payment gateway.authorize_net :Authorize.net payment gateway.
paypal_pro :Paypal Pro Account.pin :Pin payment gateway.eway :eWAy Account.eway_rapid :eWAy Rapid gateway.worldpay :WorldPay payment gateway.balanced_payments :Balanced payment gateway.beanstream :Beanstream Account.bluepay :BluePay payment gateway.elavon :Elavon Virtual Merchant.first_data_global :First Data Global Gateway Virtual Terminal Account.hdfc :HDFC Account.migs :MasterCard Internet Gateway Service.nmi :NMI gateway.ogone :Ogone Account.paymill :Paymill payment gateway.paypal_payflow_pro :Paypal Payflow Pro gateway.sage_pay :Sage Pay gateway.tco :2Checkout payment gateway.wirecard :WireCard Account.not_applicable :Indicates that payment gateway is not applicable for this resource.
Show all values[+]
status
Current status of the payment method.
enumerated string, default=valid
Possible values are:
valid :A payment method that is valid and active.expiring :A payment method that is expiring (like card's status based on its expiry date).expired :A payment method that has expired.invalid :The billing agreement cannot be used. It might become valid again either automatically or due to customer action.
referenceId
The reference id. In the case of Amazon and Paypal this will be the 'billing agreement id'. In the case of card this will be the identifier provided by the gateway/card vault for the specific payment method resource. Note: This is not the one time temporary token provided by gateways like Stripe.
optional, string, max chars=50

Creates a customer. You can create a customer and then create subscriptions for the customer when required. When creating a customer, you can pass along the billing address and card details.

Passing credit card details to through the API involves PCI liability at your end as sensitive card information passes through your servers. If you wish to avoid that, you can use one of the following integration methodologies if applicable:

  • If you are using Stripe gateway, you can use Stripe.js with your checkout form. Please refer this tutorial for more details.
  • If you are using Braintree gateway, you can use Braintree.js with your checkout form.
  • You can also use our Hosted Pages based integration.

The Billing Address is significant especially when EU VAT taxes are involved, for tax calculations will be based on this address. For customers without a billing address, EU VAT taxes will not be included. Thus ensure to set this properly if you have configured EU VAT Tax.

Billing Address attributes shall be explicitly passed for customers paying offline(Cash, Check, Bank Transfer etc).

Note: When an invoice is generated for a customer, the billing address provided for the customer will be stored with the invoice. If the First Name, Last Name, and Company fields do not contain any information under Billing Info, the same will be picked from Customer Details if the same is available there.

Sample Code
require 'ChargeBee.php';
ChargeBee_Environment::configure("{site}","{site_api_key}");
$result = ChargeBee_Customer::create(array(
  "firstName" => "John", 
  "lastName" => "Doe", 
  "email" => "john@test.com", 
  "billingAddress" => array(
    "firstName" => "John", 
    "lastName" => "Doe", 
    "line1" => "PO Box 9999", 
    "city" => "Walnut", 
    "state" => "California", 
    "zip" => "91789", 
    "country" => "US"
  )));
$customer = $result->customer();
$card = $result->card();
copy
require 'ChargeBee.php';
ChargeBee_Environment::configure("{site}","{site_api_key}");
$result = ChargeBee_Customer::create(array(
  "firstName" => "John", 
  "lastName" => "Doe", 
  "email" => "john@test.com", 
  "billingAddress" => array(
    "firstName" => "John", 
    "lastName" => "Doe", 
    "line1" => "PO Box 9999", 
    "city" => "Walnut", 
    "state" => "California", 
    "zip" => "91789", 
    "country" => "US"
  )));
$customer = $result->customer();
$card = $result->card();

Sample Result [ JSON ]

{"customer": { "id": "KyVrKRPHl5UP83m", "first_name": "John", "last_name": "Doe", "email": "john@test.com", "auto_collection": "on", "created_at": 1436275944, "object": "customer", "billing_address": { "first_name": "John", "last_name": "Doe", "line1": "PO Box 9999", "city": "Walnut", "state_code": "CA", "state": "California", "country": "US", "zip": "91789", "object": "billing_address" }, "card_status": "no_card", "account_credits": 0 }}

Method

ChargeBee_Customer::create(array(<param name> => <value>,<param name> => <value> ...))
id
Id for the new customer. If not given, this will be auto-generated.
optional, string, max chars=50
firstName
First name of the customer.
optional, string, max chars=150
lastName
Last name of the customer.
optional, string, max chars=150
email
Email of the customer. Configured email notifications will be sent to this email.
optional, string, max chars=70
phone
Phone number of the customer.
optional, string, max chars=50
company
Company name of the customer.
optional, string, max chars=250
autoCollection
Whether payments needs to be collected automatically for this customer.
optional, enumerated string, default=on
Possible values are:
on :Whenever an invoice is created, an automatic attempt to charge the customer's payment method is made.off :Whenever a new invoice is created, there will no attempt made to charge the customer. All payment reconciliations must be recorded offline.
vatNumber
VAT number of this customer. Will be validated using the VIES service. To disable this validation, go to 'Settings -> Site Info' page and select the checkbox 'Disable VAT validation'.
optional, string, max chars=20
createdFromIp
The IP address of the customer. Used primarly for referral integration and EU VAT validation.
optional, string, max chars=50
invoiceNotes
Invoice Notes for this resource. Read More.
optional, string, max chars=1000
card
Associative array of parameters for card
pass parameters as card => array("<param name>" => "<value>",...)
gateway
Name of the gateway this card is stored with.
optional, enumerated string
Possible values are:
chargebee :ChargeBee test gateway.stripe :Stripe payment gateway.braintree :Braintree payment gateway.authorize_net :Authorize.net payment gateway.
paypal_pro :Paypal Pro Account.pin :Pin payment gateway.eway :eWAy Account.eway_rapid :eWAy Rapid gateway.worldpay :WorldPay payment gateway.balanced_payments :Balanced payment gateway.beanstream :Beanstream Account.bluepay :BluePay payment gateway.elavon :Elavon Virtual Merchant.first_data_global :First Data Global Gateway Virtual Terminal Account.hdfc :HDFC Account.migs :MasterCard Internet Gateway Service.nmi :NMI gateway.ogone :Ogone Account.paymill :Paymill payment gateway.paypal_payflow_pro :Paypal Payflow Pro gateway.sage_pay :Sage Pay gateway.tco :2Checkout payment gateway.wirecard :WireCard Account.not_applicable :Indicates that payment gateway is not applicable for this resource.
Show all values[+]
tmpToken
The single-use card token returned by vaults like Stripe which acts as a substitute for your card detail. Before calling this API, you should have submitted your card details to the gateway (Stripe) and got this token in return.
Note: Supported only for Stripe gateway and with this value specified there is no need to specify other card details(like number, cvv etc).
optional, string, max chars=50
firstName
Cardholder's first name.
optional, string, max chars=50
lastName
Cardholder's last name.
optional, string, max chars=50
number
The credit card number without any format. If you are using Braintree.js, you can specify the Braintree encrypted card number here.
required if card provided, string, max chars=520
expiryMonth
Card expiry month.
required if card provided, integer, min=1, max=12
expiryYear
Card expiry year.
required if card provided, integer
cvv
The card verification value. If you are using Braintree.js, you can specify the Braintree encrypted cvv here.
optional, string, max chars=520
billingAddr1
Address line 1, as in card billing address.
optional, string, max chars=150
billingAddr2
Address line 2, as in card billing address.
optional, string, max chars=150
billingCity
City, as in card billing address.
optional, string, max chars=50
billingStateCode
The ISO 3166-2 state/province code. The recommended way of passing the state/province information. Supported for US and Canada now. Further if this is specified, 'state' attribute should not be specified as it will be set automatically.
optional, string, max chars=50
billingState
The state/province name. Use this to pass the state/province information for cases where 'state_code' is not supported or cannot be passed.
optional, string, max chars=50
billingZip
Postal or Zip code, as in card billing address.
optional, string, max chars=20
billingCountry
2-letter ISO 3166 alpha-2 country code.
optional, string, max chars=50
ipAddress
The IP address from where the payment method is created or updated. Used primarly for EU VAT validation.
optional, string, max chars=50
paymentMethod
Associative array of parameters for paymentMethod
pass parameters as paymentMethod => array("<param name>" => "<value>",...)
type
The type of payment method. For more details refer Update payment method for a customer API under Customer resource.
optional, enumerated string
Possible values are:
card :Card based payment inluding credit cards and debit cards. Details about the card can be obtained from the card resource.paypal_express_checkout :Paypal Express Checkout based payment.amazon_payments :Amazon login and pay based payment.
gateway
Name of the gateway the card is associated with. Applicable only if the type is card.
optional, enumerated string
Possible values are:
stripe :Stripe payment gateway.braintree :Braintree payment gateway.authorize_net :Authorize.net payment gateway.
paypal_pro :Paypal Pro Account.pin :Pin payment gateway.eway :eWAy Account.eway_rapid :eWAy Rapid gateway.worldpay :WorldPay payment gateway.balanced_payments :Balanced payment gateway.beanstream :Beanstream Account.bluepay :BluePay payment gateway.elavon :Elavon Virtual Merchant.first_data_global :First Data Global Gateway Virtual Terminal Account.hdfc :HDFC Account.migs :MasterCard Internet Gateway Service.nmi :NMI gateway.ogone :Ogone Account.paymill :Paymill payment gateway.paypal_payflow_pro :Paypal Payflow Pro gateway.sage_pay :Sage Pay gateway.tco :2Checkout payment gateway.wirecard :WireCard Account.not_applicable :Indicates that payment gateway is not applicable for this resource.
Show all values[+]
referenceId
The reference id. In the case of Amazon and Paypal this will be the billing agreement id. In the case of card this will be the identifier provided by the gateway/card vault for the specific payment method resource. Note: This is not the one time temporary token provided by gateways like Stripe.
For more details refer Update payment method for a customer API under Customer resource.
optional, string, max chars=50
billingAddress
Associative array of parameters for billingAddress
pass parameters as billingAddress => array("<param name>" => "<value>",...)
firstName
First name.
optional, string, max chars=150
lastName
Last name.
optional, string, max chars=150
email
Email.
optional, string, max chars=70
company
Company name.
optional, string, max chars=250
phone
Phone number.
optional, string, max chars=50
line1
Address line 1.
optional, string, max chars=150
line2
Address line 2.
optional, string, max chars=150
line3
Address line 3.
optional, string, max chars=150
city
City.
optional, string, max chars=50
stateCode
The ISO 3166-2 state/province code. The recommended way of passing the state/province information. Supported for US and Canada now. Further if this is specified, 'state' attribute should not be specified as it will be set automatically.
optional, string, max chars=50
state
The state/province name. Use this to pass the state/province information for cases where 'state_code' is not supported or cannot be passed.
optional, string, max chars=50
zip
Zip or Postal code.
optional, string, max chars=20
country
2-letter ISO 3166 alpha-2 country code.
optional, string, max chars=50
Resource object representing customer.
always returned
Resource object representing card.
optional
Retrieves the list of customers with the recent ones on top.
Sample Code
require 'ChargeBee.php';
ChargeBee_Environment::configure("{site}","{site_api_key}");
$all = ChargeBee_Customer::all(array(
  "limit" => 5));
foreach($all as $entry){
  $customer = $entry->customer();
  $card = $entry->card();
}
copy
require 'ChargeBee.php';
ChargeBee_Environment::configure("{site}","{site_api_key}");
$all = ChargeBee_Customer::all(array(
  "limit" => 5));
foreach($all as $entry){
  $customer = $entry->customer();
  $card = $entry->card();
}

Sample Result [ JSON ]

{ "list": [ {"customer": { "id": "KyVrKRPHl5UP83m", "first_name": "John", "last_name": "Doe", "email": "john@test.com", "auto_collection": "on", "created_at": 1436275944, "object": "customer", "billing_address": { "first_name": "John", "last_name": "Doe", "line1": "PO Box 9999", "city": "Walnut", "state_code": "CA", "state": "California", "country": "US", "zip": "91789", "object": "billing_address" }, "card_status": "no_card", "account_credits": 0 }}, {..} ], "next_offset": "[\"1436275944000\",\"71000000110\"]" }

Method

ChargeBee_Customer::all(array(<param name> => <value>,<param name> => <value> ...))
limit
Limits the number of resources to be returned.
optional, integer, default=10, min=1, max=100
offset
Allows you to fetch the next set of resources. The value used for this parameter must be the value returned for next_offset parameter in the previous API call.
optional, string, max chars=1000
Resource object representing customer.
always returned
Resource object representing card.
optional
next_offset
This attribute is returned only if more resources are present. To fetch the next set of resources use this value for the input parameter “offset”.
optional, string, max chars=1000
Retrieves the customer identified by the unique identifier.
Sample Code
require 'ChargeBee.php';
ChargeBee_Environment::configure("{site}","{site_api_key}");
$result = ChargeBee_Customer::retrieve("8avVGOkx8U1MX");
$customer = $result->customer();
$card = $result->card();
copy
require 'ChargeBee.php';
ChargeBee_Environment::configure("{site}","{site_api_key}");
$result = ChargeBee_Customer::retrieve("8avVGOkx8U1MX");
$customer = $result->customer();
$card = $result->card();

Sample Result [ JSON ]

{"customer": { "id": "8avVGOkx8U1MX", "first_name": "Benjamin", "last_name": "Ross", "email": "Benjamin@test.com", "auto_collection": "off", "created_at": 1317407411, "object": "customer", "card_status": "no_card", "account_credits": 0 }}

Method

ChargeBee_Customer::retrieve(<customer_id>)
Resource object representing customer.
always returned
Resource object representing card.
optional

Updates the customer resource. However this method cannot be used for updating the 'Billing Info' - the Billing Address and 'vat_number' attributes - of the customer. To update the same, use our Update Billing Info API.

Sample Code
require 'ChargeBee.php';
ChargeBee_Environment::configure("{site}","{site_api_key}");
$result = ChargeBee_Customer::update("8avVGOkx8U1MX", array(
  "firstName" => "Denise", 
  "lastName" => "Barone"));
$customer = $result->customer();
$card = $result->card();
copy
require 'ChargeBee.php';
ChargeBee_Environment::configure("{site}","{site_api_key}");
$result = ChargeBee_Customer::update("8avVGOkx8U1MX", array(
  "firstName" => "Denise", 
  "lastName" => "Barone"));
$customer = $result->customer();
$card = $result->card();

Sample Result [ JSON ]

{"customer": { "id": "8avVGOkx8U1MX", "first_name": "Denise", "last_name": "Barone", "email": "Benjamin@test.com", "auto_collection": "off", "created_at": 1317407411, "object": "customer", "card_status": "no_card", "account_credits": 0 }}

Method

ChargeBee_Customer::update(<customer_id>,array(<param name> => <value>,<param name> => <value> ...))
firstName
First name of the customer.
optional, string, max chars=150
lastName
Last name of the customer.
optional, string, max chars=150
email
Email of the customer. Configured email notifications will be sent to this email.
optional, string, max chars=70
phone
Phone number of the customer.
optional, string, max chars=50
company
Company name of the customer.
optional, string, max chars=250
autoCollection
Whether payments needs to be collected automatically for this customer.
optional, enumerated string, default=on
Possible values are:
on :Whenever an invoice is created, an automatic attempt to charge the customer's payment method is made.off :Whenever a new invoice is created, there will no attempt made to charge the customer. All payment reconciliations must be recorded offline.
invoiceNotes
Invoice Notes for this resource. Read More.
optional, string, max chars=1000
Resource object representing customer.
always returned
Resource object representing card.
optional

Updates payment method details for a customer.

Note: If you wish to pass the card number, CVV, or the single-use card tokens provided by gateways like Stripe, then use the Update card for a customer API under Cards resource. This API is not supported for Chargebee Test Gateway, which is provided to help you understand the billing workflow in Chargebee.

PayPal Express Checkout
You can use this API if you are directly integrating PayPal Express Checkout in your website instead of using ChargeBee's hosted pages. When your customer updates his payment method using PayPal Express Checkout, you will be provided with the Billing Agreement ID by PayPal. You can update the payment method for that customer in Chargebee by passing type as paypal_express_checkout and reference_id with the Billing Agreement ID.

Login and Pay with Amazon
You can use this API if you are directly integrating Login and Pay with Amazon in your website instead of using ChargeBee's hosted pages. When your customer updates Amazon as a payment method, you will be provided with the Billing Agreement ID by Amazon. You can update the payment method for that customer in Chargebee by passing type as amazon_payments and reference_id with the Billing Agreement ID.

Card Payments
When the card details of your customer are stored in the vault of gateways such as Stripe or Braintree, you can use this API to update the reference id provided by them in Chargebee. To use this API, pass

  • type as card.
  • gateway with the gateway associated with the card. If the gateway is not specified, the default gateway will be used.
  • reference_id with the identifier provided by the gateway/Spreedly to reference that specific card.

Reference id format for Card Payments
The format of reference_id will differ based on where the card is stored.
Stripe: In case of Stripe, the reference_id consists of combination of Stripe Customer ID and Stripe Card ID separated by forward slash (e.g. cus_63MnDn0t6kfDW7/card_6WjCF20vT9WN1G). If you are passing Stripe Customer ID alone, then ChargeBee will store the card marked as active for that customer in Stripe.
Braintree: In case of Braintree, the reference_id consists of combination of Braintree Customer ID and Braintree Payment Method Token separated by forward slash (e.g. cus_63MnDn0t6kfDW7/card_6WjCF20vT9WN1G). If you are passing Braintree Customer ID alone, then Chargebee will store the card marked as default for that customer in Braintree.
Spreedly Card vault: If the card details are stored in Spreedly vault, then you need to provide the Spreedly token as reference_id.

While using this API to update payment method details, the following operations will not be supported:
  • Card Verification
    Card Verification will not be done even if it is enabled for that particular gateway.
  • Collecting Latest Unpaid invoice
    An attempt to collect the latest unpaid invoice will not be made even if the option to "Collect Invoice on Card Update" is enabled.
Sample Code
require 'ChargeBee.php';
ChargeBee_Environment::configure("{site}","{site_api_key}");
$result = ChargeBee_Customer::updatePaymentMethod("8avVGOkx8U1MX", array(
  "paymentMethod" => array(
    "type" => "paypal_express_checkout", 
    "referenceId" => "B-09u9343Sde24D"
  )));
$customer = $result->customer();
$card = $result->card();
copy
require 'ChargeBee.php';
ChargeBee_Environment::configure("{site}","{site_api_key}");
$result = ChargeBee_Customer::updatePaymentMethod("8avVGOkx8U1MX", array(
  "paymentMethod" => array(
    "type" => "paypal_express_checkout", 
    "referenceId" => "B-09u9343Sde24D"
  )));
$customer = $result->customer();
$card = $result->card();

Sample Result [ JSON ]

{"customer": { "id": "KyVr8xPHl5GoC4i", "first_name": "John", "last_name": "Doe", "email": "john@test.com", "auto_collection": "on", "created_at": 1436275891, "object": "customer", "billing_address": { "first_name": "Saravanan", "last_name": "KP", "phone": "123456", "line1": "1 Main St", "city": "San Jose", "state_code": "CA", "state": "California", "country": "US", "zip": "95131", "object": "billing_address" }, "payment_method": { "object": "payment_method", "type": "paypal_express_checkout", "reference_id": "B-9G419819UU238350F", "status": "valid" }, "account_credits": 0 }}

Method

ChargeBee_Customer::updatePaymentMethod(<customer_id>,array(<param name> => <value>,<param name> => <value> ...))
paymentMethod
Associative array of parameters for paymentMethod
pass parameters as paymentMethod => array("<param name>" => "<value>",...)
type
The type of payment method. For more details refer Update payment method for a customer API under Customer resource.
required, enumerated string
Possible values are:
card :Card based payment inluding credit cards and debit cards. Details about the card can be obtained from the card resource.paypal_express_checkout :Paypal Express Checkout based payment.amazon_payments :Amazon login and pay based payment.
gateway
Name of the gateway the card is associated with. Applicable only if the type is card.
optional, enumerated string
Possible values are:
stripe :Stripe payment gateway.braintree :Braintree payment gateway.authorize_net :Authorize.net payment gateway.
paypal_pro :Paypal Pro Account.pin :Pin payment gateway.eway :eWAy Account.eway_rapid :eWAy Rapid gateway.worldpay :WorldPay payment gateway.balanced_payments :Balanced payment gateway.beanstream :Beanstream Account.bluepay :BluePay payment gateway.elavon :Elavon Virtual Merchant.first_data_global :First Data Global Gateway Virtual Terminal Account.hdfc :HDFC Account.migs :MasterCard Internet Gateway Service.nmi :NMI gateway.ogone :Ogone Account.paymill :Paymill payment gateway.paypal_payflow_pro :Paypal Payflow Pro gateway.sage_pay :Sage Pay gateway.tco :2Checkout payment gateway.wirecard :WireCard Account.not_applicable :Indicates that payment gateway is not applicable for this resource.
Show all values[+]
referenceId
The reference id. In the case of Amazon and Paypal this will be the billing agreement id. In the case of card this will be the identifier provided by the gateway/card vault for the specific payment method resource. Note: This is not the one time temporary token provided by gateways like Stripe.
For more details refer Update payment method for a customer API under Customer resource.
required, string, max chars=50
Resource object representing customer.
always returned
Resource object representing card.
optional

This method is used for updating the 'Billing Info' - the Billing Address and 'vat_number' attributes - of the customer. For updating the other customer attributes use our Update Customer API.

During this operation if Billing Info(Billing Address and vat_number) is not already present it will get added. Whereas if it is present already, the existing values will be replaced. i.e existing values for Billing Address and vat_number will be cleared and the new values will be set.

Note: When an invoice is generated for a customer, the billing address provided for the customer will be stored with the invoice. If the First Name, Last Name, and Company fields do not contain any information under Billing Info, the same will be picked from Customer Details if the same is available there.

Sample Code
require 'ChargeBee.php';
ChargeBee_Environment::configure("{site}","{site_api_key}");
$result = ChargeBee_Customer::updateBillingInfo("8avVGOkx8U1MX", array(
  "billingAddress" => array(
    "firstName" => "John", 
    "lastName" => "Doe", 
    "line1" => "PO Box 9999", 
    "city" => "Walnut", 
    "state" => "California", 
    "zip" => "91789", 
    "country" => "US"
  )));
$customer = $result->customer();
$card = $result->card();
copy
require 'ChargeBee.php';
ChargeBee_Environment::configure("{site}","{site_api_key}");
$result = ChargeBee_Customer::updateBillingInfo("8avVGOkx8U1MX", array(
  "billingAddress" => array(
    "firstName" => "John", 
    "lastName" => "Doe", 
    "line1" => "PO Box 9999", 
    "city" => "Walnut", 
    "state" => "California", 
    "zip" => "91789", 
    "country" => "US"
  )));
$customer = $result->customer();
$card = $result->card();

Sample Result [ JSON ]

{"customer": { "id": "8avVGOkx8U1MX", "first_name": "Denise", "last_name": "Barone", "email": "Benjamin@test.com", "auto_collection": "off", "created_at": 1317407411, "object": "customer", "billing_address": { "first_name": "John", "last_name": "Doe", "line1": "PO Box 9999", "city": "Walnut", "state_code": "CA", "state": "California", "country": "US", "zip": "91789", "object": "billing_address" }, "card_status": "no_card", "account_credits": 0 }}

Method

ChargeBee_Customer::updateBillingInfo(<customer_id>,array(<param name> => <value>,<param name> => <value> ...))
vatNumber
VAT number of this customer. Will be validated using the VIES service. To disable this validation, go to 'Settings -> Site Info' page and select the checkbox 'Disable VAT validation'.
optional, string, max chars=20
billingAddress
Associative array of parameters for billingAddress
pass parameters as billingAddress => array("<param name>" => "<value>",...)
firstName
First name.
optional, string, max chars=150
lastName
Last name.
optional, string, max chars=150
email
Email.
optional, string, max chars=70
company
Company name.
optional, string, max chars=250
phone
Phone number.
optional, string, max chars=50
line1
Address line 1.
optional, string, max chars=150
line2
Address line 2.
optional, string, max chars=150
line3
Address line 3.
optional, string, max chars=150
city
City.
optional, string, max chars=50
stateCode
The ISO 3166-2 state/province code. The recommended way of passing the state/province information. Supported for US and Canada now. Further if this is specified, 'state' attribute should not be specified as it will be set automatically.
optional, string, max chars=50
state
The state/province name. Use this to pass the state/province information for cases where 'state_code' is not supported or cannot be passed.
optional, string, max chars=50
zip
Zip or Postal code.
optional, string, max chars=20
country
2-letter ISO 3166 alpha-2 country code.
optional, string, max chars=50
Resource object representing customer.
always returned
Resource object representing card.
optional

This API call can be used to add credits to a customer. Learn more about Account Credits.

For example, if a customer has credits of $10, if you pass the amount as $10, then the customer’s credit balance would become $20.

Sample Code
require 'ChargeBee.php';
ChargeBee_Environment::configure("{site}","{site_api_key}");
$result = ChargeBee_Customer::addAccountCredits("8avVGOkx8U1MX", array(
  "amount" => 500, 
  "description" => "Loyalty credits"));
$customer = $result->customer();
copy
require 'ChargeBee.php';
ChargeBee_Environment::configure("{site}","{site_api_key}");
$result = ChargeBee_Customer::addAccountCredits("8avVGOkx8U1MX", array(
  "amount" => 500, 
  "description" => "Loyalty credits"));
$customer = $result->customer();

Sample Result [ JSON ]

{"customer": { "id": "8avVGOkx8U1MX", "first_name": "Denise", "last_name": "Barone", "email": "Benjamin@test.com", "auto_collection": "off", "created_at": 1317407411, "object": "customer", "billing_address": { "first_name": "John", "last_name": "Doe", "line1": "PO Box 9999", "city": "Walnut", "state_code": "CA", "state": "California", "country": "US", "zip": "91789", "object": "billing_address" }, "card_status": "no_card", "account_credits": 500 }}

Method

ChargeBee_Customer::addAccountCredits(<customer_id>,array(<param name> => <value>,<param name> => <value> ...))
amount
Credit amount to be added.
required, in cents, min=1
description
Description for this credit.
required, string, max chars=250
Resource object representing customer.
always returned

This API call can be used to deduct credits for a customer. Learn more about Account Credits.

For example, if a customer has a credit balance of $20, if you pass the amount as $5, then the customer’s credit balance would become $15.

Sample Code
require 'ChargeBee.php';
ChargeBee_Environment::configure("{site}","{site_api_key}");
$result = ChargeBee_Customer::deductAccountCredits("8avVGOkx8U1MX", array(
  "amount" => 200, 
  "description" => "Correcting credits given by mistake"));
$customer = $result->customer();
copy
require 'ChargeBee.php';
ChargeBee_Environment::configure("{site}","{site_api_key}");
$result = ChargeBee_Customer::deductAccountCredits("8avVGOkx8U1MX", array(
  "amount" => 200, 
  "description" => "Correcting credits given by mistake"));
$customer = $result->customer();

Sample Result [ JSON ]

{"customer": { "id": "8avVGOkx8U1MX", "first_name": "Denise", "last_name": "Barone", "email": "Benjamin@test.com", "auto_collection": "off", "created_at": 1317407411, "object": "customer", "billing_address": { "first_name": "John", "last_name": "Doe", "line1": "PO Box 9999", "city": "Walnut", "state_code": "CA", "state": "California", "country": "US", "zip": "91789", "object": "billing_address" }, "card_status": "no_card", "account_credits": 300 }}

Method

ChargeBee_Customer::deductAccountCredits(<customer_id>,array(<param name> => <value>,<param name> => <value> ...))
amount
Credit amount to be deducted.
required, in cents, min=1
description
Description for this credit.
required, string, max chars=250
Resource object representing customer.
always returned

This API call can be used to set credits for a customer. Learn more about Account Credits.

For example, if a customer has a credit balance of $10 and if you would like to set the balance to $100, you could pass the amount as $100.

Sample Code
require 'ChargeBee.php';
ChargeBee_Environment::configure("{site}","{site_api_key}");
$result = ChargeBee_Customer::setAccountCredits("8avVGOkx8U1MX", array(
  "amount" => 1200, 
  "description" => "Correcting credits given by mistake"));
$customer = $result->customer();
copy
require 'ChargeBee.php';
ChargeBee_Environment::configure("{site}","{site_api_key}");
$result = ChargeBee_Customer::setAccountCredits("8avVGOkx8U1MX", array(
  "amount" => 1200, 
  "description" => "Correcting credits given by mistake"));
$customer = $result->customer();

Sample Result [ JSON ]

{"customer": { "id": "8avVGOkx8U1MX", "first_name": "Denise", "last_name": "Barone", "email": "Benjamin@test.com", "auto_collection": "off", "created_at": 1317407411, "object": "customer", "billing_address": { "first_name": "John", "last_name": "Doe", "line1": "PO Box 9999", "city": "Walnut", "state_code": "CA", "state": "California", "country": "US", "zip": "91789", "object": "billing_address" }, "card_status": "no_card", "account_credits": 1200 }}

Method

ChargeBee_Customer::setAccountCredits(<customer_id>,array(<param name> => <value>,<param name> => <value> ...))
amount
Credit amount to be set.
required, in cents, min=0
description
Description for this credit.
required, string, max chars=250
Resource object representing customer.
always returned