%PDF-
%PDF-
Mini Shell
Mini Shell
<?php
namespace GoDaddy\WordPress\MWC\Core\Payments\Poynt;
use Exception;
use GoDaddy\WordPress\MWC\Common\Configuration\Configuration;
use GoDaddy\WordPress\MWC\Common\Helpers\ArrayHelper;
use GoDaddy\WordPress\MWC\Common\Helpers\StringHelper;
use GoDaddy\WordPress\MWC\Common\Models\User;
use GoDaddy\WordPress\MWC\Common\Repositories\ManagedWooCommerceRepository;
use GoDaddy\WordPress\MWC\Common\Repositories\WooCommerceRepository;
use GoDaddy\WordPress\MWC\Common\Repositories\WordPress\SiteRepository;
use GoDaddy\WordPress\MWC\Core\Payments\Poynt;
use GoDaddy\WordPress\MWC\Core\WooCommerce\Payments\Events\Producers\OnboardingEventsProducer;
use WC_Payment_Gateway;
class Onboarding
{
/** @var string connected status */
const STATUS_CONNECTED = 'CONNECTED';
/** @var string connecting status */
const STATUS_CONNECTING = 'CONNECTING';
/** @var string deactivated status */
const STATUS_DEACTIVATED = 'DEACTIVATED';
/** @var string not available status */
const STATUS_DECLINED = 'DECLINED';
/** @var string disconnected status */
const STATUS_DISCONNECTED = 'DISCONNECTED';
/** @var string incomplete status */
const STATUS_INCOMPLETE = 'INCOMPLETE';
/** @var string needs attention status */
const STATUS_NEEDS_ATTENTION = 'NEEDS_ATTENTION';
/** @var string pending status */
const STATUS_PENDING = 'PENDING';
/** @var string suspended status */
const STATUS_SUSPENDED = 'SUSPENDED';
/** @var string not available status */
const STATUS_TERMINATED = 'TERMINATED';
/** @var string add bank info action */
public const ACTION_ADD_BANK = 'ADD_BANK';
/** @var string complete verification action */
public const ACTION_COMPLETE_VERIFICATION = 'COMPLETE_VERIFICATION';
/** @var string complete verification reminder action */
public const ACTION_COMPLETE_VERIFICATION_REMINDER = 'COMPLETE_VERIFICATION_REMINDER';
/** @var string complete verification warning action */
public const ACTION_COMPLETE_VERIFICATION_WARNING = 'COMPLETE_VERIFICATION_WARNING';
/** @var string complete verification past due action */
public const ACTION_COMPLETE_VERIFICATION_PAST_DUE = 'COMPLETE_VERIFICATION_PAST_DUE';
/**
* Determines if the payment gateway can be enabled.
*
* @param string $status
*
* @return bool
*/
public static function canEnablePaymentGateway(string $status) : bool
{
return ArrayHelper::contains([static::STATUS_CONNECTED, static::STATUS_NEEDS_ATTENTION], $status);
}
/**
* Determines of the payment gateway can be managed.
*
* @param string $status
*
* @return bool
*/
public static function canManagePaymentGateway(string $status) : bool
{
return ArrayHelper::contains([
static::STATUS_CONNECTED,
static::STATUS_DECLINED,
static::STATUS_INCOMPLETE,
static::STATUS_NEEDS_ATTENTION,
static::STATUS_PENDING,
static::STATUS_SUSPENDED,
], $status);
}
/**
* Gets the signup URL.
*
* @param string $serviceId
* @param string $redirectNonce
* @return string
* @throws Exception
*/
public static function getSignupUrl(string $serviceId, string $redirectNonce) : string
{
$context = ArrayHelper::jsonEncode([
'serviceId' => $serviceId,
'redirectNonce' => $redirectNonce,
]);
$currentUser = User::getCurrent();
$parameters = [
'name' => $currentUser ? trim($currentUser->getFirstName().' '.$currentUser->getLastName()) : '',
'email' => $currentUser && is_email($currentUser->getEmail()) ? $currentUser->getEmail() : '',
'companyName' => SiteRepository::getTitle(),
'companyAddressLine1' => WooCommerceRepository::isWooCommerceActive() ? WC()->countries->get_base_address() : '', // TODO: consider wrapping these getters with a common repository {@cwiseman 2021-05-23}
'companyAddressLine2' => WooCommerceRepository::isWooCommerceActive() ? WC()->countries->get_base_address_2() : '',
'companyAddressZip' => WooCommerceRepository::isWooCommerceActive() ? WC()->countries->get_base_postcode() : '',
'companyAddressCity' => WooCommerceRepository::isWooCommerceActive() ? WC()->countries->get_base_city() : '',
'companyTerritory' => WooCommerceRepository::isWooCommerceActive() ? WC()->countries->get_base_state() : '',
'companyWebsite' => esc_url(SiteRepository::getHomeUrl()),
'context' => base64_encode($context),
'redirectUrl' => StringHelper::trailingSlash(ManagedWooCommerceRepository::getApiUrl()).'payments/redirect',
'serviceId' => $serviceId,
'serviceType' => Configuration::get('payments.poynt.serviceType', ''),
];
// add the mock flag if not in the production environment
if (! ManagedWooCommerceRepository::isProductionEnvironment()) {
$parameters['mock'] = 'true';
}
return add_query_arg(rawurlencode_deep(array_filter($parameters)), static::getBaseSignupUrl());
}
/**
* Gets the base signup URL.
*
* @return string
*/
public static function getBaseSignupUrl() : string
{
// point to the production or staging environments depending on the current site location
return ManagedWooCommerceRepository::isProductionEnvironment() ? Configuration::get('payments.poynt.onboarding.productionUrl', '') : Configuration::get('payments.poynt.onboarding.stagingUrl', '');
}
/**
* Gets the application URL.
*
* @return string
* @throws Exception
*/
public static function getApplicationUrl() : string
{
$context = ArrayHelper::jsonEncode([
'serviceId' => Poynt::getServiceId(),
'redirectNonce' => wp_create_nonce(OnboardingEventsProducer::ACTION_REDIRECT),
]);
return add_query_arg([
'context' => base64_encode($context),
'serviceType' => Configuration::get('payments.poynt.serviceType', ''),
], remove_query_arg('mock', static::getBaseSignupUrl()).'/urn:app:'.Poynt::getBusinessId().'/update');
}
/**
* Gets the switch account URL.
*
* @return string
* @throws Exception
*/
public static function getSwitchAccountUrl() : string
{
return self::getSignupUrl(Poynt::getServiceId(), wp_create_nonce(OnboardingEventsProducer::ACTION_REDIRECT));
}
/**
* Gets the onboarding status.
*
* @return string
*/
public static function getStatus() : string
{
return (string) Configuration::get('payments.poynt.onboarding.status', '');
}
/**
* Gets the configured webhook secret.
*
* @return string
* @throws Exception
*/
public static function getWebhookSecret() : string
{
return (string) Configuration::get('payments.poynt.onboarding.webhookSecret', '');
}
/**
* Gets the configured required actions.
*
* @return string[]
*/
public static function getRequiredActions() : array
{
return (array) Configuration::get('payments.poynt.onboarding.actionsRequired', []);
}
/**
* Sets the configured required actions.
*
* @param string[] $value
*/
public static function setRequiredActions(array $value)
{
update_option('mwc_payments_poynt_onboarding_actionsRequired', $value);
Configuration::set('payments.poynt.onboarding.actionsRequired', $value);
}
/**
* Determines if the onboarded account has deposits enabled.
*
* @return bool
* @throws Exception
*/
public static function depositsEnabled() : bool
{
return (bool) Configuration::get('payments.poynt.onboarding.depositsEnabled', false);
}
/**
* Determines if the onboarded account has a bank account.
*
* @return bool
* @throws Exception
*/
public static function hasBankAccount() : bool
{
return (bool) Configuration::get('payments.poynt.onboarding.hasBankAccount', false);
}
/**
* Determines if the onboarded account has been switched.
*
* @return bool
*/
public static function hasSwitchedAccounts() : bool
{
return (bool) Configuration::get('payments.poynt.onboarding.hasSwitchedAccounts', false);
}
/**
* Determines if the onboarded account has payments enabled.
*
* @return bool
* @throws Exception
*/
public static function paymentsEnabled() : bool
{
return (bool) Configuration::get('payments.poynt.onboarding.paymentsEnabled', false);
}
/**
* Determines if signup has been started.
*
* @return bool
* @throws Exception
*/
public static function isSignupStarted() : bool
{
return (bool) Configuration::get('payments.poynt.onboarding.signupStarted', false);
}
/**
* Sets whether the account has deposits enabled.
*
* @param bool $value
*
* @throws Exception
*/
public static function setDepositsEnabled(bool $value)
{
update_option('mwc_payments_poynt_onboarding_depositsEnabled', $value);
Configuration::set('payments.poynt.onboarding.depositsEnabled', $value);
}
/**
* Sets whether the account has a bank account.
*
* @param bool $value
*
* @throws Exception
*/
public static function setHasBankAccount(bool $value)
{
update_option('mwc_payments_poynt_onboarding_hasBankAccount', $value);
Configuration::set('payments.poynt.onboarding.hasBankAccount', $value);
}
/**
* Sets whether the account has been switched.
*
* @param bool $value
*/
public static function setHasSwitchedAccounts(bool $value)
{
update_option('mwc_payments_poynt_onboarding_hasSwitchedAccounts', $value);
Configuration::set('payments.poynt.onboarding.hasSwitchedAccounts', $value);
}
/**
* Sets whether the account has payments enabled.
*
* @param bool $value
*
* @throws Exception
*/
public static function setPaymentsEnabled(bool $value)
{
update_option('mwc_payments_poynt_onboarding_paymentsEnabled', $value);
Configuration::set('payments.poynt.onboarding.paymentsEnabled', $value);
}
/**
* Sets the onboarding status.
*
* @param string $value
*
* @throws Exception
*/
public static function setStatus(string $value)
{
update_option('mwc_payments_poynt_onboarding_status', $value);
Configuration::set('payments.poynt.onboarding.status', $value);
}
/**
* Sets the webhook secret.
*
* @param string $value
*
* @throws Exception
*/
public static function setWebhookSecret(string $value)
{
update_option('mwc_payments_poynt_onboarding_webhookSecret', $value);
Configuration::set('payments.poynt.onboarding.webhookSecret', $value);
}
/**
* Checks if the site has any enabled payment gateways.
*
* @since 2.10.0
*
* @return bool
*/
protected static function hasEnabledPaymentGateways() : bool
{
if (! function_exists('WC')) {
return false;
}
// intentionally scans registered gateways rather than WC()->payment_gateways()->get_available_payment_gateways(),
// which depends on a front-end WC session and is unreliable in the admin/REST/cron contexts this runs in
foreach (WC()->payment_gateways()->payment_gateways() as $gateway) {
if ($gateway instanceof WC_Payment_Gateway && 'yes' === $gateway->enabled) {
return true;
}
}
return false;
}
/**
* Checks if GDP should be auto-enabled or not.
*
* @since z.y.z
*
* @return bool
*/
public static function shouldAutoEnablePaymentGateways() : bool
{
return static::STATUS_CONNECTED === static::getStatus() &&
Configuration::get('godaddy.temporary_domain') &&
! static::hasEnabledPaymentGateways();
}
/**
* Checks if the serviceId and the webhookSecret needs to be generated and sets them.
*
* @throws Exception
*/
public static function generateIds() : void
{
if (! $serviceId = Poynt::getServiceId()) {
$serviceId = StringHelper::generateUuid4();
}
if (! $webhookSecret = Onboarding::getWebhookSecret()) {
$webhookSecret = StringHelper::generateUuid4();
}
Poynt::setServiceId($serviceId);
Onboarding::setWebhookSecret($webhookSecret);
}
}
Zerion Mini Shell 1.0
Custom Staffing Solutions | Beyond A Resume
Skip to content
Distinguish Your Business From The Rest With The People That Make Up Your Team
We go Beyond a Resume to find high value, committed people
ready, willing, and able to add true value toward your organization's mission.
The right people make or break your business
We focus on resolving two types of challenges surrounding staffing and recruiting at Beyond a Resume: The first challenge comes when a business continues to grow, but does not have the full-time, internal, talent acquisition resources to hire the right people or talent necessary to keep up with their rate of progression as a company.
The second is a business that has a dedicated internal Human Resources Team, but requires outsourced assistance when the volume of people and talent needed exceeds short term internal capacity, OR the position(s) they seek to fill demand a specific skill set that is difficult to find, requiring added bandwidth.
In nearly any line of business, growth is a challenge in and of itself. Yet, the real problems arise in managing growth to ensure your progress remains profitable, sustainable, and repeatable. The biggest factor in this equation is usually found in your people. When you have the right people, success is unlimited. On the other hand, when you don’t have the right people in place or are having trouble finding enough of the right people, failure or stagnation is imminent.
The frustration that comes with the process of “hiring” can bring you to new levels of stress as the time cost involved eats away at your production elsewhere. If you have experienced this in the past, or are currently struggling with this issue, you’re certainly not alone. You may simply need the right partner to take the worst parts of this process off your plate so you can concentrate on your responsibilities, while we work diligently to reduce the noise and deliver only the ideal candidates worth your time and attention.
People can make or break your business and we go Beyond a Resume to find high value, committed people ready, willing, and able to add true value.
Primary Industry Experience
Healthcare and Home Healthcare
Talent Acquisition Solutions
Statement of Work Projects
Scroll To Top