Stellar PHP SDK API Documentation

PutCustomerInfoRequestBuilder extends RequestBuilder

Request builder for PUT /customer endpoint operations.

This builder constructs HTTP requests to submit or update customer KYC information to the anchor's SEP-12 endpoint. It supports submitting standard SEP-9 fields (name, address, etc.), custom fields, and binary files (ID documents, proof of address).

The request uses multipart/form-data encoding to support both text fields and file uploads in a single request. The anchor returns a customer ID that can be used in subsequent requests.

Example usage:

$fields = ['first_name' => 'John', 'last_name' => 'Doe'];
$files = ['photo_id_front' => $imageBytes];
$builder = new PutCustomerInfoRequestBuilder($httpClient, $serviceAddress, $fields, $files, $jwt);
$response = $builder->execute();
Tags
see
https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0012.md#customer-put

SEP-12 v1.15.0

see
https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0009.md

SEP-9 Standard KYC Fields

see
KYCService::putCustomerInfo()

For the service method using this builder

see
PutCustomerInfoResponse

For the response structure

since
1.0.0

Table of Contents

Constants

HEADERS  = ["X-Client-Name" => "stellar_php_sdk", "X-Client-Version" => \Soneso\StellarSDK\StellarSDK::VERSION_NR]

Properties

$httpClient  : Client
$queryParameters  : array<string|int, mixed>
$segments  : array<string|int, mixed>

Methods

__construct()  : mixed
Constructor for building PUT /customer requests.
buildUrl()  : string
Builds the complete URL for the request.
cursor()  : RequestBuilder
Sets <code>cursor</code> parameter on the request.
execute()  : PutCustomerInfoResponse
Builds and executes the customer information submission request.
executeRequest()  : Response
Executes an HTTP request to Horizon and returns a parsed response object
getAndStream()  : void
Streams Server-Sent Events from Horizon to a callback function
limit()  : RequestBuilder
Sets <code>limit</code> parameter on the request.
order()  : RequestBuilder
Sets <code>order</code> parameter on the request.
request()  : PutCustomerInfoResponse
Executes the HTTP request to submit customer information.
setSegments()  : RequestBuilder
Sets the URL path segments for this request

Constants

HEADERS

public mixed HEADERS = ["X-Client-Name" => "stellar_php_sdk", "X-Client-Version" => \Soneso\StellarSDK\StellarSDK::VERSION_NR]

Properties

$queryParameters

protected array<string|int, mixed> $queryParameters

Methods

__construct()

Constructor for building PUT /customer requests.

public __construct(Client $httpClient, string $serviceAddress[, array<string|int, mixed>|null $fields = null ][, array<string|int, string>|null $files = null ][, string|null $jwtToken = null ]) : mixed
Parameters
$httpClient : Client

The HTTP client to use for sending requests

$serviceAddress : string

The base URL of the SEP-12 KYC service endpoint

$fields : array<string|int, mixed>|null = null

Customer data fields to submit

$files : array<string|int, string>|null = null

Binary file data to upload (field name => file bytes)

$jwtToken : string|null = null

JWT token for authentication obtained via SEP-10

buildUrl()

Builds the complete URL for the request.

public buildUrl() : string
Return values
string

The fully constructed URL for customer information submission

cursor()

Sets <code>cursor</code> parameter on the request.

public cursor(string $cursor) : RequestBuilder

A cursor is a value that points to a specific location in a collection of resources. The cursor attribute itself is an opaque value meaning that users should not try to parse it.

Parameters
$cursor : string
Tags
see
https://developers.stellar.org

Stellar developer docs Pagination documentation

Return values
RequestBuilder

executeRequest()

Executes an HTTP request to Horizon and returns a parsed response object

public executeRequest(string $url, string $requestType[, string|null $requestMethod = "GET" ]) : Response

This method sends the HTTP request to the Horizon server, handles errors, and parses the JSON response into the appropriate response type.

Parameters
$url : string

The complete request URL to fetch

$requestType : string

The expected response type for parsing

$requestMethod : string|null = "GET"

The HTTP method to use (default: "GET")

Tags
throws
HorizonRequestException

If the request fails or response cannot be parsed

Return values
Response

The parsed response object of the specified type

getAndStream()

Streams Server-Sent Events from Horizon to a callback function

public getAndStream(string $relativeUrl, callable $callback[, bool $retryOnServerException = true ]) : void

This method establishes a persistent connection to Horizon's streaming endpoints using Server-Sent Events (SSE). It processes each event and passes the parsed data to the provided callback function. The stream automatically reconnects on server exceptions if retryOnServerException is true.

Horizon streaming uses SSE to push real-time updates. The stream sends:

  • "hello" message on connection
  • "byebye" message on disconnection
  • JSON data objects for actual events
Parameters
$relativeUrl : string

The relative URL to stream from

$callback : callable

Function to receive parsed event data

$retryOnServerException : bool = true

If true, automatically retry on server errors (default: true)

Tags
throws
GuzzleException

If a network error occurs and retryOnServerException is false

Return values
void

This method runs indefinitely until interrupted

limit()

Sets <code>limit</code> parameter on the request.

public limit(int $number) : RequestBuilder

It defines maximum number of records to return. For range and default values check documentation of the endpoint requested.

Parameters
$number : int

Maximum number of records to return

Return values
RequestBuilder

request()

Executes the HTTP request to submit customer information.

public request(string $url) : PutCustomerInfoResponse
Parameters
$url : string

The fully constructed URL to send the request to

Tags
throws
GuzzleException

If the HTTP request fails or server returns an error

Return values
PutCustomerInfoResponse

The parsed response containing customer ID

setSegments()

Sets the URL path segments for this request

protected setSegments(string ...$segments) : RequestBuilder

This method constructs the URL path by combining multiple segments. Can only be called once per request builder instance.

Parameters
$segments : string

Variable number of URL path segments

Tags
throws
RuntimeException

If segments have already been set

Return values
RequestBuilder

This instance for method chaining


        
On this page

Search results