Adyen / adyen-magento2

Adyen Payment plugin for Magento2
MIT License
150 stars 196 forks source link

[ECP-9196] Allow shopperReference to be linked to GuestCustomer #2607

Open ryan-lambert-IEX opened 1 month ago

ryan-lambert-IEX commented 1 month ago

Is your feature request related to a problem? Please describe. We are trying to pass in a tokenized storedPaymentMethodId to a guest-cart checkout, and right now there doesn't appear to be a way to link the shopperReference with the guest user. In the current plugin, the shopperReference is either the customerID or a UUID, causing our guest-cart payment to fail, as there is no way to get or change the uuid value prior to submission.

// in Helper/Requests.php
    public function getShopperReference($customerId, $orderIncrementId): string
    {
        if ($customerId) {
            $shopperReference = $this->adyenHelper->padShopperReference($customerId);
        } else {
            $uuid = Uuid::generateV4();
            $guestCustomerId = $orderIncrementId . $uuid;
            $shopperReference = $guestCustomerId;
        }

        return $shopperReference;
    }
}

For added context, we have a headless implementation which tokenizes card information by making a 0 dollar charge (per docs ). Our implementation handles raw credit card information (we are PCI certified) and we require our AdobeCommerce partners to submit a SAQ-A-EP and provision us with our own API key as to limit the scope of our tokenization flow.

We are trying to pass our tokenized payment data (we cannot pass raw card data, as this would break the PCI chain, nor can we use the AdyenJS library in our environment) to AdobeCommerce for submission. We use guest-carts since our flow collects payment information outside the usual "primary" store workflow.

Using the guest-cart flow as described above works great for Braintree and Stripe, but this shopperReference uuid seems to break our intended flow in our Adyen implementation.

Describe the solution you'd like I think any of these things could fix this problem:

  1. Use the guest-cart uuid cartId for the shopperReference vs the current orderId.uuid you use now
  2. Allow a shopperReference value to be passed into the paymentMethod.additional_data which overrides the current behavior
  3. Allow us to retrieve the uuid value prior to submission; can be attached to the guest-cart/${cartId}

Describe alternatives you've considered I understand why you use a uuid for guests, as the assumption probably is stored payment methods belong to "stored customers".

An alternative would be for Adyen to provide a way to get a single-use-payment-token like Braintree and Stripe vs. a stored payment method (with a shopperReference), but that change is probably far too great to hope for :]

Additional context Our website

RokPopov commented 1 month ago

Hi @ryan-lambert-IEX,

Thank you for opening this issue. I have opened a ticket internally to investigate the above and decide on what would the best approach be. We'll update the issue accordingly.

Kind regards, Rok

ryan-lambert-IEX commented 1 month ago

Thank you @RokPopov keen to hear your feedback on the preferred approach. We are happy to help contribute / submit a PR for solution.

RokPopov commented 1 month ago

Hi @ryan-lambert-IEX,

Thank you for your reply. We would be happy to review your contribution and iterate over it if necessary.

Kind regards, Rok

ryan-lambert-IEX commented 1 month ago

@RokPopov #2620 offers a simple solution; please review and let us know your thoughts. This would unblock us internally so appreciate it.

RokPopov commented 1 month ago

Hi @ryan-lambert-IEX,

Thank you for your contribution, it is highly appreciated. I left a comment on the PR itself, could you please take a look when you'll get a chance?

Kind regards, Rok

ryan-lambert-IEX commented 4 weeks ago

@RokPopov let me know what you think of the updated PR; happy to make tweaks as needed