AppStore 内购验证的方法

游客

标题:AppStore 内购验证的方法
正文:
AppStore增加了验证内购(In App Purchasement)的方法, 就是苹果提供一个url地址, 开发测试用:https://sandbox.itunes.apple.com/verifyReceipt产品用:https://buy.itunes.apple.com/verifyReceipt当购买成功时, 会得到苹果返回的一个收据(receipt), 苹果推荐的方法是将收据发给开发者的server, 由server像上述地址post http消息, 进行验证, 苹果将结果返回.到底是真正的购买还是虚假的购买.没有自己server的小伙伴可以用app进行发送, 代码如下.#define ITMS_SANDBOX_VERIFY_RECEIPT_URL @&quot;https://sandbox.itunes.apple.com/verifyReceipt&quot;#pragma mark - VerifyFinishedTransaction-(void)verifyFinishedTransaction:(SKPaymentTransaction *)transaction{ if(transaction.transactionState == SKPaymentTransactionStatePurchased){ NSString *transactionIdentifier = transaction.transactionIdentifier; NSData *transactionReceipt = transaction.transactionReceipt; //将transactionIdentifer和加密后的transactionReceipt数据发送给server端 NSString* receipent = [NSString stringWithFormat:@&quot;%s&quot;, transactionReceipt.bytes]; NSLog(@&quot;receipent = %@&quot;, receipent);
[<<][[1]][2][3][>>]

查看评论(0)
发表评论

首页