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": "4gkYnd21ouvW", "email": "jane@test.com", "auto_collection": "on", "allow_direct_debit": false, "created_at": 1412101833, "taxability": "taxable", "object": "customer", "card_status": "no_card", "contacts": [ { "id": "ty68op521m", "first_name": "Michel", "last_name": "Ross", "email": "Mike@test.com", "label": "Mike", "enabled": true, "send_account_email": true, "send_billing_email": false, "object": "contact" }, {..} ], "promotional_credits": 0, "refundable_credits": 0, "excess_payments": 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
onWhenever an invoice is created, an automatic attempt to charge the customer's payment method is made.offWhenever a new invoice is created, there will no attempt made to charge the customer. All payment reconciliations must be recorded offline.
allowDirectDebit
Whether the customer can pay via Direct Debit.
boolean, default=false
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
taxability
Specifies if the customer is liable for tax.
optional, enumerated string, default=taxable
Possible values are
taxableCustomer is taxable.exemptCustomer is exempted from tax.
entityCode
The exemption category of the customer, for the USA and Canada. applicable if you use Chargebee's Avalara integration.
optional, enumerated string
Possible values are
aFederal government (United States).bState government (United States).cTribe/Status Indian/Indian Band (both).dForeign diplomat (both).
eCharitable or benevolent org (both).fReligious or educational org (both).gResale (both).hCommercial agricultural production (both).iIndustrial production/manufacturer (both).jDirect pay permit (United States).kDirect mail (United States).lOther (both).nLocal government (United States).pCommercial aquaculture (Canada).qCommercial Fishery (Canada).rNon-resident (Canada).med1US Medical Device Excise Tax with exempt sales tax.med2US Medical Device Excise Tax with taxable sales tax.
Show all values[+]
exemptNumber
Any string value that will cause the sale to be exempted. Use this if your finance team manually verifies and tracks exemption certificates. Applicable only for Avalara.
optional, string, max chars=100
fraudFlag
Indicates whether or not the customer has been identified as fraudulent.
optional, enumerated string
Possible values are
safeThe customer has been marked as safe.suspiciousThe customer has been identified as potentially fraudulent by the gateway.fraudulentThe customer has been marked as fraudulent.
invoiceNotes
Invoice Notes for this resource. Read More.
optional, string, max chars=1000
promotionalCredits
Promotional credits balance of this customer.
in cents, min=0
refundableCredits
Refundable credits balance of this customer.
in cents, min=0
excessPayments
Total unused payments associated with the customer.
in cents, min=0
metaData
Additional data about this resource can be stored here in the JSON Format. Learn more.
optional, jsonobject
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
validationStatus
The address verification status.
optional, enumerated string, default=not_validated
Possible values are
not_validatedAddress is not yet validated.validAddress was validated successfully.partially_validAddress is verified but only partially.invalidAddress is invalid.
contacts.
optional, list of contact
Contact attributes
id
Unique reference ID provided for the contact.
string, max chars=150
firstName
First name of the contact.
optional, string, max chars=150
lastName
Last name of the contact.
optional, string, max chars=150
email
Email of the contact.
string, max chars=70
phone
Phone number of the contact.
optional, string, max chars=50
label
Label/Tag provided for contact.
optional, string, max chars=50
enabled
Contact enabled / disabled.
boolean, default=false
sendAccountEmail
Whether Account Emails option is enabled for the contact.
boolean, default=false
sendBillingEmail
Whether Billing Emails option is enabled for the contact.
boolean, default=false
paymentMethod
Show attributes[+]
Payment method of a customer.
optional, payment_method
Payment method attributes
type
Type of payment method.
enumerated string
Possible values are
cardCard based payment inluding credit cards and debit cards. Details about the card can be obtained from the card resource.paypal_express_checkoutPaypal Express Checkout based payment.amazon_paymentsAmazon login and pay based payment.direct_debitDirect Debit.
gateway
Name of the gateway the payment method is associated with.
enumerated string
Possible values are
chargebeeChargebee test gateway.wepayWePay Gateway.stripeStripe payment gateway.braintreeBraintree payment gateway.
authorize_netAuthorize.net payment gateway.paypal_proPaypal Pro Account.pinPin payment gateway.ewayeWAy Account.eway_rapideWAy Rapid gateway.worldpayWorldPay payment gateway.balanced_paymentsBalanced payment gateway.beanstreamBeanstream Account.bluepayBluePay payment gateway.elavonElavon Virtual Merchant.first_data_globalFirst Data Global Gateway Virtual Terminal Account.hdfcHDFC Account.migsMasterCard Internet Gateway Service.nmiNMI gateway.ogoneOgone Account.paymillPaymill payment gateway.paypal_payflow_proPaypal Payflow Pro gateway.sage_paySage Pay gateway.tco2Checkout payment gateway.wirecardWireCard Account.gocardlessGoCardless.not_applicableIndicates 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
validA payment method that is valid and active.expiringA payment method that is expiring (like card's status based on its expiry date).expiredA payment method that has expired.invalidThe billing agreement cannot be used. It might become valid again either automatically or due to customer action.pending_verificationThe payment method need's to be verified.
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 use Stripe, you can also use Stripe.js with your checkout form, to collect card information. Here's how to set this up.
  • 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": "3Nl8JIPPtTEwuN5S", "first_name": "John", "last_name": "Doe", "email": "john@test.com", "auto_collection": "on", "allow_direct_debit": false, "created_at": 1470825272, "taxability": "taxable", "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", "promotional_credits": 0, "refundable_credits": 0, "excess_payments": 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
onWhenever an invoice is created, an automatic attempt to charge the customer's payment method is made.offWhenever a new invoice is created, there will no attempt made to charge the customer. All payment reconciliations must be recorded offline.
allowDirectDebit
Whether the customer can pay via Direct Debit.
optional, boolean, default=false
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
taxability
Specifies if the customer is liable for tax.
optional, enumerated string, default=taxable
Possible values are
taxableCustomer is taxable.exemptCustomer is exempted from tax.
entityCode
The exemption category of the customer, for the USA and Canada. applicable if you use Chargebee's Avalara integration.
optional, enumerated string
Possible values are
aFederal government (United States).bState government (United States).cTribe/Status Indian/Indian Band (both).dForeign diplomat (both).
eCharitable or benevolent org (both).fReligious or educational org (both).gResale (both).hCommercial agricultural production (both).iIndustrial production/manufacturer (both).jDirect pay permit (United States).kDirect mail (United States).lOther (both).nLocal government (United States).pCommercial aquaculture (Canada).qCommercial Fishery (Canada).rNon-resident (Canada).med1US Medical Device Excise Tax with exempt sales tax.med2US Medical Device Excise Tax with taxable sales tax.
Show all values[+]
exemptNumber
Any string value that will cause the sale to be exempted. Use this if your finance team manually verifies and tracks exemption certificates. Applicable only for Avalara.
optional, string, max chars=100
metaData
Additional data about this resource can be stored here in the JSON Format. Learn more.
optional, jsonobject
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
chargebeeChargebee test gateway.wepayWePay Gateway.stripeStripe payment gateway.braintreeBraintree payment gateway.
authorize_netAuthorize.net payment gateway.paypal_proPaypal Pro Account.pinPin payment gateway.ewayeWAy Account.eway_rapideWAy Rapid gateway.worldpayWorldPay payment gateway.balanced_paymentsBalanced payment gateway.beanstreamBeanstream Account.bluepayBluePay payment gateway.elavonElavon Virtual Merchant.first_data_globalFirst Data Global Gateway Virtual Terminal Account.hdfcHDFC Account.migsMasterCard Internet Gateway Service.nmiNMI gateway.ogoneOgone Account.paymillPaymill payment gateway.paypal_payflow_proPaypal Payflow Pro gateway.sage_paySage Pay gateway.tco2Checkout payment gateway.wirecardWireCard Account.not_applicableIndicates that payment gateway is not applicable for this resource.
Show all values[+]
tmpToken
The single-use card token returned by vaults like Stripe/Braintree which acts as a substitute for your card detail. Before calling this API, you should have submitted your card details to the gateway (Stripe/Braintree) and got this token in return.
Note: Supported only for Stripe and Braintree gateways. If this value is 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
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
cardCard based payment inluding credit cards and debit cards. Details about the card can be obtained from the card resource.paypal_express_checkoutPaypal Express Checkout based payment.amazon_paymentsAmazon login and pay based payment.direct_debitDirect Debit.
gateway
Name of the gateway the payment method is associated with.
optional, enumerated string
Possible values are
wepayWePay Gateway.stripeStripe payment gateway.braintreeBraintree payment gateway.
authorize_netAuthorize.net payment gateway.paypal_proPaypal Pro Account.pinPin payment gateway.ewayeWAy Account.eway_rapideWAy Rapid gateway.worldpayWorldPay payment gateway.balanced_paymentsBalanced payment gateway.beanstreamBeanstream Account.bluepayBluePay payment gateway.elavonElavon Virtual Merchant.first_data_globalFirst Data Global Gateway Virtual Terminal Account.hdfcHDFC Account.migsMasterCard Internet Gateway Service.nmiNMI gateway.ogoneOgone Account.paymillPaymill payment gateway.paypal_payflow_proPaypal Payflow Pro gateway.sage_paySage Pay gateway.tco2Checkout payment gateway.wirecardWireCard Account.gocardlessGoCardless.not_applicableIndicates 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
tmpToken
The single-use card token returned by vault like Stripe which acts as a substitute for your bank account detail. Before calling this API, you should have submitted your bank account details to the gateway ( Stripe ) and got this token in return.
Note: Supported only for Direct Debit ( Stripe gateway ).
required if reference_id not provided, 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
validationStatus
The address verification status.
optional, enumerated string, default=not_validated
Possible values are
not_validatedAddress is not yet validated.validAddress was validated successfully.partially_validAddress is verified but only partially.invalidAddress is invalid.
Resource object representing customer.
always returned
Resource object representing card.
optional
Retrieves the list of customers.
Sample Code
require 'ChargeBee.php';
ChargeBee_Environment::configure("{site}","{site_api_key}");
$all = ChargeBee_Customer::all(array(
  "limit" => 5, 
  "firstName[isNot]" => "John", 
  "lastName[is]" => "Doe", 
  "email[is]" => "john@test.com",
  "sortBy[asc]" => "created_at"));
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, 
  "firstName[isNot]" => "John", 
  "lastName[isNot]" => "Doe", 
  "email[is]" => "john@test.com",
  "sortBy[asc]" => "created_at"));
