Documentation

ValidateGooglePlayPurchase

Validates a Google Play purchase and gives the corresponding item to the player.

Request Details

The packageName and productId are defined in the GooglePlay store. The productId must match the ItemId of the inventory item in the PlayFab catalog for the title. This enables the PlayFab service to securely validate that the purchase is for the correct item, in order to prevent uses from passing valid receipts as being for more expensive items (passing a receipt for a 99-cent purchase as being for a $19.99 purchase, for example). Each receipt may be validated only once to avoid granting the same item over and over from a single purchase.

ValidateGooglePlayPurchaseRequest
Request Properties
CurrencyCode String

Currency used for the purchase.

PurchasePrice uint32

Amount of the stated currency paid for the object.

ReceiptJson (required) String

Original JSON string returned by the Google Play IAB API.

Signature (required) String

Signature returned by the Google Play IAB API.

POST https://{{TitleID}}.playfabapi.com/Client/ValidateGooglePlayPurchase
    Content-Type: application/json
    X-Authentication: <user_session_ticket_value>
{
  "ReceiptJson": "{\"orderId\":\"12999763169054705758.1375794066587622\",\"packageName\":\"com.playfab.android.testbed\",\"productId\":\"com.playfab.android.permatest.consumable\",\"purchaseTime\":1410891177231,\"purchaseState\":0,\"purchaseToken\":\"eaflhokdkobkmomjadmoobgb.AO-J1OwoLkW2cqvBcPEgk6SfGceQpOHALMUFmJYeawa-GuDFtl3oKct-5D28t_KvNscFiJOFiWXIS74vJBYg-CGFJgyrdbxalKEMPzXZrg5nLomCME-jIVFAUrzcPah-_66KPImG5ftsMJKI9uzldqEF9OPcakUEmt-kWoXAsl_6-9HH0gBCwh4\"}",
  "Signature": "ks12w0hHHpuit4xW3Fyoa5XX6TkxZ2KpEnBsLfpHHpeakYs2JgVtlLdgyLp/05Zp8oHAuKZyIAJTd2RIFXWMAUwDNUsI0JPBDMpr2oaL66Kuneg4VrGWJkJZTrvTyQoGpnTDdXfEME31iFKX6CrKHvWlAG9nwWxYatd58l83eevQ8CIrJhka/bC5ynw3j18OmFG7AcxymO37a4HkM8QjytvAYDJeOnDU9mooY7afcHIajtffdyAU9kzGWOqDByiU9IsRdkliwQoQYbuX/R5wQnMVZ+FGDDwO1mybx9B20rm7/WCBnWGy2NLsSAFI77iX8tUy/QebfBQhrVnRORi7bw==",
  "CurrencyCode": "USD",
  "PurchasePrice": 199
}
        

Response Details

Once verified, the catalog item (ItemId) matching the GooglePlay store item (productId) will be added to the user's inventory.

ValidateGooglePlayPurchaseResult
Result Properties

Sample Response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8


Authentication

SessionTicket

Possible Error Codes

Name Code
InvalidBundleID 1098
InvalidProductForSubscription 1338
InvalidReceipt 1021
MissingTitleGoogleProperties 1090
NoMatchingCatalogItemForReceipt 1178
NoRealMoneyPriceForCatalogItem 1180
ReceiptAlreadyUsed 1022
ReceiptCancelled 1023
SubscriptionAlreadyTaken 1340