Please follow this blog so you can get idea how to pass data payment form. create configprovider.php and di.xml.
I have posted basic code which you can modified as per your requirement. create SampleConfigProvider.php under File
Namespace/Modulename/Model/SampleConfigProvider.php
<?php
namespace Namespace\Modulename\Model;
use Magento\Checkout\Model\ConfigProviderInterface;
/**
* Class SampleConfigProvider
*/
class SampleConfigProvider implements ConfigProviderInterface
{
public function getStoredCards(){
$result = array();
$result['0'] = "Test";
$result['1'] = "Test1";
return $result;
}
public function getConfig()
{
$config = array_merge_recursive($config, [
'payment' => [
\Namespace\Modulename\Model\Payment::CODE => [
'storedCards' => $this->getStoredCards(),
],
],
]);
return $config;
}
}
Then in my frontend/di.xml add a new CompositeConfigProvider
File Namespace/Modulename/etc/frontend/di.xml
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Payment\Model\CcGenericConfigProvider">
<arguments>
<argument name="methodCodes" xsi:type="array">
<item name="test_payment" xsi:type="const">Namespace\Modulename\Model\Payment::CODE</item>
</argument>
</arguments>
</type>
<type name="Magento\Checkout\Model\CompositeConfigProvider">
<arguments>
<argument name="configProviders" xsi:type="array">
<item name="test_payment_config_provider" xsi:type="object">Namespace\Modulename\Model\SampleConfigProvider</item>
</argument>
</arguments>
</type>
</config>
add below method in omni_finance-method.js add method :
getStoreCard: function() {
return window.checkoutConfig.payment.checkmo.storedCards;
},
getCardList: function() {
return _.map(this.getStoreCard(), function(value, key) {
return {
'value': key,
'type': value
}
});
},
add in omni_finance.html file :
Namespace\Modulename\view\frontend\web\template\payment
<select name="payment[subscription_id]" class="select input-text required-entry"
data-bind="
attr: {id: getCode()+'_payment_profile_id'},
options: getCardList(),
optionsValue: 'value',
optionsText: 'type',
optionsCaption: $t('--Please Select--'),
">
</select>
you can add what ever you like it will display under relevant payment method section. Please follow this blog for basic understanding.
Don't forgot add constant CODE in your payment.php
Best Answer
To answer your question, there are 3 parts:
Create Order Attribute
For creating order attribute, you MUST use setup script with the following code:
I used upgrade script as example, but you can use inscript to perform the same function too.
Insert attribute when placing order
This process is a little bit tricky but I think it's still OK for you.
Create new file
app/code/Vendor/Module/etc/extension_attributes.xml
with the following code:Create file
app/code/Vendor/Module/view/frontend/requirejs-config.js
with the following code:Create new file
app/code/Vendor/Module/view/frontend/web/js/order/set-shipping-information-mixin.js
with the following code:Create file
app/code/Vendor/Module/view/frontend/layout/checkout_index_index.xml
Create file
app/code/Vendor/Module/view/frontend/web/template/order_attr.html
with the following code:Create file
app/code/Vendor/Module/view/frontend/web/js/view/order_attr.js
with the following code:Create file
app/code/Vendor/Module/etc/di.xml
with the following code:Create new file
app/code/Vendor/Module/Plugin/AddOrderAttrToQuote.php
with the following code:Create new file
app/code/Cleargo/NewAttributes/etc/events.xml
Create new file
app/code/Vendor/Module/Observer/HandleOrderAttrs.php
with the following code:Read the Order Attribute in payment module
For case 3, seems it's from 3rd party module. Anyway, if you want to get the value of
bank_name
from order, you can use the following code:Conslusion
It's quite a lot of work to do for an order attribute, but once you get the key point, everything will go smooth.