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
| String Reponse = String.Empty;
StreamReader Sr = null; // lire les données
StreamWriter Sw = null; //Ecrire les données
System.Uri Uri = new System.Uri(urlMerchant);
ASCIIEncoding encoding = new ASCIIEncoding();
string postData = "ref_we=" + ref_we + "&amount=" + amount + "&ref_order=" + ref_order;
byte[] data = encoding.GetBytes(postData);
try
{
HttpWebRequest httpWebRequest =
(HttpWebRequest)WebRequest.Create(Uri);
httpWebRequest.Method = "POST";
httpWebRequest.Timeout = 10000;
httpWebRequest.ContentType = "application/x-www-form-urlencoded";
httpWebRequest.ContentLength = postData.Length;
Sw = new StreamWriter(httpWebRequest.GetRequestStream());
Sw.Write(postData);
Sw.Close();
Sw = null;
HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (Sr = new StreamReader(httpWebResponse.GetResponseStream()))
{
Reponse = Sr.ReadToEnd();
//Envoi de l'email
sendEmailConfirmation(email, ref_we, ref_order, amount, Reponse);
Sr.Close();
}
return Reponse;
}
catch (Exception ex)
{
sendEmailConfirmationButErreur(email,ref_we, ref_order, amount, ex.Message);
return ex.ToString();
} |
Partager