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.
Parameter | Required | Type | Description |
---|---|---|---|
name | No | String | Product name, for example: 1 apple tree |
description | Yes | String | Product description, for example: Gold lets you buy useful items in the game |
code | Yes | String | Product ID that codes products, the sum, etc. in a free format |
price | Yes | int | Total price in the virtual currency of the portal |
options | No | String | Outdated. Always null. |
attributes | No | String | JSON encoded key/value pairs containing additional transaction parameters that will be transmitted to the server |
currency | No | String | Payment currency; currently only ok is supported (by default) |
callback | No | String | false (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) |
uiConf | No | String | JSON 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
Key | Required | Type | Desciprion |
---|---|---|---|
popLayer.payment.cards.mastercardOnly | No | Boolean | Indicates whether it is necessary to display instructions saying that the only accepted payment method is Mastercard |
popLayer.payment.custom | No | String | Name of application-specific title and description on the payment screen |
popLayer.payment.sms.enabled | No | Boolean | Indicates whether it is necessary to display the payment method via SMS, if the RUR currency is used for payment |
popLayer.payment.productHash | No | String | Validating 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
Callback example
API_callback can be called with following parameters:
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
?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
?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:
?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