Skip to content

Commit d442519

Browse files
ramya-stripestripe-openapi[bot]xavdid-stripejar-stripeprathmesh-stripe
authored
Beta SDK updates between Open API versions 1473 and 1505 (#3062)
* Update generated code for v1473 * Update generated code for v1479 * Update generated code for v1481 * Update generated code for v1483 * Update generated code for v1486 * Update generated code for v1487 * add codeowners file (#3055) * Merge upstream and update generated code for v1490 * Update generated code for v1495 * Update generated code for v1496 * Improved examples (#3054) * changed Program to accept a command line argument with the name (relative to Examples namespace) of the example to run * updated existing examples * added usage instructions * added just recipe * Merge upstream and update generated code for v1501 * Update generated code for v1501 * Update generated code for v1502 * Update generated code for v1504 * Update generated code for v1505 * Update generated code for v1505 * Update generated code (#3050) * Update generated code for v1463 * Update generated code for v1494 * Update generated code for v1495 * Update generated code for v1501 * Update generated code for v1505 --------- Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com> Co-authored-by: prathmesh-stripe <[email protected]> * Bump version to 47.4.0 --------- Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com> Co-authored-by: David Brownman <[email protected]> Co-authored-by: jar-stripe <[email protected]> Co-authored-by: prathmesh-stripe <[email protected]> Co-authored-by: Prathmesh Ranaut <[email protected]>
1 parent 60c1349 commit d442519

File tree

52 files changed

+574
-147
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+574
-147
lines changed

.github/CODEOWNERS

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# All files should be reviewed by a member of the SDKs team
2+
* @stripe/api-library-reviewers

CHANGELOG.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@
77
* Add support for `Prices` on `BillingCreditBalanceSummaryFilterApplicabilityScopeOptions`, `BillingCreditGrantApplicabilityConfigScopeOptions`, and `BillingCreditGrantApplicabilityConfigScope`
88
* Add support for `BrandProduct` on `ChargePaymentMethodDetailsAmazonPayFundingCard` and `ChargePaymentMethodDetailsRevolutPayFundingCard`
99
* Add support for `Restrictions` on `CheckoutSessionPaymentMethodOptionsCardOptions` and `CheckoutSessionPaymentMethodOptionsCard`
10+
11+
## 47.4.0 - 2025-02-24
12+
* [#3050](https://github.com/stripe/stripe-dotnet/pull/3050) Update generated code
13+
* Add support for `Prices` on `BillingCreditBalanceSummaryFilterApplicabilityScopeOptions`, `BillingCreditGrantApplicabilityConfigScopeOptions`, and `BillingCreditGrantApplicabilityConfigScope`
14+
* Add support for `Priority` on `Billing.CreditGrantCreateOptions` and `BillingCreditGrant`
15+
* Add support for `TargetDate` on `CheckoutSessionPaymentMethodOptionsAcssDebitOptions`, `CheckoutSessionPaymentMethodOptionsAcssDebit`, `CheckoutSessionPaymentMethodOptionsAuBecsDebitOptions`, `CheckoutSessionPaymentMethodOptionsAuBecsDebit`, `CheckoutSessionPaymentMethodOptionsBacsDebitOptions`, `CheckoutSessionPaymentMethodOptionsBacsDebit`, `CheckoutSessionPaymentMethodOptionsSepaDebitOptions`, `CheckoutSessionPaymentMethodOptionsSepaDebit`, `CheckoutSessionPaymentMethodOptionsUsBankAccountOptions`, `CheckoutSessionPaymentMethodOptionsUsBankAccount`, `PaymentIntentPaymentMethodOptionsAcssDebitOptions`, `PaymentIntentPaymentMethodOptionsAcssDebit`, `PaymentIntentPaymentMethodOptionsAuBecsDebitOptions`, `PaymentIntentPaymentMethodOptionsAuBecsDebit`, `PaymentIntentPaymentMethodOptionsBacsDebitOptions`, `PaymentIntentPaymentMethodOptionsBacsDebit`, `PaymentIntentPaymentMethodOptionsSepaDebitOptions`, `PaymentIntentPaymentMethodOptionsSepaDebit`, `PaymentIntentPaymentMethodOptionsUsBankAccountOptions`, and `PaymentIntentPaymentMethodOptionsUsBankAccount`
16+
* Add support for `Restrictions` on `CheckoutSessionPaymentMethodOptionsCardOptions` and `CheckoutSessionPaymentMethodOptionsCard`
17+
* Add support for `CollectedInformation` on `Checkout.SessionUpdateOptions` and `CheckoutSession`
18+
* Add support for `Metadata` on `ProductDefaultPriceDataOptions`
19+
* [#3054](https://github.com/stripe/stripe-dotnet/pull/3054) Improved examples
20+
* [#3055](https://github.com/stripe/stripe-dotnet/pull/3055) add codeowners file
1021

1122
## 47.3.0 - 2025-01-27
1223
* [#3044](https://github.com/stripe/stripe-dotnet/pull/3044) Update generated code
@@ -4152,4 +4163,3 @@ List of backwards incompatible changes:
41524163
* [#1019](https://github.com/stripe/stripe-dotnet#1019) Add `StripeChargeCaptureOptions` and use it for charge capture
41534164
* [#1022](https://github.com/stripe/stripe-dotnet#1022) Add support for SKUs
41544165
* [#1025](https://github.com/stripe/stripe-dotnet#1025) Add `Discountable` for `StripeInvoiceLineItem`
4155-

OPENAPI_VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v1472
1+
v1505

justfile

+4
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,7 @@ update-version version:
3131
echo "{{ version }}" > VERSION
3232
perl -pi -e 's|<Version>[.\-\d\w]+</Version>|<Version>{{ version }}</Version>|' src/Stripe.net/Stripe.net.csproj
3333
perl -pi -e 's|Current = "[.\-\d\w]+";|Current = "{{ version }}";|' src/Stripe.net/Constants/Version.cs
34+
35+
[working-directory("src/Examples/")]
36+
run-example example:
37+
dotnet run --project Examples.csproj {{ example }}

src/Examples/ExampleTemplate.cs

+4-5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ namespace Examples
22
{
33
using System;
44
using System.Threading.Tasks;
5+
using Stripe;
56

67
/// <summary>
78
///
@@ -21,14 +22,12 @@ public class ExampleTemplate
2122
{
2223
public static async Task Run()
2324
{
24-
var apiKey = "{{API_KEY}}";
25+
var apiKey = Environment.GetEnvironmentVariable("STRIPE_API_KEY");
2526

2627
try
2728
{
28-
Console.WriteLine("Hello World");
29-
30-
// var client = new StripeClient(apiKey);
31-
// client.V1...
29+
var client = new StripeClient(apiKey);
30+
Console.WriteLine(await client.V1.Customers.ListAsync());
3231
}
3332
catch (Exception ex)
3433
{

src/Examples/Program.cs

+55-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
namespace Examples
22
{
33
using System;
4+
using System.Reflection;
45
using System.Threading.Tasks;
56

67
public class Program
@@ -9,14 +10,62 @@ public Program()
910
{
1011
}
1112

13+
/// <summary>
14+
/// To create an example, clone ExampleTemplate.cs, implement the example
15+
/// copy this line and replace the class name with your new class.
16+
///
17+
/// To run an example from this folder, execute:
18+
/// dotnet run --project Examples.csproj NameOfExample
19+
///
20+
/// The name of the example should include any namespace parts other than "Examples"
21+
/// which is prepended when looking up the type, for example"
22+
/// dotnet run --project Examples.csproj <see cref="ExampleTemplate"/>
23+
/// or
24+
/// dotnet run --project Examples.csproj <see cref="V2.MeterEventStream"/>.
25+
///
26+
/// Examples accept configuration via environment variables, so ensure all environment vars
27+
/// are set before running the example.
28+
///
29+
/// </summary>
30+
/// <param name="args">command line args</param>
31+
/// <returns></returns>
1232
public static async Task Main(string[] args)
1333
{
14-
// To create an example, clone NewExample.cs, implement the example
15-
// copy this line and replace the class name with your new class.
16-
// await NewExample.Run();
17-
// e.g.
18-
// await MeterEventExample.Run();
19-
// then build the project and run bin/Debug/net8.0/Examples
34+
if (args.Length != 1)
35+
{
36+
Console.WriteLine("Usage: dotnet run --project Examples <name_of_example>");
37+
Environment.Exit(1);
38+
return;
39+
}
40+
41+
var type = Assembly.GetExecutingAssembly().GetType($"Examples.{args[0]}");
42+
43+
if (type == null)
44+
{
45+
Console.WriteLine($"Unable to find example class {args[0]}");
46+
Environment.Exit(1);
47+
return;
48+
}
49+
50+
var runMethod = type.GetMethod(
51+
"Run",
52+
BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy);
53+
if (runMethod == null)
54+
{
55+
Console.WriteLine($"Example class {args[0]} is missing Run method");
56+
Environment.Exit(1);
57+
return;
58+
}
59+
60+
Task? result = (Task?)runMethod.Invoke(null, null);
61+
if (result == null)
62+
{
63+
Console.WriteLine($"Unable to invoke Run method on {args[0]}");
64+
Environment.Exit(1);
65+
return;
66+
}
67+
68+
await result;
2069
}
2170
}
2271
}

src/Examples/V2/MeterEventStream.cs

+58-55
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,70 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Threading.Tasks;
4-
using Stripe;
5-
using Stripe.V2.Billing;
6-
7-
/// <summary>
8-
/// Use the high-throughput MeterEventStream to report create billing meter events.
9-
///
10-
/// In this example, we:
11-
/// - create a meter event session and store the session's authentication token
12-
/// - define an event with a payload
13-
/// - use the meterEventStream service to create an event stream that reports this event
14-
///
15-
/// This example expects a billing meter with an event_name of 'alpaca_ai_tokens'. If you have
16-
/// a different meter event name, you can change it before running this example.
17-
/// </summary>
18-
public class MeterEventStream
1+
namespace Examples.V2
192
{
20-
private static MeterEventSession? meterEventSession;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Threading.Tasks;
6+
using Stripe;
7+
using Stripe.V2.Billing;
218

22-
public static async Task Run()
9+
/// <summary>
10+
/// Use the high-throughput MeterEventStream to report create billing meter events.
11+
///
12+
/// In this example, we:
13+
/// - create a meter event session and store the session's authentication token
14+
/// - define an event with a payload
15+
/// - use the meterEventStream service to create an event stream that reports this event
16+
///
17+
/// This example expects a billing meter with an event_name of 'alpaca_ai_tokens'. If you have
18+
/// a different meter event name, you can change it before running this example.
19+
/// </summary>
20+
public class MeterEventStream
2321
{
24-
var apiKey = "{{API_KEY}}";
25-
var customerId = "{{CUSTOMER_ID}}"; // Replace with actual customer ID
22+
private static MeterEventSession? meterEventSession;
2623

27-
try
28-
{
29-
await SendMeterEvent(apiKey, "alpaca_ai_tokens", customerId, "25");
30-
Console.WriteLine("Meter event sent successfully!");
31-
}
32-
catch (Exception ex)
24+
public static async Task Run()
3325
{
34-
Console.WriteLine($"Error sending meter event: {ex.Message}");
35-
}
36-
}
26+
var apiKey = Environment.GetEnvironmentVariable("STRIPE_API_KEY");
27+
var customerId = Environment.GetEnvironmentVariable("CUSTOMER_ID");
3728

38-
private static async Task RefreshMeterEventSession(string apiKey)
39-
{
40-
// Check if session is null or expired
41-
if (meterEventSession == null || meterEventSession.ExpiresAt <= DateTime.UtcNow)
42-
{
43-
// Create a new meter event session in case the existing session expired
44-
var client = new StripeClient(apiKey);
45-
meterEventSession = await client.V2.Billing.MeterEventSession.CreateAsync(new MeterEventSessionCreateOptions());
29+
try
30+
{
31+
await SendMeterEvent(apiKey, "alpaca_ai_tokens", customerId, "25");
32+
Console.WriteLine("Meter event sent successfully!");
33+
}
34+
catch (Exception ex)
35+
{
36+
Console.WriteLine($"Error sending meter event: {ex.Message}");
37+
}
4638
}
47-
}
48-
49-
private static async Task SendMeterEvent(string apiKey, string eventName, string stripeCustomerId, string value)
50-
{
51-
// Refresh the meter event session if necessary
52-
await RefreshMeterEventSession(apiKey);
5339

54-
if (meterEventSession == null)
40+
private static async Task RefreshMeterEventSession(string apiKey)
5541
{
56-
throw new Exception("Unable to refresh meter event session");
42+
// Check if session is null or expired
43+
if (meterEventSession == null || meterEventSession.ExpiresAt <= DateTime.UtcNow)
44+
{
45+
// Create a new meter event session in case the existing session expired
46+
var client = new StripeClient(apiKey);
47+
meterEventSession = await client.V2.Billing.MeterEventSession.CreateAsync(new MeterEventSessionCreateOptions());
48+
}
5749
}
5850

59-
// Create a meter event
60-
var client = new StripeClient(meterEventSession.AuthenticationToken);
61-
var options = new MeterEventStreamCreateOptions
51+
private static async Task SendMeterEvent(string apiKey, string eventName, string stripeCustomerId, string value)
6252
{
63-
Events =
64-
[
65-
new MeterEventStreamCreateEventOptions
53+
// Refresh the meter event session if necessary
54+
await RefreshMeterEventSession(apiKey);
55+
56+
if (meterEventSession == null)
57+
{
58+
throw new Exception("Unable to refresh meter event session");
59+
}
60+
61+
// Create a meter event
62+
var client = new StripeClient(meterEventSession.AuthenticationToken);
63+
var options = new MeterEventStreamCreateOptions
64+
{
65+
Events =
66+
[
67+
new MeterEventStreamCreateEventOptions
6668
{
6769
EventName = eventName,
6870
Payload = new Dictionary<string, string>
@@ -72,7 +74,8 @@ private static async Task SendMeterEvent(string apiKey, string eventName, string
7274
},
7375
},
7476
],
75-
};
76-
client.V2.Billing.MeterEventStream.Create(options);
77+
};
78+
client.V2.Billing.MeterEventStream.Create(options);
79+
}
7780
}
7881
}
+51-48
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,63 @@
1-
#pragma warning disable SA1101 // Prefix local calls with this
2-
3-
using System;
4-
using System.IO;
5-
using System.Threading.Tasks;
6-
using Microsoft.AspNetCore.Mvc;
7-
using Stripe;
8-
using Stripe.Events;
9-
10-
/// <summary>
11-
/// Receive and process thin events like the v1.billing.meter.error_report_triggered event.
12-
///
13-
/// In this example, we:
14-
/// - use parseThinEvent to parse the received thin event webhook body
15-
/// - call StripeClient.v2.core.events.retrieve to retrieve the full event object
16-
/// - if it is a V1BillingMeterErrorReportTriggeredEvent event type, call fetchRelatedObject
17-
/// to retrieve the Billing Meter object associated with the event.
18-
/// </summary>
19-
[Route("api/[controller]")]
20-
[ApiController]
21-
public class ThinEventWebhookHandler : ControllerBase
1+
namespace Examples.V2
222
{
23-
private readonly StripeClient _client;
24-
private readonly string _webhookSecret;
3+
#pragma warning disable SA1101 // Prefix local calls with this
254

26-
public ThinEventWebhookHandler()
5+
using System;
6+
using System.IO;
7+
using System.Threading.Tasks;
8+
using Microsoft.AspNetCore.Mvc;
9+
using Stripe;
10+
using Stripe.Events;
11+
12+
/// <summary>
13+
/// Receive and process thin events like the v1.billing.meter.error_report_triggered event.
14+
///
15+
/// In this example, we:
16+
/// - use parseThinEvent to parse the received thin event webhook body
17+
/// - call StripeClient.v2.core.events.retrieve to retrieve the full event object
18+
/// - if it is a V1BillingMeterErrorReportTriggeredEvent event type, call fetchRelatedObject
19+
/// to retrieve the Billing Meter object associated with the event.
20+
/// </summary>
21+
[Route("api/[controller]")]
22+
[ApiController]
23+
public class ThinEventWebhookHandler : ControllerBase
2724
{
28-
var apiKey = Environment.GetEnvironmentVariable("STRIPE_API_KEY");
29-
_client = new StripeClient(apiKey);
30-
31-
_webhookSecret = Environment.GetEnvironmentVariable("WEBHOOK_SECRET");
32-
}
25+
private readonly StripeClient _client;
26+
private readonly string _webhookSecret;
3327

34-
[HttpPost]
35-
public async Task<IActionResult> Index()
36-
{
37-
var json = await new StreamReader(HttpContext.Request.Body).ReadToEndAsync();
38-
try
28+
public ThinEventWebhookHandler()
3929
{
40-
var thinEvent = _client.ParseThinEvent(json, Request.Headers["Stripe-Signature"], _webhookSecret);
30+
var apiKey = Environment.GetEnvironmentVariable("STRIPE_API_KEY");
31+
_client = new StripeClient(apiKey);
32+
33+
_webhookSecret = Environment.GetEnvironmentVariable("WEBHOOK_SECRET");
34+
}
4135

42-
// Fetch the event data to understand the failure
43-
var baseEvent = await _client.V2.Core.Events.GetAsync(thinEvent.Id);
44-
if (baseEvent is V1BillingMeterErrorReportTriggeredEvent fullEvent)
36+
[HttpPost]
37+
public async Task<IActionResult> Index()
38+
{
39+
var json = await new StreamReader(HttpContext.Request.Body).ReadToEndAsync();
40+
try
4541
{
46-
var meter = await fullEvent.FetchRelatedObjectAsync();
47-
var meterId = meter.Id;
42+
var thinEvent = _client.ParseThinEvent(json, Request.Headers["Stripe-Signature"], _webhookSecret);
4843

49-
// Record the failures and alert your team
50-
// Add your logic here
51-
}
44+
// Fetch the event data to understand the failure
45+
var baseEvent = await _client.V2.Core.Events.GetAsync(thinEvent.Id);
46+
if (baseEvent is V1BillingMeterErrorReportTriggeredEvent fullEvent)
47+
{
48+
var meter = await fullEvent.FetchRelatedObjectAsync();
49+
var meterId = meter.Id;
5250

53-
return Ok();
54-
}
55-
catch (StripeException e)
56-
{
57-
return BadRequest(e.Message);
51+
// Record the failures and alert your team
52+
// Add your logic here
53+
}
54+
55+
return Ok();
56+
}
57+
catch (StripeException e)
58+
{
59+
return BadRequest(e.Message);
60+
}
5861
}
5962
}
6063
}

src/Stripe.net/Constants/ApiVersion.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ namespace Stripe
33
{
44
internal class ApiVersion
55
{
6-
public const string Current = "2025-01-27.acacia";
6+
public const string Current = "2025-02-24.acacia";
77
}
88
}

0 commit comments

Comments
 (0)