Api key provided on integrations tab in Easyflow platform.
Change subscription credit card
Replaces the credit card of a subscription of the business.
- Tokenize the new card with the Easyflow JavaScript SDK and send the token in
creditCard.token. The token goes only in this request: no response and no webhook returns it. The next recurrences are charged to the new card saved in the subscription, without a new token. - The API key must have write access to subscriptions, and its user must be a collaborator of the business sent in
business-id. Only the business that owns the subscription can change its card. - Recurrences after the first one that are
delayedorfailed, and whose payments all failed, are sent to be charged on the new card. Their IDs come inretriedRecurrenceIds, and the result of each charge arrives by webhook. - A recurrence is left out of
retriedRecurrenceIds, and is not charged by this request, when the subscription isactiveand the next automatic retry of the recurrence is already due (the automatic retry charges it), or when the recurrence was retried in the last 10 minutes. - When a recurrence is sent to be charged and the subscription is
inactive, it becomesactiveagain. - Easyflow sends the
subscription.updatedwebhook. - A subscription that is
canceledorexpiredcannot have its card changed. - Up to 30 requests per minute for each user (all API keys of the same user share the limit). Above that, the API returns
429with theRetry-Afterheader.
Headers
x-api-keystringrequiredx-api-secretstringrequiredApi Secret provided on integrations tab in Easyflow platform.
business-idstringrequiredIdentifier of the business the request refers to. The user of your API key must be linked to this business, as explained in The business identifier. A value that is not a business identifier returns
400withInvalid param: [businessId], and a business that the user is not linked to returns403.
Path parameters
subscriptionIdstring · uuidrequiredID of the subscription.
Request bodyrequired
Content typeapplication/jsonobject
creditCardobjectrequiredCredit card of the buyer. The card number is sent only inside
token, created with the Easyflow JavaScript SDK.Show child attributesHide child attributes
tokenstringrequiredEncrypted card token returned by the Easyflow JavaScript SDK. Sent only in this request. No response and no webhook returns it.
last4NumbersstringrequiredLast 4 digits of the card.
holderNamestringrequiredName printed on the card.
expiresAtMonthintegerrequiredExpiration month of the card.
expiresAtYearintegerrequiredExpiration year of the card.
flagstringrequiredCard brand.
buyerobjectrequiredShow child attributesHide child attributes
deviceobjectrequiredDevice of the buyer, sent with the card. When the subscription is created, it is also written to the metadata of the first order.
Show child attributesHide child attributes
ipstringrequiredIP address of the buyer. Never send the IP address of your server.
fingerprintIdstringrequiredFingerprint of the device of the buyer.
userAgentstringrequiredUser agent of the browser of the buyer.
Responses
200The card was changed.
The card was changed.
Content typeapplication/jsonobject
statusCodeintegerdataobjectShow child attributesHide child attributes
subscriptionIdstring · uuidID of the subscription.
statusstringStatus of the subscription after the change.
creditCardobjectThe new card.
Show child attributesHide child attributes
last4NumbersstringholderNamestringexpiresAtMonthintegerexpiresAtYearintegerflagstring
retriedRecurrenceIdsarray of strings · uuidIDs of the recurrences sent to be charged on the new card. Empty when there was none.
400A field is missing or invalid; or the subscription does not exist, is not a valid ID or belongs to another business (message Invalid param: [subscriptionId]); or the subscription is canceled or expired (errorCode SUBSCRIPTIONCARDSUBSCRIPTIONFINISHED); or the subscription has no card registered (errorCode SUBSCRIPTIONCARDSUBSCRIPTIONWITHOUTCARD).
A field is missing or invalid; or the subscription does not exist, is not a valid ID or belongs to another business (message Invalid param: [subscriptionId]); or the subscription is canceled or expired (errorCode SUBSCRIPTION_CARD_SUBSCRIPTION_FINISHED); or the subscription has no card registered (errorCode SUBSCRIPTION_CARD_SUBSCRIPTION_WITHOUT_CARD).
Content typeapplication/jsonobject
messagestringInvalid param: []
errorstringBad Request
statusCodeinteger400
errorCodestringCode that identifies the error. Present only on some errors.
401The credential is missing or invalid, or the business-id header is missing (message BusinessId is required).
The credential is missing or invalid, or the business-id header is missing (message BusinessId is required).
Content typeapplication/jsonobject
messagestringInvalid field
errorstringUnauthorized
statusCodeinteger401
403The API key has no write access to subscriptions, or its user is not a collaborator of the business sent in business-id.
The API key has no write access to subscriptions, or its user is not a collaborator of the business sent in business-id.
Content typeapplication/jsonobject
messagestringForbidden resource
errorstringForbidden
statusCodeinteger403
422The card could not be used. The errorCode field tells why: SUBSCRIPTIONCARDINVALIDCARDTOKEN, SUBSCRIPTIONCARDCUSTOMERNOTFOUND, SUBSCRIPTIONCARDDATAUNREADABLE, SUBSCRIPTIONCARDREJECTED or SUBSCRIPTIONCARDPAYMENTSERVICEUNAVAILABLE (temporary failure; try again later).
The card could not be used. The errorCode field tells why: SUBSCRIPTION_CARD_INVALID_CARD_TOKEN, SUBSCRIPTION_CARD_CUSTOMER_NOT_FOUND, SUBSCRIPTION_CARD_DATA_UNREADABLE, SUBSCRIPTION_CARD_REJECTED or SUBSCRIPTION_CARD_PAYMENT_SERVICE_UNAVAILABLE (temporary failure; try again later).
Content typeapplication/jsonobject
statusCodeintegerrequiredHTTP status code.
messagestringrequiredExplanation of the error.
errorstringName of the HTTP status, such as
Bad RequestorConflict.errorCodestringCode that identifies the error. Present only on some errors.
429More than 30 requests in a minute for the user (all API keys of the same user share the limit). The message is Too many requests, retry after the Retry-After seconds. Wait the number of seconds in the Retry-After header before sending a new request.
More than 30 requests in a minute for the user (all API keys of the same user share the limit). The message is Too many requests, retry after the Retry-After seconds. Wait the number of seconds in the Retry-After header before sending a new request.
Content typeapplication/jsonobject
statusCodeintegerHTTP status code.
messagestringExplanation of the error.
500If an unexpected condition occurs and the server cannot process the request, the API will return the following error response. This response has no error field.
If an unexpected condition occurs and the server cannot process the request, the API will return the following error response. This response has no error field.
Content typeapplication/jsonobject
statusCodeintegerHTTP status code.
messagestringExplanation of the error.