Skip to content

Simple PG payment

Use simple PG payment when the app server looks up PG payment methods, the store web page directly builds the payment method selection UI, and then opens the PG provider's payment webview window with the method selected by the user.

This page explains how to call payment/methods and payment/requests in order.

The recommended implementation order is as follows.

  1. First, look up the payment methods and build the payment method selection screen on the store web page.
  2. Then, when the user clicks Pay, open the selected PG provider's payment webview window.

1. Overview

Integration flow

Simple PG payment handles the payment method selection step inside the store web page. Open the PG provider's payment webview window only after the user selects a payment method.

The following integration flow is recommended.

  1. On the store web page, the user clicks the Buy button.
  2. The app server calls the payment method lookup API.
  3. The store web page builds and displays the payment method selection UI using the response values.
  4. The user selects a payment method in the payment method selection UI and clicks Pay.
  5. The app server calls the payment request API.
  6. The store web page opens the selected PG provider's payment webview window using the response result.
  7. The user completes the payment in the PG provider's payment webview window.

Prerequisites

Prepare the following values before integrating simple PG payment.

Item Description
Hive authentication key This is the Bearer token included in the Authorization header. Use the value in Hive Console > App Center > Project Management > Game List - Select the app > Game Details > Basic Information.
app_id This is the App ID of the app for which the payment will be processed. Use the value in Hive Console > App Center > Project Management > Game List - Select the app > Game Details > Basic Information.
server_id This is the identifier of the app server that will process the payment. Use the value in Hive Console > App Center > Project Management > Game List - Select the app > Game Details > App Server.
market_pid This is the product ID to be paid for. Use the value registered in Hive Console > Billing > Product Management > Register Product. Set this value based on the Product ID prepared in each store console before registering the product.
player_id This is the Player ID of the current user making the payment. Use the value verified by the app server from the login session or app user information.
market_id This is the market ID used for simple PG payment. Use 15 as the fixed value.

2. Retrieve payment methods

The payment method lookup API retrieves the list of PG payment methods currently available for a specific product. Call it first before building the payment method selection screen inside the store web page. This API alone does not start the payment.

Request information

Endpoint

The endpoints are as follows.

Item Description
Production URL https://hiveiap.qpyou.cn/payment/methods
Sandbox URL https://sandbox-hiveiap.qpyou.cn/payment/methods
HTTP Method POST
Data Format JSON

HTTP header

The HTTP headers are as follows.

Item Description
Content-Type application/json;charset=utf-8
Authorization Bearer

The Bearer token included in the Authorization header is the Hive authentication key in Hive Console > App Center > Project Management > Game List - Select the app > Game Details > Basic Information.

Request body

In the following table, required fields are marked as M and optional fields are marked as O.

Name Type Required Description
language String M This is the game language value in which the payment methods will be displayed. Pass the language currently used by the app client in ISO 639-1 Alpha-2 format.
country String M This is the target country code for looking up payment methods. Pass the country of the user who will make the payment as a 2-letter ISO 3166-1 code.
app_id String M This is the App ID of the app for which the payment will be processed. Pass the value confirmed in Prerequisites.
market_pid String M This is the product ID to be paid for. Pass the value confirmed in Prerequisites.
market_id Integer O This is the market ID. Use 15 as the fixed value.
fixed_currency String O To display only a specific currency, enter the ISO 4217 currency code. If you do not fix the currency, use the data.currency value from the response in the next step.

Response information

In the following table, required fields are marked as M and optional fields are marked as O.

