Ejemplo n.º 1
0
        /// <summary>
        /// Gets the payments that have been processed for any scheduled transactions
        /// </summary>
        /// <param name="startDate">The start date.</param>
        /// <param name="endDate">The end date.</param>
        /// <param name="errorMessage">The error message.</param>
        /// <returns></returns>
        public override List <Payment> GetPayments(FinancialGateway financialGateway, DateTime startDate, DateTime endDate, out string errorMessage)
        {
            errorMessage = string.Empty;
            List <Payment> paymentList  = new List <Payment>();
            var            reportParams = new Dictionary <string, string>();
            var            reportingApi = new Reporting.Api(
                GetAttributeValue(financialGateway, "MerchantID"),
                GetAttributeValue(financialGateway, "TransactionKey"),
                GetAttributeValue(financialGateway, "ReportUser"),
                GetAttributeValue(financialGateway, "ReportPassword"),
                GetAttributeValue(financialGateway, "Mode").Equals("Live", StringComparison.CurrentCultureIgnoreCase)
                );

            TimeSpan timeDifference = endDate - startDate;

            for (int offset = 0; offset <= timeDifference.TotalDays; offset++)
            {
                DateTime offsetDate = startDate.AddDays(offset) < endDate?startDate.AddDays(offset) : endDate;

                reportParams.Add("date", offsetDate.ToString("yyyy/MM/dd"));

                DataTable dt = reportingApi.GetReport("SubscriptionDetailReport", reportParams, out errorMessage);
                if (dt != null && dt.Rows.Count > 0)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        var payment = new Payment();

                        decimal amount = decimal.MinValue;
                        payment.Amount = decimal.TryParse(row["Amount"].ToString(), out amount) ? amount : 0.0M;

                        var time = DateTime.MinValue;
                        payment.TransactionDateTime = DateTime.TryParse(row["Time"].ToString(), out time) ? time : DateTime.MinValue;

                        payment.TransactionCode   = row["Code"].ToString();
                        payment.GatewayScheduleId = row["Schedule"].ToString();
                        payment.ScheduleActive    = row["Status"].ToString() == "CURRENT";
                        paymentList.Add(payment);
                    }
                }

                reportParams.Clear();
            }

            if (paymentList.Any())
            {
                return(paymentList);
            }
            else
            {
                errorMessage = "The subscription detail report did not return any data for the timeframe";
                return(null);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the payments that have been processed for any scheduled transactions
        /// </summary>
        /// <param name="startDate">The start date.</param>
        /// <param name="endDate">The end date.</param>
        /// <param name="errorMessage">The error message.</param>
        /// <returns></returns>
        public override List<Payment> GetPayments( FinancialGateway financialGateway, DateTime startDate, DateTime endDate, out string errorMessage )
        {
            errorMessage = string.Empty;
            List<Payment> paymentList = new List<Payment>();
            var reportParams = new Dictionary<string, string>();
            var reportingApi = new Reporting.Api(
                GetAttributeValue( financialGateway, "MerchantID" ),
                GetAttributeValue( financialGateway, "TransactionKey" ),
                GetAttributeValue( financialGateway, "ReportUser" ),
                GetAttributeValue( financialGateway, "ReportPassword" ),
                GetAttributeValue( financialGateway, "Mode" ).Equals( "Live", StringComparison.CurrentCultureIgnoreCase )
            );

            TimeSpan timeDifference = endDate - startDate;
            for ( int offset = 0; offset <= timeDifference.TotalDays; offset++ )
            {
                DateTime offsetDate = startDate.AddDays( offset ) < endDate ? startDate.AddDays( offset ) : endDate;
                reportParams.Add( "date", offsetDate.ToString( "yyyy/MM/dd" ) );

                DataTable dt = reportingApi.GetReport( "SubscriptionDetailReport", reportParams, out errorMessage );
                if ( dt != null && dt.Rows.Count > 0 )
                {
                    foreach ( DataRow row in dt.Rows )
                    {
                        var payment = new Payment();

                        decimal amount = decimal.MinValue;
                        payment.Amount = decimal.TryParse( row["Amount"].ToString(), out amount ) ? amount : 0.0M;

                        var time = DateTime.MinValue;
                        payment.TransactionDateTime = DateTime.TryParse( row["Time"].ToString(), out time ) ? time : DateTime.MinValue;

                        payment.TransactionCode = row["Code"].ToString();
                        payment.GatewayScheduleId = row["Schedule"].ToString();
                        payment.ScheduleActive = row["Status"].ToString() == "CURRENT";
                        paymentList.Add( payment );
                    }
                }

                reportParams.Clear();
            }

            if ( paymentList.Any() )
            {
                return paymentList;
            }
            else
            {
                errorMessage = "The subscription detail report did not return any data for the timeframe";
                return null;
            }
        }