Search code examples
c#asp.net-core.net-corestripe-payments

Stripe version 2 API?


I have downloaded the Stripe.net NuGet package for processing payments.

I've seen a number of places in the documentation that talk about an API v2, but if I use Visual Studio to show the source code using metadata, I see references to paths like "/v1/billing/meter_events". Obviously, I'm currently using version 1.

How does one use this library to access the version 2 API?


Solution

  • The API v2 will use a different path, and different namespaces in the SDK. See Stripe Doc. For example:

    StripeClient stripe = new StripeClient("{{YOUR__API_KEY}}");
    
    # Call a v2 API
    var event = stripe.V2.Core.Events.Retrieve("evt_123");
    
    # Call a v1 API
    var customer = stripe.V1.Customers.Retrieve("cus_123");
    

    Now specifically looking at the meter Event, again, on Stripe Doc about V2 Meter Event you have this line of code example, which indicates how to use V2 API:

    client.V2.Billing.MeterEventStream.Create(options);