You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
defverify_with_result(
self, purchase_token: str, product_sku: str, is_subscription: bool=False
) ->GoogleVerificationResult:
"""Verifies by returning verification result instead of raising an error, basically it's and better alternative to verify method."""service=build("androidpublisher", "v3", http=self.http)
verification_result=GoogleVerificationResult({}, False, False)
ifis_subscription:
result=self.check_purchase_subscription(purchase_token, product_sku, service)
verification_result.raw_response=resultcancel_reason=int(result.get("cancelReason", 0))
ifcancel_reason!=0:
verification_result.is_canceled=Truems_timestamp=result.get("expiryTimeMillis", 0)
ifself._ms_timestamp_expired(ms_timestamp):
verification_result.is_expired=Trueelse:
result=self.check_purchase_product(purchase_token, product_sku, service)
verification_result.raw_response=resultpurchase_state=int(result.get("purchaseState", 1))
ifpurchase_state!=0:
verification_result.is_canceled=Truereturnverification_result
According to publisher docs, Google uses code 0 as a valid code of cancellation in property cancelReason. It means, that this code indicates, that subscription was canceled (by user). On the other hand, code 0 in this method used as a value of variable, which means, that the subscription is not canceled.
The question is, how to interpret GoogleVerificationResult.is_canceled (what does this attribute mean)? And how to separate the cases, when:
subscription was not cancelled
subscription canceled by user? (with code 0)
Expected Behavior
is_canceled means, that subscription is canceled (by user or not)
Actual Behavior
is_canceled means, that subscription was canceled, but not by user
Possible Fix
It depends on the meaning of the is_canceled attribute. Maybe some comment would be useful, if everything works as expected. Or, If it is a bug, then as a possible fix: change the condition check (don't use value 0 as indicator, because this value is reserved by Google).
Your Environment
Version used: 2.4.4
Operating System and version: Docker python:3.7.4-buster
The text was updated successfully, but these errors were encountered:
vartagg
changed the title
GoogleVerificationResult: how to interpret is_canceled and separate multiple cases?
GoogleVerificationResult: how to interpret is_canceled and separate different cases?
Jul 9, 2020
Description
There is a method in
GooglePlayVerifier
class:According to publisher docs, Google uses code
0
as a valid code of cancellation in propertycancelReason
. It means, that this code indicates, that subscription was canceled (by user). On the other hand, code0
in this method used as a value of variable, which means, that the subscription is not canceled.The question is, how to interpret
GoogleVerificationResult.is_canceled
(what does this attribute mean)? And how to separate the cases, when:0
)Expected Behavior
is_canceled
means, that subscription is canceled (by user or not)Actual Behavior
is_canceled
means, that subscription was canceled, but not by userPossible Fix
It depends on the meaning of the
is_canceled
attribute. Maybe some comment would be useful, if everything works as expected. Or, If it is a bug, then as a possible fix: change the condition check (don't use value0
as indicator, because this value is reserved by Google).Your Environment
2.4.4
python:3.7.4-buster
The text was updated successfully, but these errors were encountered: