mirror of
https://github.com/bitwarden/server
synced 2026-01-07 19:13:50 +00:00
[PM-7452] Handle PayPal for premium users (#4835)
* Add PremiumUserSale * Add PremiumUserBillingService * Integrate into UserService behind FF * Update invoice.created handler to bill newly created PayPal customers * Run dotnet format
This commit is contained in:
49
src/Core/Billing/Models/Sales/PremiumUserSale.cs
Normal file
49
src/Core/Billing/Models/Sales/PremiumUserSale.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using Bit.Core.Entities;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Models.Business;
|
||||
|
||||
namespace Bit.Core.Billing.Models.Sales;
|
||||
|
||||
#nullable enable
|
||||
|
||||
public class PremiumUserSale
|
||||
{
|
||||
private PremiumUserSale() { }
|
||||
|
||||
public required User User { get; set; }
|
||||
public required CustomerSetup CustomerSetup { get; set; }
|
||||
public short? Storage { get; set; }
|
||||
|
||||
public void Deconstruct(
|
||||
out User user,
|
||||
out CustomerSetup customerSetup,
|
||||
out short? storage)
|
||||
{
|
||||
user = User;
|
||||
customerSetup = CustomerSetup;
|
||||
storage = Storage;
|
||||
}
|
||||
|
||||
public static PremiumUserSale From(
|
||||
User user,
|
||||
PaymentMethodType paymentMethodType,
|
||||
string paymentMethodToken,
|
||||
TaxInfo taxInfo,
|
||||
short? storage)
|
||||
{
|
||||
var tokenizedPaymentSource = new TokenizedPaymentSource(paymentMethodType, paymentMethodToken);
|
||||
|
||||
var taxInformation = TaxInformation.From(taxInfo);
|
||||
|
||||
return new PremiumUserSale
|
||||
{
|
||||
User = user,
|
||||
CustomerSetup = new CustomerSetup
|
||||
{
|
||||
TokenizedPaymentSource = tokenizedPaymentSource,
|
||||
TaxInformation = taxInformation
|
||||
},
|
||||
Storage = storage
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Stripe;
|
||||
using Bit.Core.Models.Business;
|
||||
using Stripe;
|
||||
|
||||
namespace Bit.Core.Billing.Models;
|
||||
|
||||
@@ -11,6 +12,15 @@ public record TaxInformation(
|
||||
string City,
|
||||
string State)
|
||||
{
|
||||
public static TaxInformation From(TaxInfo taxInfo) => new(
|
||||
taxInfo.BillingAddressCountry,
|
||||
taxInfo.BillingAddressPostalCode,
|
||||
taxInfo.TaxIdNumber,
|
||||
taxInfo.BillingAddressLine1,
|
||||
taxInfo.BillingAddressLine2,
|
||||
taxInfo.BillingAddressCity,
|
||||
taxInfo.BillingAddressState);
|
||||
|
||||
public (AddressOptions, List<CustomerTaxIdDataOptions>) GetStripeOptions()
|
||||
{
|
||||
var address = new AddressOptions
|
||||
|
||||
Reference in New Issue
Block a user