Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/Action/CaptureAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Answear\Payum\PayU\Action;

use Answear\Payum\Model\Payment;
use Answear\Payum\PayU\Core\Reply\IframeHttpRedirect;
use Answear\Payum\PayU\Enum\PayMethodType;
use Answear\Payum\PayU\Enum\RecurringEnum;
use Answear\Payum\PayU\Exception\PayUException;
Expand Down Expand Up @@ -76,7 +77,10 @@ public function execute($request): void
$this->updatePayment($model, $orderCreatedResponse, $firstModel, $token);
$request->setModel($model);

throw new HttpRedirect($orderCreatedResponse->redirectUri);
throw match($orderCreatedResponse->iframeAllowed) {
true => new IframeHttpRedirect($orderCreatedResponse->redirectUri),
default => new HttpRedirect($orderCreatedResponse->redirectUri),
};
}

throw PayUException::withResponse(
Expand Down
11 changes: 11 additions & 0 deletions src/Core/Reply/IframeHttpRedirect.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

declare(strict_types=1);

namespace Answear\Payum\PayU\Core\Reply;

use Payum\Core\Reply\HttpRedirect;

class IframeHttpRedirect extends HttpRedirect
{
}
5 changes: 4 additions & 1 deletion src/ValueObject/Response/OrderCreatedResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public function __construct(
public string $orderId,
public ?string $extOrderId = null,
public ?array $payMethods = null,
public ?bool $iframeAllowed = false,
) {
}

Expand All @@ -24,7 +25,8 @@ public static function fromResponse(array $response): self
$response['redirectUri'] ?? null,
$response['orderId'],
$response['extOrderId'] ?? null,
$response['payMethods'] ?? null
$response['payMethods'] ?? null,
$response['iframeAllowed'] ?? null
);
}

Expand All @@ -36,6 +38,7 @@ public function toArray(): array
'orderId' => $this->orderId,
'extOrderId' => $this->extOrderId,
'payMethods' => $this->payMethods,
'iframeAllowed' => $this->iframeAllowed,
];
}
}
2 changes: 2 additions & 0 deletions tests/Integration/Action/CaptureActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ public function captureWithFailResponseTest(): void
'orderId' => '',
'extOrderId' => 'vjis3d90tsozmuj0rjgs3i',
'payMethods' => null,
'iframeAllowed' => false,
],
$exception->response
);
Expand Down Expand Up @@ -188,6 +189,7 @@ public function captureWithFailResponseTest(): void
'orderId' => '',
'extOrderId' => 'vjis3d90tsozmuj0rjgs3i',
'payMethods' => null,
'iframeAllowed' => false,
],
]
),
Expand Down
Loading