Name Type Required Description
result String M This is the API result string. If the response succeeds, use the payment method information in data in the next step.
code Integer M This is the API result code. Use it to distinguish success from failure and identify the cause of a failure.
message String M This is the API result message. Use it to identify the cause when a failure occurs.
data Object M This is the bundle of payment method information returned when the lookup succeeds.
data.agency_company_code Integer M This is the PG payment agency company code. After the user selects a payment method, pass it to agency_company_code in the payment request API.
data.country String M This is the country code applied to the lookup result. Use the same country code in the payment request API.
data.currency String M This is the payment currency applied to the lookup result. Pass this value to currency in the payment request API.
data.email_agree_text Array O This is the list of consent text to show to the user when the user selects a payment method that requires email input.
data.email_agree_text[].agree_id Integer O This is the consent text ID. Use it to distinguish consent items.
data.email_agree_text[].title String O This is the consent title shown to the user.
data.email_agree_text[].description String O This is the detailed consent text shown to the user.
data.available_payment_methods Array M This is the list of payment methods currently available for the product. Display only this list on the payment screen, and use the child fields of the item selected by the user in the next step.
data.available_payment_methods[].agency String M This is the PG provider code of the selected payment method. Pass it to agency in the payment request API.
data.available_payment_methods[].agency_id Integer M This is the PG provider identifier. Use it to distinguish payment methods or check internal logs.
data.available_payment_methods[].method String M This is the code of the selected payment method. Pass it to method in the payment request API.
data.available_payment_methods[].method_id Integer M This is the payment method identifier. Use it to distinguish payment methods.
data.available_payment_methods[].requires_email Boolean M If it is true, collect the user's email address before the payment request and pass it in the email field.
data.available_payment_methods[].priority Integer M This is the display priority value of the payment method. Use it to sort the payment screen.
data.available_payment_methods[].display_name String M This is the name of the payment method shown to the user on the payment screen.
data.available_payment_methods[].icon_url String O This is the URL of the payment method icon shown together on the payment screen.

Using the response values

Use the response values as follows.

  1. Use the display_name, icon_url, and priority values in data.available_payment_methods to build the payment method selection UI inside the store web page.
  2. When displaying a payment method whose requires_email is true, show the email_agree_text text as well and collect the user's email address.
  3. When the user selects a payment method, pass data.agency_company_code, data.currency, data.available_payment_methods[].agency, data.available_payment_methods[].method, and data.available_payment_methods[].requires_email unchanged as input values for the next step.

Request example

curl -L -v \
 -d '{
   "language": "ko",
   "country": "KR",
   "app_id": "com.com2us.hivesdk.normal.freefull.google.global.android.common",
   "market_pid": "com.com2us.hivesdk.normal.freefull.google.global.android.common.item01",
   "market_id": 15,
   "fixed_currency": "KRW"
 }' \
 -H "Content-Type: application/json;charset=utf-8" \
 -H "Authorization: Bearer {Bearer 토큰}" \
 https://sandbox-hiveiap.qpyou.cn/payment/methods

Response example

{
  "result": "success",
  "code": 0,
  "message": "success",
  "data": {
    "agency_company_code": 1,
    "country": "KR",
    "currency": "KRW",
    "email_agree_text": [
      {
        "agree_id": 1,
        "title": "(필수) 개인정보 수집∙이용 동의",
        "description": "Com2uS은(는) “결제 대행 업체 전송”을 위해 이메일주소를 수집합니다.<br>
내용을 자세히 읽으신 후 동의 여부를 결정해 주시기 바랍니다.<br><br>
- 수집∙이용 목적 : <span class=\"point_color\">결제 대행 업체 전송</span><br>
- 수집 항목 : 이메일주소<br>
- 보유∙이용 기간 : <span class=\"point_color\">결제 대행 업체 전송 목적으로만 수집하며 별도로 저장·보유하지 않습니다.</span><br><br>
※ 개인정보 수집∙이용에 대한 동의를 거부할 권리가 있습니다.<br>
단, 동의를 거부할 경우 해당 결제 대행 업체를 통한 결제가 제한됩니다."
      },
      {
        "agree_id": 2,
        "title": "(필수) 개인정보 제3자 제공 동의",
        "description": "Com2uS은(는) 다음과 같이 이메일주소를 제3자에게 제공하고 있습니다.<br>
내용을 자세히 읽으신 후 동의 여부를 결정해 주시기 바랍니다.<br><br>
- 제공받는 자 : <strong>결제 대행 업체 (PayPal, Terminal3)</strong><br>
- 이용 목적 : <span class=\"point_color\">부정/의심 거래 방지 및 고객 지원</span><br>
- 제공 항목 : 이메일주소<br>
- 보유∙이용 기간 : <span class=\"point_color\">가맹점과의 계약 종료 후 최대 5년</span><br><br>
※ 개인정보 제3자 제공에 대한 동의를 거부할 권리가 있습니다.<br>
단, 동의를 거부할 경우 해당 결제 대행 업체를 통한 결제가 제한됩니다."
      }
    ],
    "available_payment_methods": [
      {
          "agency": "html5_inicis",
          "agency_id": 9,
          "method": "card",
          "method_id": 1,
          "requires_email": false,
          "priority": 1,
          "display_name": "Credit Card",
          "icon_url": "https://hive-fn.qpyou.cn/hiveiap/hivestore/test/img/pg_icon/credit_card.png?ver=2.4.32"
      },
      {
          "agency": "html5_inicis",
          "agency_id": 9,
          "method": "naverpay",
          "method_id": 17,
          "requires_email": true,
          "priority": 10,
          "display_name": "NAVER Pay",
          "icon_url": "https://hive-fn.qpyou.cn/hiveiap/hivestore/test/img/pg_icon/5169459511710849342.png?ver=2.4.32"
      }
    ]
  }
}

