stripe-payments Stripe.Net Introduction

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Syntax

  • var stripeSubscriptionOptions = new StripeSubscriptionCreateOptions();

    //create a variable to hold options object

            stripeSubscriptionOptions.Quantity = model.update;
    

    //example option of quantity of seats for a subscription

            var subscriptionService = new StripeSubscriptionService();
    

    //create a service to make the API call

            var stripeSubscription = subscriptionService.Create(user.CustomerIdentifier, planId,
    

    stripeSubscriptionOptions);

    // service.create( string CustID, string PlanID, Object SubscriptionOptions)

    //Customer ID should be saved from your database, you can retrieve planID from stripe using a PlanService and create the options object like above. If you NuGet the Stripe.Net intellisense works for these as well.

Remarks

Somewhere in the beginning of your controller you should call

StripeConfiguration.SetApiKey(YOUR SECRET KEY VAR);

and for data safety it should be a value hidden as a secret in appsettings

if you do not set the API key you will not be able to modify subscriptions or create customers



Got any stripe-payments Question?