2Checkout / 2checkout-php

2Checkout PHP Library
MIT License
83 stars 66 forks source link

Twocheckout_Sale::stop Recurring item problem #20

Closed ahmetemir closed 8 years ago

ahmetemir commented 8 years ago

In Twocheckoutsale.php

$lineitemData = Twocheckout_Util::getRecurringLineitems($result);
if (isset($lineitemData[0])) {
...
}

If recurring item is not the first line item,it throws "No recurring lineitems to stop".And in my situation array returned from getRecurringLineitems function has index starting from 1.Please replace this line with:

if (count($lineitemData)>0) {

}
craigchristenson commented 8 years ago

Thanks for reporting this issue. The issue has been fixed so that we properly push the lineitems to the array, resulting in the expected index.

umutm commented 5 years ago

This issue still existed for me.

I believe that the getRecurringLineitems function in Twocheckoututil.php was not getting the latest invoice in a sale properly and changing:

$invoice = max($invoiceData); to $invoice = end($invoiceData); in Twocheckoututil.php worked for me.