本文介绍了应用内购买验证 - 根据用户验证购买的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已在我的应用程序中成功实施了应用程序内购买。

I had successfully implemented in-app purchase in my application.

我的查询是:

那里是一个苹果ID xyz@apple.com ,我通过它登录到ipad或设备中的iTunes。
现在在我的应用程序中有多个用户。他们将通过应用内购买购买产品。我的产品是非消耗品。
现在,例如,有两个用户A和B(他们登录到我的应用程序,因此他们是应用程序用户)。

There is One apple id xyz@apple.com through which i am logged in to itunes in ipad or device.now in my application there are several users. They will purchase products through in-app purchase. my product is non-consumable.Now, for example there are two user A and B (they logged in to my application so they are application users).

案例:用户使用带有苹果ID xyz@apple.com的应用内购买的购买产品,并获得所购买产品成员的用户权限(此处成功完成付款我打电话给Web服务以使用户数据库更新他/她已购买产品并从我的应用程序注销。现在用户B登录到我的应用程序并购买产品以及购买的用户A(此处请注意,苹果ID与xyz@apple.com相同)。但是当他试图购买产品苹果说你已经购买了这个。点击确定再次免费下载所以用户点击确定,这个产品将再次按用户恢复,并再次成功的那种方法,我称之为网络使用户数据库更新的服务。

所以问题是我如何在购买此ID的产品时区别对待用户(即xyz.apple .com)你已经购买了,现在用户应该是不同的,那么你必须使用另一个苹果ID登录(可能是abc.apple.com)。

推荐答案

最后我通过以下解决方案解决了app购买问题:

finally i solved in app purchase issue with the following solution :

1)我获得了交易ID并用数据库更新根据用户,如果事务ID发现重复,那么它将抛出错误并且不会使用户成为付费会员。

1) i get transaction id and update it with the database as per user if transaction id founds duplicate then it will throw error and don’t make user as a paid member.

意味着当用户进行购买然后我得到它的transaction_id并将其更新为数据库,用户名:A和t ransaction_id:XYZ。
如果B用户要从相同的iTunes id购买,那么我将获得与XYZ相同的transaction_id。所以这里不允许用户继续(即从Web服务不允许用户成为付费会员并给出错误)。以下是代码:

Means when A user make purchase then i get it's transaction_id and update it to data base as Username : A and transaction_id : XYZ.and if B user going to purchase from same iTunes id then i will get same transaction_id that is XYZ. So here it will not allow user to be proceed(i.e. from web service don't let user to be paid member and give error). following is code:

-(void)callinApp : (SKPaymentTransaction*) transaction
{
    if (transaction.originalTransaction.transactionIdentifier == nil)
    {
        // send transection.transactionIdentifire
        // means it's first time purchasing
        NSLog(@"Transection Id : %@",transaction.transactionIdentifier);
        UserId = A123;
        TransectionID = transaction.transactionIdentifier;
    }
    else
    {
        // send transaction.originaltransection.transectionidentifier
        // means already purchased one in past
        NSLog(@"Original Transection Id:%@",transaction.originalTransaction.transactionIdentifier);
        UserId = A123;
        TransectionID = transaction.originalTransaction.transactionIdentifier;
    }
   // call web service and pass TransectionID & UserId
}

2)从另一个iTunes id进行交易时出现的错误调用多次的方法(updateTransaction)我通过从iTunes连接中的沙箱测试器中删除那个苹果(iTunes)ID来解决这个问题。

2) The error which was coming while doing transaction from another iTunes id the method (updateTransaction) calling multiple time i solved that by removing that apple(iTunes) id from sandbox tester in iTunes connect.

这篇关于应用内购买验证 - 根据用户验证购买的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-17 09:25
查看更多