foreach($all as $entry){
  $customer = $entry->customer();
  $card = $entry->card();
}

Sample Result [ JSON ]

{ "list": [ {"customer": { "id": "3Nl8JIPPtTEwuN5S", "first_name": "John", "last_name": "Doe", "email": "john@test.com", "auto_collection": "on", "allow_direct_debit": false, "created_at": 1470825272, "taxability": "taxable", "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", "promotional_credits": 0, "refundable_credits": 0, "excess_payments": 0 }}, {..} ], "next_offset": "[\"1470825272000\",\"78000000430\"]" }

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
sortBy[<sort-order>]
Sorts based on the specified attribute.
Supported attributes : created_at
Supported sort-orders : asc, desc

Example "sortBy[asc]" => "created_at"
This will sort the result based on the 'created_at' attribute in ascending(earliest first) order.
optional, string filter
Filter Params
For operator usages, see the Pagination and Filtering section.
id[<operator>]
To filter based on Customer Id.
Supported operators : is, isNot, startsWith, in, notIn

Example "id[isNot]" => "9bsvnHgsvmsI"
optional, string filter
firstName[<operator>]
To filter based on Customer First Name.
Supported operators : is, isNot, startsWith, isPresent

Example "firstName[isNot]" => "John"
optional, string filter
lastName[<operator>]
To filter based on Customer Last Name.
Supported operators : is, isNot, startsWith, isPresent

