Interface InterledgerApiClient
- All Known Implementing Classes:
InterledgerApiClientImpl
This client implements a subset of the Interledger Open Payments specification optimized for Fliqa's payment facilitation use cases. It does not support all Interledger flows but focuses on the core payment workflows where Fliqa acts as an intermediary between senders and receivers.
Configuration Requirements
- Client wallet address (payment facilitator/initiator)
- Ed25519 private key for request signing
- Key ID corresponding to the private key
Supported Payment Flow
The client supports a 7-step payment flow where Fliqa facilitates payments between tenants (receivers) and users (senders):
- Wallet Discovery - Get wallet information for receiver and sender
- Receiver Grant - Create access grant for incoming payments
- Incoming Payment - Create payment request with amount
- Sender Quote - Calculate transaction costs and fees
- User Interaction - Redirect user to approve payment
- Payment Finalization - Complete payment after approval
- Status Monitoring - Track payment completion
Security
All requests are cryptographically signed using Ed25519 signatures following the HTTP Message Signatures specification. This ensures request authenticity and integrity when communicating with Interledger servers.
- Since:
- 1.0
- See Also:
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptioncontinueGrant(PaymentPointer sender, Quote quote, URI returnUrl, String nonce) Creates a pending outgoing payment that requires user interaction for authorization.createIncomingPayment(PaymentPointer receiver, AccessGrant pendingGrant, BigDecimal amount) Creates an incoming payment request on the receiver's wallet.createPendingGrant(PaymentPointer receiver) Creates a pending grant for a receiving wallet to enable incoming payment creation.createQuote(String quoteToken, PaymentPointer sender, IncomingPayment incomingPayment) Creates a quote that calculates the exact cost for the sender to complete the payment.createQuoteRequest(PaymentPointer sender) Creates a quote request grant for the sender's wallet.finalizeGrant(OutgoingPayment outgoingPayment, String interactRef) Finalizes the grant after the user has approved the payment.finalizePayment(AccessGrant finalized, PaymentPointer senderWallet, Quote quote) Executes the final payment using the finalized grant.getIncomingPayment(IncomingPayment incomingPayment, AccessGrant grantRequest) Retrieves the current status of an incoming payment.getWallet(WalletAddress address) Retrieves wallet information from an Interledger payment pointer.
-
Field Details
-
INTERNAL_SERVER_ERROR
static final int INTERNAL_SERVER_ERROR- See Also:
-
-
Method Details
-
getWallet
Retrieves wallet information from an Interledger payment pointer.This is typically the first step in any payment flow, used to discover the wallet's supported assets, authorization server, and resource server endpoints. The wallet information is essential for subsequent grant requests and payment operations.
- Parameters:
address- the wallet address that facilitates, sends, or receives payments- Returns:
- wallet information including asset details, authorization server, and resource server URLs
- Throws:
InterledgerClientException- if the wallet cannot be found or accessed- See Also:
-
createPendingGrant
Creates a pending grant for a receiving wallet to enable incoming payment creation.This grant provides Fliqa with permission to create incoming payment requests on behalf of the receiver. The grant includes access tokens that authorize operations like creating, reading, and completing incoming payments.
Step 1 in the payment flow (Receiver side).
- Parameters:
receiver- the wallet that will receive the payment- Returns:
- access grant containing tokens and permissions for incoming payments
- Throws:
InterledgerClientException- if the grant cannot be created or the wallet rejects the request- See Also:
-
createIncomingPayment
IncomingPayment createIncomingPayment(PaymentPointer receiver, AccessGrant pendingGrant, BigDecimal amount) throws InterledgerClientException Creates an incoming payment request on the receiver's wallet.This establishes a payment destination with a specific amount that senders can pay to. The incoming payment serves as the target for the outgoing payment from the sender's wallet.
Step 2 in the payment flow (Receiver side).
- Parameters:
receiver- the wallet that will receive the paymentpendingGrant- access grant obtained fromcreatePendingGrant(PaymentPointer)amount- the payment amount with two decimal places precision- Returns:
- incoming payment request that can be referenced by sender wallets
- Throws:
InterledgerClientException- if the payment request cannot be created- See Also:
-
createQuoteRequest
Creates a quote request grant for the sender's wallet.This grant provides permission to request quotes from the sender's wallet, which is necessary to calculate transaction fees and exchange rates before creating the actual payment.
Step 3 in the payment flow (Sender side).
- Parameters:
sender- the wallet that will send the payment- Returns:
- access grant for creating quotes on the sender's wallet
- Throws:
InterledgerClientException- if the quote request grant cannot be created- See Also:
-
createQuote
Quote createQuote(String quoteToken, PaymentPointer sender, IncomingPayment incomingPayment) throws InterledgerClientException Creates a quote that calculates the exact cost for the sender to complete the payment.The quote includes the debit amount (what the sender pays) and receive amount (what the receiver gets), accounting for any transaction fees and currency conversions. This quote links the sender's wallet to the specific incoming payment.
Step 4 in the payment flow (Sender side).
- Parameters:
quoteToken- access token from the quote request grantsender- the wallet that will send the paymentincomingPayment- the target payment request created on the receiver's wallet- Returns:
- quote containing debit amount, receive amount, and payment details
- Throws:
InterledgerClientException- if the quote cannot be generated- See Also:
-
continueGrant
OutgoingPayment continueGrant(PaymentPointer sender, Quote quote, URI returnUrl, String nonce) throws InterledgerClientException Creates a pending outgoing payment that requires user interaction for authorization.This step initiates the interactive authorization flow where the user must visit a redirect URL to approve the payment in their wallet. The user will be redirected back to the return URL with an interaction reference upon completion.
Step 5 in the payment flow (Sender side).
- Parameters:
sender- the wallet that will send the paymentquote- the quote generated for this paymentreturnUrl- URI where the user will be redirected after payment authorizationnonce- unique identifier to prevent replay attacks and maintain state- Returns:
- outgoing payment with interaction details including the redirect URL
- Throws:
InterledgerClientException- if the payment cannot be created- See Also:
-
finalizeGrant
AccessGrant finalizeGrant(OutgoingPayment outgoingPayment, String interactRef) throws InterledgerClientException Finalizes the grant after the user has approved the payment.Once the user completes the interactive authorization flow, they are redirected back with an interaction reference. This method uses that reference to finalize the grant and obtain the final access token needed to execute the payment.
Step 6 in the payment flow (Client side).
- Parameters:
outgoingPayment- the pending payment to be finalizedinteractRef- interaction reference returned from the user's wallet after authorization- Returns:
- finalized access grant with tokens to execute the payment
- Throws:
InterledgerClientException- if the grant cannot be finalized or the interaction reference is invalid- See Also:
-
finalizePayment
Payment finalizePayment(AccessGrant finalized, PaymentPointer senderWallet, Quote quote) throws InterledgerClientException Executes the final payment using the finalized grant.This method transfers the funds from the sender's wallet to the receiver's wallet using the finalized access grant. The payment amount and details are based on the previously generated quote.
Step 7 in the payment flow (Client side).
- Parameters:
finalized- the finalized access grant obtained fromfinalizeGrant(OutgoingPayment, String)senderWallet- the wallet that will send the paymentquote- the quote that determines payment amounts and fees- Returns:
- completed payment details including transaction ID and status
- Throws:
InterledgerClientException- if the payment execution fails- See Also:
-
getIncomingPayment
IncomingPayment getIncomingPayment(IncomingPayment incomingPayment, AccessGrant grantRequest) throws InterledgerClientException Retrieves the current status of an incoming payment.This method is used to monitor payment completion and track the received amount. It can be called multiple times to poll for payment status updates until the payment is marked as completed.
- Parameters:
incomingPayment- the incoming payment to checkgrantRequest- the access grant that provides permission to read the payment- Returns:
- current payment status including completion state and received amount
- Throws:
InterledgerClientException- if the payment cannot be found or access is denied- See Also:
-