3.Payment

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:

  • ctrl:Control 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:

  • appid:Appid of jump APP

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();

最后更新于