asp.net.netweb-serviceschargify

Chargify how can get total transactions of between two dates?


Currently, I am getting only 20 transactions per pages and can be extends only 200 but I need all transaction between that dates no paging.

Or if it possible to get count of transactions?

How can I achieve it?


Solution

  • I would use the following to retrieve all transactions for a subscription:

    bool isFinished = false;
    int counter = 1;
    var results = new Dictionary<int, ITransaction>();
    while (!isFinished)
    {
        // Get results
        var transactions = chargify.GetTransactionsForSubscription(activeSubscription.SubscriptionID, counter++, 20);
    
        // Check condition
        if (transactions.Count == 0) { isFinished = true; continue; }
    
        // Merge results
        transactions.ToList().ForEach(x => results.Add(x.Key, x.Value));
    }
    

    That should get all the transactions and merge them all into the single dictionary. :) If need to use dates, then just switch the data retrieval line to something like this:

    var transactions = chargify.GetTransactionsForSubscription(activeSubscription.SubscriptionID, counter++, 20, null, int.MinValue, int.MinValue, DateTime.Today, DateTime.Now); (just switch to your dates).