我正在使用Stripe API进行付款。我可以使用卡详细信息创建客户。 下次创建客户后,我需要更新以下内容 卡号 名称 电子邮件 国家 聚氯乙烯 经验月 每年
那么如何使用API(仅API)
var nvc = new List<KeyValuePair<string, string>>();
nvc.Add(new KeyValuePair<string, string>("card[number]", customerDetails.Number));
nvc.Add(new KeyValuePair<string, string>("card[exp_month]", Convert.ToString(customerDetails.ExpMonth)));
nvc.Add(new KeyValuePair<string, string>("card[exp_year]", Convert.ToString(customerDetails.ExpYear)));
nvc.Add(new KeyValuePair<string, string>("card[cvc]", customerDetails.Cvc));
nvc.Add(new KeyValuePair<string, string>("address_city", customerDetails.CityName));
nvc.Add(new KeyValuePair<string, string>("address_country", customerDetails.CountryName));
nvc.Add(new KeyValuePair<string, string>("address_line1", customerDetails.Addresss));
nvc.Add(new KeyValuePair<string, string>("address_state", customerDetails.StateName));
nvc.Add(new KeyValuePair<string, string>("address_zip", customerDetails.PostalCode));
nvc.Add(new KeyValuePair<string, string>("name", customerDetails.FirstName));
var req = new HttpRequestMessage(HttpMethod.Post,"https://api.stripe.com/v1/tokens") { Content = new FormUrlEncodedContent(nvc) };
JsonConvert.DeserializeObject<StripeCard>(_httpclient.SendAsync(req).Result.Content.ReadAsStringAsync().Result);
// Create Customer
nvc = new List<KeyValuePair<string, string>>();
nvc.Add(new KeyValuePair<string, string>("name]", customerDetails.FirstName));
nvc.Add(new KeyValuePair<string, string>("email", customerDetails.Email));
nvc.Add(new KeyValuePair<string, string>("description", "Createing for Nuvuew 360 Payment"));
nvc.Add(new KeyValuePair<string, string>("source", carddeatils.id));
nvc.Add(new KeyValuePair<string, string>("address[line1]", customerDetails.Addresss));
nvc.Add(new KeyValuePair<string, string>("address[state]", customerDetails.StateName));
nvc.Add(new KeyValuePair<string, string>("address[city]", customerDetails.CityName));
nvc.Add(new KeyValuePair<string, string>("address[country]", customerDetails.CountryName));
req = new HttpRequestMessage(HttpMethod.Post, "https://api.stripe.com/v1/customers") { Content = new FormUrlEncodedContent(nvc) };
JsonConvert.DeserializeObject<StripeCustomer>(_httpclient.SendAsync(req).Result.Content.ReadAsStringAsync().Result);