本文整理汇总了PHP中Mage_Payment_Model_Method_Abstract::initialize方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Payment_Model_Method_Abstract::initialize方法的具体用法?PHP Mage_Payment_Model_Method_Abstract::initialize怎么用?PHP Mage_Payment_Model_Method_Abstract::initialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Payment_Model_Method_Abstract
的用法示例。
在下文中一共展示了Mage_Payment_Model_Method_Abstract::initialize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initialize
public function initialize($paymentAction, $stateObject)
{
parent::initialize($paymentAction, $stateObject);
if ($paymentAction != 'sale') {
return $this;
}
// Set the default state of the new order.
$state = Mage_Sales_Model_Order::STATE_PENDING_PAYMENT;
// state now = 'pending_payment'
$stateObject->setState($state);
$stateObject->setStatus($state);
$stateObject->setIsNotified(false);
//Retrieve cart/quote information.
$sessionCheckout = Mage::getSingleton('checkout/session');
$quoteId = $sessionCheckout->getQuoteId();
// obtiene el quote para informacion de la orden
$quote = Mage::getModel("sales/quote")->load($quoteId);
$grandTotal = $quote->getData('grand_total');
$subTotal = $quote->getSubtotal();
$shippingHandling = $grandTotal - $subTotal;
$convertQuote = Mage::getSingleton('sales/convert_quote');
$order = $convertQuote->toOrder($quote);
$orderNumber = $order->getIncrementId();
// obtener datos del pago en info y asignar monto total
$infoIntance = $this->getInfoInstance();
$info = unserialize($infoIntance->getAdditionalData());
$info['idPedido'] = $orderNumber;
$info['prod'] = trim($this->getConfigData('prod'));
$info['idSucursal'] = trim($this->getConfigData('sucursalkey'));
$info['idUsuario'] = trim($this->getConfigData('usuariokey'));
$info['monto'] = $grandTotal;
$info['ipBuyer'] = $_SERVER['REMOTE_ADDR'];
$info['noMail'] = (int) trim($this->getConfigData('notify')) == 1 ? 0 : 1;
$info['plan'] = (int) trim($this->getConfigData('msi')) == 1 ? $info['mensualidades'] == '00' ? 'NOR' : 'MSI' : 'NOR';
// enviar pago
try {
$Api = new Pagofacil_Pagofacildirect_Model_Api();
$response = $Api->payment($info);
} catch (Exception $error) {
Mage::throwException($error->getMessage());
}
// respuesta del servicio
if ($response == null) {
Mage::throwException("El servicio de PagoFacil no se encuentra");
}
if ($response['autorizado'] == '0') {
$errorMessage = $response['texto'] . "\n";
if (is_array($response['error'])) {
$errorMessage .= implode("\n", array_values($response['error']));
}
Mage::throwException($errorMessage);
}
return $this;
}
示例2: initialize
public function initialize($paymentAction, $stateObject)
{
parent::initialize($paymentAction, $stateObject);
if ($paymentAction != 'sale') {
return $this;
}
// Set the default state of the new order.
$state = Mage_Sales_Model_Order::STATE_PENDING_PAYMENT;
// state now = 'pending_payment'
$stateObject->setState($state);
$stateObject->setStatus($state);
$stateObject->setIsNotified(false);
//Retrieve cart/quote information.
$sessionCheckout = Mage::getSingleton('checkout/session');
$quoteId = $sessionCheckout->getQuoteId();
// obtiene el quote para informacion de la orden
$quote = Mage::getModel("sales/quote")->load($quoteId);
$grandTotal = $quote->getData('grand_total');
$subTotal = $quote->getSubtotal();
$shippingHandling = $grandTotal - $subTotal;
$convertQuote = Mage::getSingleton('sales/convert_quote');
$order = $convertQuote->toOrder($quote);
$orderNumber = $order->getIncrementId();
$order1 = Mage::getModel('sales/order')->loadByIncrementId($orderNumber);
// obtener el nombre de cada uno de los items y concatenarlos
foreach ($order1->getAllItems() as $item) {
$name .= $item->getName();
}
// obtener datos del pago en info y asignar monto total
$infoIntance = $this->getInfoInstance();
$info = unserialize($infoIntance->getAdditionalData());
$info['prod'] = trim($this->getConfigData('prod'));
$info['order_id'] = $orderNumber;
$info['branch_key'] = trim($this->getConfigData('sucursalkey'));
$info['user_key'] = trim($this->getConfigData('usuariokey'));
$info['amount'] = $grandTotal;
$info['product'] = $name;
// enviar pago
try {
$Api = new Pagofacil_Pagofacildirect_Model_Api();
$response = $Api->paymentCash($info);
} catch (Exception $error) {
Mage::throwException($error->getMessage());
}
// respuesta del servicio
if ($response == null) {
Mage::throwException("El servicio de PagoFacil Efectivo no se encuentra disponible.");
}
if ($response['error'] == '1') {
$errorMessage = $response['message'] . "\n";
if (is_array($response['error'])) {
$errorMessage .= implode("\n", array_values($response['error']));
}
Mage::throwException($errorMessage);
} else {
//Se almacenan los datos de la respuesta en session para posteriormente mostrarlos en el success.
$convenience_store = $response['charge']['convenience_store'];
$store_fixed_rate = $response['charge']['store_fixed_rate'];
$store_schedule = $response['charge']['store_schedule'];
$store_image = $response['charge']['store_image'];
$bank_account_number = $response['charge']['bank_account_number'];
$bank = $response['charge']['bank'];
$expiration_date = $response['charge']['expiration_date'];
$amount = $response['charge']['amount'];
$reference = $response['charge']['reference'];
Mage::getSingleton('core/session')->setConvenienceStore($convenience_store);
Mage::getSingleton('core/session')->setStoreFixedRate($store_fixed_rate);
Mage::getSingleton('core/session')->setStoreSchedule($store_schedule);
Mage::getSingleton('core/session')->setStoreImage($store_image);
Mage::getSingleton('core/session')->setBankAccountNumber($bank_account_number);
Mage::getSingleton('core/session')->setBank($bank);
Mage::getSingleton('core/session')->setExpirationDate($expiration_date);
Mage::getSingleton('core/session')->setAmount($amount);
Mage::getSingleton('core/session')->setReference($reference);
Mage::getSingleton('core/session')->setNameItem($name);
}
return $this;
}
示例3: initialize
/**
* Inicializa o método de pagamento. Chamado quando a compra é completa.
* Objeto Order será criado após a chamada deste método.
*
* @param string $paymentAction
* @param Varien_Object $stateObject
* @return Mage_Payment_Model_Abstract
* @throws Mage_Payment_Model_Info_Exception
*/
public function initialize($paymentAction, $stateObject)
{
//Mage::helper("bcash")->saveLog('Called ' . __METHOD__ . ' with payment ' . $paymentAction);
//Mage::helper("bcash")->saveLog('Payment Onlinetransfer visitor: ' . Mage::helper('core/http')->getRemoteAddr());
parent::initialize($paymentAction, $stateObject);
if ($paymentAction != 'sale') {
return $this;
}
$state = Mage_Sales_Model_Order::STATE_PENDING_PAYMENT;
$stateObject->setState($state);
$stateObject->setStatus(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT);
$stateObject->setIsNotified(false);
try {
$result = $this->_customBeginPayment();
$response = $result['response'];
$payment_method = $result['payment_method'];
$installments = $result['installments'];
/*
1 – Em andamento
3 – Aprovada
4 – Concluída
5 – Disputa
6 – Devolvida
7 – Cancelada
8 – Chargeback
*/
// Salvar o PEDIDO em caso de SUCESSO e adicionar os dados da Transação
if ($response->status != 1 && $response->status != 2) {
$setIsNotified = false;
switch ($response->status) {
case 3:
//3 – Aprovada
//3 – Aprovada
case 4:
//4 – Concluída
$state = Mage_Sales_Model_Order::STATE_PROCESSING;
$setIsNotified = true;
break;
case 6:
//6 – Devolvida
$state = Mage_Sales_Model_Order::STATE_HOLDED;
break;
case 7:
//7 – Cancelada
//7 – Cancelada
case 8:
//8 – Chargeback
$state = Mage_Sales_Model_Order::STATE_CANCELED;
break;
default:
$state = null;
break;
}
if (!is_null($state)) {
$stateObject->setState($state);
$stateObject->setStatus($state);
$stateObject->setIsNotified($setIsNotified);
}
}
Mage::getSingleton('core/session')->setTransactionIdBcash($response->transactionId);
Mage::getSingleton('core/session')->setStatusBcash($response->status);
Mage::getSingleton('core/session')->setDescriptionStatusBcash(urldecode($response->descriptionStatus));
Mage::getSingleton('core/session')->setPaymentLinkBcash(isset($response->paymentLink) ? urldecode($response->paymentLink) : null);
Mage::getSingleton('core/session')->setPaymentMethodBcash($payment_method);
Mage::getSingleton('core/session')->setInstallmentsBcash($installments);
$cart = Mage::getSingleton('checkout/cart')->getQuote();
$cart->setTransactionIdBcash($response->transactionId)->setStatusBcash($response->status)->setDescriptionStatusBcash(urldecode($response->descriptionStatus))->setPaymentLinkBcash(isset($response->paymentLink) ? urldecode($response->paymentLink) : null)->setPaymentMethodBcash($payment_method)->setInstallmentsBcash($installments);
$cart->save();
} catch (Exception $e) {
Mage::helper("bcash")->saveLog("Exception: Model_Onlinetransfer->initialize: " . $e->getMessage());
throw new Mage_Payment_Model_Info_Exception($e->getMessage());
}
return $this;
}
示例4: initialize
/**
* Initulaize the sofort payment and set the redirect url
*
* @param string $paymentAction
* @param Varien_Object $stateObject
* @return \Paymentnetwork_Pnsofortueberweisung_Model_Method_Sofort
*/
public function initialize($paymentAction, $stateObject)
{
parent::initialize($paymentAction, $stateObject);
$communication = Mage::getModel('Paymentnetwork_Pnsofortueberweisung_Model_Service_Communication');
$communication->paymentRequest();
$url = $communication->getUrl();
Mage::getSingleton('customer/session')->setPaymentUrl($url);
$this->getInfoInstance()->setAdditionalInformation('sofort_transaction_id', $communication->getTransactionId());
return $this;
}