cancel
Showing results for 
Search instead for 
Did you mean: 

What do you see bad in that file?

What do you see bad in that file?

Hello,

 

I am implementing a custom payment gateway.

To be able to config it, I have created a ConfigProvider this way:

 

<?php/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Desytec\Transbank\Model;

use Magento\Checkout\Model\ConfigProviderInterface;
use Magento\Framework\Escaper;
use Magento\Payment\Helper\Data as PaymentHelper;

class WebpayConfigProvider implements ConfigProviderInterface
{
/**
* @var string[]
*/
protected $methodCode = Webpay::CODE;

/**
* @var Webpay
*/
protected $method;

/**
* @var Escaper
*/
protected $escaper;

/**
* @param PaymentHelper $paymentHelper
* @param Escaper $escaper
*/
public function __construct(
PaymentHelper $paymentHelper,
Escaper $escaper) {$this->escaper = $escaper;$this->method = $paymentHelper->getMethodInstance($this->methodCode);
}

/**
* {@inheritdoc}
*/
public function getConfig()
{
return $this->method->isAvailable() ? [
'payment' => [
'webpay' => [
'image' => $this->getImage(),
'instructions' => $this->getInstructions(),
],
],
] : [];
}

/**
* Get mailing address from config
*
* @return string
*/
protected function getImage()
{
return nl2br($this->escaper->escapeHtml($this->method->getImage()));
}

/**
* Get mailing address from config
*
* @return string
*/
protected function getInstructions()
{
return nl2br($this->escaper->escapeHtml($this->method->getInstructions()));
}
}

And this di.xml file in etc/frontend:

 

<?xml version="1.0"?>
<!--
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Checkout\Model\CompositeConfigProvider">
<arguments>
<argument name="configProviders" xsi:type="array">
<item name="transbank_webpay_config_provider" xsi:type="object">Desytec\Transbank\Model\WebpayConfigProvider</item>
</argument>
</arguments>
</type>
</config>


When I upload di.xml file to server, and try to load the checkout, an error 500 occurs. If I delete it, page is shown correctly.

 

What do you see bad in that file?

 

Thanks

1 REPLY 1

Re: What do you see bad in that file?

Make sure that your class Webpay is in the same directory as your WebpayConfigProvider class, or use full namespace path. Beside this I don't see anything wrong with your files.