Assinaturas
Atualizar Item
PUT
/v1/subscriptions/:subscriptionId/items/:itemIdBase URL Produção:
https://api.validapay.com.brBase URL Sandbox:
https://sandbox.validapay.com.brAutenticação
bearerAuthorizationstring · header · obrigatório
Envie no header:
Authorization: Bearer {{token}}Path Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| subscriptionId | string | Required | Subscriptionid |
| itemId | string | Required | Itemid |
Atualiza a quantidade ou o preço de um item dentro de uma assinatura ativa.
Upgrade/downgrade de item
:id = subscriptionId, :itemId = ID do item. Pelo menos priceId ou quantity.
| Campo | Obrig. | Tipo |
|---|---|---|
priceId | ✅* | string |
quantity | ✅* | number |
boletoInstructions | ❌ | object |
expirationAfterDueDate | ❌ | number |
Body
application/json
Content-Type:application/json
{
"priceId": "price_yyy",
"quantity": 2,
"boletoInstructions": null,
"expirationAfterDueDate": null
}Schema
| Field | Type | Required | Description |
|---|---|---|---|
priceId | string | - | - |
quantity | number | - | - |
boletoInstructions | object | - | - |
expirationAfterDueDate | object | - | - |
Headers
| Name | Type | Value | Required |
|---|---|---|---|
| Content-Type | - | application/json | Optional |
const url = 'https://sandbox.validapay.com.br/v1/subscriptions/:subscriptionId/items/:itemId';
const options = {
method: 'PUT',
headers: {
'Authorization': 'Bearer {{token}}',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"priceId": "price_yyy",
"quantity": 2,
"boletoInstructions": null,
"expirationAfterDueDate": null
})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));Response Examples
200200 upgrade
{
"success": true,
"type": "UPGRADE",
"chargeId": "cha_xxx",
"prorataAmount": 33.5,
"newAmount": 199.9
}200200 downgrade
{
"success": true,
"type": "DOWNGRADE",
"effectiveAt": "2024-02-01",
"newAmount": 59.9
}402402
{
"code": "PAYMENT_DECLINED"
}404404
{
"code": "ITEM_NOT_FOUND"
}