On this page
No Headings
Returns a readable representation of vaulted payment source associated with the payment token id.
Oauth2 https://uri.paypal.com/services/vault/payment-tokens/readwriteOauth 2.0 authentication
In: header
Scope: https://uri.paypal.com/services/vault/payment-tokens/readwrite
ID of the setup token.
^[0-9a-zA-Z_-]+$7 <= length <= 36Specifies the request format.
^[A-Za-z0-9/+-]+$1 <= length <= 255application/json
TypeScript Definitions
Use the request body type in TypeScript.
application/json
application/json
application/json
application/json
Request samples
using Microsoft.Extensions.Logging;
using PaypalServerSdk.Standard;
using PaypalServerSdk.Standard.Authentication;
using PaypalServerSdk.Standard.Controllers;
using PaypalServerSdk.Standard.Exceptions;
using PaypalServerSdk.Standard.Http.Response;
using PaypalServerSdk.Standard.Models;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace TestConsoleProject
{
public class Program
{
public static async Task Main()
{
// Scenario: 200 - Retrieve Payment Token - Card Token
PaypalServerSdkClient client = new PaypalServerSdkClient.Builder()
.ClientCredentialsAuth(
new ClientCredentialsAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret"
)
.Build())
.Environment(PaypalServerSdk.Standard.Environment.Sandbox)
.LoggingConfig(config => config
.LogLevel(LogLevel.Information)
.RequestConfig(reqConfig => reqConfig.Body(true))
.ResponseConfig(respConfig => respConfig.Headers(true))
)
.Build();
VaultController vaultController = client.VaultController;
string id = "5O190127TN364715T";
try
{
ApiResponse<PaymentTokenResponse> result = await vaultController.GetPaymentTokenAsync(id);
}
catch (ApiException e)
{
Console.WriteLine(e.Message);
}
}
}
}import com.paypal.sdk.Environment;
import com.paypal.sdk.PaypalServerSdkClient;
import com.paypal.sdk.authentication.ClientCredentialsAuthModel;
import com.paypal.sdk.controllers.VaultController;
import com.paypal.sdk.exceptions.ApiException;
import com.paypal.sdk.http.response.ApiResponse;
import com.paypal.sdk.models.*;
import java.util.Arrays;
import org.slf4j.event.Level;
public class Program {
public static void main(String[] args) {
// Scenario: 200 - Retrieve Payment Token - Card Token
PaypalServerSdkClient client = new PaypalServerSdkClient.Builder()
.loggingConfig(builder -> builder
.level(Level.DEBUG)
.requestConfig(logConfigBuilder -> logConfigBuilder.body(true))
.responseConfig(logConfigBuilder -> logConfigBuilder.headers(true)))
.clientCredentialsAuth(new ClientCredentialsAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret"
)
.build())
.environment(Environment.SANDBOX)
.build();
VaultController vaultController = client.getVaultController();
String id = "5O190127TN364715T";
vaultController.getPaymentTokenAsync(id).thenAccept(result -> {
System.out.println(result);
}).exceptionally(exception -> {
exception.printStackTrace();
return null;
});
}
}import { Client, Environment, LogLevel, ApiError } from '@paypal/paypal-server-sdk';
// Scenario: 200 - Retrieve Payment Token - Card Token
const client = new Client({
clientCredentialsAuthCredentials: {
oAuthClientId: 'OAuthClientId',
oAuthClientSecret: 'OAuthClientSecret'
},
environment: Environment.Sandbox,
logging: {
logLevel: LogLevel.Info,
logRequest: { logBody: true },
logResponse: { logHeaders: true },
},
});
const vaultController = client.vaultController;
const id = '5O190127TN364715T';
try {
const response = await vaultController.getPaymentToken(id);
console.log(response.result);
} catch (error) {
if (error instanceof ApiError) {
console.log(error.statusCode);
console.log(error.body);
}
}import logging
from paypalserversdk.configuration import Environment
from paypalserversdk.http.auth.o_auth_2 import ClientCredentialsAuthCredentials
from paypalserversdk.logging.configuration.api_logging_configuration import (
LoggingConfiguration, RequestLoggingConfiguration, ResponseLoggingConfiguration
)
from paypalserversdk.paypal_serversdk_client import PaypalServersdkClient
client = PaypalServersdkClient(
client_credentials_auth_credentials=ClientCredentialsAuthCredentials(
o_auth_client_id='OAuthClientId',
o_auth_client_secret='OAuthClientSecret'
),
environment=Environment.SANDBOX,
logging_configuration=LoggingConfiguration(
log_level=logging.INFO,
request_logging_config=RequestLoggingConfiguration(log_body=True),
response_logging_config=ResponseLoggingConfiguration(log_headers=True)
)
)
vault_controller = client.vault_controller
id = '5O190127TN364715T'
# Scenario: 200 - Retrieve Payment Token - Card Token
result = vault_controller.get_payment_token(id)
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)<?php
use PaypalServerSdkLib\PaypalServerSdkClientBuilder;
use PaypalServerSdkLib\Environment;
use PaypalServerSdkLib\Authentication\ClientCredentialsAuthCredentialsBuilder;
use PaypalServerSdkLib\Logging\LoggingConfigurationBuilder;
use PaypalServerSdkLib\Logging\RequestLoggingConfigurationBuilder;
use PaypalServerSdkLib\Logging\ResponseLoggingConfigurationBuilder;
use Psr\Log\LogLevel;
$client = PaypalServerSdkClientBuilder::init()
->clientCredentialsAuthCredentials(
ClientCredentialsAuthCredentialsBuilder::init(
'OAuthClientId',
'OAuthClientSecret'
)
)
->environment(Environment::SANDBOX)
->loggingConfiguration(
LoggingConfigurationBuilder::init()
->level(LogLevel::INFO)
->requestConfiguration(RequestLoggingConfigurationBuilder::init()->body(true))
->responseConfiguration(ResponseLoggingConfigurationBuilder::init()->headers(true))
)
->build();
$VaultController = $client->getVaultController();
$id = '5O190127TN364715T';
// Scenario: 200 - Retrieve Payment Token - Card Token
$apiResponse = $vaultController->getPaymentToken($id);require 'paypal_server_sdk'
include PaypalServerSdk
client = Client.new(
client_credentials_auth_credentials: ClientCredentialsAuthCredentials.new(
o_auth_client_id: 'OAuthClientId',
o_auth_client_secret: 'OAuthClientSecret'
),
environment: Environment::SANDBOX,
logging_configuration: LoggingConfiguration.new(
log_level: Logger::INFO,
request_logging_config: RequestLoggingConfiguration.new(log_body: true),
response_logging_config: ResponseLoggingConfiguration.new(log_headers: true)
)
)
vault_controller = client.vault_controller
id = '5O190127TN364715T'
# Scenario: 200 - Retrieve Payment Token - Card Token
result = vault_controller.get_payment_token(id)
if result.success?
puts result.data
elsif result.error?
warn result.errors
endusing Microsoft.Extensions.Logging;
using PaypalServerSdk.Standard;
using PaypalServerSdk.Standard.Authentication;
using PaypalServerSdk.Standard.Controllers;
using PaypalServerSdk.Standard.Exceptions;
using PaypalServerSdk.Standard.Http.Response;
using PaypalServerSdk.Standard.Models;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace TestConsoleProject
{
public class Program
{
public static async Task Main()
{
// Scenario: 200 - Retrieve Payment Token - PayPal Wallet Token
PaypalServerSdkClient client = new PaypalServerSdkClient.Builder()
.ClientCredentialsAuth(
new ClientCredentialsAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret"
)
.Build())
.Environment(PaypalServerSdk.Standard.Environment.Sandbox)
.LoggingConfig(config => config
.LogLevel(LogLevel.Information)
.RequestConfig(reqConfig => reqConfig.Body(true))
.ResponseConfig(respConfig => respConfig.Headers(true))
)
.Build();
VaultController vaultController = client.VaultController;
string id = "5O190127TN364715T";
try
{
ApiResponse<PaymentTokenResponse> result = await vaultController.GetPaymentTokenAsync(id);
}
catch (ApiException e)
{
Console.WriteLine(e.Message);
}
}
}
}import com.paypal.sdk.Environment;
import com.paypal.sdk.PaypalServerSdkClient;
import com.paypal.sdk.authentication.ClientCredentialsAuthModel;
import com.paypal.sdk.controllers.VaultController;
import com.paypal.sdk.exceptions.ApiException;
import com.paypal.sdk.http.response.ApiResponse;
import com.paypal.sdk.models.*;
import java.util.Arrays;
import org.slf4j.event.Level;
public class Program {
public static void main(String[] args) {
// Scenario: 200 - Retrieve Payment Token - PayPal Wallet Token
PaypalServerSdkClient client = new PaypalServerSdkClient.Builder()
.loggingConfig(builder -> builder
.level(Level.DEBUG)
.requestConfig(logConfigBuilder -> logConfigBuilder.body(true))
.responseConfig(logConfigBuilder -> logConfigBuilder.headers(true)))
.clientCredentialsAuth(new ClientCredentialsAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret"
)
.build())
.environment(Environment.SANDBOX)
.build();
VaultController vaultController = client.getVaultController();
String id = "5O190127TN364715T";
vaultController.getPaymentTokenAsync(id).thenAccept(result -> {
System.out.println(result);
}).exceptionally(exception -> {
exception.printStackTrace();
return null;
});
}
}import { Client, Environment, LogLevel, ApiError } from '@paypal/paypal-server-sdk';
// Scenario: 200 - Retrieve Payment Token - PayPal Wallet Token
const client = new Client({
clientCredentialsAuthCredentials: {
oAuthClientId: 'OAuthClientId',
oAuthClientSecret: 'OAuthClientSecret'
},
environment: Environment.Sandbox,
logging: {
logLevel: LogLevel.Info,
logRequest: { logBody: true },
logResponse: { logHeaders: true },
},
});
const vaultController = client.vaultController;
const id = '5O190127TN364715T';
try {
const response = await vaultController.getPaymentToken(id);
console.log(response.result);
} catch (error) {
if (error instanceof ApiError) {
console.log(error.statusCode);
console.log(error.body);
}
}import logging
from paypalserversdk.configuration import Environment
from paypalserversdk.http.auth.o_auth_2 import ClientCredentialsAuthCredentials
from paypalserversdk.logging.configuration.api_logging_configuration import (
LoggingConfiguration, RequestLoggingConfiguration, ResponseLoggingConfiguration
)
from paypalserversdk.paypal_serversdk_client import PaypalServersdkClient
client = PaypalServersdkClient(
client_credentials_auth_credentials=ClientCredentialsAuthCredentials(
o_auth_client_id='OAuthClientId',
o_auth_client_secret='OAuthClientSecret'
),
environment=Environment.SANDBOX,
logging_configuration=LoggingConfiguration(
log_level=logging.INFO,
request_logging_config=RequestLoggingConfiguration(log_body=True),
response_logging_config=ResponseLoggingConfiguration(log_headers=True)
)
)
vault_controller = client.vault_controller
id = '5O190127TN364715T'
# Scenario: 200 - Retrieve Payment Token - PayPal Wallet Token
result = vault_controller.get_payment_token(id)
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)<?php
use PaypalServerSdkLib\PaypalServerSdkClientBuilder;
use PaypalServerSdkLib\Environment;
use PaypalServerSdkLib\Authentication\ClientCredentialsAuthCredentialsBuilder;
use PaypalServerSdkLib\Logging\LoggingConfigurationBuilder;
use PaypalServerSdkLib\Logging\RequestLoggingConfigurationBuilder;
use PaypalServerSdkLib\Logging\ResponseLoggingConfigurationBuilder;
use Psr\Log\LogLevel;
$client = PaypalServerSdkClientBuilder::init()
->clientCredentialsAuthCredentials(
ClientCredentialsAuthCredentialsBuilder::init(
'OAuthClientId',
'OAuthClientSecret'
)
)
->environment(Environment::SANDBOX)
->loggingConfiguration(
LoggingConfigurationBuilder::init()
->level(LogLevel::INFO)
->requestConfiguration(RequestLoggingConfigurationBuilder::init()->body(true))
->responseConfiguration(ResponseLoggingConfigurationBuilder::init()->headers(true))
)
->build();
$VaultController = $client->getVaultController();
$id = '5O190127TN364715T';
// Scenario: 200 - Retrieve Payment Token - PayPal Wallet Token
$apiResponse = $vaultController->getPaymentToken($id);require 'paypal_server_sdk'
include PaypalServerSdk
client = Client.new(
client_credentials_auth_credentials: ClientCredentialsAuthCredentials.new(
o_auth_client_id: 'OAuthClientId',
o_auth_client_secret: 'OAuthClientSecret'
),
environment: Environment::SANDBOX,
logging_configuration: LoggingConfiguration.new(
log_level: Logger::INFO,
request_logging_config: RequestLoggingConfiguration.new(log_body: true),
response_logging_config: ResponseLoggingConfiguration.new(log_headers: true)
)
)
vault_controller = client.vault_controller
id = '5O190127TN364715T'
# Scenario: 200 - Retrieve Payment Token - PayPal Wallet Token
result = vault_controller.get_payment_token(id)
if result.success?
puts result.data
elsif result.error?
warn result.errors
endusing Microsoft.Extensions.Logging;
using PaypalServerSdk.Standard;
using PaypalServerSdk.Standard.Authentication;
using PaypalServerSdk.Standard.Controllers;
using PaypalServerSdk.Standard.Exceptions;
using PaypalServerSdk.Standard.Http.Response;
using PaypalServerSdk.Standard.Models;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace TestConsoleProject
{
public class Program
{
public static async Task Main()
{
// Scenario: 200 - Retrieve Payment Token - Venmo Token
PaypalServerSdkClient client = new PaypalServerSdkClient.Builder()
.ClientCredentialsAuth(
new ClientCredentialsAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret"
)
.Build())
.Environment(PaypalServerSdk.Standard.Environment.Sandbox)
.LoggingConfig(config => config
.LogLevel(LogLevel.Information)
.RequestConfig(reqConfig => reqConfig.Body(true))
.ResponseConfig(respConfig => respConfig.Headers(true))
)
.Build();
VaultController vaultController = client.VaultController;
string id = "5O190127TN364715T";
try
{
ApiResponse<PaymentTokenResponse> result = await vaultController.GetPaymentTokenAsync(id);
}
catch (ApiException e)
{
Console.WriteLine(e.Message);
}
}
}
}import com.paypal.sdk.Environment;
import com.paypal.sdk.PaypalServerSdkClient;
import com.paypal.sdk.authentication.ClientCredentialsAuthModel;
import com.paypal.sdk.controllers.VaultController;
import com.paypal.sdk.exceptions.ApiException;
import com.paypal.sdk.http.response.ApiResponse;
import com.paypal.sdk.models.*;
import java.util.Arrays;
import org.slf4j.event.Level;
public class Program {
public static void main(String[] args) {
// Scenario: 200 - Retrieve Payment Token - Venmo Token
PaypalServerSdkClient client = new PaypalServerSdkClient.Builder()
.loggingConfig(builder -> builder
.level(Level.DEBUG)
.requestConfig(logConfigBuilder -> logConfigBuilder.body(true))
.responseConfig(logConfigBuilder -> logConfigBuilder.headers(true)))
.clientCredentialsAuth(new ClientCredentialsAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret"
)
.build())
.environment(Environment.SANDBOX)
.build();
VaultController vaultController = client.getVaultController();
String id = "5O190127TN364715T";
vaultController.getPaymentTokenAsync(id).thenAccept(result -> {
System.out.println(result);
}).exceptionally(exception -> {
exception.printStackTrace();
return null;
});
}
}import { Client, Environment, LogLevel, ApiError } from '@paypal/paypal-server-sdk';
// Scenario: 200 - Retrieve Payment Token - Venmo Token
const client = new Client({
clientCredentialsAuthCredentials: {
oAuthClientId: 'OAuthClientId',
oAuthClientSecret: 'OAuthClientSecret'
},
environment: Environment.Sandbox,
logging: {
logLevel: LogLevel.Info,
logRequest: { logBody: true },
logResponse: { logHeaders: true },
},
});
const vaultController = client.vaultController;
const id = '5O190127TN364715T';
try {
const response = await vaultController.getPaymentToken(id);
console.log(response.result);
} catch (error) {
if (error instanceof ApiError) {
console.log(error.statusCode);
console.log(error.body);
}
}import logging
from paypalserversdk.configuration import Environment
from paypalserversdk.http.auth.o_auth_2 import ClientCredentialsAuthCredentials
from paypalserversdk.logging.configuration.api_logging_configuration import (
LoggingConfiguration, RequestLoggingConfiguration, ResponseLoggingConfiguration
)
from paypalserversdk.paypal_serversdk_client import PaypalServersdkClient
client = PaypalServersdkClient(
client_credentials_auth_credentials=ClientCredentialsAuthCredentials(
o_auth_client_id='OAuthClientId',
o_auth_client_secret='OAuthClientSecret'
),
environment=Environment.SANDBOX,
logging_configuration=LoggingConfiguration(
log_level=logging.INFO,
request_logging_config=RequestLoggingConfiguration(log_body=True),
response_logging_config=ResponseLoggingConfiguration(log_headers=True)
)
)
vault_controller = client.vault_controller
id = '5O190127TN364715T'
# Scenario: 200 - Retrieve Payment Token - Venmo Token
result = vault_controller.get_payment_token(id)
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)<?php
use PaypalServerSdkLib\PaypalServerSdkClientBuilder;
use PaypalServerSdkLib\Environment;
use PaypalServerSdkLib\Authentication\ClientCredentialsAuthCredentialsBuilder;
use PaypalServerSdkLib\Logging\LoggingConfigurationBuilder;
use PaypalServerSdkLib\Logging\RequestLoggingConfigurationBuilder;
use PaypalServerSdkLib\Logging\ResponseLoggingConfigurationBuilder;
use Psr\Log\LogLevel;
$client = PaypalServerSdkClientBuilder::init()
->clientCredentialsAuthCredentials(
ClientCredentialsAuthCredentialsBuilder::init(
'OAuthClientId',
'OAuthClientSecret'
)
)
->environment(Environment::SANDBOX)
->loggingConfiguration(
LoggingConfigurationBuilder::init()
->level(LogLevel::INFO)
->requestConfiguration(RequestLoggingConfigurationBuilder::init()->body(true))
->responseConfiguration(ResponseLoggingConfigurationBuilder::init()->headers(true))
)
->build();
$VaultController = $client->getVaultController();
$id = '5O190127TN364715T';
// Scenario: 200 - Retrieve Payment Token - Venmo Token
$apiResponse = $vaultController->getPaymentToken($id);require 'paypal_server_sdk'
include PaypalServerSdk
client = Client.new(
client_credentials_auth_credentials: ClientCredentialsAuthCredentials.new(
o_auth_client_id: 'OAuthClientId',
o_auth_client_secret: 'OAuthClientSecret'
),
environment: Environment::SANDBOX,
logging_configuration: LoggingConfiguration.new(
log_level: Logger::INFO,
request_logging_config: RequestLoggingConfiguration.new(log_body: true),
response_logging_config: ResponseLoggingConfiguration.new(log_headers: true)
)
)
vault_controller = client.vault_controller
id = '5O190127TN364715T'
# Scenario: 200 - Retrieve Payment Token - Venmo Token
result = vault_controller.get_payment_token(id)
if result.success?
puts result.data
elsif result.error?
warn result.errors
endusing Microsoft.Extensions.Logging;
using PaypalServerSdk.Standard;
using PaypalServerSdk.Standard.Authentication;
using PaypalServerSdk.Standard.Controllers;
using PaypalServerSdk.Standard.Exceptions;
using PaypalServerSdk.Standard.Http.Response;
using PaypalServerSdk.Standard.Models;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace TestConsoleProject
{
public class Program
{
public static async Task Main()
{
// Scenario: 403 - Get Payment Token - 403 Forbidden Error - Merchant Not Onboarded to Vault
PaypalServerSdkClient client = new PaypalServerSdkClient.Builder()
.ClientCredentialsAuth(
new ClientCredentialsAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret"
)
.Build())
.Environment(PaypalServerSdk.Standard.Environment.Sandbox)
.LoggingConfig(config => config
.LogLevel(LogLevel.Information)
.RequestConfig(reqConfig => reqConfig.Body(true))
.ResponseConfig(respConfig => respConfig.Headers(true))
)
.Build();
VaultController vaultController = client.VaultController;
string id = "5O190127TN364715T";
try
{
ApiResponse<PaymentTokenResponse> result = await vaultController.GetPaymentTokenAsync(id);
}
catch (ApiException e)
{
Console.WriteLine(e.Message);
}
}
}
}import com.paypal.sdk.Environment;
import com.paypal.sdk.PaypalServerSdkClient;
import com.paypal.sdk.authentication.ClientCredentialsAuthModel;
import com.paypal.sdk.controllers.VaultController;
import com.paypal.sdk.exceptions.ApiException;
import com.paypal.sdk.http.response.ApiResponse;
import com.paypal.sdk.models.*;
import java.util.Arrays;
import org.slf4j.event.Level;
public class Program {
public static void main(String[] args) {
// Scenario: 403 - Get Payment Token - 403 Forbidden Error - Merchant Not Onboarded to Vault
PaypalServerSdkClient client = new PaypalServerSdkClient.Builder()
.loggingConfig(builder -> builder
.level(Level.DEBUG)
.requestConfig(logConfigBuilder -> logConfigBuilder.body(true))
.responseConfig(logConfigBuilder -> logConfigBuilder.headers(true)))
.clientCredentialsAuth(new ClientCredentialsAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret"
)
.build())
.environment(Environment.SANDBOX)
.build();
VaultController vaultController = client.getVaultController();
String id = "5O190127TN364715T";
vaultController.getPaymentTokenAsync(id).thenAccept(result -> {
System.out.println(result);
}).exceptionally(exception -> {
exception.printStackTrace();
return null;
});
}
}import { Client, Environment, LogLevel, ApiError } from '@paypal/paypal-server-sdk';
// Scenario: 403 - Get Payment Token - 403 Forbidden Error - Merchant Not Onboarded to Vault
const client = new Client({
clientCredentialsAuthCredentials: {
oAuthClientId: 'OAuthClientId',
oAuthClientSecret: 'OAuthClientSecret'
},
environment: Environment.Sandbox,
logging: {
logLevel: LogLevel.Info,
logRequest: { logBody: true },
logResponse: { logHeaders: true },
},
});
const vaultController = client.vaultController;
const id = '5O190127TN364715T';
try {
const response = await vaultController.getPaymentToken(id);
console.log(response.result);
} catch (error) {
if (error instanceof ApiError) {
console.log(error.statusCode);
console.log(error.body);
}
}import logging
from paypalserversdk.configuration import Environment
from paypalserversdk.http.auth.o_auth_2 import ClientCredentialsAuthCredentials
from paypalserversdk.logging.configuration.api_logging_configuration import (
LoggingConfiguration, RequestLoggingConfiguration, ResponseLoggingConfiguration
)
from paypalserversdk.paypal_serversdk_client import PaypalServersdkClient
client = PaypalServersdkClient(
client_credentials_auth_credentials=ClientCredentialsAuthCredentials(
o_auth_client_id='OAuthClientId',
o_auth_client_secret='OAuthClientSecret'
),
environment=Environment.SANDBOX,
logging_configuration=LoggingConfiguration(
log_level=logging.INFO,
request_logging_config=RequestLoggingConfiguration(log_body=True),
response_logging_config=ResponseLoggingConfiguration(log_headers=True)
)
)
vault_controller = client.vault_controller
id = '5O190127TN364715T'
# Scenario: 403 - Get Payment Token - 403 Forbidden Error - Merchant Not Onboarded to Vault
result = vault_controller.get_payment_token(id)
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)<?php
use PaypalServerSdkLib\PaypalServerSdkClientBuilder;
use PaypalServerSdkLib\Environment;
use PaypalServerSdkLib\Authentication\ClientCredentialsAuthCredentialsBuilder;
use PaypalServerSdkLib\Logging\LoggingConfigurationBuilder;
use PaypalServerSdkLib\Logging\RequestLoggingConfigurationBuilder;
use PaypalServerSdkLib\Logging\ResponseLoggingConfigurationBuilder;
use Psr\Log\LogLevel;
$client = PaypalServerSdkClientBuilder::init()
->clientCredentialsAuthCredentials(
ClientCredentialsAuthCredentialsBuilder::init(
'OAuthClientId',
'OAuthClientSecret'
)
)
->environment(Environment::SANDBOX)
->loggingConfiguration(
LoggingConfigurationBuilder::init()
->level(LogLevel::INFO)
->requestConfiguration(RequestLoggingConfigurationBuilder::init()->body(true))
->responseConfiguration(ResponseLoggingConfigurationBuilder::init()->headers(true))
)
->build();
$VaultController = $client->getVaultController();
$id = '5O190127TN364715T';
// Scenario: 403 - Get Payment Token - 403 Forbidden Error - Merchant Not Onboarded to Vault
$apiResponse = $vaultController->getPaymentToken($id);require 'paypal_server_sdk'
include PaypalServerSdk
client = Client.new(
client_credentials_auth_credentials: ClientCredentialsAuthCredentials.new(
o_auth_client_id: 'OAuthClientId',
o_auth_client_secret: 'OAuthClientSecret'
),
environment: Environment::SANDBOX,
logging_configuration: LoggingConfiguration.new(
log_level: Logger::INFO,
request_logging_config: RequestLoggingConfiguration.new(log_body: true),
response_logging_config: ResponseLoggingConfiguration.new(log_headers: true)
)
)
vault_controller = client.vault_controller
id = '5O190127TN364715T'
# Scenario: 403 - Get Payment Token - 403 Forbidden Error - Merchant Not Onboarded to Vault
result = vault_controller.get_payment_token(id)
if result.success?
puts result.data
elsif result.error?
warn result.errors
endusing Microsoft.Extensions.Logging;
using PaypalServerSdk.Standard;
using PaypalServerSdk.Standard.Authentication;
using PaypalServerSdk.Standard.Controllers;
using PaypalServerSdk.Standard.Exceptions;
using PaypalServerSdk.Standard.Http.Response;
using PaypalServerSdk.Standard.Models;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace TestConsoleProject
{
public class Program
{
public static async Task Main()
{
// Scenario: 404 - Get Payment Token - 404 Not Found Error - Payment Token Cannot Be Located
PaypalServerSdkClient client = new PaypalServerSdkClient.Builder()
.ClientCredentialsAuth(
new ClientCredentialsAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret"
)
.Build())
.Environment(PaypalServerSdk.Standard.Environment.Sandbox)
.LoggingConfig(config => config
.LogLevel(LogLevel.Information)
.RequestConfig(reqConfig => reqConfig.Body(true))
.ResponseConfig(respConfig => respConfig.Headers(true))
)
.Build();
VaultController vaultController = client.VaultController;
string id = "5O190127TN364715T";
try
{
ApiResponse<PaymentTokenResponse> result = await vaultController.GetPaymentTokenAsync(id);
}
catch (ApiException e)
{
Console.WriteLine(e.Message);
}
}
}
}import com.paypal.sdk.Environment;
import com.paypal.sdk.PaypalServerSdkClient;
import com.paypal.sdk.authentication.ClientCredentialsAuthModel;
import com.paypal.sdk.controllers.VaultController;
import com.paypal.sdk.exceptions.ApiException;
import com.paypal.sdk.http.response.ApiResponse;
import com.paypal.sdk.models.*;
import java.util.Arrays;
import org.slf4j.event.Level;
public class Program {
public static void main(String[] args) {
// Scenario: 404 - Get Payment Token - 404 Not Found Error - Payment Token Cannot Be Located
PaypalServerSdkClient client = new PaypalServerSdkClient.Builder()
.loggingConfig(builder -> builder
.level(Level.DEBUG)
.requestConfig(logConfigBuilder -> logConfigBuilder.body(true))
.responseConfig(logConfigBuilder -> logConfigBuilder.headers(true)))
.clientCredentialsAuth(new ClientCredentialsAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret"
)
.build())
.environment(Environment.SANDBOX)
.build();
VaultController vaultController = client.getVaultController();
String id = "5O190127TN364715T";
vaultController.getPaymentTokenAsync(id).thenAccept(result -> {
System.out.println(result);
}).exceptionally(exception -> {
exception.printStackTrace();
return null;
});
}
}import { Client, Environment, LogLevel, ApiError } from '@paypal/paypal-server-sdk';
// Scenario: 404 - Get Payment Token - 404 Not Found Error - Payment Token Cannot Be Located
const client = new Client({
clientCredentialsAuthCredentials: {
oAuthClientId: 'OAuthClientId',
oAuthClientSecret: 'OAuthClientSecret'
},
environment: Environment.Sandbox,
logging: {
logLevel: LogLevel.Info,
logRequest: { logBody: true },
logResponse: { logHeaders: true },
},
});
const vaultController = client.vaultController;
const id = '5O190127TN364715T';
try {
const response = await vaultController.getPaymentToken(id);
console.log(response.result);
} catch (error) {
if (error instanceof ApiError) {
console.log(error.statusCode);
console.log(error.body);
}
}import logging
from paypalserversdk.configuration import Environment
from paypalserversdk.http.auth.o_auth_2 import ClientCredentialsAuthCredentials
from paypalserversdk.logging.configuration.api_logging_configuration import (
LoggingConfiguration, RequestLoggingConfiguration, ResponseLoggingConfiguration
)
from paypalserversdk.paypal_serversdk_client import PaypalServersdkClient
client = PaypalServersdkClient(
client_credentials_auth_credentials=ClientCredentialsAuthCredentials(
o_auth_client_id='OAuthClientId',
o_auth_client_secret='OAuthClientSecret'
),
environment=Environment.SANDBOX,
logging_configuration=LoggingConfiguration(
log_level=logging.INFO,
request_logging_config=RequestLoggingConfiguration(log_body=True),
response_logging_config=ResponseLoggingConfiguration(log_headers=True)
)
)
vault_controller = client.vault_controller
id = '5O190127TN364715T'
# Scenario: 404 - Get Payment Token - 404 Not Found Error - Payment Token Cannot Be Located
result = vault_controller.get_payment_token(id)
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)<?php
use PaypalServerSdkLib\PaypalServerSdkClientBuilder;
use PaypalServerSdkLib\Environment;
use PaypalServerSdkLib\Authentication\ClientCredentialsAuthCredentialsBuilder;
use PaypalServerSdkLib\Logging\LoggingConfigurationBuilder;
use PaypalServerSdkLib\Logging\RequestLoggingConfigurationBuilder;
use PaypalServerSdkLib\Logging\ResponseLoggingConfigurationBuilder;
use Psr\Log\LogLevel;
$client = PaypalServerSdkClientBuilder::init()
->clientCredentialsAuthCredentials(
ClientCredentialsAuthCredentialsBuilder::init(
'OAuthClientId',
'OAuthClientSecret'
)
)
->environment(Environment::SANDBOX)
->loggingConfiguration(
LoggingConfigurationBuilder::init()
->level(LogLevel::INFO)
->requestConfiguration(RequestLoggingConfigurationBuilder::init()->body(true))
->responseConfiguration(ResponseLoggingConfigurationBuilder::init()->headers(true))
)
->build();
$VaultController = $client->getVaultController();
$id = '5O190127TN364715T';
// Scenario: 404 - Get Payment Token - 404 Not Found Error - Payment Token Cannot Be Located
$apiResponse = $vaultController->getPaymentToken($id);require 'paypal_server_sdk'
include PaypalServerSdk
client = Client.new(
client_credentials_auth_credentials: ClientCredentialsAuthCredentials.new(
o_auth_client_id: 'OAuthClientId',
o_auth_client_secret: 'OAuthClientSecret'
),
environment: Environment::SANDBOX,
logging_configuration: LoggingConfiguration.new(
log_level: Logger::INFO,
request_logging_config: RequestLoggingConfiguration.new(log_body: true),
response_logging_config: ResponseLoggingConfiguration.new(log_headers: true)
)
)
vault_controller = client.vault_controller
id = '5O190127TN364715T'
# Scenario: 404 - Get Payment Token - 404 Not Found Error - Payment Token Cannot Be Located
result = vault_controller.get_payment_token(id)
if result.success?
puts result.data
elsif result.error?
warn result.errors
endusing Microsoft.Extensions.Logging;
using PaypalServerSdk.Standard;
using PaypalServerSdk.Standard.Authentication;
using PaypalServerSdk.Standard.Controllers;
using PaypalServerSdk.Standard.Exceptions;
using PaypalServerSdk.Standard.Http.Response;
using PaypalServerSdk.Standard.Models;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace TestConsoleProject
{
public class Program
{
public static async Task Main()
{
// Scenario: 500 - Get Payment Token - 500 Internal Server Error
PaypalServerSdkClient client = new PaypalServerSdkClient.Builder()
.ClientCredentialsAuth(
new ClientCredentialsAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret"
)
.Build())
.Environment(PaypalServerSdk.Standard.Environment.Sandbox)
.LoggingConfig(config => config
.LogLevel(LogLevel.Information)
.RequestConfig(reqConfig => reqConfig.Body(true))
.ResponseConfig(respConfig => respConfig.Headers(true))
)
.Build();
VaultController vaultController = client.VaultController;
string id = "5O190127TN364715T";
try
{
ApiResponse<PaymentTokenResponse> result = await vaultController.GetPaymentTokenAsync(id);
}
catch (ApiException e)
{
Console.WriteLine(e.Message);
}
}
}
}import com.paypal.sdk.Environment;
import com.paypal.sdk.PaypalServerSdkClient;
import com.paypal.sdk.authentication.ClientCredentialsAuthModel;
import com.paypal.sdk.controllers.VaultController;
import com.paypal.sdk.exceptions.ApiException;
import com.paypal.sdk.http.response.ApiResponse;
import com.paypal.sdk.models.*;
import java.util.Arrays;
import org.slf4j.event.Level;
public class Program {
public static void main(String[] args) {
// Scenario: 500 - Get Payment Token - 500 Internal Server Error
PaypalServerSdkClient client = new PaypalServerSdkClient.Builder()
.loggingConfig(builder -> builder
.level(Level.DEBUG)
.requestConfig(logConfigBuilder -> logConfigBuilder.body(true))
.responseConfig(logConfigBuilder -> logConfigBuilder.headers(true)))
.clientCredentialsAuth(new ClientCredentialsAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret"
)
.build())
.environment(Environment.SANDBOX)
.build();
VaultController vaultController = client.getVaultController();
String id = "5O190127TN364715T";
vaultController.getPaymentTokenAsync(id).thenAccept(result -> {
System.out.println(result);
}).exceptionally(exception -> {
exception.printStackTrace();
return null;
});
}
}import { Client, Environment, LogLevel, ApiError } from '@paypal/paypal-server-sdk';
// Scenario: 500 - Get Payment Token - 500 Internal Server Error
const client = new Client({
clientCredentialsAuthCredentials: {
oAuthClientId: 'OAuthClientId',
oAuthClientSecret: 'OAuthClientSecret'
},
environment: Environment.Sandbox,
logging: {
logLevel: LogLevel.Info,
logRequest: { logBody: true },
logResponse: { logHeaders: true },
},
});
const vaultController = client.vaultController;
const id = '5O190127TN364715T';
try {
const response = await vaultController.getPaymentToken(id);
console.log(response.result);
} catch (error) {
if (error instanceof ApiError) {
console.log(error.statusCode);
console.log(error.body);
}
}import logging
from paypalserversdk.configuration import Environment
from paypalserversdk.http.auth.o_auth_2 import ClientCredentialsAuthCredentials
from paypalserversdk.logging.configuration.api_logging_configuration import (
LoggingConfiguration, RequestLoggingConfiguration, ResponseLoggingConfiguration
)
from paypalserversdk.paypal_serversdk_client import PaypalServersdkClient
client = PaypalServersdkClient(
client_credentials_auth_credentials=ClientCredentialsAuthCredentials(
o_auth_client_id='OAuthClientId',
o_auth_client_secret='OAuthClientSecret'
),
environment=Environment.SANDBOX,
logging_configuration=LoggingConfiguration(
log_level=logging.INFO,
request_logging_config=RequestLoggingConfiguration(log_body=True),
response_logging_config=ResponseLoggingConfiguration(log_headers=True)
)
)
vault_controller = client.vault_controller
id = '5O190127TN364715T'
# Scenario: 500 - Get Payment Token - 500 Internal Server Error
result = vault_controller.get_payment_token(id)
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)<?php
use PaypalServerSdkLib\PaypalServerSdkClientBuilder;
use PaypalServerSdkLib\Environment;
use PaypalServerSdkLib\Authentication\ClientCredentialsAuthCredentialsBuilder;
use PaypalServerSdkLib\Logging\LoggingConfigurationBuilder;
use PaypalServerSdkLib\Logging\RequestLoggingConfigurationBuilder;
use PaypalServerSdkLib\Logging\ResponseLoggingConfigurationBuilder;
use Psr\Log\LogLevel;
$client = PaypalServerSdkClientBuilder::init()
->clientCredentialsAuthCredentials(
ClientCredentialsAuthCredentialsBuilder::init(
'OAuthClientId',
'OAuthClientSecret'
)
)
->environment(Environment::SANDBOX)
->loggingConfiguration(
LoggingConfigurationBuilder::init()
->level(LogLevel::INFO)
->requestConfiguration(RequestLoggingConfigurationBuilder::init()->body(true))
->responseConfiguration(ResponseLoggingConfigurationBuilder::init()->headers(true))
)
->build();
$VaultController = $client->getVaultController();
$id = '5O190127TN364715T';
// Scenario: 500 - Get Payment Token - 500 Internal Server Error
$apiResponse = $vaultController->getPaymentToken($id);require 'paypal_server_sdk'
include PaypalServerSdk
client = Client.new(
client_credentials_auth_credentials: ClientCredentialsAuthCredentials.new(
o_auth_client_id: 'OAuthClientId',
o_auth_client_secret: 'OAuthClientSecret'
),
environment: Environment::SANDBOX,
logging_configuration: LoggingConfiguration.new(
log_level: Logger::INFO,
request_logging_config: RequestLoggingConfiguration.new(log_body: true),
response_logging_config: ResponseLoggingConfiguration.new(log_headers: true)
)
)
vault_controller = client.vault_controller
id = '5O190127TN364715T'
# Scenario: 500 - Get Payment Token - 500 Internal Server Error
result = vault_controller.get_payment_token(id)
if result.success?
puts result.data
elsif result.error?
warn result.errors
endResponse samples
{
"id": "8kk8451t",
"customer": {
"id": "BygeLlrpZF",
"merchant_customer_id": "[email protected]"
},
"payment_source": {
"card": {
"last_digits": "1111",
"expiry": "2027-02",
"brand": "VISA",
"name": "John Doe",
"billing_address": {
"id": "kk",
"address_line_1": "2211 N First Street",
"address_line_2": "17.3.160",
"admin_area_2": "San Jose",
"admin_area_1": "CA",
"postal_code": "95131",
"country_code": "US"
}
}
},
"links": [
{
"rel": "self",
"href": "https://api-m.paypal.com/v3/vault/payment-tokens/8kk8451t",
"method": "GET",
"encType": "application/json"
},
{
"rel": "delete",
"href": "https://api-m.paypal.com/v3/vault/payment-tokens/8kk8451t",
"method": "DELETE",
"encType": "application/json"
}
]
}{
"id": "fgh6561t",
"customer": {
"id": "BygeLlrpZF",
"merchant_customer_id": "[email protected]"
},
"payment_source": {
"paypal": {
"email_address": "[email protected]",
"account_id": "VYYFH3WJ4JPJQ"
}
},
"links": [
{
"rel": "self",
"href": "https://api-m.paypal.com/v3/vault/payment-tokens/fgh6561t",
"method": "GET",
"encType": "application/json"
},
{
"rel": "delete",
"href": "https://api-m.paypal.com/v3/vault/payment-tokens/fgh6561t",
"method": "DELETE",
"encType": "application/json"
}
]
}{
"id": "hg654s1t",
"customer": {
"id": "BygeLlrpZF",
"merchant_customer_id": "[email protected]"
},
"payment_source": {
"venmo": {
"email_address": "[email protected]"
}
},
"links": [
{
"rel": "self",
"href": "https://api-m.paypal.com/v3/vault/payment-tokens/hg654s1t",
"method": "GET",
"encType": "application/json"
},
{
"rel": "delete",
"href": "https://api-m.paypal.com/v3/vault/payment-tokens/hg654s1t",
"method": "DELETE",
"encType": "application/json"
}
]
}{
"name": "NOT_AUTHORIZED",
"message": "Authorization failed due to insufficient permissions.",
"debug_id": "9ecb6d8e2e112",
"details": [
{
"issue": "PERMISSION_DENIED",
"description": "You do not have permission to access or perform operations on this resource."
}
],
"links": [
{
"href": "https://developer.paypal.com/docs/api/overview/#error",
"rel": "information_link"
}
]
}{
"name": "RESOURCE_NOT_FOUND",
"message": "The specified resource does not exist.",
"debug_id": "ccb6f410b107f",
"details": [
{
"issue": "TOKEN_NOT_FOUND",
"description": "The specified token id does not exist."
}
],
"links": [
{
"href": "https://developer.paypal.com/docs/api/overview/#error",
"rel": "information_link"
}
]
}{
"name": "INTERNAL_SERVER_ERROR",
"message": "An internal server error has occurred.",
"debug_id": "z9x8y7w6v5u43"
}