square / connect-csharp-sdk

C# client library for the Square Connect APIs
https://docs.connect.squareup.com/
Apache License 2.0
27 stars 25 forks source link

Obtain Batch Token and Paging #115

Closed jmawebtech closed 5 years ago

jmawebtech commented 5 years ago

Hi,

How do I page a list of payments and obtain a batch token? Here is my code:

` public void SearchPayments(DateTime beginTime, DateTime endTime, string locationName) { // Configure OAuth2 access token for authorization: oauth2 Configuration.Default.AccessToken = m_Access_Token;

        var apiInstance = new V1TransactionsApi();
        var locationId = String.IsNullOrEmpty(locationName) ? null : m_Locations.Where(a => a.name == locationName).FirstOrDefault().id;  // string | The ID of the location to list payments for. If you specify me, this endpoint returns payments aggregated from all of the business's locations.
        var limit = 56;  // int? | The maximum number of payments to return in a single response. This value cannot exceed 200. (optional) 
        var includePartial = true;  // bool? | Indicates whether or not to include partial payments in the response. Partial payments will have the tenders collected so far, but the itemizations will be empty until the payment is completed. (optional) 

        try
        {
            // ListPayments
            List<V1Payment> result = apiInstance.ListPayments(locationId, null, beginTime.ToUniversalTime().ToString("o"), endTime.ToUniversalTime().ToString("o"), limit, null, includePartial);
            Debug.WriteLine(result);
        }
        catch (Exception e)
        {
            Debug.Print("Exception when calling V1TransactionsApi.ListPayments: " + e.Message);
        }
    }

`