我能够成功创建一个令牌,然后创建一个新客户,将他们注册到特定的订阅计划中。
我无法弄清楚如何捕获 Stripe 为他们创建的 customer_id。我需要这个以便以后进行更改(更改计划、更新 CC 等)。我用于创建客户的代码如下(我使用阅读器获取 fname、lname 等,为简洁起见在此处排除):
private StripeCustomer CreateCustomer()
{
NameValueCollection nvc = Request.Form;
string tokenID = nvc["stripeToken"];
if (tokenID != null)
{
var tokenService = new StripeTokenService();
StripeToken stripeToken = tokenService.Get(tokenID);
}
var myCustomer = new StripeCustomerCreateOptions();
myCustomer.Email = email;
myCustomer.Description = fname + " " + lname + " (" + email + ")";
myCustomer.TokenId = tokenID;
string plan = "basic";
myCustomer.PlanId = plan;
var customerService = new StripeCustomerService();
StripeCustomer CurrentCustomer = customerService.Create(myCustomer);
}
也许我正在错误地考虑这个(必须是),但我最初是在寻找提供 CustomerID 的令牌。这是提供的内容:
id: tok_102znI2MdvjLMWitzgclEEcg
livemode: false
created: 1385241151
used: false
object: "token"
type: "card"
card:
id: card_102znI2MdvjLMWitq44B0MY7
object: "card"
last4: "4242"
type: "Visa"
exp_month: 12
exp_year: 2021
fingerprint: "V2WUOPIgMkP5DGGe"
customer: null
country: "US"
name: null
address_line1: null
address_line2: null
address_city: null
address_state: null
address_zip: null
address_country: null
在创建客户之前将令牌传回给我,因此这显然不起作用。