Validation of the product cost for in-game payments

The process of an in-game payment includes the payment validation stage on the game server.

The feedback process is described in detail on this page: callbacks.payment.

When your game passes moderation before its release on the OK Gaming Platform, one of obligatory requirements is the correct validation of payments where the goods cost parameter is also taken into account.

This is required to not only protect users that make payments, but also to not let users commit improper actions towards the developer, such as buying products for a price that is different from the one listed in your in-game shop.

How to check the products price

One of obligatory requirements of the in-game payment validation is checking the product cost in the moment when your callback service received a request.

If someone attempts to buy products for a price that is listed in the request but is different from the one you listed in the shop, the service must return an error.

How to check it

Let’s say, there is a following product in your shop:

  • product id: someProduct;
  • product cost: 149 OKs.

To execute a valid payment in this case, you will need to call a similar code (by using the FAPI.UI.showPayment method):

function showPayment() {
FAPI.UI.showPayment("test product", "test description", "someProduct", 149, null, null, "ok", "true");
}

This is the case of using a valid payment method. When confirmed, your service should give a positive response to a payment validation request.

To simulate an improper request, call the following code:

function showPayment() {
FAPI.UI.showPayment("test product", "test description", "someProduct", 1, null, null, "ok", "true");
}

As you can see, the cost here is 1 OK instead of 149 OKs. In this case, when your service receives a payment validation request, it should return an error. If this happens, it is forbidden to withdraw funds from the user’s balance and reward the user in the game.