protected void Button1_Click(object sender, EventArgs e) { price = "50000"; string date_per; PersianCalendar p = new PersianCalendar(); DateTime dt = DateTime.Now; int y, m, d; y = p.GetYear(dt); m = p.GetMonth(dt); d = p.GetDayOfMonth(dt); date_per = y.ToString() + "/" + m.ToString() + "/" + d.ToString(); System.Net.ServicePointManager.Expect100Continue = false; var zp = new zarinpal.ServiceReference.PaymentGatewayImplementationServicePortTypeClient(); string Authority; // کد پذیرنده Authority = ""; // Session["amont"] = s; int status = zp.PaymentRequest("b54a42c6-4340-11ea-87e2-000c295eb8fc", Convert.ToInt32(price), "as", "as", "asa", "http://localhost:62679/Teacher_now.aspx", out Authority); Session["Authority1"] = Authority; Session["status1"] = status; Response.Redirect("https://www.zarinpal.com/pg/StartPay/" + Authority); }
/// <summary> /// Starts payment /// </summary> /// <returns>Returns payment autohority id</returns> public string StartPay() { try { ServiceReference.PaymentGatewayImplementationServicePortTypeClient request = new ServiceReference.PaymentGatewayImplementationServicePortTypeClient(); string autohority = string.Empty; int value = request.PaymentRequest(_MerchantID, _Amount, _Description, _Email, _Mobile, _CallbackURL, out autohority); if (value > 0) { new Thread(() => { CheckPaymentStatus(autohority); }).Start(); return(autohority); } else { return(value.ToString()); } } catch { return(null); } }
protected void Button2_Click(object sender, EventArgs e) { string date_per; PersianCalendar p = new PersianCalendar(); DateTime dt = DateTime.Now; int y, m, d; y = p.GetYear(dt); m = p.GetMonth(dt); d = p.GetDayOfMonth(dt); date_per = y.ToString() + "/" + m.ToString() + "/" + d.ToString(); System.Net.ServicePointManager.Expect100Continue = false; var zp = new zarinpal.ServiceReference.PaymentGatewayImplementationServicePortTypeClient(); string Authority; // کد پذیرنده Authority = ""; // Session["amont"] = s; int status = zp.PaymentRequest("c30-4bf5-a83b-65cecdd_33394", Convert.ToInt32(price), "", "", txtemail.Text, "http://localhost:1169//Pardakht_off.aspx", out Authority); Session["Authority1"] = Authority; Session["status1"] = status; Response.Redirect("https://www.zarinpal.com/pg/StartPay/" + Authority); }
private void CheckPaymentStatus(string autohority) { ServiceReference.PaymentGatewayImplementationServicePortTypeClient request = new ServiceReference.PaymentGatewayImplementationServicePortTypeClient(); long refID = -1; bool stopit = false; long curtick = DateTime.Now.Ticks / TimeSpan.TicksPerSecond; while (true) { if (stopit) { break; } int verf = -21; try { verf = request.PaymentVerification(_MerchantID, autohority, _Amount, out refID); } catch { } if (verf > 0) { stopit = true; if (OnPaymentAction != null) { OnPaymentAction(this, new PayArgs(verf, autohority, refID)); } } else { if (!stopit && verf != -21) { stopit = true; if (OnPaymentAction != null) { OnPaymentAction(this, new PayArgs(verf, autohority, refID)); } } } long curtime = DateTime.Now.Ticks / TimeSpan.TicksPerSecond; if ((curtime - curtick) > 1850) // 30 * 60 +- 50 { if (!stopit) { OnPaymentAction(this, new PayArgs(-22, autohority, refID)); stopit = true; } } } }