您好,我在使用xamarin表单的应用程序上应用了AppPurchase,并且我的应用程序在服务器(azure)上很好地发送了Google收据。
但是在发送Apple Receipt时收到StatusCode:400,BadRequest错误。
这是我的代码:
public async Task<PurchaseResult> PurchaseAsync(AppleReceipt receipt)
{
switch (Device.RuntimePlatform)
{
case Device.iOS:
devicePlatform = "ios";
break;
case Device.Android:
devicePlatform = "android";
break;
}
client.DefaultRequestHeaders.Add("deviceplatform", devicePlatform);
client.DefaultRequestHeaders.Add("serviceid", serviceId);
InitializeApiClientUser(true);
client.BaseAddress = new Uri($"{Constants.ApiUrl}purchaseapple{codePrefix}{Constants.ApiKey}");
var s = new JsonSerializerSettings { DateFormatHandling = DateFormatHandling.MicrosoftDateFormat };
HttpResponseMessage response = await client.PostAsJsonAsync(client.BaseAddress, receipt);
CocoSharpControlUI.DisplayAlert("RESPONSE", response.ToString());
client = new HttpClient();
return JsonConvert.DeserializeObject<PurchaseResult>(await response.Content.ReadAsStringAsync());
}