Sha256: 9f02536163331bbd23c64da5ff1197e1d0d9d0f21a11c9d4ce3166088da2619d

Contents?: true

Size: 849 Bytes

Versions: 3

Compression:

Stored size: 849 Bytes

Contents

module CandyCheck
  module PlayStore
    # Verifies a purchase token against the Google API
    # The call return either an {Receipt} or an {VerificationFailure}
    class SubscriptionVerification < Verification
      # Performs the verification against the remote server
      # @return [Subscription] if successful
      # @return [VerificationFailure] otherwise
      def call!
        verify!
        if valid?
          Subscription.new(@response)
        else
          VerificationFailure.new(@response['error'])
        end
      end

      private

      def valid?
        ok_kind = @response['kind'] == 'androidpublisher#subscriptionPurchase'
        @response && @response['expiryTimeMillis'] && ok_kind
      end

      def verify!
        @response = @client.verify_subscription(package, product_id, token)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
candy_check-0.1.2 lib/candy_check/play_store/subscription_verification.rb
candy_check-0.1.1 lib/candy_check/play_store/subscription_verification.rb
candy_check-0.1.0.pre lib/candy_check/play_store/subscription_verification.rb