Auto-Renewable Subscription Wrong Time Response Sa

2019-03-05 12:14发布

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

1条回答
神经病院院长
2楼-- · 2019-03-05 12:26

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.

查看更多
登录 后发表回答