Skip to content

Commit

Permalink
Merge pull request #16 from david-fiaty-cko/master
Browse files Browse the repository at this point in the history
Checkout.com Magento 2 Module - v1.0.8
  • Loading branch information
nicolas-maalouf-cko authored Oct 16, 2017
2 parents 23548e6 + 5b1b4c6 commit 5a6b335
Show file tree
Hide file tree
Showing 11 changed files with 262 additions and 31 deletions.
107 changes: 107 additions & 0 deletions Block/Order/Info.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<?php
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace CheckoutCom\Magento2\Block\Order;

use Magento\Sales\Model\Order\Address;
use Magento\Framework\View\Element\Template\Context as TemplateContext;
use Magento\Framework\Registry;
use Magento\Payment\Helper\Data as PaymentHelper;
use Magento\Sales\Model\Order\Address\Renderer as AddressRenderer;

/**
* Invoice view comments form
*
* @author Magento Core Team <[email protected]>
*/
class Info extends \Magento\Framework\View\Element\Template
{
/**
* @var string
*/
protected $_template = 'order/info.phtml';

/**
* Core registry
*
* @var \Magento\Framework\Registry
*/
protected $coreRegistry = null;

/**
* @var \Magento\Payment\Helper\Data
*/
protected $paymentHelper;

/**
* @var AddressRenderer
*/
protected $addressRenderer;

/**
* @param TemplateContext $context
* @param Registry $registry
* @param PaymentHelper $paymentHelper
* @param AddressRenderer $addressRenderer
* @param array $data
*/
public function __construct(
TemplateContext $context,
Registry $registry,
PaymentHelper $paymentHelper,
AddressRenderer $addressRenderer,
array $data = []
) {
$this->addressRenderer = $addressRenderer;
$this->paymentHelper = $paymentHelper;
$this->coreRegistry = $registry;
$this->_isScopePrivate = true;
parent::__construct($context, $data);
}

/**
* @return void
*/
protected function _prepareLayout()
{
$this->pageConfig->getTitle()->set(__('Order # %1', $this->getOrder()->getRealOrderId()));
$infoBlock = $this->paymentHelper->getInfoBlock($this->getOrder()->getPayment(), $this->getLayout());
$this->setChild('payment_info', $infoBlock);
}

/**
* @return string
*/
public function getPaymentInfoHtml()
{
$order = $this->coreRegistry->registry('current_order');
$payment = $order->getPayment();
$method = $payment->getMethodInstance();

return $method->getTitle();

}

/**
* Retrieve current order model instance
*
* @return \Magento\Sales\Model\Order
*/
public function getOrder()
{
return $this->coreRegistry->registry('current_order');
}

/**
* Returns string with formatted address
*
* @param Address $address
* @return null|string
*/
public function getFormattedAddress(Address $address)
{
return $this->addressRenderer->format($address, 'html');
}
}
28 changes: 14 additions & 14 deletions Gateway/Config/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ class Config extends BaseConfig {
const KEY_CUSTOM_CSS = 'custom_css';
const KEY_CSS_FILE = 'css_file';

const KEY_VAULT_TITLE = 'checkout_com_cc_vault/title';

/**
* @var array
*/
Expand All @@ -88,6 +90,17 @@ public function getEnvironment() {
return (string) $this->getValue(self::KEY_ENVIRONMENT);
}

/**
* Returns the vault option title.
*
* @return string
*/
public function getVaultTitle() {
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$scopeConfig = $objectManager->create('Magento\Framework\App\Config\ScopeConfigInterface');
return (string) $scopeConfig->getValue('payment/checkout_com_cc_vault/title');
}

/**
* Returns the payment mode.
*
Expand Down Expand Up @@ -127,7 +140,7 @@ public function getDesignSettings() {
'button_label' => $this->getValue(self::KEY_BUTTON_LABEL)
)
);
}
}

/**
* Determines if the environment is set as sandbox mode.
Expand Down Expand Up @@ -171,14 +184,8 @@ public function isHostedIntegration() {
* @return bool
*/
public function isActive() {

// Get an object manager instance
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();

// Load the quote
$quote = $objectManager->create('Magento\Checkout\Model\Session')->getQuote();

// Return the status
return (bool) in_array($quote->getQuoteCurrencyCode(), $this->getAcceptedCurrencies());
}

Expand Down Expand Up @@ -369,13 +376,8 @@ public function getCssFile() {
* @return string
*/
public function getCustomCss() {

// Get an object manager instance
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();

// Load the quote
$scopeConfig = $objectManager->create('Magento\Framework\App\Config\ScopeConfigInterface');

return $scopeConfig->getValue('payment/checkout_com/checkout_com_base_settings/custom_css');
}

Expand All @@ -395,7 +397,6 @@ public function isAutoCapture() {
*/
public function getAutoCaptureTimeInHours() {
$autoCaptureTime = (int) $this->getValue(self::KEY_AUTO_CAPTURE_TIME);

return (int) max(min($autoCaptureTime, self::MAX_AUTO_CAPTURE_TIME), self::MIN_AUTO_CAPTURE_TIME);
}

Expand All @@ -417,7 +418,6 @@ public function getCountrySpecificCardTypeConfig() {
*/
public function getCountryAvailableCardTypes($country) {
$types = $this->getCountrySpecificCardTypeConfig();

return (!empty($types[$country])) ? $types[$country] : [];
}

Expand Down
1 change: 1 addition & 0 deletions Model/Ui/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public function getConfig() {
'embedded_css' => $this->config->getEmbeddedCss(),
'css_file' => $this->config->getCssFile(),
'custom_css' => $this->config->getCustomCss(),
'vault_title' => $this->config->getVaultTitle(),
],
],
];
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.7",
"version": "1.0.8",
"autoload": {
"files": [
"registration.php"
Expand Down
33 changes: 23 additions & 10 deletions view/adminhtml/templates/embedded.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,33 @@ if (!$block->hasCustomCss()) {
overflow-y: scroll !important;
}

body {
overflow: visible !important;
}

#embeddedForm {
height: 110px;
z-index: 0 !important;
}

#embeddedForm, #embeddedForm iframe {
position: relative !important;
height: 110px;
position: relative !important;
}

#cko-form-holder {
max-width: 50%;
#embeddedForm iframe {
min-height: 153px;
}

@media all and (min-width: 520px) {
#cko-form-holder {
max-width: 60%;
}
}

