本文整理汇总了PHP中Mage_Payment_Model_Method_Abstract::authorize方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Payment_Model_Method_Abstract::authorize方法的具体用法?PHP Mage_Payment_Model_Method_Abstract::authorize怎么用?PHP Mage_Payment_Model_Method_Abstract::authorize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Payment_Model_Method_Abstract
的用法示例。
在下文中一共展示了Mage_Payment_Model_Method_Abstract::authorize方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: authorize
public function authorize(Varien_Object $payment, $amount)
{
parent::authorize($payment, $amount);
$payment->setIsTransactionClosed(false);
Mage::helper('assist')->debug('authorize');
return $this;
}
示例2: authorize
/**
* Authorize (Preauthroization)
*
* @param Varien_Object $orderPayment
* @return Mage_Payment_Model_Abstract
*/
public function authorize(Varien_Object $payment, $amount)
{
parent::authorize($payment, $amount);
$order = $payment->getOrder();
$options = array('transactionData' => array('trxAmount' => round($amount * 100), 'trxCurrency' => $order->getBaseCurrencyCode(), 'invoiceText' => $this->_getInvoiceText($order), 'trxUserComment' => $order->getRealOrderId() . '-' . $order->getQuoteId(), 'shopperId' => $order->getRealOrderId()));
$this->_processRequest('preAuthorize', $options, $payment);
return $this;
}
示例3: authorize
/**
* @param Mage_Sales_Model_Order_Payment $payment
* @param float $amount
* @return $this|Mage_Payment_Model_Abstract
*/
public function authorize(Varien_Object $payment, $amount)
{
parent::authorize($payment, $amount);
if ($amount <= 0) {
Mage::log('Expected amount for transaction is zero or below', Zend_Log::ERR, self::$logFile);
Mage::throwException(Mage::helper('pinpay')->__('Invalid amount for authorization.'));
}
if (Mage::app()->getStore()->isAdmin() && !is_null($payment->getAdditionalInformation('offline_transaction_id'))) {
$this->_placeOfflineTransaction($payment, $amount);
} else {
$request = $this->_buildRequest($payment, $amount, $this->getCustomerEmail());
$this->_place($payment, self::REQUEST_TYPE_AUTH_ONLY, $request);
$payment->setIsTransactionClosed(false);
}
return $this;
}
示例4: authorize
/**
* Authorizes a transaction
* @param Varien_Object $payment
* @param float $amount
* @return Mage_Payment_Model_Method_Abstract
*/
public function authorize(Varien_Object $payment, $amount)
{
parent::authorize($payment, $amount);
$session = Mage::getSingleton('checkout/session');
$order = $payment->getOrder();
$ebanx = Mage::app()->getRequest()->getParam('ebanx');
Mage::log('Authorizing order [' . $order->getApiOrderId() . ']');
$birthDate = str_pad($ebanx['birth_day'], 2, '0', STR_PAD_LEFT) . '/' . str_pad($ebanx['birth_month'], 2, '0', STR_PAD_LEFT) . '/' . $ebanx['birth_year'];
// Street number workaround
$streetNumber = preg_replace('/[\\D]/', '', $order->getBillingAddress()->getData('street'));
$streetNumber = $streetNumber > 0 ? $streetNumber : '1';
// Defines the order ID, if in test append time() to avoid errors
$testMode = intval(Mage::getStoreConfig('payment/ebanx/testing')) == 1;
$orderId = $order->getIncrementId() . ($testMode ? time() : '');
// Cut order ID in test mode
if (strlen($orderId) > 20 && $testMode) {
$orderId = substr($orderId, 0, 20);
}
// Gets the currency code and total
// Backend/base currency
if (Mage::getStoreConfig('payment/ebanx_express/paymentcurrency') == 'base') {
$amountTotal = $order->getBaseGrandTotal();
$currencyCode = $order->getBaseCurrencyCode();
} else {
$amountTotal = $order->getGrandTotal();
$currencyCode = $order->getOrderCurrency()->getCurrencyCode();
}
// On guest checkout, get billing email address
$email = $order->getCustomerEmail() ?: $order->getBillingAddress()->getEmail();
$state = $order->getBillingAddress()->getRegionCode();
if (strlen($state) > 2) {
$state = 'PR';
}
$ccExpiration = str_pad($ebanx['cc_expiration_month'], 2, '0', STR_PAD_LEFT) . '/' . $ebanx['cc_expiration_year'];
$params = array('mode' => 'full', 'operation' => 'request', 'payment' => array('name' => $order->getCustomerFirstname() . ' ' . $order->getCustomerLastname(), 'document' => $ebanx['cpf'], 'birth_date' => $birthDate, 'email' => $email, 'phone_number' => $order->getBillingAddress()->getTelephone(), 'currency_code' => $currencyCode, 'amount_total' => $amountTotal, 'payment_type_code' => $ebanx['cc_type'], 'merchant_payment_code' => $orderId, 'order_number' => $order->getIncrementId(), 'zipcode' => $order->getBillingAddress()->getData('postcode'), 'address' => $order->getBillingAddress()->getData('street'), 'street_number' => $streetNumber, 'city' => $order->getBillingAddress()->getData('city'), 'state' => $state, 'country' => 'br', 'creditcard' => array('card_name' => $ebanx['cc_name'], 'card_number' => $ebanx['cc_number'], 'card_cvv' => $ebanx['cc_cvv'], 'card_due_date' => $ccExpiration)));
// If has installments, adjust total
if (isset($ebanx['installments'])) {
if (intval($ebanx['installments']) > 1) {
$interestRate = floatval(Mage::getStoreConfig('payment/ebanx_express/interest_installments'));
$interestMode = Mage::getStoreConfig('payment/ebanx_express/installments_mode');
$params['payment']['instalments'] = intval($ebanx['installments']);
$params['payment']['amount_total'] = Ebanx_Express_Utils::calculateTotalWithInterest($interestMode, $interestRate, $amountTotal, intval($ebanx['installments']));
}
}
try {
// Set DirectMode as true
\Ebanx\Config::setDirectMode(true);
$response = \Ebanx\Ebanx::doRequest($params);
Mage::log('Authorizing order [' . $order->getIncrementId() . '] - calling EBANX');
if (!empty($response) && $response->status == 'SUCCESS') {
$hash = $response->payment->hash;
// Add the EBANX hash in the order data
$order->getPayment()->setData('ebanx_hash', $hash)->save();
// Redirect to bank page if the client chose TEF
if (isset($response->redirect_url)) {
$_SESSION['ebxRedirectUrl'] = $response->redirect_url;
} else {
$_SESSION['ebxRedirectUrl'] = Mage::getUrl('checkout/onepage/success') . '?hash=' . $hash;
}
Mage::log('Authorizing order [' . $order->getIncrementId() . '] - success');
} else {
Mage::log('Authorizing order [' . $order->getIncrementId() . '] - error: ' . $response->status_message);
Mage::throwException($this->getEbanxErrorMessage($response->status_code));
}
} catch (Exception $e) {
Mage::throwException($e->getMessage());
}
return $this;
}
示例5: authorize
/**
* Authorize
*
* @param Varien_Object $orderPayment
* @return Mage_Payment_Model_Abstract
*/
public function authorize(Varien_Object $payment, $amount)
{
parent::authorize($payment, $amount);
return $this;
}
示例6: authorize
/**
* Authorizes a transaction
* @param Varien_Object $payment
* @param float $amount
* @return Mage_Payment_Model_Method_Abstract
*/
public function authorize(Varien_Object $payment, $amount)
{
parent::authorize($payment, $amount);
$country = strtolower($payment->getOrder()->getBillingAddress()->getCountry());
$session = Mage::getSingleton('checkout/session');
$order = $payment->getOrder();
Mage::log('Authorizing order [' . $order->getApiOrderId() . ']');
// Street number workaround
$streetNumber = preg_replace('/[\\D]/', '', $order->getBillingAddress()->getData('street'));
$streetNumber = $streetNumber > 0 ? $streetNumber : '1';
// Defines the order ID, if in test append time() to avoid errors
$testMode = intval(Mage::getStoreConfig('payment/ebanx/testing')) == 1;
$orderId = $order->getIncrementId() . ($testMode ? time() : '');
// Cut order ID in test mode
if (strlen($orderId) > 20 && $testMode) {
$orderId = substr($orderId, 0, 20);
}
// Gets the currency code and total
// Backend/base currency
if (Mage::getStoreConfig('payment/ebanx_standard/paymentcurrency') == 'base') {
$amountTotal = $order->getBaseGrandTotal();
$currencyCode = $order->getBaseCurrencyCode();
} else {
$amountTotal = $order->getGrandTotal();
$currencyCode = $order->getOrderCurrency()->getCurrencyCode();
}
$dueDate = date('d/m/Y', strtotime('+' . intval(Mage::getStoreConfig('payment/ebanx_standard/due_date')) . $dueDays . 'days'));
// On guest checkout, get billing email address
$email = $order->getCustomerEmail() ?: $order->getBillingAddress()->getEmail();
$params = array('name' => $order->getCustomerFirstname() . ' ' . $order->getCustomerLastname(), 'email' => $email, 'phone_number' => $order->getBillingAddress()->getTelephone(), 'currency_code' => $currencyCode, 'amount' => $amountTotal, 'payment_type_code' => '_all', 'merchant_payment_code' => $orderId, 'due_date' => $dueDate, 'order_number' => $order->getIncrementId(), 'zipcode' => $order->getBillingAddress()->getData('postcode'), 'address' => $order->getBillingAddress()->getData('street'), 'street_number' => $streetNumber, 'city' => $order->getBillingAddress()->getData('city'), 'state' => $order->getBillingAddress()->getRegionCode(), 'country' => strtolower($order->getBillingAddress()->getCountry()));
try {
$response = \Ebanx\Ebanx::doRequest($params);
Mage::log('Authorizing order [' . $order->getIncrementId() . '] - calling EBANX');
if (!empty($response) && $response->status == 'SUCCESS') {
$hash = $response->payment->hash;
// Add the EBANX hash in the order data
$order->getPayment()->setData('ebanx_hash', $hash)->save();
// Redirect to bank page if the client chose TEF
if (isset($response->redirect_url)) {
$_SESSION['ebxRedirectUrl'] = $response->redirect_url;
} else {
$_SESSION['ebxRedirectUrl'] = Mage::getUrl('checkout/onepage/success') . '?hash=' . $hash;
}
Mage::log('Authorizing order [' . $order->getIncrementId() . '] - success');
} else {
Mage::log('Authorizing order [' . $order->getIncrementId() . '] - error: ' . $response->status_message);
Mage::throwException($this->getEbanxErrorMessage($response->status_code));
}
} catch (Exception $e) {
Mage::throwException($e->getMessage());
}
return $this;
}
示例7: authorize
/**
* In the backend it means Authorize only
* @param Varien_Object $payment
* @param unknown_type $amount
*/
public function authorize(Varien_Object $payment, $amount)
{
parent::authorize($payment, $amount);
$payment->setLastTransId($this->getTransactionId())->setIsTransactionPending(true);
if ($this->getCode() == 'adyen_boleto' || $this->getCode() == 'adyen_cc' || $this->getCode() == 'adyen_oneclick' || $this->getCode() == 'adyen_elv' || $this->getCode() == 'adyen_sepa') {
$_authorizeResponse = $this->_processRequest($payment, $amount, "authorise");
}
return $this;
}
示例8: authorize
/**
* In the backend it means Authorize only
* @param Varien_Object $payment
* @param $amount
* @return $this
*/
public function authorize(Varien_Object $payment, $amount)
{
parent::authorize($payment, $amount);
$payment->setLastTransId($this->getTransactionId())->setIsTransactionPending(true);
$order = $payment->getOrder();
// by zero authentication payment is authorised when api responds is succesfull
if ($order->getGrandTotal() == 0) {
$payment->setIsTransactionPending(false);
}
/*
* Do not send a email notification when order is created.
* Only do this on the AUHTORISATION notification.
* For Boleto send it on order creation
*/
if ($this->getCode() != 'adyen_boleto') {
$order->setCanSendNewEmailFlag(false);
}
if ($this->getCode() == 'adyen_boleto' || $this->getCode() == 'adyen_cc' || substr($this->getCode(), 0, 14) == 'adyen_oneclick' || $this->getCode() == 'adyen_elv' || $this->getCode() == 'adyen_sepa') {
if (substr($this->getCode(), 0, 14) == 'adyen_oneclick') {
// set payment method to adyen_oneclick otherwise backend can not view the order
$payment->setMethod("adyen_oneclick");
$recurringDetailReference = $payment->getAdditionalInformation("recurring_detail_reference");
// load agreement based on reference_id (option to add an index on reference_id in database)
$agreement = Mage::getModel('sales/billing_agreement')->load($recurringDetailReference, 'reference_id');
// agreement could be a empty object
if ($agreement && $agreement->getAgreementId() > 0 && $agreement->isValid()) {
$agreement->addOrderRelation($order);
$agreement->setIsObjectChanged(true);
$order->addRelatedObject($agreement);
$message = Mage::helper('adyen')->__('Used existing billing agreement #%s.', $agreement->getReferenceId());
$comment = $order->addStatusHistoryComment($message);
$order->addRelatedObject($comment);
}
}
$_authorizeResponse = $this->_processRequest($payment, $amount, "authorise");
}
return $this;
}
示例9: authorize
public function authorize(Varien_Object $payment, $amount)
{
parent::authorize($payment, $amount);
if (!$payment->getPoNumber()) {
Mage::throwException(Mage::helper('moneybookerspsp')->__('Moneybookers transaction failed: account data is missing.'));
}
$params = $this->_initRequestParams();
$params['PAYMENT.CODE'] = $this->_getPaymentCode(self::PAYMENT_TYPE_PREAUTHORIZE);
$params['TRANSACTION.RESPONSE'] = 'ASYNC';
// make API call
$response = $this->_getApi()->request($params);
$this->_processResponse($params, $response, $payment);
return $this;
}
示例10: authorize
public function authorize(Varien_Object $payment, $amount)
{
parent::authorize($payment, $amount);
$payment->setSkipTransactionCreation(true);
return $this;
}
示例11: authorize
/**
* Gets Excecuted when the checkout button is pressed.
* @param Varien_Object $payment
* @param float $amount
* @throws Exception
*/
public function authorize(Varien_Object $payment, $amount)
{
$token = Mage::getSingleton('core/session')->getToken();
if (empty($token)) {
Mage::helper('paymill/loggingHelper')->log("No token found.");
Mage::throwException("There was an error processing your payment.");
}
if (Mage::helper('paymill/optionHelper')->isPreAuthorizing() && $this->_code === "paymill_creditcard") {
Mage::helper('paymill/loggingHelper')->log("Starting payment process as preAuth");
$this->_preauthFlag = true;
} else {
Mage::helper('paymill/loggingHelper')->log("Starting payment process as debit");
$this->_preauthFlag = false;
}
$success = $this->payment($payment, $amount);
if (!$success) {
Mage::helper('paymill/loggingHelper')->log(Mage::helper("paymill/paymentHelper")->getErrorMessage($this->_errorCode));
Mage::getSingleton('checkout/session')->setGotoSection('payment');
Mage::throwException(Mage::helper("paymill/paymentHelper")->getErrorMessage($this->_errorCode));
}
//Finish as usual
return parent::authorize($payment, $amount);
}