1.软文推荐

2.软文推荐

3.软文推荐

外贸电子商务中,选择合适的支付方式很重要,而Magento作为一套专业热门的开源的电子商务系统,是可以直接设置创建支付方式的,安全即可靠。本文,主要为大家介绍如何在Magento 2中创建支付方式的教程步骤。

1、在app/code/Alwayly/CustomPayment/registration.php中创建registration.php文件,加入代码:

?php
MagentoFrameworkComponentComponentRegistrar::register(
MagentoFrameworkComponentComponentRegistrar::MODULE,
‘Alwayly_CustomPayment’,
__DIR__
);

2、在app/code/Alwayly/CustomPayment/etc/module.xml中创建module.xml文件,加入代码:

?xml version=”1.0″?
config xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:noNamespaceSchemaLocation=”urn:magento:framework:Module/etc/module.xsd”
module name=”Alwayly_CustomPayment” setup_version=”1.0.0″
/module
/config

3、在app/code/Alwayly/CustomPayment/etc/config.xml中创建config.xml文件,加入代码:

?xml version=”1.0″?
config xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:noNamespaceSchemaLocation=”../../Store/etc/config.xsd”
default
payment
custompayment
payment_action authorize /payment_action !– You can use another method –
model AlwaylyCustomPaymentModelPaymentMethod /model
active 1 /active
title Custom Payment /title
order_status pending_payment /order_status !– set default order status–
/custompayment
/payment
/default
/config

4、在app/code/Alwayly/CustomPayment/etc/adminhtml/system.xml中创建system.xml文件,加入代码:

?xml version=”1.0″?
config xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:noNamespaceSchemaLocation=”urn:magento:module:Magento_Config:etc/system_file.xsd”
system
section id=”payment”
group id=”custompayment” translate=”label” sortOrder=”100″ showInDefault=”1″ showInWebsite=”1″ showInStore=”1″
label Custom Payment Method /label
field id=”active” translate=”label comment” sortOrder=”10″ type=”select” showInDefault=”1″ showInWebsite=”1″ showInStore=”0″
label Enable /label
source_model MagentoConfigModelConfigSourceYesno /source_model
/field
field id=”title” translate=”label” type=”text” sortOrder=”20″ showInDefault=”1″ showInWebsite=”1″ showInStore=”1″
label Custom Payment /label
/field
/group
/section
/system
/config

5、在app/code/Alwayly/CustomPayment/Model/PaymentMethod.php中创建PaymentMethod.php文件,加入代码:

?php

namespace AlwaylyCustomPaymentModel;

/**
* Pay In Store payment method model
*/
class PaymentMethod extends MagentoPaymentModelMethodAbstractMethod
{
/**
* Payment code
*
* @var string
*/
protected $_code = ‘custompayment’;
}

6、在app/code/Alwayly/CustomPayment/view/frontend/layout/checkout_index_index.xml中创建checkout_index_index.xml文件,加入代码:

?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”
body
referenceBlock name=”checkout.root”
arguments
argument name=”jsLayout” xsi:type=”array”
item name=”components” xsi:type=”array”
item name=”checkout” xsi:type=”array”
item name=”children” xsi:type=”array”
item name=”steps” xsi:type=”array”
item name=”children” xsi:type=”array”
item name=”billing-step” xsi:type=”array”
item name=”component” xsi:type=”string” uiComponent /item
item name=”children” xsi:type=”array”
item name=”payment” xsi:type=”array”
item name=”children” xsi:type=”array”
item name=”renders” xsi:type=”array”
!– merge payment method renders here –
item name=”children” xsi:type=”array”
item name=”custompayment” xsi:type=”array”
item name=”component” xsi:type=”string” Emipro_Custompayment/js/view/payment/method-renderer /item
item name=”methods” xsi:type=”array”
item name=”custompayment” xsi:type=”array”
item name=”isBillingAddressRequired” xsi:type=”boolean” true /item
/item
/item
/item
/item
/item
/item
/item
/item
/item
/item
/item
/item
/item
/item
/argument
/arguments
/referenceBlock
/body
/page

7、在app/code/Alwayly/CustomPayment/view/frontend/web/js/view/payment/method-renderer.js上创建method-renderer.js文件,加入代码:

define(
[
‘uiComponent’,
‘Magento_Checkout/js/model/payment/renderer-list’
],
function (
Component,
rendererList
) {
‘use strict’;
rendererList.push(
{
type: ‘custompayment’,
component: ‘Alwayly_CustomPayment/js/view/payment/method-renderer/custompayment’
}
);
return Component.extend({});
}
);

