supersdk

文档中心

文档中心

下载文档

Payment module


Preparation before integration

The game developer needs to read thepublic configuration,and prepare relevant configuration.

The game developer needs to complete the login module ,first and integrate all interfaces.

Before integrating the payment module, the game developer must integrate the Youzu server selection system first (please contact with operation and operation and maintenance colleagues).

Pay

Interface Description: Invoking this interface will open the payment interface of the channel.

Note 1: The following configuration is required before the joint debugging,then the game server can receive the notification of successful payment:

1. Operation and maintenance system configures the OpSid and the Ip or domain name of the game server.

2. Configure the template recharge callback address on the packaging tool.

Note 2: The game can’t rely on the callback of the payment to perform the game logic processing, such as the first recharge display, etc. (There is no callback of successful payment in some channels)

Interface invoke:


int         price           = 6;                    // 商品价格
NSString    *productId      = @"com.uuzu.zctx1";    // 商品Id
NSString    *productName    = @"钻石";               // 商品名称
NSString    *productDesc    = @"游戏道具";            // 商品描述
NSString    *pointRate      = @"10";                // 货币和游戏币比率
NSString    *pointName      = @"钻石";               // 游戏币单位
NSString    *orderTitle     = @"6元直冲";            // 订单标题
NSDictionary *parameters    = @{
                                    @"price"        : @(price).stringValue,
                                    @"productId"    : productId,
                                    @"productName"  : productName,
                                    @"productDesc"  : productDesc,
                                    @"pointRate"    : pointRate,
                                    @"pointName"    : pointName,
                                    @"orderTitle"   : orderTitle,
                                    };

[SuperSDK invoke:BCORE_MODULE_PLATFORM funcName:BCORE_FUNC_PAY parameters:parameters];

Interface callback:

- (void)handlerCallback:(NSString *)moduleName funcName:(NSString *)funcName result:(NSString *)result {
    
    // 处理SuperSDK回调逻辑,注意,所有模块回调都在这里。
    NSLog(@"****** 收到回调\n moduleName : %@,\n funcName : %@,\n result : %@", moduleName, funcName, result);
    
    
    // 1.回调参数解析
    NSDictionary *retParam = nil;
    if (result) {
        NSData *jsonData = [result dataUsingEncoding:NSUTF8StringEncoding];
        if (jsonData) {
            retParam = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableLeaves error:nil];
        }
    }
    
    int code            = [[retParam objectForKey:@"code"] intValue];   // 状态码
    NSString *msg       = [retParam objectForKey:@"msg"];               // 说明
    
    // 2.回调参数判断
    if ([moduleName isEqualToString:BCORE_MODULE_PLATFORM]) {// 平台模块回调
        
        if ([funcName isEqualToString:BCORE_FUNC_PAY_ORDER_ID]) {// 获取订单号成功回调
            NSString *orderId = [retParam objectForKey:@"data"];// 回调data数据
            NSLog(@"获取订单号成功,订单号为:%@", orderId);
        }
        else if ([funcName isEqualToString:BCORE_FUNC_PAY]) {// 支付回调,注意、部分渠道支付是不会有回调的
            NSLog(@"********支付结果回调********");
            if(code == BCORE_SUCCESS){
                NSLog(@"支付成功");
            }
            else {
                NSLog(@"支付失败,code=%d ,原因是 %@",code, msg);
            }
        }
    }
}

Callback log printing:

2017-07-04 15:26:33.276100+0800 Demo_Mubao[1219:351266] ****** 收到回调
 moduleName : platform,
 funcName : payOrderId,
 result : {
  "msg" : "获取订单号成功",
  "data" : "OS_ZXLX97IK1B98RDL8L",
  "code" : 1
}

2017-07-04 15:27:19.590996+0800 Demo_Mubao[1219:351266] ****** 收到回调
 moduleName : platform,
 funcName : pay,
 result : {
  "msg" : "支付成功",
  "code" : 1
}

Appendix

Constant string Actual string Description
BCORE_MODULE_PLATFORM platform Platform module
BCORE_FUNC_PAY pay Open the payment interface
BCORE_FUNC_PAY_ORDER_ID payOrderId Method of getting orderID callback
BCORE_KEY_PAY_ORDER_ID orderId Payment orderID key
BCORE_KEY_PRICE price top up amount
BCORE_KEY_PRODUCT_ID productId Product ID
BCORE_KEY_PRODUCT_NAME productName product name
BCORE_KEY_PRODUCT_DESC productDesc product description
BCORE_KEY_POINT_RATE pointRate The exchange rate of real money to game currency , such as 1:10, fill in 10
BCORE_KEY_POINT_NAME pointName Currency of the game, such as diamond
BCORE_KEY_ORDER_TITLE orderTitle Order title