Adyen / adyen-magento2

Adyen Payment plugin for Magento2
MIT License
155 stars 211 forks source link

[PW-6655] GraphQL Improvements: Return URL and cart reactivation on pressing back #1481

Closed paales closed 2 years ago

paales commented 2 years ago

Talked with @acampos1916 last week about possible improvements to the GraphQL setup. We're developing a PWA solution for Magento 2 called GraphCommerce.

We currently have a customer that is scheduled to be released in the coming months and wil use Adyen's GraphQL implementation. The goal is that the module runs in a headless mode so a visitor will never touch a Magento URL directly, all communication should happen via GraphQL.

I've taken a look at the GraphQL schema and it seems to be 90% the way there, so that is great! We've got a few feature requests:

1. As a developer I’d like to give a return URL when placing an order, so that we can easily work with the adyen module without having to configure frontend URL’s.

input PlaceOrderInput {
  adyen_return_url: String
    @doc(
      description: "Optionally send a URL where the visitor is returned after completing the Adyen order, the URL should be in the format of `http://mydomain.com/my/path?payload={{payload}}`"
    )
}

The reason for this is that there isn't a one-to-one mapping between the frontend environments and the backend environments. This is beautiful during development as this allows frontend and backend developers release things in their own pace.

When a customer returns to the store with the payload we can call the adyenPaymentDetails mutation.

2. As a developer I'd like to be able to reactivate the cart when the customer presses back in their browser.

When a customer presses back, we'd like to be able to cancel the payment and reactivate the cart.

Maybe this is already possible with the adyenPaymentDetails mutation, but it isn't clear from the schema.

larsroettig commented 2 years ago

@acampos1916 I think this is a good idea, maybe we need security approval, but apiclient is also already checking the domain in terms of security

Morerice commented 2 years ago

Hi @paales,

Apologies for the late reply. Thanks for opening this issue and providing a suggestion for the first request. We have created an internal ticket with this info that we will refine and will get back to you.

For the second request, we already have some functionality for non-headless merchants in place. We will check if we can abstract this functionality and also open it for headless merchants.

Best regards, Jean Adyen

paales commented 2 years ago

@Morerice

I noticed that the stateData object in essence is the payload send to the payments request object API

Maybe it should be allowed to provide this URL in the stateData?

Manually defined here: https://github.com/Adyen/adyen-magento2/blob/develop/Gateway/Request/ReturnUrlDataBuilder.php Stripped here: https://github.com/Adyen/adyen-php-api-library/blob/6727f47f1df98df64fb7c4be687cda70ba919905/src/Adyen/Service/Validator/CheckoutStateDataValidator.php#L7