Method signature

This SDK is deprecated
For games and applications launched from OK please consider using multiplatform SDK

Method is used for processing in-app payments. Payment dialog is opened on a new page.

OKSDK.Payment.show(productName, productPrice, productCode, options)

Where:

  • productName - product name that is going to be shown in a payment dialog. Required parameter;
  • productPrice - product price on OKs. Required parameter;
  • productCode - product code. Will be used in a payment transaction info and will be sent to app’s callback service. Required parameter;
  • options - deprecated parameter.

Example usage

OKSDK.Payment.show(
    "One apple",
    30,
    "apple",
    null
);

As a result payment dialog will be opened on a new page where user can either cancel or verify a payment:

In-app dialog on a page

Payment result handling

When payment dialog is closed a result will be sent to a game. Message format and transport type depends on app’s launch type.

App is opened in an iframe

If your app is opened in an iframe postMessage will be sent to a game’s page with data field containing payment result:

  • payment=cancel - payment was cancelled;
  • payment=ok - payment was successfully proceeded.

Payment window will be closed automatically if your app is opened in an iframe.

App is opened as an external page

If your app is opened as an external page after payment window is closed user will be redirected to a game’s page and payment result will be passed as an additional GET-parameter custom_args with following value:

  • payment=cancel - payment was cancelled;
  • payment=ok - payment was successfully proceeded.

If your app is opened as an external page you need to close payment window manually.