我正在使用Stripe Checkout,并且想更新价格的UnitAmount。
但是,更新价格API不允许使用UnitPrice。这是Stripe的API文档中的代码:
StripeConfiguration.ApiKey = "{MY_API_KEY}";
var options = new PriceUpdateOptions
{
Metadata = new Dictionary<string, string>
{
{ "order_id", "6735" },
},
};
var service = new PriceService();
service.Update("gold", options);
这些是PriceUpdateOptions中的属性:
[JsonProperty("active")]
public bool? Active { get; set; }
[JsonProperty("lookup_key")]
public string LookupKey { get; set; }
[JsonProperty("metadata")]
public Dictionary<string, string> Metadata { get; set; }
public string Nickname { get; set; }
[JsonProperty("recurring")]
public PriceRecurringOptions Recurring { get; set; }
[JsonProperty("transfer_lookup_key")]
public bool? TransferLookupKey { get; set; }
查看属性,创建价格后,UnitAmount似乎不可编辑。
我想做类似的事情:
public void UpdateStripePrice(Product updatedProductResponse, ProductViewModel updatedProduct)
{
StripeConfiguration.ApiKey = "{MY_API_KEY}";
var options = new PriceUpdateOptions
{
Product = updatedProductResponse.Id,
UnitAmount = (long)updatedProduct.Price * 100,
};
var service = new PriceService();
service.Update(updatedProduct.StripePriceId, options);
}
我也找不到删除价格并通过重新创建价格“更新”的方法。