在服务器上发送Apple收据时获取StatusCode:400,错误请求

时间:2020-01-24 08:36:04

标签: xamarin xamarin.ios in-app-purchase

您好,我在使用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());
        }

0 个答案:

没有答案
相关问题