Skip to content

Commit 169d48b

Browse files
authored
fix: checkout as guest customer (#166)
fixes #165
1 parent e2c13c0 commit 169d48b

File tree

12 files changed

+347
-9
lines changed

12 files changed

+347
-9
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
# 9.7.2
2+
- Fixes an issue, where guest checkout was not possible (shopware/SwagPayPal#165)
3+
14
# 9.7.1
2-
- Fixes an issue where payments could not be refunded (shopware/shopware#7644)
5+
- Fixes an issue, where payments could not be refunded (shopware/shopware#7644)
36

47
# 9.7.0
58
- PPI-1000 - Fixes an issue, where PayLater is shown in cases where it should not be available

CHANGELOG_de-DE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 9.7.2
2+
- Behebt ein Problem, bei dem der Checkout als Gast nicht möglich war (shopware/SwagPayPal#165)
3+
14
# 9.7.1
25
- Behebt ein Problem, bei dem Zahlungen nicht erstattet werden konnten (shopware/shopware#7644)
36

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "swag/paypal",
33
"description": "PayPal integration for Shopware 6",
4-
"version": "9.7.1",
4+
"version": "9.7.2",
55
"type": "shopware-platform-plugin",
66
"license": "MIT",
77
"authors": [

src/Resources/config/services/storefront.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
<argument type="service" id="Swag\PayPal\Setting\Service\CredentialsUtil"/>
7272
</service>
7373

74-
<service id="Swag\PayPal\Storefront\Data\Service\ACDCCheckoutDataService" public="true" parent="Swag\PayPal\Storefront\Data\Service\AbstractCheckoutDataService" />
74+
<service id="Swag\PayPal\Storefront\Data\Service\ACDCCheckoutDataService" public="true" parent="Swag\PayPal\Storefront\Data\Service\AbstractCheckoutDataService"/>
7575
<service id="Swag\PayPal\Storefront\Data\Service\ApplePayCheckoutDataService" public="true" parent="Swag\PayPal\Storefront\Data\Service\AbstractCheckoutDataService"/>
7676
<service id="Swag\PayPal\Storefront\Data\Service\GooglePayCheckoutDataService" public="true" parent="Swag\PayPal\Storefront\Data\Service\AbstractCheckoutDataService" />
7777
<service id="Swag\PayPal\Storefront\Data\Service\PayLaterCheckoutDataService" public="true" parent="Swag\PayPal\Storefront\Data\Service\AbstractCheckoutDataService" />

src/Storefront/Data/Service/AbstractCheckoutDataService.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ abstract class AbstractCheckoutDataService extends AbstractScriptDataService
2727
{
2828
public const PAYPAL_ERROR = 'isPayPalError';
2929

30+
protected AbstractMethodData $methodData;
31+
3032
/**
3133
* @internal
3234
*/
@@ -38,6 +40,7 @@ public function __construct(
3840
CredentialsUtilInterface $credentialsUtil,
3941
) {
4042
parent::__construct($localeCodeProvider, $systemConfigService, $credentialsUtil);
43+
$this->methodData = $this->paymentMethodDataRegistry->getPaymentMethod($this->getMethodDataClass());
4144
}
4245

4346
abstract public function buildCheckoutData(SalesChannelContext $context, ?Cart $cart = null, ?OrderEntity $order = null): ?AbstractCheckoutData;
@@ -53,10 +56,7 @@ protected function getBaseData(SalesChannelContext $context, ?OrderEntity $order
5356
throw CartException::customerNotLoggedIn();
5457
}
5558

56-
$paymentMethodId = $this->paymentMethodDataRegistry->getEntityIdFromData(
57-
$this->paymentMethodDataRegistry->getPaymentMethod($this->getMethodDataClass()),
58-
$context->getContext()
59-
);
59+
$paymentMethodId = $this->paymentMethodDataRegistry->getEntityIdFromData($this->methodData, $context->getContext());
6060

6161
$salesChannelId = $context->getSalesChannelId();
6262

src/Storefront/Data/Service/SPBCheckoutDataService.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,17 @@ public function buildCheckoutData(
7171

7272
$data = $this->getBaseData($context, $order);
7373

74+
$userIdToken = null;
75+
if ($this->methodData->isVaultable($context)) {
76+
$userIdToken = $this->customerVaultTokenRoute->getVaultToken($context)->getToken();
77+
}
78+
7479
return (new SPBCheckoutButtonData())->assign(\array_merge($data, [
7580
'buttonColor' => $this->systemConfigService->getString(Settings::SPB_BUTTON_COLOR, $salesChannelId),
7681
'useAlternativePaymentMethods' => $this->systemConfigService->getBool(Settings::SPB_ALTERNATIVE_PAYMENT_METHODS_ENABLED, $salesChannelId),
7782
'disabledAlternativePaymentMethods' => $this->getDisabledAlternativePaymentMethods($price, $currency->getIsoCode()),
7883
'showPayLater' => $this->systemConfigService->getBool(Settings::SPB_SHOW_PAY_LATER, $salesChannelId),
79-
'userIdToken' => $this->customerVaultTokenRoute->getVaultToken($context)->getToken(),
84+
'userIdToken' => $userIdToken,
8085
]));
8186
}
8287

src/Storefront/Data/Service/VenmoCheckoutDataService.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,13 @@ public function buildCheckoutData(SalesChannelContext $context, ?Cart $cart = nu
4141
{
4242
$data = $this->getBaseData($context, $order);
4343

44+
$userIdToken = null;
45+
if ($this->methodData->isVaultable($context)) {
46+
$userIdToken = $this->customerVaultTokenRoute->getVaultToken($context)->getToken();
47+
}
48+
4449
return (new VenmoCheckoutData())->assign(\array_merge($data, [
45-
'userIdToken' => $this->customerVaultTokenRoute->getVaultToken($context)->getToken(),
50+
'userIdToken' => $userIdToken,
4651
]));
4752
}
4853

src/Util/Lifecycle/Method/ACDCMethodData.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ public function getCheckoutTemplateExtensionId(): string
9898

9999
public function isVaultable(SalesChannelContext $context): bool
100100
{
101+
if (!$context->getCustomer() || $context->getCustomer()->getGuest()) {
102+
return false;
103+
}
104+
101105
$systemConfigService = $this->container->get(SystemConfigService::class);
102106

103107
return $systemConfigService->getBool(Settings::VAULTING_ENABLED_ACDC, $context->getSalesChannelId());

src/Util/Lifecycle/Method/PayPalMethodData.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ public function getCheckoutTemplateExtensionId(): string
9898

9999
public function isVaultable(SalesChannelContext $context): bool
100100
{
101+
if (!$context->getCustomer() || $context->getCustomer()->getGuest()) {
102+
return false;
103+
}
104+
101105
$systemConfigService = $this->container->get(SystemConfigService::class);
102106

103107
return $systemConfigService->getBool(Settings::VAULTING_ENABLED_WALLET, $context->getSalesChannelId());

src/Util/Lifecycle/Method/VenmoMethodData.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ public function validateCapability(MerchantIntegrations $merchantIntegrations):
112112

113113
public function isVaultable(SalesChannelContext $context): bool
114114
{
115+
if (!$context->getCustomer() || $context->getCustomer()->getGuest()) {
116+
return false;
117+
}
118+
115119
$systemConfigService = $this->container->get(SystemConfigService::class);
116120

117121
return $systemConfigService->getBool(Settings::VAULTING_ENABLED_VENMO, $context->getSalesChannelId());

0 commit comments

Comments
 (0)