Question

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 Jaime

Was it helpful?

Solution

it does not have to be the di.xml itself containing the error.

a 500 response mostly means, that you should look into your webservers error.log. There should be an exception or error in it containing a propper error message

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top