如何取消用户订阅用户google-api-python-client

时间:2017-10-11 12:23:19

标签: python google-api google-api-python-client

我想用python从我的服务器端代码取消用户订阅。我已经使用谷歌API验证用户订阅。 API端点看起来像这样。

  

获取https://www.googleapis.com/androidpublisher/v2/applications/ {packageName} / purchases / subscriptions / {subscriptionId} / tokens / {token}

我在python中实现了这个

service = build(serviceName='androidpublisher', version='v2', credentials=cred)
response = service.purchases().subscriptions().get(
            packageName=receipt_json.get('packageName'),
            subscriptionId=receipt_json.get('productId'),
            token=receipt_json.get('purchaseToken')).execute()

取消订阅的端点如下所示。

  

POST https://www.googleapis.com/androidpublisher/v2/applications/ {packageName} / purchases / subscriptions / {subscriptionId} / tokens / {token}:取消

如何在google-api-python-client中实现此:cancel

1 个答案:

答案 0 :(得分:0)

我这样做了

service = build(serviceName='androidpublisher', version='v2', credentials=cred) 
response = service.purchases().subscriptions().cancel(
            packageName=receipt_json.get('packageName'),
            subscriptionId=receipt_json.get('productId'),
            token=receipt_json.get('purchaseToken')).execute()