-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PAYSHIP-3135] Refacto CapturePayPalOrderCommandHandler #1299
base: prestashop/8.x
Are you sure you want to change the base?
[PAYSHIP-3135] Refacto CapturePayPalOrderCommandHandler #1299
Conversation
@@ -0,0 +1,31 @@ | |||
<?php | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to add the license header (stuff like * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
...) 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There a composer script set-license-header
;)
|
|
||
class CapturePayloadBuilder | ||
{ | ||
private $payPalOrderRepository; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private $payPalOrderRepository; | |
private PayPalOrderRepository $payPalOrderRepository; |
$this->payPalOrderRepository = $payPalOrderRepository; | ||
} | ||
|
||
public function buildPayload($mode, $orderId, $merchantId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add phpdoc and type hinting, please ?
|
||
class CaptureOrderPayloadDTO | ||
{ | ||
private $mode; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add types ?
private $payee; | ||
private $vault = false; | ||
|
||
private function __construct($mode, $orderId, $payee, $vault) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add type hinting ?
$this->vault = $vault; | ||
} | ||
|
||
public static function create($mode, $orderId, $merchantId, $vault) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add phpdoc and type hinting ?
return $paymentToken; | ||
} | ||
|
||
private function processTheCapture($orderPayPal) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private function processTheCapture($orderPayPal) | |
private function processCapture($orderPayPal) |
} | ||
} | ||
|
||
return $this->processTheCapture($orderPayPal); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return $this->processTheCapture($orderPayPal); | |
return $this->processCapture($orderPayPal); |
|
||
class CaptureOrderDTO | ||
{ | ||
private $toto; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😄 ?
/** | ||
* @var string | ||
*/ | ||
private $environment; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it the paypal mode ? SANDBOX or LIVE ? If it's the case, it's better call it $mode
Missing before OK:
|
|
||
if ($orderPayPal['status'] === PayPalOrderStatus::COMPLETED) { | ||
$this->logger->info(''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty log
|
||
if (isset($orderPayPal['payment_source'][$capturePayPalOrderCommand->getFundingSource()]['attributes']['vault'])) { | ||
$vault = $orderPayPal['payment_source'][$capturePayPalOrderCommand->getFundingSource()]['attributes']['vault']; | ||
$vault = $this->savePrestaShopPayPalCustomerRelationship($vault); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me this part of overwriting $vault variable feels a bit off. Why not wrap it in try-catch?
} catch (\Exception $exception) { | ||
$this->logger->error(sprintf('An error occurs during process : %s', $exception->getMessage())); | ||
return []; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you decide to keep catch clauses here, then you don't need a return at each one. Just one at the end of the function
No description provided.