From 532c23d58b0fd09c93ae33d0c600ca62d9ed7e5a Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Thu, 21 Feb 2019 21:08:45 -0500 Subject: [PATCH] ipn updates --- src/Billing/Controllers/PayPalController.cs | 22 +++++++++++++++++++-- src/Billing/Utilities/PayPalIpnClient.cs | 2 ++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/Billing/Controllers/PayPalController.cs b/src/Billing/Controllers/PayPalController.cs index 40c38c6194..90e3a5dc83 100644 --- a/src/Billing/Controllers/PayPalController.cs +++ b/src/Billing/Controllers/PayPalController.cs @@ -186,7 +186,25 @@ namespace Bit.Billing.Controllers } var ipnTransaction = new PayPalIpnClient.IpnTransaction(body); - if(ipnTransaction.ReceiverId != _billingSettings.PayPal.BusinessId || ipnTransaction.McCurrency != "USD") + if(ipnTransaction.ReceiverId != _billingSettings.PayPal.BusinessId) + { + return new BadRequestResult(); + } + + if(ipnTransaction.TxnType != "web_accept" && ipnTransaction.TxnType != "merch_pmt" && + ipnTransaction.PaymentStatus != "Refunded") + { + // Only processing billing agreement payments, buy now button payments, and refunds for now. + return new OkResult(); + } + + if(ipnTransaction.PaymentType == "echeck") + { + // Not accepting eChecks + return new OkResult(); + } + + if(ipnTransaction.McCurrency != "USD") { return new BadRequestResult(); } @@ -197,9 +215,9 @@ namespace Bit.Billing.Controllers return new OkResult(); } - // Only processing credits via IPN for now if(!ipnTransaction.IsAccountCredit()) { + // Only processing credits via IPN for now return new OkResult(); } diff --git a/src/Billing/Utilities/PayPalIpnClient.cs b/src/Billing/Utilities/PayPalIpnClient.cs index 34f8c668cd..44e626fc38 100644 --- a/src/Billing/Utilities/PayPalIpnClient.cs +++ b/src/Billing/Utilities/PayPalIpnClient.cs @@ -78,6 +78,7 @@ namespace Bit.Billing.Utilities TxnType = GetDictValue(dataDict, "txn_type"); ParentTxnId = GetDictValue(dataDict, "parent_txn_id"); PaymentStatus = GetDictValue(dataDict, "payment_status"); + PaymentType = GetDictValue(dataDict, "payment_type"); McCurrency = GetDictValue(dataDict, "mc_currency"); Custom = GetDictValue(dataDict, "custom"); ItemName = GetDictValue(dataDict, "item_name"); @@ -105,6 +106,7 @@ namespace Bit.Billing.Utilities public string TxnType { get; set; } public string ParentTxnId { get; set; } public string PaymentStatus { get; set; } + public string PaymentType { get; set; } public decimal McGross { get; set; } public decimal McFee { get; set; } public string McCurrency { get; set; }