Receipt validation on iOS In-App-Purchase returns multiple transaction

后端 未结 2 1833
终归单人心
终归单人心 2021-02-06 18:37

In-app purchase on sandbox mode returns multiple transactions on same product id.

Language Used: Swift 4.0

func validateAppReceipt(_ receipt: Data) {
            


        
相关标签:
2条回答
  • 2021-02-06 19:07

    I think you have implemented auto renewable in app purchase. Your response is proper.

    Why I am getting multiple transaction on same ID

    As in your response transaction performed for auto renew product at every 5 minutes(Sandbox environment renew product in 5 minutes instead of 1 month in App Store).

    Whether this response is correct or not

    Yes

    If it is correct, which ID to validate

    You have to get all the transaction for your product id tfc.premium.subscription and then grab last object and use it as your latest/last transaction.

    Read this Apple Document for proper understanding.

    The behavior of auto-renewable subscriptions differs between the testing environment and the production environment.

    In the testing environment, subscription renewals happen at an accelerated rate, and auto-renewable subscriptions renew a maximum of six times per day. This enables you to test how your app handles a subscription renewal, a subscription lapse, and a subscription history that includes gaps. See Testing Auto-Renewable Subscriptions in the In-App Purchase Configuration Guide for iTunes Connect to learn about the subscription durations for testing.

    Because of the accelerated expiration and renewal rates, a subscription can expire before the system tries to renew the subscription, leaving a small lapse in the subscription period. Such lapses are also possible in production for a variety of reasons—make sure your app handles them correctly.

    0 讨论(0)
  • 2021-02-06 19:19

    You are using auto renewable subscriptions. There will be one receipt for every auto-renew or renew of the subscription.

    So generally, if subscription has renewed 5 times then there will be 5 receipts in the sandbox environment and 6 in real environment (production environment, downloaded from AppStore). Because an receipt is generated for the app downloaded or purchased from the AppStore as well.

    0 讨论(0)
提交回复
热议问题