Skip to content

Commit

Permalink
PT-13108 - Fix general setting landing page with default value (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Garding committed Jun 27, 2023
1 parent 299849f commit fce0ae6
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ protected function createExperienceContext(PayPalOrderParameter $orderParameter)
}

$experienceContext->setLocale(str_replace('_', '-', $shop->getLocale()->getLocale()));
$experienceContext->setLandingPage($generalSettings->getLandingPageType());
$experienceContext->setLandingPage($this->getLandingPage($generalSettings));

if ($this->requiresUrls($orderParameter->getPaymentType())) {
$experienceContext->setCancelUrl($this->returnUrlHelper->getCancelUrl($orderParameter->getBasketUniqueId(), $orderParameter->getPaymentToken()));
Expand All @@ -118,6 +118,20 @@ protected function createExperienceContext(PayPalOrderParameter $orderParameter)
return $experienceContext;
}

/**
* @return string
*/
private function getLandingPage(General $generalSettings)
{
$currentLandingPage = $generalSettings->getLandingPageType();

if (!\in_array($currentLandingPage, ExperienceContext::LANDING_PAGE_TYPES)) {
return ExperienceContext::LANDING_PAGE_TYPE_NO_PREFERENCE;
}

return $currentLandingPage;
}

/**
* @param string $firstname
* @param string $lastname
Expand Down
12 changes: 12 additions & 0 deletions PayPalBundle/V2/Api/Order/PaymentSource/ExperienceContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@

class ExperienceContext extends PayPalApiStruct
{
const LANDING_PAGE_TYPE_LOGIN = 'LOGIN';

const LANDING_PAGE_TYPE_BILLING = 'BILLING';

const LANDING_PAGE_TYPE_NO_PREFERENCE = 'NO_PREFERENCE';

const LANDING_PAGE_TYPES = [
self::LANDING_PAGE_TYPE_BILLING,
self::LANDING_PAGE_TYPE_LOGIN,
self::LANDING_PAGE_TYPE_NO_PREFERENCE,
];

const PAYMENT_METHOD_PREFERENCE = 'IMMEDIATE_PAYMENT_REQUIRED';

const PAYMENT_METHOD = 'PAYPAL';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Ext.define('Shopware.apps.PaypalUnifiedSettings.view.LandingPageSelect', {
queryMode: 'local',
valueField: 'key',
displayField: 'label',
value: 'NO_PREFERENCE',

listConfig: {
getInnerTpl: function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ public function testCreateExperienceContext(
$this->insertGeneralSettingsFromArray([
'active' => true,
'brand_name' => 'AnyFancyFooBarBrandName',
'landing_page_type' => 'NO_PREFERENCE',
]);

$reflectionMethod = $this->getReflectionMethod(\get_class($orderValueHandler), 'createExperienceContext');
Expand All @@ -109,12 +108,13 @@ public function testCreateExperienceContext(
static::assertInstanceOf(ExperienceContext::class, $result);

static::assertSame('AnyFancyFooBarBrandName', $result->getBrandName());
static::assertSame('NO_PREFERENCE', $result->getLandingPage());
static::assertSame(ExperienceContext::PAYMENT_METHOD_PREFERENCE, $result->getPaymentMethodPreference());
static::assertSame(ExperienceContext::PAYMENT_METHOD, $result->getPaymentMethodSelected());
static::assertSame(ExperienceContext::SHIPPING_PREFERENCE_PROVIDED_ADDRESS, $result->getShippingPreference());
static::assertSame(ExperienceContext::USER_ACTION_PAY_NOW, $result->getUserAction());
static::assertSame('de-DE', $result->getLocale());
// check default landing page isset
static::assertSame('NO_PREFERENCE', $result->getLandingPage());
}

/**
Expand Down
9 changes: 9 additions & 0 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@
<author>shopware AG</author>
<compatibility minVersion="5.2.27" maxVersion="5.99.99"/>

<changelog version="REPLACE_GLOBAL_WITH_NEXT_VERSION(6.0.9)">
<changes lang="de">
PT-13108 - Nutzt Standard-Landingpage, wenn die Einstellung nicht korrekt gesetzt wurde;
</changes>
<changes lang="en">
PT-13108 - Uses default landing page if setting is not set correctly;
</changes>
</changelog>

<changelog version="6.0.8">
<changes lang="de">
PT-13099 - Bei wiederkehrendem Express-Checkout ist die PayPal Zahlungsart nun korrekt ausgewählt;
Expand Down

0 comments on commit fce0ae6

Please sign in to comment.