Method: purchases.subscriptionsv2.revoke
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
对用户购买的订阅执行 subscriptionsv2.revoke 操作。
HTTP 请求
POST https://androidpublisher.googleapis.com/androidpublisher/v3/applications/{packageName}/purchases/subscriptionsv2/tokens/{token}:revoke
网址采用 gRPC 转码语法。
路径参数
参数 |
packageName |
string
必需。购买相应订阅所对应的应用的软件包(例如“com.some.thing”)。
|
token |
string
必需。在用户购买订阅时向用户设备提供的令牌。
|
请求正文
请求正文中包含结构如下的数据:
字段 |
revocationContext |
object (RevocationContext )
必需。有关撤消订阅的其他详细信息。
|
示例
以下是一个示例请求:
curl -X POST \
'https://androidpublisher.googleapis.com/androidpublisher/v3/applications/com.example.myapp/purchases/subscriptionsv2/tokens/sample_purchase_token:revoke' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"revocationContext": {
"proratedRefund": {}
}
}'
授权范围
需要以下 OAuth 范围:
https://www.googleapis.com/auth/androidpublisher
RevocationContext
purchases.subscriptionsv2.revoke API 的撤消上下文。
JSON 表示法 |
{
// Union field RefundType can be only one of the following:
"fullRefund": {
object (FullRefund )
},
"proratedRefund": {
object (ProratedRefund )
},
"itemBasedRefund": {
object (ItemBasedRefund )
}
// End of list of possible types for union field RefundType .
} |
字段 |
联合字段 RefundType 。确定应批准的退款类型。必须在有效请求中指定退款类型。RefundType 只能是下列其中一项: |
fullRefund |
object (FullRefund )
可选。应当将订阅中每个项的最新扣款金额全额退还给用户时,使用此字段。
|
proratedRefund |
object (ProratedRefund )
可选。应当根据订阅的剩余时间按比例退还用户支付的订阅费时,使用此字段。
|
itemBasedRefund |
object (ItemBasedRefund )
可选。当订阅包含附加项时,应针对特定项退款时使用。
|
FullRefund
此类型没有字段。
用于确定 RevocationContext 中的退款类型是不是全额退款。
ProratedRefund
此类型没有字段。
用于确定 RevocationContext 中的退款类型是不是按比例退款。
ItemBasedRefund
JSON 表示法 |
{
"productId": string
} |
字段 |
productId |
string
必需。如果订阅包含附加内容,则为要撤消的订阅项的商品 ID。
|
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003eRevoke a user's subscription purchase using the \u003ccode\u003esubscriptionsv2.revoke\u003c/code\u003e API.\u003c/p\u003e\n"],["\u003cp\u003eThe API requires the package name and purchase token in the request path.\u003c/p\u003e\n"],["\u003cp\u003eYou can optionally specify a full or prorated refund in the request body.\u003c/p\u003e\n"],["\u003cp\u003eSuccessful revocation results in an empty response body.\u003c/p\u003e\n"],["\u003cp\u003eRequires the \u003ccode\u003ehttps://www.googleapis.com/auth/androidpublisher\u003c/code\u003e OAuth scope for authorization.\u003c/p\u003e\n"]]],["This document outlines the process for revoking a user's subscription purchase via the `subscriptionsv2.revoke` API. The `POST` request, sent to `https://androidpublisher.googleapis.com/androidpublisher/v3/applications/{packageName}/purchases/subscriptionsv2/tokens/{token}:revoke`, requires the application's package name and the user's subscription token. The request body must include a `revocationContext`, specifying either a `fullRefund` or `proratedRefund`. Successful requests yield an empty response. This API action also needs the `androidpublisher` authorization scope.\n"],null,["# Method: purchases.subscriptionsv2.revoke\n\n- [HTTP request](#body.HTTP_TEMPLATE)\n- [Path parameters](#body.PATH_PARAMETERS)\n- [Request body](#body.request_body)\n - [JSON representation](#body.request_body.SCHEMA_REPRESENTATION)\n- [Response body](#body.response_body)\n- [Authorization scopes](#body.aspect)\n- [RevocationContext](#RevocationContext)\n - [JSON representation](#RevocationContext.SCHEMA_REPRESENTATION)\n- [FullRefund](#FullRefund)\n- [ProratedRefund](#ProratedRefund)\n- [ItemBasedRefund](#ItemBasedRefund)\n - [JSON representation](#ItemBasedRefund.SCHEMA_REPRESENTATION)\n- [Try it!](#try-it)\n\nsubscriptionsv2.revoke a subscription purchase for the user.\n\n### HTTP request\n\n`POST https://androidpublisher.googleapis.com/androidpublisher/v3/applications/{packageName}/purchases/subscriptionsv2/tokens/{token}:revoke`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Path parameters\n\n| Parameters ||\n|---------------|------------------------------------------------------------------------------------------------------------------------------|\n| `packageName` | `string` Required. The package of the application for which this subscription was purchased (for example, 'com.some.thing'). |\n| `token` | `string` Required. The token provided to the user's device when the subscription was purchased. |\n\n### Request body\n\nThe request body contains data with the following structure:\n\n| JSON representation |\n|-------------------------------------------------------------------------------------------------------------------------------------|\n| ``` { \"revocationContext\": { object (/android-publisher/api-ref/rest/v3/purchases.subscriptionsv2/revoke#RevocationContext) } } ``` |\n\n| Fields ||\n|---------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `revocationContext` | `object (`[RevocationContext](/android-publisher/api-ref/rest/v3/purchases.subscriptionsv2/revoke#RevocationContext)`)` Required. Additional details around the subscription revocation. |\n\n### Response body\n\nIf successful, the response body is empty.\n\n### Sample\n\nThe following is a sample request: \n\n```json\ncurl -X POST \\\n 'https://androidpublisher.googleapis.com/androidpublisher/v3/applications/com.example.myapp/purchases/subscriptionsv2/tokens/sample_purchase_token:revoke' \\\n -H 'Accept: application/json' \\\n -H 'Content-Type: application/json' \\\n -d '{\n \"revocationContext\": {\n \"proratedRefund\": {}\n }\n }'\n```\n\n### Authorization scopes\n\nRequires the following OAuth scope:\n\n- `https://www.googleapis.com/auth/androidpublisher`\n\nRevocationContext\n-----------------\n\nRevocation context of the purchases.subscriptionsv2.revoke API.\n\n| JSON representation |\n|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ``` { // Union field `RefundType` can be only one of the following: \"fullRefund\": { object (/android-publisher/api-ref/rest/v3/purchases.subscriptionsv2/revoke#FullRefund) }, \"proratedRefund\": { object (/android-publisher/api-ref/rest/v3/purchases.subscriptionsv2/revoke#ProratedRefund) }, \"itemBasedRefund\": { object (/android-publisher/api-ref/rest/v3/purchases.subscriptionsv2/revoke#ItemBasedRefund) } // End of list of possible types for union field `RefundType`. } ``` |\n\n| Fields ||\n|-------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Union field `RefundType`. Determines the type of refund that should be granted. A refund type must be specified as part of a valid request. `RefundType` can be only one of the following: ||\n| `fullRefund` | `object (`[FullRefund](/android-publisher/api-ref/rest/v3/purchases.subscriptionsv2/revoke#FullRefund)`)` Optional. Used when users should be refunded the full amount of latest charge on each item in the subscription. |\n| `proratedRefund` | `object (`[ProratedRefund](/android-publisher/api-ref/rest/v3/purchases.subscriptionsv2/revoke#ProratedRefund)`)` Optional. Used when users should be refunded a prorated amount they paid for their subscription based on the amount of time remaining in a subscription. |\n| `itemBasedRefund` | `object (`[ItemBasedRefund](/android-publisher/api-ref/rest/v3/purchases.subscriptionsv2/revoke#ItemBasedRefund)`)` Optional. Used when a specific item should be refunded in a subscription with add-on items. |\n\nFullRefund\n----------\n\nThis type has no fields.\nUsed to determine if the refund type in the RevocationContext is a full refund.\n\nProratedRefund\n--------------\n\nThis type has no fields.\nUsed to determine if the refund type in the RevocationContext is a prorated refund.\n\nItemBasedRefund\n---------------\n\nUsed to determine what specific item to revoke in a subscription with multiple items.\n\n| JSON representation |\n|---------------------------------|\n| ``` { \"productId\": string } ``` |\n\n| Fields ||\n|-------------|---------------------------------------------------------------------------------------------------------------------------|\n| `productId` | `string` Required. If the subscription is a subscription with add-ons, the product id of the subscription item to revoke. |"]]