Skip to content

Allow negative amount for items #1

@engram-design

Description

@engram-design

Having an issue whenever there's a negative item (not line item) in the order - namely a discount. For example, refer to the below cart:

image

The above has a discount set to remove the shipping value from the order, but any discount will do the same thing. Tested with taking a flat $5 off the order.

Trying to pay throws a A negative amount is not allowed..

Drilling into it, it seems mostly an omnipay issue. Refer to Getting the items in the cart, which in turn calls a common method, checking if each item is negative. Give the example above:

Money\Money#1
(
    [Money\Money:amount] => '29595'
    [Money\Money:currency] => Money\Currency#2
    (
        [Money\Currency:code] => 'AUD'
    )
) 
Money\Money#1
(
    [Money\Money:amount] => '1350'
    [Money\Money:currency] => Money\Currency#2
    (
        [Money\Currency:code] => 'AUD'
    )
) 
Money\Money#1
(
    [Money\Money:amount] => '-1350'
    [Money\Money:currency] => Money\Currency#2
    (
        [Money\Currency:code] => 'AUD'
    )
)

Because one value in that is negative, this check ($money->isNegative()) is thrown.

Slightly related to this is thephpleague/omnipay-paypal#198, where the PayPal plugin includes protected $negativeAmountAllowed = true;. I have confirmed adding this the the eway plugin works.

This begs the question though - is this really not an issue for anyone else using this plugin? I would've thought this would've been picked up sooner, so just trying to figure out if I'm doing something wrong. In any case, it would probably require a fork of the omnipay-eway package?

Any ideas @lukeholder or @nfourtythree ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions