Change product
Target audience: Developers
Release version: 4.11.4
Change product¶
Introduction¶
This endpoint lets you request a package change on an ongoing subscription. There are a number of requirements to take into account when using this functionality, which you can read more about here.
Compared to version 1, a delivery address can be given with the change, see Changing to a package with a print product.
Package change behaviours¶
While requesting a change, there are a few ways for us to determine what kind of change it is going to be.
Price based (for upgrades/downgrades)¶
Package changes/requests will typically be performed as either an upgrade or a downgrade. By default, this decision will be based upon the payment period prices. If the customer would land on a more expensive period, we'll see it as an upgrade. If the customer would land on a cheaper period, we'll see it as a downgrade.
To use this behaviour, the default_behaviour parameter must be set to true.
Rank based (for upgrades/downgrades)¶
Packages can be ranked in PAP. This means that the ranking of packages will be used instead of the payment period prices to decide whether it should be handled as an upgrade or downgrade (granted a ranking exists on both the source and target package). More on how Ranks work in Payway can be read upon here.
To use this behaviour, the default_behaviour parameter must be set to true.
Change request¶
Separate from package upgrades/downgrades, package changes can also be made. These work much in the same way as downgrades in the sense that they do not change the subscription of the customer until period end, but will be considered as a explicit package change instead of a upgrade/downgrade with all its implications.
To use this behaviour, the default_behaviour parameter must be set to false, and a target_period_id must be specified.
Changing to a package with a print product¶
A package that includes a print product needs a delivery address on the subscription. If the subscription has no delivery address, for example one that was bought as digital-only, send the address in delivery_address. It is saved as the delivery address of the subscription, and the change is made. Without it, the change is refused with the error code invalid_package_change. Available product changes tells which packages require it.
A delivery_address is always saved when it is given, also when the change does not need it. It then replaces the current delivery address of the subscription right away, also for a change that takes effect at the end of the period, and the paper is delivered to the new address from then on.
URI¶
| Environment | URI |
|---|---|
| Stage | https://payway-api.stage.adeprimo.se/external/api/v2/me/change_product |
| Production | https://backend.worldoftulo.com/external/api/v2/me/change_product |
Requirements¶
| Identity | Scope |
|---|---|
| Yes | /external/me/w |
Parameters¶
| Field | Required | Type | Description |
|---|---|---|---|
| id | Required | String | The id of the user product to change product on. Size range: ..24 Allowed values: "/^[a-f\d]{24}$/i" |
| package_code | Required | String | The package_code of the package to upgrade/downgrade into. Size range: 1..50 |
| target_period_id | Optional | String | The id of the period to transition to. If none is specified, we will attempt to find one based on the current payment method and a period length of 1 month. Size range: ..24 Allowed values: "/^[a-f\d]{24}$/i" |
| default_behaviour | Optional | Boolean | Decides whether the package change should follow default behaviour or not. Read more about this parameter here. Default: True |
| traffic_source | Optional | String | The traffic source that should be applied on the new order. Size range: ..128 |
| merchant_reference | Optional | String | The merchant reference that should be applied on the new order. |
| delivery_address | Optional | Object | The delivery address of the subscription, needed when changing to a package with a print product and the subscription has no delivery address. Read more here. See format here |
Curl Example¶
curl --request PUT \
--url https://payway-api.stage.adeprimo.se/external/api/v2/me/change_product \
--header 'accept: application/json' \
--header 'authorization: Bearer token' \
--header 'content-type: application/json' \
--data '{
"id": "50f3ac249f6aef294d000007",
"package_code": "print_package",
"delivery_address": {
"first_name": "Anna",
"last_name": "Andersson",
"street": "Storgatan 1",
"zip_code": "12345",
"city": "Stockholm",
"country_code": "SE"
}
}'
Response¶
| Field | Description |
|---|---|
| id | The id of the new user product. |
HTTP 200 Updated
{
"id": "50f3ac249f6aef294d000007"
}
Errors¶
This API uses the common error conventions of the Payway API