Skip to content

Commit

Permalink
Support model based for PaymentRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
hossam-adyen committed Jan 23, 2024
1 parent bd556d6 commit 9499f17
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 10 additions & 0 deletions Gateway/Http/Client/TransactionPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,16 @@ public function placeRequest(TransferInterface $transferObject): array
$paymentResponse->setMerchantReference($requestData["reference"]);
$this->paymentResponseResourceModel->save($paymentResponse);
$responseData = (array)$response->jsonSerialize();

/**
* Since casting $response->jsonSerialize() to an array not casting the nested array elements,
* we ended up with $responseData['action'] as stdclass, sp we had to convert it to an array
*/
$action = $response->getAction();
if ($action) {
$responseData['action'] = (array)$action->jsonSerialize();
}

$this->adyenHelper->logResponse($responseData);
} catch (AdyenException $e) {
$this->adyenHelper->logAdyenException($e);
Expand Down
10 changes: 6 additions & 4 deletions Model/Api/PaymentRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
namespace Adyen\Payment\Model\Api;

use Adyen\AdyenException;
use Adyen\Model\Checkout\PaymentDetailsRequest;
use Adyen\Payment\Helper\Config;
use Adyen\Payment\Helper\Data;
use Adyen\Payment\Logger\AdyenLogger;
use Adyen\Payment\Model\RecurringType;
use Adyen\Service\Checkout\PaymentsApi;
use Exception;
use Magento\Framework\App\State;
use Magento\Framework\DataObject;
Expand Down Expand Up @@ -70,7 +72,7 @@ public function __construct(
* @throws LocalizedException
* @throws NoSuchEntityException
*/
public function authorise3d(Payment $payment): mixed
public function authorise3d(Payment $payment): array
{
$order = $payment->getOrder();
$storeId = $order->getStoreId();
Expand Down Expand Up @@ -102,13 +104,13 @@ public function authorise3d(Payment $payment): mixed

try {
$client = $this->adyenHelper->initializeAdyenClient($storeId);
$service = $this->adyenHelper->createAdyenCheckoutService($client);
$result = $service->paymentsDetails($request);
$service = new PaymentsApi($client);
$response = $service->paymentsDetails(new PaymentDetailsRequest($request));
} catch (AdyenException $e) {
throw new LocalizedException(__('3D secure failed'));
}

return $result;
return (array) $response->jsonSerialize();
}

/**
Expand Down

0 comments on commit 9499f17

Please sign in to comment.