Update customer

POST /v1/customers/:id

curl https://testapi.txpmnts.com/v1/customers/9v4RIaTmQbqq1T7jox85Og \
  -u sk_test_yFStF-KUmgr-7CoumuY2JA: \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d default_source=7CrJwEG5Rsy9SDoN5G210Q

The above command returns JSON structured like this:

{
	"id": "P2ZTA56JQ7-AvwGf0pHd2Q",
	"first_name": "John",
	"last_name": "Doe",
	"email": "john.doe@example.com",
	"phone": "+48-7589658478",
	"currency": "usd",
	"created_at": 1568895751,
	"default_source": "Cb7gfDClSoiIJXL4h54lYw",
	"address_line1": "Address line 1",
	"address_city": "City example",
	"address_country": "PL",
	"address_line2": "Address line 2",
	"address_zip": "03-5896",
	"address_state": "sk"
	"description": "",
}

If you pass the source parameter, that becomes the customer’s active source (e.g., a card) to be used for all charges in the future. When you update a customer to a new valid card source by passing the source parameter: for each of the customer’s current subscriptions, if the subscription bills automatically and is in the past_due state, then the latest open invoice for the subscription with automatic collection enabled will be retried. This retry will not count as an automatic retry, and will not affect the next regularly scheduled payment for the invoice. Changing the default_source for a customer will not trigger this behavior.

Arguments

Parameter
Type
Required
Description

source

string

required

The source can be a Token or a Source, as returned by Elements. You must provide a source if the customer does not already have a valid source attached, and you are subscribing the customer to be charged automatically for a plan that is not free. Passing source will create a new source object, make it the customer default source, and delete the old customer default if one exists. If you want to add an additional source, instead use the card creation API to add the card and then the customer update API to set it as the default. Whenever you attach a card to a customer, the api will automatically validate the card.

Last updated