Method: purchases.subscriptions.get
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
เลิกใช้งานแล้ว: ใช้ purchases.subscriptionsv2.get แทน ตรวจสอบว่าการสมัครใช้บริการของผู้ใช้ถูกต้องหรือไม่และแสดงเวลาหมดอายุ
คำขอ HTTP
GET https://androidpublisher.googleapis.com/androidpublisher/v3/applications/{packageName}/purchases/subscriptions/{subscriptionId}/tokens/{token}
URL ใช้ไวยากรณ์การแปลง gRPC
พารามิเตอร์เส้นทาง
พารามิเตอร์ |
packageName |
string
ชื่อแพ็กเกจของแอปพลิเคชันที่ซื้อการสมัครใช้บริการนี้ (เช่น "com.some.thing")
|
subscriptionId |
string
รหัสการสมัครใช้บริการที่ซื้อ (เช่น "monthly001")
|
token |
string
โทเค็นที่ระบุให้กับอุปกรณ์ของผู้ใช้เมื่อซื้อการสมัครใช้บริการ
|
เนื้อความของคำขอ
เนื้อหาของคำขอต้องว่างเปล่า
เนื้อหาการตอบกลับ
หากทำสำเร็จ เนื้อหาการตอบกลับจะมีอินสแตนซ์ SubscriptionPurchase
ตัวอย่าง
ตัวอย่างคําขอมีดังนี้
curl -X GET \
'https://androidpublisher.googleapis.com/androidpublisher/v3/applications/com.example.app/purchases/subscriptions/monthly.premium/tokens/abcdefghijklmnopqrstuvwxyz.0123456789' \
-H 'Accept: application/json'
ตัวอย่างคำตอบมีดังนี้
{
"kind": "androidpublisher#subscriptionPurchase",
"startTimeMillis": "1678886400000",
"expiryTimeMillis": "1710470400000",
"autoRenewing": true,
"priceCurrencyCode": "USD",
"priceAmountMicros": "9990000",
"introductoryPriceInfo": {
"introductoryPriceCurrencyCode": "USD",
"introductoryPriceAmountMicros": "4990000",
"introductoryPricePeriod": "P1M",
"introductoryPriceCycles": 1
},
"countryCode": "US",
"developerPayload": "{\"userId\": \"user12345\", \"source\": \"app-promo\"}",
"paymentState": 1,
"cancelReason": 0,
"userCancellationTimeMillis": "1709251200000",
"cancelSurveyResult": {
"cancelSurveyReason": 3,
"userInputCancelReason": null
},
"orderId": "GPA.3344-5566-7788-99001",
"linkedPurchaseToken": null,
"purchaseType": 0,
"priceChange": null,
"profileName": "Jane Doe",
"emailAddress": "jane.doe@example.com",
"givenName": "Jane",
"familyName": "Doe",
"profileId": "109876543210987654321",
"acknowledgementState": 1,
"externalAccountId": "user-jane-doe-app-id",
"promotionType": 1,
"promotionCode": "WELCOME20",
"obfuscatedExternalAccountId": "obfUaCcOunTId123",
"obfuscatedExternalProfileId": "obfPrOfiLeId456",
"autoResumeTimeMillis": null
}
ขอบเขตการให้สิทธิ์
ต้องใช้ขอบเขต OAuth ต่อไปนี้
https://www.googleapis.com/auth/androidpublisher
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 2025-07-26 UTC"],[[["\u003cp\u003eVerifies the validity of a user's subscription purchase and provides the expiry time.\u003c/p\u003e\n"],["\u003cp\u003eRequires the package name, subscription ID, and purchase token to validate the subscription.\u003c/p\u003e\n"],["\u003cp\u003eUses an HTTP GET request and requires authorization with the \u003ccode\u003ehttps://www.googleapis.com/auth/androidpublisher\u003c/code\u003e scope.\u003c/p\u003e\n"],["\u003cp\u003eReturns a \u003ccode\u003eSubscriptionPurchase\u003c/code\u003e object containing subscription details if the purchase is valid.\u003c/p\u003e\n"]]],["The core function validates a user's subscription purchase and provides its expiry time. It uses a `GET` HTTP request to a specific URL, incorporating parameters for `packageName`, `subscriptionId`, and `token`. The request body should be empty. A successful response returns a `SubscriptionPurchase` instance. Authorization requires the `https://www.googleapis.com/auth/androidpublisher` OAuth scope. This process verifies the validity of subscription data using a predefined request structure and security measures.\n"],null,["# Method: purchases.subscriptions.get\n\n- [HTTP request](#body.HTTP_TEMPLATE)\n- [Path parameters](#body.PATH_PARAMETERS)\n- [Request body](#body.request_body)\n- [Response body](#body.response_body)\n- [Authorization scopes](#body.aspect)\n- [Try it!](#try-it)\n\n| This item is deprecated!\nDeprecated: Use purchases.subscriptionsv2.get instead. Checks whether a user's subscription purchase is valid and returns its expiry time.\n\n### HTTP request\n\n`GET https://androidpublisher.googleapis.com/androidpublisher/v3/applications/{packageName}/purchases/subscriptions/{subscriptionId}/tokens/{token}`\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` 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 must be empty.\n\n### Response body\n\nIf successful, the response body contains an instance of [SubscriptionPurchase](/android-publisher/api-ref/rest/v3/purchases.subscriptions#SubscriptionPurchase).\n\n### Sample\n\nThe following is a sample request: \n\n```json\ncurl -X GET \\\n 'https://androidpublisher.googleapis.com/androidpublisher/v3/applications/com.example.app/purchases/subscriptions/monthly.premium/tokens/abcdefghijklmnopqrstuvwxyz.0123456789' \\\n -H 'Accept: application/json'\n```\n\nThe following is a sample response: \n\n```json\n{\n \"kind\": \"androidpublisher#subscriptionPurchase\",\n \"startTimeMillis\": \"1678886400000\",\n \"expiryTimeMillis\": \"1710470400000\",\n \"autoRenewing\": true,\n \"priceCurrencyCode\": \"USD\",\n \"priceAmountMicros\": \"9990000\",\n \"introductoryPriceInfo\": {\n \"introductoryPriceCurrencyCode\": \"USD\",\n \"introductoryPriceAmountMicros\": \"4990000\",\n \"introductoryPricePeriod\": \"P1M\",\n \"introductoryPriceCycles\": 1\n },\n \"countryCode\": \"US\",\n \"developerPayload\": \"{\\\"userId\\\": \\\"user12345\\\", \\\"source\\\": \\\"app-promo\\\"}\",\n \"paymentState\": 1,\n \"cancelReason\": 0,\n \"userCancellationTimeMillis\": \"1709251200000\",\n \"cancelSurveyResult\": {\n \"cancelSurveyReason\": 3,\n \"userInputCancelReason\": null\n },\n \"orderId\": \"GPA.3344-5566-7788-99001\",\n \"linkedPurchaseToken\": null,\n \"purchaseType\": 0,\n \"priceChange\": null,\n \"profileName\": \"Jane Doe\",\n \"emailAddress\": \"jane.doe@example.com\",\n \"givenName\": \"Jane\",\n \"familyName\": \"Doe\",\n \"profileId\": \"109876543210987654321\",\n \"acknowledgementState\": 1,\n \"externalAccountId\": \"user-jane-doe-app-id\",\n \"promotionType\": 1,\n \"promotionCode\": \"WELCOME20\",\n \"obfuscatedExternalAccountId\": \"obfUaCcOunTId123\",\n \"obfuscatedExternalProfileId\": \"obfPrOfiLeId456\",\n \"autoResumeTimeMillis\": null\n}\n```\n\n### Authorization scopes\n\nRequires the following OAuth scope:\n\n- `https://www.googleapis.com/auth/androidpublisher`"]]