Как обновить детали счета клиента, используя полосу API - PullRequest
0 голосов
/ 31 января 2019

Я хочу обновить детали счета клиента, детали, которые показаны на рисунке ниже

enter image description here

Я исследовал, и в документации написано использованиеэтот код обновляет ivoice

StripeConfiguration.SetApiKey("sk_test_hi3LvqzVUrxrlBwqdFukAK4Q");

var options = new CustomerUpdateOptions {
  Description = "Customer for jenny.rosen@example.com"
};

var service = new CustomerService();
Customer customer = service.Update("cus_EQL4cC8XJAO4YJ", options);

Этот код работает нормально, но когда я пытаюсь использовать CustomerUpdateOptions для обновления, например Address Line 1 Я не могу найти это свойство в этом классе

    [JsonProperty("account_balance")]
    public int? AccountBalance { get; set; }
    [JsonProperty("business_vat_id")]
    public string BusinessVatId { get; set; }
    [JsonProperty("source")]
    public string SourceToken { get; set; }
    [JsonProperty("source")]
    public SourceCard SourceCard { get; set; }
    [JsonProperty("coupon")]
    public string Coupon { get; set; }
    [JsonProperty("default_source")]
    public string DefaultSource { get; set; }
    [JsonProperty("description")]
    public string Description { get; set; }
    [JsonProperty("email")]
    public string Email { get; set; }
    [JsonProperty("metadata")]
    public Dictionary<string, string> Metadata { get; set; }

Все свойства, которые у меня есть в CustomerUpdateOptions, являются вышеупомянутыми.Как обновить другие поля, указанные на картинке?

1 Ответ

0 голосов
/ 31 января 2019

Если вы отправите свои изменения на информационной панели Stripe, вы увидите следующее тело запроса

{
  "account_balance": "0",
  "description": "Customer for Testing",
  "invoice_prefix": "KarenPrefix",
  "shipping": {
    "phone": "+12016262852",
    "name": "",
    "address": {
      "line1": "",
      "line2": "",
      "city": "",
      "state": "",
      "postal_code": "",
      "country": ""
    }
  },
  "tax_info": {
    "tax_id": "",
    "type": "vat"
  },
  "invoicing": {
    "email_to": [
      "test@test.com"
    ],
    "email_cc": [
      "test2@test.com"
    ]
  }
}

, поэтому оно сопоставляется с телом запроса, показанным в Stripe API doc .

CustomerUpdateOptions выглядит следующим образом, см. doc

namespace Stripe
{
    using System;
    using System.Collections.Generic;
    using Newtonsoft.Json;

    public class CustomerUpdateOptions : BaseOptions
    {
        [JsonProperty("account_balance")]
        public long? AccountBalance { get; set; }

        [JsonProperty("coupon")]
        public string Coupon { get; set; }

        [JsonProperty("default_source")]
        public string DefaultSource { get; set; }

        [JsonProperty("description")]
        public string Description { get; set; }

        [JsonProperty("email")]
        public string Email { get; set; }

        [JsonProperty("invoice_prefix")]
        public string InvoicePrefix { get; set; }

        [JsonProperty("metadata")]
        public Dictionary<string, string> Metadata { get; set; }

        [JsonProperty("shipping")]
        public ShippingOptions Shipping { get; set; }

        [JsonProperty("source")]
        public string SourceToken { get; set; }

        [JsonProperty("source")]
        public CardCreateNestedOptions SourceCard { get; set; }

        [JsonProperty("tax_info")]
        public CustomerTaxInfoOptions TaxInfo { get; set; }

        [JsonProperty("validate")]
        public bool? Validate { get; set; }
    }
} 

Таким образом, вы должны установить ShippingOptions для обновления address.line1

Надеюсь, это поможет

...