Integrate payment with Payhub web portal
User flow
Payhub document
Payhub is a payment system for games and apps.
User flow
Flow of user in Payhub
Developer
Variables
roleID :
In-game character id (character name)serverID:
In-game server id (server name)itemID:
ID (name) of game currency (gold, coin, KNB, month card, ...)API_key:
API key to identify game on Payhub systemAppota_User_ID:
Appota User ID when user logintransaction_id:
Transaction ID of the payment
Register app with Payhub
- Register your games (app) with Payhub to receive
APIKey
.APIKey
is used for transaction verification and games identify - For the games which is already on Appota Developer,
APIKey
and payment config will auto imported to Payhub - For new games, developer needs to config payment package price, type of item (gold, coin, month card, ...) and amount of item receive for each payment method.
API flow
Flow between developer API and Payhub API There are 4 API you need to implement : [1], [2] is optional , [3] and [4] is required, [4.1] is also a required step to call Payhub API to get and check transaction information.- [1] - List server API: Return list of server for the games. If you do not implement this API user will input
serverID
to charge. - [2] - Get
roleID
byserverID
andAppota User ID
API: If you games let user login byAppota User ID
, please implement this function to getroleID
fromserverID
andAppota User ID
. If you do not implement this API user will inputroleID
to charge. - [3] - Verify matching
roleID
andserverID
API. - [4] - Increase gold (coin, ...) API based on transaction information,
roleID
,serverID
,itemID
. (Remember to call Payhub API[4.1]
to get transaction information, then increase gold based on these information).
API detail
- Get list server
- Endpoint:
get_list_server
- Method:
GET
- Params:
- - `api_key`: String|Require
- - `appota_user_id`: Integer|Optional
- - `signature`: String|Require, md5(api_key + appota_user_id + secret_key)
- Result: String JSON
data
: Array of Objectserver_id
: Stringserver_name
: String
- Endpoint:
-
Get roleID:
- Endpoint: get_role_id
- Method: GET
- Params:
- - `api_key`: String|Require
- - `appota_user_id`: Integer|Require
- - `server_id`: String|Require
- - `signature`: String|Require, md5(api_key + appota_user_id + server_id + secret_key)
- Result: String JSON
data
: Array of Objectrole_id
: Stringrole_name
: String
-
Check roleID:
- Endpoint:
check_role_id
- Method:
GET
- Params:
- - `api_key`: String|Require
- - `server_id`: String|Require
- - `role_id`: String|Require
- - `signature`: String|Require, md5(api_key + role_id + server_id + secret_key)
- Result: String JSON of Object
error_code
: Int - Error code (0 - correct role_id, 1 wrong role_id, 2 other)messsage
: String - Message
- Endpoint:
-
Buy gold
- Endpoint:
buy_item
- Method:
GET
- Params:
- - `api_key`: String|Require
- - `item_id`: String|Require
- - `role_id`: String|Require
- - `server_id`: String|Require
- - `transaction_id`: String|Require
- - `signature`: String|Require, md5(api_key + item_id + role_id + server_id + transaction_id + secret_key)
- Result: String JSON of Object
error_code
: Int - (0. Transaction success, 1. Transaction fail)messsage
: String - Message
- Endpoint:
Note
Get transaction information from Payhub
[4.1]
- Endpoint:
http://api.appotapay.com/v1/services/check_transaction? api_key=XX&lang=YY
- Method:
POST
- Params:
transaction_id
: String- Response Data: JSON
error_code
: Integer (Transaction status: 0 - successful, 9 - failed or not exist)data
: Object (Transaction detail)data.transaction_id
: String (Transaction code)data.type
: String Transaction type:- SMS - SMS transaction
- CARD - Card transaction
- BANK - Internet Banking transaction
- EWALLET
- APPLE
data.amount
: Float (Amount of transaction)data.currency
: String (Currency - VND, USD, ...)data.country_code
: String (Country code - VN, US, ...)data.target
: String (Appota User’s identified information)data.state
: String (Value of string state used in SDK)data.time
: String (Transaction time)data.vendor
: String Transaction vendor can be:- data.type = CARD: vendor = appota / vtc / gate / bit
- data.type = BANK: vendor = onepay / vnpay / napas / gamota (bank_transfer) / megabank (epay) / viettel_pay / viettel_post / truemoney_atm / truemoney_visa / viettel_post_cod / vt_sms_9029
- data.type = EWALLET: vendor = appota / momo
- data.type = APPLE: vendor = empty
- data.type = GOOGLE: vendor = empty
data.data_signature
: String (Value of string state used in SDK)- Replace
API_KEY
with yourAPIKey
from Payhub system, API [4.1] is from Payhub, please study the image flow - Remember to store the Payhub
transaction_id
to prevent duplicated charging with sametransaction_id