protected void BT_Valider_Click(object sender, EventArgs e) { Order commande = DataMapping.GetOrderByGuid(HF_id.Value); if (commande == null) { throw new Exception("Erreur d'ouverture de la commande"); } commande.rule_type = RB_Moyen_Paiement.SelectedValue; commande.rule_par = UserInfo.DisplayName; if (!DataMapping.UpdateOrder(commande)) { throw new Exception("Erreur de validation du paiement"); } p_default.Visible = false; P_valider.Visible = false; switch (RB_Moyen_Paiement.SelectedValue) { case "virement": P_virement_ok.Visible = true; break; case "cheque": P_cheque_ok.Visible = true; break; case "cb": P_cb_ok.Visible = true; string pathfile = Server.MapPath(@"/mercanet/payment/param/pathfile"); SIPSApiWeb api = new SIPSApiWeb(pathfile); SIPSDataObject call = (SIPSDataObject) new SIPSCallParm(); call.setValue("merchant_id", "005008592740862"); call.setValue("merchant_country", "fr"); call.setValue("amount", "" + (commande.amount * 100)); call.setValue("currency_code", "978"); call.setValue("transaction_id", "" + DataMapping.GetOrderNewTransactionID(commande.id)); call.setValue("customer_email", "" + UserInfo.Email); call.setValue("order_id", "" + commande.id); string urlretour = Request.Url.ToString().Replace(Request.Url.PathAndQuery, "") + Const.MERCANET_RETURN_URL; call.setValue("normal_return_url", urlretour); call.setValue("cancel_return_url", urlretour); string iii = Guid.NewGuid().ToString(); Session[iii] = "<html><body id='Body' >" + api.sipsPaymentCallFunc(call) + "</body></html>"; TXT_mercanet.Text = "<iframe width='400px' height='200px' src='/AIS/iframe.aspx?id=" + iii + "'></iframe>"; //Response.Redirect(Functions.UrlAddParam(Const.COMMANDE_PAY_CB_URL, "id", HF_id.Value)); break; } }
/// <summary> /// traitement de la requete de paiement /// Dans cet exemple, on affiche un formulaire de /// connexion au serveur de paiement a l'internaute. /// </summary> public void RequestMethod() { try{ Response.ContentType = "text/html"; TextWriter responseWriter = Response.Output; responseWriter.WriteLine("<html><head><title>SHERLOCKS - Paiement Securise sur Internet</title></head>"); responseWriter.WriteLine("<body bgcolor=#ffffff>"); responseWriter.WriteLine("<Font color=#000000>"); responseWriter.WriteLine("<center><h1>Test de l'API C# SHERLOCKS</h1></center><br /><br />"); /* Initialisation du chemin du fichier pathfile (a modifier) * ex : SIPSApiWeb api = new SIPSApiWeb("c:\\repertoire\\pathfile"); */ SIPSApiWeb api = new SIPSApiWeb("c:\\repertoire\\pathfile"); /* Initialisation de l'objet d'appel */ SIPSDataObject call = (SIPSDataObject) new SIPSCallParm(); /**************************** Parametres obligatoires*************************/ // ex : merchant_id = 014295303911111 call.setValue("merchant_id", "014295303911111"); // ex : merchant_country = fr call.setValue("merchant_country", "fr"); // Affectation du montant de la transaction dans la plus petite unite // monetaire du pays // ex : 123,00 Euros ==> 12300 (currency_code = 978) call.setValue("amount", "12300"); // Affectation du code monetaire ISO 4217 pour la transaction // ex : Euro ==> 978 call.setValue("currency_code", "978"); // Identifiant de transaction // ex : transaction_id = 123456 call.setValue("transaction_id", "123456"); /******************************************************************************/ // Affectation d'un numero identifiant pour la transaction // Attention aux reserves sur l'affectation automatique // cf Guide du developpeur // Valorisation des autres donnees de la transaction // facultatives, a completer au besoin // Les valeurs proposees ne sont que des exemples // Les champs et leur utilisation sont expliques dans le Dictionnaire des donnees // // call.setValue("normal_return_url",""); // call.setValue("cancel_return_url",""); // call.setValue("automatic_response_url",""); // call.setValue("language","fr"); // call.setValue("payment_means","CB,2,VISA,2,MASTERCARD,2"); // call.setValue("header_flag","no"); // call.setValue("capture_day",""); // call.setValue("capture_mode",""); // call.setValue("bgcolor",""); // call.setValue("block_align",""); // call.setValue("block_order",""); // call.setValue("textcolor",""); // call.setValue("receipt_complement",""); // call.setValue("caddie","mon caddie"); // call.setValue("customer_id",""); // call.setValue("customer_email",""); // call.setValue("data",""); // call.setValue("return_context",""); // call.setValue("target",""); // call.setValue("order_id",""); // call.setValue("customer_title",""); // call.setValue("customer_name",""); // call.setValue("customer_firstname",""); // call.setValue("customer_birthdate",""); // call.setValue("customer_phone",""); // call.setValue("customer_mobile_phone",""); // call.setValue("customer_ip_address",""); // call.setValue("customer_nationality_country",""); // call.setValue("customer_birth_zipcode",""); // call.setValue("customer_birth_city",""); // call.setValue("home_city",""); // call.setValue("home_streetnumber",""); // call.setValue("home_street",""); // call.setValue("home_zipcode",""); // ELV ou Paypal delivery, billing address // // call.setValue("delivery_title",""); // call.setValue("delivery_firstname",""); // call.setValue("delivery_name","Smith"); // call.setValue("delivery_company",""); // call.setValue("delivery_streetnumber",""); // call.setValue("delivery_street",""); // call.setValue("delivery_zipCode",""); // call.setValue("delivery_city",""); // call.setValue("delivery_state",""); // call.setValue("delivery_country",""); // call.setValue("delivery_additional1",""); // call.setValue("delivery_additional2",""); // call.setValue("delivery_additional3",""); // call.setValue("delivery_email",""); // call.setValue("delivery_phone",""); // // call.setValue("billing_title",""); // call.setValue("billing_firstname",""); // call.setValue("billing_name",""); // call.setValue("billing_company",""); // call.setValue("billing_streetnumber",""); // call.setValue("billing_street",""); // call.setValue("billing_zipCode",""); // call.setValue("billing_city",""); // call.setValue("billing_state",""); // call.setValue("billing_country",""); // call.setValue("billing_additional1",""); // call.setValue("billing_additional2",""); // call.setValue("billing_additional3",""); // call.setValue("billing_email",""); // call.setValue("billing_phone",""); // Les valeurs suivantes ne sont utilisables qu'en pre-production // Elles necessitent l'installation de vos logos et templates sur // le serveur de paiement // // call.setValue("normal_return_logo",""); // call.setValue("cancel_return_logo",""); // call.setValue("submit_logo",""); // call.setValue("logo_id",""); // call.setValue("logo_id2",""); // call.setValue("advert",""); // call.setValue("background_id",""); // call.setValue("templatefile","mon_template"); // Insertion de la commande dans votre base de donnees // avec le status "en cours" // ... // Appel de l'api SIPS payment responseWriter.WriteLine(api.sipsPaymentCallFunc(call)); responseWriter.WriteLine("<br /><br />"); responseWriter.WriteLine("</body>"); responseWriter.WriteLine("</html>"); responseWriter.Close(); } catch (Exception e) { TextWriter responseWriter; Response.ContentType = "text/html"; responseWriter = Response.Output; responseWriter.WriteLine("<center>"); responseWriter.WriteLine("<br />"); responseWriter.WriteLine("Error = " + e.GetType().FullName + e.Message); responseWriter.WriteLine("</center>"); responseWriter.WriteLine("</body>"); responseWriter.WriteLine("</html>"); responseWriter.Close(); } }