コード例 #1
0
ファイル: payment.aspx.cs プロジェクト: shaikhsdf/rentacar
        protected void Page_Load(object sender, EventArgs e)
        {
            OleDbCommand cmda = new OleDbCommand();

            //this.InitializeComponent();
            cmda.CommandText = "select * from transactionid where username='******'";
            connect();
            cmda.Connection = cn;
            OleDbDataReader dra;

            dra = cmda.ExecuteReader();
            while (dra.Read())
            {
                string ClientID     = "lm0yIbueCMdnyDtG8IG2FFwNbDG4TwcCzu2uSYsT";
                string secretkey    = "F8MsK5hAZ8IMgKwp9JmAkpNMfEREFMtM9dnMqECCzaP3xGnVJwhAJs0Ks1G2Iy8slOmvoy6p8ehZpjwpT1VuhDpKoMyCgU8fUHOaSZZuUlMs05OW6eGJGvrokPAuAuIY";
                string endpoint     = "https://api.instamojo.com/v2/";
                string authendpoint = "https://www.instamojo.com/oauth2/token/";
                /***** Details of Payment order using TransactionId. *******/
                Instamojo objClass = InstamojoImplementation.getApi(ClientID, secretkey, endpoint, authendpoint);
                try
                {
                    PaymentOrderDetailsResponse objPaymentRequestDetailsResponse = objClass.getPaymentOrderDetailsByTransactionId(dra[0].ToString());
                    paymentid.Text  = objPaymentRequestDetailsResponse.transaction_id;
                    phone.Text      = objPaymentRequestDetailsResponse.phone;
                    paidamount.Text = objPaymentRequestDetailsResponse.amount.ToString();
                    status.Text     = objPaymentRequestDetailsResponse.status;
                }
                catch (Exception ex)
                {
                    Label1.Visible = true;
                    Label1.Text    = "**********No Data to be displayed***********";
                }
            }
        }
コード例 #2
0
        private void DetailsofPayment(Instamojo objClass)
        {
            PaymentOrderDetailsResponse paymentOrderDetailsResponse = objClass.getPaymentOrderDetailsByTransactionId(Session["transID"].ToString());

            TxnId.Text     = paymentOrderDetailsResponse.transaction_id;
            txtName.Text   = paymentOrderDetailsResponse.name;
            txtAmount.Text = Convert.ToString(paymentOrderDetailsResponse.amount);
            h1Message.Text = paymentOrderDetailsResponse.status;
            date.Text      = paymentOrderDetailsResponse.created_at;
        }
コード例 #3
0
        public ActionResult Complete()
        {
            // Payment data comes in url so we have to get it from url

            // This id is instamojo unique payment id which can be use to get the payment details from instamojo
            string paymentId = Request.Params["payment_id"];

            // This is payment status which will be Credit
            string paymentStatus = Request.Params["payment_status"];

            // This is orderId
            string id = Request.Params["id"];

            // This id is your unique transaction id which created on create order
            string transactionId = Request.Params["transaction_id"];

            // Now you can verify the order existance in your db using transactin id


            // Let's get the transaction data from payment gatway
            // Thaer are two ways to get transaction data through orderId or transactionid

            InstamojoAPI.Instamojo objClass = InstamojoAPI.InstamojoImplementation.getApi(instamojoClientId, instamojoSecretId, endpoint, auth_endpoint);

            // Get transaciton data using transactionId
            PaymentOrderDetailsResponse response = objClass.getPaymentOrderDetailsByTransactionId(transactionId);

            // get transaciton data using orderId
            PaymentOrderDetailsResponse response1 = objClass.getPaymentOrderDetails(id);


            // Check payment made successfully

            if (response.status.ToLower().Equals("completed") == true)
            {
                // Create these action method
                return(RedirectToAction("Success"));
            }
            else
            {
                return(RedirectToAction("Failed"));
            }
        }
