My code is:
public function save_paypal_transaction() {
if ($this->request->is('post')) {
$this->loadModel('PaypalTransaction');
$fields = $this->request->data;
if (!isset($fields['currency'])) {
$fields['currency'] = 'EUR';
}
$this->log($fields);
$res = $this->PaypalTransaction->save($fields);
$this->log(print_r($res, 1));
if ($res) {
echo json_encode(array('status' => 'success'));
} else {
echo json_encode(array('status' => 'error', 'data' => 'Error while saving into db'));
}
} else {
echo json_encode(array('status' => 'error'));
}
}
Then when I check my logs I have:
2015-05-05 13:59:29 Error: Array
(
[transaction_id] => xxxxxxx
[profile_id] => xxxxxx
[item_name] => xxxxxxx
[total_price] => 30.00
[buyer_f_name] => xxxxxxx
[buyer_l_name] => xxxxxxx
[buyer_email] => xxxxxxx@hotmail.com
[date_dt] => 2015-05-05 13:59:29
[user_id] => 0
[currency] => EUR
)
2015-05-05 13:59:29 Error: Array
(
[PaypalTransaction] => Array
(
[transaction_id] => xxxxxxx
[profile_id] => xxxxxxx
[item_name] => xxxxxxx
[total_price] => 30.00
[buyer_f_name] => xxxxxxx
[buyer_l_name] => xxxxxxx
[buyer_email] => xxxxxxx@hotmail.com
[date_dt] => 2015-05-05 13:59:29
[user_id] => 0
[currency] => EUR
[id] => 7807
)
)
By the way, when I check my table, all fields are saved correctly excepts the currency
fields who is empty. This field is : 'currency' CHAR(3) NOT NULL
Any idea why this field is empty in my table on save ?