0

In etc/adminhtml/system.xml I add an additioal field which is

<field id="gateway_ID" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
     <label>Gateway ID</label>
</field>

But then I can't call this field in my

js/view/payment/method-renderer/gateway_renderer.js 

How can i call this field sa that i can send it to the third party url in.

afterPlaceOrder: function () {}

and also i need to get payment information like subtotal of the current checkout.

  • You had a configProviders for your custom payment? Please, post this part? – Khoa TruongDinh Oct 13 '16 at 4:43
1

In order to do this

We have to inject \Magento\Payment\Gateway\Config\ConfigFactory in ConfigProvider class

const CODE = 'code_gateway';
private $config;
function __construct(
   \Magento\Payment\Gateway\Config\ConfigFactory $configFactory
) {
   $this->config = $configFactory->create(self::CODE);
}

    public function getConfig()
    {
        return [
            'payment' => [
                self::CODE => [
                    .....
                    'gateway_ID' => $this->config->getValue('gateway_ID')
                    .....
                ]
            ]
        ];
    }

Now in gateway_renderer.js

gatewayID: function () {
   return console.log(window.checkoutConfig.payment.code_gateway.gateway_ID);
}

on template.html

<button class="action primary checkout"
     type="submit"
     data-bind="
     click: gatewayID,
     attr: {title: $t('Place Order')}
                        ">
    <span data-bind="i18n: 'Place Order'"></span>
</button>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.