2

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 Answers1

0
  1. Yes, that's right. All amounts are in cents/pence.

  2. I don't know enough about Stripe to help you with this one I'm afraid.

  3. This tells Stripe what process to use to carry out the transaction - it's the second half of a charge previously created with the Capture property set to 'false'. So you would later need to call the API with it set to true to actually complete the charge. See the API for more information: https://stripe.com/docs/api?lang=php#capture_charge

pete the pagan-gerbil
  • 3,136
  • 2
  • 28
  • 49