【问题标题】:PayPal authentication problem on azure "live store"天蓝色“实时商店”上的 PayPal 身份验证问题
【发布时间】:2021-05-11 09:05:41
【问题描述】:

我在尝试使用 paypal API 时收到以下错误

HttpStatusCode: Unauthorized; AUTHENTICATION_FAILURE; Authentication failed due to invalid authentication credentials or a missing Authorization header.

但问题仅在于我将代码发布到 Azure Api 时。如果我在 Visual Studio 上运行 Live Store,它就可以工作。

    public async Task<bool> InvoicingCreate(Models.ShopTransaction t)
    {
        sentJson = null;
        if (_accessToken == null) await GetAccessTokenAsync();

        HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "v2/invoicing/invoices");
        request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", _accessToken.access_token);

        bool addNotes;
        if (t.Product.TotalPrice == 0.0) addNotes = false;
        else if (t.PaymentMethod == null) addNotes = true;
        else if (t.PaymentMethod == "paypal" || t.PaymentMethod == "credit_card") addNotes = false;
        else addNotes = true;

        string billingEmail;
        if (t.Product.IndividualCouponId.HasValue)
        {
            billingEmail = _configuration["Shop:CouponInvoiceEmail"];
        }
        else
        {
            billingEmail = t.BillingAddress.Email;
        }
        var inv = new Root
        {
            detail = new Detail
            {

        .......details the items. ...
            },


        .......Fill the items. ...


        sentJson = JsonConvert.SerializeObject(inv, Formatting.None, new JsonSerializerSettings { DefaultValueHandling = DefaultValueHandling.Ignore });

        request.Content = new StringContent(JsonConvert.SerializeObject(inv), Encoding.UTF8, "application/json");

        HttpResponseMessage response = await _httpClient.SendAsync(request);

        string content = await response.Content.ReadAsStringAsync();

        if (response.StatusCode != System.Net.HttpStatusCode.Created)
        {
            Error error = JsonConvert.DeserializeObject<Error>(content);
            throw new Exception(CompactError("Invoicing-create", response.StatusCode, error));
        }
        CreateResponse invoiceCreated = JsonConvert.DeserializeObject<CreateResponse>(content);

        t.InvoiceId = invoiceCreated.href.Split('/').Last();

        return true;
    }

Auth methode

appsettings.json paypalmodel

开票方式

【问题讨论】:

  • 欢迎来到 Stack Overflow!请务必阅读How to Askedit 您的问题以提高其质量:不要永远更喜欢文本图像而不是实际文本——请使用包含你们两个文本的代码块截图! (请注意,您的“开票方法”也丢失了。)此外,如果您有比“它在本地工作时无法在生产中工作”更多的调试信息,请将其包含在问题中。谢谢!

标签: paypal invoice


【解决方案1】:

我发现了问题。 这是一个域问题。它已发送到贝宝服务器上的许多请求。如此经典的拒绝服务。

【讨论】:

    猜你喜欢
    • 2018-12-27
    • 1970-01-01
    • 2021-06-10
    • 1970-01-01
    • 2016-08-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-15
    相关资源
    最近更新 更多