Closed Gameonn closed 2 years ago
If you got a response from google api with status 200 - purchase is valid.
What kind of service provide to customer depends on your logic.
To detect sandbox purchase use method getPurchaseType().
More info here: https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.subscriptions
Presently I am using getPurchaseType()
method but in real purchase I get null
value and for sandbox I get 0
value.
Rest response remains same for sandbox and production.
Is this the expected behaviour?
Sample Response:
PurchaseResponse {#211 ▼
#response: Google_Service_AndroidPublisher_ProductPurchase {#262 ▼
+acknowledgementState: 1
+consumptionState: 1
+developerPayload: "{"developerPayload":"","is_free_trial":false,"has_introductory_price_trial":false,"is_updated":false,"accountId":""}"
+kind: "androidpublisher#productPurchase"
+obfuscatedExternalAccountId: null
+obfuscatedExternalProfileId: null
+orderId: "GPA.3305-3625-0851-58138"
+productId: null
+purchaseState: 1
+purchaseTimeMillis: "1607046594799"
+purchaseToken: null
+purchaseType: null
+quantity: null
+regionCode: "MX"
#internal_gapi_mappings: []
#modelData: []
#processed: []
}
#developerPayload: array:5 [▼
"developerPayload" => ""
"is_free_trial" => false
"has_introductory_price_trial" => false
"is_updated" => false
"accountId" => ""
]
}
Are there any other methods for the above response that I can execute in order to check sandbox purchase?
Presently I am using
getPurchaseType()
method but in real purchase I getnull
value and for sandbox I get0
value. Rest response remains same for sandbox and production.Is this the expected behaviour?
Yes, it is also described in documentation. purchaseType=0
is about sandbox.
_The type of purchase of the subscription. This field is only set if this purchase was not made using the standard in-app billing flow. Possible values are:
Are there any other methods for the above response that I can execute in order to check sandbox purchase? no.
In iTunes, we have methods like
isValid()
andgetReceipt()
, do we have similar methods in google play as well??What are the methods to determine whether it is a test/sandbox purchase or real purchase??