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

Forter adyen support #11

Merged
merged 25 commits into from
Aug 12, 2020
Merged

Forter adyen support #11

merged 25 commits into from
Aug 12, 2020

Conversation

zachGirit
Copy link
Collaborator

No description provided.

if ($item->getData('entity_body') == 'approve') {
$this->approve->handleApproveImmediatly($order);
} elseif ($item->getData('entity_body') == 'decline') {
if ($order->canUnhold()) {
$order->unhold()->save();
}
$this->decline->handlePostTransactionDescision($order);
} elseif ($method == 'adyen_cc' && $order->getPayment()->getAdyenPspReference()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

why you don't check by entity type "pre_sync_order"? would be more correct
also worth changing the other "ifs" to consider entity_type so the code will be more clear?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the entity_type was added, regarding the pre_Sync_order it's not that simple because we want the Adyen integration will run after the second running but I change it to support more generic Cron integration for the extension.


$response = $this->abstractApi->sendApiRequest($url, json_encode($data));
$order->setForterResponse($response);
$response = json_decode($response);
Copy link
Contributor

@alexandrefarber2 alexandrefarber2 Aug 11, 2020

Choose a reason for hiding this comment

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

need to handle failure case

if ($response->status != 'success' || !isset($response->action)) {
    $order->setForterStatus('error');
    $order->save();
    return false;
}

$order->setForterStatus($response->action);
$order->save();
return true;

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added

}

$item->setSyncFlag('1');
$item->save();
}
}

private function handleAdyenMethod($order)
{
Copy link
Contributor

Choose a reason for hiding this comment

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

let's put this whole function inside try/catch
(in another day we can discuss if we want to keep using try catch or stop it - one merchant commented they don't like)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added try/catch with reportToForterOnCatch method on exception

@@ -128,7 +128,11 @@ public function __construct(
*/
public function buildTransaction($order, $orderStage)
{
$headers = getallheaders();
if (getallheaders()) {
$connectionInformation = $this->basicInfoPrepare->getConnectionInformation($order->getRemoteIp(), $headers);
Copy link
Contributor

Choose a reason for hiding this comment

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

you removed $headers = getallheaders(); so this will break - you need to declare $headers first

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

you are right, my mistake.

@@ -91,6 +112,20 @@ public function execute(\Magento\Framework\Event\Observer $observer)
try {
$order = $observer->getEvent()->getPayment()->getOrder();

if ($this->config->getIsCron() && $order->getPayment()->getMethod() == 'adyen_cc') {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we don't need to check adyen_cc, maybe it can work for any payment method - what do you think?
Don't need to change this now, but I want to know how do we offer the cron feature to anyone who wants - let's talk

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In theory, yes it should work for everyone on Cron, But it's required testing for authorize.net, Braintree, PayPal. I change it and we can test it later (you can just instruct the clients that it's only validate for Adyen right now).

@alexandrefarber2 alexandrefarber2 merged commit 9980165 into master Aug 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants