The Technical Preview of Corda Payments is Here!

January 13, 2022

By Dr. Iryna Tsimashenka

R3 has launched the Technical Preview of Corda Payments, a new payment initiation and processing module for CorDapps. Corda Payments enables developers to quickly connect to traditional off-ledger payment rails and payment service providers with minimal coding. Corda Payments includes out-of-the-box integration with Modulr—a banking as a service provider for UK and EU real-time payments that can initiate a payment on behalf of the customer. With minimal code, developers can initiate a payment instruction, check balances, review transaction history and view the payment status. The agent application then orchestrates the payment by taking the instructions from the payment flow and routes the transaction to Modulr.

Sign up for your Corda Payments trial today on Customer Hub.

How It Works

Corda Payments Technical Preview comprises of two core components:

  • Agent CorDapp: A closed source JAR operated by a Business Network Operator. It can use an existing Corda network or establish a new permissioned Corda Payments Network. The operator needs to own a node and install the Corda Payments Agent CorDapp.
    • Gateway Service: This collects payment requests from the vault within the Agent CorDapp and makes a call to the REST API endpoints of the PSP to try and process the payment.
  • Corda Payments SDK: A library that integrates with the user’s CorDapp, allowing the end user to initiate a payment. You can use it to send payment instructions on the Corda Payments Network to the Agent.

Additionally, we are providing :

  • Sample Agent UI – This is a sample React front end which can be used with the Agent to provide an enhanced user experience for testing and using the Corda Payments system.
  • Sample Client UI – This is a sample React front end which connects to one of the nodes on the network and can carry out limited functionality using the SDK. This front is an easy way to view the capabilities of the SDK without having to write code. 
  • Sample CorDapp – This is a sample CorDapp template which includes SDK configuration instructions and sample code to showcase how to integrate the SDK into a new or existing CorDapp. This is not a CorDapp in the traditional sense but a template to allow one to easily set up a CorDapp.

This diagram shows high-level components included in the preview, and an example of a simple payment flow.

Diagram 1. High-level payment workflow and components
Diagram 1. High-level payment workflow and components

Features

The main features of the Corda Payments Technical Preview include:

Client CorDapp

This is where the end user writes business logic and creates payment instructions.

Agent

This is a trusted party on the network — usually the Business Network Operator. As the Agent, you will facilitate payments through to the integration with the PSP, Modulr. The Agent is responsible for:

  • Setting up the customer account on Modulr on behalf of the customer and removing the pain of KYB and compliance checks. 
  • Payment facilitation – Since it sits in the middle of the business network, the Agent facilitates payment instructions. An Agent can’t make a payment on the user’s behalf but can review any errors that may occur when processing the transaction.

PSP

This is an external payment service provider (PSP).  Our current integration is with Modulr who provides us with direct access to UK Faster Payments and SEPA. We are working with Modulr to establish other alternative payment routes on behalf of the Agent. The workflow is: 

  1. An end user initiates payment instructions to make a payment. 
  2. The Agent sends the payments to the PSP. 
  3. The PSP responds to say that the payment has been successfully received and accepted.
  4. The PSP will then send a second payment status to confirm settlement success.
  5. The Agent receives the payment status from the PSP and in turn updates the payment status through to the CorDapp for end user visibility.

We have designed the technical preview to provide the core payment capabilities our Corda customers require, whilst delivering a seamless digital experience as the user remains within the Corda environment. Payments will be processed off ledger using traditional payments rails. Payments rails are optimised to offer the fastest settlement service and status is tracked and updated on the ledger and held within the vault.

Low-level Components of Corda Payments

This diagram shows the end user infrastructure and the Agent infrastructure in more detail:

Diagram 2. Low-level Components of Corda Payments
Diagram 2. Low-level Components of Corda Payments

R3 provides fully prewritten end user and Agent infrastructure. It contains the:

  • Agent CorDapp – the network operator installs this on the Agent node.
  • Key storage for storing Agent’s credentials.

The Agent exposes the Agent REST API for Agent operations staff to interact with the Agent infrastructure. There will also be a sample Agent GUI provided as part of the release.

The above diagram shows the components of a Business CorDapp.

User-written Components

  • Business CorDapp flows
  • Web server
  • Business CorDapp UI

The Payments SDK

  • Payment Flows APIs
  • The State Machine, which is shared with the Agent CorDapp and the Vault Listener.

The end user interacts with the Payments CorDapp. Business CorDapp flows use Payments SDK calls and interact with the payments infrastructure. The end user needs to write business logic to drive Payments SDK calls. The Payments SDK provides an easy way to integrate a set of generic Payments Service APIs, which trigger the State Machine to execute payments and return a status update to the Vault Listener.

Here’s an example of a payment execution from the user’s perspective, simplified to one line. Consider the following example of establishing a connection (line 1), getting a list of nodes on the network (line 3), and making a payment (line 20):

val clientConnection = client.start(rpcUsername, rpcPassword)
val proxy = clientConnection.proxy
val nodes = proxy.networkMapSnapshot()

val partyA = getNodeWithName(nodes,"PartyA", "O=PartyA, L=London, C=GB")
val partyB = getNodeWithName(nodes,"PartyB", "O=PartyB, L=New York, C=US")

// Instead of searching for accounts owned by PartyA you can simply pass the PaymentAccountId to the MakePayment flow
val accountA = proxy.startTrackedFlow(
    ::PaymentAccounts,
    partyA
).returnValue.getOrThrow().first()

// Instead of searching for accounts owned by PartyB you can simply pass the PaymentAccountId to the MakePayment flow
val accountB = proxy.startTrackedFlow(
    ::PaymentAccounts,
    partyB
).returnValue.getOrThrow().first()

val paymentState = proxy.startTrackedFlow(
    ::MakePayment,
    250 of GBP,
    accountA.accountId,
    accountB.accountId
).returnValue.getOrThrow()

Code snippet: https://gist.github.com/iryna-09/b91709491e5f950d43ea250618ce03ce

Payment can be achieved through a simple one-line payment instruction with only three parameters (amount, debtor, and creditor).

We are keen to get feedback and comments on Corda Payments to make improvements and meet your needs. For this and together with any questions please use our Slack payments channel.

Sign up for your trial on Customer Hub to start using Corda Payments today!

Share: