Skip to content
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

BP- 2132 BP-2813 clean refactor push & redirect #770

Conversation

LucianTuriacArnia
Copy link
Contributor

No description provided.

@LucianTuriacArnia LucianTuriacArnia self-assigned this Aug 14, 2023
@LucianTuriacArnia LucianTuriacArnia added the Refactor This will be part of a refactoring process. label Aug 14, 2023
This was linked to issues Aug 14, 2023
Comment on lines 629 to 633
} elseif (in_array($statusKey, $this->buckarooStatusCode->getFailedStatuses())) {
return $this->processFailedPush($newStatus, $statusMessage);
} elseif (in_array($statusKey, $this->buckarooStatusCode->getPendingStatuses())) {
return $this->processPendingPaymentPush();
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think we need the else if here since we do a return in each branch, it will be nicer to read

Service/Push/OrderRequestService.php Outdated Show resolved Hide resolved
if ($this->receivePushCheckDuplicates()) {
throw new BuckarooException(__('Skipped handling this push, duplicate'));
}
// TODO: Implement processPush() method.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I deleted the entire class because was from an old version of push refactor.

$pushType = $pushTransactionType->getPushType();
if ($pushType == PushTransactionType::BUCK_PUSH_TYPE_INVOICE) {
$pushProcessorClass = $this->pushProcessors['credit_managment'];
} elseif ($pushType == PushTransactionType::BUCK_PUSH_TYPE_INVOICE_INCOMPLETE) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in my opinion we should do simple ifs and return, will look cleaner

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I proceed like this because a pushProcessorClass can change the value from $paymentMethod to group_transaction or refund. Also I proceed like this to avoid the next error: "This method has 5 returns, which is more than the 3 allowed."

Comment on lines 217 to 220
if ($this->pushRequest->getStatusCode() !== null) {
$statusCode = $this->pushRequest->getStatusCode();
}
break;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will make it cleaner if we move the ifs into different function

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I change it with a shorter version $statusCode = $this->pushRequest->getStatusCode() ?: $statusCode;

*/
private function skipPendingRefundPush(PushRequestInterface $pushRequest): bool
{
if ($pushRequest->hasAdditionalInformation('initiated_by_magento', 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will be nice to reduce inline ifs as much as possible

{
if (!empty($this->pushRequest->getServiceKlarnakpReservationnumber())) {
$this->order->setBuckarooReservationNumber($this->pushRequest->getServiceKlarnakpReservationnumber());
$this->order->save();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we could do better when committing data to the database, like to do this after all the processing was done, was thinking of a class for each entity that will handle the db committing OrderHandler, OrderHistoryHandler, PaymentHandler , set a flag hasChanged and commit the changes if it changed

@LucianTuriacArnia LucianTuriacArnia merged commit b4d9c97 into feature/payment_provider_gateway Aug 16, 2023
4 of 7 checks passed
@LucianTuriacArnia LucianTuriacArnia deleted the BP-2132-clean-refactor-push-redirect branch January 9, 2024 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Refactor This will be part of a refactoring process.
Projects
Development

Successfully merging this pull request may close these issues.

BP-2132: Refactor Push BP-2133: Refactor Redirect
2 participants