1
0
Files
PayPal-PHP-Server-SDK/doc/controllers/vault.md
2025-05-27 17:46:31 +00:00

9.9 KiB

Vault

Use the /vault resource to create, retrieve, and delete payment and setup tokens.

$vaultController = $client->getVaultController();

Class Name

VaultController

Methods

Delete Payment Token

Delete the payment token associated with the payment token id.

function deletePaymentToken(string $id): ApiResponse

Parameters

Parameter Type Tags Description
id string Template, Required ID of the payment token.

Constraints: Minimum Length: 1, Maximum Length: 36, Pattern: ^[0-9a-zA-Z_-]+$

Response Type

This method returns an ApiResponse instance.

Example Usage

$id = 'id0';

$apiResponse = $vaultController->deletePaymentToken($id);

Errors

HTTP Status Code Error Description Exception Class
400 Request is not well-formed, syntactically incorrect, or violates schema. ErrorException
403 Authorization failed due to insufficient permissions. ErrorException
500 An internal server error has occurred. ErrorException

Create Setup Token

Creates a Setup Token from the given payment source and adds it to the Vault of the associated customer.

function createSetupToken(array $options): ApiResponse

Parameters

Parameter Type Tags Description
body SetupTokenRequest Body, Required Setup Token creation with a instrument type optional financial instrument details and customer_id.
paypalRequestId ?string Header, Optional The server stores keys for 3 hours.

Constraints: Minimum Length: 1, Maximum Length: 10000, Pattern: ^.*$

Response Type

This method returns an ApiResponse instance. The getResult() method on this instance returns the response data which is of type SetupTokenResponse.

Example Usage

$collect = [
    'body' => SetupTokenRequestBuilder::init(
        SetupTokenRequestPaymentSourceBuilder::init()->build()
    )->build()
];

$apiResponse = $vaultController->createSetupToken($collect);

Errors

HTTP Status Code Error Description Exception Class
400 Request is not well-formed, syntactically incorrect, or violates schema. ErrorException
403 Authorization failed due to insufficient permissions. ErrorException
422 The requested action could not be performed, semantically incorrect, or failed business validation. ErrorException
500 An internal server error has occurred. ErrorException

Get Setup Token

Returns a readable representation of temporarily vaulted payment source associated with the setup token id.

function getSetupToken(string $id): ApiResponse

Parameters

Parameter Type Tags Description
id string Template, Required ID of the setup token.

Constraints: Minimum Length: 7, Maximum Length: 36, Pattern: ^[0-9a-zA-Z_-]+$

Response Type

This method returns an ApiResponse instance. The getResult() method on this instance returns the response data which is of type SetupTokenResponse.

Example Usage

$id = 'id0';

$apiResponse = $vaultController->getSetupToken($id);

Errors

HTTP Status Code Error Description Exception Class
403 Authorization failed due to insufficient permissions. ErrorException
404 The specified resource does not exist. ErrorException
422 The requested action could not be performed, semantically incorrect, or failed business validation. ErrorException
500 An internal server error has occurred. ErrorException

Create Payment Token

Creates a Payment Token from the given payment source and adds it to the Vault of the associated customer.

function createPaymentToken(array $options): ApiResponse

Parameters

Parameter Type Tags Description
body PaymentTokenRequest Body, Required Payment Token creation with a financial instrument and an optional customer_id.
paypalRequestId ?string Header, Optional The server stores keys for 3 hours.

Constraints: Minimum Length: 1, Maximum Length: 10000, Pattern: ^.*$

Response Type

This method returns an ApiResponse instance. The getResult() method on this instance returns the response data which is of type PaymentTokenResponse.

Example Usage

$collect = [
    'body' => PaymentTokenRequestBuilder::init(
        PaymentTokenRequestPaymentSourceBuilder::init()->build()
    )->build()
];

$apiResponse = $vaultController->createPaymentToken($collect);

Errors

HTTP Status Code Error Description Exception Class
400 Request is not well-formed, syntactically incorrect, or violates schema. ErrorException
403 Authorization failed due to insufficient permissions. ErrorException
404 Request contains reference to resources that do not exist. ErrorException
422 The requested action could not be performed, semantically incorrect, or failed business validation. ErrorException
500 An internal server error has occurred. ErrorException

List Customer Payment Tokens

Returns all payment tokens for a customer.

function listCustomerPaymentTokens(array $options): ApiResponse

Parameters

Parameter Type Tags Description
customerId string Query, Required A unique identifier representing a specific customer in merchant's/partner's system or records.

Constraints: Minimum Length: 7, Maximum Length: 36, Pattern: ^[0-9a-zA-Z_-]+$
pageSize ?int Query, Optional A non-negative, non-zero integer indicating the maximum number of results to return at one time.

Default: 5

Constraints: >= 1, <= 5
page ?int Query, Optional A non-negative, non-zero integer representing the page of the results.

Default: 1

Constraints: >= 1, <= 10
totalRequired ?bool Query, Optional A boolean indicating total number of items (total_items) and pages (total_pages) are expected to be returned in the response.

Default: false

Response Type

This method returns an ApiResponse instance. The getResult() method on this instance returns the response data which is of type CustomerVaultPaymentTokensResponse.

Example Usage

$collect = [
    'customerId' => 'customer_id8',
    'pageSize' => 5,
    'page' => 1,
    'totalRequired' => false
];

$apiResponse = $vaultController->listCustomerPaymentTokens($collect);

Errors

HTTP Status Code Error Description Exception Class
400 Request is not well-formed, syntactically incorrect, or violates schema. ErrorException
403 Authorization failed due to insufficient permissions. ErrorException
500 An internal server error has occurred. ErrorException

Get Payment Token

Returns a readable representation of vaulted payment source associated with the payment token id.

function getPaymentToken(string $id): ApiResponse

Parameters

Parameter Type Tags Description
id string Template, Required ID of the payment token.

Constraints: Minimum Length: 1, Maximum Length: 36, Pattern: ^[0-9a-zA-Z_-]+$

Response Type

This method returns an ApiResponse instance. The getResult() method on this instance returns the response data which is of type PaymentTokenResponse.

Example Usage

$id = 'id0';

$apiResponse = $vaultController->getPaymentToken($id);

Errors

HTTP Status Code Error Description Exception Class
403 Authorization failed due to insufficient permissions. ErrorException
404 The specified resource does not exist. ErrorException
422 The requested action could not be performed, semantically incorrect, or failed business validation. ErrorException
500 An internal server error has occurred. ErrorException