Skip to content

Commit 36de0c5

Browse files
handle iframeAllowed parameter from order request response
1 parent 905961d commit 36de0c5

3 files changed

Lines changed: 18 additions & 2 deletions

File tree

src/Action/CaptureAction.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Answear\Payum\PayU\Action;
66

77
use Answear\Payum\Model\Payment;
8+
use Answear\Payum\PayU\Core\Reply\Continue3DsHttpRedirect;
89
use Answear\Payum\PayU\Enum\PayMethodType;
910
use Answear\Payum\PayU\Enum\RecurringEnum;
1011
use Answear\Payum\PayU\Exception\PayUException;
@@ -76,7 +77,7 @@ public function execute($request): void
7677
$this->updatePayment($model, $orderCreatedResponse, $firstModel, $token);
7778
$request->setModel($model);
7879

79-
throw new HttpRedirect($orderCreatedResponse->redirectUri);
80+
throw new Continue3DsHttpRedirect(!(null === $orderCreatedResponse->iframeAllowed), $orderCreatedResponse->redirectUri);
8081
}
8182

8283
throw PayUException::withResponse(
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
namespace Answear\Payum\PayU\Core\Reply;
3+
4+
use Payum\Core\Reply\HttpRedirect;
5+
6+
class Continue3DsHttpRedirect extends HttpRedirect
7+
{
8+
public function __construct(public readonly bool $iframeAllowed, string $url, int $statusCode = 302, array $headers = array())
9+
{
10+
parent::__construct($url, $statusCode, $headers);
11+
}
12+
}

src/ValueObject/Response/OrderCreatedResponse.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public function __construct(
1414
public string $orderId,
1515
public ?string $extOrderId = null,
1616
public ?array $payMethods = null,
17+
public ?array $iframeAllowed = null,
1718
) {
1819
}
1920

@@ -24,7 +25,8 @@ public static function fromResponse(array $response): self
2425
$response['redirectUri'] ?? null,
2526
$response['orderId'],
2627
$response['extOrderId'] ?? null,
27-
$response['payMethods'] ?? null
28+
$response['payMethods'] ?? null,
29+
$response['iframeAllowed'] ?? null
2830
);
2931
}
3032

@@ -36,6 +38,7 @@ public function toArray(): array
3638
'orderId' => $this->orderId,
3739
'extOrderId' => $this->extOrderId,
3840
'payMethods' => $this->payMethods,
41+
'iframeAllowed' => $this->iframeAllowed,
3942
];
4043
}
4144
}

0 commit comments

Comments
 (0)