我的问题可能看起来很流行,但我面临困难......
部分功能代码是
public function capture(Varien_Object $payment, $amount){
if(!$this->isEnabled()){
return parent::capture($payment, $amount);
}else{
---- MORE CODE--
$quote = Mage::getSingleton('customer/session');
$nickname = $quote->getAuthorizenetNickname();
$profile = $quote->getProfile();
$postedNickname = $quote->getNickname();
if ($payment->getCcTransId()) {
$payment->setAnetTransType(self::REQUEST_TYPE_PRIOR_AUTH_CAPTURE);
} else {
$payment->setAnetTransType(self::REQUEST_TYPE_AUTH_CAPTURE);
}
$payment->setAmount($amount);
$request= $this->_buildRequest($payment);
$result = $this->_postRequest($request);
MORE CODE HERE, NOT RELEVENT TO MY ISSUE
我在这里有两个问题
我如何通过
进行交易ID$payment->setAmount($amount);
$request= $this->_buildRequest($payment);
$result = $this->_postRequest($request);
,第二个问题是
如何回传/调试传递的transactionID值
对你来说可能很容易,但我失败了
到目前为止尝试了
$payment->setTransID($payment->gerOrder->getTransID());
and
$payment->gerOrder->getTransID()
$payment->setAmount($amount);
$request= $this->_buildRequest($payment);
感谢您的帮助和指南
答案 0 :(得分:7)
之前我已经完成了这个问题,这是我的发现:)
付款与交易完全不同,尽管它们有关系。
付款对象包含有关订单总数的完整信息(折扣,总计,取消,运送等...)
交易仅保留与例如来自支付网关(txn_id
,parent_txn_id
的相关信息 - 如果它具有父母交易 - 等等......)因此它不会支付多少费用/多少钱/多少取消/发货等..
$order->getPayment();
)last_trans_id
分配给付款对象并保存! 我希望这可以帮助你:)
请找到我为将付款添加到付款
所做的付款集成示例 /**
* Creates Transactions for directlink activities
*
* @param Mage_Sales_Model_Order $order
* @param int $transactionID - persistent transaction id
* @param int $subPayID - identifier for each transaction
* @param array $arrInformation - add dynamic data
* @param string $typename - name for the transaction exp.: refund
* @param string $comment - order comment
*
* @return Cashu_Helper_DirectLink $this
*/
public function directLinkTransact($order,$transactionID, $subPayID,
$arrInformation = array(), $typename, $comment, $closed = 0)
{
$payment = $order->getPayment();
$payment->setTransactionId($transactionID."/".$subPayID);
$transaction = $payment->addTransaction($typename, null, false, $comment);
$transaction->setParentTxnId($transactionID);
$transaction->setIsClosed($closed);
$transaction->setAdditionalInformation("arrI nfo", serialize($arrInformation));
$transaction->save();
$order->save();
return $this;
}
答案 1 :(得分:2)
我也正在构建CIM支付模块。所以我确切地知道你要经历什么(我想我差不多完成了,但是过去3周我一直都这么说)
从您上面的代码中,您似乎正在尝试执行PRIOR_AUTH_CAPTURE
,这意味着您应该在执行AUTH_ONLY
事务时存储事务ID。
看看
/app/code/core/Mage/Paygate/Model/Authorizenet.php
设置交易ID(PRIOR_AUTH_CAPTURE
)
protected function _preauthorizeCaptureCardTransaction($payment, $amount, $card)
{
$authTransactionId = $card->getLastTransId();
$authTransaction = $payment->getTransaction($authTransactionId);
$realAuthTransactionId = $authTransaction->getAdditionalInformation($this->_realTransactionIdKey);
$payment->setAnetTransType(self::REQUEST_TYPE_PRIOR_AUTH_CAPTURE);
$payment->setXTransId($realAuthTransactionId);
保存交易ID的代码(AUTH_ONLY
)
protected function _place($payment, $amount, $requestType)
{
....
switch ($result->getResponseCode()) {
case self::RESPONSE_CODE_APPROVED:
$this->getCardsStorage($payment)->flushCards();
$card = $this->_registerCard($result, $payment); //<-- take a look at
.....
$this->_addTransaction(
$payment,
$card->getLastTransId(),
$newTransactionType,
array('is_transaction_closed' => 0),
array(
$this->_realTransactionIdKey => $card->getLastTransId(), //<-- take a look at
$this->_isTransactionFraud => true
),
更新
$payment->setAmount($amount);
$payment->setXTransId({put your transaction id here});
$payment->setAnetTransType($requestType);
$request= $this->_buildRequest($payment);
$result = $this->_postRequest($request);
然后在构建您的请求时
protected function _buildRequest(Varien_Object $payment)
{
....
switch ($payment->getAnetTransType()) {
.....
case self::REQUEST_TYPE_PRIOR_AUTH_CAPTURE: //<-- for all the request that need Transaction id
$request->setXTransId($payment->getXTransId());
break;