Skip to main content
Samsung Developer Program

Server-to-Server Purchase Verification

After a user makes a purchase, by using the purchase token to visit a URL, developers can determine whether or not that purchase was successfully processed by Samsung Billing.

Purchase verification is typically performed by the service app server; the following diagram illustrates this behavior. However, purchase verification can be performed directly on the service app.

OpenIAB_Integration_Interdependencies_ServerToServerVerificationDiagram.png

To perform Server-to-Server Purchase Verification

  1. Use the verify URL:
https://iap.samsungapps.com/iap/appsItermVerifyIAPReceipt.as?protocolVersion=2.0
  1. Get the purchaseID. You can get the purchaseID from:

onPurchaseSucceeded callback (Unity Level)This is a Unity level approach. In the Shop.cs file, get the token attribute from the object Purchase purchase by using purchase.Token as shown in the following example.

Shop.cs
private void OnPurchaseSucceeded (Purchase purchase) {

    ...
    String purchaseID = purchase.Token;
    ...
}

Purchase finished logsAfter a purchase, get the token included in the purchase finished logs. This option can be enabled and disabled in the source code using enableDebugLogging(). See the Open IAB Unity Plugin API Reference for details. For example: 

D        24718    OpenIAB-UnityPlugin  Purchase finished: IabResult: 0, 0:OK, purchase: PurchaseInfo(type:inapp): 
{"orderId":TPMTID20151104PHI2037906, "packageName":com.samsung.bostoniab, "productId":sku_plane_fuel, "purchaseTime": 
1446604114390, "purchaseState":0, "developerPayload":, "token":9954cec99a965fef6490b3fec3baf9ba7d98335a6d5blc663774c6503d442e77}

For production apps, it is recommended to disable debug logging.

  1. Append the purchaseID to the URL following the format below: 
&purchaseID=<token>
  1. The following is an example that uses the format specified above:
https://iap.samsungapps.com/iap/appsItemVerifyIAPReceipt.as?protocolVersion=2.0&purchaseID=9954cec99a965fef6490b3fec3baf9ba7d98335a6d5blc663774c6503d442ee7
  1. Verify URL. The link will provide the results of the verification in JSON format. 
  • If the purchase is valid:
{
"itemId" : "57515",
"paymentId" :  "ZPMTID20131122GBI0015292",
"itemName" : "Test Pack",
"itemDesc" : "IAP Test Item. Best value!",
"purchaseDate" : "2013-11-22 04:22:36",
"paymentAmount" : "9.000",
"status" : "true",
"paymentMethod" : "CreditCard",
"mode" : "REAL",
}
  • If the purchase is invalid: 
{"status" : "false"} 

For more details about the description of result values, see the Samsung In-App Purchase section.

  • Was this article helpful?