dotpot / InAppPy

Python In-app purchase validator for Apple AppStore and GooglePlay.
MIT License
207 stars 50 forks source link

how to Authorize before verifying the purchase ? #49

Closed burkaslarry closed 5 years ago

burkaslarry commented 5 years ago

When I practice the module to verify my Google subscription purchase , it turns out to be : []( <HttpError 400 when requesting https://www.googleapis.com/androidpublisher/v3/applications/abcd.test.app.adnroid/purchases/subscriptions/membership_monthly_apr2019/tokens/%7B%22orderId%22%3A%22GPA.3316-2634-9980-25396%22%2C%22packageName%22%3A%22gogoyuedu.book.job.news.learn.read%22%2C%22productId%22%3A%22membership_monthly_apr2019%22%2C%22purchaseTime%22%3A1563259021417%2C%22purchaseState%22%3A0%2C%22purchaseToken%22%3A%22njlokbknpapfkhcoepfidmbk.AO-J1OxkB6c_m_K4V81wIBCj02oU7-357ZVEmGFAGu2aA9beGvB8uGFgpKUSZlektF7-SXV5CfddOz5aNfwkxWg-ReAkiFbYJH8wPISEDBqnn5rgMOn6HS1FhD4gsc9BLtcvGWHTVzqTNJnAij3qs0hY5FovVbRppw%22%2C%22autoRenewing%22%3Atrue%7D?alt=json returned "Invalid Value">)

Would you please tell me which module / attribute of GooglePlayVerifier to authorise ?

Here is my code :

bundle_id = 'gogoyuedu.book.job.news.learn.read'
            api_key = 'Alkene-608a20735120.json'
            validator = GooglePlayVerifier(bundle_id, api_key)
            response = {'valid': False, 'transactions': []}
            try:
        # receipt means `androidData` in result of purchase
        # signature means `signatureAndroid` in result of purchase
                validation_result = validator.verify(purchase_json ,sub_code ,is_subscription=True )
                print("validation_result:")
                pprint(validation_result)

                response['valid'] = True
                response['transactions'].append((result['orderId'], product_sku))

            except errors.GoogleError as exc:
                logging.error('Purchase validation failed {}'.format(exc))
            return response
burkaslarry commented 5 years ago

2019-07-23 15:50:07.802 32354-32354/abc.test.app.android I/System.out: verify_subscription error : <HttpError 400 when requesting https://www.googleapis.com/androidpublisher/v3/applications/abc.test.app.android/purchases/subscriptions/membership_monthly_apr2019/tokens/%7B%22orderId%22%3A%22GPA.3316-2634-9980-25396%22%2C%22packageName%22%3A%22abc.test.app.android%22%2C%22productId%22%3A%22membership_monthly_apr2019%22%2C%22purchaseTime%22%3A1563259021417%2C%22purchaseState%22%3A0%2C%22purchaseToken%22%3A%22njlokbknpapfkhcoepfidmbk.AO-J1OxkB6c_m_K4V81wIBCj02oU7-357ZVEmGFAGu2aA9beGvB8uGFgpKUSZlektF7-SXV5CfddOz5aNfwkxWg-ReAkiFbYJH8wPISEDBqnn5rgMOn6HS1FhD4gsc9BLtcvGWHTVzqTNJnAij3qs0hY5FovVbRppw%22%2C%22autoRenewing%22%3Atrue%7D?alt=json returned "Invalid Value">

ruslux commented 5 years ago

2019-07-23 15:50:07.802 32354-32354/abc.test.app.android I/System.out: verify_subscription error : <HttpError 400 when requesting https://www.googleapis.com/androidpublisher/v3/applications/abc.test.app.android/purchases/subscriptions/membership_monthly_apr2019/tokens/%7B%22orderId%22%3A%22GPA.3316-2634-9980-25396%22%2C%22packageName%22%3A%22abc.test.app.android%22%2C%22productId%22%3A%22membership_monthly_apr2019%22%2C%22purchaseTime%22%3A1563259021417%2C%22purchaseState%22%3A0%2C%22purchaseToken%22%3A%22njlokbknpapfkhcoepfidmbk.AO-J1OxkB6c_m_K4V81wIBCj02oU7-357ZVEmGFAGu2aA9beGvB8uGFgpKUSZlektF7-SXV5CfddOz5aNfwkxWg-ReAkiFbYJH8wPISEDBqnn5rgMOn6HS1FhD4gsc9BLtcvGWHTVzqTNJnAij3qs0hY5FovVbRppw%22%2C%22autoRenewing%22%3Atrue%7D?alt=json returned "Invalid Value">

This mean what token (from receipt) is wrong. See PR #50

burkaslarry commented 5 years ago

Under what condition should the token to be correct ? Given correct code as above

burkaslarry commented 5 years ago

I am currently using a test card (Android) / sandbox environment (IOS). Does it affect the situation that turning our receipt is valid or not?

ruslux commented 5 years ago

I am currently using a test card (Android) / sandbox environment (IOS). Does it affect the situation that turning our receipt is valid or not?

https://gist.github.com/ruslux/5760e41241e209f87b89a8f2431360ae

dotpot commented 5 years ago

should be fixed with #50

burkaslarry commented 5 years ago

Thanks I am waiting for the update. Great work