We will work on Apr 26th (Saturday) and will be off from Apr 30th (Wednesday) until May 2nd (Friday) for public holiday in our country

Commit 03db9708 authored by Rik ter Beek's avatar Rik ter Beek Committed by GitHub

Merge pull request #503 from Adyen/PW-1634

PW-1634 Retrieve shopper email during guest checkout wth virtual product
parents eceac425 e5b7358b
......@@ -67,12 +67,15 @@ class Requests extends AbstractHelper
}
/**
* @param $request
* @param array $request
* @param int $customerId
* @param $billingAddress
* @return mixed
* @param $storeId
* @param null $payment
* @param null $payload
* @return array
*/
public function buildCustomerData($request = [], $customerId = 0, $billingAddress, $storeId, $payment = null)
public function buildCustomerData($request = [], $customerId = 0, $billingAddress, $storeId, $payment = null, $payload = null)
{
if ($customerId > 0) {
$request['shopperReference'] = $customerId;
......@@ -83,6 +86,17 @@ class Requests extends AbstractHelper
$paymentMethod = $payment->getAdditionalInformation(AdyenHppDataAssignObserver::BRAND_CODE);
}
// In case of virtual product and guest checkout there is a workaround to get the guest's email address
if (!empty($payload['additional_data']['guestEmail'])) {
if ($this->adyenHelper->isPaymentMethodOpenInvoiceMethod($paymentMethod) &&
!$this->adyenHelper->isPaymentMethodAfterpayTouchMethod($paymentMethod)
) {
$request['paymentMethod']['personalDetails']['shopperEmail'] = $payload['additional_data']['guestEmail'];
} else {
$request['shopperEmail'] = $payload['additional_data']['guestEmail'];
}
}
if (!empty($billingAddress)) {
// Openinvoice (klarna and afterpay BUT not afterpay touch) methods requires different request format
if ($this->adyenHelper->isPaymentMethodOpenInvoiceMethod($paymentMethod) &&
......
......@@ -131,7 +131,7 @@ class AdyenPaymentProcess implements AdyenPaymentProcessInterface
// Customer data builder
$customerId = $quote->getCustomerId();
$billingAddress = $quote->getBillingAddress();
$request = $this->adyenRequestHelper->buildCustomerData($request, $customerId, $billingAddress, $storeId);
$request = $this->adyenRequestHelper->buildCustomerData($request, $customerId, $billingAddress, $storeId, null, $payload);
// Customer Ip data builder
$shopperIp = $quote->getXForwardedFor();
......
......@@ -280,6 +280,7 @@ define(
var data = {
'method': this.item.method,
additional_data: {
'guestEmail': quote.guestEmail,
'cc_type': this.creditCardType(),
'number': this.creditCardNumber(),
'cvc': this.securityCode(),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment