Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion API_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0de52cdca31a7c51c6d11187fc88ab23ea3a1c5b
7019a9a61be5a9cc3ffa998a36dbe33057249d39
2 changes: 1 addition & 1 deletion OPENAPI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0de52cdca31a7c51c6d11187fc88ab23ea3a1c5b
v2049
34 changes: 19 additions & 15 deletions src/Examples/V2/EventNotificationWebhookHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ namespace Examples.V2
using Microsoft.AspNetCore.Mvc;
using Stripe;
using Stripe.Events;
using Stripe.V2;

/// <summary>
/// Receive and process EventNotifications like the v1.billing.meter.error_report_triggered event.
Expand All @@ -18,6 +17,7 @@ namespace Examples.V2
/// - call StripeClient.v2.core.events.retrieve to retrieve the full event object
/// - if it is a V1BillingMeterErrorReportTriggeredEvent event type, call fetchRelatedObject
/// to retrieve the Billing Meter object associated with the event.
/// - handle unknown event types gracefully.
/// </summary>
[Route("api/[controller]")]
[ApiController]
Expand All @@ -31,7 +31,7 @@ public EventNotificationWebhookHandler()
var apiKey = Environment.GetEnvironmentVariable("STRIPE_API_KEY");
client = new StripeClient(apiKey);

webhookSecret = Environment.GetEnvironmentVariable("WEBHOOK_SECRET");
webhookSecret = Environment.GetEnvironmentVariable("WEBHOOK_SECRET") ?? string.Empty;
}

[HttpPost]
Expand All @@ -43,26 +43,30 @@ public async Task<IActionResult> Index()
var eventNotification = client.ParseEventNotification(json, Request.Headers["Stripe-Signature"], webhookSecret);

// match on the type of the class to determine what event you have
if (eventNotification is V1BillingMeterErrorReportTriggeredEventNotification evt)
if (eventNotification is V1BillingMeterErrorReportTriggeredEventNotification notif)
{
// the related object is correctly typed
var meter = evt.FetchRelatedObject();
Console.WriteLine($"Default aggregation: {meter.DefaultAggregation}");
// there's basic info about the related object in the notification
Console.WriteLine(
$"Meter w/ id {notif.RelatedObject.Id} had a problem");

// can also fetch the full event to get the event data
var eventObj = evt.FetchEvent();
var eventData = eventObj.Data;
Console.WriteLine($"Err summary: {eventData.DeveloperMessageSummary}");
}
// or you can fetch the full object form the API for more details
var meter = await notif.FetchRelatedObjectAsync();
Console.WriteLine($"Meter {meter.DisplayName} ({meter.Id}) had a problem");

// check other types the SDK knows about
// for event types that were released after this SDK was generated, check type
// And you can always fetch the full event:
var evt = await notif.FetchEventAsync();
Console.WriteLine($"More info: {evt.Data.DeveloperMessageSummary}");
}
else if (eventNotification is UnknownEventNotification unknownEvt)
{
// fall back to checking type
// Events that were introduced after this SDK version release are
// represented as `UnknownEventNotification`s.
// They're valid, the SDK just doesn't have corresponding classes for them.
// You must match on the "type" property instead.
if (unknownEvt.Type == "some.other.event")
{
// handle the event
// you can still `.fetchEvent()` and `.fetchRelatedObject()`, but the latter may
// return `null` if that event type doesn't have a related object.
}
}

Expand Down
6 changes: 6 additions & 0 deletions src/Stripe.net/Entities/Cards/Card.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@ public Account Account
#endif
public List<string> AvailablePayoutMethods { get; set; }

[JsonProperty("benefits")]
#if NET6_0_OR_GREATER
[STJS.JsonPropertyName("benefits")]
#endif
public CardBenefits Benefits { get; set; }

