Stellar PHP SDK API Documentation

InteractiveService
in package

Implements SEP-0024 - Hosted Deposit and Withdrawal.

See <https://github.com/stellar/stellar-protocol/blob/v3.8.0/ecosystem/sep-0024.md" target="_blank">Hosted Deposit and Withdrawal

Table of Contents

Methods

__construct()  : mixed
Constructor.
deposit()  : SEP24InteractiveResponse
A deposit is when a user sends an external token (BTC via Bitcoin, USD via bank transfer, etc...) to an address held by an anchor. In turn, the anchor sends an equal amount of tokens on the Stellar network (minus fees) to the user's Stellar account.
fee()  : SEP24FeeResponse
Get the anchor's to reported fee that would be charged for a given deposit or withdraw operation.
fromDomain()  : InteractiveService
Constructs an InteractiveService instance by parsing the server service address from the given domain using sep-01.
info()  : SEP24InfoResponse
Get the anchors basic info about what their TRANSFER_SERVER_SEP0024 support to wallets and clients.
setMockHandlerStack()  : mixed
transaction()  : SEP24TransactionResponse
The transaction endpoint enables clients to query/validate a specific transaction at an anchor.
transactions()  : SEP24TransactionsResponse
The transaction history endpoint helps anchors enable a better experience for users using an external wallet.
withdraw()  : SEP24InteractiveResponse
This operation allows a user to redeem an asset currently on the Stellar network for the real asset (BTC, USD, stock, etc...) via the anchor of the Stellar asset.

Methods

__construct()

Constructor.

public __construct(string $serviceAddress[, Client|null $httpClient = null ]) : mixed
Parameters
$serviceAddress : string

the server address of the sep-24 service (e.g. from sep-01).

$httpClient : Client|null = null

optional http client to be used for the requests. If not provided, then uses an own client.

deposit()

A deposit is when a user sends an external token (BTC via Bitcoin, USD via bank transfer, etc...) to an address held by an anchor. In turn, the anchor sends an equal amount of tokens on the Stellar network (minus fees) to the user's Stellar account.

public deposit(SEP24DepositRequest $request) : SEP24InteractiveResponse

The deposit endpoint allows a wallet to get deposit information from an anchor, so a user has all the information needed to initiate a deposit. It also lets the anchor specify additional information that the user must submit interactively via a popup or embedded browser window to be able to deposit.

Parameters
$request : SEP24DepositRequest

the request data.

Tags
throws
RequestErrorException

if the server responds with an error and corresponding error message.

throws
SEP24AuthenticationRequiredException

if the server responds with an authentication_required error.

throws
GuzzleException

if another request error occurred.

Return values
SEP24InteractiveResponse

the parsed response.

fee()

Get the anchor's to reported fee that would be charged for a given deposit or withdraw operation.

public fee(SEP24FeeRequest $request) : SEP24FeeResponse

This endpoint is deprecated in favor of SEP-38 GET /price endpoint for obtaining fee information. Anchors should implement SEP-38 for more comprehensive pricing and fee data including exchange rates. Clients should migrate to using SEP-38 GET /price for new implementations.

This is important to allow an anchor to accurately report fees to a user even when the fee schedule is complex. If a fee can be fully expressed with the fee_fixed, fee_percent or fee_minimum fields in the /info response, then an anchor will not implement this endpoint.

Parameters
$request : SEP24FeeRequest

the request data.

Tags
throws
RequestErrorException

if the server responds with an error and corresponding error message.

throws
SEP24AuthenticationRequiredException

if the server responds with an authentication_required error.

throws
GuzzleException

if another request error occurred.

see
https://github.com/stellar/stellar-protocol/blob/v2.5.0/ecosystem/sep-0038.md

SEP-38 Anchor RFQ API

Return values
SEP24FeeResponse

the parsed response.

fromDomain()

Constructs an InteractiveService instance by parsing the server service address from the given domain using sep-01.

public static fromDomain(string $domain[, Client|null $httpClient = null ]) : InteractiveService
Parameters
$domain : string

the domain to parse the data from. e.g. 'testanchor.stellar.org'.

$httpClient : Client|null = null

optional http client to be used for the requests. If not provided, then uses an own client.

Tags
throws
Exception

if the service address could not be loaded from the given domain.

Return values
InteractiveService

the constructed InteractiveService object.

info()

Get the anchors basic info about what their TRANSFER_SERVER_SEP0024 support to wallets and clients.

public info([string|null $lang = null ]) : SEP24InfoResponse
Parameters
$lang : string|null = null

(optional) Language code specified using ISO 639-1. description fields in the response should be in this language. Defaults to en.

Tags
throws
GuzzleException

if a request exception occurs.

Return values
SEP24InfoResponse

response the parsed response.

setMockHandlerStack()

public setMockHandlerStack(HandlerStack $handlerStack) : mixed
Parameters
$handlerStack : HandlerStack

transaction()

The transaction endpoint enables clients to query/validate a specific transaction at an anchor.

public transaction(SEP24TransactionRequest $request) : SEP24TransactionResponse

Anchors must ensure that the SEP-10 JWT included in the request contains the Stellar account and optional memo value used when making the original deposit or withdraw request that resulted in the transaction requested using this endpoint.

Parameters
$request : SEP24TransactionRequest

the request data.

Tags
throws
RequestErrorException

if the server responds with an error and corresponding error message.

throws
SEP24AuthenticationRequiredException

if the server responds with an authentication_required error.

throws
SEP24TransactionNotFoundException

if the anchor could not find the transaction.

throws
GuzzleException

if another request error occurred.

Return values
SEP24TransactionResponse

the parsed response.

transactions()

The transaction history endpoint helps anchors enable a better experience for users using an external wallet.

public transactions(SEP24TransactionsRequest $request) : SEP24TransactionsResponse

With it, wallets can display the status of deposits and withdrawals while they process and a history of past transactions with the anchor. It's only for transactions that are deposits to or withdrawals from the anchor. It returns a list of transactions from the account encoded in the authenticated JWT.

Parameters
$request : SEP24TransactionsRequest

the request data.

Tags
throws
RequestErrorException

if the server responds with an error and corresponding error message.

throws
SEP24AuthenticationRequiredException

if the server responds with an authentication_required error.

throws
GuzzleException

if another request error occurred.

Return values
SEP24TransactionsResponse

the parsed response.

withdraw()

This operation allows a user to redeem an asset currently on the Stellar network for the real asset (BTC, USD, stock, etc...) via the anchor of the Stellar asset.

public withdraw(SEP24WithdrawRequest $request) : SEP24InteractiveResponse

The withdraw endpoint allows a wallet to get withdrawal information from an anchor, so a user has all the information needed to initiate a withdrawal. It also lets the anchor specify the url for the interactive webapp to continue with the anchor's side of the withdrawal.

Parameters
$request : SEP24WithdrawRequest

the request data

Tags
throws
RequestErrorException

if the server responds with an error and corresponding error message.

throws
SEP24AuthenticationRequiredException

if the server responds with an authentication_required error.

throws
GuzzleException

if another request exception occurred.

Return values
SEP24InteractiveResponse

the parsed response.


        
On this page

Search results