mirror of
https://github.com/bitwarden/server
synced 2025-12-31 07:33:43 +00:00
rename to PayPal
This commit is contained in:
@@ -6,9 +6,9 @@
|
||||
public virtual string StripeWebhookKey { get; set; }
|
||||
public virtual string StripeWebhookSecret { get; set; }
|
||||
public virtual string BraintreeWebhookKey { get; set; }
|
||||
public virtual PaypalSettings Paypal { get; set; } = new PaypalSettings();
|
||||
public virtual PayPalSettings PayPal { get; set; } = new PayPalSettings();
|
||||
|
||||
public class PaypalSettings
|
||||
public class PayPalSettings
|
||||
{
|
||||
public virtual bool Production { get; set; }
|
||||
public virtual string ClientId { get; set; }
|
||||
|
||||
@@ -11,15 +11,15 @@ using System.Threading.Tasks;
|
||||
namespace Bit.Billing.Controllers
|
||||
{
|
||||
[Route("paypal")]
|
||||
public class PaypalController : Controller
|
||||
public class PayPalController : Controller
|
||||
{
|
||||
private readonly BillingSettings _billingSettings;
|
||||
private readonly PaypalClient _paypalClient;
|
||||
private readonly PayPalClient _paypalClient;
|
||||
private readonly ITransactionRepository _transactionRepository;
|
||||
|
||||
public PaypalController(
|
||||
public PayPalController(
|
||||
IOptions<BillingSettings> billingSettings,
|
||||
PaypalClient paypalClient,
|
||||
PayPalClient paypalClient,
|
||||
ITransactionRepository transactionRepository)
|
||||
{
|
||||
_billingSettings = billingSettings?.Value;
|
||||
@@ -47,7 +47,7 @@ namespace Bit.Billing.Controllers
|
||||
}
|
||||
|
||||
var verified = await _paypalClient.VerifyWebhookAsync(body, HttpContext.Request.Headers,
|
||||
_billingSettings.Paypal.WebhookId);
|
||||
_billingSettings.PayPal.WebhookId);
|
||||
if(!verified)
|
||||
{
|
||||
return new BadRequestResult();
|
||||
@@ -55,7 +55,7 @@ namespace Bit.Billing.Controllers
|
||||
|
||||
if(body.Contains("\"PAYMENT.SALE.COMPLETED\""))
|
||||
{
|
||||
var ev = JsonConvert.DeserializeObject<PaypalClient.Event<PaypalClient.Sale>>(body);
|
||||
var ev = JsonConvert.DeserializeObject<PayPalClient.Event<PayPalClient.Sale>>(body);
|
||||
var sale = ev.Resource;
|
||||
var saleTransaction = await _transactionRepository.GetByGatewayIdAsync(
|
||||
GatewayType.PayPal, sale.Id);
|
||||
@@ -80,7 +80,7 @@ namespace Bit.Billing.Controllers
|
||||
}
|
||||
else if(body.Contains("\"PAYMENT.SALE.REFUNDED\""))
|
||||
{
|
||||
var ev = JsonConvert.DeserializeObject<PaypalClient.Event<PaypalClient.Refund>>(body);
|
||||
var ev = JsonConvert.DeserializeObject<PayPalClient.Event<PayPalClient.Refund>>(body);
|
||||
var refund = ev.Resource;
|
||||
var refundTransaction = await _transactionRepository.GetByGatewayIdAsync(
|
||||
GatewayType.PayPal, refund.Id);
|
||||
|
||||
@@ -39,8 +39,8 @@ namespace Bit.Billing
|
||||
// Repositories
|
||||
services.AddSqlServerRepositories(globalSettings);
|
||||
|
||||
// Paypal Client
|
||||
services.AddSingleton<Utilities.PaypalClient>();
|
||||
// PayPal Client
|
||||
services.AddSingleton<Utilities.PayPalClient>();
|
||||
|
||||
// Context
|
||||
services.AddScoped<CurrentContext>();
|
||||
|
||||
@@ -9,7 +9,7 @@ using Newtonsoft.Json;
|
||||
|
||||
namespace Bit.Billing.Utilities
|
||||
{
|
||||
public class PaypalClient
|
||||
public class PayPalClient
|
||||
{
|
||||
private readonly HttpClient _httpClient = new HttpClient();
|
||||
private readonly string _baseApiUrl;
|
||||
@@ -18,12 +18,12 @@ namespace Bit.Billing.Utilities
|
||||
|
||||
private AuthResponse _authResponse;
|
||||
|
||||
public PaypalClient(BillingSettings billingSettings)
|
||||
public PayPalClient(BillingSettings billingSettings)
|
||||
{
|
||||
_baseApiUrl = _baseApiUrl = !billingSettings.Paypal.Production ? "https://api.sandbox.paypal.com/{0}" :
|
||||
_baseApiUrl = _baseApiUrl = !billingSettings.PayPal.Production ? "https://api.sandbox.paypal.com/{0}" :
|
||||
"https://api.paypal.com/{0}";
|
||||
_clientId = billingSettings.Paypal.ClientId;
|
||||
_clientSecret = billingSettings.Paypal.ClientSecret;
|
||||
_clientId = billingSettings.PayPal.ClientId;
|
||||
_clientSecret = billingSettings.PayPal.ClientSecret;
|
||||
}
|
||||
|
||||
public async Task<bool> VerifyWebhookAsync(string webhookJson, IHeaderDictionary headers, string webhookId)
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
}
|
||||
},
|
||||
"billingSettings": {
|
||||
"paypal": {
|
||||
"payPal": {
|
||||
"production": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
"stripeWebhookKey": "SECRET",
|
||||
"stripeWebhookSecret": "SECRET",
|
||||
"braintreeWebhookKey": "SECRET",
|
||||
"paypal": {
|
||||
"payPal": {
|
||||
"production": false,
|
||||
"clientId": "SECRET",
|
||||
"clientSecret": "SECRET",
|
||||
|
||||
Reference in New Issue
Block a user