- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
注意:我正在为 Mac 开发,而不是 iOS!
- (void)recordTransaction:(SKPaymentTransaction *)transaction
{
if ([transaction.payment.productIdentifier isEqualToString:kInAppProIdentifier])
{
[[NSUserDefaults standardUserDefaults] setValue:transaction.transactionReceipt forKey:@"proUpgradeTransactionReceipt" ];
[[NSUserDefaults standardUserDefaults] synchronize];
}
}
我从编译器中收到此错误:
error: property 'transactionReceipt' not found on object of type 'SKPaymentTransaction *'; did you mean 'transactionDate'? [3]
此外,我在 reference for the SKPaymentTransaction
class 中找不到 transactionReceipt
属性! (尽管此页面包含一些对“收据”的引用,但没有 transactionReceipt 属性)。
但是the documentation说它应该存在!
A successful transaction includes a transactionIdentifier property and a transactionReceipt property that record the details of the processed payment. Your application is not required to do anything with this information. You may wish to record this information to establish an audit trail for the transaction. If your application uses a server to deliver content, the receipt can be sent to your server and validated by the App Store.
这有什么问题吗?
最佳答案
该属性是私有(private)的,并且在 OS X 上返回空字符串。
"On iOS, this is the value of the transaction's transactionReceipt property. On OS X, this is the entire contents of the receipt file inside the application bundle. Encode the receipt data using base64 encoding."
要获取收据,请使用:
[NSData dataWithContentsOfURL:[[NSBundle mainBundle] appStoreReceiptURL]]
适用于 iOS 和 OS X 的示例,用于获取收据并将其发送到服务器进行验证(使用针对 OS X 版本设置的宏):
NSData *tr ;
#ifdef OSX
tr = [NSData dataWithContentsOfURL:[[NSBundle mainBundle] appStoreReceiptURL]] ;
#else
tr = [transaction transactionReceipt];
#endif
NSString *jsonObjectString = [[self encode:(uint8_t *)[tr bytes] length:[tr length]] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString *completeString = [NSString stringWithFormat:@"https://ssl.myserver.com/verify.php?%@", jsonObjectString];
NSURL *urlForValidation = [NSURL URLWithString:completeString];
NSMutableURLRequest *validationRequest = [[NSMutableURLRequest alloc] initWithURL:urlForValidation];
[validationRequest setHTTPMethod:@"GET"];
NSData *responseData = [NSURLConnection sendSynchronousRequest:validationRequest returningResponse:nil error:nil];
验证时要小心,OS X 和 iOS 收据的 json 对象不同,因此您可能需要单独的服务器端代码进行验证。
更新:添加对发布收据进行编码的功能:
+ (NSString *)encode:(const uint8_t *)input length:(NSInteger)length {
static char table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
NSMutableData *data = [NSMutableData dataWithLength:((length + 2) / 3) * 4];
uint8_t *output = (uint8_t *)data.mutableBytes;
for (NSInteger i = 0; i < length; i += 3) {
NSInteger value = 0;
for (NSInteger j = i; j < (i + 3); j++) {
value <<= 8;
if (j < length) {
value |= (0xFF & input[j]);
}
}
NSInteger index = (i / 3) * 4;
output[index + 0] = table[(value >> 18) & 0x3F];
output[index + 1] = table[(value >> 12) & 0x3F];
output[index + 2] = (i + 1) < length ? table[(value >> 6) & 0x3F] : '=';
output[index + 3] = (i + 2) < length ? table[(value >> 0) & 0x3F] : '=';
}
return [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
}
关于macos - 交易收据属性 : can't find it anymore?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7980935/
注意:我正在为 Mac 开发,而不是 iOS! - (void)recordTransaction:(SKPaymentTransaction *)transaction { if ([tra
有人用this library吗?了? 去年对我来说效果很好,但现在我的代码无法编译: (在带有 GCC 4.6.1 的 MinGW 上): In file included from ../incl
此问题与之前的帖子相关,临时解决了问题:Caption text over an image . 我不得不将我的网站移动到脚本不再工作的新服务器上。目的是从我网站上的文件夹加载随机图像,并在图像上显示
我在我的 gradle 文件中有一个这样配置的共享测试文件夹: androidTest { java.srcDirs += "src/sharedTest/ja
我了解各种可能的移动开发平台。不过,我很想知道您能告诉我有关 Qualcomm BREW 的什么信息吗?为什么现在还有人关心它?我的意思是,有了 J2ME 的可移植性(中高级设备中对 J2ME 的兴趣
我用 yeoman 创建了一个角度应用程序,当我执行 grunt 命令时出现以下错误 Running "karma:unit" (karma) task WARN [config]: JASMINE
我正在写新闻并将其插入到我的数据库中,我在 3 年前构建了代码并且运行良好,但我不能再插入了,我不明白为什么: $insert=mysqli_query($co,"INSERT INTO articl
关闭。这个问题需要更多focused .它目前不接受答案。 想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 5 年前。 Improve this qu
我正在分享一张图片,此代码适用于 Android 6 之前的设备: Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.s
我添加了OmniFaces使用 CombinedResourceHandler 。但现在PrimeFaces Extensions 不再起作用了。 这个问题有解决办法吗? 最佳答案 不幸的是,这是一
好吧,在突然的怀旧情绪中,我将 Eclipse 工作场所从正在工作的 libgdx 项目切换到了较旧的项目。在查看了我的旧内容后,我在将其切换回来时遇到了一些问题,因为我没有正确导入它。在我开始工作后
但是应用程序没有编译。 我不知道该怎么办? 我正在尝试清理项目 我正在尝试构建项目 我正在重启 mac 等等,但这些步骤对我没有帮助。谁能帮我?谢谢 最佳答案 你可以像手动给颜色一样 "#ffffff
昨晚我遇到了注册问题,当使用 ajax 时,php 将空数据保存到我的数据库中,但在堆栈溢出的帮助下,问题得到了解决。我在 url 中发送数据,而不是使用 $_GET 我使用 $_POST,问题解决了
我作为前端工程师正在研究 XSS 预防。 根据 OWASP document ,应从用户输入中过滤以下代码。但是当我在我的 chrome 和 safari 浏览器中测试它时,它似乎不起作用。 BODY
我有 2 个类,我想返回对私有(private)成员对象的引用。 class BB{}; class B { std::unique_ptr b; public: const std::u
出于某种原因,这个网站的白色菜单项:www.danydiop.com 从一天到另一天在 Chrome 中消失了。 这怎么可能?是因为 Chrome 更新了吗? 谢谢 最佳答案 努力改变 #block-
之前,我们可以使用android提供的颜色: @android:color/white , @android:color/red 和 @android:color/yellow 等等。 但是,它们突然
从 VTK 迁移一些代码5.10 到 6.1,我有几个这样的代码片段: vtkSmartPointer img = vtkSmartPointer::New(); // ... initialize
所以我刚刚安装了 python 版本 3.11 并在 pycharm 中更改了我的 python 解释器,并且在我将软件包重新安装到我的新 venv 之后代码现在可以正常运行。 但是当我调试我的代码时
我正在处理一个非常简单的问题:在对 Sprite 应用 BevelFilter 之后,它似乎不再调度 MouseEvents。我曾尝试重新启用 buttonMode,但没有成功。我是否遗漏了一些非常基
我是一名优秀的程序员,十分优秀!