2015-10-06 48 views
2

我试图直接使用Stripe为客户收费。我使用此示例代码:Stripe.Net直接收费

var stripeChargeCreateOptions = new StripeChargeCreateOptions(); 

stripeChargeCreateOptions.Amount = 1000; 
stripeChargeCreateOptions.Currency = "usd"; 

stripeChargeCreateOptions.Description = "Test"; 

stripeChargeCreateOptions.Source = new StripeSourceOptions() 
{ 

    Number = "4242424242424242", 
    ExpirationYear = "2022", 
    ExpirationMonth = "10", 
    AddressCountry = "US",    // optional 
    AddressLine1 = "24 Beef Flank St", // optional 
    AddressLine2 = "Apt 24",    // optional 
    AddressCity = "Biggie Smalls",  // optional 
    AddressState = "NC",     // optional 
    AddressZip = "27617",     // optional 
    Name = "Joe Meatballs",    // optional 
    Cvc = "1223"       // optional 
}; 

stripeChargeCreateOptions.Capture = true; 

var stripeChargeService = new StripeChargeService(); 
StripeCharge stripeCharge = stripeChargeService.Create(stripeChargeCreateOptions); 

这似乎在测试模式下工作。这里是我的3个问题:

  1. 1000这里的金额是10美元 - 对吗?

  2. 这也可以使用活键吗?我听说Stripe不允许直接收费,并要求我们给他们的Javascript和存储令牌让我们实际收费?它如何在测试模式下工作?

  3. stripeChargeCreateOptions.Capture = true;的重要性如果将其设置为false会发生什么?

+0

这使得3个问题... :) –

+0

@Thomas:更新。谢谢! :) –

回答

0
  1. 是的,这是正确的。所有金额均以美分/分。

  2. 我不太了解Stripe以帮助你解决这个问题。

  3. 这告诉Stripe使用什么过程来执行交易 - 这是之前使用Capture属性设置为'false'创建的费用的后半部分。因此,您稍后需要调用API并将其设置为true以实际完成收费。查看API获取更多信息:https://stripe.com/docs/api?lang=php#capture_charge