Example "lastName[is]" => "Clint"
optional, string filter
email[<operator>]
To filter based on Customer Email.
Supported operators : is, isNot, startsWith, isPresent

Example "email[is]" => "john@test.com"
optional, string filter
company[<operator>]
To filter based on Customer Company.
Supported operators : is, isNot, startsWith, isPresent

Example "company[is]" => "Globex Corp"
optional, string filter
autoCollection[<operator>]
To filter based on Customer Auto Collection. Possible values are : on, off.
Supported operators : is, isNot, in, notIn

Example "autoCollection[is]" => "on"
optional, enumerated string filter
taxability[<operator>]
To filter based on Customer Taxability. Possible values are : taxable, exempt.
Supported operators : is, isNot, in, notIn

Example "taxability[is]" => "taxable"
optional, enumerated string filter
createdAt[<operator>]
To filter based on Customer Created At.
Supported operators : after, before, on, between

Example "createdAt[after]" => "1435054328"
optional, timestamp(UTC) in seconds filter
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("4gkYnd21ouvW");
$customer = $result->customer();
$card = $result->card();
copy
require 'ChargeBee.php';
ChargeBee_Environment::configure("{site}","{site_api_key}");
$result = ChargeBee_Customer::retrieve("4gkYnd21ouvW");
$customer = $result->customer();
$card = $result->card();

Sample Result [ JSON ]

