Skip to content

Commit

Permalink
Merge pull request #15 from OnTap/master
Browse files Browse the repository at this point in the history
Simplify Commerce version 3.1.0
  • Loading branch information
oconnort authored May 28, 2020
2 parents fcb4e12 + 0fa9054 commit ae99932
Show file tree
Hide file tree
Showing 58 changed files with 194 additions and 88 deletions.
2 changes: 1 addition & 1 deletion Block/Customer/CardRenderer.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2013-2019 Mastercard
* Copyright (c) 2013-2020 Mastercard
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion Block/Info.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2013-2019 Mastercard
* Copyright (c) 2013-2020 Mastercard
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
56 changes: 54 additions & 2 deletions Controller/Simplify/PlaceOrder.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2013-2019 Mastercard
* Copyright (c) 2013-2020 Mastercard
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -28,9 +28,13 @@
use Magento\Framework\App\RequestInterface;
use Magento\Framework\Controller\Result\Redirect;
use Magento\Framework\Controller\ResultFactory;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Stdlib\Cookie\CookieMetadataFactory;
use Magento\Framework\Stdlib\CookieManagerInterface;
use Magento\Payment\Gateway\ConfigInterface;
use Magento\Quote\Api\CartManagementInterface;
use Magento\Quote\Api\Data\CartInterface;
use Magento\Store\Model\StoreManagerInterface;
use Psr\Log\LoggerInterface;
use Zend_Json_Encoder;

Expand Down Expand Up @@ -66,28 +70,53 @@ class PlaceOrder extends Action
*/
protected $customerSession;

/**
* @var CookieManagerInterface
*/
protected $cookieManager;

/**
* @var CookieMetadataFactory
*/
protected $cookieMetadataFactory;

/**
* @var StoreManagerInterface
*/
protected $storeManager;

/**
* Redirect constructor.
* @param Context $context
* @param ConfigInterface $config
* @param CheckoutSession $checkoutSession
* @param LoggerInterface $logger
* @param CartManagementInterface $cartManagement
* @param CustomerSession $customerSession
* @param CookieManagerInterface $cookieManager
* @param CookieMetadataFactory $cookieMetadataFactory
* @param StoreManagerInterface $storeManager
*/
public function __construct(
Context $context,
ConfigInterface $config,
CheckoutSession $checkoutSession,
LoggerInterface $logger,
CartManagementInterface $cartManagement,
CustomerSession $customerSession
CustomerSession $customerSession,
CookieManagerInterface $cookieManager,
CookieMetadataFactory $cookieMetadataFactory,
StoreManagerInterface $storeManager
) {
parent::__construct($context);
$this->config = $config;
$this->checkoutSession = $checkoutSession;
$this->logger = $logger;
$this->cartManagement = $cartManagement;
$this->customerSession = $customerSession;
$this->cookieManager = $cookieManager;
$this->cookieMetadataFactory = $cookieMetadataFactory;
$this->storeManager = $storeManager;
}

/**
Expand Down Expand Up @@ -120,6 +149,27 @@ protected function validateQuote($quote)
}
}

/**
* @throws NoSuchEntityException
* @throws \Magento\Framework\Exception\InputException
* @throws \Magento\Framework\Stdlib\Cookie\CookieSizeLimitReachedException
* @throws \Magento\Framework\Stdlib\Cookie\FailureToSendException
*/
protected function setInvalidationCookie()
{
try {
$store = $this->storeManager->getStore();
$cookieMeta = $this->cookieMetadataFactory->createPublicCookieMetadata()
->setHttpOnly(false)
->setDuration(86400) //24h
->setPath($store->getStorePath());

$this->cookieManager->setPublicCookie('simplify_section_data_clean', '1', $cookieMeta);
} catch (\Exception $e) {
$this->logger->error('Simplify Commerce could not set Invalidation Cookie:' . $e->getMessage());
}
}

/**
* @inheritDoc
*/
Expand All @@ -143,6 +193,8 @@ public function execute()

$this->cartManagement->placeOrder($quote->getId());

$this->setInvalidationCookie();

