c# - 如何使用 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
都是上面提到的。如何更新图片中指定的其他字段?
解决方案
If you submit your changes on Stripe dashboard, you would see the following request body
{
"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"
]
}
}
So it maps to the request body shown in Stripe API doc.
The `CustomerUpdateOptions looks likes the following, refer to 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; }
}
}
So you would set the ShippingOptions
to update the address.line1
Hope it helps
推荐阅读
- c - 找不到 AVRDude 可执行文件。如果 AVRDude 的路径正确,请检查 AVR 首选项
- nsis - NSIS 取消包含错误内容的消息框
- css - Sass 在 Laravel Mix ^4.0.7 中将背景位置值编译为 100%
- apache-kafka - Spring Cloud Bus 事件( RemoteApplicationEvent )未发布到 Kafka
- python - 小部件未在 pyqt5 中显示标签
- python - 为什么我的列表只有一部分写入输出文件?(Python)
- google-apps-script - How can i deploy gmail addon to marketplace?
- css - I was unable to style the active route in React using react-router
- php - ACF: Why can't I display all the images at once?
- php - why the name capture group does not capture the same value?