mirror of
https://github.com/bitwarden/server.git
synced 2025-05-23 04:21:05 -05:00
rename to PayPal
This commit is contained in:
parent
44630e9728
commit
a5044b6e6c
@ -6,9 +6,9 @@
|
|||||||
public virtual string StripeWebhookKey { get; set; }
|
public virtual string StripeWebhookKey { get; set; }
|
||||||
public virtual string StripeWebhookSecret { get; set; }
|
public virtual string StripeWebhookSecret { get; set; }
|
||||||
public virtual string BraintreeWebhookKey { 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 bool Production { get; set; }
|
||||||
public virtual string ClientId { get; set; }
|
public virtual string ClientId { get; set; }
|
||||||
|
@ -11,15 +11,15 @@ using System.Threading.Tasks;
|
|||||||
namespace Bit.Billing.Controllers
|
namespace Bit.Billing.Controllers
|
||||||
{
|
{
|
||||||
[Route("paypal")]
|
[Route("paypal")]
|
||||||
public class PaypalController : Controller
|
public class PayPalController : Controller
|
||||||
{
|
{
|
||||||
private readonly BillingSettings _billingSettings;
|
private readonly BillingSettings _billingSettings;
|
||||||
private readonly PaypalClient _paypalClient;
|
private readonly PayPalClient _paypalClient;
|
||||||
private readonly ITransactionRepository _transactionRepository;
|
private readonly ITransactionRepository _transactionRepository;
|
||||||
|
|
||||||
public PaypalController(
|
public PayPalController(
|
||||||
IOptions<BillingSettings> billingSettings,
|
IOptions<BillingSettings> billingSettings,
|
||||||
PaypalClient paypalClient,
|
PayPalClient paypalClient,
|
||||||
ITransactionRepository transactionRepository)
|
ITransactionRepository transactionRepository)
|
||||||
{
|
{
|
||||||
_billingSettings = billingSettings?.Value;
|
_billingSettings = billingSettings?.Value;
|
||||||
@ -47,7 +47,7 @@ namespace Bit.Billing.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
var verified = await _paypalClient.VerifyWebhookAsync(body, HttpContext.Request.Headers,
|
var verified = await _paypalClient.VerifyWebhookAsync(body, HttpContext.Request.Headers,
|
||||||
_billingSettings.Paypal.WebhookId);
|
_billingSettings.PayPal.WebhookId);
|
||||||
if(!verified)
|
if(!verified)
|
||||||
{
|
{
|
||||||
return new BadRequestResult();
|
return new BadRequestResult();
|
||||||
@ -55,7 +55,7 @@ namespace Bit.Billing.Controllers
|
|||||||
|
|
||||||
if(body.Contains("\"PAYMENT.SALE.COMPLETED\""))
|
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 sale = ev.Resource;
|
||||||
var saleTransaction = await _transactionRepository.GetByGatewayIdAsync(
|
var saleTransaction = await _transactionRepository.GetByGatewayIdAsync(
|
||||||
GatewayType.PayPal, sale.Id);
|
GatewayType.PayPal, sale.Id);
|
||||||
@ -80,7 +80,7 @@ namespace Bit.Billing.Controllers
|
|||||||
}
|
}
|
||||||
else if(body.Contains("\"PAYMENT.SALE.REFUNDED\""))
|
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 refund = ev.Resource;
|
||||||
var refundTransaction = await _transactionRepository.GetByGatewayIdAsync(
|
var refundTransaction = await _transactionRepository.GetByGatewayIdAsync(
|
||||||
GatewayType.PayPal, refund.Id);
|
GatewayType.PayPal, refund.Id);
|
||||||
|
@ -39,8 +39,8 @@ namespace Bit.Billing
|
|||||||
// Repositories
|
// Repositories
|
||||||
services.AddSqlServerRepositories(globalSettings);
|
services.AddSqlServerRepositories(globalSettings);
|
||||||
|
|
||||||
// Paypal Client
|
// PayPal Client
|
||||||
services.AddSingleton<Utilities.PaypalClient>();
|
services.AddSingleton<Utilities.PayPalClient>();
|
||||||
|
|
||||||
// Context
|
// Context
|
||||||
services.AddScoped<CurrentContext>();
|
services.AddScoped<CurrentContext>();
|
||||||
|
@ -9,7 +9,7 @@ using Newtonsoft.Json;
|
|||||||
|
|
||||||
namespace Bit.Billing.Utilities
|
namespace Bit.Billing.Utilities
|
||||||
{
|
{
|
||||||
public class PaypalClient
|
public class PayPalClient
|
||||||
{
|
{
|
||||||
private readonly HttpClient _httpClient = new HttpClient();
|
private readonly HttpClient _httpClient = new HttpClient();
|
||||||
private readonly string _baseApiUrl;
|
private readonly string _baseApiUrl;
|
||||||
@ -18,12 +18,12 @@ namespace Bit.Billing.Utilities
|
|||||||
|
|
||||||
private AuthResponse _authResponse;
|
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}";
|
"https://api.paypal.com/{0}";
|
||||||
_clientId = billingSettings.Paypal.ClientId;
|
_clientId = billingSettings.PayPal.ClientId;
|
||||||
_clientSecret = billingSettings.Paypal.ClientSecret;
|
_clientSecret = billingSettings.PayPal.ClientSecret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> VerifyWebhookAsync(string webhookJson, IHeaderDictionary headers, string webhookId)
|
public async Task<bool> VerifyWebhookAsync(string webhookJson, IHeaderDictionary headers, string webhookId)
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"billingSettings": {
|
"billingSettings": {
|
||||||
"paypal": {
|
"payPal": {
|
||||||
"production": false
|
"production": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@
|
|||||||
"stripeWebhookKey": "SECRET",
|
"stripeWebhookKey": "SECRET",
|
||||||
"stripeWebhookSecret": "SECRET",
|
"stripeWebhookSecret": "SECRET",
|
||||||
"braintreeWebhookKey": "SECRET",
|
"braintreeWebhookKey": "SECRET",
|
||||||
"paypal": {
|
"payPal": {
|
||||||
"production": false,
|
"production": false,
|
||||||
"clientId": "SECRET",
|
"clientId": "SECRET",
|
||||||
"clientSecret": "SECRET",
|
"clientSecret": "SECRET",
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
United = 11,
|
United = 11,
|
||||||
Yahoo = 12,
|
Yahoo = 12,
|
||||||
Zonelabs = 13,
|
Zonelabs = 13,
|
||||||
Paypal = 14,
|
PayPal = 14,
|
||||||
Avon = 15,
|
Avon = 15,
|
||||||
Diapers = 16,
|
Diapers = 16,
|
||||||
Contacts = 17,
|
Contacts = 17,
|
||||||
|
@ -26,7 +26,7 @@ namespace Bit.Core.Utilities
|
|||||||
GlobalDomains.Add(GlobalEquivalentDomainsType.United, new List<string> { "ua2go.com", "ual.com", "united.com", "unitedwifi.com" });
|
GlobalDomains.Add(GlobalEquivalentDomainsType.United, new List<string> { "ua2go.com", "ual.com", "united.com", "unitedwifi.com" });
|
||||||
GlobalDomains.Add(GlobalEquivalentDomainsType.Yahoo, new List<string> { "overture.com", "yahoo.com", "flickr.com" });
|
GlobalDomains.Add(GlobalEquivalentDomainsType.Yahoo, new List<string> { "overture.com", "yahoo.com", "flickr.com" });
|
||||||
GlobalDomains.Add(GlobalEquivalentDomainsType.Zonelabs, new List<string> { "zonealarm.com", "zonelabs.com" });
|
GlobalDomains.Add(GlobalEquivalentDomainsType.Zonelabs, new List<string> { "zonealarm.com", "zonelabs.com" });
|
||||||
GlobalDomains.Add(GlobalEquivalentDomainsType.Paypal, new List<string> { "paypal.com", "paypal-search.com" });
|
GlobalDomains.Add(GlobalEquivalentDomainsType.PayPal, new List<string> { "paypal.com", "paypal-search.com" });
|
||||||
GlobalDomains.Add(GlobalEquivalentDomainsType.Avon, new List<string> { "avon.com", "youravon.com" });
|
GlobalDomains.Add(GlobalEquivalentDomainsType.Avon, new List<string> { "avon.com", "youravon.com" });
|
||||||
GlobalDomains.Add(GlobalEquivalentDomainsType.Diapers, new List<string> { "diapers.com", "soap.com", "wag.com", "yoyo.com", "beautybar.com", "casa.com", "afterschool.com", "vine.com", "bookworm.com", "look.com", "vinemarket.com" });
|
GlobalDomains.Add(GlobalEquivalentDomainsType.Diapers, new List<string> { "diapers.com", "soap.com", "wag.com", "yoyo.com", "beautybar.com", "casa.com", "afterschool.com", "vine.com", "bookworm.com", "look.com", "vinemarket.com" });
|
||||||
GlobalDomains.Add(GlobalEquivalentDomainsType.Contacts, new List<string> { "1800contacts.com", "800contacts.com" });
|
GlobalDomains.Add(GlobalEquivalentDomainsType.Contacts, new List<string> { "1800contacts.com", "800contacts.com" });
|
||||||
|
Loading…
x
Reference in New Issue
Block a user