magneto1.9集成的PayPal支付通道主要分为三个,第一个是在产品页和购物车页面的快速结账,包含有加购功能,点击后不需要输入信息即可跳转支付。第二个是结账页的PayPal标准结账,第三个是结账页的PayPal信用卡结账。
最近领导要求开启PayPal信用卡结账,减少钱海信用卡支付的订单数。在这个调试的过程中遇到了坑,按照以前的方法,死活不行,一连卡了三天。最后装了一个纯净版的magento,对照参数才发现里面的一个可能存在问题。最终比对后成功,其中关巧如下。
1、mangeto初装的时候,开启PayPal后有个设置默认为Authorization,通常使用的时候需要更改为Sale。
2、需要跳转到信用卡界面的话增加如下参数:
app\code\core\Mage\Paypal\Model\Api\Nvp.php中的933行的call()方法,增加$request参数。
if($checkPaymentMethod==1){ $request['SOLUTIONTYPE']='Sole'; $request['LANDINGPAGE']='Billing'; $request['PAYMENTACTION']='Authorization'; //$request['USERSELECTEDFUNDINGSOURCE']='CreditCard'; //Mage::log($request,NULL,'amy1.log'); }else{ $request['LANDINGPAGE']='Login'; // Mage::log($request,NULL,'amy2.log'); }
3、$checkPaymentMethod来源于前台接收的参数,控制在点击购物车页面的快速结账按钮的时候传递0,点击结账页的选择PayPal按钮并plance order的时候传递1;这样就做到了两种不同的着陆页展现。
$checkPaymentMethod=Mage::getSingleton('core/session')->getPaypalInstruction();
4、测试的结果是如果想跳转到信用卡界面,必须使用Authorization的请求方式,使用Sale死活不行。就这个问题卡了三天,但是之前使用Sale是一直ok的,包括前同事也都是ok的,但现在这个系统里面使用Sale的方式请求,一直不成功,log参数核对了几遍,坑。
最后放一下日志:
2019-09-03T03:01:03+00:00 DEBUG (7): Array
(
[url] => https://api-3t.sandbox.paypal.com/nvp
[SetExpressCheckout] => Array
(
[PAYMENTACTION] => Authorization
[AMT] => 35.92
[CURRENCYCODE] => USD
[RETURNURL] => http://zz.com/paypal/express/return/
[CANCELURL] => http://zz.com/paypal/express/cancel/
[INVNUM] => 100000007
[SOLUTIONTYPE] => Sole
[GIROPAYCANCELURL] => http://zz.com/paypal/express/cancel/
[GIROPAYSUCCESSURL] => http://zz.com/checkout/onepage/success/
[BANKTXNPENDINGURL] => http://zz.com/checkout/onepage/success/
[HDRIMG] => https://www.zeelool.com/skin/frontend/ves_taima/default/images/logo.png
[LOCALECODE] => en_US
[ITEMAMT] => 35.92
[TAXAMT] => 0.00
[SHIPPINGAMT] => 0.00
[L_NUMBER0] => FP0300-01
[L_NAME0] => Lucy Cat Eye Glasses
[L_QTY0] => 2
[L_AMT0] => 23.95
[L_NUMBER1] =>
[L_NAME1] => Discount
[L_QTY1] => 1
[L_AMT1] => -11.98
[BUSINESS] =>
[NOTETEXT] =>
[EMAIL] => damaerguo@gmail.com
[FIRSTNAME] => x
[LASTNAME] => z
[MIDDLENAME] =>
[SALUTATION] =>
[SUFFIX] =>
[COUNTRYCODE] => US
[STATE] => AM
[CITY] => dfddddddd
[STREET] => tt
[ZIP] => 5555
[PHONENUM] => 6666666
[SHIPTOCOUNTRYCODE] => US
[SHIPTOSTATE] => AM
[SHIPTOCITY] => dfddddddd
[SHIPTOSTREET] => tt
[SHIPTOZIP] => 5555
[SHIPTOPHONENUM] => 6666666
[SHIPTOSTREET2] =>
[STREET2] =>
[SHIPTONAME] => x z
[ADDROVERRIDE] => 0
[METHOD] => SetExpressCheckout
[LANDINGPAGE] => Billing
[VERSION] => 72.0
[USER] => ****
[PWD] => ****
[SIGNATURE] => ****
[BUTTONSOURCE] => yisainuo_Cart
)
[response] => Array
(
[TOKEN] => EC-2D613061WP178013V
[TIMESTAMP] => 2019-09-03T03:00:57Z
[CORRELATIONID] => ec3e2a9fcc222
[ACK] => Success
[VERSION] => 72.0
[BUILD] => 53481737
)
[__pid] => 1336
)