gpt4 book ai didi

ios - Apple IAP 收据验证返回代码 21002

转载 作者:行者123 更新时间:2023-12-01 20:14:21 24 4
gpt4 key购买 nike

我尝试提交到沙箱(和实时)verifyReceipt 端点,但我总是从 Apple 收到以下 JSON 响应...

{"status":21002, "exception":"java.lang.IllegalArgumentException"}

这是 postman 屏幕截图

Postman testing

我正在发布数据并设置 header (application/json)

{"receipt-data":"MIIVbwYJKoZIhvcNAQcCoIIVYDCCFVwCAQExCzAJBgUrDgMCGgUAMIIFEAYJKoZIhvcNAQcBoIIFAQSCBP0xggT5MAoCAQgCAQEEAhYAMAoCARQCAQEEAgwAMAsCAQECAQEEAwIBADALAgELAgEBBAMCAQAwCwIBDgIBAQQDAgFSMAsCAQ8CAQEEAwIBADALAgEQAgEBBAMCAQAwCwIBGQIBAQQDAgEDMAwCAQoCAQEEBBYCNCswDQIBDQIBAQQFAgMBh2gwDQIBEwIBAQQFDAMxLjAwDgIBCQIBAQQGAgRQMjQ3MBACAQMCAQEECAwGMS4wLjI1MBgCAQQCAQIEEF/oX9LMmvqyAj2stAJzCkwGwIBAAIBAQQTDBFQcm9kdWN0aW9uU2FuZGJveDAcAgEFAgEBBBSdVfsFONtpXYexzWJbbskLrjqDAeAgEMAgEBBBYWFDIwMTctMDItMDVUMjM6MzA6NDBaMB4CARICAQEEFhYUMjAxMy0wOC0wMVQwNzowMDowMFowKgIBAgIBAQQiDCBjb20uZ2V0dmVoaWNsZXNtYXJ0LnZlaGljbGVzbWFydDBKAgEGAgEBBELMHlpKMWF8kHtwHgdygKIhevAiUBra8O/S/LJ2nDoFaLvE2AHWybr72qz2jfS7RtCZJI4yG5IIfxyeeeaWDb9K6BEwSgIBBwIBAQRCtZDfwHj0puyfpvVzRhVGUVvZn0ISOO45j7YowXVk24fFqwGD4ZGe/wuJRhfOoYyWw916pTdzRvC7RC9SUNDHriG4MIIBbQIBEQIBAQSCAWMxggFfMAsCAgasAgEBBAIWADALAgIGrQIBAQQCDAAwCwICBrACAQEEAhYAM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这是通过 TestFlight 内部测试部署从 iOS 设备上运行的应用程序执行的。

我有点不确定 Base64 字符串是否格式不正确或者其他什么 - 它确实有一些空格,但我现在删除了这些空格(因为我看到报告说它有帮助)。

这是我在移动应用程序中捕获 Base 64 编码的方法,请注意这是 Xamarin 代码 (C#),但它与您在 Objective-C/swift 中所做的操作非常接近......

String purchaseToken = null;
NSUrl receiptUrl = NSBundle.MainBundle.AppStoreReceiptUrl;
NSData receipt = null;

if (receiptUrl != null) {
receipt = NSData.FromUrl (receiptUrl);
}

if (receipt == null) {
// No local receipt -- handle the error
// https://forums.xamarin.com/discussion/25304/how-do-i-exit-with-reason
Environment.Exit (173);
} else {
// http://stackoverflow.com/questions/37505020/example-of-parsing-a-receipt-for-an-in-app-purchase-using-ios-xamarin
NSDictionary requestContents = NSDictionary.FromObjectAndKey ((NSString)receipt.GetBase64EncodedString (
NSDataBase64EncodingOptions.None),
(NSString)"receipt-data");
string receiptData = (requestContents ["receipt-data"] as NSString).ToString ();

purchaseToken = receiptData;
}

this.iapConsumableEvent.PurchaseToken = purchaseToken;

服务器代码(Java)使用 HttpClient 将其传输到 Apple...

HttpClient client = HttpClientHelper.createHttpClient(new DefaultRedirectStrategy());
final HttpPost postRequest = new HttpPost(appleEnvironmentUrl);
StringEntity input = new StringEntity(receiptRequestJson);
input.setContentType("application/json");
postRequest.setEntity(input);
HttpResponse response = client.execute(postRequest);

String rawResponse = EntityUtils.toString(response.getEntity(), "UTF-8");
BasicDBObject appleJson = BasicDBObject.parse(rawResponse);

int statusCode = appleJson.getInt("status", 99999);

//ALWAYS RETURNING 21002 The data in the receipt-data property was malformed or missing.

我很感激任何想法/答案!

最佳答案

我在尝试通过 postman 让它工作时遇到了问题。

这在 Node.js 中对我有用。在它起作用之前我必须先进行 JSON.stringify :

function createReceiptRequestJSON(base64String, secret) {
return JSON.stringify({
"receipt-data":base64String,
password:secret
});
}

您可以通过 itunes connect 找到您的 secret ,但我相当确定您需要将其包含在请求中。

编辑:

再和 postman 一起看看。从这个答案得到收据 Apple receipt_data sample .

enter image description here

似乎有效...

关于ios - Apple IAP 收据验证返回代码 21002,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42058686/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com