-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feat/3135] Refacto CapturePayPalOrderCommandHandler
- Loading branch information
1 parent
be7373e
commit 30ffdc8
Showing
6 changed files
with
221 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PrestaShop\Module\PrestashopCheckout\Builder\Payload; | ||
|
||
use PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO\Write\CaptureOrderPayloadDTO; | ||
use PrestaShop\Module\PrestashopCheckout\PayPal\Order\Entity\PayPalOrder; | ||
use PrestaShop\Module\PrestashopCheckout\Repository\PayPalOrderRepository; | ||
|
||
class CapturePayloadBuilder | ||
{ | ||
private $payPalOrderRepository; | ||
|
||
public function __construct(PayPalOrderRepository $payPalOrderRepository) | ||
{ | ||
$this->payPalOrderRepository = $payPalOrderRepository; | ||
} | ||
|
||
public function buildPayload($mode, $orderId, $merchantId) | ||
{ | ||
$order = $this->payPalOrderRepository->getPayPalOrderById($orderId); | ||
|
||
return CaptureOrderPayloadDTO::create( | ||
$mode, | ||
$orderId, | ||
['merchantId' => $merchantId], | ||
$order->checkCustomerIntent(PayPalOrder::CUSTOMER_INTENT_USES_VAULTING) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; | ||
|
||
class CaptureOrderDTO | ||
{ | ||
private $toto; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; | ||
|
||
class PayPalOrderDTO | ||
{ | ||
|
||
/** | ||
* @var int | ||
*/ | ||
private $id; | ||
/** | ||
* @var int | ||
*/ | ||
private $idCart; | ||
/** | ||
* @var string | ||
*/ | ||
private $intent; | ||
/** | ||
* @var string | ||
*/ | ||
private $fundingSource; | ||
/** | ||
* @var string | ||
*/ | ||
private $status; | ||
/** | ||
* @var array | ||
*/ | ||
private $paymentSource; | ||
/** | ||
* @var string | ||
*/ | ||
private $environment; | ||
/** | ||
* @var bool | ||
*/ | ||
private $isCardFields; | ||
/** | ||
* @var bool | ||
*/ | ||
private $isExpressCheckout; | ||
/** | ||
* @var array | ||
*/ | ||
private $customerIntent; | ||
/** | ||
* @var int|null | ||
*/ | ||
private $paymentTokenId; | ||
|
||
public static function createFromMasslandResponse(array $data): PayPalOrderDTO | ||
{ | ||
return new PayPalOrderDTO(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO\Write; | ||
|
||
class CaptureOrderPayloadDTO | ||
{ | ||
private $mode; | ||
private $orderId; | ||
private $payee; | ||
private $vault = false; | ||
|
||
private function __construct($mode, $orderId, $payee, $vault) | ||
{ | ||
$this->mode = $mode; | ||
$this->orderId = $orderId; | ||
$this->payee = $payee; | ||
$this->vault = $vault; | ||
} | ||
|
||
public static function create($mode, $orderId, $merchantId, $vault) | ||
{ | ||
return new self($mode, $orderId, $merchantId, $vault); | ||
} | ||
|
||
public function toArray(): array | ||
{ | ||
return [ | ||
'mode' => $this->mode, | ||
'orderId' => $this->orderId, | ||
'payee' => $this->payee, | ||
'vault' => $this->vault, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PrestaShop\Module\PrestashopCheckout\PayPal\Processor; | ||
|
||
class CaptureOrderProcessor | ||
{ | ||
private $eventDispatcher; | ||
private $logger; | ||
|
||
public function process(array $order) | ||
{ | ||
|
||
} | ||
} |