Skip to content

Commit

Permalink
Merge pull request #204 from OXID-eSales/PSAPC_TakeOver6.3
Browse files Browse the repository at this point in the history
Psapc take over6.3
  • Loading branch information
mariolorenz authored Jan 17, 2025
2 parents 1e48d69 + a3f6268 commit 6bef488
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [3.1.6] - 2025-??-??

- Added `is_string` check for [PhpHelper::jsonToArray()](./src/Core/Helper/PhpHelper.php)
- Fixed wrong namespace on Controller/Admin/OrderArticle
- Changed [Amazonclient::getCharge()](./src/Core/AmazonClient.php) to match the upstream library call
- [0007654](https://bugs.oxid-esales.com/view.php?id=7654): Fix Capture type is incorrectly evaluated
- [0007636](https://bugs.oxid-esales.com/view.php?id=7636): Fix Refund value can only be entered with a point, semicolon is not possible
- [0007685](https://bugs.oxid-esales.com/view.php?id=7685): Smarty-Template Improvements
Expand Down
4 changes: 1 addition & 3 deletions src/Controller/Admin/OrderArticle.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
use OxidEsales\Eshop\Core\Exception\DatabaseErrorException;
use OxidEsales\EshopCommunity\Core\Request;
use OxidSolutionCatalysts\AmazonPay\Core\Config;
use OxidSolutionCatalysts\AmazonPay\Core\Constants;
use OxidSolutionCatalysts\AmazonPay\Core\Logger;
Expand Down Expand Up @@ -40,10 +39,9 @@ private function refundAmazon()
if (!$config->automatedRefundActivated()) {
return;
}
$request = new Request();
// get article id
/** @var string $sOrderArtId */
$sOrderArtId = $request->getRequestParameter('sArtID') ?: '';
$sOrderArtId = Registry::getRequest()->getRequestParameter('sArtID') ?: '';
$sOrderId = $this->getEditObjectId() ?: '';

$oOrderArticle = oxNew(\OxidEsales\Eshop\Application\Model\OrderArticle::class);
Expand Down
2 changes: 1 addition & 1 deletion src/Core/AmazonClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function getChargePermission($chargePermissionId, $headers = []): array
*/
public function getCharge($chargeId, $headers = []): array
{
return $this->decodeResponse(parent::getChargePermission($chargeId, $headers));
return $this->decodeResponse(parent::getCharge($chargeId, $headers));
}

/**
Expand Down
15 changes: 13 additions & 2 deletions src/Core/AmazonService.php
Original file line number Diff line number Diff line change
Expand Up @@ -571,13 +571,24 @@ public function processCharge(string $chargeId, LoggerInterface $logger)
if ($order->load($orderId)) {
switch ($response['statusDetails']['state']) {
case "Declined":
$order->updateAmazonPayOrderStatus('AMZ_AUTH_OR_CAPT_DECLINED', $result);
$order->updateAmazonPayOrderStatus('AMZ_AUTH_OR_CAPT_DECLINED', [
'result' => $result
]);
break;
case "Pending":
$order->updateAmazonPayOrderStatus('AMZ_PAYMENT_PENDING', $result);
break;
case 'Authorized':
$order->updateAmazonPayOrderStatus('AMZ_2STEP_AUTH_OK', [
'chargeAmount' => $response['chargeAmount']['amount'],
'chargeId' => $response['chargeId']
]);
break;
case "Captured":
$order->updateAmazonPayOrderStatus('AMZ_AUTH_AND_CAPT_OK', $result);
$order->updateAmazonPayOrderStatus('AMZ_AUTH_AND_CAPT_OK', [
'chargeAmount' => $response['chargeAmount']['amount'],
'chargeId' => $response['chargeId']
]);
break;
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/Core/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,12 @@ public function resolveLogContent(array $result): array
$context = [];

if (!empty($result['response'])) {
$response = PhpHelper::jsonToArray($result['response']);
// ensure it is a string
if (is_string($result['response'])){
$response = PhpHelper::jsonToArray($result['response']);
} else {
$response = $result['response'];
}

if (!empty($response['statusDetails']['state'])) {
$context['message'] = $response['statusDetails']['state'];
Expand Down
12 changes: 10 additions & 2 deletions src/Model/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,11 @@ public function updateAmazonPayOrderStatus(string $amazonPayStatus, array $data
case "AMZ_AUTH_AND_CAPT_FAILED":
$remark = 'AmazonPay: ERROR';
if (!empty($data['result']['response'])) {
$response = PhpHelper::jsonToArray($data['result']['response']);
if (is_string($data['result']['response'])) {
$response = PhpHelper::jsonToArray($data['result']['response']);
} else {
$response = $data['result']['response'];
}
$remark .= ' (' . $response['reasonCode'] . ')';
}

Expand Down Expand Up @@ -191,7 +195,11 @@ public function updateAmazonPayOrderStatus(string $amazonPayStatus, array $data
case "AMZ_AUTH_OR_CAPT_DECLINED":
$remark = 'AmazonPay: Auth or Capture Declined';
if (!empty($data['result']['response'])) {
$response = PhpHelper::jsonToArray($data['result']['response']);
if (is_string($data['result']['response'])){
$response = PhpHelper::jsonToArray($data['result']['response']);
} else {
$response = $data['result']['response'];
}
$remark .= ' (' . $response['reasonCode'] . ')';
}
$this->setFieldData('oxtransstatus', 'NOT_FINISHED');
Expand Down

0 comments on commit 6bef488

Please sign in to comment.