Interface PaymentService
-
public interface PaymentServiceContains the interface methods for a payment service. It can be implemented in different networks, like Stellar, Circle, Wyre or others.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description reactor.core.publisher.Mono<Account>createAccount(java.lang.String accountId)API request that creates an account with the given id.reactor.core.publisher.Mono<Account>getAccount(java.lang.String accountId)API request that retrieves the account with the given id.reactor.core.publisher.Mono<PaymentHistory>getAccountPaymentHistory(java.lang.String accountID)API request that returns the history of payments involving a given account.reactor.core.publisher.Mono<DepositInstructions>getDepositInstructions(DepositRequirements config)API request that returns the info needed to make a deposit into a user account.reactor.core.publisher.Mono<java.lang.String>getDistributionAccountAddress()API request that returns the id of the distribution account managed by the secret key.NetworkgetNetwork()java.lang.StringgetSecretKey()java.lang.StringgetUrl()reactor.core.publisher.Mono<java.lang.Void>ping()API request that pings the server to make sure it's up and running.reactor.core.publisher.Mono<Payment>sendPayment(Account sourceAccount, Account destinationAccount, java.lang.String currencyName, java.math.BigDecimal amount)API request that executes a payment between accounts.voidsetNetwork(Network network)voidsetSecretKey(java.lang.String secretKey)voidsetUrl(java.lang.String url)reactor.core.publisher.Mono<java.lang.Void>validateSecretKey()API request that checks with the server if the provided secret key is valid and registered.
-
-
-
Method Detail
-
getNetwork
Network getNetwork()
-
setNetwork
void setNetwork(Network network)
-
getUrl
java.lang.String getUrl()
-
setUrl
void setUrl(java.lang.String url)
-
getSecretKey
java.lang.String getSecretKey()
-
setSecretKey
void setSecretKey(java.lang.String secretKey)
-
ping
reactor.core.publisher.Mono<java.lang.Void> ping() throws HttpExceptionAPI request that pings the server to make sure it's up and running.- Returns:
- asynchronous stream with a Void value. If no exception is thrown it means the request was successful and the remote server is operational.
- Throws:
HttpException- If the http response status code is 4xx or 5xx.
-
validateSecretKey
reactor.core.publisher.Mono<java.lang.Void> validateSecretKey() throws HttpExceptionAPI request that checks with the server if the provided secret key is valid and registered.- Returns:
- asynchronous stream with a Void value. If no exception is thrown it means the request was successful and the secret key is valid.
- Throws:
HttpException- If the http response status code is 4xx or 5xx.
-
getDistributionAccountAddress
reactor.core.publisher.Mono<java.lang.String> getDistributionAccountAddress() throws HttpExceptionAPI request that returns the id of the distribution account managed by the secret key.- Returns:
- asynchronous stream with the id of the distribution account managed by the secret key.
- Throws:
HttpException- If the http response status code is 4xx or 5xx.
-
getAccount
reactor.core.publisher.Mono<Account> getAccount(java.lang.String accountId) throws HttpException
API request that retrieves the account with the given id.- Parameters:
accountId- is the existing account identifier.- Returns:
- asynchronous stream with the account object.
- Throws:
HttpException- If the http response status code is 4xx or 5xx.
-
createAccount
reactor.core.publisher.Mono<Account> createAccount(@Nullable java.lang.String accountId) throws HttpException
API request that creates an account with the given id.- Parameters:
accountId- is the identifier of the account to be created. It could be mandatory or optional depending on the implementation.- Returns:
- asynchronous stream with the account object.
- Throws:
HttpException- If the http response status code is 4xx or 5xx.
-
getAccountPaymentHistory
reactor.core.publisher.Mono<PaymentHistory> getAccountPaymentHistory(java.lang.String accountID) throws HttpException
API request that returns the history of payments involving a given account.- Parameters:
accountID- the id of the account whose payment history we want to fetch.- Returns:
- asynchronous stream with the payment history.
- Throws:
HttpException- If the http response status code is 4xx or 5xx.
-
sendPayment
reactor.core.publisher.Mono<Payment> sendPayment(Account sourceAccount, Account destinationAccount, java.lang.String currencyName, java.math.BigDecimal amount) throws HttpException
API request that executes a payment between accounts. The APIKey needs to have access to the source account for this request to succeed.- Parameters:
sourceAccount- the account making the payment. Only the network and id fields are needed.destinationAccount- the account receiving the payment. The network field and a subset of (id, address and addressTag) will be mandatory.currencyName- the name of the currency used in the payment. It should obey the {scheme}:{identifier} format described in SEP-38.amount- the payment amount.- Returns:
- asynchronous stream with the payment object.
- Throws:
HttpException- If the provided input parameters are invalid.HttpException- If the http response status code is 4xx or 5xx.
-
getDepositInstructions
reactor.core.publisher.Mono<DepositInstructions> getDepositInstructions(DepositRequirements config) throws HttpException
API request that returns the info needed to make a deposit into a user account. This method will be needed if the implementation allows users to make deposits using external networks. For instance, when a user wants to make a deposit to their Circle account through a Stellar payment:// Here we want to check how we can top up a Circle account using USDC funds from the Stellar network. String circleWalletId = "1000066041"; Network fromNetwork = Network.STELLAR; String currencyName = "USD"; // or "USDC" DepositConfiguration config = new DepositConfiguration(circleWalletId, fromNetwork, currencyName); // Here are the instructions with the Stellar account that will receive the payment: DepositInfo depositInfo = getInfoForDeposit(config).block(); System.out.println("PublicKey: " + depositInfo.accountId); // "PublicKey: G..." System.out.println("Memo: " + depositInfo.accountIdTag); // "Memo: 2454278437550473431" System.out.println("Network: " + depositInfo.network); // "Network: stellar" System.out.println("CurrencyName: " + depositInfo.currencyName); // "CurrencyName: stellar:USDC:<circle-issuer>" System.out.println("Extra: " + depositInfo.extra); // "Extra: null"- Parameters:
config- an object containing all configuration options needed for an external user to make a deposit to the desired internal account. Different fields may be mandatory depending on the interface implementation.- Returns:
- asynchronous stream with the info needed to make the deposit.
- Throws:
HttpException- If the http response status code is 4xx or 5xx or if the configuration is not supported by the network.
-
-