Stored Recipient

Visit the Stored Recipient reference area for background details.

The stored recipient API client allows you to create, retrieve, update and delete stored recipients. Below are code samples that show how to use this client.

Configure a new stored recipient API client

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

Create a stored recipient

A StoredRecipient object is required to define the details in order to create a stored recipient.

// define stored recipient
var recipientInfo = new StoredRecipient
{
  Name = "SDK Testing",
  Country = "GB",
  Currency = "GBP",
  ExternalStoredRecipientId = Guid.NewGuid().ToString(),
  Account = new AccountDescriptor
  {
    AccountNumber = "11111111",
    SortCode = "111111"
  }
};

// create stored recipient
Response<StoredRecipient> newRecipient = 
  await storedRecipientClient.CreateAsync(recipientInfo);

Retrieve stored recipients

A specific stored recipient can be retrieved as well as all stored recipients.

Response<StoredRecipient> newRecipient = 
  await storedRecipientClient.CreateAsync(recipientInfo);
recipientId = newRecipient.Resource.ExternalStoredRecipientId;

// retrieve stored recipient
StoredRecipient retrievedRecipient = 
  await storedRecipientClient.RetrieveAsync(recipientId);

// retrieve all stored recipients
List<StoredRecipient> allRecipients = 
  await storedRecipientClient.RetrieveRecipientsAsync();

Update stored recipient

Updating a stored recipient requires a StoredRecipient object to be used with any changes specified.

var recipient = await storedRecipientClient.RetrieveAsync(recipientId);
recipient.Name = "New Name";
recipient.Email = "[email protected]"

// update stored recipient
Response<StoredRecipient> updatedRecipient = 
  await storedRecipientClient.UpdateAsync(recipient);

Delete a stored recipient

Response<StoredRecipient> newRecipient = 
  await storedRecipientClient.CreateAsync(recipientInfo);
recipientId = newRecipient.Resource.ExternalStoredRecipientId;

// delete stored recipient
Response<StoredRecipient> deletedRecipient = 
  await storedRecipientClient.DeleteAsync(recipientId);