Payment Gateway Game Studio Guides - gtoken/sdk-download GitHub Wiki

This article helps game studio easily to set up API credentials and deeply understand the response body from GToken Payment Gateway (GPG) callback after payment is processed completely.

##I. API credentials##

Regardless of how you connect your website or mobile application to GPG, at minimum you will be required to provide these values to process payments:

  • API Key: client-specific public identifier

  • API Secret: client-specific secure identifier that should not be shared - even with us!

  • Scope: specify which group of APIs client can access including

     + payment: being accessible for creating payment, checking out order
    
     + ipay: being accessible for Ipay callback
    
     + verify: being accessible for getting payment status, getting payment callback log 
    

Notes: You can choose multiple scopes in one API credential.

You can locate these values by following these steps:

  1. Log into admin dashboard

  2. Navigate to API Key

  3. Choose one of Studio Name and click Add key button

  4. You will be redirected to new page to choose Scopes and click Create button

  5. The pop-up will be showed the API Key and API Secret, please save it secretly somewhere and click OK

Congratulations!!! You owned your first API credentials.

##II. Payment Gateway Callback##

First of all, you need to setup your payment callback URL by following these steps

  1. Log into admin dashboard

  2. Navigate to Studios then find and edit your studio.

  3. Enter your payment callback endpoint in the input next to Payment Callback URL (POST method) and click Update button

Once user did the payment successfully, GPG will send a request to your defined endpoint (above steps) by POST method. The request body contains the following keys and values:

Key Value Note
payment_response
payment_id the identifier of payment
amount total money user pays for items
total_token total token user pays for items
token token currency PTK or GTK
currency currency that user pays for items
status payment status * completed_ok: success to execute payment and callback to game studio, completed_error: failed to callback to game studio
private_info the customized information used by game studio to transfer information
created_date The payment created date in Unix timespan format
short_description The payment's description
gameitem_responses
transaction_id The identifier of transaction
game_id The identifier of game in GToken system
amount The money user pays for this transaction
amount_token The token user pays for this transaction
item_name The item's name
created_date The transaction's time span
item_id The identifier of item in GToken system
exchange_option_identifier The identifier of item in game studio system
success the request's status
error_code the error code
message the error message

Json Format:

{
  "payment_response": {
    "short_description": "TEST_0710",
    "total_amount": 1,
    "total_token" : 1,
    "token" : "PTK",
    "currency": "USD",
    "payment_id": "f757e272-07a8-4fe4-8fd8-82284c2227d8",
    "created_date": 1480321150.8414428,
    "status": "completed_ok",
    "private_info": "secret is secret"
  },
  "gameitem_responses": [
    {
      "transaction_id": 3329,
      "game_id": "808a4391-4d66-4293-9d2d-06f30d0c5417",
      "amount": 1,
      "amount_token" : 1,
      "item_name": "MGT0710",
      "created_date": 1480321150.8414428,
      "item_id": 409904333,
      "exchange_option_identifier": "TEST TEST"
    }
  ],
  "success": true,
  "error_code": "",
  "message": ""
}

In term of completed_error status, you can go to admin dashboard and navigate to Studios. After finding your studio then click View callback logs.

##III. APIs ##

1. Get payment status for studio

_ URL: /api/v1/payments/get-payment-status-for-studio

_ Scope: server-verify

-Request object

Key Value Note
payment_id the identifier of payment

_ Response object

Same to II. Payment Gateway Callback