PayPal, refunds and currency codes, v4.2

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
4 years ago
I have encountered this issue twice now when trying to refund an order that was paid in a foreign currency through either nopCommerce's PayPal Smart Buttons or Express Checkout plugins.

Our primary currency is USD, and what I believe is happening is the OrderTotal (in USD) is being sent along with the foreign currency code, which PayPal then interprets that amount in the foreign currency.  Code snippets below.

For example, this morning's order total was $21.82 USD and customer paid €18.44 EUR.  Trying to refund in full results in this error: "The partial refund amount must be less than or equal to the remaining amount".  I can only assume that PayPal interprets the refundRequest.Amount as €21.82 EUR.

Am I right in one of these approaches?

1) Override the Refund method in OrderProcessingService to convert OrderTotal to the foreign currency before assigning it to request.AmountToRefund

2) Override the Refund method in PayPal's ServiceManager to always use the store's default currency (this is how it's done in Authorize.net : currencyCode = _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode).  I anticipate that PayPal expects the amount in the currency paid though, so 1) above is probably preferable.  

3) Add all the foreign currencies to our PayPal account since we currently only have USD setup : https://www.paypal.com/businesswallet/addcurrency
(though it's not clear to me what they mean by "balance" in their description "When you add a currency, any payments you receive in that currency will be credited to that balance")

code snippets:

orderProcessingService.Refund

            var request = new RefundPaymentRequest();
            try
            {
                request.Order = order;
                request.AmountToRefund = order.OrderTotal;
                request.IsPartialRefund = false;
                result = _paymentService.Refund(request);
                if (result.Success) ...


PayPal's paymentMethod.Refund

var amount = refundPaymentRequest.AmountToRefund != refundPaymentRequest.Order.OrderTotal
                ? (decimal?)refundPaymentRequest.AmountToRefund
                : null;
var (refund, error) = _serviceManager.Refund(refundPaymentRequest.Order.CaptureTransactionId, refundPaymentRequest.Order.CustomerCurrencyCode, amount);
4 years ago
Thanks for the info. We'll check it, here is a work item.
4 years ago
Thanks Romanov, but it very well could be my PayPal account settings.  Here is info on how PayPal holds foreign currencies in a "balance": https://www.paypal.com/us/brc/article/how-to-accept-foreign-currency-with-your-business-account

Can anyone verify that refunds work as expected for foreign currencies if they have that currency added to their PayPal account?
4 years ago
When working with payment services we should always use the primary store currency for all the methods (payment, refund, etc).
We have fixed this bug for the PayPal SmartPaymentButtons plugin, thanks again.
4 years ago
Excellent, thank you!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.