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

PWA return url cannot be a path #2850

Open
RobKega opened this issue Jan 15, 2025 · 2 comments
Open

PWA return url cannot be a path #2850

RobKega opened this issue Jan 15, 2025 · 2 comments
Assignees
Labels
Enhancement Indicates a new feature request

Comments

@RobKega
Copy link

RobKega commented Jan 15, 2025

Making your own contribution is easy, encouraged and greatly appreciated! We will put effort into reviewing and merging your PR quickly. For more info, please refer to the contribution guidelines: https://github.com/Adyen/adyen-magento2/blob/develop/CONTRIBUTING.md

Is your feature request related to a problem? Please describe.
Yes, with version changes there are defaults in the plugin that change which require code changes in our application.

Describe the solution you'd like
Because the default PWA return path is subject to change with different versions of the plugin it would be nice to be able to set the PWA return url as a path instead of a full URL

a simple solution would be to change the getStoreReurnUrl method in the ReturnUrlHelper class to :

/**
 * @param null|int|string $storeId
 * @return string
 */
public function getStoreReturnUrl($storeId)
{
    if ($paymentReturnUrl = $this->config->getPWAReturnUrl($storeId)) {
        if (str_starts_with($paymentReturnUrl, 'http')) {
            return rtrim($this->url->getBaseUrl(), '/') . '/'. rtrim((string) $paymentReturnUrl, '/');
        }
        return rtrim((string) $paymentReturnUrl, '/');
    }
    
    if ('adminhtml' === $this->state->getAreaCode()) {
        return rtrim($this->backendHelper->getHomePageUrl(), '/') . '/adyen/return';
    }
    
    return rtrim($this->url->getBaseUrl(), '/') . '/adyen/return';
}

So that it allows the PWA return URL to be a path

@RobKega RobKega added the Enhancement Indicates a new feature request label Jan 15, 2025
@khushboo-singhvi khushboo-singhvi self-assigned this Jan 15, 2025
@khushboo-singhvi
Copy link
Contributor

Hello @RobKega,

Thank you so much for the contribution. It is very much appreciated. I understand your concern about making the PWA return URL configuration more flexible.
However, after considering the various use cases, I believe the current approach is necessary to support different platforms effectively. Specifically, we need the ability to handle different types of return URLs for various scenarios: Web/iOS/Android

You can find more details here.

By maintaining the ability to configure a full URL, we ensure compatibility across all platforms, including web, iOS, and Android. If we switch to only using a path, we would lose the flexibility required for non-web cases (such as mobile apps) and could potentially create integration issues.

If you're looking for a way to make this process more dynamic, we are open for more ideas on how the return URL should be handled based on the platform.

I hope this explanation clarifies the reasoning behind the current approach.

Regards!
Khushboo

@RobKega
Copy link
Author

RobKega commented Jan 15, 2025

@khushboo-singhvi If you looked closer, the proposed solution will accept both fully qualified urls as well as routes/paths.

I did notice an error in the proposed code, it should be

/**

  • @param null|int|string $storeId

  • @return string
    */
    public function getStoreReturnUrl($storeId)
    {
    if ($paymentReturnUrl = $this->config->getPWAReturnUrl($storeId)) {

     // return url is a path so prepend magento base url 
     if (!str_starts_with($paymentReturnUrl, 'http')) {
         return rtrim($this->url->getBaseUrl(), '/') . '/'. rtrim((string) $paymentReturnUrl, '/');
     }
     // fully qualified url 
     return rtrim((string) $paymentReturnUrl, '/');
    

    }

    if ('adminhtml' === $this->state->getAreaCode()) {
    return rtrim($this->backendHelper->getHomePageUrl(), '/') . '/adyen/return';
    }

    return rtrim($this->url->getBaseUrl(), '/') . '/adyen/return';
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Indicates a new feature request
Projects
None yet
Development

No branches or pull requests

2 participants