How to change the charge amount for an active subscription
To change the charge amount of an active subscription, run an HTTP-PATCH request https://subscriptions.xsolla.com/api/v1/projects/{projectId}/subscriptions/{subscriptionId}/price
.
After changing the charge amount, the user is notified by email, and the new amount takes effect from the next billing period.
To change the charge amount for new subscriptions, use the Update Plan method. The new amount only applies to new subscriptions, and all existing subscriptions will continue under the old terms.
The request must contain an Authorization: Basic <your_authorization_basic_key>
header, where <your_authorization_basic_key>
is the merchant_id:api_key
pair encoded according to the Base64 standard.
Go to Publisher Account to find these parameters:
merchant_id
is shown:- In the Project settings > Webhooks section.
- In the Company settings > Company section.
- In the URL of the browser’s address bar on any Publisher Account page. The URL has the following format:
https://publisher.xsolla.com/&lt;merchant ID>/<Publisher Account section>
.
api_key
is shown in Publisher Account only once when it is created and must be stored on your side. You can create a new key in the following section:- Company settings > API keys
- Project settings > API keys
Pass as path parameters:
Parameter | Type | Description |
---|---|---|
projectId | integer | Required. Project ID. You can find this parameter in your Publisher Account next to the name of the project. |
subscriptionId | integer | Required. Subscription ID. |
Parameter | Type | Description |
---|---|---|
amount | float | Required. Charge amount value. |
currency | string | Required. Three-letter currency code per ISO 4217. |
- curl
curl -X PATCH \
'https://subscriptions.xsolla.com/api/v1/projects/{project_id}/subscriptions/{subscription_id}/price' \
-H 'accept: application/json' \
-H 'Authorization: Basic'
{
"amount": 4.99,
"currency": "USD"
}
Response examples:
200
— Charge amount is changed successfully400
— Subscription is not active404
— Subscription is not found
Found a typo or other text error? Select the text and press Ctrl+Enter.