WooCommerce Code Reference

TransactAccountManager
in package

PayPal TransactAccountManager Class

Handles Transact account management.

Tags
since
10.5.0

Table of Contents

TRANSACT_ACCOUNT_CACHE_EXPIRY  = 60 * 60 * 24
The expiry time for the Transact account cache.
TRANSACT_MERCHANT_ACCOUNT_CACHE_KEY_LIVE  = 'woocommerce_paypal_transact_merchant_account_live'
Cache key for the merchant account in live mode.
TRANSACT_MERCHANT_ACCOUNT_CACHE_KEY_TEST  = 'woocommerce_paypal_transact_merchant_account_test'
Cache key for the merchant account in test mode.
TRANSACT_PROVIDER_ACCOUNT_CACHE_KEY_LIVE  = 'woocommerce_paypal_transact_provider_account_live'
Cache key for the provider account in live mode.
TRANSACT_PROVIDER_ACCOUNT_CACHE_KEY_TEST  = 'woocommerce_paypal_transact_provider_account_test'
Cache key for the provider account in test mode.
TRANSACT_PROVIDER_TYPE  = 'paypal_standard'
Transact provider type, for provider onboarding.
WPCOM_PROXY_ENDPOINT_API_VERSION  = 2
The API version for the proxy endpoint.
$gateway  : WC_Gateway_Paypal
Paypal gateway object.
__construct()  : mixed
Constructor.
do_onboarding()  : void
Onboard the merchant with the Transact platform.
get_transact_account_data()  : mixed
Get the Transact account (merchant or provider) data. Performs a fetch if the account is not in cache or expired.
create_merchant_account()  : array<string|int, mixed>|null
Create the merchant account with the Transact platform.
create_provider_account()  : bool
Create the provider account with the Transact platform.
fetch_merchant_account()  : array<string|int, mixed>|null
Fetch the merchant account from the Transact platform.
fetch_provider_account()  : bool
Fetch the provider account from the Transact platform.
get_cache_key()  : string|null
Get the cache key for the transact account.
get_transact_account_from_cache()  : mixed
Get the transact account (merchant or provider) from the database cache.
send_transact_api_request()  : array<string|int, mixed>|WP_Error
Send a request to the Transact platform.
update_transact_account_cache()  : void
Update the transact account (merchant or provider) cache.

Constants

TRANSACT_MERCHANT_ACCOUNT_CACHE_KEY_LIVE

Cache key for the merchant account in live mode.

private string TRANSACT_MERCHANT_ACCOUNT_CACHE_KEY_LIVE = 'woocommerce_paypal_transact_merchant_account_live'
Tags
since
10.5.0

TRANSACT_MERCHANT_ACCOUNT_CACHE_KEY_TEST

Cache key for the merchant account in test mode.

private string TRANSACT_MERCHANT_ACCOUNT_CACHE_KEY_TEST = 'woocommerce_paypal_transact_merchant_account_test'
Tags
since
10.5.0

TRANSACT_PROVIDER_ACCOUNT_CACHE_KEY_LIVE

Cache key for the provider account in live mode.

private string TRANSACT_PROVIDER_ACCOUNT_CACHE_KEY_LIVE = 'woocommerce_paypal_transact_provider_account_live'
Tags
since
10.5.0

TRANSACT_PROVIDER_ACCOUNT_CACHE_KEY_TEST

Cache key for the provider account in test mode.

private string TRANSACT_PROVIDER_ACCOUNT_CACHE_KEY_TEST = 'woocommerce_paypal_transact_provider_account_test'
Tags
since
10.5.0

Properties

Methods

get_transact_account_data()

Get the Transact account (merchant or provider) data. Performs a fetch if the account is not in cache or expired.

public get_transact_account_data(string $account_type) : mixed
Parameters
$account_type : string

The type of account to get (merchant or provider).

Tags
since
10.5.0
Return values
mixedReturns null if the transact account cannot be retrieved.

create_merchant_account()

Create the merchant account with the Transact platform.

private create_merchant_account() : array<string|int, mixed>|null
Tags
since
10.5.0
Return values
array<string|int, mixed>|nullThe API response body, or null if the request fails.

create_provider_account()

Create the provider account with the Transact platform.

private create_provider_account() : bool
Tags
since
10.5.0
Return values
boolTrue if the provider account creation was successful, false otherwise.

fetch_merchant_account()

Fetch the merchant account from the Transact platform.

private fetch_merchant_account() : array<string|int, mixed>|null
Tags
since
10.5.0
Return values
array<string|int, mixed>|nullThe API response body, or null if the request fails.

fetch_provider_account()

Fetch the provider account from the Transact platform.

private fetch_provider_account() : bool
Tags
since
10.5.0
Return values
boolTrue if the provider account exists, false otherwise.

get_cache_key()

Get the cache key for the transact account.

private get_cache_key(string $account_type) : string|null
Parameters
$account_type : string

The type of account to get (merchant or provider).

Tags
since
10.5.0
Return values
string|nullThe cache key, or null if the account type is invalid.

get_transact_account_from_cache()

Get the transact account (merchant or provider) from the database cache.

private get_transact_account_from_cache(string $cache_key) : mixed
Parameters
$cache_key : string

The cache key to get the account.

Tags
since
10.5.0
Return values
mixedThe transact account data, or null if the cache is empty or expired.

send_transact_api_request()

Send a request to the Transact platform.

private send_transact_api_request(string $method, string $endpoint, array<string|int, mixed> $request_body) : array<string|int, mixed>|WP_Error
Parameters
$method : string

The HTTP method to use.

$endpoint : string

The endpoint to request.

$request_body : array<string|int, mixed>

The request body.

Tags
since
10.5.0
Return values
array<string|int, mixed>|WP_ErrorThe API response body, or null if the request fails.

update_transact_account_cache()

Update the transact account (merchant or provider) cache.

private update_transact_account_cache(string|null $cache_key, array<string|int, mixed>|bool $account_data) : void
Parameters
$cache_key : string|null

The cache key to update.

$account_data : array<string|int, mixed>|bool

The transact account data.

Tags
since
10.5.0
Return values
void