/** @var Redirect $resultRedirect */
return $resultRedirect->setPath('checkout/onepage/success', ['_secure' => true]);
} catch (Exception $e) {
Expand Down
2 changes: 1 addition & 1 deletion Gateway/Command/AuthorizeStrategyCommand.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2013-2019 Mastercard
* Copyright (c) 2013-2020 Mastercard
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion Gateway/Command/CaptureStrategyCommand.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2013-2019 Mastercard
* Copyright (c) 2013-2020 Mastercard
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
3 changes: 2 additions & 1 deletion Gateway/Http/Client/AbstractTransaction.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2013-2019 Mastercard
* Copyright (c) 2013-2020 Mastercard
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -67,6 +67,7 @@ public function placeRequest(TransferInterface $transferObject)
try {
$response['object'] = $this->process($data);
} catch (\Simplify_ApiException $e) {
$log['detail'] = $e->describe();
$log['field_errors'] = [];
$log['exception'] = $e->getMessage();
if ($e instanceof \Simplify_BadRequestException && $e->hasFieldErrors()) {
Expand Down
2 changes: 1 addition & 1 deletion Gateway/Http/Client/CustomerCreate.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2013-2019 Mastercard
* Copyright (c) 2013-2020 Mastercard
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion Gateway/Http/Client/PaymentAuthorize.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2013-2019 Mastercard
* Copyright (c) 2013-2020 Mastercard
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion Gateway/Http/Client/PaymentCapture.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2013-2019 Mastercard
* Copyright (c) 2013-2020 Mastercard
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion Gateway/Http/Client/PaymentRefund.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2013-2019 Mastercard
* Copyright (c) 2013-2020 Mastercard
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion Gateway/Http/Client/PaymentVoid.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2013-2019 Mastercard
* Copyright (c) 2013-2020 Mastercard
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion Gateway/Http/TransferFactory.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2013-2019 Mastercard
* Copyright (c) 2013-2020 Mastercard
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion Gateway/Request/AuthorizationIdBuilder.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2013-2019 Mastercard
* Copyright (c) 2013-2020 Mastercard
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion Gateway/Request/CardTokenBuilder.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2013-2019 Mastercard
* Copyright (c) 2013-2020 Mastercard
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion Gateway/Request/CustomerBuilder.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2013-2019 Mastercard
* Copyright (c) 2013-2020 Mastercard
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion Gateway/Request/CustomerIdBuilder.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2013-2019 Mastercard
* Copyright (c) 2013-2020 Mastercard
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion Gateway/Request/PaymentBuilder.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2013-2019 Mastercard
* Copyright (c) 2013-2020 Mastercard
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion Gateway/Request/PaymentIdBuilder.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2013-2019 Mastercard
* Copyright (c) 2013-2020 Mastercard
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion Gateway/Request/VaultTokenBuilder.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2013-2019 Mastercard
* Copyright (c) 2013-2020 Mastercard
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion Gateway/Response/AuthorizationHandler.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2013-2019 Mastercard
* Copyright (c) 2013-2020 Mastercard
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion Gateway/Response/CaptureHandler.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2013-2019 Mastercard
* Copyright (c) 2013-2020 Mastercard
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion Gateway/Response/CustomerHandler.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2013-2019 Mastercard
* Copyright (c) 2013-2020 Mastercard
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion Gateway/Response/PaymentHandler.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2013-2019 Mastercard
* Copyright (c) 2013-2020 Mastercard
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion Gateway/Response/TokenHandler.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2013-2019 Mastercard
* Copyright (c) 2013-2020 Mastercard
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion Gateway/Validator/CustomerValidator.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2013-2019 Mastercard
* Copyright (c) 2013-2020 Mastercard
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion Gateway/Validator/PaymentValidator.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2013-2019 Mastercard
* Copyright (c) 2013-2020 Mastercard
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion Gateway/Validator/ValidateTrue.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2013-2019 Mastercard
* Copyright (c) 2013-2020 Mastercard
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion Model/Adminhtml/Source/PaymentAction.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2013-2019 Mastercard
* Copyright (c) 2013-2020 Mastercard
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion Model/Config/Source/FormType.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2013-2019 Mastercard
* Copyright (c) 2013-2020 Mastercard
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion Model/Config/Source/Order/Status/Pendingpayment.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2013-2019 Mastercard
* Copyright (c) 2013-2020 Mastercard
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion Model/InstantPurchase/AvailabilityChecker.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2013-2019 Mastercard
* Copyright (c) 2013-2020 Mastercard
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2013-2019 Mastercard
* Copyright (c) 2013-2020 Mastercard
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion Model/InstantPurchase/TokenFormatter.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2013-2019 Mastercard
* Copyright (c) 2013-2020 Mastercard
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion Observer/DataAssignObserver.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2013-2019 Mastercard
* Copyright (c) 2013-2020 Mastercard
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion Ui/ConfigProvider.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2013-2019 Mastercard
* Copyright (c) 2013-2020 Mastercard
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Loading

0 comments on commit ae99932

Please sign in to comment.