本文整理汇总了PHP中Mage_Payment_Model_Info::getRefundTransactionId方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Payment_Model_Info::getRefundTransactionId方法的具体用法?PHP Mage_Payment_Model_Info::getRefundTransactionId怎么用?PHP Mage_Payment_Model_Info::getRefundTransactionId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Payment_Model_Info
的用法示例。
在下文中一共展示了Mage_Payment_Model_Info::getRefundTransactionId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _refund
/**
* Send refund request to MerchantWare gateway
*
* @param Mage_Payment_Model_Info $payment
* @param decimal $amount
* @return $result
* @throws Mage_Core_Exception
*/
private function _refund($payment, $amount)
{
$error = false;
$soapClient = $this->getSoapApi();
$this->iniRequest();
//Add token
if ($payment->getRefundTransactionId()) {
$this->_request->token = $payment->getRefundTransactionId();
} else {
//No transaction Id.
$error = Mage::helper('merchantware_directpost')->__('No gateway transaction could be found. Gateway transaction could not be refunded.');
Mage::throwException($error);
}
//Add merchantTransactionId
$order = $payment->getOrder();
$this->_request->merchantTransactionId = $order->getIncrementId();
//Add overrideAmount
$this->_request->overrideAmount = $amount;
$debugData['request'] = $this->_request;
$additionalInfo = array();
try {
$result = $soapClient->Refund($this->_request);
$result = $result->RefundResult;
$debugData['result'] = $result;
if (!empty($result->ErrorMessage)) {
$additionalInfo['ErrorMessage'] = $result->ErrorMessage;
}
//Authorization is approved.
$additionalInfo['ApprovalStatus'] = $result->ApprovalStatus;
$additionalInfo['Amount'] = $result->Amount;
$additionalInfo['AuthorizationCode'] = $result->AuthorizationCode;
if (!empty($result->Cardholder)) {
$additionalInfo['Cardholder'] = $result->Cardholder;
}
if (!empty($result->AvsResponse)) {
$additionalInfo['AvsResponse'] = $result->AvsResponse;
}
if (!empty($result->CvResponse)) {
$additionalInfo['CvResponse'] = $result->AvsResponse;
}
$additionalInfo['CardType'] = $result->CardType;
if (!empty($result->InvoiceNumber)) {
$additionalInfo['InvoiceNumber'] = $result->InvoiceNumber;
}
$additionalInfo['Token'] = $result->Token;
$additionalInfo['TransactionDate'] = $result->TransactionDate;
$additionalInfo['TransactionType'] = $result->TransactionType;
if (!empty($result->ExtraData)) {
$additionalInfo['ExtraData'] = $result->ExtraData;
}
switch ($this->_parseApprovalStatus($result->ApprovalStatus)) {
case self::APPROVAL_STATUS_APPROVED:
//SaleKey Approved.
$message = 'Type: Refund | ApprovalStatus: ' . $result->ApprovalStatus . ' | Amount: ' . $result->Amount;
$payment->setSkipTransactionCreation(false);
$payment->setTransactionId($result->Token)->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND, null, false, $message)->setTransactionAdditionalInfo(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $additionalInfo)->setIsTransactionClosed(1)->save();
break;
case self::APPROVAL_STATUS_DECLINED:
case self::APPROVAL_STATUS_DECLINED_DUPLICATE:
case self::APPROVAL_STATUS_FAILED:
case self::APPROVAL_STATUS_REFERRAL:
default:
$error = Mage::helper('merchantware_directpost')->__('Your refund request has been declined. Gateway approval status: %s | Gateway error response: %s', $result->ApprovalStatus, $result->ErrorMessage);
Mage::throwException($error);
break;
}
return $result;
} catch (Exception $e) {
Mage::throwException(Mage::helper('merchantware_directpost')->__('Gateway request error: %s', $e->getMessage()));
}
if ($error !== false) {
Mage::throwException($error);
}
$this->_debug($debugData);
return false;
}