Immediate Transactions

Visit the Immediate Transactions reference area for background details.

The immediate transaction api client allows you to validate, create and retrieve immediate transactions. Below are code samples that show how to use this client.

Configure a new immediate transaction API client.

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

Validate or create an immediate transaction

A TransactionRequest object needs to be defined to set the payment details when validating or creating an immediate transaction.

// define transaction request
var rq = new TransactionRequest
{
  SendValue = 10,
  SendCurrency = "GBP",
  Recipient = new Recipient
  {
    Name = "SDK TESTING",
    Country = "GB",
    Currency = "GBP",
    RecipientReference = "REF",
    Account = new AccountDescriptor
    {
      AccountNumber = "11111111",
      SortCode = "111111"
    }
  },
};

// validate immediate transaction
Response<TransactionResponse> validateTx = await txClient.ValidateAsync(rq);

// create immediate transaction
Response<TransactionResponse> createTx = await txClient.CreateAsync(rq);

Retrieve immediate transaction

Response<TransactionResponse> createTx = await txClient.CreateAsync(rq);
var txId = createTx.Resource.TransactionId;

// retrieve immediate transaction (by Guid or string)
TransactionResponse dtx = await dtxClient.RetrieveAsync(txId);

Processing Cheques

In addition to sending money to a bank account, our system also supports sending cheques to recipients. We have two dedicated route types that you can use for this purpose. For background reading on cheques, and how to specify these in the API, please see the document on Route Types.

When sending postal cheques, you need to supply a valid postal address. You can do this in the SDK by using the GBAddress and USAddress datatypes - we currently only support cheques for the UK and USA. The example below shows how you could supply a minimal address for sending a cheque to a recipient in the UK...

// define transaction request
var rq = new TransactionRequest
{
  SendValue = 10,
  SendCurrency = "GBP",
  Recipient = new Recipient
  {
    Name = "Mr. Benn",
    Country = "GB",
    Currency = "GBP",
    RecipientReference = "REF",
    Account = AccountDescriptor.Empty,
    Address = new GBAddress {
      Line1: "52 Festive Road",
      Postcode: "SW15 1LP"
    }
  },
  RouteType = RouteType.PostalCheque
};

// Create the transaction...
Response<TransactionResponse> createTx = await txClient.CreateAsync(rq);

The AccountDescriptor property is mandatory but can be supplied using the static AccountDescriptor.Empty property as a concenience.

The Address property is defined as an object, and can be a string (when the RouteType is Cheque), or can be an instance of the GBAddress type or the USAddress type, depending on whether you are sending a cheque to a UK or US recipient.

When retrieving a transaction request from the system using the API, the address element is automatically converted to the appropriate datatype, dependant on the response from our API. Despite the address property being defined as an object on the class, we have implemented a custom JSON converter such that the API response is converted to a string, GBAddress or USAddress, dependant on what was sent to the system in the first place.