Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: added possibility to have a proxied webhook url #38

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

jhony1104
Copy link

The reason for this pr is a structure where shopware is not accessible from the internet. Only required endpoints are to be routed to shopware (/store-api/, WebHooks, ...) using a proxy.

This PR is to make this possible for SwagPayPal.

Comment on lines +11 to +12
paypal:
webhook_proxy_url: null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you do one more layer? so

paypal:
    webhook:
        proxy_url: null

Background: we will in a future iteration, add more config parameters to the yaml files, therefore we would like to have some sort of namespacing

Comment on lines +109 to +120
if ($this->proxyWebhookUrl !== null) {
$webhookUrl = $this->proxyWebhookUrl . '?' . http_build_query(
[self::PAYPAL_WEBHOOK_TOKEN_NAME => $webhookExecuteToken]
);
} else {
$this->router->getContext()->setScheme('https');
$webhookUrl = $this->router->generate(
'api.action.paypal.webhook.execute',
[self::PAYPAL_WEBHOOK_TOKEN_NAME => $webhookExecuteToken],
UrlGeneratorInterface::ABSOLUTE_URL
);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please outsource this into an extra private method? So we don't have the duplicate code?

UrlGeneratorInterface::ABSOLUTE_URL
);
if ($this->proxyWebhookUrl !== null) {
$webhookUrl = $this->proxyWebhookUrl . '?' . http_build_query(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the proxy already contains GET parameters? Maybe do a str_contains('?') ? '&' : '?' (overly simplified)

@mstegmeyer mstegmeyer self-assigned this Jul 25, 2024
@mstegmeyer
Copy link
Contributor

@jhony1104 any updates here? are you going to implement the suggested changes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants