Skip to content

Commit

Permalink
Merge pull request #1074 from BearGroup/release/5.7.1
Browse files Browse the repository at this point in the history
Release/5.7.1
  • Loading branch information
tlundgr authored Sep 1, 2021
2 parents d978eb8 + 5673ce2 commit 2cc203f
Show file tree
Hide file tree
Showing 8 changed files with 156 additions and 70 deletions.
9 changes: 6 additions & 3 deletions Api/CheckoutSessionManagementInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
interface CheckoutSessionManagementInterface
{
/**
* @param mixed|null $cartId
* @return mixed
*/
public function getConfig();
public function getConfig($cartId = null);

/**
* @param mixed $amazonSessionId
Expand All @@ -45,13 +46,15 @@ public function getPaymentDescriptor($amazonSessionId);

/**
* @param mixed $amazonSessionId
* @param mixed|null $cartId
* @return string
*/
public function updateCheckoutSession($amazonSessionId);
public function updateCheckoutSession($amazonSessionId, $cartId = null);

/**
* @param mixed $amazonSessionId
* @param mixed|null $cartId
* @return int
*/
public function completeCheckoutSession($amazonSessionId);
public function completeCheckoutSession($amazonSessionId, $cartId = null);
}
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## 5.7.1
* Fixed issue when phone number not required and entered in Magento
* Updated API calls to take in a masked cart ID so they can be used without relying on Magento sessions
* Updated logging to sanitize some data

## 5.7.0
* Changed the response of completeCheckoutSession API call to include both increment ID and order ID
* Fixed issue with logging in when a customer has an empty password hash (thanks @rafczow!)
Expand All @@ -8,7 +13,6 @@
* Fixed issue where using Amazon Pay in the Payment Methods section did not work on one step checkouts
* Fixed issue where using Amazon Pay in the Payment Methods section could bypass agreeing to Terms and Conditions
* Removed usage of isPlaceOrderActionAllowed in js components
* Updated API calls to take in a masked cart ID so they can be used without relying on Magento sessions
* Updated response validators to look for specific response code and states

## 5.6.0
Expand Down
2 changes: 1 addition & 1 deletion CustomerData/CheckoutSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ public function __construct(
*/
public function getConfig()
{
return $this->checkoutSessionManagement->getConfig($this->session->getQuote());
return $this->checkoutSessionManagement->getConfig();
}
}
42 changes: 34 additions & 8 deletions Model/Adapter/AmazonPayAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -459,18 +459,36 @@ protected function processResponse($clientResponse, $functionName)
// Log
$isError = !in_array($response['status'], [200, 201]);
if ($isError || $this->amazonConfig->isLoggingEnabled()) {
$debugBackTrace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 2);
$this->logger->debug($functionName . ' <- ', $debugBackTrace[1]['args']);
if ($isError) {
$this->logger->error($functionName . ' -> ', $response);
} else {
$this->logger->debug($functionName . ' -> ', $response);
}
$this->logSanitized($functionName, $response, $isError);
}

return $response;
}

protected function logSanitized($functionName, $response, $isError)
{
$debugBackTrace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 3);
$buyerKeys = ['buyerId' => '', 'primeMembershipTypes' => '', 'status' => ''];

if ($functionName == 'getBuyer') {
$response = array_intersect_key($response, $buyerKeys);
$debugBackTrace[2]['args'] = [];
}

if (isset($response['buyer'])) {
$response['buyer'] = array_intersect_key($response['buyer'], $buyerKeys);
}

unset($response['shippingAddress'], $response['billingAddress']);

$this->logger->debug($functionName . ' <- ', $debugBackTrace[2]['args']);
if ($isError) {
$this->logger->error($functionName . ' -> ', $response);
} else {
$this->logger->debug($functionName . ' -> ', $response);
}
}

/**
* Generate idempotency header
*
Expand Down Expand Up @@ -568,7 +586,15 @@ public function generatePayNowButtonPayload(Quote $quote, $paymentIntent = Payme
$addressData[$addressKey] = $streetLine;
}

$addressData = array_filter($addressData);
// Remove empty fields, or ones that contain only "-"
$addressData = array_filter($addressData, function ($val) {
return !empty($val) && $val != "-";
});

// Make sure phone number is set for PayNow button
if (!array_key_exists('phoneNumber', $addressData)) {
$addressData['phoneNumber'] = "0";
}

$payload['addressDetails'] = $addressData;
}
Expand Down
Loading

0 comments on commit 2cc203f

Please sign in to comment.