FAPI.UI.showPayment

Method signature

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.

FAPI.UI.showPayment(
    name,
    description,
    code,
    price,
    options,
    attributes,
    currency,
    callback,
    uiConf
);
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

Example usage

function showPayment() {
    FAPI.UI.showPayment("Apple", "It is very tasty", 777, 1, null, null, "ok", "true");
}

Callback example

Функция API_callback может быть вызвана со следующими параметрами:

Callback in case of a successful payment

Web

method: “showPayment”

result: “ok”

data: “{‘amount’:’5’}”

Mobile

method: “showPayment”

result: “ok”

data: “ok”

Callback in case of a cancelled payment

method: “showPayment”

result: “error”

data: “cancel”

Callback in case of a payment processed via phone

This type of callback is only supported on mobile

If a payment resulted in a such callback there can be a delay between callback and an actual in-game purchase

method: “showPayment”

result: “ok”

data: “phone”

Callback in case of a payment processed via card

This type of callback is only supported on mobile

If a payment resulted in a such callback there can be a delay between callback and an actual in-game purchase

method: “showPayment”

result: “ok”

data: “card”

Server callback

A server callback will be sent to your callback service if user has accepted an in-game purchase.

To successfully process this payment you need to verify it on your server.

More information about server callback can be found here: callbacks.payment

Callback example

https://callback.serice/callback_path
   ?transaction_id=632264039936
   &sig=60717782e6d0288aa730f85561fe1743
   &uid=1234567890
   &amount=5
   &method=callbacks.payment
   &transaction_time=2019-04-26 14:11:56
   &product_code=qCoins
   &extra_attributes=[]
   &application_key=APPLICATION_PUBLIC_KEY
   &call_id=1556277116081

Mobile callback example

For mobile payment extra_attributes is always present in a callback

https://callback.serice/callback_path
   ?transaction_id=632264214528
   &sig=aae5be58d0ab4eaf54db033b9d00b95c
   &uid=1234567890
   &amount=1
   &method=callbacks.payment
   &transaction_time=2019-04-26 14:12:35
   &product_code=777
   &extra_attributes={"launcher":"on"}
   &product_option=
   &application_key=APPLICATION_PUBLIC_KEY
   &call_id=1556277155234

Callback example with attributes parameter used

For example, if attributes parameter is ”{"key": "value"}”, following callback will be sent to your callback service:

https://callback.serice/callback_path
   ?transaction_id=632264756480
   &sig=8226ef4f8b92bb11a406075d6f875da6
   &uid=1234567890
   &amount=1
   &method=callbacks.payment
   &transaction_time=2019-04-26 14:14:38
   &product_code=777
   &extra_attributes={"key": "value"}
   &application_key=APPLICATION_PUBLIC_KEY
   &call_id=1556277278594

Payment dialog examples

As a result of this method payment dialog will be opened where user can either decline or accept a purchase.

Initial payment dialog example

Web

Mobile

Payment success dialog example

If payment was accepted by user and you’ve successfully validated on your side following dialog window will be displayed to a user:

Web

Mobile

Payment error dialog example

Web

Mobile