-
Notifications
You must be signed in to change notification settings - Fork 581
Migration guide for v22
Version 22 of Stripe.net contains a large number of changes. This guide will help you update your Stripe integration so that it keeps working as expected after you upgrade to v22.
One of the most important changes in this version is that deserializing an event using the EventUtility.ConstructEvent or EventUtility.ParseEvent methods will now throw a StripeException if the library detects a mismatch between the event's API version and the API version the library is pinned to (which is 2018-11-08 for Stripe.net 22.0.0).
This is a safety feature to ensure that the events you receive via your webhook handler are formatted as the library expects. Otherwise this could lead to missing information (e.g. if an attribute was renamed) or even crashes (e.g. if the library expects a non-nullable value type that is missing in the event's JSON).
You can disable this behavior by passing throwOnApiVersionMismatch: false to either method, but we don't recommend you do this.
-
InvoiceService.ListUpcomingLineItemsnow accepts aUpcomingInvoiceListLineItemsOptionsinstead of aUpcomingInvoiceOptions. The newUpcomingInvoiceListLineItemsOptionsclass has all the same attributes asUpcomingInvoiceOptions, but also accepts pagination parameters. -
Recipient.ActiveAccountis now aBankAccountinstead of aRecipientActiveAccount. TheRecipientActiveAccountclass has been removed entirely. -
Deletedis now abool?instead of aboolon all classes. -
All arrays have been replaced by lists:
| Property | Old type | New type |
|---|---|---|
AccountVerification.FieldsNeeded |
string[] |
List<string> |
Card.AvailablePayoutMethods |
string[] |
List<string> |
Requirements.CurrentlyDue |
string[] |
List<string> |
Requirements.EventuallyDue |
string[] |
List<string> |
Requirements.PastDue |
string[] |
List<string> |
Product.Attributes |
string[] |
List<string> |
Product.DeactivateOn |
string[] |
List<string> |
Product.Images |
string[] |
List<string> |
WebhookEndpoint.EnabledEvents |
string[] |
List<string> |
BankAccountVerifyOptions.Amounts |
long[] |
List<long> |
OrderListOptions.Ids |
string[] |
List<string> |
OrderListOptions.UpstreamIds |
string[] |
List<string> |
ProductCreateOptions.Attributes |
string[] |
List<string> |
ProductCreateOptions.DeactivateOn |
string[] |
List<string> |
ProductCreateOptions.Images |
string[] |
List<string> |
ProductListOptions.Ids |
string[] |
List<string> |
ProductUpdateOptions.Attributes |
string[] |
List<string> |
ProductUpdateOptions.DeactivateOn |
string[] |
List<string> |
ProductUpdateOptions.Images |
string[] |
List<string> |
SkuListOptions.Ids |
string[] |
List<string> |
WebhookEndpointCreateOptions.EnabledEvents |
string[] |
List<string> |
WebhookEndpointUpdateOptions.EnabledEvents |
string[] |
List<string> |
The following properties have been renamed:
| Old name | New name |
|---|---|
Account.BusinessLogoFileId |
Account.BusinessLogoId |
LegalEntityVerification.DocumentIdBack |
LegalEntityVerification.DocumentBackId |
Evidence.CancellationPolicyFileId |
Evidence.CancellationPolicyId |
Evidence.CancellationPolicyFile |
Evidence.CancellationPolicy |
Evidence.CustomerCommunicationFileId |
Evidence.CustomerCommunicationId |
Evidence.CustomerCommunicationFile |
Evidence.CustomerCommunication |
Evidence.CustomerSignatureFileId |
Evidence.CustomerSignatureId |
Evidence.CustomerSignatureFile |
Evidence.CustomerSignature |
Evidence.CustomerSignatureFileId |
Evidence.CustomerSignatureId |
Evidence.CustomerSignatureFile |
Evidence.CustomerSignature |
Evidence.DuplicateChargeDocumentationFileId |
Evidence.DuplicateChargeDocumentationId |
Evidence.DuplicateChargeDocumentationFile |
Evidence.DuplicateChargeDocumentation |
Evidence.ReceiptFileId |
Evidence.ReceiptId |
Evidence.ReceiptFile |
Evidence.Receipt |
Evidence.RefundPolicyFileId |
Evidence.RefundPolicyId |
Evidence.RefundPolicyFile |
Evidence.RefundPolicy |
Evidence.ServiceDocumentationFileId |
Evidence.ServiceDocumentationId |
Evidence.ServiceDocumentationFile |
Evidence.ServiceDocumentation |
Evidence.ShippingDocumentationFileId |
Evidence.ShippingDocumentationId |
Evidence.ShippingDocumentationFile |
Evidence.ShippingDocumentation |
Recipient.StripeDefaultCardId |
Recipient.DefaultCardId |
Recipient.StripeDefaultCard |
Recipient.DefaultCard |
-
StripeList.TotalCounthas been removed. This property was deprecated and is no longer returned by the API in nearly all cases. -
ValueList.UpdatedandValueList.UpdatedByhave been removed. The API no longer returns these properties.
String constants (e.g. Event.ChargeCreated) are now declared as static read-only properties. For the most part, this requires no change on your part, save for switch statements. C# only accepts constant values in switch statements, so you will have to replace the various switch / case with if / else if to achieve the same effect.
Stripe.net now supports auto-pagination.
Example usage:
var service = new BalanceTransactionService();
var listOptions = new BalanceTransactionListOptions
{
Created = new DateRangeOptions
{
GreatherThanOrEqual = DateTime.Parse("2018-11-01T00:00:00Z"),
LessThan = DateTime.Parse("2018-12-01T00:00:00Z"),
},
Limit = 100,
};
foreach (var balanceTransaction in service.ListAutoPaging(listOptions))
{
// Do something with balanceTransaction
}You can also use LINQ's ToList() method to convert the iterator to a list in memory (be careful when doing this though as this could take a long time depending on the number of items to fetch):
var service = new InvoiceService();
var lineItems = service.ListLineItemsAutoPaging("in_123").ToList();You can now call ToJson() on any instance of a StripeEntity to get a JSON representation of the object.
ToString() has also been overridden to be more useful and include more information, including the class name, a unique ID, and the JSON represensation.
The library now supports SourceLink, which should improve your debugging experience.