Verify token
First time, user subscribes, You need to verify a purchase token.
there are two APIs (V, V2)
If you want to know trial status of subscrtion, use V because of parameter purchaseType
V2 doesn’t support this parameter yet (23.01.01).
POST
@param { purchaseToken }
@path /api/iap/verify/google
Ref. https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.subscriptions
{
"isSuccessful": true,
"errorMessage": null,
"payload": {
"startTimeMillis": "1666693125073",
"expiryTimeMillis": "1666693170935",
"autoRenewing": false,
"priceCurrencyCode": "KRW",
"priceAmountMicros": "7900000000",
"countryCode": "KR",
"developerPayload": "",
"cancelReason": 2,
"orderId": "GPA.0000-6933-1569-77703",
"linkedPurchaseToken":"olaclkgakogdalhpikoblhac.AO-J1OwhYqKZaeUqT1mXvr4z8OsjmMX88QHfvlRf—--"
"purchaseType": 0,
"acknowledgementState": 1,
"kind": "androidpublisher#subscriptionPurchase"
}
Ref. https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.subscriptionsv2
{
"kind": string,
"regionCode": string,
"latestOrderId": string,
"lineItems": [
{
object (SubscriptionPurchaseLineItem)
}
],
"startTime": string,
"subscriptionState": enum (SubscriptionState),
"linkedPurchaseToken": string,
"pausedStateContext": {
object (PausedStateContext)
},
"canceledStateContext": {
object (CanceledStateContext)
},
"testPurchase": {
object (TestPurchase)
},
"acknowledgementState": enum (AcknowledgementState),
"externalAccountIdentifiers": {
object (ExternalAccountIdentifiers)
},
"subscribeWithGoogleInfo": {
object (SubscribeWithGoogleInfo)
}
}
SubscriptionPurchaseLineItem
{
"productId": string,
"expiryTime": string,
// Union field plan_type can be only one of the following:
"autoRenewingPlan": {
object (AutoRenewingPlan)
},
"prepaidPlan": {
object (PrepaidPlan)
}
// End of list of possible types for union field plan_type.
}
Response
Google Realtime Notification
Ref. https://developer.android.com/google/play/billing/rtdn-reference
Config. Google Cloud - Pub/Sub
Response
After you decode the base64-encoded data field, the DeveloperNotification contains the following fields:

A subscriptionNotification contains the following fields:
{
"version":"1.0",
"packageName":"com.some.thing",
"eventTimeMillis":"1503349566168",
"subscriptionNotification":
{
"version":"1.0",
"notificationType":4,
"purchaseToken":"PURCHASE_TOKEN",
"subscriptionId":"monthly001"
}
}
- Use notificationType and subscriptionId
- Verify token again
'CODE > Javascript' 카테고리의 다른 글
| Appstore Server API (0) | 2023.01.31 |
|---|---|
| How to handle App Store Subscription (0) | 2023.01.20 |