Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RCP Member Discount getting doubled when checking out with PayPal #7163

Closed
dgoldak opened this issue Feb 15, 2019 · 5 comments
Closed

RCP Member Discount getting doubled when checking out with PayPal #7163

dgoldak opened this issue Feb 15, 2019 · 5 comments
Assignees
Labels

Comments

@dgoldak
Copy link

dgoldak commented Feb 15, 2019

Original issue but determined to be related to PayPal: https://github.com/easydigitaldownloads/edd-rcp-member-discounts/issues/14

Bug Report

Expected behavior

When a RCP member discount is applied, checkout using PayPal should charge the expected total.

Actual behavior

PayPal either changed the wrong amount or we get error:
Things don't appear to be working at the moment. Please try again later.

  1. What appears to be happening is the discount is getting doubled. Therefore the error is caused by the error being $0. You can confirm this by adding an item to cart that isn't eligible for RCP discount.
  2. If the incorrect total is $1 or more, PayPal Pro will process the payment but at the wrong price. PayPal Standard will fail, I assume due to the EDD price not matching the PayPal price.

I'm not able to replicate PayPal Pro myself due to sandbox issues but here is a screenshot from the customer:
screenshot-2018-12-06-at-04-39-21
screenshot-2018-12-06-at-04-40-14

In the screenshot, you can see that the Discount in PayPal is wrong, $7 instead of $3.50.

Steps to reproduce the behavior

  1. Setup a RCP Member Discount at 50%.
  2. Log in as RCP member
  3. Add download to cart, member discount should be applied
  4. Checkout with PayPal Standard
  5. Should be redirected to PayPal to process payment - with no errors.
  6. Confirm payment in complete in EDD
  7. Confirm PayPal amount & discount is correct
  8. Repete steps with PayPal Pro

Information:

PHP Version: 7.1

EDD RCP Member Discounts Version (or branch): master

EDD Version (or branch): master

WordPress Version: 5.0

Any other relevant information: Originally reported by a customer.
https://secure.helpscout.net/conversation/718764724/95475?folderId=1847242

Tested with Stripe which works as expected, this issue appears to be specific to PayPal.

@dgoldak
Copy link
Author

dgoldak commented Feb 15, 2019

@misulicus discovered the following:

Replicated with a standard EDD product of 4.99 and a member discount of 10%
On checkout page price is correct: Purchase Total: $4.49
But once you reach the PayPal page the price goes to $3.99. Discounted for $1 instead of $0.50

Did some debugging in paypal stadard and on these lines is where the discount gets set to $1
https://github.com/easydigitaldownloads/easy-digital-downloads/blob/master/includes/gateways/paypal-standard.php#L296-L301

this is my testing block

       if( $paypal_sum > $purchase_data['price'] ) {
            var_dump( $paypal_args['discount_amount_cart'] );
            $difference = round( $paypal_sum - $purchase_data['price'], 2 );
            var_dump( $difference );
            if( ! isset( $paypal_args['discount_amount_cart'] ) ) {
                $paypal_args['discount_amount_cart'] = 0;
            }
            $paypal_args['discount_amount_cart'] += $difference;
        }
var_dump($paypal_args['discount_amount_cart']);exit;

and that returns string(4) "0.50" float(0.5) float(1)

so $paypal_args['discount_amount_cart'] = "0.50" at the top then $difference = 0.5 and then at the end $paypal_args['discount_amount_cart'] += $difference; adds them so it turns to 1

@cklosowski
Copy link
Contributor

@dgoldak Can you replicate without member discounts but using Discounts Pro or something that adds a negative fee to it?

@dgoldak
Copy link
Author

dgoldak commented Feb 19, 2019

@cklosowski I confirmed Discounts Pro works properly with PayPal:
screen shot 2019-02-19 at 5 14 34 pm

@dgoldak
Copy link
Author

dgoldak commented Mar 14, 2019

Tested PayPal Express 1.4.4 & master and this issue doesn't appear to be affect Express. Order processes successfully with the correct amount.

@ashleyfae
Copy link
Contributor

Closing this in favour of #6837 . Pretty sure it's the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants