コード例 #1
0
ファイル: Test.cs プロジェクト: shaikhsdf/rentacar
        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);
            }
        }
コード例 #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));
        }
コード例 #3
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);
            }
        }