{"customer": { "id": "4gkYnd21ouvW", "email": "jane@test.com", "auto_collection": "off", "allow_direct_debit": false, "created_at": 1412101833, "taxability": "taxable", "object": "customer", "card_status": "no_card", "contacts": [ { "id": "ty68op521m", "first_name": "Michel", "last_name": "Ross", "email": "Mike@test.com", "label": "Mike", "enabled": true, "send_account_email": true, "send_billing_email": false, "object": "contact" }, {..} ], "promotional_credits": 0, "refundable_credits": 0, "excess_payments": 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("4gkYnd21ouvW", 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("4gkYnd21ouvW", array(
  "firstName" => "Denise", 
  "lastName" => "Barone"));
$customer = $result->customer();
$card = $result->card();

Sample Result [ JSON ]

{"customer": { "id": "4gkYnd21ouvW", "first_name": "Denise", "last_name": "Barone", "email": "jane@test.com", "auto_collection": "off", "allow_direct_debit": false, "created_at": 1412101833, "taxability": "taxable", "object": "customer", "card_status": "no_card", "contacts": [ { "id": "ty68op521m", "first_name": "Michel", "last_name": "Ross", "email": "Mike@test.com", "label": "Mike", "enabled": true, "send_account_email": true, "send_billing_email": false, "object": "contact" }, {..} ], "promotional_credits": 0, "refundable_credits": 0, "excess_payments": 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
Possible values are
onWhenever an invoice is created, an automatic attempt to charge the customer's payment method is made.offWhenever a new invoice is created, there will no attempt made to charge the customer. All payment reconciliations must be recorded offline.
allowDirectDebit
Whether the customer can pay via Direct Debit.
optional, boolean
taxability
Specifies if the customer is liable for tax.
optional, enumerated string
Possible values are
taxableCustomer is taxable.exemptCustomer is exempted from tax.
entityCode
The exemption category of the customer, for the USA and Canada. applicable if you use Chargebee's Avalara integration.
optional, enumerated string
Possible values are
aFederal government (United States).bState government (United States).cTribe/Status Indian/Indian Band (both).dForeign diplomat (both).
eCharitable or benevolent org (both).fReligious or educational org (both).gResale (both).hCommercial agricultural production (both).iIndustrial production/manufacturer (both).jDirect pay permit (United States).kDirect mail (United States).lOther (both).nLocal government (United States).pCommercial aquaculture (Canada).qCommercial Fishery (Canada).rNon-resident (Canada).med1US Medical Device Excise Tax with exempt sales tax.med2US Medical Device Excise Tax with taxable sales tax.
Show all values[+]
exemptNumber
Any string value that will cause the sale to be exempted. Use this if your finance team manually verifies and tracks exemption certificates. Applicable only for Avalara.
optional, string, max chars=100
invoiceNotes
Invoice Notes for this resource. Read More.
optional, string, max chars=1000
metaData
Additional data about this resource can be stored here in the JSON Format. Learn more.
optional, jsonobject
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.

Direct Debit Payments
When the bank account details of your customer are stored in the gateway vault, you can use this API to update the reference id provided by them in Chargebee. To use this API, pass

  • type as direct_debit.
  • gateway with the gateway where the bank account details are stored (e.g. authorize_net). If the gateway is not specified, the gateway supporting the direct debit will be used.
  • reference_id with the identifier provided by the gateway to reference the customer's bank account details.
  • tmp_token with the single use token provided by the gateway ( Applicable only for Stripe gateway and should be passed only if reference_id is not passed ).

Reference id format for Direct Debit Payments
The format of reference_id will differ based on where the bank account is stored.

Stripe: In case of Stripe, the reference_id consists of combination of Stripe Customer ID and Stripe Bank Account ID separated by forward slash
(e.g. cus_8suoHaLQH4G5AW/ba_18b8z2KmcbENlhgU03RznRYW). If you are passing Stripe Customer ID alone, then Chargebee will store the first bank account details present in payment profile list of that customer in Stripe.

Authorize.Net: The reference_id consists of combination of Authorize.Net's Customer Profile ID and Payment Profile ID separated by forward slash (e.g. 2384383/34834382). If you are passing Authorize.Net's Customer Profile ID alone, then Chargebee will store the first bank account details present in payment profile list of that customer in Authorize.Net.

Note: While using this API to update payment method details, Card Verification will not happen even if it is enabled for that particular gateway.

Sample Code
require 'ChargeBee.php';
ChargeBee_Environment::configure("{site}","{site_api_key}");
$result = ChargeBee_Customer::updatePaymentMethod("4gkYnd21ouvW", 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("4gkYnd21ouvW", array(
  "paymentMethod" => array(
    "type" => "paypal_express_checkout", 
    "referenceId" => "B-09u9343Sde24D"
  )));
$customer = $result->customer();
$card = $result->card();

Sample Result [ JSON ]

{ "customer": { "id": "3Nl8JCyPtTEQ0p4p", "first_name": "John", "last_name": "Doe", "email": "john@test.com", "auto_collection": "on", "allow_direct_debit": false, "created_at": 1470825145, "taxability": "taxable", "object": "customer", "billing_address": { "first_name": "Hello", "last_name": "World", "phone": "122242222", "line1": "Wow", "line2": "Cool", "city": "Chennai", "state": "Tamil Nadu", "country": "IN", "zip": "600041", "object": "billing_address" }, "card_status": "valid", "payment_method": { "object": "payment_method", "type": "card", "reference_id": "cus_8yrkrsr02A0dfE/card_8yrkC10ERP2qYV", "gateway": "stripe", "status": "valid" }, "promotional_credits": 0, "refundable_credits": 0, "excess_payments": 0 }, "card": { "customer_id": "3Nl8JCyPtTEQ0p4p", "status": "valid", "gateway": "stripe", "first_name": "Hello", "last_name": "World", "iin": "******", "last4": "4242", "card_type": "visa", "expiry_month": 10, "expiry_year": 2020, "object": "card", "masked_number": "************4242" } }

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
cardCard based payment inluding credit cards and debit cards. Details about the card can be obtained from the card resource.paypal_express_checkoutPaypal Express Checkout based payment.amazon_paymentsAmazon login and pay based payment.direct_debitDirect Debit.
gateway
Name of the gateway the payment method is associated with.
optional, enumerated string
Possible values are
wepayWePay Gateway.stripeStripe payment gateway.braintreeBraintree payment gateway.
authorize_netAuthorize.net payment gateway.paypal_proPaypal Pro Account.pinPin payment gateway.ewayeWAy Account.eway_rapideWAy Rapid gateway.worldpayWorldPay payment gateway.balanced_paymentsBalanced payment gateway.beanstreamBeanstream Account.bluepayBluePay payment gateway.elavonElavon Virtual Merchant.first_data_globalFirst Data Global Gateway Virtual Terminal Account.hdfcHDFC Account.migsMasterCard Internet Gateway Service.nmiNMI gateway.ogoneOgone Account.paymillPaymill payment gateway.paypal_payflow_proPaypal Payflow Pro gateway.sage_paySage Pay gateway.tco2Checkout payment gateway.wirecardWireCard Account.gocardlessGoCardless.not_applicableIndicates 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
tmpToken
The single-use card token returned by vault like Stripe which acts as a substitute for your bank account detail. Before calling this API, you should have submitted your bank account details to the gateway ( Stripe ) and got this token in return.
Note: Supported only for Direct Debit ( Stripe gateway ).
required if reference_id not provided, 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("4gkYnd21ouvW", 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("4gkYnd21ouvW", 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": "4gkYnd21ouvW", "first_name": "Denise", "last_name": "Barone", "email": "jane@test.com", "auto_collection": "off", "allow_direct_debit": false, "created_at": 1412101833, "taxability": "taxable", "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", "contacts": [ { "id": "ty68op521m", "first_name": "Michel", "last_name": "Ross", "email": "Mike@test.com", "label": "Mike", "enabled": true, "send_account_email": true, "send_billing_email": false, "object": "contact" }, {..} ], "promotional_credits": 0, "refundable_credits": 0, "excess_payments": 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
validationStatus
The address verification status.
optional, enumerated string, default=not_validated
Possible values are
not_validatedAddress is not yet validated.validAddress was validated successfully.partially_validAddress is verified but only partially.invalidAddress is invalid.
Resource object representing customer.
always returned
Resource object representing card.
optional
Sample Code
require 'ChargeBee.php';
ChargeBee_Environment::configure("{site}","{site_api_key}");
$result = ChargeBee_Customer::addContact("4gkYnd21ouvW", array(
  "contact" => array(
    "firstName" => "Jane", 
    "lastName" => "Doe", 
    "email" => "jane@test.com", 
    "label" => "dev", 
    "enabled" => true, 
    "sendBillingEmail" => true, 
    "sendAccountEmail" => true
  )));
$customer = $result->customer();
$card = $result->card();
copy
require 'ChargeBee.php';
ChargeBee_Environment::configure("{site}","{site_api_key}");
$result = ChargeBee_Customer::addContact("4gkYnd21ouvW", array(
  "contact" => array(
    "firstName" => "Jane", 
    "lastName" => "Doe", 
    "email" => "jane@test.com", 
    "label" => "dev", 
    "enabled" => true, 
    "sendBillingEmail" => true, 
    "sendAccountEmail" => true
  )));
$customer = $result->customer();
$card = $result->card();

Sample Result [ JSON ]

{"customer": { "id": "4gkYnd21ouvW", "first_name": "Denise", "last_name": "Barone", "email": "jane@test.com", "auto_collection": "off", "allow_direct_debit": false, "created_at": 1412101833, "taxability": "taxable", "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", "contacts": [ { "id": "ty68op521m", "first_name": "Michel", "last_name": "Ross", "email": "Mike@test.com", "label": "Mike", "enabled": true, "send_account_email": true, "send_billing_email": false, "object": "contact" }, {..} ], "promotional_credits": 0, "refundable_credits": 0, "excess_payments": 0 }}

Method

ChargeBee_Customer::addContact(<customer_id>,array(<param name> => <value>,<param name> => <value> ...))
contact
Associative array of parameters for contact
pass parameters as contact => array("<param name>" => "<value>",...)
id
Unique reference ID provided for the contact.
optional, string, max chars=150
firstName
First name of the contact.
optional, string, max chars=150
lastName
Last name of the contact.
optional, string, max chars=150
email
Email of the contact.
required, string, max chars=70
phone
Phone number of the contact.
optional, string, max chars=50
label
Label/Tag provided for contact.
optional, string, max chars=50
enabled
Contact enabled / disabled.
optional, boolean, default=false
sendBillingEmail
Whether Billing Emails option is enabled for the contact.
optional, boolean, default=false
sendAccountEmail
Whether Account Emails option is enabled for the contact.
optional, boolean, default=false
Resource object representing customer.
always returned
Resource object representing card.
optional
Sample Code
require 'ChargeBee.php';
ChargeBee_Environment::configure("{site}","{site_api_key}");
$result = ChargeBee_Customer::updateContact("4gkYnd21ouvW", array(
  "contact" => array(
    "id" => "8avaFPYtreDQ5", 
    "firstName" => "Jane", 
    "lastName" => "Doe", 
    "email" => "jane@test.com", 
    "label" => "dev", 
    "enabled" => true, 
    "sendBillingEmail" => true, 
    "sendAccountEmail" => true
  )));
$customer = $result->customer();
$card = $result->card();
copy
require 'ChargeBee.php';
ChargeBee_Environment::configure("{site}","{site_api_key}");
$result = ChargeBee_Customer::updateContact("4gkYnd21ouvW", array(
  "contact" => array(
    "id" => "8avaFPYtreDQ5", 
    "firstName" => "Jane", 
    "lastName" => "Doe", 
    "email" => "jane@test.com", 
    "label" => "dev", 
    "enabled" => true, 
    "sendBillingEmail" => true, 
    "sendAccountEmail" => true
  )));
$customer = $result->customer();
$card = $result->card();

Sample Result [ JSON ]

{"customer": { "id": "4gkYnd21ouvW", "first_name": "Denise", "last_name": "Barone", "email": "jane@test.com", "auto_collection": "off", "allow_direct_debit": false, "created_at": 1412101833, "taxability": "taxable", "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", "contacts": [ { "id": "ty68op521m", "first_name": "Michel", "last_name": "Ross", "email": "Mike@test.com", "label": "Mike", "enabled": true, "send_account_email": true, "send_billing_email": false, "object": "contact" }, {..} ], "promotional_credits": 0, "refundable_credits": 0, "excess_payments": 0 }}

Method

ChargeBee_Customer::updateContact(<customer_id>,array(<param name> => <value>,<param name> => <value> ...))
contact
Associative array of parameters for contact
pass parameters as contact => array("<param name>" => "<value>",...)
id
Unique reference ID provided for the contact.
required, string, max chars=150
firstName
First name of the contact.
optional, string, max chars=150
lastName
Last name of the contact.
optional, string, max chars=150
email
Email of the contact.
optional, string, max chars=70
phone
Phone number of the contact.
optional, string, max chars=50
label
Label/Tag provided for contact.
optional, string, max chars=50
enabled
Contact enabled / disabled.
optional, boolean
sendBillingEmail
Whether Billing Emails option is enabled for the contact.
optional, boolean
sendAccountEmail
Whether Account Emails option is enabled for the contact.
optional, boolean
Resource object representing customer.
always returned
Resource object representing card.
optional
Sample Code
require 'ChargeBee.php';
ChargeBee_Environment::configure("{site}","{site_api_key}");
$result = ChargeBee_Customer::deleteContact("4gkYnd21ouvW", array(
  "contact" => array(
    "id" => "8avaFPYtreDQ5"
  )));
$customer = $result->customer();
$card = $result->card();
copy
require 'ChargeBee.php';
ChargeBee_Environment::configure("{site}","{site_api_key}");
$result = ChargeBee_Customer::deleteContact("4gkYnd21ouvW", array(
  "contact" => array(
    "id" => "8avaFPYtreDQ5"
  )));
$customer = $result->customer();
$card = $result->card();

Sample Result [ JSON ]

{"customer": { "id": "4gkYnd21ouvW", "first_name": "Denise", "last_name": "Barone", "email": "jane@test.com", "auto_collection": "off", "allow_direct_debit": false, "created_at": 1412101833, "taxability": "taxable", "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", "contacts": [ { "id": "ty68op521m", "first_name": "Michel", "last_name": "Ross", "email": "Mike@test.com", "label": "Mike", "enabled": true, "send_account_email": true, "send_billing_email": false, "object": "contact" }, {..} ], "promotional_credits": 0, "refundable_credits": 0, "excess_payments": 0 }}

Method

ChargeBee_Customer::deleteContact(<customer_id>,array(<param name> => <value>,<param name> => <value> ...))
contact
Associative array of parameters for contact
pass parameters as contact => array("<param name>" => "<value>",...)
id
Unique reference ID provided for the contact.
required, string, max chars=150
Resource object representing customer.
always returned
Resource object representing card.
optional

This API call can be used to add promotional credits to a customer. Learn more about Promotional 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::addPromotionalCredits("4gkYnd21ouvW", array(
  "amount" => 500, 
  "description" => "Loyalty credits"));
$customer = $result->customer();
copy
require 'ChargeBee.php';
ChargeBee_Environment::configure("{site}","{site_api_key}");
$result = ChargeBee_Customer::addPromotionalCredits("4gkYnd21ouvW", array(
  "amount" => 500, 
  "description" => "Loyalty credits"));
$customer = $result->customer();

Sample Result [ JSON ]

{"customer": { "id": "4gkYnd21ouvW", "first_name": "Denise", "last_name": "Barone", "email": "jane@test.com", "auto_collection": "off", "allow_direct_debit": false, "created_at": 1412101833, "taxability": "taxable", "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", "contacts": [ { "id": "ty68op521m", "first_name": "Michel", "last_name": "Ross", "email": "Mike@test.com", "label": "Mike", "enabled": true, "send_account_email": true, "send_billing_email": false, "object": "contact" }, {..} ], "promotional_credits": 500, "refundable_credits": 0, "excess_payments": 0 }}

Method

ChargeBee_Customer::addPromotionalCredits(<customer_id>,array(<param name> => <value>,<param name> => <value> ...))
amount
Credit amount to be added.
required, in cents, min=1
currencyCode
The currency code (ISO 4217 format) of the specified credit amount.
required if Multicurrency is enabled, string, max chars=3
description
Description for this credit.
required, string, max chars=250
Resource object representing customer.
always returned

This API call can be used to deduct promotional credits for a customer. Learn more about Promotional 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::deductPromotionalCredits("4gkYnd21ouvW", 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::deductPromotionalCredits("4gkYnd21ouvW", array(
  "amount" => 200, 
  "description" => "Correcting credits given by mistake"));
$customer = $result->customer();

Sample Result [ JSON ]

{"customer": { "id": "4gkYnd21ouvW", "first_name": "Denise", "last_name": "Barone", "email": "jane@test.com", "auto_collection": "off", "allow_direct_debit": false, "created_at": 1412101833, "taxability": "taxable", "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", "contacts": [ { "id": "ty68op521m", "first_name": "Michel", "last_name": "Ross", "email": "Mike@test.com", "label": "Mike", "enabled": true, "send_account_email": true, "send_billing_email": false, "object": "contact" }, {..} ], "promotional_credits": 300, "refundable_credits": 0, "excess_payments": 0 }}

Method

ChargeBee_Customer::deductPromotionalCredits(<customer_id>,array(<param name> => <value>,<param name> => <value> ...))
amount
Credit amount to be deducted.
required, in cents, min=1
currencyCode
The currency code (ISO 4217 format) of the specified credit amount.
required if Multicurrency is enabled, string, max chars=3
description
Description for this credit.
required, string, max chars=250
Resource object representing customer.
always returned

This API call can be used to set the promotional credits balnce of a customer. Learn more about Promotional 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::setPromotionalCredits("4gkYnd21ouvW", 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::setPromotionalCredits("4gkYnd21ouvW", array(
  "amount" => 1200, 
  "description" => "Correcting credits given by mistake"));
$customer = $result->customer();

Sample Result [ JSON ]

{"customer": { "id": "4gkYnd21ouvW", "first_name": "Denise", "last_name": "Barone", "email": "jane@test.com", "auto_collection": "off", "allow_direct_debit": false, "created_at": 1412101833, "taxability": "taxable", "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", "contacts": [ { "id": "ty68op521m", "first_name": "Michel", "last_name": "Ross", "email": "Mike@test.com", "label": "Mike", "enabled": true, "send_account_email": true, "send_billing_email": false, "object": "contact" }, {..} ], "promotional_credits": 1200, "refundable_credits": 0, "excess_payments": 0 }}

Method

ChargeBee_Customer::setPromotionalCredits(<customer_id>,array(<param name> => <value>,<param name> => <value> ...))
amount
Credit amount to be set.
required, in cents, min=0
currencyCode
The currency code (ISO 4217 format) of the specified credit amount.
required if Multicurrency is enabled, string, max chars=3
description
Description for this credit.
required, string, max chars=250
Resource object representing customer.
always returned

Use this API to record any excess payments made by the customer, such as advance payments. Such payments will be automatically applied to the future invoices. It can also be manually applied to the existing Not Paid or Payment Due invoices.

Sample Code
require 'ChargeBee.php';
ChargeBee_Environment::configure("{site}","{site_api_key}");
$result = ChargeBee_Customer::recordExcessPayment("4gkYnd21ouvW", array(
  "comment" => "Check payment received from John", 
  "transaction" => array(
    "amount" => 500, 
    "date" => 1435054328, 
    "paymentMethod" => "check"
  )));
$customer = $result->customer();
$transaction = $result->transaction();
copy
require 'ChargeBee.php';
ChargeBee_Environment::configure("{site}","{site_api_key}");
$result = ChargeBee_Customer::recordExcessPayment("4gkYnd21ouvW", array(
  "comment" => "Check payment received from John", 
  "transaction" => array(
    "amount" => 500, 
    "date" => 1435054328, 
    "paymentMethod" => "check"
  )));
$customer = $result->customer();
$transaction = $result->transaction();

Sample Result [ JSON ]

{ "customer": { "id": "4gkYnd21ouvW", "first_name": "Denise", "last_name": "Barone", "email": "jane@test.com", "auto_collection": "off", "allow_direct_debit": false, "created_at": 1412101833, "taxability": "taxable", "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", "contacts": [ { "id": "ty68op521m", "first_name": "Michel", "last_name": "Ross", "email": "Mike@test.com", "label": "Mike", "enabled": true, "send_account_email": true, "send_billing_email": false, "object": "contact" }, {..} ], "promotional_credits": 1200, "refundable_credits": 0, "excess_payments": 500 }, "transaction": { "id": "txn_3Nl8JIPPtTEwxW5X", "customer_id": "4gkYnd21ouvW", "payment_method": "check", "gateway": "not_applicable", "type": "payment", "date": 1435054328, "amount": 500, "status": "success", "object": "transaction", "currency_code": "USD", "amount_unused": 500, "linked_invoices": [], "linked_refunds": [] } }

Method

ChargeBee_Customer::recordExcessPayment(<customer_id>,array(<param name> => <value>,<param name> => <value> ...))
comment
Remarks, if any, on the payment.
optional, string, max chars=300
transaction
Associative array of parameters for transaction
pass parameters as transaction => array("<param name>" => "<value>",...)
amount
The payment transaction amount.
required, in cents, min=1
currencyCode
The currency code (ISO 4217 format) for the transaction.
required if Multicurrency is enabled, string, max chars=3
date
Indicates when this transaction occurred.
required, timestamp(UTC) in seconds
paymentMethod
The Payment Method of this transaction.
required, enumerated string, default=card
Possible values are
cashCash.checkCheck.
bank_transferBank Transfer.otherPayment Methods other than the above types.
Show all values[+]
referenceNumber
The reference number for this transaction. e.g check number in case of 'check' payments.
optional, string, max chars=100
Resource object representing customer.
always returned
Resource object representing transaction.
always returned

Deletes the customer resource.

Notes

This will delete the Payment Method from the gateway/vault. If you do not want the Payment Method to be deleted from the vault, set the value for the delete_payment_method parameter to false.

This operation is irreversible - all data related to the customer, such as subscriptions, invoices, transactions, and reports, will be deleted.

Note: This operation schedules the customer resource for deletion. It will be deleted in a few minutes.

Sample Code
require 'ChargeBee.php';
ChargeBee_Environment::configure("{site}","{site_api_key}");
$result = ChargeBee_Customer::delete("4gkYnd21ouvW");
$customer = $result->customer();
$card = $result->card();
copy
require 'ChargeBee.php';
ChargeBee_Environment::configure("{site}","{site_api_key}");
$result = ChargeBee_Customer::delete("4gkYnd21ouvW");
$customer = $result->customer();
$card = $result->card();

Sample Result [ JSON ]

{"customer": { "id": "4gkYnd21ouvW", "first_name": "Denise", "last_name": "Barone", "email": "jane@test.com", "auto_collection": "off", "allow_direct_debit": false, "created_at": 1412101833, "taxability": "taxable", "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", "contacts": [ { "id": "ty68op521m", "first_name": "Michel", "last_name": "Ross", "email": "Mike@test.com", "label": "Mike", "enabled": true, "send_account_email": true, "send_billing_email": false, "object": "contact" }, {..} ], "promotional_credits": 1200, "refundable_credits": 0, "excess_payments": 500 }}

Method

ChargeBee_Customer::delete(<customer_id>,array(<param name> => <value>,<param name> => <value> ...))
deletePaymentMethod
Deletes the Payment Method from the gateway/vault.
optional, boolean, default=true
Resource object representing customer.
always returned
Resource object representing card.
optional