Esempio n. 1
0
        static void GetAllPaymentOrdersList(Instamojo objClass)
        {
            try
            {
                PaymentOrderListRequest objPaymentOrderListRequest = new PaymentOrderListRequest();
                //Optional Parameters
                objPaymentOrderListRequest.limit = 21;
                objPaymentOrderListRequest.page  = 3;

                PaymentOrderListResponse objPaymentRequestStatusResponse = objClass.getPaymentOrderList(objPaymentOrderListRequest);
                foreach (var item in objPaymentRequestStatusResponse.orders)
                {
                    Console.WriteLine(item.email + item.description + item.amount);
                }
                MessageBox.Show("Order List = " + objPaymentRequestStatusResponse.orders.Count());
            }
            catch (ArgumentNullException ex)
            {
                MessageBox.Show(ex.Message);
            }
            catch (WebException ex)
            {
                MessageBox.Show(ex.Message);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error:" + ex.Message);
            }
        }
Esempio n. 2
0
        // GET: Admin
        public ActionResult GetDonations()
        {
            Instamojo objClass = InstamojoImplementation.getApi(PaymentGatewaySecrets.CLIENT_ID,
                                                                PaymentGatewaySecrets.CLIENT_SECRET, PaymentGatewaySecrets.API_ENDPOINT,
                                                                PaymentGatewaySecrets.AUTH_ENDPOINT);

            PaymentOrderListRequest objPaymentOrderListRequest = new PaymentOrderListRequest();

            PaymentOrderListResponse objPaymentRequestStatusResponse = objClass.getPaymentOrderList(objPaymentOrderListRequest);

            List <OrderViewModel> viewModel = new List <OrderViewModel>();

            foreach (var order in objPaymentRequestStatusResponse.orders)
            {
                viewModel.Add(new OrderViewModel
                {
                    Amount        = order.amount,
                    CreatedAt     = order.created_at,
                    Currency      = order.currency,
                    Description   = order.description,
                    Email         = order.email,
                    Id            = order.id,
                    Name          = order.name,
                    Phone         = order.phone,
                    RedirectUrl   = order.redirect_url,
                    ResourceUri   = order.resource_uri,
                    Status        = order.status,
                    TransactionId = order.transaction_id,
                    WebhookUrl    = order.webhook_url
                });
            }

            return(View(viewModel));
        }
        protected void submit_Click(object sender, EventArgs e)
        {
            string Insta_client_id     = ConfigurationManager.AppSettings["ClientId"];     //,//   "test_sFhb8ig0JPT0Hc21G2CWZg4RqhO4d3KqMdO",
            string Insta_client_secret = ConfigurationManager.AppSettings["ClientSecret"]; //, //"test_7VCjAHfdUrQMtlvUwYUEtAFbYJuvAGZ1Pu63WUfSBWOgsmW8Oa3rgx6AmOsi8UuXeZ3zbFyuPFJMXbEd9rppVFSTXALInXFS3Oa7Ux1hB5NQKAh9OnzvqTSHcV8",
            string Insta_Endpoint      = "";                                               //ConfigurationManager.AppSettings["APIEndpoint"],// InstamojoConstants.INSTAMOJO_API_ENDPOINT,
            string Insta_Auth_Endpoint = "";                                               //ConfigurationManager.AppSettings["AuthEndpoint"];// InstamojoConstants.INSTAMOJO_AUTH_ENDPOINT;

            //bool validPayment = false;
            Insta_Endpoint      = ConfigurationManager.AppSettings["APIEndpoint"];
            Insta_Auth_Endpoint = ConfigurationManager.AppSettings["AuthEndpoint"];

            /*
             * if (paymenttype == "fromcustomer")
             * {*/
            Insta_client_id     = ConfigurationManager.AppSettings["ClientId"];
            Insta_client_secret = ConfigurationManager.AppSettings["ClientSecret"];
            //    validPayment = true;

            /*}
             * else if (paymenttype == "tosupplier")
             * {
             *  Insta_client_id = ClientId.Value;
             *  Insta_client_secret = ClientSecret.Value;
             *  validPayment = true;
             * }
             * else
             *  Response.Write("Invalid Payment type");
             */
            Instamojo objClass = InstamojoImplementation.getApi(Insta_client_id, Insta_client_secret, Insta_Endpoint, Insta_Auth_Endpoint);

            try
            {
                PaymentOrderListRequest objPaymentOrderListRequest = new PaymentOrderListRequest();
                //Optional Parameters
                objPaymentOrderListRequest.limit = 20;
                objPaymentOrderListRequest.page  = 3;

                //PaymentOrderListResponse objPaymentRequestStatusResponse = objClass.getPaymentOrderList(objPaymentOrderListRequest);
                PaymentOrderDetailsResponse        objPaymentRequestStatusResponse = objClass.getPaymentOrderDetails(ddlTranId.SelectedValue);
                List <PaymentOrderDetailsResponse> objlist = new List <PaymentOrderDetailsResponse>();
                objlist.Add(objPaymentRequestStatusResponse);
                GridView1.DataSource = objlist;
                GridView1.DataBind();


                //PropertyInfo[] properties = typeof(Order).GetProperties();
                //foreach (var item in objPaymentRequestStatusResponse.orders)
                //{
                //    Response.Write("Id :" + item.id ,);

                //}

                //MessageBox.Show("Order Count = " + objPaymentRequestStatusResponse.orders.Count());
            }
            catch (Exception ex)
            {
                Response.Write("Error:" + ex.Message);
            }



            //if (validPayment)
            //{
            //    Insta_Endpoint = ConfigurationManager.AppSettings["APIEndpoint"];
            //    Insta_Auth_Endpoint = ConfigurationManager.AppSettings["AuthEndpoint"];

            //    Instamojo objClass = InstamojoImplementation.getApi(Insta_client_id, Insta_client_secret, Insta_Endpoint, Insta_Auth_Endpoint);

            //    string responseURL = CreatePaymentOrder(objClass);

            //    Response.Redirect(responseURL);
            //}
        }
