Payment System

SGSDK can call Google, WeChat or Apple payment.

Payment Initialization Setting

1.Google Payment 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>

2.WeChat Payment

  • Just set PaymentChannel = "WeChat" you can call WeChat payment.

3.Apple Initialization Setting

Function

void IAPInit(string productsJSON)

Description
  • Call IAPInit before Pay.
Example
  • SGSDK.Instance.IAPInit ("[ConsumbleItem, NonConsumable, AutoSubscription, NonAutoSbuscriptions]");

Parameters
  • productsJSON is product serial number string array of iTunes Connect.
Response

Pay & Upload Order

Function

void Pay(SGPayRequest req)

Description
  • Launches third-party vendor IAP flow, and uploads order information to SG server.
  • Please refer to SGDemo for more detail SGPayRequest parameters setting.
  • Call Google payment SGPayRequest.PaymentChannel must be "GooglePay"。
  • Call WeChat payment SGPayRequest.PaymentChannel must be "WeChat"。
  • Call Apple payment SGPayRequest.PaymentChannel must be "AppStore"。
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
Parameters Description
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

Other Payment Function

1.Consume Order(Google Payment)

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.
Response

2.Restore Order (Apple Payment)

Function

void IAPRestore()

Description
  • When users switch to a new phone, you need to call this function to restore purchased for Non-Consumable and Auto-renewing subscription products.
Response