Skip to content

Commit

Permalink
Merge pull request #11 from david-fiaty-cko/master
Browse files Browse the repository at this point in the history
Checkout.com Magento 2 Module - v1.0.7
  • Loading branch information
nicolas-maalouf-cko authored Oct 3, 2017
2 parents 70518b6 + 4b5c545 commit 23548e6
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 13 deletions.
8 changes: 6 additions & 2 deletions Helper/Watchdog.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ public function bark($data) {
// Add the error code
if (isset($data['status'])) {
$this->messageManager->addNoticeMessage(__('Status') . ' : ' . $data['status']);
}
}
}

// Add the message
if (isset($data['message'])) {
$this->messageManager->addNoticeMessage(__('Message') . ' : ' . $data['message']);
} }
}
}
17 changes: 12 additions & 5 deletions Model/Service/PaymentTokenService.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use CheckoutCom\Magento2\Gateway\Exception\ApiClientException;
use CheckoutCom\Magento2\Model\GatewayResponseHolder;
use CheckoutCom\Magento2\Model\Adapter\ChargeAmountAdapter;
use CheckoutCom\Magento2\Helper\Watchdog;

class PaymentTokenService {

Expand All @@ -45,18 +46,25 @@ class PaymentTokenService {
*/
protected $storeManager;

/**
* @var Watchdog
*/
protected $watchdog;

/**
* PaymentTokenService constructor.
* @param GatewayConfig $gatewayConfig
* @param TransferFactory $transferFactory
* @param Session $checkoutSession
* @param StoreManagerInterface $storeManager
* @param Watchdog $watchdog
*/
public function __construct(GatewayConfig $gatewayConfig, TransferFactory $transferFactory, Session $checkoutSession, StoreManagerInterface $storeManager) {
public function __construct(GatewayConfig $gatewayConfig, TransferFactory $transferFactory, Session $checkoutSession, StoreManagerInterface $storeManager, Watchdog $watchdog) {
$this->gatewayConfig = $gatewayConfig;
$this->transferFactory = $transferFactory;
$this->checkoutSession = $checkoutSession;
$this->storeManager = $storeManager;
$this->watchdog = $watchdog;
}

/**
Expand Down Expand Up @@ -89,11 +97,10 @@ public function getToken() {

$result = (array) json_decode($response->getBody(), true);

if( array_key_exists('errorCode', $result) ) {
throw new ApiClientException($result['message'], $result['errorCode'], $result['eventId']);
}
// Debug info
$this->watchdog->bark($result);

return $result['id'];
return isset($result['id']) ? $result['id'] : null;

}
catch (Zend_Http_Client_Exception $e) {
Expand Down
2 changes: 1 addition & 1 deletion Plugin/PaymentInformationManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function aroundSavePaymentInformationAndPlaceOrder(
try {
$orderId = $this->cartManagement->placeOrder($cartId);
} catch (LocalizedException $exception) {
throw new CouldNotSaveException(__($exception->getMessage()));
throw new CouldNotSaveException(__($exception->getMessage()));
} catch (\Exception $exception) {
$this->logger->critical($exception);
throw new CouldNotSaveException(
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"magento/module-vault": "100.2.*"
},
"type": "magento2-module",
"version": "1.0.6",
"version": "1.0.7",
"autoload": {
"files": [
"registration.php"
Expand Down
4 changes: 0 additions & 4 deletions view/frontend/templates/embedded.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ if (!$block->hasCustomCss()) {
overflow-y: scroll !important;
}

body {
overflow: visible !important;
}

#embeddedForm {
z-index: 0 !important;
}
Expand Down
1 change: 1 addition & 0 deletions view/frontend/web/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ require([

$(document).ready(function() {


});
});
2 changes: 2 additions & 0 deletions view/frontend/web/js/view/payment/method-renderer/embedded.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ define(
placeOrder: function() {
var self = this;

$.migrateMute = true;

this.isPlaceOrderActionAllowed(false);
this.getPlaceOrderDeferredObject()
.fail(
Expand Down

0 comments on commit 23548e6

Please sign in to comment.