FAPI.UI.showPayment

Displays payment dialog for the final product. For successful payment, the server callback from the developer’s side must confirm it. Otherwise, the payment will fail and the money will be returned to the user. Once the transaction is complete, the application will get the “ok” notification and JSON with amount as data.

Parameters

ParameterRequiredTypeDescription
nameNoStringProduct name, for example: 1 apple tree
descriptionYesStringProduct description, for example: Gold lets you buy useful items in the game
codeYesStringProduct ID that codes products, the sum, etc. in a free format
priceYesintTotal price in the virtual currency of the portal
optionsNoStringOutdated. Always null.
attributesNoStringJSON encoded key/value pairs containing additional transaction parameters that will be transmitted to the server
currencyNoStringPayment currency; currently only ok is supported (by default)
callbackNoStringfalse (by default) – update the application after the successful completion of the transaction, true – do not update the application, but notify with a callback (see the API_callback section)
uiConfNoStringJSON encoded key/value pairs containing configuration for UI representation of payment dialog. See the section “Possible values of the uiConf attribute” below.

Possible values of the uiConf attribute

KeyRequiredTypeDesciprion
popLayer.payment.cards.mastercardOnlyNoBooleanIndicates whether it is necessary to display instructions saying that the only accepted payment method is Mastercard
popLayer.payment.customNoStringName of application-specific title and description on the payment screen
popLayer.payment.sms.enabledNoBooleanIndicates whether it is necessary to display the payment method via SMS, if the RUR currency is used for payment
popLayer.payment.productHashNoStringValidating hash to protect the price from being falsified.
The hash must be generated only on the server, as the application secret key must not be available in the client.
Validation is activated upon the request to the support team

productHash contains the hex representation SHA-256 in UTF-8 of the string code:price:secretKey
For an Apple product with 5 OK price and the secret application key 9DC54A7008D30D1E0E748F37: popLayer.payment.productHash = SHA-256(“Apple:5:9DC54A7008D30D1E0E748F37”) = 00d8ff0c8c997fae89922dde39868da0fd4dedac8f18dfc1cced427b35c52155

function showPayment() {
    FAPI.UI.showPayment("Apple", "Very tasty!", 777, 1, null, null, "ok", "true");
}