1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-16 23:27:30 -05:00

handle transactions on paypal webhook

This commit is contained in:
Kyle Spearrin
2019-02-01 22:22:08 -05:00
parent f3b5068aba
commit 44630e9728
11 changed files with 211 additions and 8 deletions

View File

@ -13,6 +13,8 @@ namespace Bit.Core.Enums
[Display(Name = "Google Play Store")]
PlayStore = 3,
[Display(Name = "Coinbase")]
Coinbase = 4
Coinbase = 4,
[Display(Name = "PayPal")]
PayPal = 1,
}
}

View File

@ -5,6 +5,7 @@
Charge = 0,
Credit = 1,
PromotionalCredit = 2,
ReferralCredit = 3
ReferralCredit = 3,
Refund = 4,
}
}

View File

@ -17,7 +17,7 @@ namespace Bit.Core.Models.Table
public PaymentMethodType? PaymentMethodType { get; set; }
public GatewayType? Gateway { get; set; }
public string GatewayId { get; set; }
public DateTime CreationDate { get; internal set; } = DateTime.UtcNow;
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public void SetNewId()
{

View File

@ -2,6 +2,7 @@
using Bit.Core.Models.Table;
using System.Collections.Generic;
using System.Threading.Tasks;
using Bit.Core.Enums;
namespace Bit.Core.Repositories
{
@ -9,5 +10,6 @@ namespace Bit.Core.Repositories
{
Task<ICollection<Transaction>> GetManyByUserIdAsync(Guid userId);
Task<ICollection<Transaction>> GetManyByOrganizationIdAsync(Guid organizationId);
Task<Transaction> GetByGatewayIdAsync(GatewayType gatewayType, string gatewayId);
}
}

View File

@ -6,6 +6,7 @@ using Dapper;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using Bit.Core.Enums;
namespace Bit.Core.Repositories.SqlServer
{
@ -44,5 +45,18 @@ namespace Bit.Core.Repositories.SqlServer
return results.ToList();
}
}
public async Task<Transaction> GetByGatewayIdAsync(GatewayType gatewayType, string gatewayId)
{
using(var connection = new SqlConnection(ConnectionString))
{
var results = await connection.QueryAsync<Transaction>(
$"[{Schema}].[Transaction_ReadByGatewayId]",
new { Gateway = gatewayType, GatewayId = gatewayId },
commandType: CommandType.StoredProcedure);
return results.SingleOrDefault();
}
}
}
}