3.1 Set payment callback
Android
复制 PayNative.setPayResultCallback(new PayManager.PayCallback() {
@Override
public void onPayFinish(PayParams params) {
// TODO Auto-generated method stub
switch (params.getPayResult()){
//pay success
case PayDef.PAY_RESULT_SUCCESS:
break;
//pay fail
case PayDef.PAY_RESULT_FAIL:
break;
//cancel pay
case PayDef.PAY_RESULT_CANCEL:
break;
}
}
@Override
public void onInitPayAgentFinish(BasePayAgent arg0) {
// TODO Auto-generated method stub
}
});
Callback Method Description:
onPayFinish:Payment Result Callback
payParams:Payment related parameters (payment result, billing ID and other information can be obtained through this parameter)
onInitPayAgentFinish:Payment method initialized success
iOS
复制 [IOSLoader setPayResultCallback:^(NSDictionary *dic) {
if ([[dic objectForKey:@"reasonCode"] integerValue] == 1) {
//pay success
}
}];
3.2 Does the market support exit?(only Android)
Android(Necessary)
复制 PayNative.isExitGame();
Unity
复制 Wb.PayManager.Instance.IsSupportExit();
3.3 Get payment button type
Android
复制 PayNative.getButtonType(payID);
iOS
复制 [IOSLoader getButtonType];
Unity
复制 Wb.PayManager.Instance.GetButtonType(int payID);
3.4 Get the market type
Android
复制 PayNative.getMarketType();
iOS
复制 [IOSLoader getMarketType];
Unity
复制 Wb.PayManager.Instance.GetMarketType();
3.5 Get package control information
Android
复制 PayNative.getGiftCtrlFlagUse(int ctrl);
iOS
复制 [IOSLoader getGiftSwitch:ctrl];
Unity
复制 Wb.PayManager.Instance.GetGiftCtrlFlagUse(int ctrl)
parameter:
Return value:
Control parameter
Description of control parameters:
3.6 Call payment
Android
复制 PayNative.orderPay(id);
复制 orderPay(int id,String userdata);
复制 orderPay(int id,int price,String userdata);
复制 orderPay(int id, int price, int payType,String userdata);
If you want to use WeChat payment, you need to put feedata_wx.xml in the assets directory. If you want Alipay, you need to put feedata_alipay.xml
iOS
复制 [IOSLoader orderPay:id];
复制 [IOSLoader orderPay:id userData:@"userData"];
复制 [IOSLoader orderPay:id price:price userData:@"userData"];
复制 [IOSLoader orderPay:id price:price type:payType userData:@"userData"];
复制 //This method can be called directly. Payment callback is set by default.
[IOSLoader textPayWithProductId:id callBack:^(NSDictionary *dic) {
if ([dic[@"reasonCode"] integerValue] == 0) {
//pay success
}
}];
Unity
复制 Wb.PayManager.Instance.OrderPay(int id, Action<string, int> callFun);
复制 Wb.PayManager.Instance.OrderPay(int id, string userData, Action<string, int> callFun);
复制 Wb.PayManager.Instance.OrderPay(int id, int price, string userData, Action<string, int> callFun);
复制 Wb.PayManager.Instance.OrderPayWithType(int id, int price, int payType,string userData, Action<string, int> callFun)
example:
复制 Wb.PayManager.Instance.OrderPay(1, (result, id) =>
{
if (result.Equals("Paysuccess"))
{
ShowToast("pay success", false);
}
else if (result.Equals("Payfail"))
{
ShowToast("pay fail", true);
}
else if (result.Equals("Paycancel"))
{
ShowToast("cancel pay", false);
}
});
parameter:
id:Billing points defined in the gameid
price:The price of the billing point, in minutes.
payType:Payment type specified。eg:PayDef.PAY_TYPE_MM
userdata:User defined data
callFun:Payment callback(only Unity)
3.7 Repay props
iOS
复制 [IOSLoader payConsumableGoodsRecoveryCallBack:^(NSDictionary * dic) {
//Repay props
//call finish method
[IOSLoader payConsumableGoodsRecoveryFinish];
}];
3.7 Need more game buttons
Android
复制 PayNative.isMoreGame();
Unity
复制 Wb.PayManager.Instance.IsMoreGameBtn();
3.8 Open more games
Android
复制 PayNative.openMoreGame();
Unity
复制 Wb.PayManager.Instance.OpenMoreGame();
3.9 Jump to an app details page in the store
Android
复制 PayNative.openMarket(String package);
iOS
复制 [IOSLoader jumpSomeApp:appid];
parameter:
Unity
复制 Wb.PayManager.Instance.OpenMarket(string package);
parameter:
package:The name of APP package in Android platform and app ID in IOS platform
3.10 Jump to the store details page of the current app
Android
复制 PayNative.openAppraise();
iOS
复制 [IOSLoader openAppDetail];
Unity
复制 Wb.PayManager.Instance.OpenAppraise();