We will be off from 27/1 (Monday) to 31/1 (Friday) (GMT +7) for our Tet Holiday (Lunar New Year) 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 ...@@ -67,12 +67,15 @@ class Requests extends AbstractHelper
} }
/** /**
* @param $request * @param array $request
* @param int $customerId * @param int $customerId
* @param $billingAddress * @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) { if ($customerId > 0) {
$request['shopperReference'] = $customerId; $request['shopperReference'] = $customerId;
...@@ -83,6 +86,17 @@ class Requests extends AbstractHelper ...@@ -83,6 +86,17 @@ class Requests extends AbstractHelper
$paymentMethod = $payment->getAdditionalInformation(AdyenHppDataAssignObserver::BRAND_CODE); $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)) { if (!empty($billingAddress)) {
// Openinvoice (klarna and afterpay BUT not afterpay touch) methods requires different request format // Openinvoice (klarna and afterpay BUT not afterpay touch) methods requires different request format
if ($this->adyenHelper->isPaymentMethodOpenInvoiceMethod($paymentMethod) && if ($this->adyenHelper->isPaymentMethodOpenInvoiceMethod($paymentMethod) &&
......
...@@ -131,7 +131,7 @@ class AdyenPaymentProcess implements AdyenPaymentProcessInterface ...@@ -131,7 +131,7 @@ class AdyenPaymentProcess implements AdyenPaymentProcessInterface
// Customer data builder // Customer data builder
$customerId = $quote->getCustomerId(); $customerId = $quote->getCustomerId();
$billingAddress = $quote->getBillingAddress(); $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 // Customer Ip data builder
$shopperIp = $quote->getXForwardedFor(); $shopperIp = $quote->getXForwardedFor();
......
...@@ -280,6 +280,7 @@ define( ...@@ -280,6 +280,7 @@ define(
var data = { var data = {
'method': this.item.method, 'method': this.item.method,
additional_data: { additional_data: {
'guestEmail': quote.guestEmail,
'cc_type': this.creditCardType(), 'cc_type': this.creditCardType(),
'number': this.creditCardNumber(), 'number': this.creditCardNumber(),
'cvc': this.securityCode(), '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