Store payment id inside checkout - if enabled in parameters and there is only one valid payment, it can be directly stored
But then the cart needs to be reloaded to store the costs of the payment and make ready for payment (payment gets info about payment because of rules)
Parameters
/**
* Store payment id inside checkout - if enabled in parameters and there is only one valid payment, it can be directly stored
* But then the cart needs to be reloaded to store the costs of the payment and make ready for payment (payment gets info about payment because of rules)
* @param $paymentId
* @param $userId
*/
public function storePaymentRegistered($paymentId, $userId)
{
$row = Table::getInstance('PhocacartCart', 'Table');
if ((int) $userId > 0) {
if (!$row->load(array('user_id' => (int) $userId, 'vendor_id' => 0, 'ticket_id' => 0, 'unit_id' => 0, 'section_id' => 0))) {
return false;
// there must be some info in cart yet
}
}
if (!empty($row->cart)) {
$data['payment'] = (int) $paymentId;
$data['user_id'] = (int) $userId;
$data['payment'] = (int) $paymentId;
//$data['coupon'] = // Not set when automatically adding;
//$data['reward'] = // Not set when automatically adding;
if (!$row->bind($data)) {
$this->setError($row->getError());
return false;
}
$row->date = gmdate('Y-m-d H:i:s');
if (!$row->check()) {
$this->setError($row->getError());
return false;
}
if (!$row->store()) {
$this->setError($row->getError());
return false;
}
return (int) $paymentId;
}
return false;
}