草庐IT

关于 php:Magento: 删除”paypal/express/review”步骤的简单方法

codeneng 2023-03-28 原文

Magento: easy way to remove "paypal/express/review" step

在magento中使用paypal订购时,它会带你到paypal,paypal已经显示确认,你确认,你会被重定向到另一个确认页面(/paypal/express/review),这是一个额外的步骤,对于用户体验,我想删除它并在用户在贝宝页面上确认时自动下订单,一旦离开贝宝,如果订单成功,客户应该会看到成功页面。

是否有任何简单的解决方案可以解决我可能忽略的问题,或者至少如果您能指出正确的方向来删除该步骤。

  • 如果您不需要此功能,请不要使用贝宝快递并使用贝宝标准。 paypal express 是一种结帐方式而不是付款方式
  • 谢谢!我没有注意到这一点。现在我知道了。
  • 是的,您可以将其发布为答案,我会选择它。再次感谢。


其实 Express Checkout 可以解决这个问题,我个人建议坚持使用。

在 SetExpressCheckout 请求之后,您将用户重定向到 PayPal。您可以将 useraction=commit 附加到此 URL 以触发来自 PayPal 页面的确认。

这会导致 PayPal 上的"继续"按钮切换到"支付"按钮,并通知用户这是他们的最终确认...点击支付将提交付款。

您仍然需要在您的服务器上调用 DoExpressCheckoutPayment 来完成该过程,但此时 GetExpressCheckoutDetails 是可选的。使用 useraction=commit 时,您将在 ReturnURL 中将 PayerID 作为 URL 参数返回,因此如果您不想/不需要,则不必调用 GECD。

您可以进一步设置并使用回调 API(也称为即时更新 API)将运费和销售税信息提供给 PayPal 审核页面。这允许您根据在 PayPal 评论页面上选择的用户送货地址,使用您自己的送货数据填充 PayPal 评论页面上的下拉值。

这些功能的引入是为了完全按照您的指定...消除额外的审查过程。

综上所述,如果用于 Express Checkout 的 Magento 模块没有为所有这些提供选项,您将需要扩展它并自己构建它们。不过,我很漂亮。

  • 我将继续为执行此操作的 Magento EC 模块构建一个扩展,我将在 MagentoConnect 上免费发布它。希望在几周内完成。只得腾出时间来。
  • 你有没有做过这个或者有一个 github 分支可以从中提取?
  • 我开始了,但我还没有完成。不过,这里似乎还有其他一些很好的答案。
  • 它现在受 1.9 支持,您可以跳过审查并从设置中调整它
  • 1.9 中有一个选项,但它与"快捷按钮"不兼容 - 更多信息在这里。


实际上这里提到的所有解决方案都需要编辑 Magento 核心。这被称为不良做法,不会让您的商店保持更新。

