mirror of
https://github.com/bitwarden/server.git
synced 2025-04-21 13:05:11 -05:00
Updated Stripe API SDK version to 36.9.0
This commit is contained in:
parent
3c5cd0ffb2
commit
9a2d8e96e4
@ -52,7 +52,7 @@
|
|||||||
<PackageReference Include="System.Text.Json" Version="4.7.1" />
|
<PackageReference Include="System.Text.Json" Version="4.7.1" />
|
||||||
<PackageReference Include="AspNetCoreRateLimit" Version="2.1.0" />
|
<PackageReference Include="AspNetCoreRateLimit" Version="2.1.0" />
|
||||||
<PackageReference Include="Braintree" Version="4.17.0" />
|
<PackageReference Include="Braintree" Version="4.17.0" />
|
||||||
<PackageReference Include="Stripe.net" Version="28.8.0" />
|
<PackageReference Include="Stripe.net" Version="36.9.0" />
|
||||||
<PackageReference Include="U2F.Core" Version="1.0.4" />
|
<PackageReference Include="U2F.Core" Version="1.0.4" />
|
||||||
<PackageReference Include="Otp.NET" Version="1.2.2" />
|
<PackageReference Include="Otp.NET" Version="1.2.2" />
|
||||||
<PackageReference Include="YubicoDotNetClient" Version="1.2.0" />
|
<PackageReference Include="YubicoDotNetClient" Version="1.2.0" />
|
||||||
|
@ -339,7 +339,7 @@ namespace Bit.Core.Services
|
|||||||
.Select(i => new InvoiceSubscriptionItemOptions
|
.Select(i => new InvoiceSubscriptionItemOptions
|
||||||
{
|
{
|
||||||
Id = i.Id,
|
Id = i.Id,
|
||||||
PlanId = i.Plan.Id,
|
Plan = i.Plan.Id,
|
||||||
Quantity = i.Quantity,
|
Quantity = i.Quantity,
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
@ -347,16 +347,16 @@ namespace Bit.Core.Services
|
|||||||
{
|
{
|
||||||
subItemOptions.Add(new InvoiceSubscriptionItemOptions
|
subItemOptions.Add(new InvoiceSubscriptionItemOptions
|
||||||
{
|
{
|
||||||
PlanId = plan.StripeSeatPlanId,
|
Plan = plan.StripeSeatPlanId,
|
||||||
Quantity = additionalSeats,
|
Quantity = additionalSeats,
|
||||||
});
|
});
|
||||||
subUpdateAction = (prorate) => subscriptionItemService.CreateAsync(
|
subUpdateAction = (prorate) => subscriptionItemService.CreateAsync(
|
||||||
new SubscriptionItemCreateOptions
|
new SubscriptionItemCreateOptions
|
||||||
{
|
{
|
||||||
PlanId = plan.StripeSeatPlanId,
|
Plan = plan.StripeSeatPlanId,
|
||||||
Quantity = additionalSeats,
|
Quantity = additionalSeats,
|
||||||
Prorate = prorate,
|
Prorate = prorate,
|
||||||
SubscriptionId = sub.Id
|
Subscription = sub.Id
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (additionalSeats > 0 && seatItem != null)
|
else if (additionalSeats > 0 && seatItem != null)
|
||||||
@ -364,13 +364,13 @@ namespace Bit.Core.Services
|
|||||||
subItemOptions.Add(new InvoiceSubscriptionItemOptions
|
subItemOptions.Add(new InvoiceSubscriptionItemOptions
|
||||||
{
|
{
|
||||||
Id = seatItem.Id,
|
Id = seatItem.Id,
|
||||||
PlanId = plan.StripeSeatPlanId,
|
Plan = plan.StripeSeatPlanId,
|
||||||
Quantity = additionalSeats,
|
Quantity = additionalSeats,
|
||||||
});
|
});
|
||||||
subUpdateAction = (prorate) => subscriptionItemService.UpdateAsync(seatItem.Id,
|
subUpdateAction = (prorate) => subscriptionItemService.UpdateAsync(seatItem.Id,
|
||||||
new SubscriptionItemUpdateOptions
|
new SubscriptionItemUpdateOptions
|
||||||
{
|
{
|
||||||
PlanId = plan.StripeSeatPlanId,
|
Plan = plan.StripeSeatPlanId,
|
||||||
Quantity = additionalSeats,
|
Quantity = additionalSeats,
|
||||||
Prorate = prorate
|
Prorate = prorate
|
||||||
});
|
});
|
||||||
@ -382,7 +382,8 @@ namespace Bit.Core.Services
|
|||||||
Id = seatItem.Id,
|
Id = seatItem.Id,
|
||||||
Deleted = true
|
Deleted = true
|
||||||
});
|
});
|
||||||
subUpdateAction = (prorate) => subscriptionItemService.DeleteAsync(seatItem.Id);
|
subUpdateAction = (prorate) => subscriptionItemService.DeleteAsync(seatItem.Id,
|
||||||
|
new SubscriptionItemDeleteOptions());
|
||||||
}
|
}
|
||||||
|
|
||||||
string paymentIntentClientSecret = null;
|
string paymentIntentClientSecret = null;
|
||||||
|
@ -102,7 +102,7 @@ namespace Bit.Core.Services
|
|||||||
{
|
{
|
||||||
OffSession = true,
|
OffSession = true,
|
||||||
TrialPeriodDays = plan.TrialPeriodDays,
|
TrialPeriodDays = plan.TrialPeriodDays,
|
||||||
Items = new List<SubscriptionItemOption>(),
|
Items = new List<SubscriptionItemOptions>(),
|
||||||
Metadata = new Dictionary<string, string>
|
Metadata = new Dictionary<string, string>
|
||||||
{
|
{
|
||||||
[org.GatewayIdField()] = org.Id.ToString()
|
[org.GatewayIdField()] = org.Id.ToString()
|
||||||
@ -111,36 +111,36 @@ namespace Bit.Core.Services
|
|||||||
|
|
||||||
if (plan.StripePlanId != null)
|
if (plan.StripePlanId != null)
|
||||||
{
|
{
|
||||||
subCreateOptions.Items.Add(new SubscriptionItemOption
|
subCreateOptions.Items.Add(new SubscriptionItemOptions
|
||||||
{
|
{
|
||||||
PlanId = plan.StripePlanId,
|
Plan = plan.StripePlanId,
|
||||||
Quantity = 1
|
Quantity = 1
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (additionalSeats > 0 && plan.StripeSeatPlanId != null)
|
if (additionalSeats > 0 && plan.StripeSeatPlanId != null)
|
||||||
{
|
{
|
||||||
subCreateOptions.Items.Add(new SubscriptionItemOption
|
subCreateOptions.Items.Add(new SubscriptionItemOptions
|
||||||
{
|
{
|
||||||
PlanId = plan.StripeSeatPlanId,
|
Plan = plan.StripeSeatPlanId,
|
||||||
Quantity = additionalSeats
|
Quantity = additionalSeats
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (additionalStorageGb > 0)
|
if (additionalStorageGb > 0)
|
||||||
{
|
{
|
||||||
subCreateOptions.Items.Add(new SubscriptionItemOption
|
subCreateOptions.Items.Add(new SubscriptionItemOptions
|
||||||
{
|
{
|
||||||
PlanId = plan.StripeStoragePlanId,
|
Plan = plan.StripeStoragePlanId,
|
||||||
Quantity = additionalStorageGb
|
Quantity = additionalStorageGb
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (premiumAccessAddon && plan.StripePremiumAccessPlanId != null)
|
if (premiumAccessAddon && plan.StripePremiumAccessPlanId != null)
|
||||||
{
|
{
|
||||||
subCreateOptions.Items.Add(new SubscriptionItemOption
|
subCreateOptions.Items.Add(new SubscriptionItemOptions
|
||||||
{
|
{
|
||||||
PlanId = plan.StripePremiumAccessPlanId,
|
Plan = plan.StripePremiumAccessPlanId,
|
||||||
Quantity = 1
|
Quantity = 1
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -154,15 +154,15 @@ namespace Bit.Core.Services
|
|||||||
Description = org.BusinessName,
|
Description = org.BusinessName,
|
||||||
Email = org.BillingEmail,
|
Email = org.BillingEmail,
|
||||||
Source = stipeCustomerSourceToken,
|
Source = stipeCustomerSourceToken,
|
||||||
PaymentMethodId = stipeCustomerPaymentMethodId,
|
PaymentMethod = stipeCustomerPaymentMethodId,
|
||||||
Metadata = stripeCustomerMetadata,
|
Metadata = stripeCustomerMetadata,
|
||||||
InvoiceSettings = new CustomerInvoiceSettingsOptions
|
InvoiceSettings = new CustomerInvoiceSettingsOptions
|
||||||
{
|
{
|
||||||
DefaultPaymentMethodId = stipeCustomerPaymentMethodId
|
DefaultPaymentMethod = stipeCustomerPaymentMethodId
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
subCreateOptions.AddExpand("latest_invoice.payment_intent");
|
subCreateOptions.AddExpand("latest_invoice.payment_intent");
|
||||||
subCreateOptions.CustomerId = customer.Id;
|
subCreateOptions.Customer = customer.Id;
|
||||||
var subscriptionService = new SubscriptionService();
|
var subscriptionService = new SubscriptionService();
|
||||||
subscription = await subscriptionService.CreateAsync(subCreateOptions);
|
subscription = await subscriptionService.CreateAsync(subCreateOptions);
|
||||||
if (subscription.Status == "incomplete" && subscription.LatestInvoice?.PaymentIntent != null)
|
if (subscription.Status == "incomplete" && subscription.LatestInvoice?.PaymentIntent != null)
|
||||||
@ -225,8 +225,8 @@ namespace Bit.Core.Services
|
|||||||
|
|
||||||
var subCreateOptions = new SubscriptionCreateOptions
|
var subCreateOptions = new SubscriptionCreateOptions
|
||||||
{
|
{
|
||||||
CustomerId = customer.Id,
|
Customer = customer.Id,
|
||||||
Items = new List<SubscriptionItemOption>(),
|
Items = new List<SubscriptionItemOptions>(),
|
||||||
Metadata = new Dictionary<string, string>
|
Metadata = new Dictionary<string, string>
|
||||||
{
|
{
|
||||||
[org.GatewayIdField()] = org.Id.ToString()
|
[org.GatewayIdField()] = org.Id.ToString()
|
||||||
@ -235,36 +235,36 @@ namespace Bit.Core.Services
|
|||||||
|
|
||||||
if (plan.StripePlanId != null)
|
if (plan.StripePlanId != null)
|
||||||
{
|
{
|
||||||
subCreateOptions.Items.Add(new SubscriptionItemOption
|
subCreateOptions.Items.Add(new SubscriptionItemOptions
|
||||||
{
|
{
|
||||||
PlanId = plan.StripePlanId,
|
Plan = plan.StripePlanId,
|
||||||
Quantity = 1
|
Quantity = 1
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (additionalSeats > 0 && plan.StripeSeatPlanId != null)
|
if (additionalSeats > 0 && plan.StripeSeatPlanId != null)
|
||||||
{
|
{
|
||||||
subCreateOptions.Items.Add(new SubscriptionItemOption
|
subCreateOptions.Items.Add(new SubscriptionItemOptions
|
||||||
{
|
{
|
||||||
PlanId = plan.StripeSeatPlanId,
|
Plan = plan.StripeSeatPlanId,
|
||||||
Quantity = additionalSeats
|
Quantity = additionalSeats
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (additionalStorageGb > 0)
|
if (additionalStorageGb > 0)
|
||||||
{
|
{
|
||||||
subCreateOptions.Items.Add(new SubscriptionItemOption
|
subCreateOptions.Items.Add(new SubscriptionItemOptions
|
||||||
{
|
{
|
||||||
PlanId = plan.StripeStoragePlanId,
|
Plan = plan.StripeStoragePlanId,
|
||||||
Quantity = additionalStorageGb
|
Quantity = additionalStorageGb
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (premiumAccessAddon && plan.StripePremiumAccessPlanId != null)
|
if (premiumAccessAddon && plan.StripePremiumAccessPlanId != null)
|
||||||
{
|
{
|
||||||
subCreateOptions.Items.Add(new SubscriptionItemOption
|
subCreateOptions.Items.Add(new SubscriptionItemOptions
|
||||||
{
|
{
|
||||||
PlanId = plan.StripePremiumAccessPlanId,
|
Plan = plan.StripePremiumAccessPlanId,
|
||||||
Quantity = 1
|
Quantity = 1
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -303,7 +303,7 @@ namespace Bit.Core.Services
|
|||||||
{
|
{
|
||||||
paymentMethodType = PaymentMethodType.Card;
|
paymentMethodType = PaymentMethodType.Card;
|
||||||
stripePaymentMethod = true;
|
stripePaymentMethod = true;
|
||||||
subCreateOptions.DefaultPaymentMethodId = paymentMethod.Id;
|
subCreateOptions.DefaultPaymentMethod = paymentMethod.Id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -440,11 +440,11 @@ namespace Bit.Core.Services
|
|||||||
Description = user.Name,
|
Description = user.Name,
|
||||||
Email = user.Email,
|
Email = user.Email,
|
||||||
Metadata = stripeCustomerMetadata,
|
Metadata = stripeCustomerMetadata,
|
||||||
PaymentMethodId = stipeCustomerPaymentMethodId,
|
PaymentMethod = stipeCustomerPaymentMethodId,
|
||||||
Source = stipeCustomerSourceToken,
|
Source = stipeCustomerSourceToken,
|
||||||
InvoiceSettings = new CustomerInvoiceSettingsOptions
|
InvoiceSettings = new CustomerInvoiceSettingsOptions
|
||||||
{
|
{
|
||||||
DefaultPaymentMethodId = stipeCustomerPaymentMethodId
|
DefaultPaymentMethod = stipeCustomerPaymentMethodId
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
createdStripeCustomer = true;
|
createdStripeCustomer = true;
|
||||||
@ -457,25 +457,25 @@ namespace Bit.Core.Services
|
|||||||
|
|
||||||
var subCreateOptions = new SubscriptionCreateOptions
|
var subCreateOptions = new SubscriptionCreateOptions
|
||||||
{
|
{
|
||||||
CustomerId = customer.Id,
|
Customer = customer.Id,
|
||||||
Items = new List<SubscriptionItemOption>(),
|
Items = new List<SubscriptionItemOptions>(),
|
||||||
Metadata = new Dictionary<string, string>
|
Metadata = new Dictionary<string, string>
|
||||||
{
|
{
|
||||||
[user.GatewayIdField()] = user.Id.ToString()
|
[user.GatewayIdField()] = user.Id.ToString()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
subCreateOptions.Items.Add(new SubscriptionItemOption
|
subCreateOptions.Items.Add(new SubscriptionItemOptions
|
||||||
{
|
{
|
||||||
PlanId = paymentMethodType == PaymentMethodType.AppleInApp ? PremiumPlanAppleIapId : PremiumPlanId,
|
Plan = paymentMethodType == PaymentMethodType.AppleInApp ? PremiumPlanAppleIapId : PremiumPlanId,
|
||||||
Quantity = 1,
|
Quantity = 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (additionalStorageGb > 0)
|
if (additionalStorageGb > 0)
|
||||||
{
|
{
|
||||||
subCreateOptions.Items.Add(new SubscriptionItemOption
|
subCreateOptions.Items.Add(new SubscriptionItemOptions
|
||||||
{
|
{
|
||||||
PlanId = StoragePlanId,
|
Plan = StoragePlanId,
|
||||||
Quantity = additionalStorageGb
|
Quantity = additionalStorageGb
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -518,7 +518,7 @@ namespace Bit.Core.Services
|
|||||||
{
|
{
|
||||||
var previewInvoice = await invoiceService.UpcomingAsync(new UpcomingInvoiceOptions
|
var previewInvoice = await invoiceService.UpcomingAsync(new UpcomingInvoiceOptions
|
||||||
{
|
{
|
||||||
CustomerId = customer.Id,
|
Customer = customer.Id,
|
||||||
SubscriptionItems = ToInvoiceSubscriptionItemOptions(subCreateOptions.Items)
|
SubscriptionItems = ToInvoiceSubscriptionItemOptions(subCreateOptions.Items)
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -604,7 +604,7 @@ namespace Bit.Core.Services
|
|||||||
{
|
{
|
||||||
var previewInvoice = await invoiceService.UpcomingAsync(new UpcomingInvoiceOptions
|
var previewInvoice = await invoiceService.UpcomingAsync(new UpcomingInvoiceOptions
|
||||||
{
|
{
|
||||||
CustomerId = customer.Id,
|
Customer = customer.Id,
|
||||||
SubscriptionItems = ToInvoiceSubscriptionItemOptions(subCreateOptions.Items)
|
SubscriptionItems = ToInvoiceSubscriptionItemOptions(subCreateOptions.Items)
|
||||||
});
|
});
|
||||||
if (previewInvoice.AmountDue > 0)
|
if (previewInvoice.AmountDue > 0)
|
||||||
@ -630,7 +630,7 @@ namespace Bit.Core.Services
|
|||||||
{
|
{
|
||||||
var invoices = await invoiceService.ListAsync(new InvoiceListOptions
|
var invoices = await invoiceService.ListAsync(new InvoiceListOptions
|
||||||
{
|
{
|
||||||
SubscriptionId = subscription.Id
|
Subscription = subscription.Id
|
||||||
});
|
});
|
||||||
|
|
||||||
var invoice = invoices?.FirstOrDefault();
|
var invoice = invoices?.FirstOrDefault();
|
||||||
@ -687,11 +687,11 @@ namespace Bit.Core.Services
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<InvoiceSubscriptionItemOptions> ToInvoiceSubscriptionItemOptions(
|
private List<InvoiceSubscriptionItemOptions> ToInvoiceSubscriptionItemOptions(
|
||||||
List<SubscriptionItemOption> subItemOptions)
|
List<SubscriptionItemOptions> subItemOptions)
|
||||||
{
|
{
|
||||||
return subItemOptions.Select(si => new InvoiceSubscriptionItemOptions
|
return subItemOptions.Select(si => new InvoiceSubscriptionItemOptions
|
||||||
{
|
{
|
||||||
PlanId = si.PlanId,
|
Plan = si.Plan,
|
||||||
Quantity = si.Quantity
|
Quantity = si.Quantity
|
||||||
}).ToList();
|
}).ToList();
|
||||||
}
|
}
|
||||||
@ -713,7 +713,7 @@ namespace Bit.Core.Services
|
|||||||
.Select(i => new InvoiceSubscriptionItemOptions
|
.Select(i => new InvoiceSubscriptionItemOptions
|
||||||
{
|
{
|
||||||
Id = i.Id,
|
Id = i.Id,
|
||||||
PlanId = i.Plan.Id,
|
Plan = i.Plan.Id,
|
||||||
Quantity = i.Quantity,
|
Quantity = i.Quantity,
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
@ -721,15 +721,15 @@ namespace Bit.Core.Services
|
|||||||
{
|
{
|
||||||
subItemOptions.Add(new InvoiceSubscriptionItemOptions
|
subItemOptions.Add(new InvoiceSubscriptionItemOptions
|
||||||
{
|
{
|
||||||
PlanId = storagePlanId,
|
Plan = storagePlanId,
|
||||||
Quantity = additionalStorage,
|
Quantity = additionalStorage,
|
||||||
});
|
});
|
||||||
subUpdateAction = (prorate) => subscriptionItemService.CreateAsync(
|
subUpdateAction = (prorate) => subscriptionItemService.CreateAsync(
|
||||||
new SubscriptionItemCreateOptions
|
new SubscriptionItemCreateOptions
|
||||||
{
|
{
|
||||||
PlanId = storagePlanId,
|
Plan = storagePlanId,
|
||||||
Quantity = additionalStorage,
|
Quantity = additionalStorage,
|
||||||
SubscriptionId = sub.Id,
|
Subscription = sub.Id,
|
||||||
Prorate = prorate
|
Prorate = prorate
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -738,13 +738,13 @@ namespace Bit.Core.Services
|
|||||||
subItemOptions.Add(new InvoiceSubscriptionItemOptions
|
subItemOptions.Add(new InvoiceSubscriptionItemOptions
|
||||||
{
|
{
|
||||||
Id = storageItem.Id,
|
Id = storageItem.Id,
|
||||||
PlanId = storagePlanId,
|
Plan = storagePlanId,
|
||||||
Quantity = additionalStorage,
|
Quantity = additionalStorage,
|
||||||
});
|
});
|
||||||
subUpdateAction = (prorate) => subscriptionItemService.UpdateAsync(storageItem.Id,
|
subUpdateAction = (prorate) => subscriptionItemService.UpdateAsync(storageItem.Id,
|
||||||
new SubscriptionItemUpdateOptions
|
new SubscriptionItemUpdateOptions
|
||||||
{
|
{
|
||||||
PlanId = storagePlanId,
|
Plan = storagePlanId,
|
||||||
Quantity = additionalStorage,
|
Quantity = additionalStorage,
|
||||||
Prorate = prorate
|
Prorate = prorate
|
||||||
});
|
});
|
||||||
@ -756,7 +756,8 @@ namespace Bit.Core.Services
|
|||||||
Id = storageItem.Id,
|
Id = storageItem.Id,
|
||||||
Deleted = true
|
Deleted = true
|
||||||
});
|
});
|
||||||
subUpdateAction = (prorate) => subscriptionItemService.DeleteAsync(storageItem.Id);
|
subUpdateAction = (prorate) => subscriptionItemService.DeleteAsync(storageItem.Id,
|
||||||
|
new SubscriptionItemDeleteOptions());
|
||||||
}
|
}
|
||||||
|
|
||||||
string paymentIntentClientSecret = null;
|
string paymentIntentClientSecret = null;
|
||||||
@ -819,7 +820,7 @@ namespace Bit.Core.Services
|
|||||||
var chargeService = new ChargeService();
|
var chargeService = new ChargeService();
|
||||||
var charges = await chargeService.ListAsync(new ChargeListOptions
|
var charges = await chargeService.ListAsync(new ChargeListOptions
|
||||||
{
|
{
|
||||||
CustomerId = subscriber.GatewayCustomerId
|
Customer = subscriber.GatewayCustomerId
|
||||||
});
|
});
|
||||||
|
|
||||||
if (charges?.Data != null)
|
if (charges?.Data != null)
|
||||||
@ -827,7 +828,7 @@ namespace Bit.Core.Services
|
|||||||
var refundService = new RefundService();
|
var refundService = new RefundService();
|
||||||
foreach (var charge in charges.Data.Where(c => c.Captured.GetValueOrDefault() && !c.Refunded))
|
foreach (var charge in charges.Data.Where(c => c.Captured.GetValueOrDefault() && !c.Refunded))
|
||||||
{
|
{
|
||||||
await refundService.CreateAsync(new RefundCreateOptions { ChargeId = charge.Id });
|
await refundService.CreateAsync(new RefundCreateOptions { Charge = charge.Id });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -856,14 +857,14 @@ namespace Bit.Core.Services
|
|||||||
|
|
||||||
var pendingInvoiceItems = invoiceItemService.ListAutoPaging(new InvoiceItemListOptions
|
var pendingInvoiceItems = invoiceItemService.ListAutoPaging(new InvoiceItemListOptions
|
||||||
{
|
{
|
||||||
CustomerId = subscriber.GatewayCustomerId
|
Customer = subscriber.GatewayCustomerId
|
||||||
}).ToList().Where(i => i.InvoiceId == null);
|
}).ToList().Where(i => i.InvoiceId == null);
|
||||||
var pendingInvoiceItemsDict = pendingInvoiceItems.ToDictionary(pii => pii.Id);
|
var pendingInvoiceItemsDict = pendingInvoiceItems.ToDictionary(pii => pii.Id);
|
||||||
|
|
||||||
var upcomingPreview = await invoiceService.UpcomingAsync(new UpcomingInvoiceOptions
|
var upcomingPreview = await invoiceService.UpcomingAsync(new UpcomingInvoiceOptions
|
||||||
{
|
{
|
||||||
CustomerId = subscriber.GatewayCustomerId,
|
Customer = subscriber.GatewayCustomerId,
|
||||||
SubscriptionId = subscriber.GatewaySubscriptionId,
|
Subscription = subscriber.GatewaySubscriptionId,
|
||||||
SubscriptionItems = subItemOptions
|
SubscriptionItems = subItemOptions
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -908,8 +909,8 @@ namespace Bit.Core.Services
|
|||||||
{
|
{
|
||||||
Currency = ii.Currency,
|
Currency = ii.Currency,
|
||||||
Description = ii.Description,
|
Description = ii.Description,
|
||||||
CustomerId = subscriber.GatewayCustomerId,
|
Customer = subscriber.GatewayCustomerId,
|
||||||
SubscriptionId = ii.SubscriptionId,
|
Subscription = ii.SubscriptionId,
|
||||||
Discountable = ii.Discountable,
|
Discountable = ii.Discountable,
|
||||||
Amount = ii.Amount
|
Amount = ii.Amount
|
||||||
});
|
});
|
||||||
@ -920,9 +921,9 @@ namespace Bit.Core.Services
|
|||||||
{
|
{
|
||||||
CollectionMethod = "send_invoice",
|
CollectionMethod = "send_invoice",
|
||||||
DaysUntilDue = 1,
|
DaysUntilDue = 1,
|
||||||
CustomerId = subscriber.GatewayCustomerId,
|
Customer = subscriber.GatewayCustomerId,
|
||||||
SubscriptionId = subscriber.GatewaySubscriptionId,
|
Subscription = subscriber.GatewaySubscriptionId,
|
||||||
DefaultPaymentMethodId = cardPaymentMethodId
|
DefaultPaymentMethod = cardPaymentMethodId
|
||||||
});
|
});
|
||||||
|
|
||||||
var invoicePayOptions = new InvoicePayOptions();
|
var invoicePayOptions = new InvoicePayOptions();
|
||||||
@ -970,7 +971,7 @@ namespace Bit.Core.Services
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
invoicePayOptions.OffSession = true;
|
invoicePayOptions.OffSession = true;
|
||||||
invoicePayOptions.PaymentMethodId = cardPaymentMethodId;
|
invoicePayOptions.PaymentMethod = cardPaymentMethodId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1019,8 +1020,8 @@ namespace Bit.Core.Services
|
|||||||
{
|
{
|
||||||
Currency = item.Currency,
|
Currency = item.Currency,
|
||||||
Description = item.Description,
|
Description = item.Description,
|
||||||
CustomerId = item.CustomerId,
|
Customer = item.CustomerId,
|
||||||
SubscriptionId = item.SubscriptionId,
|
Subscription = item.SubscriptionId,
|
||||||
Discountable = item.Discountable,
|
Discountable = item.Discountable,
|
||||||
Metadata = item.Metadata,
|
Metadata = item.Metadata,
|
||||||
Quantity = item.Proration ? 1 : item.Quantity,
|
Quantity = item.Proration ? 1 : item.Quantity,
|
||||||
@ -1324,10 +1325,10 @@ namespace Bit.Core.Services
|
|||||||
Email = subscriber.BillingEmailAddress(),
|
Email = subscriber.BillingEmailAddress(),
|
||||||
Metadata = stripeCustomerMetadata,
|
Metadata = stripeCustomerMetadata,
|
||||||
Source = stipeCustomerSourceToken,
|
Source = stipeCustomerSourceToken,
|
||||||
PaymentMethodId = stipeCustomerPaymentMethodId,
|
PaymentMethod = stipeCustomerPaymentMethodId,
|
||||||
InvoiceSettings = new CustomerInvoiceSettingsOptions
|
InvoiceSettings = new CustomerInvoiceSettingsOptions
|
||||||
{
|
{
|
||||||
DefaultPaymentMethodId = stipeCustomerPaymentMethodId
|
DefaultPaymentMethod = stipeCustomerPaymentMethodId
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1353,7 +1354,7 @@ namespace Bit.Core.Services
|
|||||||
else if (!string.IsNullOrWhiteSpace(stipeCustomerPaymentMethodId))
|
else if (!string.IsNullOrWhiteSpace(stipeCustomerPaymentMethodId))
|
||||||
{
|
{
|
||||||
await paymentMethodService.AttachAsync(stipeCustomerPaymentMethodId,
|
await paymentMethodService.AttachAsync(stipeCustomerPaymentMethodId,
|
||||||
new PaymentMethodAttachOptions { CustomerId = customer.Id });
|
new PaymentMethodAttachOptions { Customer = customer.Id });
|
||||||
defaultPaymentMethodId = stipeCustomerPaymentMethodId;
|
defaultPaymentMethodId = stipeCustomerPaymentMethodId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1372,7 +1373,7 @@ namespace Bit.Core.Services
|
|||||||
|
|
||||||
var cardPaymentMethods = paymentMethodService.ListAutoPaging(new PaymentMethodListOptions
|
var cardPaymentMethods = paymentMethodService.ListAutoPaging(new PaymentMethodListOptions
|
||||||
{
|
{
|
||||||
CustomerId = customer.Id,
|
Customer = customer.Id,
|
||||||
Type = "card"
|
Type = "card"
|
||||||
});
|
});
|
||||||
foreach (var cardMethod in cardPaymentMethods.Where(m => m.Id != defaultPaymentMethodId))
|
foreach (var cardMethod in cardPaymentMethods.Where(m => m.Id != defaultPaymentMethodId))
|
||||||
@ -1386,7 +1387,7 @@ namespace Bit.Core.Services
|
|||||||
DefaultSource = defaultSourceId,
|
DefaultSource = defaultSourceId,
|
||||||
InvoiceSettings = new CustomerInvoiceSettingsOptions
|
InvoiceSettings = new CustomerInvoiceSettingsOptions
|
||||||
{
|
{
|
||||||
DefaultPaymentMethodId = defaultPaymentMethodId
|
DefaultPaymentMethod = defaultPaymentMethodId
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1509,7 +1510,7 @@ namespace Bit.Core.Services
|
|||||||
|
|
||||||
var invoices = await invoiceService.ListAsync(new InvoiceListOptions
|
var invoices = await invoiceService.ListAsync(new InvoiceListOptions
|
||||||
{
|
{
|
||||||
CustomerId = customer.Id,
|
Customer = customer.Id,
|
||||||
Limit = 50
|
Limit = 50
|
||||||
});
|
});
|
||||||
billingInfo.Invoices = invoices.Data.Where(i => i.Status != "void" && i.Status != "draft")
|
billingInfo.Invoices = invoices.Data.Where(i => i.Status != "void" && i.Status != "draft")
|
||||||
@ -1547,7 +1548,7 @@ namespace Bit.Core.Services
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var upcomingInvoice = await invoiceService.UpcomingAsync(
|
var upcomingInvoice = await invoiceService.UpcomingAsync(
|
||||||
new UpcomingInvoiceOptions { CustomerId = subscriber.GatewayCustomerId });
|
new UpcomingInvoiceOptions { Customer = subscriber.GatewayCustomerId });
|
||||||
if (upcomingInvoice != null)
|
if (upcomingInvoice != null)
|
||||||
{
|
{
|
||||||
subscriptionInfo.UpcomingInvoice =
|
subscriptionInfo.UpcomingInvoice =
|
||||||
@ -1565,7 +1566,7 @@ namespace Bit.Core.Services
|
|||||||
{
|
{
|
||||||
var paymentMethodService = new PaymentMethodService();
|
var paymentMethodService = new PaymentMethodService();
|
||||||
var cardPaymentMethods = paymentMethodService.ListAutoPaging(
|
var cardPaymentMethods = paymentMethodService.ListAutoPaging(
|
||||||
new PaymentMethodListOptions { CustomerId = customerId, Type = "card" });
|
new PaymentMethodListOptions { Customer = customerId, Type = "card" });
|
||||||
return cardPaymentMethods.OrderByDescending(m => m.Created).FirstOrDefault();
|
return cardPaymentMethods.OrderByDescending(m => m.Created).FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user