[英]How Update customer invoice details using stripe api
我要更新客戶發票明細,詳細信息如下圖所示
我已經研究過,文檔說使用此代碼更新了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
中擁有的所有屬性均如上所述。 如何更新圖片中指定的其他字段?
如果您在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
希望能幫助到你
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.