Appearance
支付相关
WARNING
使用母包测试渠道测试支付时,是模拟支付, 客户端无需实际付钱, 点击支付成功后, 聚合服务端会回调通知游戏服务器,给玩家发道具。
支付
当玩家点击游戏内商品充值项时,调用支付接口。 请在UI主线程中调用该接口。
objc
U8ProductInfo* productInfo = [[U8ProductInfo alloc] init];
productInfo.productName = @"礼包1";
productInfo.productDesc = @"礼包1";
productInfo.productId = @"libao1";
productInfo.price = [NSNumber numberWithInt:30];
productInfo.buyNum = 1;
productInfo.coinNum = 900;
productInfo.roleId = @"12345";
productInfo.roleName = @"角色";
productInfo.roleLevel = @"66";
productInfo.serverId = @"1";
productInfo.serverName = @"桃源";
productInfo.vip = @"1";
productInfo.cpOrderId = @"2323";
productInfo.extension= @"1111";
productInfo.notifyUrl = @"http://110.54.33.45/game/pay/notify";
[[U8SDK sharedInstance] pay:productInfo];
PayParams对象的结构说明如下:
参数名称 | 参数类型 | 参数说明 |
---|---|---|
productId | String | 充值商品ID,游戏内的商品ID, |
productName | String | 商品名称,比如100元宝,500钻石等, |
productDesc | String | 商品描述,比如 充值100元宝,赠送20元宝, |
price | int | 充值金额(单位:元), |
buyNum | int | 购买数量,固定为1 |
coinNum | int | 玩家当前身上剩余的游戏币,默认0 |
serverId | String | 玩家所在服务器的ID, |
serverName | String | 玩家所在服务器的名称, |
roleId | String | 玩家角色ID, |
roleName | String | 玩家角色名称, |
roleLevel | String | 玩家角色等级, |
vip | String | 玩家vip等级 |
notifyUrl | String | 玩家支付成功,U8聚合SDK会优先通过该地址,通知游戏服务器,给玩家发货。 如果该地址没设置, 会使用后台配置的地址 |
cpOrderId | String | 游戏自己的订单号,最大长度64字符;支付成功之后,U8聚合SDK原样返回给游戏服务器 |
extension | String | 自定义数据,最大长度:64字符;支付成功之后,U8聚合SDK原样返回给游戏服务器 |
处理支付回调事件
当渠道SDK支付成功或失败时, 聚合SDK会通过初始化时设置的U8SDKDelegate->OnEventWithCode
,通知给游戏层:
objc
-(void) OnEventWithCode:(int)code msg:(NSString*)msg
{
switch (code){
case U8_CODE_PAY_SUCCESS:
// 渠道SDK支付成功
break;
case U8_CODE_PAY_FAILED:
// 渠道SDK支付失败
break;
}
}
处理服务端发货通知
玩家在客户端支付成功后, 各个渠道平台都会通知给U8聚合SDK服务端。 接着, U8聚合SDK服务端会按统一的协议通知给游戏服务器。
游戏服务器需要实现服务端->支付回调通知协议,用来接收U8聚合SDK的发货通知请求。
收到请求并验证通过后, 才能给玩家发放道具。