清洁解决方案需要做什么:

  • 创建一个模块(在我的示例中:Avoe_Paypal)以包含更改
  • 重写 Paypal 配置
  • 重定向贝宝快递审查步骤,即 http://yourdomain.com/paypal/express/review/
  • 1) 创建你的模块

    Avoe/Paypal/etc/config.xml

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    <?xml version="1.0" encoding="UTF-8"?>
    <config>
        <modules>
            <Avoe_Paypal>
                <version>0.1.0</version>
            </Avoe_Paypal>
        </modules>

        <global>
            <models>
                <Avoe_Paypal>
                    <class>Avoe_Paypal_Model</class>
                </Avoe_Paypal>
                <paypal>
                    <rewrite>
                        <config>Avoe_Paypal_Model_Config</config>
                    </rewrite>
                </paypal>
            </models>
            <events>
                <controller_action_predispatch_paypal_express_review>
                    <observers>
                       
                            <type>singleton</type>
                            <class>Avoe_Paypal_Model_Observer</class>
                            <method>paypalExpressReturnPredispatch</method>
                        </avoe_paypal_predispatch>
                    </observers>
                </controller_action_predispatch_paypal_express_review>
            </events>
        </global>
    </config>

    app/etc/Avoe_Paypal.xml

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    <?xml version="1.0" encoding="UTF-8"?>
    <config>
        <modules>
            <Avoe_Paypal>
                true</active>
                <codePool>local</codePool>
                <depends>
                    <Mage_Paypal />
                </depends>
            </Avoe_Paypal>
        </modules>
    </config>

    2) 重写配置,添加用户操作\\'commit\\':

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    <?php
    class Avoe_Paypal_Model_Config extends Mage_Paypal_Model_Config {

        /**
         * Get url for dispatching customer to express checkout start
         * Added useraction 'commit' to remove PayPal Express Checkout review page
         *
         * @param string $token
         * @return string
         */

        public function getExpressCheckoutStartUrl($token)
        {
            return $this->getPaypalUrl(array(
                'cmd'   => '_express-checkout',
                'useraction' => 'commit',
                'token' => $token,
            ));
        }
    }

    3) 创建要重定向的观察者:

    1
    2
    3
    4
    5
    6
    7
    8
    <?php

    class Avoe_Paypal_Model_Observer {

        function paypalExpressReturnPredispatch($observer) {
            Mage::app()->getResponse()->setRedirect(Mage::getUrl('*/*/placeOrder'));
        }
    }

    还有一个昨天刚刚发布的小型 Magento 扩展,用于删除审查步骤:

    https://github.com/tim-bezhashvyly/Sandfox_RemovePaypalExpressReviewStep


    所以正确的交易,完美的工作(对我来说)是上面的总结:

    1。转到:\\\\\\\\app\\\\\\\\code\\\\\\\\core\\\\\\\\Mage\\\\\\\\Paypal\\\\\\\\Controller\\\\\\\\Express\\\\\\\\Abstract.php

    并在 returnAction() 中搜索:

    1
    $this->_redirect('*/*/review');

    你必须改变:

    1
    $this->_redirect('*/*/review');

    到:

    1
    $this->_redirect('*/*/placeOrder');

    2。转到:\\\\\\\\app\\\\\\\\code\\\\\\\\core\\\\\\\\Mage\\\\\\\\Paypal\\\\\\\\Model\\\\\\\\Config.php
    并更改:

    1
    2
    3
    4
    5
    6
    7
    public function getExpressCheckoutStartUrl($token)
    {
        return $this->getPaypalUrl(array(
            'cmd'   => '_express-checkout',
            'token' => $token,
        ));
    }

    到:

    1
    2
    3
    4
    5
    6
    7
    8
    public function getExpressCheckoutStartUrl($token)
    {
        return $this->getPaypalUrl(array(
            'cmd'   => '_express-checkout',
            'useraction' => 'commit',
            'token' => $token,
        ));
    }

    通过上面的 2 个更改,我想出了如何
    跳过 Magento Paypal Express Checkout 中的评论页面。

    • 谢谢Keyur Shah。我搜索了几天......我从托尼大卫那里找到了解决方案,所以我做了一个更清晰的总结


    如果您不需要此功能,请不要使用 paypal express 并使用 paypal 标准。 paypal express 是一种结帐方式而不是付款方式

    edit:这现在可以在 1.9 中进行配置,仍然延迟但可行。

    • 嗨,我检查了 Magento CE 1.9 中的 PayPal express 设置,但找不到禁用评论页面的设置。你指的是哪个配置?
    • @AnnaV?lkl payment/paypal_express/skip_order_review_step
    • @AnnaV?lkl 我想如果您启用了协议,它就不起作用,必须接受这些协议......
    • 1.9 中有一个选项,但它与"快捷按钮"不兼容 - 更多信息在这里。
    • 请注意,不再支持 PayPal Standard,而 PayPal Express 是可行的方法。


    Andrew Angel\\'s answer确实没有避开确认页面,它只是将按钮值更改为"支付"而不是"确认",或类似的东西。

    无论如何,正确的方法是
    \\\\\\\\app\\\\\\\\code\\\\\\\\core\\\\\\\\Mage\\\\\\\\Paypal\\\\\\\\Model\\\\\\\\Config.php,到
    getExpressCheckoutEditUrl($token) 方法和更改

    1
    'useraction' => 'continue',

    1
    'useraction' => 'commit’.

    要避免 Paypal Express 中的确认用户页面,您只需在控制器操作中更改一行。
    转到 Mage/Paypal/Controller/Express/Abstract.php 并搜索 $this->_redirect('*/*/review');在 returnAction() 中。那里你必须改变

    1
    $this->_redirect('\\*/\\*/review');

    1
    $this->_redirect('\\*/\\*/placeOrder');

    这样,当贝宝返回返回操作时,您就可以避免显示整个评论页面并自动确认付款。因此,Paypal 再次重定向到成功页面,就像 PayPal 标准方法一样。


    @Toni 重定向网址部分效果很好,谢谢!但是,将"继续"更改为"提交"并没有改变 PayPal 网站上的按钮。但是,我可以通过执行以下操作来修复它: 在 Toni 指示更改继续提交的 getExpressCheckoutEditUrl 函数正上方,有函数 getExpressCheckoutStartUrl。如果您在那里添加 useraction 变量,它将起作用。
    原函数:

    1
    2
    3
    4
    5
    6
    7
    public function getExpressCheckoutStartUrl($token)
    {
    'return $this->getPaypalUrl(array(
    '
    cmd'   => '_express-checkout',
    '
    token' => $token,
    ));
    }

    新功能:

    1
    2
    3
    4
    5
    6
    7
    8
    public function getExpressCheckoutStartUrl($token)
    {
    'return $this->getPaypalUrl(array(
    '
    cmd'   => '_express-checkout',
    '
    useraction' => 'commit',
    '
    token' => $token,
    ));
    }

    注意 \\'useraction\\' => \\'commit\\',已添加到新函数中。这应该工作!


    Magento 1.9 内置了对此的支持,即 Skip Order Review Step 选项,但它有一个微妙的警告。该功能不适用于您可以在产品详细信息和购物车页面上显示的"快捷方式"按钮。

    我的建议是,禁用快捷按钮并启用"跳过订单审核步骤"选项。为了获得额外的信用,您可以重新安排 Onepage Checkout 流程,这样客户就不必输入两次帐单信息(一次在 Magento 上,一次在 PayPal 上)。

    此博客文章中提供了更多详细信息。


    这里少了一个步骤,让我再总结一下整个过程。

    1。转到:\\\\\\\\app\\\\\\\\code\\\\\\\\core\\\\\\\\Mage\\\\\\\\Paypal\\\\\\\\Controller\\\\\\\\Express\\\\\\\\Abstract.php

    并在 returnAction() 中搜索:

    1
    $this->_redirect('*/*/review');

    你必须改变:

    1
    $this->_redirect('*/*/review');

    到:

    1
    $this->_redirect('*/*/placeOrder');

    2。转到:\\\\\\\\app\\\\\\\\code\\\\\\\\core\\\\\\\\Mage\\\\\\\\Paypal\\\\\\\\Model\\\\\\\\Config.php 并更改:

    1
    2
    3
    4
    5
    6
    7
    public function getExpressCheckoutStartUrl($token)
    {
        return $this->getPaypalUrl(array(
            'cmd'   => '_express-checkout',
            'token' => $token,
        ));
    }

    到:

    1
    2
    3
    4
    5
    6
    7
    8
    public function getExpressCheckoutStartUrl($token)
    {
        return $this->getPaypalUrl(array(
            'cmd'   => '_express-checkout',
            'useraction' => 'commit',
            'token' => $token,
        ));
    }

    3。通过上述两项更改,您仍将被带到评论页面并且必须同意条款和条件,以避免这种情况转到:

    /app/code/core/Mage/Paypal/Controller/Express/Abstract.php
    搜索:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    public function placeOrderAction()
    {
    try {
    $requiredAgreements = Mage::helper(‘checkout’)->getRequiredAgreementIds();
    if ($requiredAgreements) {
    $postedAgreements = array_keys($this->getRequest()->getPost(‘agreement’, array()));
    if (array_diff($requiredAgreements, $postedAgreements)) {
    Mage::throwException(Mage::helper(‘paypal’)->__(‘Please agree to all the terms and conditions before placing the order.));
    }
    }

    以简单的//开头注释以下行:

    1
    2
    3
    //if (array_diff($requiredAgreements, $postedAgreements)) {
    // Mage::throwException(Mage::helper(‘paypal’)->__(‘Please agree to all the terms and conditions before placing the order.’));
    // }

    您将被带到评论页面的唯一时间是客户的贝宝返回拒绝错误。

    有关关于 php:Magento: 删除”paypal/express/review”步骤的简单方法的更多相关文章

    1. ruby - 如何使用 Nokogiri 的 xpath 和 at_xpath 方法 - 2

      我正在学习如何使用Nokogiri,根据这段代码我遇到了一些问题:require'rubygems'require'mechanize'post_agent=WWW::Mechanize.newpost_page=post_agent.get('http://www.vbulletin.org/forum/showthread.php?t=230708')puts"\nabsolutepathwithtbodygivesnil"putspost_page.parser.xpath('/html/body/div/div/div/div/div/table/tbody/tr/td/div

    2. ruby - 如何从 ruby​​ 中的字符串运行任意对象方法? - 2

      总的来说,我对ruby​​还比较陌生,我正在为我正在创建的对象编写一些rspec测试用例。许多测试用例都非常基础,我只是想确保正确填充和返回值。我想知道是否有办法使用循环结构来执行此操作。不必为我要测试的每个方法都设置一个assertEquals。例如:describeitem,"TestingtheItem"doit"willhaveanullvaluetostart"doitem=Item.new#HereIcoulddotheitem.name.shouldbe_nil#thenIcoulddoitem.category.shouldbe_nilendend但我想要一些方法来使用

    3. ruby - 为什么我可以在 Ruby 中使用 Object#send 访问私有(private)/ protected 方法? - 2

      类classAprivatedeffooputs:fooendpublicdefbarputs:barendprivatedefzimputs:zimendprotecteddefdibputs:dibendendA的实例a=A.new测试a.foorescueputs:faila.barrescueputs:faila.zimrescueputs:faila.dibrescueputs:faila.gazrescueputs:fail测试输出failbarfailfailfail.发送测试[:foo,:bar,:zim,:dib,:gaz].each{|m|a.send(m)resc

    4. ruby - Facter::Util::Uptime:Module 的未定义方法 get_uptime (NoMethodError) - 2

      我正在尝试设置一个puppet节点,但ruby​​gems似乎不正常。如果我通过它自己的二进制文件(/usr/lib/ruby/gems/1.8/gems/facter-1.5.8/bin/facter)在cli上运行facter,它工作正常,但如果我通过由ruby​​gems(/usr/bin/facter)安装的二进制文件,它抛出:/usr/lib/ruby/1.8/facter/uptime.rb:11:undefinedmethod`get_uptime'forFacter::Util::Uptime:Module(NoMethodError)from/usr/lib/ruby

    5. Ruby 方法() 方法 - 2

      我想了解Ruby方法methods()是如何工作的。我尝试使用“ruby方法”在Google上搜索,但这不是我需要的。我也看过ruby​​-doc.org,但我没有找到这种方法。你能详细解释一下它是如何工作的或者给我一个链接吗?更新我用methods()方法做了实验,得到了这样的结果:'labrat'代码classFirstdeffirst_instance_mymethodenddefself.first_class_mymethodendendclassSecond使用类#returnsavailablemethodslistforclassandancestorsputsSeco

    6. ruby-on-rails - 如何从 format.xml 中删除 <hash></hash> - 2

      我有一个对象has_many应呈现为xml的子对象。这不是问题。我的问题是我创建了一个Hash包含此数据,就像解析器需要它一样。但是rails自动将整个文件包含在.........我需要摆脱type="array"和我该如何处理?我没有在文档中找到任何内容。 最佳答案 我遇到了同样的问题;这是我的XML:我在用这个:entries.to_xml将散列数据转换为XML,但这会将条目的数据包装到中所以我修改了:entries.to_xml(root:"Contacts")但这仍然将转换后的XML包装在“联系人”中,将我的XML代码修改为

    7. ruby - 我可以使用 Ruby 从 CSV 中删除列吗? - 2

      查看Ruby的CSV库的文档,我非常确定这是可能且简单的。我只需要使用Ruby删除CSV文件的前三列,但我没有成功运行它。 最佳答案 csv_table=CSV.read(file_path_in,:headers=>true)csv_table.delete("header_name")csv_table.to_csv#=>ThenewCSVinstringformat检查CSV::Table文档:http://ruby-doc.org/stdlib-1.9.2/libdoc/csv/rdoc/CSV/Table.html

    8. ruby-on-rails - Rails 3.2.1 中 ActionMailer 中的未定义方法 'default_content_type=' - 2

      我在我的项目中添加了一个系统来重置用户密码并通过电子邮件将密码发送给他,以防他忘记密码。昨天它运行良好(当我实现它时)。当我今天尝试启动服务器时,出现以下错误。=>BootingWEBrick=>Rails3.2.1applicationstartingindevelopmentonhttp://0.0.0.0:3000=>Callwith-dtodetach=>Ctrl-CtoshutdownserverExiting/Users/vinayshenoy/.rvm/gems/ruby-1.9.3-p0/gems/actionmailer-3.2.1/lib/action_mailer

    9. ruby - Highline 询问方法不会使用同一行 - 2

      设置:狂欢ruby1.9.2高线(1.6.13)描述:我已经相当习惯在其他一些项目中使用highline,但已经有几个月没有使用它了。现在,在Ruby1.9.2上全新安装时,它似乎不允许在同一行回答提示。所以以前我会看到类似的东西:require"highline/import"ask"Whatisyourfavoritecolor?"并得到:Whatisyourfavoritecolor?|现在我看到类似的东西:Whatisyourfavoritecolor?|竖线(|)符号是我的终端光标。知道为什么会发生这种变化吗? 最佳答案

    10. ruby - 主要 :Object when running build from sublime 的未定义方法 `require_relative' - 2

      我已经从我的命令行中获得了一切,所以我可以运行rubymyfile并且它可以正常工作。但是当我尝试从sublime中运行它时,我得到了undefinedmethod`require_relative'formain:Object有人知道我的sublime设置中缺少什么吗?我正在使用OSX并安装了rvm。 最佳答案 或者,您可以只使用“require”,它应该可以正常工作。我认为“require_relative”仅适用于ruby​​1.9+ 关于ruby-主要:Objectwhenrun

    随机推荐