Account Movements

Visit the Account Movements reference area for further details.

The account movements API client allows you to create, retrieve and approve/cancel account movements. Below are code samples that show how to use this client.

Configure a new account movements API client

var config = new Configuration("{api-token}", Environment.Staging);
var accountMovementsClient = new AccountMovementsApiClient(config);

Validate or Create an account movement

A AccountMovement object is required to define the details in order to create an account movement.

// define account movement
var accMovementRequest = new AccountMovementRequest 
{
  CreditAccountId = 123,
  DebitAccountId = 987,
  CreditAmount = 10.50, // either credit or debit amount is required
  PaymentReference = "Ref-1",
  MerchantReference = "Ref-2",
  Narrative = "Ref-3"
};

// validate stored recipient request
Response<ErrorResponse> response = await accountMovementsClient.ValidateAsync(accMovementRequest);

// create stored recipient request
Response<AccountMovement> response = await accountMovementsClient.CreateAsync(accMovementRequest);

Retrieve account movement

A specific account movement can be retrieved as well as all account movements.

Response<AccountMovement> newMovement = 
  await accountMovementsClient.CreateAsync(accountMovement);
var accountMovementId = newMovement.Resource.AccountMovementId;

// retrieve stored recipient
AccountMovement retrievedRecipient = 
  await accountMovementsClient.GetIndividualAsync(accountMovementId);

When retrieving account movements a query is required, this can be specified by creating classes that inherit from the AccountEntryQueryBase class. Below are examples of how to use this to query by count, max account movement ID, date range and account movement ID range.

Not the count parameter is optional for all queries where the default is 25.

// retrieve all stored recipients
var accountMovementQuery = new AccountMovementQuery();
  
// retrieve all account movements with optional count and max ID
var queryWithMaxIdAndCount = new AccountMovementQuery(123L, 10);

// retrieve all account movements with date range and optional count
var queryByDateRangeAndCount = 
  new AccountMovementQueryByDateRange(DateTime.Now.AddDays(-1), DateTime.Now);
  
// query by start entry id, end entry id and an option of count
var queryByEntryRange = new AccountMovementQueryByEntryIdRange(5000L, 600L, 10);

The query can then be used to get account movements in a paginated fashion.

IPage<AccountMovement, Uri> firstPage = 
  await accountMovementsClient.GetListAsync(accountMovementQuery);

// get next page of results using token
IPage<AccountMovement, Uri> nextPage = accountMovementsClient.ContinueGetListAsync(firstPage.NextPageToken);
  
// get next page of results
IPage<AccountMovement, Uri> nextPage = accountMovementsClient.GetNextPageAsync();

// get current account movements in the page returned
IEnumerable<AccountMovement> accountMovements = nextPage.CurrentItems;

// check if there are more account entries
bool moreResults = firstPage.HasMoreResults;

Update account movement

When an account movement is created, it also needs to be Approved or Cancelled otherwise it will expire after 15 mins.

int id = 123;

// Approve account movement
Response approved = await accountMovementsClient.UpdateAysnc(id, ApprovedOrCancelled.Approved);

// Cancel account movement
Response approved = await accountMovementsClient.UpdateAysnc(id, ApprovedOrCancelled.Cancelled);