MagenTo修改PAYPAL支付方式递交字段方法

时间:12-08-05 栏目:MagenTo 作者:admin 评论:0 点击: 5,126 次

MagenTo修改支付方式递交字段示例:

以MagenTo paypal Standard为例

(app/code/core/Mage/Paypal/Block/Standard/Redirect.php),在此文件合适的地方修改。

		$websiteName = Mage::getStoreConfig('general/store_information/name');

	    $fields = $standard->getStandardCheckoutFormFields();
		if($fields['item_number_1']){
			$fields['item_number_1'] =  '#'.$fields['invoice'];
			$fields['item_name_1'] =   $websiteName . ' purchase' ;
		}else{
			$fields['item_number'] = '#'.$fields['invoice'];
			$fields['item_name'] = $websiteName . ' purchase' ;
		}

        foreach ($fields as $field=>$value) {
            $form->addField($field, 'hidden', array('name'=>$field, 'value'=>$value));
        }

上面的修改,对于有购物车有多个商品的情况没有进行处理,在实际使用时,请自行修改适应。

顺便提下,获取网站配置的一些值,可以用:

$website = Mage::getModel('core/website')->load($this->getRequest()->getParam('website'));
$websiteUrl = Mage::getStoreConfig($path, $website->getDefaultStore());

这种方式,getStoreConfig(路径,店ID)

以下是PayPal Express 递交参数修改方式:

/app/code/core/Mage/Paypal/Model/Api/Nvp.php 在此文件合适的地方修改。

protected function _exportLineItems(array &$request, $i = 0)
{
	if (!$this->_cart) {
		return;
	}
	$this->_cart->isDiscountAsItem(true);

	parent::_exportLineItems($request, $i);

	/******************** Modify for steven.liao *******************/
	$websiteName = Mage::getStoreConfig('general/store_information/name');
	if($request['L_NUMBER1']){
		 foreach ($request as $field=>$value) {
			if(strtolower($value)!='shipping' && strstr($field,'L_NAME') && strlen($field) == strlen('L_NAME1')){
				$request['L_NUMBER'.substr($field,-1)] =  $request['INVNUM'];
				$request[$field] =   $websiteName . ' purchase' ;
			}
		 }
	}else{
		$request['L_NUMBER'] = $request['INVNUM'];
		$request['L_NAME'] = $websiteName . ' purchase' ;
	}
	//print_r($request);
	/******************** Modify for steven.liao end *******************/		

	return $request;
}

 PAYPAL NVP 参数参考:

(
    [PAYMENTACTION] => Authorization
    [AMT] => 121.00
    [CURRENCYCODE] => USD
    [RETURNURL] => http://www.magento.info/paypal/express/return/
    [CANCELURL] => http://www.magento.info/paypal/express/cancel/
    [INVNUM] => 100000018
    [SOLUTIONTYPE] => Sole
    [GIROPAYCANCELURL] => http://www.magento.info/paypal/express/cancel/
    [GIROPAYSUCCESSURL] => http://www.magento.info/checkout/onepage/success/
    [BANKTXNPENDINGURL] => http://www.magento.info/checkout/onepage/success/
    [LOCALECODE] => en_US
    [ITEMAMT] => 111.00
    [TAXAMT] => 0.00
    [SHIPPINGAMT] => 10.00
    [L_NUMBER0] => 100000018
    [L_NAME0] => magento.info purchase
    [L_QTY0] => 1
    [L_AMT0] => 100.00
    [L_NUMBER1] => 100000018
    [L_NAME1] => magento.info purchase
    [L_QTY1] => 1
    [L_AMT1] => 11.00

声明: 本文由( admin )原创编译,转载请保留链接: MagenTo修改PAYPAL支付方式递交字段方法

MagenTo修改PAYPAL支付方式递交字段方法:等您坐沙发呢!

发表评论


------====== 本站公告 ======------
联系信息:
lxq73061#qq.com qq:583964941
支付宝:https://me.alipay.com/lxq73061
相关插件程序等信息均会在站内发布,敬请关注。

读者排行