-
Notifications
You must be signed in to change notification settings - Fork 0
/
call_autoresponse.php
145 lines (116 loc) · 6.58 KB
/
call_autoresponse.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<!--
-------------------------------------------------------------
Topic : Exemple PHP traitement de l'autoréponse de paiement
Version : P615
Dans cet exemple, les données de la transaction sont
décryptées et sauvegardées dans un fichier log.
-------------------------------------------------------------
-->
<?php
include("config.php");
// Récupération de la variable cryptée DATA
$message="message=$HTTP_POST_VARS[DATA]";
// Initialisation du chemin du fichier pathfile (à modifier)
// ex :
// -> Windows : $pathfile="pathfile=c:/repertoire/pathfile"
// -> Unix : $pathfile="pathfile=/home/repertoire/pathfile"
$pathfile="pathfile=http://reserveruncab.com/sogenactif/param/pathfile";
//Initialisation du chemin de l'executable response (à modifier)
//ex :
//-> Windows : $path_bin = "c:/repertoire/bin/response"
//-> Unix : $path_bin = "/home/repertoire/bin/response"
//
$path_bin = "http://reserveruncab.com/sogenactif/bin/static/response";
// Appel du binaire response
$message = escapeshellcmd($message);
$result=exec("$path_bin $pathfile $message");
// Sortie de la fonction : !code!error!v1!v2!v3!...!v29
// - code=0 : la fonction retourne les données de la transaction dans les variables v1, v2, ...
// : Ces variables sont décrites dans le GUIDE DU PROGRAMMEUR
// - code=-1 : La fonction retourne un message d'erreur dans la variable error
// on separe les differents champs et on les met dans une variable tableau
$tableau = explode ("!", $result);
$code = $tableau[1];
$error = $tableau[2];
$merchant_id = $tableau[3];
$merchant_country = $tableau[4];
$amount = $tableau[5];
$transaction_id = $tableau[6];
$payment_means = $tableau[7];
$transmission_date= $tableau[8];
$payment_time = $tableau[9];
$payment_date = $tableau[10];
$response_code = $tableau[11];
$payment_certificate = $tableau[12];
$authorisation_id = $tableau[13];
$currency_code = $tableau[14];
$card_number = $tableau[15];
$cvv_flag = $tableau[16];
$cvv_response_code = $tableau[17];
$bank_response_code = $tableau[18];
$complementary_code = $tableau[19];
$complementary_info= $tableau[20];
$return_context = $tableau[21];
$caddie = $tableau[22];
$receipt_complement = $tableau[23];
$merchant_language = $tableau[24];
$language = $tableau[25];
$customer_id = $tableau[26];
$order_id = $tableau[27];
$customer_email = $tableau[28];
$customer_ip_address = $tableau[29];
$capture_day = $tableau[30];
$capture_mode = $tableau[31];
$data = $tableau[32];
$order_validity = $tableau[33];
$transaction_condition = $tableau[34];
$statement_reference = $tableau[35];
$card_validity = $tableau[36];
$score_value = $tableau[37];
$score_color = $tableau[38];
$score_info = $tableau[39];
$score_threshold = $tableau[40];
$score_profile = $tableau[41];
$codecommande = $_GET['ref'];
// Initialisation du chemin du fichier de log (à modifier)
// ex :
// -> Windows : $logfile="c:\\repertoire\\log\\logfile.txt";
// -> Unix : $logfile="/home/repertoire/log/logfile.txt";
//
//$logfile="/home/reserverrz/www/sogenactif/sample/logs.txt";
// Ouverture du fichier de log en append
//$fp=fopen($logfile, "a");
// analyse du code retour
if (( $code == "" ) && ( $error == "" ) )
{
//fwrite($fp, "erreur appel response\n");
print ("executable response non trouve $path_bin\n");
}
// Erreur, sauvegarde le message d'erreur
else if ( $response_code != 0 ){
$sql = mysql_query("insert into sogenactif(coderetour,error,merchant_id,merchant_country,amount,transaction_id,payment_means,transmission_date,payment_time,payment_date,
response_code, payment_certificate,authorisation_id,currency_code,card_number,cvv_flag,cvv_response_code,bank_response_code,complementary_code,complementary_info,
return_context,caddie,receipt_complement,merchant_language,language,customer_id,customer_email,customer_ip_address,capture_day,capture_mode,data,order_validity,
transaction_condition,statement_reference,card_validity,score_value,score_color,score_info,score_threshold, score_profile, codecommande)values('".$code."','".$error."','".$merchant_id."',
'".$merchant_country."','".$amount."','".$transaction_id."','".$payment_means."','".$transmission_date."','".$payment_time."','".$payment_date."','".$response_code."',
'".$payment_certificate."','".$authorisation_id."','".$currency_code."','".$card_number."','".$cvv_flag."','".$cvv_response_code."','".$bank_response_code."','".$complementary_code."',
'".$complementary_info."','".$return_context."','".$caddie."','".$receipt_complement."','".$merchant_language."','".$language."','".$customer_id."','".$customer_email."',
'".$customer_ip_address."','".$capture_day."','".$capture_mode."','".$data."','".$order_validity."','".$transaction_condition."','".$statement_reference."',
'".$card_validity."','".$score_value."','".$score_color."','".$score_info."','".$score_threshold."','".$score_profile."','".$codecommande."');");
//fwrite($fp, " API call error.\n");
//fwrite($fp, "Error message : $error\n");
}
else {
// OK, Sauvegarde des champs de la réponse
$sql = mysql_query("insert into sogenactif(coderetour,error,merchant_id,merchant_country,amount,transaction_id,payment_means,transmission_date,payment_time,payment_date,
response_code, payment_certificate,authorisation_id,currency_code,card_number,cvv_flag,cvv_response_code,bank_response_code,complementary_code,complementary_info,
return_context,caddie,receipt_complement,merchant_language,language,customer_id,customer_email,customer_ip_address,capture_day,capture_mode,data,order_validity,
transaction_condition,statement_reference,card_validity,score_value,score_color,score_info,score_threshold, score_profile, codecommande)values('".$code."','".$error."','".$merchant_id."',
'".$merchant_country."','".$amount."','".$transaction_id."','".$payment_means."','".$transmission_date."','".$payment_time."','".$payment_date."','".$response_code."',
'".$payment_certificate."','".$authorisation_id."','".$currency_code."','".$card_number."','".$cvv_flag."','".$cvv_response_code."','".$bank_response_code."','".$complementary_code."',
'".$complementary_info."','".$return_context."','".$caddie."','".$receipt_complement."','".$merchant_language."','".$language."','".$customer_id."','".$customer_email."',
'".$customer_ip_address."','".$capture_day."','".$capture_mode."','".$data."','".$order_validity."','".$transaction_condition."','".$statement_reference."',
'".$card_validity."','".$score_value."','".$score_color."','".$score_info."','".$score_threshold."','".$score_profile."','".$codecommande."');");
}
//fclose ($fp);
?>