iOS PHP – 从Apple IAP中提取金额

栏目: PHP · 发布时间: 7年前

内容简介:翻译自:https://stackoverflow.com/questions/31135752/ios-php-extracting-sum-of-money-from-apple-iap

我正在开发一个使用Apple的应用程序内购买服务的iOS应用程序.

我还在开发一个 PHP

后端服务,在购买时,它会收到编码的收据字符串,使用Apple的验证服务器对其进行验证,并将购买记录保存在数据库中.

我想从服务器端知道产品的价格,或者用户实际为产品支付的金额.

我更喜欢用美元得到结果,但只要我有办法知道它是哪种货币(即货币符号作为字符串的一部分),任何货币都会很好,所以我可以转换它.

从验证返回的JSON对象不包含交易中已支付的金额或产品的价格.有没有办法从收据字符串中获取此信息?或者也许来自产品ID或交易ID(两者都可以从收据中提取)?或者这些信息是否必须由应用程序提供?

谢谢!!

据我所知,实际支付的金额不包括在收据中(密钥列于 here

).

但是,价格包含在SKProduct对象中,产品标识符在收据中可用,因此您可以在发送收据时将所有价格发送到服务器,并使用收据中的产品标识符来获取相应的价格.

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {

    NSMutableDictionary *prices = [NSMutableDictionary dictionary];
    for (SKProduct *product in [response products]) {

        NSString *productIdentifier = [product productIdentifier];
        NSDecimalNumber *price = [product price];
        NSLocale *priceLocale = [product priceLocale];

        prices[productIdentifier] = @[price, priceLocale];
    }

    // keep these in memory and send them with the receipt
}

翻译自:https://stackoverflow.com/questions/31135752/ios-php-extracting-sum-of-money-from-apple-iap


以上所述就是小编给大家介绍的《iOS PHP – 从Apple IAP中提取金额》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Machine Learning in Action

Machine Learning in Action

Peter Harrington / Manning Publications / 2012-4-19 / GBP 29.99

It's been said that data is the new "dirt"—the raw material from which and on which you build the structures of the modern world. And like dirt, data can seem like a limitless, undifferentiated mass. ......一起来看看 《Machine Learning in Action》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

html转js在线工具
html转js在线工具

html转js在线工具

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具