Esempio n. 4
0
        public PaymentOrderListResponse GetPaymentOrderList(PaymentOrderListRequest objPaymentOrderListRequest)
        {
            if (objPaymentOrderListRequest == null)
            {
                throw new ArgumentNullException(typeof(PaymentOrderListRequest).Name, "PaymentOrderListRequest Object Can not be Null");
            }
            string queryString = "", stream = "";

            if (string.IsNullOrEmpty(objPaymentOrderListRequest.id))
            {
                queryString = "id=" + objPaymentOrderListRequest.id;
            }
            if (string.IsNullOrEmpty(objPaymentOrderListRequest.transaction_id))
            {
                string transQuery = "transaction_id=" + objPaymentOrderListRequest.transaction_id;
                queryString += string.IsNullOrEmpty(queryString) ? transQuery : ("&" + transQuery);
            }
            if (objPaymentOrderListRequest.page != 0)
            {
                string pageQuery = "page=" + objPaymentOrderListRequest.page;
                queryString += string.IsNullOrEmpty(queryString) ? pageQuery : ("&" + pageQuery);
            }
            if (objPaymentOrderListRequest.limit != 0)
            {
                string limitQuery = "limit=" + objPaymentOrderListRequest.limit;
                queryString += string.IsNullOrEmpty(queryString) ? limitQuery : ("&" + limitQuery);
            }
            try
            {
                if (queryString != "")
                {
                    stream = api_call("GET", "gateway/orders/?" + queryString, objPaymentOrderListRequest);
                }
                else
                {
                    stream = api_call("GET", "gateway/orders/", null);
                }

                PaymentOrderListResponse objPaymentRequestStatusResponse = JsonConvert.DeserializeObject <PaymentOrderListResponse>(stream);
                return(objPaymentRequestStatusResponse);
            }
            catch (IOException ex)
            {
                throw new IOException(ex.Message, ex.InnerException);
            }
            catch (BaseException ex)
            {
                throw new BaseException(ex.Message, ex.InnerException);
            }
            catch (UriFormatException ex)
            {
                throw new UriFormatException(ex.Message, ex.InnerException);
            }
            catch (WebException ex)
            {
                if (ex.Status == WebExceptionStatus.ProtocolError)
                {
                    HttpWebResponse err = ex.Response as HttpWebResponse;
                    if (err != null)
                    {
                        string htmlResponse = new StreamReader(err.GetResponseStream()).ReadToEnd();
                        throw new WebException(err.StatusDescription + " " + htmlResponse);
                    }
                }
                throw new WebException(ex.Message, ex.InnerException);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex.InnerException);
            }
        }