Skip to content

Commit

Permalink
Do not set the lineitem index when returning active recurring lineitems
Browse files Browse the repository at this point in the history
`Twocheckout_Util::getRecurringLineitems` was setting the index on the 
array it returns as it iterated through all lineitems an invoice. This fix insures 
that we are just pushing each active lineitem into the new array. The same 
fix was  also applied to the Twocheckout_Sale::stop method.
  • Loading branch information
Craig Christenson committed Jan 29, 2016
1 parent 22bfc3b commit 7e65356
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 2 additions & 4 deletions lib/Twocheckout/Api/TwocheckoutSale.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,15 @@ public static function stop($params=array()) {
}
$lineitemData = Twocheckout_Util::getRecurringLineitems($result);
if (isset($lineitemData[0])) {
$i = 0;
$stoppedLineitems = array();
foreach( $lineitemData as $value )
{
$params = array('lineitem_id' => $value);
$result = $request->doCall($urlSuffix, $params);
$result = json_decode($result, true);
if ($result['response_code'] == "OK") {
$stoppedLineitems[$i] = $value;
$stoppedLineitems[] = $value;
}
$i++;
}
$result = Twocheckout_Message::message('OK', $stoppedLineitems);
} else {
Expand Down Expand Up @@ -102,4 +100,4 @@ public static function reauth($params=array()) {
return Twocheckout_Util::returnResponse($result);
}

}
}
4 changes: 2 additions & 2 deletions lib/Twocheckout/Api/TwocheckoutUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static function getRecurringLineitems($saleDetail) {

while (isset($invoice['lineitems'][$i])) {
if ($invoice['lineitems'][$i]['billing']['recurring_status'] == "active") {
$lineitemData[$i] = $invoice['lineitems'][$i]['billing']['lineitem_id'];
$lineitemData[] = $invoice['lineitems'][$i]['billing']['lineitem_id'];
}
$i++;
};
Expand All @@ -71,4 +71,4 @@ public static function checkError($contents)
}
}

}
}

0 comments on commit 7e65356

Please sign in to comment.