本文整理汇总了PHP中Mage_Sales_Model_Order_Payment::getCreditmemo方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Order_Payment::getCreditmemo方法的具体用法?PHP Mage_Sales_Model_Order_Payment::getCreditmemo怎么用?PHP Mage_Sales_Model_Order_Payment::getCreditmemo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Order_Payment
的用法示例。
在下文中一共展示了Mage_Sales_Model_Order_Payment::getCreditmemo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: refund
/**
* Refund order
*
* @param Mage_Sales_Model_Order_Payment $payment
* @param float $amount
* @return string Amazon Transaction Id
*/
public function refund($payment, $amount)
{
$_document = '<?xml version="1.0" encoding="UTF-8"?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>' . $this->getMerchantIdentifier() . '</MerchantIdentifier>
</Header>
<MessageType>OrderAdjustment</MessageType>';
$_shippingAmount = $payment->getCreditmemo()->getShippingAmount();
$_messageId = 1;
foreach ($payment->getCreditmemo()->getAllItems() as $item) {
/* @var $item Mage_Sales_Model_Order_Creditmemo_Item */
if ($item->getOrderItem()->getParentItemId()) {
continue;
}
$shipping = 0;
$amazon_amounts = unserialize($item->getOrderItem()->getProductOptionByCode('amazon_amounts'));
if ($amazon_amounts['shipping'] > $_shippingAmount) {
$shipping = $_shippingAmount;
} else {
$shipping = $amazon_amounts['shipping'];
}
$_shippingAmount -= $shipping;
$_document .= '<Message>
<MessageID>' . $_messageId . '</MessageID>
<OrderAdjustment>
<AmazonOrderID>' . $payment->getOrder()->getExtOrderId() . '</AmazonOrderID>
<AdjustedItem>
<AmazonOrderItemCode>' . $item->getOrderItem()->getExtOrderItemId() . '</AmazonOrderItemCode>
<AdjustmentReason>GeneralAdjustment</AdjustmentReason>
<ItemPriceAdjustments>
<Component>
<Type>Principal</Type>
<Amount currency="USD">' . $this->formatAmount($item->getBaseRowTotal()) . '</Amount>
</Component>
<Component>
<Type>Tax</Type>
<Amount currency="USD">' . $this->formatAmount($item->getBaseTaxAmount()) . '</Amount>
</Component>' . '<Component>
<Type>Shipping</Type>
<Amount currency="USD">' . $this->formatAmount($shipping) . '</Amount>
</Component>' . '</ItemPriceAdjustments>';
$_document .= '</AdjustedItem>
</OrderAdjustment>
</Message>';
$_messageId++;
}
$_document .= '</AmazonEnvelope>';
$params = array('merchant' => $this->getMerchantInfo(), 'messageType' => self::MESSAGE_TYPE_ADJUSTMENT, 'doc' => $this->_createAttachment($_document));
$this->_proccessRequest('postDocument', $params);
return $this->_result;
}
示例2: refund
/**
* Refund order
*
* @param Mage_Sales_Model_Order_Payment $payment
* @param float $amount
* @return string Amazon Transaction Id
* Modified to use MWS instead of SOAP
*/
public function refund($payment, $amount)
{
$_document = '<?xml version="1.0" encoding="UTF-8"?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>' . $this->getMerchantIdentifier() . '</MerchantIdentifier>
</Header>
<MessageType>OrderAdjustment</MessageType>';
$_shippingAmount = $payment->getCreditmemo()->getShippingAmount();
$_messageId = 1;
foreach ($payment->getCreditmemo()->getAllItems() as $item) {
/* @var $item Mage_Sales_Model_Order_Creditmemo_Item */
if ($item->getOrderItem()->getParentItemId()) {
continue;
}
$shipping = 0;
$amazon_amounts = unserialize($item->getOrderItem()->getProductOptionByCode('amazon_amounts'));
if ($amazon_amounts['shipping'] > $_shippingAmount) {
$shipping = $_shippingAmount;
} else {
$shipping = $amazon_amounts['shipping'];
}
$_shippingAmount -= $shipping;
$currency = Mage::getModel('amazonpayments/api_cba')->getCurrencyFormat();
$_document .= '<Message>
<MessageID>' . $_messageId . '</MessageID>
<OrderAdjustment>
<AmazonOrderID>' . $payment->getOrder()->getExtOrderId() . '</AmazonOrderID>
<AdjustedItem>
<AmazonOrderItemCode>' . $item->getOrderItem()->getExtOrderItemId() . '</AmazonOrderItemCode>
<AdjustmentReason>GeneralAdjustment</AdjustmentReason>
<ItemPriceAdjustments>
<Component>
<Type>Principal</Type>
<Amount currency="' . $currency . '">' . $this->formatAmount($item->getBaseRowTotal()) . '</Amount>
</Component>
<Component>
<Type>Tax</Type>
<Amount currency="' . $currency . '">' . $this->formatAmount($amazon_amounts['tax'] + $amazon_amounts['shipping_tax']) . '</Amount>
</Component>' . '<Component>
<Type>Shipping</Type>
<Amount currency="' . $currency . '">' . $this->formatAmount($shipping) . '</Amount>
</Component>' . '</ItemPriceAdjustments>';
$_document .= '</AdjustedItem>
</OrderAdjustment>
</Message>';
$_messageId++;
}
$_document .= '</AmazonEnvelope>';
$this->_processMWSRequest($_document, "_POST_PAYMENT_ADJUSTMENT_DATA_");
$comment = $payment->getOrder()->addStatusToHistory(Mage_Sales_Model_Order::STATE_PROCESSING, Mage::helper('amazonpayments')->__('Refund Reference ID:' . $this->_result . ' and Amazon order ID:' . $payment->getOrder()->getExtOrderId()))->save();
return $this->_result;
}