php Magento:删除“paypal/express/review”步骤的简单方法
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7607180/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Magento: easy way to remove "paypal/express/review" step
提问by Dreaded semicolon
When ordering using paypal in magento, it takes you to paypal, paypal already displays a confirmation, you confirm, you get redirected to another confirmation page (/paypal/express/review), it is an extra step that is unnecessary for user experience, I would like to remove it and make the order automatically placed when user confirm on paypal page, once leave paypal if order successful the customer should see the success page.
在magento中使用paypal下单时,会带你到paypal,paypal已经显示了一个确认,你确认,你会被重定向到另一个确认页面(/paypal/express/review),这是一个额外的步骤,对于用户体验来说是不必要的,我想删除它并在用户在贝宝页面确认时自动下订单,如果订单成功离开贝宝,客户应该看到成功页面。
is there any easy solution to this I might have overlooked or at least if you can point me to the right direction to remove that step.
是否有任何简单的解决方案可以解决我可能忽略的问题,或者至少如果您可以指出正确的方向来删除该步骤。
采纳答案by Anton S
don't use paypal express and use paypal standard if you don't need this feature. paypal express is a checkout method and not a payment method
如果您不需要此功能,请不要使用贝宝快递并使用贝宝标准。paypal express 是一种结账方式,而不是一种付款方式
edit: this is now configurable in 1.9, still retarded but doable.
编辑:这现在可以在 1.9 中配置,仍然延迟但可行。
回答by Drew Angell
Actually, Express Checkout can handle this no problem, and I would personally recommend sticking with it.
实际上,Express Checkout 可以解决这个问题,我个人建议坚持使用它。
After the SetExpressCheckout request you redirect the user over to PayPal. You can append useraction=commit to this URL in order to trigger the confirmation from PayPal pages.
在 SetExpressCheckout 请求之后,您将用户重定向到 PayPal。您可以将 useraction=commit 附加到此 URL 以触发来自 PayPal 页面的确认。
This causes the "Continue" button on PayPal to switch to a "Pay" button and informs the user that this is their final confirmation...clicking Pay will submit the payment.
这会导致 PayPal 上的“继续”按钮切换到“付款”按钮,并通知用户这是他们的最终确认……单击“付款”将提交付款。
You still have to call DoExpressCheckoutPayment on your server to complete the process, but GetExpressCheckoutDetails is optional at this point. When using useraction=commit you'll get the PayerID back as a URL parameter in your ReturnURL so you don't have to call GECD if you don't want/need to.
您仍然需要在服务器上调用 DoExpressCheckoutPayment 来完成该过程,但此时 GetExpressCheckoutDetails 是可选的。使用 useraction=commit 时,您将在 ReturnURL 中将 PayerID 作为 URL 参数返回,因此如果您不想/不需要,则不必调用 GECD。
You can take this all a setup farther and use the callback API (also known as instant update API) to feed shipping and sales tax information to the PayPal review page. This allows you to populate the drop down values on PayPal's review page with your own shipping data based on the user's shipping address selected on the PayPal review page.
您可以进一步设置这一切,并使用回调 API(也称为即时更新 API)将运费和销售税信息提供给 PayPal 页面。这允许您根据在 PayPal 页面上选择的用户送货地址,使用您自己的送货数据填充 PayPal 页面上的下拉值。
The introduction of those features was to do exactly what you specified...eliminate the additional review process.
引入这些功能是为了完全按照您指定的方式进行……消除额外的过程。
All of that said, if the Magento module for Express Checkout doesn't provide options for all of this you'll need to extend it and build them in yourself. I'm pretty it does, though.
综上所述,如果 Express Checkout 的 Magento 模块不提供所有这些选项,您将需要扩展它并自己构建它们。不过,我很漂亮。
回答by Anna V?lkl
Actually all the solutions mentioned here required to edit the Magento core. This is known as bad practiseand does not keep your shop updateable.
实际上这里提到的所有解决方案都需要编辑 Magento 核心。这被称为不好的做法,不会使您的商店保持可更新。
What you need to do for a clean solution:
您需要做什么才能获得干净的解决方案:
- Create a module (in my exampe: Avoe_Paypal) to include the changes
- Rewrite Paypal Config
- Redirect on paypal express review step which is http://yourdomain.com/paypal/express/review/
- 创建一个模块(在我的例子中:Avoe_Paypal)以包含更改
- 重写 Paypal 配置
- 重定向到贝宝快递步骤http://yourdomain.com/paypal/express/review/
1) Create your module
1)创建你的模块
Avoe/Paypal/etc/config.xml
Avoe/Paypal/etc/config.xml
<?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>
<avoe_paypal_predispatch>
<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
app/etc/Avoe_Paypal.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Avoe_Paypal>
<active>true</active>
<codePool>local</codePool>
<depends>
<Mage_Paypal />
</depends>
</Avoe_Paypal>
</modules>
</config>
2) Rewrite config, add useraction 'commit':
2) 重写配置,添加 useraction 'commit':
<?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) Create observer to redirect:
3)创建观察者重定向:
<?php
class Avoe_Paypal_Model_Observer {
function paypalExpressReturnPredispatch($observer) {
Mage::app()->getResponse()->setRedirect(Mage::getUrl('*/*/placeOrder'));
}
}
There is also a small Magento extension which was just released yesterday, to remove the review step:
还有一个昨天刚刚发布的小型 Magento 扩展,以删除步骤:
https://github.com/tim-bezhashvyly/Sandfox_RemovePaypalExpressReviewStep
https://github.com/tim-bezhashvyly/Sandfox_RemovePaypalExpressReviewStep
回答by G.i. John
So the right deal there, that works perfectly (for me ) is a sum up from the above :
所以正确的交易,完美的(对我来说)是上面的总结:
1. Go to:\app\code\core\Mage\Paypal\Controller\Express\Abstract.php
1. 前往:\app\code\core\Mage\Paypal\Controller\Express\Abstract.php
and search in returnAction()for:
并在returnAction() 中搜索:
$this->_redirect('*/*/review');
There you have to change:
在那里你必须改变:
$this->_redirect('*/*/review');
to:
到:
$this->_redirect('*/*/placeOrder');
2. Go to:\app\code\core\Mage\Paypal\Model\Config.php and change the:
2. 转到:\app\code\core\Mage\Paypal\Model\Config.php 并更改:
public function getExpressCheckoutStartUrl($token)
{
return $this->getPaypalUrl(array(
'cmd' => '_express-checkout',
'token' => $token,
));
}
to:
到:
public function getExpressCheckoutStartUrl($token)
{
return $this->getPaypalUrl(array(
'cmd' => '_express-checkout',
'useraction' => 'commit',
'token' => $token,
));
}
With the 2 changes above, i figure out how to Skip Review Page in Magento Paypal Express Checkout.
通过上述 2 项更改,我弄清楚了如何在 Magento Paypal Express Checkout 中跳过评论页面。
回答by Toni
Andrew Angel's answer really doesn't avoid the comfirmation page, it just changes button value to "Pay" rather to "Confirm", or something like that.
安德鲁天使的回答确实没有避开确认页面,它只是将按钮值更改为“支付”而不是“确认”,或者类似的东西。
Anyway the correct way to do that is going to
\app\code\core\Mage\Paypal\Model\Config.php, to
getExpressCheckoutEditUrl($token)
method and change
无论如何,正确的方法是在
\app\code\core\Mage\Paypal\Model\Config.php中进行
getExpressCheckoutEditUrl($token)
方法和更改
'useraction' => 'continue',
to
到
'useraction' => 'commit'.
To aviod confirmation user page in Paypal Express you only need to change one line in on controller action.
Go to Mage/Paypal/Controller/Express/Abstract.phpand search for $this->_redirect('*/*/review')
; in returnAction()
. There you have to change
要避免在 Paypal Express 中确认用户页面,您只需要在控制器操作中更改一行。转到Mage/Paypal/Controller/Express/Abstract.php并搜索$this->_redirect('*/*/review')
; 在returnAction()
。你必须改变
$this->_redirect('\*/\*/review');
to
到
$this->_redirect('\*/\*/placeOrder');
That way when paypal returns to return action you avoid to show entire review page and payment was automatically confirmed. So, Paypal redirects again to success pages the same way like PayPal Standard method.
这样,当贝宝返回返回操作时,您可以避免显示整个评论页面并自动确认付款。因此,Paypal 以与 PayPal Standard 方法相同的方式再次重定向到成功页面。
回答by David
@Toni The redirect url part works excellent, thanks! However changing the 'continue' to 'commit' did not change the buttons on PayPal's website. However, I was able to fix it by doing the following: Right above the getExpressCheckoutEditUrl function where Toni instructed to change the continue to commit, there is the funciton getExpressCheckoutStartUrl. If you add the useraction variable there, it will work. Original function:
@Toni 重定向网址部分效果很好,谢谢!但是,将“继续”更改为“提交”并没有更改 PayPal 网站上的按钮。但是,我可以通过执行以下操作来修复它:在托尼指示更改继续提交的 getExpressCheckoutEditUrl 函数正上方,有函数 getExpressCheckoutStartUrl。如果您在那里添加 useraction 变量,它将起作用。原函数:
public function getExpressCheckoutStartUrl($token)
{
'return $this->getPaypalUrl(array(
'cmd' => '_express-checkout',
'token' => $token,
));
}
New function:
新功能:
public function getExpressCheckoutStartUrl($token)
{
'return $this->getPaypalUrl(array(
'cmd' => '_express-checkout',
'useraction' => 'commit',
'token' => $token,
));
}
Notice the 'useraction' => 'commit', was added at the new function. This should work!
请注意,'useraction' => 'commit' 已添加到新函数中。这应该有效!
回答by Juggernaught
THere was one step missing let me summarize the entire process again.
少了一步让我再次总结整个过程。
1.Go to: \app\code\core\Mage\Paypal\Controller\Express\Abstract.php
1.前往:\app\code\core\Mage\Paypal\Controller\Express\Abstract.php
and search in returnAction() for:
并在 returnAction() 中搜索:
$this->_redirect('*/*/review');
There you have to change:
在那里你必须改变:
$this->_redirect('*/*/review');
to:
到:
$this->_redirect('*/*/placeOrder');
2.Go to: \app\code\core\Mage\Paypal\Model\Config.php and change the:
2.转到:\app\code\core\Mage\Paypal\Model\Config.php 并更改:
public function getExpressCheckoutStartUrl($token)
{
return $this->getPaypalUrl(array(
'cmd' => '_express-checkout',
'token' => $token,
));
}
to:
到:
public function getExpressCheckoutStartUrl($token)
{
return $this->getPaypalUrl(array(
'cmd' => '_express-checkout',
'useraction' => 'commit',
'token' => $token,
));
}
3.With the above two changes you will still be taken to the review page and have to agree to the terms and conditions, to avoid this go to:
3.进行以上两项更改后,您仍将被带到评论页面并必须同意条款和条件,以避免这种情况转到:
/app/code/core/Mage/Paypal/Controller/Express/Abstract.php Search for :
/app/code/core/Mage/Paypal/Controller/Express/Abstract.php 搜索:
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.'));
}
}
Comment out the following lines with a simple // at the beginning :
在开头用简单的 // 注释掉以下几行:
//if (array_diff($requiredAgreements, $postedAgreements)) {
// Mage::throwException(Mage::helper(‘paypal')->__(‘Please agree to all the terms and conditions before placing the order.'));
// }
The only time you will every be take to the review page is if the customers paypal returns a declined error.
您每次进入评论页面的唯一时间是客户贝宝返回拒绝错误。
回答by quickshiftin
Magento 1.9 has built-in support for this, the Skip Order Review Stepoption, but it has a subtle caveat. The feature doesn't work with the 'Shortcut' buttons you can display on the product detail and cart pages.
Magento 1.9 对此有内置支持,即跳过订单审核步骤选项,但它有一个微妙的警告。该功能不适用于您可以在产品详细信息和购物车页面上显示的“快捷方式”按钮。
My suggestion, disable the shortcut buttons and enable the Skip Order Review Stepoption. For extra credit you can rearrange the Onepage Checkout flow so that customers won't have to enter billing information twice (once on Magento and again on PayPal).
我的建议是禁用快捷按钮并启用跳过订单审核步骤选项。为了获得额外的信用,您可以重新安排 Onepage Checkout 流程,这样客户就不必两次输入帐单信息(一次在 Magento 上,一次在 PayPal 上)。
More details available in this blog post.
此博客文章中提供了更多详细信息。