@media all and and (min-width: 301px) and (max-width: 519px) {
#cko-form-holder {
max-width: 80%;
}
}

@media all and (max-width: 300px) {
#cko-form-holder {
max-width: 100%;
}
}
</style>
36 changes: 36 additions & 0 deletions view/frontend/layout/sales_order_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<update handle="customer_account"/>
<update handle="sales_order_item_renderers"/>
<update handle="sales_order_item_price"/>
<update handle="sales_order_info_links"/>
<body>
<referenceContainer name="page.main.title">
<block class="Magento\Sales\Block\Order\Info" name="order.status" template="order/order_status.phtml"/>
<block class="Magento\Sales\Block\Order\Info" name="order.date" template="order/order_date.phtml"/>
<container name="order.actions.container" htmlTag="div" htmlClass="actions-toolbar order-actions-toolbar">
<block class="Magento\Sales\Block\Order\Info\Buttons" as="buttons" name="sales.order.info.buttons" cacheable="false"/>
</container>
</referenceContainer>
<referenceContainer name="sales.order.info.buttons">
<block class="Magento\Sales\Block\Order\Info\Buttons\Rss" as="buttons.rss" name="sales.order.info.buttons.rss" cacheable="false"/>
</referenceContainer>
<referenceContainer name="content">
<block class="Magento\Sales\Block\Order\View" name="order.comments" template="order/order_comments.phtml" before="sales.order.info.links"/>
<block class="Magento\Sales\Block\Order\View" name="sales.order.view" cacheable="false" after="sales.order.info.links">
<block class="Magento\Sales\Block\Order\Items" name="order_items" template="order/items.phtml">
<block class="Magento\Framework\View\Element\RendererList" name="sales.order.items.renderers" as="renderer.list"/>
<block class="Magento\Sales\Block\Order\Totals" name="order_totals" template="order/totals.phtml">
<arguments>
<argument name="label_properties" xsi:type="string">colspan="4" class="mark"</argument>
<argument name="value_properties" xsi:type="string">class="amount"</argument>
</arguments>
<block class="Magento\Tax\Block\Sales\Order\Tax" name="tax" template="order/tax.phtml"/>
</block>
</block>
</block>
<block class="CheckoutCom\Magento2\Block\Order\Info" as="info" name="sales.order.info" after="sales.order.view"/>
</referenceContainer>
<block class="Magento\Framework\View\Element\Template" name="additional.product.info" template="Magento_Theme::template.phtml"/>
</body>
</page>
20 changes: 17 additions & 3 deletions view/frontend/templates/embedded.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,21 @@ if (!$block->hasCustomCss()) {
min-height: 153px;
}

#cko-form-holder {
max-width: 50%;
}
@media all and (min-width: 520px) {
#cko-form-holder {
max-width: 60%;
}
}

@media all and and (min-width: 301px) and (max-width: 519px) {
#cko-form-holder {
max-width: 80%;
}
}

@media all and (max-width: 300px) {
#cko-form-holder {
max-width: 100%;
}
}
</style>
56 changes: 56 additions & 0 deletions view/frontend/templates/order/info.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile

?>
<?php /** @var $block \Magento\Sales\Block\Order\Info */ ?>
<?php $_order = $block->getOrder() ?>
<div class="block block-order-details-view">
<div class="block-title">
<strong><?php /* @escapeNotVerified */ echo __('Order Information') ?></strong>
</div>
<div class="block-content">
<?php if (!$_order->getIsVirtual()): ?>
<div class="box box-order-shipping-address">
<strong class="box-title"><span><?php /* @escapeNotVerified */ echo __('Shipping Address') ?></span></strong>
<div class="box-content">
<address><?php /* @escapeNotVerified */ echo $block->getFormattedAddress($_order->getShippingAddress()); ?></address>
</div>
</div>

<div class="box box-order-shipping-method">
<strong class="box-title">
<span><?php /* @escapeNotVerified */ echo __('Shipping Method') ?></span>
</strong>
<div class="box-content">
<?php if ($_order->getShippingDescription()): ?>
<?php echo $block->escapeHtml($_order->getShippingDescription()) ?>
<?php else: ?>
<?php /* @escapeNotVerified */ echo __('No shipping information available'); ?>
<?php endif; ?>
</div>
</div>
<?php endif; ?>

<div class="box box-order-billing-address">
<strong class="box-title">
<span><?php /* @escapeNotVerified */ echo __('Billing Address') ?></span>
</strong>
<div class="box-content">
<address><?php /* @escapeNotVerified */ echo $block->getFormattedAddress($_order->getBillingAddress()); ?></address>
</div>
</div>
<div class="box box-order-billing-method">
<strong class="box-title">
<span><?php /* @escapeNotVerified */ echo __('Payment Method') ?></span>
</strong>
<div class="box-content">
<?php echo $block->getPaymentInfoHtml() ?>
</div>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ define(
* @returns {string}
*/
getQuoteValue: function() {
//return CheckoutCom.getPaymentConfig()['quote_value'];
return quote.getTotals();
},

Expand Down
Loading

0 comments on commit 5a6b335

Please sign in to comment.