本文整理汇总了PHP中Mage_Sales_Model_Order_Payment类的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Order_Payment类的具体用法?PHP Mage_Sales_Model_Order_Payment怎么用?PHP Mage_Sales_Model_Order_Payment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Mage_Sales_Model_Order_Payment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _place
public function _place(Mage_Sales_Model_Order_Payment $payment, $amount)
{
$order = $payment->getOrder();
$items = Mage::helper('iugu')->getItemsFromOrder($payment->getOrder());
$payer = Mage::helper('iugu')->getPayerInfoFromOrder($payment->getOrder());
$data = new Varien_Object();
$data->setMethod(Inovarti_Iugu_Model_Api::PAYMENT_METHOD_BOLETO)->setEmail($order->getCustomerEmail())->setItems($items)->setPayer($payer)->setNotificationUrl(Mage::getUrl('iugu/notification'));
// Discount
if ($order->getBaseDiscountAmount()) {
$data->setDiscountCents(Mage::helper('iugu')->formatAmount(abs($order->getBaseDiscountAmount())));
}
// Tax
if ($order->getBaseTaxAmount()) {
$data->setTaxCents($this->formatAmount($order->getBaseTaxAmount()));
}
$result = Mage::getSingleton('iugu/api')->charge($data);
if ($result->getErrors()) {
$messages = array();
if (is_array($result->getErrors())) {
foreach ($result->getErrors() as $field => $errors) {
foreach ($errors as $error) {
$messages[] = $field . ': ' . $error . '.';
}
}
} else {
$messages[] = $result->getErrors();
}
Mage::throwException(implode("\n", $messages));
}
// iugu info
$payment->setIuguInvoiceId($result->getInvoiceId())->setIuguUrl($result->getUrl())->setIuguPdf($result->getPdf());
return $this;
}
示例2: determineIsPartial
/**
* Checks if partial capture
*
* @param Mage_Sales_Model_Order_Payment $payment
* @param float $amount
* @return bool
*/
public function determineIsPartial($payment, $amount)
{
$grandTotal = $payment->getOrder()->getGrandTotal();
if ($grandTotal != $amount) {
return true;
} else {
return false;
}
}
示例3: paymentToQuotePayment
/**
* Convert order payment to quote payment
*
* @param Mage_Sales_Model_Order_Payment $payment
* @return Mage_Sales_Model_Quote_Payment
*/
public function paymentToQuotePayment(Mage_Sales_Model_Order_Payment $payment, $quotePayment = null)
{
if (!$quotePayment instanceof Mage_Sales_Model_Quote_Payment) {
$quotePayment = Mage::getModel('sales/quote_payment');
}
$quotePayment->setStoreId($payment->getStoreId())->setCustomerPaymentId($payment->getCustomerPaymentId());
Mage::helper('core')->copyFieldset('sales_convert_order_payment', 'to_quote_payment', $payment, $quotePayment);
return $quotePayment;
}
示例4: unserializeFields
/**
* Unserialize additional data if required
* @param Mage_Sales_Model_Order_Payment $payment
*/
public function unserializeFields(Mage_Sales_Model_Order_Payment $payment)
{
$additionalInformation = $payment->getData('additional_information');
if (empty($additionalInformation)) {
$payment->setData('additional_information', array());
} elseif (!is_array($additionalInformation)) {
$payment->setData('additional_information', unserialize($additionalInformation));
}
}
示例5: _placeOrder
/**
* Place an order with authorization or capture action
*
* @param Mage_Sales_Model_Order_Payment $payment
* @param float $amount
* @return Mage_Paypal_Model_Method_Agreement
*/
protected function _placeOrder(Mage_Sales_Model_Order_Payment $payment, $amount)
{
$order = $payment->getOrder();
$api = $this->_pro->getApi()->setBillingAgreementId($payment->getBillingAgreementId())->setPaymentAction($this->_pro->getConfig()->paymentAction)->setAmount($amount)->setNotifyUrl(Mage::getUrl('paypal/ipn/'))->setPaypalCart(Mage::getModel('paypal/cart', array($order)))->setIsLineItemsEnabled($this->_pro->getConfig()->lineItemsEnabled)->setInvNum($order->getIncrementId());
// call api and import transaction and other payment information
$api->callDoReferenceTransaction();
$this->_pro->importPaymentInfo($api, $payment);
$payment->setAdditionalInformation(CLS_Paypal_Model_Paypaluk_Api_Nvp::RESPONSE_MSG, $api->getResponseMsg())->setPreparedMessage(Mage::helper('cls_paypal')->__('Payflow PNREF: #%s.', $api->getTransactionId()))->setTransactionAdditionalInfo(Mage_PaypalUk_Model_Pro::TRANSPORT_PAYFLOW_TXN_ID, $api->getTransactionId());
$payment->setTransactionId($api->getPaypalTransactionId())->setIsTransactionClosed(0);
return $this;
}
示例6: _placeOrder
/**
* Place an order with authorization or capture action
*
* @param Mage_Sales_Model_Order_Payment $payment
* @param float $amount
* @return CLS_Paypal_Model_Paypal_Method_Orderstored_Agreement
*/
protected function _placeOrder(Mage_Sales_Model_Order_Payment $payment, $amount)
{
$order = $payment->getOrder();
$api = $this->_pro->getApi()->setReferenceId($payment->getBillingAgreementId())->setPaymentAction($this->_pro->getConfig()->paymentAction)->setAmount($amount)->setNotifyUrl(Mage::getUrl('paypal/ipn/'))->setPaypalCart(Mage::getModel('paypal/cart', array($order)))->setIsLineItemsEnabled($this->_pro->getConfig()->lineItemsEnabled)->setInvNum($order->getIncrementId());
// call api and import transaction and other payment information
$api->callDoReferenceTransaction();
$this->_pro->importPaymentInfo($api, $payment);
$api->callGetTransactionDetails();
$this->_pro->importPaymentInfo($api, $payment);
$payment->setTransactionId($api->getTransactionId())->setIsTransactionClosed(0);
return $this;
}
示例7: addNewTransaction
/**
* Magento $payment->addTransaction(...) needs the transaction_id = id from the transaction entry or string!
*
* @param Mage_Sales_Model_Order_Payment $payment
* @param string $type
* @param Mage_Sales_Model_Abstract $salesDocument
* @param bool $failsafe
* @param string $message
* @return null|Mage_Sales_Model_Order_Payment_Transaction
*/
public function addNewTransaction(Mage_Sales_Model_Order_Payment $payment, $type, $salesDocument = null, $failsafe = false, $message = false)
{
$transaction = null;
try {
$addInformation = $payment->getAdditionalInformation();
$payment->setTransactionId($addInformation['transactionId'] . '-' . $type);
$transaction = $payment->addTransaction($type, $salesDocument, $failsafe, $message);
$transaction->save();
} catch (Exception $e) {
Mage::logException($e);
}
return $transaction;
}
示例8: _place
public function _place(Mage_Sales_Model_Order_Payment $payment, $amount)
{
try {
$order = $payment->getOrder();
$azpay = new AZPay($this->_merchantId, $this->_merchantKey);
$azpay->curl_timeout = 60;
$azpay->config_order['reference'] = $order->getRealOrderId();
$azpay->config_order['totalAmount'] = Mage::helper('azpay')->formatAmount($amount);
$azpay->config_options['urlReturn'] = Mage::getUrl('azpay/transaction_boleto/postback');
/*$azpay->config_boleto['acquirer'] = $this->getConfigData('operator');
$azpay->config_boleto['expire'] = $this->_generateExpirationDate();
$azpay->config_boleto['nrDocument'] = substr($order->getRealOrderId(), 1);
$azpay->config_boleto['amount'] = Mage::helper('azpay')->formatAmount($amount);
$azpay->config_boleto['instructions'] = $this->getConfigData('instructions');*/
$azpay->config_online_debit['acquirer'] = $this->getConfigData('operator');
$billingAddress = $order->getBillingAddress();
if ($order->getCustomerTaxvat()) {
$azpay->config_billing['customerIdentity'] = $order->getCustomerTaxvat();
} else {
$azpay->config_billing['customerIdentity'] = $order->getRealOrderId();
}
$azpay->config_billing['name'] = $order->getCustomerName();
$azpay->config_billing['address'] = $billingAddress->getStreet(1) . ',' . $billingAddress->getStreet(2);
$azpay->config_billing['address2'] = $billingAddress->getStreet(3) ? $billingAddress->getStreet(3) : '';
$azpay->config_billing['city'] = $billingAddress->getCity();
$azpay->config_billing['state'] = $billingAddress->getRegionCode();
$azpay->config_billing['postalCode'] = Zend_Filter::filterStatic($billingAddress->getPostcode(), 'Digits');
$azpay->config_billing['phone'] = Mage::helper('azpay')->splitTelephone($billingAddress->getTelephone());
$azpay->config_billing['email'] = $order->getCustomerEmail();
$azpay->config_options['urlReturn'] = Mage::getUrl('azpay/transaction_boleto/postback');
// Execute
$azpay->online_debit()->execute();
$azpay->getXml();
// usado para salvar o XML gerado no log
// Log
if ($this->getConfigData('log')) {
Mage::log($azpay, null, "azpay_boleto.log");
}
} catch (AZPay_Error $e) {
Mage::log($e->getMessage(), null, "azpay_boleto_error.log");
$error = $azpay->responseError();
return Mage::throwException("Ocorreu um problema com o seu pedido. Tente novamente ou entre em contato conosco informando este código: " . $error['status_message']);
}
// Response
$gateway_response = $azpay->response();
$paymentDetails['azpayboletourl'] = (string) $gateway_response->processor->Transfer->urlTransfer;
$payment->setAdditionalData(serialize($paymentDetails));
// azpay info
$payment->setAzpayTransactionId($gateway_response->transactionId)->setAzpayBoletoUrl((string) $gateway_response->processor->Transfer->urlTransfer);
return $this;
}
示例9: getVaultParams
/**
* @param Mage_Sales_Model_Order_Payment $payment
* @return array
*/
protected function getVaultParams($payment)
{
$params = array();
$params['card_number'] = $payment->getCcNumber();
$params['card_expiry_month'] = $payment->getCcExpMonth() < 10 ? '0' . $payment->getCcExpMonth() : $payment->getCcExpMonth();
$params['card_expiry_year'] = $payment->getCcExpYear();
$params['cvc'] = $payment->getCcCid();
$params['multi_use'] = 1;
//Add card holder
$billing = $payment->getOrder()->getBillingAddress();
$defaultOwner = $billing->getFirstname() && $billing->getLastname() ? $billing->getFirstname() . ' ' . $billing->getLastname() : $billing->getEmail();
$params['card_holder'] = $payment->getCcOwner() ? $payment->getCcOwner() : $defaultOwner;
$this->_debug($params);
return $params;
}
示例10: cancel
/**
* Order cancellation hook for payment method instance
* Adds void transaction if needed
* @return Mage_Sales_Model_Order_Payment
*/
public function cancel()
{
if ($this->getMethodInstance()->getCode() == Braintree_Payments_Model_Creditcard::PAYMENT_METHOD_CODE) {
Mage::register(self::REGISTRY_KEY_CANCEL, true);
}
return parent::cancel();
}
示例11: _beforeSave
/**
* Verify data required for saving
* @return Mage_Sales_Model_Order_Payment_Transaction
* @throws Mage_Core_Exception
*/
protected function _beforeSave()
{
// set parent id
$this->_verifyPaymentObject();
$this->setPaymentId($this->_paymentObject->getId())->setOrderId($this->getOrderId());
return parent::_beforeSave();
}
示例12: _place
public function _place(Mage_Sales_Model_Order_Payment $payment, $amount)
{
$order = $payment->getOrder();
$customer = Mage::helper('pagarme')->getCustomerInfoFromOrder($payment->getOrder());
$data = new Varien_Object();
$data->setPaymentMethod(Inovarti_Pagarme_Model_Api::PAYMENT_METHOD_BOLETO)->setAmount(Mage::helper('pagarme')->formatAmount($amount))->setBoletoExpirationDate($this->_generateExpirationDate())->setCustomer($customer)->setPostbackUrl(Mage::getUrl('pagarme/transaction_boleto/postback'));
$pagarme = Mage::getModel('pagarme/api');
$transaction = $pagarme->charge($data);
if ($transaction->getErrors()) {
$messages = array();
foreach ($transaction->getErrors() as $error) {
$messages[] = $error->getMessage() . '.';
}
Mage::throwException(implode("\n", $messages));
}
// pagar.me info
$payment->setPagarmeTransactionId($transaction->getId())->setPagarmeBoletoUrl($transaction->getBoletoUrl())->setPagarmeBoletoBarcode($transaction->getBoletoBarcode())->setPagarmeBoletoExpirationDate($transaction->getBoletoExpirationDate());
return $this;
}
示例13: testGetTotalsHtml
/**
* @magentoAppIsolation enabled
*/
public function testGetTotalsHtml()
{
$order = new Mage_Sales_Model_Order();
Mage::register('current_order', $order);
$payment = new Mage_Sales_Model_Order_Payment();
$payment->setMethod('checkmo');
$order->setPayment($payment);
$layout = new Mage_Core_Model_Layout();
$block = new Mage_Sales_Block_Order_Print_Creditmemo();
$layout->addBlock($block, 'block');
$childBlock = $layout->addBlock('Mage_Core_Block_Text', 'creditmemo_totals', 'block');
$expectedHtml = '<b>Any html</b>';
$creditmemo = new Mage_Sales_Model_Order_Creditmemo();
$this->assertEmpty($childBlock->getCreditmemo());
$this->assertNotEquals($expectedHtml, $block->getTotalsHtml($creditmemo));
$childBlock->setText($expectedHtml);
$actualHtml = $block->getTotalsHtml($creditmemo);
$this->assertSame($creditmemo, $childBlock->getCreditmemo());
$this->assertEquals($expectedHtml, $actualHtml);
}
示例14: _beforeSave
/**
* Verify data required for saving
* @return Mage_Sales_Model_Order_Payment_Transaction
* @throws Mage_Core_Exception
*/
protected function _beforeSave()
{
// set parent id
$this->_verifyPaymentObject();
if (!$this->getId()) {
// We need to set order and payment ids only for new transactions
if (null !== $this->_paymentObject) {
$this->setPaymentId($this->_paymentObject->getId());
}
if (null !== $this->_order) {
$this->setOrderId($this->_order->getId());
}
$this->setCreatedAt(Mage::getModel('core/date')->gmtDate());
}
return parent::_beforeSave();
}
示例15: importOrderPayment
/**
* Import payment data to billing agreement
*
* $payment->getBillingAgreementData() contains array with following structure :
* [billing_agreement_id] => string
* [method_code] => string
*
* @param Mage_Sales_Model_Order_Payment $payment
* @return Mage_Sales_Model_Billing_Agreement
*/
public function importOrderPayment(Mage_Sales_Model_Order_Payment $payment)
{
$baData = $payment->getBillingAgreementData();
$this->_paymentMethodInstance = isset($baData['method_code']) ? Mage::helper('payment')->getMethodInstance($baData['method_code']) : $payment->getMethodInstance();
if ($this->_paymentMethodInstance) {
$this->_paymentMethodInstance->setStore($payment->getMethodInstance()->getStore());
$this->setCustomerId($payment->getOrder()->getCustomerId())->setMethodCode($this->_paymentMethodInstance->getCode())->setReferenceId($baData['billing_agreement_id'])->setStatus(self::STATUS_ACTIVE);
}
return $this;
}