candy_check icon indicating copy to clipboard operation
candy_check copied to clipboard

IOS expired subscription verification return VerificationFailure

Open catacs opened this issue 6 years ago • 0 comments

When a user cancel a subscription and from server side I check the subscription later, I get VerificationFailure with code 21006 and message:

This receipt is valid but the subscription has expired. When this status code is returned to your server, the receipt data is also decoded and returned as part of the response.

The message is self explanatory, the subscription data should be parsed from the response. The result must contains a Receipt when call verify method and ReceiptCollection for verify_subscription method.

Changes must be done in the valid? method from class CandyCheck::AppStore::Verification and CandyCheck::AppStore::SubscriptionVerification in the same overridden method, valid?. It should allow to parse the response for code 21006 and not only for STATUS_OK = 0

Posible solution for CandyCheck::AppStore::Verification:

module CandyCheck
  module AppStore
    # Verifies a receipt block against a verification server.
    # The call return either an {Receipt} or a {VerificationFailure}
    class Verification
      STATUS_EXPIRED = 21006

      private

      def valid?
        @response && (@response['status'] == STATUS_OK || @response['status'] == STATUS_EXPIRED) && @response['receipt']
      end
    end
  end
end

catacs avatar Jan 15 '19 07:01 catacs