To upgrade or downgrade a subscription, you first need to identify the user's current active subscription. This can be done using the Publication API.
Sign in with Google to retrieve your current entitlements. If an active subscription is found, the update buttons below will be enabled.
| Button | Details |
|---|---|
|
Sign-in with Google button to check your active subscriptions. |
The showUpdateOffers() method displays an offers carousel specifically for existing subscribers. It requires an oldSku parameter to identify the subscription being replaced.
In this demo, we'll use your current active SKU (retrieved above) as the oldSku and offer SWGPD.3391-5185-7663-76625 and SWGPD.9541-3600-4891-30479 as alternatives.
The updateSubscription() method initiates a direct purchase flow for a new SKU, replacing an existing one. It also requires an oldSku.
In this demo, we'll trigger an update from your current SKU to SWGPD.3391-5185-7663-76625.
getEntitlements()).showUpdateOffers() with the current SKU as oldSku and a list of available skus to upgrade/downgrade to.subscriptions.showUpdateOffers({
oldSku: 'SWGPD.2773-7054-3310-59985',
skus: ['SWGPD.3391-5185-7663-76625', 'SWGPD.9541-3600-4891-30479'],
isClosable: true
});
If you want to trigger a specific upgrade/downgrade directly (e.g., from a custom button), use updateSubscription().
subscriptions.updateSubscription({
skuId: 'SWGPD.3391-5185-7663-76625',
oldSku: 'SWGPD.2773-7054-3310-59985'
});
By default, SwG uses IMMEDIATE_WITH_TIME_PRORATION. You can explicitly set this in the SubscriptionRequest.
subscriptions.updateSubscription({
skuId: 'new_sku_id',
oldSku: 'current_sku_id',
replaceSkuProrationMode: 'IMMEDIATE_WITH_TIME_PRORATION'
});