Method: purchases.subscriptions.cancel
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.
Huỷ giao dịch mua gói thuê bao của người dùng. Gói thuê bao vẫn có hiệu lực cho đến thời điểm hết hạn.
Yêu cầu HTTP
POST https://androidpublisher.googleapis.com/androidpublisher/v3/applications/{packageName}/purchases/subscriptions/{subscriptionId}/tokens/{token}:cancel
URL sử dụng cú pháp Chuyển mã gRPC.
Tham số đường dẫn
Thông số |
packageName |
string
Tên gói của ứng dụng mà bạn đã mua gói thuê bao này (ví dụ: "com.some.thing").
|
subscriptionId |
string
Lưu ý: Kể từ ngày 21 tháng 5 năm 2025, bạn không bắt buộc phải sử dụng subscriptionId và không nên sử dụng cho gói thuê bao có tiện ích bổ sung. Mã nhận dạng gói thuê bao được mua (ví dụ: "monthly001").
|
token |
string
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 |
cancellationType |
enum (CancellationType )
Không bắt buộc. Loại yêu cầu huỷ gói thuê bao đã mua. Xin lưu ý rằng trường này chỉ được hỗ trợ trong yêu cầu HTTP. Phương thức này không có trong thư viện ứng dụng.
|
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 \
-H "Accept: application/json" \
"https://androidpublisher.googleapis.com/androidpublisher/v3/applications/com.example.app/purchases/subscriptions/monthly.premium.plan/tokens/EXAMPLE_TOKEN_STRING_12345:cancel"
Phạm vi uỷ quyền
Yêu cầu phạm vi OAuth sau:
https://www.googleapis.com/auth/androidpublisher
CancellationType
Loại yêu cầu huỷ của nhà phát triển.
Enum |
CANCELLATION_TYPE_UNSPECIFIED |
Chưa xác định loại yêu cầu huỷ. |
USER_REQUESTED_STOP_RENEWALS |
Người dùng đã yêu cầu huỷ và gói thuê bao có thể được khôi phục. Thao tác này chỉ ngăn gói thuê bao gia hạn vào lần tiếp theo. Đối với gói thuê bao trả góp, người dùng vẫn cần hoàn tất thời hạn cam kết. Để biết thêm thông tin chi tiết về việc gia hạn và thanh toán, hãy xem https://developer.android.com/google/play/billing/subscriptions#installments |
DEVELOPER_REQUESTED_STOP_PAYMENTS |
Nhà phát triển yêu cầu huỷ và bạn không thể khôi phục gói thuê bao. Thao tác này sẽ dừng khoản thanh toán tiếp theo của gói thuê bao. Đối với gói thuê bao trả góp, người dùng sẽ không cần thanh toán khoản thanh toán tiếp theo và hoàn tất thời hạn cam kết. Để biết thêm thông tin chi tiết về việc gia hạn và thanh toán, hãy xem https://developer.android.com/google/play/billing/subscriptions#installments. Đây là hành vi mặc định khi không chỉ định loại huỷ. |
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\u003eCancels a user's subscription purchase, but the subscription remains valid until its expiration time.\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"],["\u003cp\u003eUses a \u003ccode\u003ePOST\u003c/code\u003e request to the specified URL with the package name, subscription ID, and purchase token as path parameters.\u003c/p\u003e\n"],["\u003cp\u003eThe request body should be empty, and a successful cancellation results in an empty response body.\u003c/p\u003e\n"]]],["This document outlines the process for canceling a user's subscription via a `POST` request to the specified URL. The request requires three path parameters: `packageName`, `subscriptionId`, and `token`. The request body optionally includes the `cancellationType`, which can be `USER_REQUESTED_STOP_RENEWALS` or `DEVELOPER_REQUESTED_STOP_PAYMENTS`; default behavior is `DEVELOPER_REQUESTED_STOP_PAYMENTS`. A successful request returns an empty response body and requires the `androidpublisher` OAuth scope. It details various cancellation types.\n"],null,["# Method: purchases.subscriptions.cancel\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- [CancellationType](#CancellationType)\n- [Try it!](#try-it)\n\nCancels a user's subscription purchase. The subscription remains valid until its expiration time.\n\n### HTTP request\n\n`POST https://androidpublisher.googleapis.com/androidpublisher/v3/applications/{packageName}/purchases/subscriptions/{subscriptionId}/tokens/{token}:cancel`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Path parameters\n\n| Parameters ||\n|------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `packageName` | `string` The package name of the application for which this subscription was purchased (for example, 'com.some.thing'). |\n| `subscriptionId` | `string` Note: Since May 21, 2025, subscriptionId is not required, and not recommended for subscription with add-ons. The purchased subscription ID (for example, 'monthly001'). |\n| `token` | `string` 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| ``` { \"cancellationType\": enum (/android-publisher/api-ref/rest/v3/purchases.subscriptions/cancel#CancellationType) } ``` |\n\n| Fields ||\n|--------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `cancellationType` | `enum (`[CancellationType](/android-publisher/api-ref/rest/v3/purchases.subscriptions/cancel#CancellationType)`)` Optional. The type of cancellation for the purchased subscription. Note that this field is only supported in the HTTP request. It is not available in client libraries. |\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 -H \"Accept: application/json\" \\\n \"https://androidpublisher.googleapis.com/androidpublisher/v3/applications/com.example.app/purchases/subscriptions/monthly.premium.plan/tokens/EXAMPLE_TOKEN_STRING_12345:cancel\"\n```\n\n### Authorization scopes\n\nRequires the following OAuth scope:\n\n- `https://www.googleapis.com/auth/androidpublisher`\n\nCancellationType\n----------------\n\nThe type of cancellation requested by the developer.\n\n| Enums ||\n|-------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `CANCELLATION_TYPE_UNSPECIFIED` | Cancellation type unspecified. |\n| `USER_REQUESTED_STOP_RENEWALS` | Cancellation requested by the user, and the subscription can be restored. It only stops subscription's next renewal. For an installment subscription, users still need to finish the commitment period. For more details on renewals and payments, see \u003chttps://developer.android.com/google/play/billing/subscriptions#installments\u003e |\n| `DEVELOPER_REQUESTED_STOP_PAYMENTS` | Cancellation requested by the developer, and the subscription cannot be restored. It stops the subscription's next payment. For an installment subscription, users will not need to pay the next payment and finish the commitment period. For more details on renewals and payments, see \u003chttps://developer.android.com/google/play/billing/subscriptions#installments\u003e This is the default behavior when no cancellation type is specified. |"]]