Application Context

See https://developer.paypal.com/docs/api/orders/v2/#definition-order_application_context

Methods

ApplicationContext::__construct()

Creates an application context object using constructor.

Signature

public function __construct(
    ?string $brand_name = null,
    ?string $locale = 'en-US',
    ?string $landing_page = NO_PREFERENCE,
    ?string $shipping_preference = NO_SHIPPING,
    ?string $return_url = null,
    ?string $cancel_url = null
);

Example

$application_context = new ApplicationContext('PHPJuice', 'en-US');

ApplicationContext::create()

Helper method to create an ApplicationContext statically.

Signature

public static function create(
    ?string $brand_name = null,
    ?string $locale = 'en-US',
    ?string $landing_page = NO_PREFERENCE,
    ?string $shipping_preference = NO_SHIPPING,
    ?string $return_url = null,
    ?string $cancel_url = null
): ApplicationContext;

Example

$application_context = ApplicationContext::create('PHPJuice', 'en-US');

ApplicationContext::getBrandName()

Returns the brand name value from the application context.

Signature

public function getBrandName(): ?string;

Example

$application_context = ApplicationContext::create('PHPJuice', 'en-US');
$application_context->getBrandName() // PHPJuice

ApplicationContext::setBrandName()

Sets the brand name value on an application context.

Signature

public function setBrandName($brand_name): self;

Example

$application_context = ApplicationContext::create('PHPJuice', 'en-US');
$application_context->setBrandName('PHPJuice Inc');
$application_context->getBrandName(); // PHPJuice Inc

ApplicationContext::getLocale()

Returns the locale value from the application context, default to en-US.

Signature

public function getLocale(): string;

Example

$application_context = ApplicationContext::create('PHPJuice', 'en-US');
$application_context->getLocale() // en-US

ApplicationContext::setLocale()

Sets a locale on an application context.

Signature

public function setLocale($locale): self;

Example

$application_context = ApplicationContext::create('PHPJuice', 'en-US');
$application_context->setLocale('en-GB');
$application_context->getLocale(); // en-GB

ApplicationContext::getShippingPreference()

Returns the shipping preference value from an application context, default to NO_SHIPPING.

Signature

public function getShippingPreference(): string;

Example

$application_context = ApplicationContext::create('PHPJuice', 'en-US', 'NO_SHIPPING');
$application_context->getShippingPreference() // NO_SHIPPING

ApplicationContext::setShippingPreference()

Sets a shipping preference value on an application context.

Signature

public function setShippingPreference($shipping_preference): self;

Available shipping preference options

const GET_FROM_FILE = 'GET_FROM_FILE';
const NO_SHIPPING = 'NO_SHIPPING';
const SET_PROVIDED_ADDRESS = 'SET_PROVIDED_ADDRESS';

Example

$application_context = ApplicationContext::create('PHPJuice', 'en-US');
$application_context->setShippingPreference('GET_FROM_FILE');
$application_context->getShippingPreference(); // GET_FROM_FILE

ApplicationContext::getLandingPage()

Returns the landing page value from an application context, default to NO_PREFERENCE.

Signature

public function getLandingPage(): string;

Example

$application_context = ApplicationContext::create('PHPJuice', 'en-US');
$application_context->getLandingPage() // NO_PREFERENCE

ApplicationContext::setLandingPage()

Sets a landing page value on an application context.

Signature

public function setLandingPage($landing_page): self;

Available landing page options

const LOGIN = 'LOGIN';
const BILLING = 'BILLING';
const NO_PREFERENCE = 'NO_PREFERENCE';

Example

$application_context = ApplicationContext::create('PHPJuice', 'en-US');
$application_context->setLandingPage('BILLING');
$application_context->getLandingPage(); // BILLING

ApplicationContext::getUserAction()

Returns the user action value from an application context, default to CONTINUE.

Signature

public function getUserAction(): string;

Example

$application_context = ApplicationContext::create('PHPJuice', 'en-US');
$application_context->getUserAction() // CONTINUE

ApplicationContext::setUserAction()

Sets a user action value on an application context.

Signature

public function setUserAction($user_action): self;

Available user action options

const ACTION_CONTINUE = 'CONTINUE';
const ACTION_PAY_NOW = 'PAY_NOW';

Example

$application_context = ApplicationContext::create('PHPJuice', 'en-US');
$application_context->setUserAction('PAY_NOW');
$application_context->getUserAction(); // PAY_NOW

ApplicationContext::getReturnUrl()

Returns the return url value from an application context, default to null.

Signature

public function getReturnUrl(): string;

Example

$application_context = ApplicationContext::create('PHPJuice', 'en-US');
$application_context->getReturnUrl() // null

ApplicationContext::setReturnUrl()

Sets a return url value on an application context.

Signature

public function setReturnUrl($return_url): self;

Example

$application_context = ApplicationContext::create('PHPJuice', 'en-US');
$application_context->setReturnUrl('https://phpjuice.org/success');
$application_context->getReturnUrl(); // https://phpjuice.org/success

ApplicationContext::getCancelUrl()

Returns the cancel url value from an application context, default to null.

Signature

public function getCancelUrl(): string;

Example

$application_context = ApplicationContext::create('PHPJuice', 'en-US');
$application_context->getCancelUrl() // null

ApplicationContext::setCancelUrl()

Sets a cancel url value on an application context.

Signature

public function setCancelUrl($cancel_url): self;

Example

$application_context = ApplicationContext::create('PHPJuice', 'en-US');
$application_context->setCancelUrl('https://phpjuice.org/cancel');
$application_context->getCancelUrl(); // https://phpjuice.org/cancel

Last updated