iOS SDK_支付功能
可使用应用内购买所需的支付功能。支付结果值以Delegate形式实现。
AppDelegate设置
为使用支付功能设置AppDelegate时,请使用下列代码。
#import <GamePot/GamePot.h>
@interface ViewController () <GamePotPurchaseDelegate>
@end
@implementation ViewController
- (void)viewDidLoad
{
...
[[GamePot getInstance] setPurchaseDelegate:self];
...
}
- (void)GamePotPurchaseSuccess:(GamePotPurchaseInfo *)_info
{
// 付款成功
}
- (void)GamePotPurchaseFail:(NSError *)_error
{
// 支付错误。请在游戏弹窗显示失败原因相关消息。
// 消息语句请使用[error localizedDescription]。
}
- (void)GamePotPurchaseCancel
{
// 启动付款过程中取消
// 在游戏弹窗显示“已取消支付。”消息。
}
@end
支付尝试功能
如要使用支付尝试功能,请使用下列代码。
尝试一般支付
#import <GamePot/GamePot.h> // productid:输入商店中注册的商品ID [[GamePot getInstance] purchase:productid];
单独管理支付尝试及发票号
#import <GamePot/GamePot.h> // productId:输入商店中注册的商品ID // uniqueId:输入单独管理的发票号 [[GamePot getInstance] purchase:productid uniqueId:uniqueid];
单独管理支付尝试、发票号,将角色信息传递到Webhook
#import <GamePot/GamePot.h> // productId:商店中添加的商品ID // uniqueId:单独管理的发票号 // serverId:付费角色的服务器ID // playerId:付费角色的角色ID // etc : 付费角色的其他信息 [[GamePot getInstance] purchase:productid uniqueId:uniqueid serverId:serverid playerId:playerid etc:etc]];
获取付费道具列表功能
如要使用获取由商店传递的应用内付费道具列表功能,请使用下列代码。
[case1]
NSArray<SKProduct*>* itemList = [[GamePot getInstance] getDetails];
// 读取根据设备的货币设置标注的价格时
[[GamePot getInstance] getLocalizePrice:[product productIdentifier]];
[case2]
[[GamePot getInstance] getPurchaseItemsJsonString];
[case3]
@try{
[[GamePot getInstance] getPurchaseDetailListAsyncToJSON:^(BOOL _success, NSString *_items, NSError *_error)
{
if(_success)
{
if(_items)
{
// In-app information
}
}else
{
if(_error){
// NSLog(@"Error = %@", [_error localizedDescription]);
}
}
}];
}
@catch(NSException* ex){
NSLog(@"Error : %@", ex);
}
发放付费道具的功能
可设置为与支付商店的发票明细进行对照并完成所有验证后向开发商服务器传递发放请求。
详细说明请参考道具发放请求。
Last updated