iOS subscription expiration

Hi,

I am implementing a subscription feature in an iOS app development project.
Using Unity 2020.3.26f1 and UnityIAP 4.5.1, I am implementing the public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args) method.

public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args)
{
    Product product = args.purchasedProduct;

    bool isPurchased = false;
    var receipt = args.purchasedProduct.receipt;
    CrossPlatformValidator validator = new CrossPlatformValidator(GooglePlayTangle.Data(), AppleTangle.Data(), Application.identifier);
    IPurchaseReceipt[] purchases = validator.Validate(receipt);
    if (purchases != null)
    {
        foreach (var purchase in purchases)
        {
            AppleInAppPurchaseReceipt appleReceipt = purchase as AppleInAppPurchaseReceipt;
            if (appleReceipt != null
             && DateTime.UtcNow <= appleReceipt.subscriptionExpirationDate)
            {
                Debug.Log("*** purchaseDate:" + appleReceipt.purchaseDate, Debug.Type.Web);
                Debug.Log("*** subscriptionExpirationDate:" + appleReceipt.subscriptionExpirationDate, Debug.Type.Web);
                isPurchased = true;
            }
        }
    }

    if (isPurchased == true)
    {
        SubscriptionManager subscriptionManager = new SubscriptionManager(product, null);
        SubscriptionInfo subscriptionInfo = subscriptionManager.getSubscriptionInfo();

        if (subscriptionInfo.isSubscribed() == Result.True
         && subscriptionInfo.isExpired() == Result.False)
        {
            Debug.Log("*** PurchaseDate: " + subscriptionInfo.getPurchaseDate());
            Debug.Log("*** ExpireDate: " + subscriptionInfo.getExpireDate());
        }
    }

    return PurchaseProcessingResult.Complete;
}

Within this method, I am using SubscriptionManager’s getSubscriptionInfo() to retrieve the SubscriptionInfo and confirm the getExpireDate().

Premise:
The environment is set to Sandbox.
The subscription update frequency is set to “monthly update every 5 minutes.”
Two subscription items are available: 1 month and 3 months.

Steps:

  1. Purchased a 3-month subscription item at 11:00 and confirmed that the expiration date is 11:15.
  2. Attempted to downgrade the subscription by purchasing a 1-month subscription item at 11:05.
    The expected expiration date should be at 11:20, after the 3-month subscription renewal.
    However, the receipt shows the date of 11:10.
    If the environment is Sandbox, will the subscription items “1 month” and “3 months” be parallel?

Thank you.

1 Like

Hello shimizuzu,

This is an issue with Apple’s Sandbox where the behaviour is different from production and doesn’t support upgrading/downgrading subscriptions. On Sandbox, both will be treated as their own.

1 Like