Skip to content

Commit

Permalink
Adyen proxy minor fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
ebanolopes committed Oct 28, 2021
1 parent 24a5848 commit a15f96c
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions Plugin/Adyen/Payment/Gateway/Request/CheckoutDataBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,16 @@ public function afterBuild(AdyenCheckoutDataBuilder $subject, $request)
$request['body']['additionalData']['bin'] = $magentoRequest['paymentMethod']['additional_data']['cardBin'];
}

if ($quote->getCustomerIsGuest()) {
$customerEmail = $quote->getBillingAddress()->getEmail();
} else {
$customerEmail = $quote->getCustomerEmail();
}

$request['body']['additionalData']['teamId'] = $teamId;
$request['body']['additionalData']['checkoutAttemptId'] = uniqid();
$request['body']['additionalData']['enhancedSchemeData.dutyAmount'] = $this->processAmount($taxAmount);
$request['body']['additionalData']['riskdata.basket.item0.receiverEmail'] = $quote->getCustomer()->getEmail();
$request['body']['additionalData']['riskdata.basket.item0.receiverEmail'] = $customerEmail;

if ($discountAmount) {
$request['body']['additionalData']['riskdata.promotions.promotion0.promotionDiscountAmount'] =
Expand Down Expand Up @@ -226,9 +232,6 @@ public function afterBuild(AdyenCheckoutDataBuilder $subject, $request)
}
}

$createdAt = $quote->getCustomer()->getCreatedAt();
$createdAt = str_replace(' ', 'T', $createdAt) . "+00:00";

$address = $quote->getShippingAddress()->getCity() !== null ?
$quote->getShippingAddress() : $quote->getBillingAddress();
$shippingData = $this->getAddressData($quote->getShippingAddress());
Expand Down Expand Up @@ -256,7 +259,13 @@ public function afterBuild(AdyenCheckoutDataBuilder $subject, $request)
$request['body']['merchantRiskIndicator']['deliveryTimeframe'] = $deliveryTimeframe;
}

$request['body']['accountInfo']['accountCreationDate'] = $createdAt;
$createdAt = $quote->getCustomer()->getCreatedAt();

if (isset($createdAt)) {
$createdAt = str_replace(' ', 'T', $createdAt) . "+00:00";
$request['body']['accountInfo']['accountCreationDate'] = $createdAt;
}

$request['body']['merchantRiskIndicator']['deliveryAddressIndicator'] = $deliveryAddressIndicator;
$request['body']['deliveryAddress'] = $adyenAddress;

Expand All @@ -265,7 +274,7 @@ public function afterBuild(AdyenCheckoutDataBuilder $subject, $request)

public function getAddressData(\Magento\Quote\Model\Quote\Address $address)
{
$data = implode($address->getStreet(), '');
$data = implode('', $address->getStreet());
$data .= $address->getPostcode();
$data .= $address->getCity();
$data .= $address->getRegion();
Expand Down

0 comments on commit a15f96c

Please sign in to comment.