I am new to stripe and have decided to use stripe.net (https://github.com/jaymedavis/stripe.net).
What I want to do is put the customer on a plan that will charge them monthly. I also want to give them the option to cancel their subscription to the plan. Here is the code that the stripe.net project shows to use.
StripeConfiguration.SetApiKey("[your api key here]");
var myCustomer = new StripeCustomerCreateOptions();
// set these properties if it makes you happy
myCustomer.Email = "[email protected]";
myCustomer.Description = "Johnny Tenderloin ([email protected])";
// set these properties if using a card
myCustomer.CardNumber = "4242424242424242";
myCustomer.CardExpirationYear = "2012";
myCustomer.CardExpirationMonth = "10";
myCustomer.CardAddressCountry = "US";
myCustomer.PlanId = *planId*;
var customerService = new StripeCustomerService();
StripeCustomer stripeCustomer = customerService.Create(myCustomer);
Is this all I have to do to put the customer on a plan that charges them monthly? and to cancel the plan...
var customerService = new StripeCustomerService();
StripeSubscription subscription = customerService.CancelSubscription(*customerId*);
Is this all I have to do? There is also a section on the stripe.net page for creating a charge and I'm not sure if I have to do anything with that.
Yep, that's it. Were you expecting something more painful based on past experience? ;)
The Stripe API is designed to be really easy to use, and most of the available libraries (including Stripe.net) strive to maintain that.
You don't have to do anything with charges. If you need to bill a customer for some one-off thing, like a hat maybe, that's what a charge is for. Plans take care of themselves.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments