【发布时间】:2023-03-30 16:15:01
【问题描述】:
我正在尝试使用收费命令通过 restsharp 使用 stripe.com api
https://stripe.com/docs/api/php#create_charge
有机会将元数据作为键值对传递,但我似乎没有成功
const string baseUrl = "https://api.stripe.com/";
const string endPoint = "v1/charges";
var apiKey = this.SecretKey;
var client = new RestClient(baseUrl) { Authenticator = new HttpBasicAuthenticator(apiKey, "") };
var request = new RestRequest(endPoint, Method.POST);
request.AddParameter("card", token);
request.AddParameter("amount", wc.totalToPayForStripe);
request.AddParameter("currency", "eur");
request.AddParameter("description", wc.crt.cartid + " - " + wc.co.oid);
request.AddParameter("metadata", "{cartid: " + wc.crt.cartid + ", oid: " + wc.co.oid + "}");
request.AddParameter("statement_description", "# " + wc.crt.cartid);
request.AddParameter("description", wc.crt.cartid + " - " + wc.co.oid);
总是出现以下错误:
Invalid metadata: metadata must be a set of key-value pairs
显然我没有按我应该的方式传递键值对,但我找不到任何关于它的 restsharp 文档。
有人可以帮忙吗?
【问题讨论】:
标签: c# stripe-payments restsharp