Method: purchases.subscriptionsv2.revoke
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
subscriptionsv2.revoke a subscription purchase for the user.
Yêu cầu HTTP
POST https://androidpublisher.googleapis.com/androidpublisher/v3/applications/{packageName}/purchases/subscriptionsv2/tokens/{token}:revoke
URL sử dụng cú pháp Chuyển mã gRPC.
Tham số đường dẫn
Thông số |
packageName |
string
Bắt buộc. Gói của ứng dụng mà người dùng đã mua gói thuê bao này (ví dụ: "com.some.thing").
|
token |
string
Bắt buộc. Mã thông báo được cung cấp cho thiết bị của người dùng khi người dùng mua gói thuê bao.
|
Nội dung yêu cầu
Nội dung yêu cầu chứa dữ liệu có cấu trúc sau:
Trường |
revocationContext |
object (RevocationContext )
Bắt buộc. Thông tin bổ sung về việc thu hồi gói thuê bao.
|
Nội dung phản hồi
Nếu thành công, nội dung phản hồi sẽ trống.
Mẫu
Sau đây là một yêu cầu mẫu:
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": {}
}
}'
Phạm vi uỷ quyền
Yêu cầu phạm vi OAuth sau:
https://www.googleapis.com/auth/androidpublisher
RevocationContext
Ngữ cảnh thu hồi của API purchases.subscriptionsv2.revoke.
Biểu diễn dưới dạng 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 .
} |
Trường |
Trường hợp hợp nhất RefundType . Xác định loại khoản tiền hoàn lại cần được cấp. Bạn phải chỉ định một loại khoản hoàn tiền trong một yêu cầu hợp lệ. RefundType chỉ có thể là một trong những loại sau: |
fullRefund |
object (FullRefund )
Không bắt buộc. Được dùng khi người dùng cần được hoàn lại toàn bộ số tiền của khoản phí mới nhất trên từng mục trong gói thuê bao.
|
proratedRefund |
object (ProratedRefund )
Không bắt buộc. Được dùng khi người dùng cần được hoàn lại một khoản tiền theo tỷ lệ mà họ đã trả cho gói thuê bao dựa trên khoảng thời gian còn lại trong gói thuê bao.
|
itemBasedRefund |
object (ItemBasedRefund )
Không bắt buộc. Được dùng khi cần hoàn tiền cho một mặt hàng cụ thể trong gói thuê bao có các mặt hàng bổ sung.
|
FullRefund
Loại này không có trường nào.
Dùng để xác định xem loại khoản hoàn tiền trong RevocationContext có phải là hoàn tiền toàn bộ hay không.
ProratedRefund
Loại này không có trường nào.
Dùng để xác định xem loại tiền hoàn lại trong RevocationContext có phải là tiền hoàn lại theo tỷ lệ hay không.
ItemBasedRefund
Dùng để xác định mục cụ thể cần thu hồi trong một gói thuê bao có nhiều mục.
Biểu diễn dưới dạng JSON |
{
"productId": string
} |
Trường |
productId |
string
Bắt buộc. Nếu gói thuê bao có các tiện ích bổ sung, hãy cung cấp mã sản phẩm của mặt hàng thuê bao cần thu hồi.
|
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-07-26 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-26 UTC."],[[["\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. |"]]