Payment System

SG Payment system incorporates third-party vendors billing system to help you implement in-app purchasing (IAP) function easier.

Development Setting

Please add following meta-data setting in AndroidManifest.xml before using IAP functions:

1
2
3
4
5
6
7
8
<application......>
    ......
    ......

    <meta-data android:name="SDKChannel" android:value="googleplay" />
    <meta-data android:name="Base64PublicKey" android:value="xxxxxxxxxxxxxxxxx" />

</application>

Pay

Function

void pay(SGPayRequest req)

Description
  • Launches third-party vendor IAP flow, and uploads order information to SG server.
  • Note on Google IAP: when using Google IAP, the pay function initializes (once) Google IAP service automatically. It also consumes the product automatically, after purchased successfully.
Parameters Response

Get Order

Function
void getOrder(String orderId, String gameKey, String openId, String sign)
Description
  • Obtain detailed order and receipt information of previous successful orders.
Parameters
gameKey Your developer identification.
openId SG member ID. You can obtain it through GetOpenID() after user login.
orderId Order ID you passed in when making the purchase.
sign Signature generated from above three parameters.
Please refer to signature algorithm.
Response

Consume Purchased Items

Function
void consumePurchasedItems()
Description
  • The function is only needed when you using Google IAP and encounter response code 1174 (purchase successful yet consume failed). It consumes all previous purchased but not consumed items.
  • The function is also called automatically in Activity onResume event.
Response