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. |
1. Description
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
POST
Callback Content
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
Sample:
3.2 Handle Mobage Http Request
Validation
Validation can be confirmed by IP and SIGN.
IP Source:
Platform | IP |
---|---|
Mobage Simplified Chinese Platform | 119.15.138.0/24(119.15.138.0~119.15.138.255) |
Mobage Traditional Chinese Platform | 27.131.9.0/24 (27.131.9.0~27.131.9.255) |
Sign validation:
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
PHP
Java
Hisotry
2013.08.20 Initial Release
2013.09.17 Add user_id to callback content