}
$amounts = DTLC_Util::getDevisAmounts($devis);
+ $error = '';
+
+ $am = round($amounts['ttc'] * 100);
+ $statusesOK = ['AUTHORISED', 'CAPTURED'];
if (
- in_array($response['vads_trans_status'], ['AUTHORISED']) &&
+ in_array($response['vads_trans_status'], $statusesOK) &&
$response['vads_occurrence_type'] === 'UNITAIRE' &&
$response['vads_currency'] == 978 &&
- $response['vads_amount'] == $amounts['ttc'] * 100) {
+ $response['vads_amount'] == $am) {
// Conditions pour valider le paiement
// reponse = 00
// devis EUR
$status = 2;
} else {
$status = 4;
+
+ $e = [];
+ if ($response['vads_amount'] != $am) {
+ $e[] = 'Wrong amount : ' . $response['vads_amount'] . " || " . $am;
+ }
+ if (!in_array($response['vads_trans_status'], $statusesOK)) {
+ $e[] = 'Wrong status : ' . $response['vads_trans_status'];
+ }
+ if ($response['vads_currency'] != 978) {
+ $e[] = 'Wrong currency : ' . $response['vads_currency'];
+ }
+ if ($response['vads_occurrence_type'] !== 'UNITAIRE') {
+ $e[] = 'Wrong occurence type : ' . $response['vads_occurrence_type'];
+ }
+ $error = "\n\n" . implode("\n", $e);
}
- $data = array('infos_paiement' => print_r($response, true), 'date_paiement' => CubeIT_Date::now(), 'status' => $status);
+ $data = array('infos_paiement' => print_r($response, true) . $error, 'date_paiement' => CubeIT_Date::now(), 'status' => $status);
$db->compliantUpdate('devis', $data, array('id = ?' => $devis->id));
if ($status == 2) {