Auto-Renewable Subscription Wrong Time Response Sandbox Mode
Asked Answered
L

1

0

I was trying to do local receipt validation and doing testing at present. But from apple receipt response, I was getting wrong time related response so it become difficult for me to test application at present.

Here is log information: enter image description here

Here is source code that I used for receipt validation:

 public void CheckIfSubscriptionIsActive(bool validateReceipt)
{
    ConfigurationBuilder builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());

    IAppleConfiguration appleConfig = builder.Configure<IAppleConfiguration>();
    bool isSubscriptionRunning = false;

    if (!string.IsNullOrEmpty(appleConfig.appReceipt))
    {
        if (validateReceipt)
        {
            // local receipt verification
            var receiptData = System.Convert.FromBase64String(appleConfig.appReceipt);
            AppleReceipt receipt = new AppleValidator(AppleTangle.Data()).Validate(receiptData);
            foreach (AppleInAppPurchaseReceipt productReceipt in receipt.inAppPurchaseReceipts)
            {

                Debug.Log("# server date: " + GameManager.Instance.ServerDate + " expire date: " + productReceipt.subscriptionExpirationDate);
                int result = DateTime.Compare(GameManager.Instance.ServerDate, productReceipt.subscriptionExpirationDate);
                if (result <= 0)
                {
                    isSubscriptionRunning = true;
                    Debug.Log(" === ==== === Subscription Running: curr date: " + GameManager.Instance.ServerDate + " expire date: " + productReceipt.subscriptionExpirationDate);
                }

                //Debug.Log("PRODUCTID: " + productReceipt.productID);
                //Debug.Log("PURCHASE DATE: " + productReceipt.purchaseDate);
                //Debug.Log("EXPIRATION DATE: " + productReceipt.subscriptionExpirationDate);
                //Debug.Log("CANCELDATE DATE: " + productReceipt.cancellationDate);
            }

            if (isSubscriptionRunning)
                SubscriptionActivated();

            // hide loading...
            showLoader = false;
            Camera.main.SendMessage("ActivateLoadingDialog", false, SendMessageOptions.DontRequireReceiver);

        }
        else
        {
            // server side receipt vecification
            appReceipt = appleConfig.appReceipt;
            StartCoroutine(CheckSubscriptionStatusServerSideVerification());
        }
    }
}

Usually Weekly subscription has 3 mins time duration so if I am not getting exact time then how can I do proper testing!!

In above image, I have mention both times, my local time is 15:01:04 and apple receipt response time is 09:37:18. Using local device receipt validation at present I can't able to test the work. so what way exist for me for testing??

Leoleod answered 8/12, 2017 at 10:19 Comment(3)
Any suggestion regarding this?? If you want more info then I am available for that.Leoleod
I am having same issue :(Ringed
I found the solution for this let me create an answer for this question.Leoleod
L
1

Basically in above problem, I was getting major time difference in Apple receipt response but now I have concluded the solution for this. local time is 15:01:04 apple receipt response time is 09:37:18

Main reason for this is GMT time difference. I am living in India so we have 5:30 time difference running.

So in Apple receipt time, I require to add this GMT time difference to get exact time values and after this we can complete our rest coding.

I will post link here with my Unity Support discussion if anybody required that.

Leoleod answered 2/2, 2018 at 11:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.