コード例 #4
0
 public PaymentOrderDetailsResponse GetPaymentOrderDetailsByTransactionId(string strTransactionId)
 {
     if (string.IsNullOrEmpty(strTransactionId))
     {
         throw new ArgumentNullException(typeof(string).Name, "Transaction Id Can not be Null or Empty");
     }
     try
     {
         string stream = api_call("GET", "gateway/orders/transaction_id:" + strTransactionId + "/", null);
         PaymentOrderDetailsResponse objPaymentRequestDetailsResponse = JsonConvert.DeserializeObject <PaymentOrderDetailsResponse>(stream);
         return(objPaymentRequestDetailsResponse);
     }
     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);
     }
 }
コード例 #5
0
ファイル: Test.cs プロジェクト: shaikhsdf/rentacar
 static void GetPaymentOrderDetailsUsingTransactionId_WhenTransactionIdIsUnknown(Instamojo objClass)
 {
     try
     {
         PaymentOrderDetailsResponse objPaymentRequestDetailsResponse = objClass.getPaymentOrderDetailsByTransactionId("Unknown");
         MessageBox.Show("Transaction Id = " + objPaymentRequestDetailsResponse.transaction_id);
     }
     catch (ArgumentNullException ex)
     {
         MessageBox.Show(ex.Message);
     }
     catch (WebException ex)
     {
         MessageBox.Show(ex.Message);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error:" + ex.Message);
     }
 }
コード例 #6
0
ファイル: Test.cs プロジェクト: shaikhsdf/rentacar
 static void GetPaymentOrderDetailUsingOrderId_WhenOrderIdIsUnknown(Instamojo objClass)
 {
     try
     {
         PaymentOrderDetailsResponse objPaymentRequestDetailsResponse = objClass.getPaymentOrderDetails("3189cff7c68245bface8915ca"); //"3189cff7c68245bface8915cac1f89df");
         MessageBox.Show("Transaction Id = " + objPaymentRequestDetailsResponse.transaction_id);
     }
     catch (ArgumentNullException ex)
     {
         MessageBox.Show(ex.Message);
     }
     catch (WebException ex)
     {
         MessageBox.Show(ex.Message);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error:" + ex.Message);
     }
 }
        // POST: odata/OnlinepaymentFromWebhooks
        public async Task <IHttpActionResult> Post(OnlinepaymentFromWebhook onlinepaymentFromWebhook)
        {
            //if (!ModelState.IsValid)
            //{
            //    return BadRequest(ModelState);
            //}
            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;

            Insta_Endpoint      = ConfigurationManager.AppSettings["APIEndpoint"];
            Insta_Auth_Endpoint = ConfigurationManager.AppSettings["AuthEndpoint"];

            Insta_client_id     = ConfigurationManager.AppSettings["ClientId"];
            Insta_client_secret = ConfigurationManager.AppSettings["ClientSecret"];
            Instamojo objClass = InstamojoImplementation.getApi(Insta_client_id, Insta_client_secret, Insta_Endpoint, Insta_Auth_Endpoint);


            PaymentOrderDetailsResponse        objPaymentRequestStatusResponse = objClass.getPaymentOrderDetails(onlinepaymentFromWebhook.id);
            List <PaymentOrderDetailsResponse> objlist = new List <PaymentOrderDetailsResponse>();

            objlist.Add(objPaymentRequestStatusResponse);

            onlinepaymentFromWebhook.status      = objPaymentRequestStatusResponse.status;
            onlinepaymentFromWebhook.buyer       = objPaymentRequestStatusResponse.email;
            onlinepaymentFromWebhook.buyer_name  = objPaymentRequestStatusResponse.name;
            onlinepaymentFromWebhook.buyer_phone = objPaymentRequestStatusResponse.phone;
            onlinepaymentFromWebhook.purpose     = objPaymentRequestStatusResponse.description;
            onlinepaymentFromWebhook.createdon   = Convert.ToDateTime(objPaymentRequestStatusResponse.created_at);
            onlinepaymentFromWebhook.currency    = objPaymentRequestStatusResponse.currency;
            onlinepaymentFromWebhook.amount      = objPaymentRequestStatusResponse.amount;

            db.OnlinepaymentFromWebhooks.Add(onlinepaymentFromWebhook);
            await db.SaveChangesAsync();

            return(Created(onlinepaymentFromWebhook));
        }
        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);
            //}
        }