Stripe.Net direct charge

时间:2015-10-06 09:02:17

标签: c# .net stripe-payments stripe.net

I am trying to directly charge the customer using Stripe. I am using this sample code:

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);

This seems to work in test mode. Here are my 3 questions:

  1. The amount 1000 here is 10 USD - right?

  2. Will this also work using live keys? I heard Stripe does not allow direct charge and requires us to their Javascript and store token for us to actually charge? How is it working in test mode?

  3. What is the importance of stripeChargeCreateOptions.Capture = true; What would happen if I set it to false?

1 个答案:

答案 0 :(得分:0)

  1. 是的,没错。所有金额均以美分/便士计算。

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

  3. 这告诉Stripe使用什么进程来执行事务 - 这是先前使用Capture属性设置为'false'创建的费用的后半部分。因此,您稍后需要调用API并将其设置为true以实际完成收费。有关详细信息,请参阅API:https://stripe.com/docs/api?lang=php#capture_charge