/// <summary>
/// Card brand. Can be <c>American Express</c>, <c>Cartes Bancaires</c>, <c>Diners Club</c>,
/// <c>Discover</c>, <c>Eftpos Australia</c>, <c>Girocard</c>, <c>JCB</c>,
Expand Down
30 changes: 30 additions & 0 deletions src/Stripe.net/Entities/Cards/CardBenefits.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// File generated from our OpenAPI spec
namespace Stripe
{
using System.Collections.Generic;
using Newtonsoft.Json;
#if NET6_0_OR_GREATER
using STJS = System.Text.Json.Serialization;
#endif

public class CardBenefits : StripeEntity<CardBenefits>
{
/// <summary>
/// Issuer of this benefit card.
/// </summary>
[JsonProperty("issuer")]
#if NET6_0_OR_GREATER
[STJS.JsonPropertyName("issuer")]
#endif
public string Issuer { get; set; }

/// <summary>
/// Available benefit programs for this card.
/// </summary>
[JsonProperty("programs")]
#if NET6_0_OR_GREATER
[STJS.JsonPropertyName("programs")]
#endif
public List<string> Programs { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -288,5 +288,11 @@ public class ChargePaymentMethodDetailsCard : StripeEntity<ChargePaymentMethodDe
[STJS.JsonPropertyName("wallet")]
#endif
public ChargePaymentMethodDetailsCardWallet Wallet { get; set; }

[JsonProperty("benefits")]
#if NET6_0_OR_GREATER
[STJS.JsonPropertyName("benefits")]
#endif
public ChargePaymentMethodDetailsCardBenefits Benefits { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// File generated from our OpenAPI spec
namespace Stripe
{
using Newtonsoft.Json;
#if NET6_0_OR_GREATER
using STJS = System.Text.Json.Serialization;
#endif

public class ChargePaymentMethodDetailsCardBenefits : StripeEntity<ChargePaymentMethodDetailsCardBenefits>
{
/// <summary>
/// Issuer of the benefit card utilized on this payment.
/// </summary>
[JsonProperty("issuer")]
#if NET6_0_OR_GREATER
[STJS.JsonPropertyName("issuer")]
#endif
public string Issuer { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -178,5 +178,11 @@ public class ConfirmationTokenPaymentMethodPreviewCard : StripeEntity<Confirmati
[STJS.JsonPropertyName("wallet")]
#endif
public ConfirmationTokenPaymentMethodPreviewCardWallet Wallet { get; set; }

[JsonProperty("benefits")]
#if NET6_0_OR_GREATER
[STJS.JsonPropertyName("benefits")]
#endif
public ConfirmationTokenPaymentMethodPreviewCardBenefits Benefits { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// File generated from our OpenAPI spec
namespace Stripe
{
using System.Collections.Generic;
using Newtonsoft.Json;
#if NET6_0_OR_GREATER
using STJS = System.Text.Json.Serialization;
#endif

public class ConfirmationTokenPaymentMethodPreviewCardBenefits : StripeEntity<ConfirmationTokenPaymentMethodPreviewCardBenefits>
{
/// <summary>
/// Issuer of this benefit card.
/// </summary>
[JsonProperty("issuer")]
#if NET6_0_OR_GREATER
[STJS.JsonPropertyName("issuer")]
#endif
public string Issuer { get; set; }

/// <summary>
/// Available benefit programs for this card.
/// </summary>
[JsonProperty("programs")]
#if NET6_0_OR_GREATER
[STJS.JsonPropertyName("programs")]
#endif
public List<string> Programs { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,11 @@ public class PaymentIntentPaymentDetails : StripeEntity<PaymentIntentPaymentDeta
[STJS.JsonPropertyName("subscription")]
#endif
public PaymentIntentPaymentDetailsSubscription Subscription { get; set; }

[JsonProperty("benefit")]
#if NET6_0_OR_GREATER
[STJS.JsonPropertyName("benefit")]
#endif
public PaymentIntentPaymentDetailsBenefit Benefit { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// File generated from our OpenAPI spec
namespace Stripe
{
using Newtonsoft.Json;
#if NET6_0_OR_GREATER
using STJS = System.Text.Json.Serialization;
#endif

public class PaymentIntentPaymentDetailsBenefit : StripeEntity<PaymentIntentPaymentDetailsBenefit>
{
[JsonProperty("fr_meal_voucher")]
#if NET6_0_OR_GREATER
[STJS.JsonPropertyName("fr_meal_voucher")]
#endif
public PaymentIntentPaymentDetailsBenefitFrMealVoucher FrMealVoucher { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// File generated from our OpenAPI spec
namespace Stripe
{
using Newtonsoft.Json;
#if NET6_0_OR_GREATER
using STJS = System.Text.Json.Serialization;
#endif

public class PaymentIntentPaymentDetailsBenefitFrMealVoucher : StripeEntity<PaymentIntentPaymentDetailsBenefitFrMealVoucher>
{
/// <summary>
/// The 14-digit SIRET of the meal voucher acceptor.
/// </summary>
[JsonProperty("siret")]
#if NET6_0_OR_GREATER
[STJS.JsonPropertyName("siret")]
#endif
public string Siret { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// File generated from our OpenAPI spec
namespace Stripe
{
using System;
using Newtonsoft.Json;
using Stripe.Infrastructure;
#if NET6_0_OR_GREATER
using STJS = System.Text.Json.Serialization;
#endif

/// <summary>
/// PaymentMethodBalance objects represent balances available on a payment method. You can
/// use v1/payment_methods/:id/check_balance to check the balance of a payment method.
/// </summary>
public class PaymentMethodBalance : StripeEntity<PaymentMethodBalance>, IHasObject
{
/// <summary>
/// String representing the object's type. Objects of the same type share the same value.
/// </summary>
[JsonProperty("object")]
#if NET6_0_OR_GREATER
[STJS.JsonPropertyName("object")]
#endif
public string Object { get; set; }

/// <summary>
/// The time at which the balance was calculated. Measured in seconds since the Unix epoch.
/// </summary>
[JsonProperty("as_of")]
[JsonConverter(typeof(UnixDateTimeConverter))]
#if NET6_0_OR_GREATER
[STJS.JsonPropertyName("as_of")]
[STJS.JsonConverter(typeof(STJUnixDateTimeConverter))]
#endif
public DateTime AsOf { get; set; } = Stripe.Infrastructure.DateTimeUtils.UnixEpoch;

/// <summary>
/// BalanceEntry contain information about every individual balance type of a card.
/// </summary>
[JsonProperty("balance")]
#if NET6_0_OR_GREATER
[STJS.JsonPropertyName("balance")]
#endif
public PaymentMethodBalanceBalance Balance { get; set; }

/// <summary>
/// Has the value <c>true</c> if the object exists in live mode or the value <c>false</c> if
/// the object exists in test mode.
/// </summary>
[JsonProperty("livemode")]
#if NET6_0_OR_GREATER
[STJS.JsonPropertyName("livemode")]
#endif
public bool Livemode { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// File generated from our OpenAPI spec
namespace Stripe
{
using Newtonsoft.Json;
#if NET6_0_OR_GREATER
using STJS = System.Text.Json.Serialization;
#endif

public class PaymentMethodBalanceBalance : StripeEntity<PaymentMethodBalanceBalance>
{
/// <summary>
/// The available FR Meal Voucher balances.
/// </summary>
[JsonProperty("fr_meal_voucher")]
#if NET6_0_OR_GREATER
[STJS.JsonPropertyName("fr_meal_voucher")]
#endif
public PaymentMethodBalanceBalanceFrMealVoucher FrMealVoucher { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// File generated from our OpenAPI spec
namespace Stripe
{
using System.Collections.Generic;
using Newtonsoft.Json;
#if NET6_0_OR_GREATER
using STJS = System.Text.Json.Serialization;
#endif

public class PaymentMethodBalanceBalanceFrMealVoucher : StripeEntity<PaymentMethodBalanceBalanceFrMealVoucher>
{
/// <summary>
/// The hashes of balances and amounts for available balances.
/// </summary>
[JsonProperty("available")]
#if NET6_0_OR_GREATER
[STJS.JsonPropertyName("available")]
#endif
public List<PaymentMethodBalanceBalanceFrMealVoucherAvailable> Available { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// File generated from our OpenAPI spec
namespace Stripe
{
using Newtonsoft.Json;
#if NET6_0_OR_GREATER
using STJS = System.Text.Json.Serialization;
#endif

public class PaymentMethodBalanceBalanceFrMealVoucherAvailable : StripeEntity<PaymentMethodBalanceBalanceFrMealVoucherAvailable>
{
/// <summary>
/// The amount of the balance.
/// </summary>
[JsonProperty("amount")]
#if NET6_0_OR_GREATER
[STJS.JsonPropertyName("amount")]
#endif
public long Amount { get; set; }

/// <summary>
/// The currency of the balance.
/// </summary>
[JsonProperty("currency")]
#if NET6_0_OR_GREATER
[STJS.JsonPropertyName("currency")]
#endif
public string Currency { get; set; }
}
}
6 changes: 6 additions & 0 deletions src/Stripe.net/Entities/PaymentMethods/PaymentMethodCard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,5 +178,11 @@ public class PaymentMethodCard : StripeEntity<PaymentMethodCard>
[STJS.JsonPropertyName("wallet")]
#endif
public PaymentMethodCardWallet Wallet { get; set; }

[JsonProperty("benefits")]
#if NET6_0_OR_GREATER
[STJS.JsonPropertyName("benefits")]
#endif
public PaymentMethodCardBenefits Benefits { get; set; }
}
}
Loading
Loading