3. Request payment

The payment request API opens the selected PG provider's payment webview window with the payment method that the user has already selected inside the store web page. You must reuse the values returned by the payment method lookup API.

Note the following.

  1. This API does not show the payment method selection screen again.
  2. This API itself does not finally confirm payment completion.

Request information

Endpoint

The endpoints are as follows.

Item Description
Production URL https://hiveiap.qpyou.cn/payment/requests
Sandbox URL https://sandbox-hiveiap.qpyou.cn/payment/requests
HTTP Method POST
Data Format JSON

HTTP header

The HTTP headers are as follows.

Item Description
Content-Type application/json;charset=utf-8
Authorization Bearer

The Bearer token included in the Authorization header is the Hive authentication key in Hive Console > App Center > Project Management > Game List - Select the app > Game Details > Basic Information.

Request body

In the following table, required fields are marked as M and optional fields are marked as O.

Name Type Required Description
language String M Pass the same game language value used in the payment method lookup API.
country String M Pass the same country code used in the payment method lookup API.
currency String M Pass the data.currency value from the payment method lookup API response.
app_id String M Pass the same App ID used in the payment method lookup API.
server_id String M Pass the server ID confirmed in Prerequisites.
market_id Integer M This is the market ID. As with the payment method lookup API, use 15 as the fixed value.
market_pid String M Pass the same product ID used in the payment method lookup API.
quantity Integer M This is the quantity to purchase in this payment request. Pass the quantity selected by the user in the game.
agency_company_code Integer M Pass the data.agency_company_code value from the payment method lookup API response.
method String M Pass the data.available_payment_methods[].method value of the payment method selected by the user.
agency String M Pass the data.available_payment_methods[].agency value of the payment method selected by the user.
player_id String M Pass the current user's Player ID confirmed in Prerequisites.
vid_type String M This is the SDK version value. Use v4 as the fixed value.
email String O If the selected payment method's requires_email value is true, pass the email address entered by the user.
sandbox Boolean O Use true when testing with the Sandbox URL. In a production environment, omit this field or use a value appropriate for the environment.

Response information

The payment request API is not an API that finally confirms whether the payment succeeded. If the request is processed successfully, use the returned result to open the selected PG provider's payment webview window.

Using the response values

Use the response values as follows.

  1. Use the response result to open the selected PG provider's payment webview window on the store web page.
  2. Do not determine that the payment is complete based only on this response. This step is for opening the payment window.
  3. To check the actual payment result, see Payment completion history inquiry and IAP v4 receipt verification.

Request example

curl -L -v \
 -d '{
   "language": "ko",
   "country": "KR",
   "currency": "KRW",
   "app_id": "com.com2us.hivesdk.windows.microsoftstore.global.normal",
   "server_id": "global",
   "market_id": 15,
   "market_pid": "com.com2us.hivesdk.windows.microsoftstore.global.normal.item01",
   "quantity": 1,
   "agency_company_code": 1,
   "method": "kakaopay",
   "agency": "html5_inicis",
   "player_id": "123456789",
   "vid_type": "v4",
   "email": "bobong@com2us.com",
   "sandbox": true
 }' \
 -H "Content-Type: application/json;charset=utf-8" \
 -H "Authorization: Bearer {Bearer 토큰}" \
 https://sandbox-hiveiap.qpyou.cn/payment/requests

4. Next steps

Do not grant the purchased item immediately in the app client just because the user completed the payment in the PG provider's payment webview window. Payment completion information is delivered from the PG provider to the Hive IAP v4 server, so the app server must perform follow-up verification.

Proceed with the follow-up processing in the following order.

  1. Call Payment completion history inquiry to retrieve the stored payment information.
  2. If additional validation is needed to confirm that the payment completed successfully, use purchase_bypass_info from the response to perform IAP v4 receipt verification.