Skip to content

Commit d1636fb

Browse files
committed
feat: simple Rafiki integration guide
1 parent 4f25c87 commit d1636fb

2 files changed

Lines changed: 118 additions & 0 deletions

File tree

559 KB
Loading
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
---
2+
title: 'Simple Rafiki Integration Guide'
3+
description: 'TBD'
4+
date: 2026-03-18
5+
slug: simple-rafiki-integration-guide
6+
authors:
7+
- Max Kurapov
8+
author_urls:
9+
- https://github.com/mkurapov
10+
tags:
11+
- Rafiki
12+
- Integration
13+
- Updates
14+
---
15+
16+
17+
## ASE and Rafiki responsibilities
18+
19+
![Overview of responsibilities between ASE and Rafiki](/developers/img/blog/2026-03-18/responsibilites.png)
20+
21+
## Open Payments and ILP
22+
23+
### Open Payments API
24+
Open Payments is an API standard for allowing **third-party clients** to initiate payments between wallet addresses.
25+
26+
#### Use cases
27+
- eCommerce payments
28+
- Peer to peer payments (e.g. remittances)
29+
- Recurring payments (e.g. subscriptions)
30+
31+
### ILP (Interledger Protocol)
32+
A protocol for transferring payments (through packets).
33+
If the Open Payments API is responsible for payment authorization, then ILP is **how** the payments actually happen.
34+
35+
### Basic concepts
36+
#### Wallet addresses
37+
A wallet address is a sharable identifier (URL) linked to an underlying user account at an ASE, and accessible via the Open Payments API standard.
38+
39+
#### Assets
40+
Assets represent monetary values, for example, country currencies. Each asset is made up of a code, and a scale to represent the decimal units. For example, US dollars can be deliniated as code: `USD`, with scale `2`, where value `1000` represents `$10.00`.
41+
42+
### Integrating Rafiki with your system
43+
#### Components
44+
Currently, Rafiki is made up of three software components:
45+
- `backend`: hosts the Open Payments resource server, ILP connector, and the Admin API
46+
- `auth`: hosts the Open Payments auth server
47+
- `frontend`: UI to manage the Rafiki resources (wallet addresses, payments, assets, e.t.c.) through the Admin API.
48+
49+
#### Admin API
50+
As an ASE, the main entrypoint into the Rafiki system will be through the Admin API. This is a GraphQL API.
51+
52+
### Integration steps
53+
#### Creating assets
54+
In order to begin your Rafiki integration, you need to load the assets you will support for your users. For example, if you will be supporting US dollars, you must create an USD asset in Rafiki [through the Admin UI or Admin API](https://rafiki.dev/integration/requirements/assets/).
55+
56+
#### Creating wallet addresses
57+
After creating at least one asset, you can start [creating wallet addresses](https://rafiki.dev/integration/requirements/wallet-addresses/) under that asset. This wallet address must be linked to a user account in your sytem, and will be publicly accessible through the Open Payments API.
58+
59+
#### Making payments
60+
Making payments consists of three parts:
61+
62+
63+
##### 1. Creating an incoming payment
64+
First, you will need to create an incoming payment for a recipient's wallet address using the [Admin API's `createIncomingPayment`](https://rafiki.dev/apis/graphql/backend/#mutation-createIncomingPayment). This will set up a resource to pay into.
65+
66+
##### 2. Creating a quote
67+
Second, you will need to create a quote for a sender's wallet address using the [Admin API's `createQuote`](https://rafiki.dev/apis/graphql/backend/#mutation-createQuote). This will show how much it will cost the sender to deliver an amount to the receiver.
68+
69+
##### 3. Creating an outgoing payment
70+
Third, you will create an outgoing payment for the sender's wallet address using the [Admin API's `createOutgoingPayment`](https://rafiki.dev/apis/graphql/backend/#mutation-createOutgoingPayment). This will be the operation to actually start the payment. At this point, you as the ASE will need to fund/approve the outgoing payment before it gets sent.
71+
72+
###### Webhook request handling
73+
When operating Rafiki, you as the ASE will be notified about events that happen in the system, e.g. an incoming payment was created or expired. Some of these events are actionable, for example, the outgoing payment created event. When an outgoing payment is created, you as the ASE will need to:
74+
1. Check that the user account (for the linked wallet address) is active
75+
2. Check that the user account has enough balance to make the payment
76+
3. Reserve funds on the user account
77+
4. Notify Rafiki to approve the outgoing payment by calling the [`depositOutgoingPaymentLiquidity` API](https://rafiki.dev/apis/graphql/backend/#mutation-depositOutgoingPaymentLiquidity).
78+
79+
Once the outgoing payment has been approved/funded, Rafiki will make the payment between the sender and receiver.
80+
81+
5. If the payment in Rafiki is successful, you will receive an outgoing payment completed webhook. When this is received, you should finalize the debit of the sending user's account.
82+
6. You will also receive an incoming payment completed (or incoming payment expired) webhook. For these webhooks, you should credit the recepient's user account.
83+
84+
85+
```mermaid
86+
sequenceDiagram
87+
participant ASE as ASE (you)
88+
participant R as Rafiki
89+
90+
91+
ASE ->> R: createIncomingPayment Admin API
92+
R -->> ASE: incoming_payment.created webhook
93+
ASE ->> R: Create quote
94+
95+
ASE ->> R: createOutgoingPayment Admin API
96+
R -->> ASE: outgoing_payment.created webhook
97+
ASE ->> ASE: Check user account status, balance & reserve funds
98+
ASE ->> R: depositOutgoingPaymentLiquidity Admin API
99+
R ->> R: Payment is made between sender and receiver
100+
R -->> ASE: outgoing_payment.completed webhook
101+
ASE ->> ASE: Finalize debit on sender account
102+
R -->> ASE: incoming_payment.completed (or expired) webhook
103+
ASE ->> ASE: Credit receiver's account
104+
```
105+
106+
The [Rafiki documentation](https://rafiki.dev/integration/requirements/webhook-events/) describes all of the webhook events and how they should be handled.
107+
108+
> [!NOTE]
109+
> When Rafiki sends a webhook to the ASE, it expects a 200 response. Otherwise, it will keep retrying.
110+
111+
## FAQ
112+
### What APIs are exposed publicly?
113+
Open Payments endpoints + ILP connector. The Admin API must not be exposed externally.
114+
115+
116+
### Can you make cross-currency payments?
117+
In order to make cross-currency payments, you will need to create the corresponding assets, and [provide a way for Rafiki to fetch rates](https://rafiki.dev/integration/requirements/exchange-rates/).
118+

0 commit comments

Comments
 (0)