This commit is contained in:
David Remer 2020-07-02 13:10:41 +03:00
parent f74773952c
commit cbba3e39c1
3 changed files with 19 additions and 14 deletions

View file

@ -1,9 +1,9 @@
<?php
declare(strict_types=1);
namespace Inpsyde\PayPalCommerce\Onboarding\Assets;
use Inpsyde\PayPalCommerce\ApiClient\Endpoint\PartnerReferrals;
use Inpsyde\PayPalCommerce\Onboarding\Endpoint\LoginSellerEndpoint;
use Inpsyde\PayPalCommerce\Onboarding\State;
@ -19,12 +19,13 @@ class OnboardingAssets
State $state,
LoginSellerEndpoint $loginSellerEndpoint
) {
$this->moduleUrl = $moduleUrl;
$this->state = $state;
$this->loginSellerEndpoint = $loginSellerEndpoint;
}
public function register() : bool
public function register(): bool
{
if (!$this->shouldRender()) {
@ -51,8 +52,8 @@ class OnboardingAssets
return true;
}
public function enqueue() : bool {
public function enqueue(): bool
{
if (! $this->shouldRender()) {
return false;
}
@ -61,7 +62,9 @@ class OnboardingAssets
return true;
}
private function shouldRender() : bool {
private function shouldRender(): bool
{
// phpcs:disable Inpsyde.CodeQuality.VariablesName.SnakeCaseVar
global $current_section;
if ($current_section !== 'ppcp-gateway') {
return false;
@ -70,4 +73,4 @@ class OnboardingAssets
$shouldRender = $this->state->currentState() === State::STATE_PROGRESSIVE;
return $shouldRender;
}
}
}

View file

@ -44,8 +44,6 @@ class OnboardingModule implements ModuleInterface
]
);
add_filter(
'woocommerce_form_field',
static function ($field, $key, $config) use ($container) {

View file

@ -1,9 +1,9 @@
<?php
declare(strict_types=1);
namespace Inpsyde\PayPalCommerce\Onboarding\Render;
use Inpsyde\PayPalCommerce\ApiClient\Endpoint\PartnerReferrals;
use Inpsyde\PayPalCommerce\ApiClient\Exception\RuntimeException;
@ -16,7 +16,8 @@ class OnboardingRenderer
$this->partnerReferrals = $partnerReferrals;
}
public function render() {
public function render()
{
try {
$url = add_query_arg(
[
@ -32,18 +33,21 @@ class OnboardingRenderer
href="<?php echo esc_url($url); ?>"
data-paypal-button="true"
><?php
esc_html_e('Sign up for PayPal', 'woocommerce-paypal-commerce-gateway');
esc_html_e(
'Sign up for PayPal',
'woocommerce-paypal-commerce-gateway'
);
?></a>
<script
id="paypal-js"
src="https://www.sandbox.paypal.com/webapps/merchantboarding/js/lib/lightbox/partner.js"
></script>
<?php
} catch(RuntimeException $exception) {
} catch (RuntimeException $exception) {
esc_html_e(
'We could not properly connect to PayPal. Please reload the page to continue',
'woocommerce-paypal-commerce-gateway'
);
);
}
}
}
}