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 system
  • Appota_User_ID: Appota User ID when user login
  • transaction_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. [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. [2] - Get roleID by serverID and Appota User ID API: If you games let user login by Appota User ID, please implement this function to get roleID from serverID and Appota User ID. If you do not implement this API user will input roleID to charge.
  3. [3] - Verify matching roleID and serverID API.
  4. [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

  1. 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 Object
      • server_id: String
      • server_name: String
  2. 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 Object
      • role_id: String
      • role_name: String
  3. 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
  4. 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

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
        • GOOGLE
      • 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
        This information can be used to alter gold rate for each vendor
      • data.data_signature: String (Value of string state used in SDK)
  • Replace API_KEY with your APIKey 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 same transaction_id