Auto-Renewable Subscription Wrong Time Response Sandbox Mode

你离开我真会死。 提交于 2019-12-02 16:26:39

问题


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:

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??


回答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.



来源:https://stackoverflow.com/questions/47712225/auto-renewable-subscription-wrong-time-response-sandbox-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!