Paypal Smart Buttons plugin not working in NopCommerce 4.4

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
2 года назад
I have tried to install Paypal Smart Buttons plugin to NopCommerce 4.4
After the step 5 to select payment method and enter the paypal account, it return to the checkout page but cannot process to "Confirm Order" page. Then the payment and order information will not be saved.

This is working in 4.3 but cannot work in 4.4. I have try to install it into different site but cannot solve this problem...
2 года назад
Any errors in the log ?
2 года назад
No error in bug log.
If I use Live account, it call you Paypal and I choose using VISA. I have got confirmation from VISA by finally not charge.

As attached image, only "BACK" but no "Continue"

2 года назад
For nop 4.4 download PayPal Commerce plugin. Use that instead of Smart Buttons. Try that.
2 года назад
I have try Paypal Commercial, just login my account and got nothing.

But finally, I try using Paypal Standard. It cannot return the payment status at sandbox mode, but it is all ok for live mode. So, I am using Paypal Standard now.
2 года назад
Now I'm having problems with PayPal buttons. Most of the transactions are successful but intermittently some has failed.

I've installed Payments.PayPalCommerce on a  nop 4.404 site and receiving only one error in the logs when a transaction fails. Customer has mentioned the workflow keeps looping back to the checkout/confirm and back again to PayPal. The transaction was not charged. I can't replicate in dev.

Anyone else have this problem?

Log level
Error
Short message
Payments.PayPalCommerce error:
Could not find an order a334957b-f8bb-4029-9e50-a2e28510b266
Full message
Nop.Core.NopException: Could not find an order a334957b-f8bb-4029-9e50-a2e28510b266
   at Nop.Plugin.Payments.PayPalCommerce.Services.ServiceManager.<>c__DisplayClass37_0.<<HandleWebhookAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Nop.Plugin.Payments.PayPalCommerce.Services.ServiceManager.HandleFunctionAsync[TResult](Func`1 function)
IP address
<undisclosed>
Customer
Guest
Page URL
https://www.<undisclosed>.com/plugins/paypalcommerce/webhook
Referrer URL
Created on
1/09/2021 3:05:01 AM
2 года назад
jayc wrote:

Customer has mentioned the workflow keeps looping back to the checkout/confirm and back again to PayPal. The transaction was not charged. .


This is strange, I have not seen such behavior. Perhaps some client errors (so they weren't logged) by PayPal were displayed to the customer.
2 года назад
RomanovM wrote:

This is strange, I have not seen such behavior. Perhaps some client errors (so they weren't logged) by PayPal were displayed to the customer.


The error occured when the paypal commerce plugin is handling the webhook sent from PayPal.
It can't find the order guid to proceed to insert the order notes and proceed to authorize the paypal transaction. Now this concerns me. As it happens way too often on my environment.

For the one page checkout, when I reviewed how the order guid is generated, its saved just after the payment method is selected and also when the opc order is confirmed. There is some logic in the code to keep the same order guid as long as the interval is between the SETTING 'paymentsettings.regenerateorderguidinterval'. This value is defaulted to 180 seconds.

Now the timing of how the order guid is determined whether to use the existing guid or generate a brand new one makes me nervous. I've set the regenerateorderguidinterval value very high and will keep an eye out on any further issues.

You might also want to review the code in PaymentService.cs

The line here I believe causes race conditions.
DateTime.UtcNow - previousPaymentRequest.OrderGuidGeneratedOnUtc.Value;

DateTime.UtcNow relies on the webserver time, what about previousPaymentRequest.OrderGuidGeneratedOnUtc.Value? There would be more a concern if the deployment is running under a web farm.


        /// <summary>
        /// Generate an order GUID
        /// </summary>
        /// <param name="processPaymentRequest">Process payment request</param>
        public virtual void GenerateOrderGuid(ProcessPaymentRequest processPaymentRequest)
        {
            if (processPaymentRequest == null)
                return;

            //we should use the same GUID for multiple payment attempts
            //this way a payment gateway can prevent security issues such as credit card brute-force attacks
            //in order to avoid any possible limitations by payment gateway we reset GUID periodically
            var previousPaymentRequest = _httpContextAccessor.HttpContext.Session.Get<ProcessPaymentRequest>("OrderPaymentInfo");
            if (_paymentSettings.RegenerateOrderGuidInterval > 0 &&
                previousPaymentRequest != null &&
                previousPaymentRequest.OrderGuidGeneratedOnUtc.HasValue)
            {
                var interval = DateTime.UtcNow - previousPaymentRequest.OrderGuidGeneratedOnUtc.Value;
                if (interval.TotalSeconds < _paymentSettings.RegenerateOrderGuidInterval)
                {
                    processPaymentRequest.OrderGuid = previousPaymentRequest.OrderGuid;
                    processPaymentRequest.OrderGuidGeneratedOnUtc = previousPaymentRequest.OrderGuidGeneratedOnUtc;
                }
            }

            if (processPaymentRequest.OrderGuid == Guid.Empty)
            {
                processPaymentRequest.OrderGuid = Guid.NewGuid();
                processPaymentRequest.OrderGuidGeneratedOnUtc = DateTime.UtcNow;
            }
        }
2 года назад
Well, we should take a closer look at this logic. Thanks, here is a work item for this.
2 года назад
RomanovM wrote:
Well, we should take a closer look at this logic. Thanks, here is a work item for this.


To save you sometime, I've had another look at it and it seems the order guid is OK.
In the checkoutcontroller the order guid is set just before an order has been placed by calling
_orderProcessingService.PlaceOrderAsync

There's something happening the the paypal commerce pluging that is causing errors, I just haven't time to figure it out. I've reverted back to the old PayPal smart buttons plugin which has been working flawless on my other site.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.