awesomemotive / easy-digital-downloads

Sell digital downloads through WordPress
https://easydigitaldownloads.com
GNU General Public License v2.0
863 stars 475 forks source link

Wrong gateway for 100% discounted product #8777

Open dalguji opened 2 years ago

dalguji commented 2 years ago

Bug Report

Expected behavior

When I put a product in EDD cart and apply a 100% discount coupon to it so the total price becomes 0, I expect it goes to 'manual' gateway.

Actual behavior

It goes to a credit card gateway and the purchase gets denied by the PG because the payment amount is 0.

Steps to reproduce the behavior

1) Create a 100% discount coupon. 2) Put any product in EDD cart 3) Apply a 100% discount coupon to the product. 4) Click 'Purchase' button

Information (if a specific version is affected):

PHP Version: 7.3

EDD Version (or branch): 2.10.1

WordPress Version: 5.7

Any other relevant information: I suggest to change edd_get_cart_subtotal() to edd_get_cart_total() on the line below: https://github.com/easydigitaldownloads/easy-digital-downloads/blob/5657a2b4355874b30a2a08d0b79162a739f609ef/includes/gateways/functions.php#L374

ashleyfae commented 2 years ago

Which payment gateway are you using?

dalguji commented 2 years ago

I am using this one: https://wordpress.org/plugins/iamport-for-easy-digital-downloads/

ashleyfae commented 2 years ago

That might be an issue you need to report to that developer. Right now we handle this logic inside the gateway, and all our own internal gateways process $0 payments via manual. So unless it can be reproduced via a built-in gateway, you'll have to report the bug to the gateway developer.

dalguji commented 2 years ago

My understanding is that if a product costs $10 and discount is 100%, the subtotal price will be $10 and the total price will be $0. $0 payments in total should be processed by manual gateway.

However the code below is missing to check the total price, it only checks subtotal price when choosing the gateway in function edd_get_chosen_gateway():

https://github.com/easydigitaldownloads/easy-digital-downloads/blob/5657a2b4355874b30a2a08d0b79162a739f609ef/includes/gateways/functions.php#L374-L376

https://github.com/easydigitaldownloads/easy-digital-downloads/blob/5657a2b4355874b30a2a08d0b79162a739f609ef/includes/gateways/functions.php#L348-L349

That's why I opened this issue. If I am misunderstanding something, could you please shed more light on this?