8、在app/code/Alwayly/CustomPayment/view/frontend/web/js/view/payment/method-renderer/custompayment.js上创建custompayment.js文件,加入代码:

define(
[
‘Magento_Checkout/js/view/payment/default’
],
function (Component) {
‘use strict’;

return Component.extend({
defaults: {
template: ‘Alwayly_CustomPayment/payment/customtemplate’
}
});
}
);

9、在app/code/Alwayly/CustomPayment/view/frontend/web/template/payment/customtemplate.html上创建customtemplate.html文件,加入代码:

div > div > input type=”radio”
name=”payment[method]”
> data-bind=”attr: {‘id’: getCode()}, value: getCode(), checked: isChecked, click: selectPaymentMethod, visible: isRadioButtonVisible()”/
label data-bind=”attr: {‘for’: getCode()}” > /div
div > !– ko foreach: getRegion(‘messages’) –
!– ko template: getTemplate() – !– /ko –
!–/ko–
div > !– ko foreach: $parent.getRegion(getBillingAddressFormName()) –
!– ko template: getTemplate() – !– /ko –
!–/ko–
/div
div > !– ko foreach: $parent.getRegion(‘before-place-order’) –
!– ko template: getTemplate() – !– /ko –
!–/ko–
/div
div > div > button > type=”submit”
data-bind=”
click: placeOrder,
attr: {title: $t(‘Place Order’)},
css: {disabled: !isPlaceOrderActionAllowed()},
enable: (getCode() == isChecked())

disabled
span data-bind=”i18n: ‘Place Order'” /span
/button
/div
/div
/div
/div

到此,就完成了在Magento 2商店中创建自定义付款方式的步骤。接下来就可以启用付款方式,步骤如下:

1、如图所示,选择“YES”

2、启用付款方式后,可以在检出产品时将其显示在前端:

来源:idcspy.com/23947.html

本站声明:内容来源于网络,内容不代表本站立场,仅供阅读参考,文章版权归原作者“本公司cmy.cn”所有。如有侵权,请联系我们删除。

免责声明:本站发布的内容(图片、视频和文字)以原创、来自本网站内容采集于网络互联网转载等其它媒体和分享为主,内容观点不代表本网站立场,如侵犯了原作者的版权,请告知一经查实,将立刻删除涉嫌侵权内容,联系我们56dr_com,同时欢迎投稿传递力量。

相关文章 8

1

网站突然打不开(有些网站突然打不开了怎么办) 35秒前

目录:1、网站突然打不开怎么回事?2、网页打不开是怎么回事?3、最近很多网站打不开,怎么解决?4、网站为什么突然打不开了?网站突...

2

快速建站咋样,和普通建站相比有什么优劣?(建站太难了) 2分钟前

??制作网站是为获取更广阔的业务市场,现阶段企业不建站只做线下业务渠道,错失建站发展线上业务,利用线下 线上带动企业向前发展的...

3

百度联盟优化排名(百度网站优化排名) 3分钟前

目录:1、求问,我在百度上竞价排名了,能在百度上排名第一 但是在百度联盟上面搜索排名非常靠后,这是为嘛啊2、请问百度联盟和百度...

4

哪里有便宜的云服务器(哪里可以买云) 6分钟前

哪里有便宜的云服务器?如今市面上的云服务商有很多,其中比较知名且性价比高的云服务器,推荐本公司,云服务器安全可靠,稳定易用...

5

租用多IP美国站群服务器 明白这几点受益匪浅(搭建美国ip) 8分钟前

从多IP美国站群服务器居高不下的租用需求可以看出,现在站群网站建设是有多么火爆,让小编不经意的联想到2017年某美国主机商站群服务...

6

香港、美国和韩国服务器哪个更好?(香港与韩国的关系) 9分钟前

二、美国服务器 和香港服务器相反,美国服务器大部分都是有硬防的,比较适合对安全性要求高的用户。而且由于美国服务器带宽足够大,...

7

十堰vps(十堰仲裁委员会是什么机构) 10分钟前

目录:1、需要一个江苏南通 、镇江 或 扬州 的VPS,听说这的不错,谁能提供几个IDC?需要一个江苏南通 、镇江 或 扬州 的VPS,听说这的不...

8

服务器机柜哪个牌子好,如何来选择?(服务器机柜是干嘛的) 12分钟前

机柜的种类在现在市场中有很多种,在具体了解服务器机柜哪个牌子好的时候,还可以从市场口碑和评价上来了解。其实,掌握对了选择方...