Before setting up External SDK check your application’s settings:
- MOBILE_HTML or External platform should be enabled;
- for MOBILE_HTML apps:
- callback url must be specified for payments to work correctly;
- for External apps:
- client OAuth authorization is enabled;
- redirect_uri field contains an url that will be used for authorization process;
- all required permissions are enabled. It is highly recommended to enable LONG_ACCESS_TOKEN permission for native IOS and Android applications.
To enable External SDK in your project you need to: * copy oksdk.js file from repository to your project; * enable this script on your page, i.e:
To correctly init SDK specify your application’s id and key in a config:
To invoke REST API method use OKSDK.REST.call:
To use our widgets use the following methods:
- publishing widget - OKSDK.Widgets.post;
- invitation and recommendation widgets - OKSDK.Widgets.invite / OKSDK.Widgets.suggest).
Payment example for MOBILE_HTML application
To initiate a payment you need to open a following URL:
|name||Yes||String||Product name. I.e. “1 apple”|
|price||Yes||int||Product price in OKs|
|code||Yes||String||Product identifier. It is a string that contains information about product, it’s price and all other data required for verification. Code is sent to application server during payment processing.|
Signature is calculated by the following formula:
md5(“application_key=” + APPLICATION_PUBLIC_KEY + “code=”+PRODUCT_CODE + “name=” + PRODUCT_NAME + “price=” + PRODUCT_PRICE + “session_key=” + SESSION_KEY + SESSION_SECRET_KEY)
Payment with SDK
SDK allows you to proceed payments in an easy and fast way:
If a payment was accepted or canceled by user he is then redirected to an application page. Additional GET-parameter “custom_args” is added to an URL with value “payment=ok” if payment was proceeded successfully and “payment=cancel” if it was cancelled.