public string ZarinPalRedirect(decimal amount, Guid orderId) { ZarinPal.ZarinPal zarinpal = ZarinPal.ZarinPal.Get(); String CallbackURL = WebConfigurationManager.AppSettings["callBackUrl"]; long Amount = Convert.ToInt64(amount); String description = "خرید از وب سایت دکتر کامران صحت"; ZarinPal.PaymentRequest pr = new ZarinPal.PaymentRequest(MerchantId, Amount, CallbackURL, description); // zarinpal.DisableSandboxMode(); zarinpal.DisableSandboxMode(); try { var res = zarinpal.InvokePaymentRequest(pr); if (res.Status == 100) { InsertToAuthority(orderId, res.Authority, amount); db.SaveChanges(); return(res.PaymentURL); } else { return("false"); } } catch (Exception e) { return("zarrin"); } }
public string ZarinPalRedirect(Order order, decimal amount) { string MerchantId = db.ShopConfigurations.FirstOrDefault(c => c.Name == "zarinpal").Value; ZarinPal.ZarinPal zarinpal = ZarinPal.ZarinPal.Get(); String CallbackURL = WebConfigurationManager.AppSettings["callBackUrl"]; long Amount = Convert.ToInt64(amount); List <OrderDetail> orderDetails = db.OrderDetails.Where(current => current.OrderId == order.Id).ToList(); string productDesc = null; foreach (OrderDetail orderDetail in orderDetails) { productDesc = productDesc + orderDetail.Product.Code + ","; } String description = "خرید محصول کد" + productDesc; ZarinPal.PaymentRequest pr = new ZarinPal.PaymentRequest(MerchantId, Amount, CallbackURL, description); zarinpal.EnableSandboxMode(); try { var res = zarinpal.InvokePaymentRequest(pr); if (res.Status == 100) { InsertToAuthority(order.Id, res.Authority, amount); return(res.PaymentURL); } else { return("false"); } } catch (Exception e) { return("zarrin"); } }
public string ZarinPalRedirect(Order order, decimal amount) { ZarinPal.ZarinPal zarinpal = ZarinPal.ZarinPal.Get(); // String CallbackURL = "http://localhost:59339/callback"; String CallbackURL = "https://www.rushweb.ir/callback"; long Amount = Convert.ToInt64(amount); List <OrderDetail> orderDetails = db.OrderDetails.Where(current => current.OrderId == order.Id).Include(c => c.Product).ToList(); string productDesc = null; foreach (OrderDetail orderDetail in orderDetails) { // productDesc = productDesc + orderDetail.Product. + ","; } String description = "خرید محصول "; ZarinPal.PaymentRequest pr = new ZarinPal.PaymentRequest(MerchantId, Amount, CallbackURL, description); zarinpal.DisableSandboxMode(); try { var res = zarinpal.InvokePaymentRequest(pr); if (res.Status == 100) { InsertToAuthority(order.Id, res.Authority, amount); return(res.PaymentURL); } else { return("false"); } } catch (Exception e) { return("zarrin"); } }