public void findReports() { string url = "https://staging-api.payhub.com/api/v2/"; string oauth = "107d74ab-4a18-4713-88ff-69bd05710086"; Merchant merchant = new Merchant(); merchant.organization_id = 10127; merchant.terminal_id = 215; TransactionSearchParameters tsp = new TransactionSearchParameters(); tsp.AmountFrom = "1"; tsp.AmountTo = "1002"; tsp.CardLast4Digits = "4507"; tsp.BatchIdFrom = "1300"; tsp.BatchIdTo = "1320"; tsp.Email = "marrighi"; tsp.TransactionType = "Sale"; tsp.ResponseCode = "00"; tsp.FirstName = "First"; tsp.LastName = "Cont"; tsp.PhoneNumber = "(415) 479 1349"; tsp.TrnDateFrom = "2015-04-01 00:00:00"; tsp.TrnDateTo = "2015-04-30 00:00:00"; tsp.CardType = "MasterCard"; tsp.CardToken = "9999000000001853"; tsp.Swiped = "true"; tsp.Source = "3rd Party API"; TransactionManager transaction = new TransactionManager(url, oauth, merchant); List<TransactionReportInformation> tri = transaction.findTransactions(tsp); Console.Write(tri.ElementAt(0).CustomerName); }
/// <summary> /// Perform a new query that retrieves you the Transaction results from a set of parameters. /// /// <param name="parameters"> /// String parameters: the set of parameters to search the transactions. /// </param> /// <returns> /// a TransactionReportInformation List object. /// </returns> /// <seealso cref="PayHubWS.com.payhub.ws.api.TransactionReportInformation"/> /// </summary> public List<TransactionReportInformation> findTransactions(TransactionSearchParameters parameters) { String url = _url + "report/transactionReport"; HttpWebRequest request = setHeadersPost(url, this._oauthToken); string json = JsonConvert.SerializeObject(parameters, Formatting.None, new JsonSerializerSettings { DefaultValueHandling = DefaultValueHandling.Ignore }); string result = findTransactionReports(request, json); List<TransactionReportInformation> response = new List<TransactionReportInformation>(); try { response = JsonConvert.DeserializeObject<List<TransactionReportInformation>>(result.ToString()); } catch { try { var node = JObject.Parse(result); List<Errors> errors = JsonConvert.DeserializeObject<List<Errors>>(node["errors"].ToString()); TransactionReportInformation t = new TransactionReportInformation(); t.Errors = errors; response.Add(t); } catch { List<Errors> errors = new List<Errors>(); Errors error = new Errors(); error.Reason = "Unknown Error"; errors.Add(error); TransactionReportInformation t = new TransactionReportInformation(); t.Errors = errors; response.Add(t); } } return response; }