Total transaction amount with Sagepay official PHP Integration Kit -


using official sagepay php integration kit protocol 3.0 there doesn't appear way set total transaction amount. total value of transaction calculated according items within basket added using sagepaybasket->additem(sagepayitem $item) method.

basic setup this:

$config = sagepaysettings::getinstance($configs,true); $api = sagepayapifactory::create('server', $config); $basket = new sagepaybasket(); 

you can add items:

$item = new sagepayitem(); $item->setdescription($oproduct['oc_item_title']); $item->setunittaxamount($oproduct['oc_item_vat']); $item->setquantity($oproduct['oc_qty']); $item->setunitnetamount(($oproduct['oc_net_item_price'])); $basket->additem($item); 

you can add shipping info:

$basket->setdeliverynetamount($order['shipping_cost_net']); $basket->setdeliverytaxamount($order['shipping_cost_vat']); 

however, basket total dependent on discounts. can add discounts basket using:

$discounts = [     'discount' => [         'fixed'         =>  $order['voucher_discount'],         'description'   =>  'voucher discount'     ] ]; $basket->setdiscounts($discounts); 

however, data ignored in total calculation. means amount passed sagepay incorrect.

this can seen looking @ basket.php lacks call $basket->getdiscounts method:

public function getamount() {     $amount = $this->getdeliverygrossamount();     foreach ($this->_items $item)     {         $amount += $item->gettotalgrossamount();     }     return $amount; } 

when make call sagepay data correctly identify line totals not add correctly amount sent sending response:

statusdetail=3195 : line item amount details not add correctly

the option here make work modify library seems wrong there no other option can see. i've posted here list "support forum" either sagepay see or else developer has used code might point out i'm going wrong.

in short - don't use kit. it's not intended production according sagepay and, such, there's no intention catch these kinds of issues.


Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -