Skip to content

Commit

Permalink
- add POA standard birthday validation as option
Browse files Browse the repository at this point in the history
- send order new email even if the payment is on pending, but do not create invoice
- code review
  • Loading branch information
larisagroza committed Nov 3, 2014
1 parent 17211e2 commit 9698247
Show file tree
Hide file tree
Showing 38 changed files with 360 additions and 836 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ protected function _construct() {
parent::_construct();
$mark = Mage::getConfig()->getBlockClassName('core/template');
$mark = new $mark;
$mark->setTemplate('hypercharge/form/cc_mark.phtml'); // known issue: code above will render only static mark image
$mark->setTemplate('hypercharge/form/cc_mark.phtml');
$mark->setMethodLabel(Mage::getStoreConfig('payment/hypercharge_mobile_cc/title'));
$this->setTemplate('hypercharge/form/cc.phtml')
->setMethodTitle('') // Output mark, omit title
->setMethodTitle('')
->setMethodLabelAfterHtml($mark->toHtml());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ protected function _construct() {
parent::_construct();
$mark = Mage::getConfig()->getBlockClassName('core/template');
$mark = new $mark;
$mark->setTemplate('hypercharge/form/giropay_mark.phtml'); // known issue: code above will render only static mark image
$mark->setTemplate('hypercharge/form/giropay_mark.phtml');
$mark->setMethodLabel(Mage::getStoreConfig('payment/hypercharge_wpf_giropay/title'));
$this->setMethodTitle('') // Output mark, omit title
$this->setMethodTitle('')
->setMethodLabelAfterHtml($mark->toHtml());
return parent::_construct();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ protected function _construct() {
parent::_construct();
$mark = Mage::getConfig()->getBlockClassName('core/template');
$mark = new $mark;
$mark->setTemplate('hypercharge/form/ideal_mark.phtml'); // known issue: code above will render only static mark image
$mark->setTemplate('hypercharge/form/ideal_mark.phtml');
$mark->setMethodLabel(Mage::getStoreConfig('payment/hypercharge_wpf_ideal/title'));
$this->setMethodTitle('') // Output mark, omit title
$this->setMethodTitle('')
->setMethodLabelAfterHtml($mark->toHtml());
return parent::_construct();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ protected function _construct() {
parent::_construct();
$mark = Mage::getConfig()->getBlockClassName('core/template');
$mark = new $mark;
$mark->setTemplate('hypercharge/form/paypal_mark.phtml'); // known issue: code above will render only static mark image
$mark->setTemplate('hypercharge/form/paypal_mark.phtml');
$mark->setMethodLabel(Mage::getStoreConfig('payment/hypercharge_wpf_paypal/title'));
$this->setMethodTitle('') // Output mark, omit title
$this->setMethodTitle('')
->setMethodLabelAfterHtml($mark->toHtml());
return parent::_construct();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ protected function _construct() {
parent::_construct();
$mark = Mage::getConfig()->getBlockClassName('core/template');
$mark = new $mark;
$mark->setTemplate('hypercharge/form/paysafe_mark.phtml'); // known issue: code above will render only static mark image
$mark->setTemplate('hypercharge/form/paysafe_mark.phtml');
$mark->setMethodLabel(Mage::getStoreConfig('payment/hypercharge_wpf_pay_safe/title'));
$this->setMethodTitle('') // Output mark, omit title
$this->setMethodTitle('')
->setMethodLabelAfterHtml($mark->toHtml());
return parent::_construct();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ protected function _construct() {
parent::_construct();
$mark = Mage::getConfig()->getBlockClassName('core/template');
$mark = new $mark;
$mark->setTemplate('hypercharge/form/sofort_mark.phtml'); // known issue: code above will render only static mark image
$mark->setTemplate('hypercharge/form/sofort_mark.phtml');
$mark->setMethodLabel(Mage::getStoreConfig('payment/hypercharge_wpf_sofort/title'));
$this->setMethodTitle('') // Output mark, omit title
$this->setMethodTitle('')
->setMethodLabelAfterHtml($mark->toHtml());
return parent::_construct();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,16 @@ class GlobalExperts_Hypercharge_Block_Info_Cc extends Mage_Payment_Block_Info {
protected $_isCheckoutProgressBlockFlag = true;

protected function _prepareSpecificInformation($transport = null) {
$info = parent::_prepareSpecificInformation($transport);
parent::_prepareSpecificInformation($transport);
$payment = $this->getInfo();
$transport = new Varien_Object();
$paymentInfo = $payment->getAdditionalInformation();

if ($this->htmlEscape($payment->getAdditionalInformation('Last Transaction ID'))) {
$transport->addData(array(
Mage::helper('bithypercharge')->__('Last Transaction ID') => $this->htmlEscape($payment->getAdditionalInformation('Last Transaction ID'))
));
}

if ($this->htmlEscape($payment->getAdditionalInformation('Transaction Status'))) {
$transport->addData(array(
Mage::helper('bithypercharge')->__('Transaction Status') => $this->htmlEscape($payment->getAdditionalInformation('Transaction Status'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
class GlobalExperts_Hypercharge_Block_Response extends Mage_Core_Block_Abstract {

protected function _toHtml() {
$model = Mage::getModel('bithypercharge/cc');
$xml = $model->hyperResponse($this->getRequest()->getPost());
$model = Mage::getModel('bithypercharge/cc');
$post = $this->getRequest()->getPost();
$xml = $model->hyperResponse($post);
if($xml)
return $xml;
return '<?xml version="1.0" encoding="utf-8"?><root />';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ class GlobalExperts_Hypercharge_Block_Wpfresponse extends Mage_Core_Block_Abstra

protected function _toHtml() {
$model = Mage::getModel('bithypercharge/checkout');
$xml = $model->wpfResponse($this->getRequest()->getPost());
$post = $this->getRequest()->getPost();
$xml = $model->wpfResponse($post);
if($xml)
return $xml;
return '<?xml version="1.0" encoding="utf-8"?><root />';
Expand Down
89 changes: 2 additions & 87 deletions app/code/community/GlobalExperts/Hypercharge/Model/Cc.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,15 @@

class GlobalExperts_Hypercharge_Model_Cc extends GlobalExperts_Hypercharge_Model_Mobile {

// unique internal payment method identifier
// @var string [a-z0-9_]
protected $_code = 'hypercharge_mobile_cc';
// Define payment block form
protected $_formBlockType = 'bithypercharge/form_cc';
// Info block type
protected $_infoBlockType = 'bithypercharge/info_cc';
// Can capture funds online?
protected $_canCapture = true;
// Can refund online?
protected $_canRefund = true;
// Can void transactions online?
protected $_canRefund = false;
protected $_canVoid = true;
// Can use this payment method in administration panel?
protected $_canUseInternal = false;
// Can show this payment method as an option on checkout payment page?
protected $_canUseCheckout = true;
// Is this payment method suitable for multi-shipping checkout?
protected $_canUseForMultishipping = false;
// Can save credit card information for future processing?
protected $_canSaveCc = false;

protected $_jsonTransactionType = "";
Expand Down Expand Up @@ -131,8 +120,7 @@ public function void(Varien_Object $payment) {
,$hypercharge_channels[$currency]['pass']
,$mode
);
$channelToken = $hypercharge_channels[$currency]['channel'];


// prepare refund data
$uniqueId = $payment->getAdditionalInformation('unique_id');
$void = Hypercharge\Payment::void($uniqueId);
Expand Down Expand Up @@ -168,77 +156,4 @@ public function cancel(Varien_Object $payment) {
$this->void($payment);
return $this;
}

/**
* refund the amount with transaction id
*
* @param string $payment Varien_Object object
* @return Mage_Paygate_Model_Authorizenet
* @throws Mage_Core_Exception
*/
public function refund(Varien_Object $payment, $amount) {
if ($payment->getRefundTransactionId() && $amount > 0) {
$payment->setAnetTransType(self::REQUEST_TYPE_CREDIT)
->setIsTransactionClosed(0); // open transaction for refunding

// prepare hypercharge gateway channels for calling
$hypercharge_channels = $this->getConfigChannels();
// check if test mode
$test = $this->getConfigData('test');
// set API call mode
if ($test) {
$mode = Hypercharge\Config::ENV_SANDBOX;
} else {
$mode = Hypercharge\Config::ENV_LIVE;
}
// start logging transaction
Mage::helper('bithypercharge')->logger("\n" . str_repeat("*", 80) . "\n Refunding transaction started");
// get current order
$order = $payment->getOrder();
// check if gateway channels are set
if(!$hypercharge_channels) {
Mage::helper('bithypercharge')->logger("\n Channels not configured");
$order->addStatusToHistory($order->getStatus(), 'Channels not configured');
Mage::throwException(Mage::helper('bithypercharge')->__('Channels not configured'));
}
// check if there is a channel for order currency
$currency = $order->getBaseCurrencyCode();
if(!array_key_exists($currency, $hypercharge_channels)) {
Mage::helper('bithypercharge')->logger("\n Currency channel does not exist");
Mage::getSingleton('core/session')->addError('Could not find currency channel in configuration');
$order->addStatusToHistory($order->getStatus(), 'Could not find currency channel in configuration');
Mage::throwException(Mage::helper('bithypercharge')->__('Could not find currency channel in configuration'));
}
// set gateway data
Hypercharge\Config::set(
$hypercharge_channels[$currency]['login']
,$hypercharge_channels[$currency]['pass']
,$mode
);
$channelToken = $hypercharge_channels[$currency]['channel'];

// prepare refund data
$uniqueId = $payment->getAdditionalInformation('unique_id');
$refund = Hypercharge\Payment::refund($uniqueId);

// check if void is approved
if ($refund->unique_id && $refund->status == 'refunded' && !$refund->error) {
Mage::helper('bithypercharge')->logger("Refund transaction approved");
$payment->setTransactionId($refund->unique_id)
->setTransactionType($refund->transaction_type)
->setIsTransactionClosed(1) // refund initiated by merchant
->setStatus(self::STATUS_SUCCESS);
return $this;
// if not, display error and cancel order
} elseif ($refund->unique_id && $refund->error) {
$error = $refund->error;
$errMsg = $error->technical_message;
Mage::helper('bithypercharge')->logger($error->status_code . ': ' . $errMsg);
Mage::throwException(Mage::helper('bithypercharge')->__($errMsg));
}
}
// if no error message, display a generic error message
Mage::throwException(Mage::helper('bithypercharge')->__('Error in refunding the payment.'));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ public function getOrderPlaceRedirectUrl() {
* @return mixed
*/
public function wpfResponse($post) {
Mage::log("response from hyper", null, "hyper-notif.log");
$gate = Mage::helper('bithypercharge/gateway');
$hypercharge_channels = $this->getConfigChannels();
$timestamp = date('Y-m-d H:i:s', time() + 10800);
Expand Down Expand Up @@ -811,10 +812,10 @@ public function wpfResponse($post) {
$order->getPayment()
->setPreparedMessage('Payment not complete yet.')
->setTransactionId($transaction['unique_id'])
->setIsTransactionClosed(0)
->registerPaymentReviewAction(
Mage_Sales_Model_Order_Payment
::REVIEW_ACTION_UPDATE, false);
->setIsTransactionClosed(0);
// ->registerPaymentReviewAction(
// Mage_Sales_Model_Order_Payment
// ::REVIEW_ACTION_UPDATE, false);
if (!$order->getEmailSent()) {
$order->sendNewOrderEmail();
}
Expand Down
91 changes: 3 additions & 88 deletions app/code/community/GlobalExperts/Hypercharge/Model/Debit.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,18 @@

class GlobalExperts_Hypercharge_Model_Debit extends GlobalExperts_Hypercharge_Model_Mobile {

// unique internal payment method identifier
// @var string [a-z0-9_]
protected $_code = 'hypercharge_mobile_debit';
// Define payment block form
protected $_formBlockType = 'bithypercharge/form_debit';
// Info block type
protected $_infoBlockType = 'bithypercharge/info_debit';
// Can capture funds online?
protected $_canCapture = true;
// Can refund online?
protected $_canRefund = true;
// Can void transactions online?
protected $_canRefund = false;
protected $_canVoid = true;
// Can use this payment method in administration panel?
protected $_canUseInternal = false;
// Can show this payment method as an option on checkout payment page?
protected $_canUseCheckout = true;
// Is this payment method suitable for multi-shipping checkout?
protected $_canUseForMultishipping = false;
// Can save credit card information for future processing?
protected $_canSaveCc = false;

protected $_jsonTransactionType = "";

/**
* Payment redirect
*
Expand Down Expand Up @@ -131,8 +120,7 @@ public function void(Varien_Object $payment) {
,$hypercharge_channels[$currency]['pass']
,$mode
);
$channelToken = $hypercharge_channels[$currency]['channel'];


// prepare refund data
$uniqueId = $payment->getAdditionalInformation('unique_id');
$void = Hypercharge\Payment::void($uniqueId);
Expand Down Expand Up @@ -168,77 +156,4 @@ public function cancel(Varien_Object $payment) {
$this->void($payment);
return $this;
}

/**
* refund the amount with transaction id
*
* @param string $payment Varien_Object object
* @return Mage_Paygate_Model_Authorizenet
* @throws Mage_Core_Exception
*/
public function refund(Varien_Object $payment, $amount) {
if ($payment->getRefundTransactionId() && $amount > 0) {
$payment->setAnetTransType(self::REQUEST_TYPE_CREDIT)
->setIsTransactionClosed(0); // open transaction for refunding

// prepare hypercharge gateway channels for calling
$hypercharge_channels = $this->getConfigChannels();
// check if test mode
$test = $this->getConfigData('test');
// set API call mode
if ($test) {
$mode = Hypercharge\Config::ENV_SANDBOX;
} else {
$mode = Hypercharge\Config::ENV_LIVE;
}
// start logging transaction
Mage::helper('bithypercharge')->logger("\n" . str_repeat("*", 80) . "\n Refunding transaction started");
// get current order
$order = $payment->getOrder();
// check if gateway channels are set
if(!$hypercharge_channels) {
Mage::helper('bithypercharge')->logger("\n Channels not configured");
$order->addStatusToHistory($order->getStatus(), 'Channels not configured');
Mage::throwException(Mage::helper('bithypercharge')->__('Channels not configured'));
}
// check if there is a channel for order currency
$currency = $order->getBaseCurrencyCode();
if(!array_key_exists($currency, $hypercharge_channels)) {
Mage::helper('bithypercharge')->logger("\n Currency channel does not exist");
Mage::getSingleton('core/session')->addError('Could not find currency channel in configuration');
$order->addStatusToHistory($order->getStatus(), 'Could not find currency channel in configuration');
Mage::throwException(Mage::helper('bithypercharge')->__('Could not find currency channel in configuration'));
}
// set gateway data
Hypercharge\Config::set(
$hypercharge_channels[$currency]['login']
,$hypercharge_channels[$currency]['pass']
,$mode
);
$channelToken = $hypercharge_channels[$currency]['channel'];

// prepare refund data
$uniqueId = $payment->getAdditionalInformation('unique_id');
$refund = Hypercharge\Payment::refund($uniqueId);

// check if void is approved
if ($refund->unique_id && $refund->status == 'refunded' && !$refund->error) {
Mage::helper('bithypercharge')->logger("Refund transaction approved");
$payment->setTransactionId($refund->unique_id)
->setTransactionType($refund->transaction_type)
->setIsTransactionClosed(1) // refund initiated by merchant
->setStatus(self::STATUS_SUCCESS);
return $this;
// if not, display error and cancel order
} elseif ($refund->unique_id && $refund->error) {
$error = $refund->error;
$errMsg = $error->technical_message;
Mage::helper('bithypercharge')->logger($error->status_code . ': ' . $errMsg);
Mage::throwException(Mage::helper('bithypercharge')->__($errMsg));
}
}
// if no error message, display a generic error message
Mage::throwException(Mage::helper('bithypercharge')->__('Error in refunding the payment.'));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@

class GlobalExperts_Hypercharge_Model_Giropay extends GlobalExperts_Hypercharge_Model_Checkout {

// unique internal payment method identifier
// @var string [a-z0-9_]
protected $_code = 'hypercharge_wpf_giropay';

// Define payment block form
protected $_formBlockType = 'bithypercharge/form_giropay';

public function getTransactionType() {
Expand Down
Loading

0 comments on commit 9698247

Please sign in to comment.