Callback function of close Transaction
This function is ONLY supported in mobage Greater China region including Simplified Chinese and Traditional Chinese. If your apps would be porting to other mobage regions, please do not rely on the callback to give items to users.
After transaction is successfully closed(either from SDK or RESTful API), Mobage Open Platform would call the url, which is registered at Developer Portal, to inform developer that the transaction has been done successfully.
Developers should register the callback url firstly, then handle the http request, which is sent from mobage.
2. Register Callback URL
- Choose the app which need to add callback URL at App Management.
At Game Console - 2 Settings - Bank Callback Settings, add your bank URL
Sandbox and Production callback URL are separated. "Click to switch" to choose environment.
3. Handle Mobage Http Request
3.1 Mobage Http Request
Callback Http Method
sign: it is used to verify whether the http request is sent from Mobage platform. id: transaction id user_id: user id state: transaction status, only if the the state is "close", it indicate that transaction is successful. items: detail information for the items in the transaction. comment: extra information，which is filled by developers during creating transaction. published: create time of transaction updated: end time of transaction
3.2 Handle Mobage Http Request
Validation can be confirmed by IP and SIGN.
|Mobage Simplified Chinese Platform||220.127.116.11/24(18.104.22.168~22.214.171.124)|
|Mobage Traditional Chinese Platform||126.96.36.199/24 (188.8.131.52~184.108.40.206)|
The method of generate sign：
MD5 the combined string of app_id, transaction_id and consumer key.
consumer_key can be get from Developer site, At Game Console - 1 Base Info - Common - Consumer Key(for game server)
3.3 Callback Timing, Response and Retry Mechanism
After closeTransaction successfully called.
Response and Retry
If processing succeeded, game server should returns http code 200. Otherwise mobage server would consider the response as a failure. The callback would NOT check body of game server's response.
Without gaining http code 200 response, Mobage server would retry at most 10 times to call the registered URL.
The timing of retry is (3 ^ n - 1) seconds after the last Callback failure. n is times. max of n is 10.
|Retry||Time: ? seconds after last failure|
|First retry||3 ^ 1 - 1 = 2|
|Second retry||3 ^ 2 - 1 = 8|
|Tenth retry||3 ^ 10 - 1 = 59048|
The last retry is about 24.6 hours after first callback, 16.4 hours after the ninth callback.
Retry process only works on PRODUCTION environment. For SANDBOX, there is no retry even without gaining 200 code.
3.4 Sample Code
2013.08.20 Initial Release
2013.09.17 Add user_id to callback content