1.6 Callback URL

In order to manage user points in your server, 
  • In publishing configuration page, select 'Point Management' as 'Callback URL' .
  • Enter an URL to receive the postback request for user points.

Method
    HTTP POST 

Parameters

 Name    Description
 seq_id Unique transaction Id for each event. Use this value to exclude duplicated requests.
 pay_pnt Amount of point to be given.
 md_user_nm User identification string. You have to set this string in your app using setUserName() API.
 md_chk Check string to verify if all parameters are valid. This value if MD5 hash string of <app_key> + <md_user_nm> + <seq_id>. You can get <app_key> value in Tnk site.
 app_idApp Id of advertising app related to this request.
 user_id
 (deprecated)
Device id of user's device. This parameter is deprecated. (use md_user_nm instead.)
 chk_cd
 (deprecated)
Check string to verify if all parameters are valid.  This parameter is deprecated. (use md_chk instead.)
 
Return Code
Return HTTP 200 code on success. If other value is returned, post back request repeats until 200 code is returned for 24 hours maximun.

* Notice! It is possible to same request delivered, so you must check <seq_id> value not to process twice the same request.

Callback URL Samle code (Java)

Sample Code

// amount of points to give

int payPoint = Integer.parseInt(request.getParameter("pay_pnt"));

// unique transaction id generated in Tnk server to distinguish this postback.

String seqId = request.getParameter("seq_id");

// check code to verify parameters

String checkCode = request.getParameter("md_chk");

// user identifcation string that you have set in your app using TnkSession's setUserName: method

String mdUserName = request.getParameter("md_user_nm");

// Your app key  from Tnk site

String appKey = "d2bbd...........19c86c8b021";

// Make verfication Code using the parameters in this post back.

// DigestUtils comes from Apache's commons-codec.jar. Other md5 libraries are Ok.

String verifyCode = DigestUtils.md5Hex(appKey + mdUserName + seqId);

// Compare verification code you generated with the value from md_chk parameter. These two values must be identical.

if (checkCode == null || !checkCode.equals(verifyCode)) {

    // invalid request

    log.error("tnkad() check error : " + verifyCode + " != " + checkCode);

else {

    log.debug("tnkad() : " + mdUserName + ", " + seqId);

    // do your point management logic here. Don't forget to check if seqId is processed before.

    purchaseManager.getPointByAd(mdUserName, payPoint, seqId);

}


Comments