It is not possible to checkout an order with discount line items (amount < 0) with CyberSouce gateway.

CyberSource replies that some items have an invalid unit price field.

Comments

jherencia’s picture

Category: task » bug
jherencia’s picture

Status: Active » Needs review
StatusFileSize
new1.19 KB

This patch might fix this issue.

rszrama’s picture

Issue tags: +ubercamp sprint
Rainman’s picture

Thank You for this patch, fixed (same) issue using uc_coupon.

Rainman’s picture

Well it appeared working at first testing with coupons, but when processing without (using a coupon) it threw uc_order into a loop until it timed out. I did the following modify to fix that issue, it appears that count($order->line_items) does not work as expected.

Code replaced:

   for ($i = 0; (i < count($order->line_items)) && !$discount_line_items; $i++) {
     $line_item = $order->line_items[$i];
     if ($line_item['amount'] < 0)
       $discount_line_items = true;

Replaced with:

     if (is_array($order->line_items)) {
       foreach ($order->line_items as $key => $value) {
         if (($value['amount'] < 0) && !$discount_line_items)
       $discount_line_items = true;
     }
tr’s picture

Version: 6.x-2.0-rc3 » 6.x-2.x-dev
Status: Needs review » Needs work

#5 indicates that the patch doesn't work properly. Need a new patch and a review before this can move forward.

Rainman’s picture

It's been so long I don't remember exactly what it was, but I found more situations that caused glitches with it too, so ended up removing the whole line item part.

What I have running now that does work is removed the whole conditional section starting at line 549 and replaced with

    $purchaseTotals->grandTotalAmount = $amount;
    $request->purchaseTotals = $purchaseTotals;

Cybersource is picky about line items. by only submitting the total, it never sees the details.. nor does it have a need to know in my case anyhow.

I suppose a more elegant solution than hacking all that out would be to have an option to only submit order total, I think I have seen that in other payment modules.

wodenx’s picture

wodenx’s picture

Status: Needs work » Needs review
StatusFileSize
new1.24 KB

Here is the patch from that issue - guess I need to post it here so it can be tested.

Status: Needs review » Needs work
Issue tags: -ubercamp sprint

The last submitted patch, 1321904-cybersource-negative-line-items.patch, failed testing.

wodenx’s picture

Status: Needs work » Needs review
Issue tags: +ubercamp sprint
wodenx’s picture

Dunno why it failed before - didn't change anything, and the fail was in a totally unrelated area.

longwave’s picture

Issue tags: -ubercamp sprint

Looks okay to me, but needs confirmation from someone who uses CyberSource before commit.

wodenx’s picture

Had some confirmation in the uc_coupon queue at #1321904: CyberSource Checkout fails with UC Coupon #4.

longwave’s picture

Status: Needs review » Fixed

Committed to both branches.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.