Version Notes
The Base currency of the magento should be same as the Currency with which merchant account is processing in Debitway
Download this release
Release Info
| Developer | ramya |
| Extension | DebitwayCC_Creditcard |
| Version | 2.0.0 |
| Comparing to | |
| See all releases | |
Version 2.0.0
- app/code/community/DebitwayCC/Creditcard/Block/Form/Pay.php +6 -0
- app/code/community/DebitwayCC/Creditcard/Block/Info/Pay.php +20 -0
- app/code/community/DebitwayCC/Creditcard/Helper/Data.php +6 -0
- app/code/community/DebitwayCC/Creditcard/Model/Pay.php +573 -0
- app/code/community/DebitwayCC/Creditcard/Model/Source/Action.php +22 -0
- app/code/community/DebitwayCC/Creditcard/controllers/IndexController.php +130 -0
- app/code/community/DebitwayCC/Creditcard/etc/config.xml +93 -0
- app/code/community/DebitwayCC/Creditcard/etc/system.xml +139 -0
- app/etc/modules/DebitwayCC_Creditcard.xml +9 -0
- package.xml +21 -0
app/code/community/DebitwayCC/Creditcard/Block/Form/Pay.php
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/* Inherit the Credit Card save payment form */
|
| 4 |
+
|
| 5 |
+
class DebitwayCC_Creditcard_Block_Form_Pay extends Mage_Payment_Block_Form_Ccsave {
|
| 6 |
+
}
|
app/code/community/DebitwayCC/Creditcard/Block/Info/Pay.php
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class DebitwayCC_Creditcard_Block_Info_Pay extends Mage_Payment_Block_Info
|
| 3 |
+
{
|
| 4 |
+
protected function _prepareSpecificInformation($transport = null)
|
| 5 |
+
{
|
| 6 |
+
if (null !== $this->_paymentSpecificInformation) {
|
| 7 |
+
return $this->_paymentSpecificInformation;
|
| 8 |
+
}
|
| 9 |
+
$info = $this->getInfo();
|
| 10 |
+
$transport = new Varien_Object();
|
| 11 |
+
$transport = parent::_prepareSpecificInformation($transport);
|
| 12 |
+
$transport->addData(array(
|
| 13 |
+
Mage::helper('payment')->__('Credit Card No Last 4') => $info->getCcLast4(),
|
| 14 |
+
Mage::helper('payment')->__('Card Type') => $info->getCcType(),
|
| 15 |
+
Mage::helper('payment')->__('Exp Date') => $info->getCcExpMonth() . ' / '.$info->getCcExpYear(),
|
| 16 |
+
Mage::helper('payment')->__('Card Owner') => $info->getCcOwner(),
|
| 17 |
+
));
|
| 18 |
+
return $transport;
|
| 19 |
+
}
|
| 20 |
+
}
|
app/code/community/DebitwayCC/Creditcard/Helper/Data.php
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class DebitwayCC_Creditcard_Helper_Data extends Mage_Core_Helper_Abstract
|
| 4 |
+
{
|
| 5 |
+
|
| 6 |
+
}
|
app/code/community/DebitwayCC/Creditcard/Model/Pay.php
ADDED
|
@@ -0,0 +1,573 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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model_Method_Cc {
|
| 3 |
+
protected $_code = 'pay';
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
protected $_formBlockType = 'pay/form_pay';
|
| 7 |
+
protected $_infoBlockType = 'pay/info_pay';
|
| 8 |
+
protected $_isGateway = true;
|
| 9 |
+
protected $_canAuthorize = true;
|
| 10 |
+
protected $_canCapture = true;
|
| 11 |
+
protected $_canRefund = true;
|
| 12 |
+
protected $_canSaveCc = false;
|
| 13 |
+
protected $_canVoid = true;
|
| 14 |
+
|
| 15 |
+
protected $_canUseInternal = true;
|
| 16 |
+
protected $_canUseCheckout = true;
|
| 17 |
+
protected $_canUseForMultishipping = false;
|
| 18 |
+
protected $_canRefundInvoicePartial = true;
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
public function process($data) {
|
| 23 |
+
if ($data['cancel'] == 1) {
|
| 24 |
+
$order->getPayment()->setTransactionId(null)->setParentTransactionId(time())->void();
|
| 25 |
+
$message = 'Unable to process Payment';
|
| 26 |
+
$order->registerCancellation($message)->save();
|
| 27 |
+
}
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
/** For void **/
|
| 31 |
+
public function void(Varien_Object $payment)
|
| 32 |
+
{
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
$result = $this->callDecline($payment, 'Decline');
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
if ($result === false) {
|
| 39 |
+
$errorCode = 'Invalid Data';
|
| 40 |
+
$errorMsg = $this->_getHelper()->__('Error Processing the request');
|
| 41 |
+
Mage::throwException($errorMsg);
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
return $this;
|
| 45 |
+
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
/** For cancel **/
|
| 49 |
+
public function cancel(Varien_Object $payment)
|
| 50 |
+
{
|
| 51 |
+
|
| 52 |
+
$amount = 0;
|
| 53 |
+
$result = $this->callDecline($payment, 'Decline');
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
if ($result === false) {
|
| 57 |
+
$errorCode = 'Invalid Data';
|
| 58 |
+
$errorMsg = $this->_getHelper()->__('Error Processing the request');
|
| 59 |
+
Mage::throwException($errorMsg);
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
return $this;
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
/** For capture **/
|
| 66 |
+
public function capture(Varien_Object $payment, $amount) {
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
$order = $payment->getOrder();
|
| 70 |
+
|
| 71 |
+
$transaction_id = $payment->getParentTransactionId();
|
| 72 |
+
|
| 73 |
+
if($transaction_id==null){
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
$result = $this->callApi($payment, $amount, 'Sale');
|
| 77 |
+
}
|
| 78 |
+
else{
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
$result = $this->callApi($payment, $amount, 'Saleadmin');
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
$errorMsg = false;
|
| 86 |
+
if ($result === false) {
|
| 87 |
+
$errorCode = 'Invalid Data';
|
| 88 |
+
$errorMsg = $this->_getHelper()->__('Error Processing the request');
|
| 89 |
+
}
|
| 90 |
+
else {
|
| 91 |
+
if ($result['status'] == 1) {
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
$payment->setTransactionId($result['transaction_id']);
|
| 95 |
+
$payment->setIsTransactionClosed(1);
|
| 96 |
+
|
| 97 |
+
// Save additional variables as needed
|
| 98 |
+
$payment->setTransactionAdditionalInfo(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, array(
|
| 99 |
+
'key1' => 'value1',
|
| 100 |
+
'key2' => 'value2'
|
| 101 |
+
));
|
| 102 |
+
}
|
| 103 |
+
else {
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
Mage::throwException("Error Encountered: ".$result['error']);
|
| 108 |
+
}
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
if ($errorMsg) {
|
| 112 |
+
Mage::throwException($errorMsg);
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
return $this;
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
/** For authorization **/
|
| 121 |
+
public function authorize(Varien_Object $payment, $amount) {
|
| 122 |
+
|
| 123 |
+
//Mage::throwException("in authorize");
|
| 124 |
+
$order = $payment->getOrder();
|
| 125 |
+
$items = $order->getAllVisibleItems();
|
| 126 |
+
|
| 127 |
+
$result = $this->callApi($payment, $amount, 'Authorization');
|
| 128 |
+
$errorMsg = "";
|
| 129 |
+
|
| 130 |
+
if ($result === false) {
|
| 131 |
+
$errorCode = 'Invalid Data';
|
| 132 |
+
$errorMsg = $this->_getHelper()->__('Error Processing the request');
|
| 133 |
+
Mage::throwException($errorMsg);
|
| 134 |
+
}
|
| 135 |
+
else {
|
| 136 |
+
if ($result['status'] == 1) {
|
| 137 |
+
|
| 138 |
+
$payment->setTransactionId($result['transaction_id']);
|
| 139 |
+
$payment->setIsTransactionClosed(false);
|
| 140 |
+
$payment->setTransactionAdditionalInfo(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, array(
|
| 141 |
+
'key1' => 'value1',
|
| 142 |
+
'key2' => 'value2'
|
| 143 |
+
));
|
| 144 |
+
|
| 145 |
+
$order->addStatusToHistory($order->getStatus(), 'Payment Sucessfully Placed with Transaction ID ' . $result['transaction_id'], false);
|
| 146 |
+
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true)->save();
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
}
|
| 150 |
+
else if($result['status'] == 0){
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
Mage::throwException("Error Encountered: ".$result['error']);
|
| 154 |
+
|
| 155 |
+
}
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
return $this;
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
public function processBeforeRefund($invoice, $payment)
|
| 162 |
+
{
|
| 163 |
+
return parent::processBeforeRefund($invoice, $payment);
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
public function refund(Varien_Object $payment, $amount)
|
| 167 |
+
{
|
| 168 |
+
|
| 169 |
+
$order = $payment->getOrder();
|
| 170 |
+
$result = $this->callApi($payment, $amount, 'Refund');
|
| 171 |
+
if ($result === false) {
|
| 172 |
+
$errorCode = 'Invalid Data';
|
| 173 |
+
$errorMsg = $this->_getHelper()->__('Error Processing the request');
|
| 174 |
+
Mage::throwException($errorMsg);
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
return $this;
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
public function processCreditmemo($creditmemo, $payment)
|
| 181 |
+
{
|
| 182 |
+
return parent::processCreditmemo($creditmemo, $payment);
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
/**
|
| 186 |
+
*
|
| 187 |
+
* @param (type) This string can be used to tell the API
|
| 188 |
+
* if the call is for Sale or Authorization
|
| 189 |
+
*/
|
| 190 |
+
private function callApi(Varien_Object $payment, $amount, $type = "")
|
| 191 |
+
{
|
| 192 |
+
|
| 193 |
+
|
| 194 |
+
$identifier = trim(Mage::getStoreConfig('payment/pay/identifier'));
|
| 195 |
+
$vericode = trim(Mage::getStoreConfig('payment/pay/vericode'));
|
| 196 |
+
$website_unique_id = trim(Mage::getStoreConfig('payment/pay/website_unique_id'));
|
| 197 |
+
$url = trim(Mage::getStoreConfig('payment/pay/integration_url'));
|
| 198 |
+
|
| 199 |
+
|
| 200 |
+
|
| 201 |
+
if ($amount > 0) {
|
| 202 |
+
|
| 203 |
+
|
| 204 |
+
$order = $payment->getOrder();
|
| 205 |
+
$cc_number = $payment->getCcNumber();
|
| 206 |
+
$expirationMonth = $payment->getCcExpMonth();
|
| 207 |
+
$expirationYear = $payment->getCcExpYear();
|
| 208 |
+
$billingAddress = $order->getBillingAddress();
|
| 209 |
+
$shippingAddress = $order->getShippingAddress();
|
| 210 |
+
$street = $billingAddress->getStreet(1);
|
| 211 |
+
$postcode = $billingAddress->getPostcode();
|
| 212 |
+
$cc_security_code = $payment->getCcCid();
|
| 213 |
+
|
| 214 |
+
if(strlen($expirationMonth)==1){
|
| 215 |
+
$expirationMonth = '0'.$expirationMonth;
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
$cc_expdate = substr($expirationYear,-2).$expirationMonth;
|
| 219 |
+
$cc_type = trim($payment->getCcType());
|
| 220 |
+
if($cc_type == 'VI'){
|
| 221 |
+
$cc_type = 'VISA';
|
| 222 |
+
|
| 223 |
+
}else if($cc_type == 'MC'){
|
| 224 |
+
|
| 225 |
+
$cc_type = 'MASTERCARD';
|
| 226 |
+
}
|
| 227 |
+
|
| 228 |
+
|
| 229 |
+
$items = $order->getAllItems();
|
| 230 |
+
|
| 231 |
+
$item_name_total ="";
|
| 232 |
+
foreach($items as $item) {
|
| 233 |
+
$qty = round($item->getData('qty_ordered'));
|
| 234 |
+
$name = $item->getName();
|
| 235 |
+
$item_total = $qty.'*'.$name;
|
| 236 |
+
if($item_name_total!=null){
|
| 237 |
+
$item_name_total .='-';
|
| 238 |
+
}
|
| 239 |
+
$item_name_total .=$item_total;
|
| 240 |
+
|
| 241 |
+
}
|
| 242 |
+
$grandTotal1 = number_format($order->getBaseGrandTotal(),2);
|
| 243 |
+
|
| 244 |
+
$currency_code = $order->getBaseCurrencyCode();
|
| 245 |
+
$current_currency_code = $order->getDefaultCurrencyCode();
|
| 246 |
+
|
| 247 |
+
$first_name = Mage::helper('core')->removeAccents($billingAddress->getFirstname());
|
| 248 |
+
$last_name = Mage::helper('core')->removeAccents($billingAddress->getLastname());
|
| 249 |
+
$phone = $order->getCustomerTelephone();
|
| 250 |
+
$email = $order->getCustomerEmail();
|
| 251 |
+
|
| 252 |
+
$billing_address = $billingAddress->getStreet1();
|
| 253 |
+
$billing_city = $billingAddress->getCity();
|
| 254 |
+
$billing_state_or_province = $billingAddress->getRegionCode();
|
| 255 |
+
$billing_country = $billingAddress->getCountry();
|
| 256 |
+
$billing_zip_or_postal_code = $billingAddress->getPostcode();
|
| 257 |
+
$bphone = $billingAddress->getTelephone();
|
| 258 |
+
|
| 259 |
+
|
| 260 |
+
$shipping_address = $shippingAddress->getStreet1();
|
| 261 |
+
$shipping_city = $shippingAddress->getCity();
|
| 262 |
+
$shipping_state_or_province = $shippingAddress->getRegionCode();
|
| 263 |
+
$shipping_country = $shippingAddress->getCountry();
|
| 264 |
+
$shipping_zip_or_postal_code = $shippingAddress->getPostcode();
|
| 265 |
+
$return_url = Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB);
|
| 266 |
+
$return_url .= 'pay/payment/response';
|
| 267 |
+
|
| 268 |
+
if($type =="Refund"){
|
| 269 |
+
|
| 270 |
+
$transaction_id = $payment->getParentTransactionId();
|
| 271 |
+
if($transaction_id==null){
|
| 272 |
+
Mage::throwException(Mage::helper('payment')->__('null value in transaction id'));
|
| 273 |
+
|
| 274 |
+
}
|
| 275 |
+
|
| 276 |
+
|
| 277 |
+
$comments = "A refund was issued to the customer";
|
| 278 |
+
$ch = curl_init();
|
| 279 |
+
|
| 280 |
+
curl_setopt($ch, CURLOPT_URL,$url);
|
| 281 |
+
|
| 282 |
+
curl_setopt($ch, CURLOPT_POST, true);
|
| 283 |
+
|
| 284 |
+
$post_data = 'identifier='.$identifier.'&vericode='.$vericode.'&comments='.$comments.'&transaction_id='.$transaction_id.'&amount='.$amount.'&action=refund';
|
| 285 |
+
curl_setopt ($ch, CURLOPT_POSTFIELDS, $post_data);
|
| 286 |
+
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
|
| 287 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
| 288 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
| 289 |
+
$result = curl_exec($ch);
|
| 290 |
+
|
| 291 |
+
curl_close($ch);
|
| 292 |
+
|
| 293 |
+
$output = $this->get_value_from_response($result,'result');
|
| 294 |
+
if($output == "success"){
|
| 295 |
+
$approved = true;
|
| 296 |
+
}else{
|
| 297 |
+
$error = $this->get_value_from_response($result,'errors_meaning');
|
| 298 |
+
$approved = false;
|
| 299 |
+
Mage::throwException($error);
|
| 300 |
+
}
|
| 301 |
+
|
| 302 |
+
$transaction_id = $this->get_value_from_response($result,'transaction_id');
|
| 303 |
+
if($result == null){
|
| 304 |
+
$approved = false;
|
| 305 |
+
}
|
| 306 |
+
if($approved==false){
|
| 307 |
+
Mage::throwException(Mage::helper('payment')->__('Problem encountered in Refunding.'));
|
| 308 |
+
}
|
| 309 |
+
}
|
| 310 |
+
|
| 311 |
+
if($type == "Saleadmin"){
|
| 312 |
+
|
| 313 |
+
|
| 314 |
+
$transaction_id = $payment->getParentTransactionId();
|
| 315 |
+
|
| 316 |
+
|
| 317 |
+
$ch = curl_init();
|
| 318 |
+
|
| 319 |
+
curl_setopt($ch, CURLOPT_URL,$url);
|
| 320 |
+
|
| 321 |
+
curl_setopt($ch, CURLOPT_POST, true);
|
| 322 |
+
|
| 323 |
+
$post_data = array(
|
| 324 |
+
|
| 325 |
+
'identifier' => $identifier,
|
| 326 |
+
'vericode'=> $vericode,
|
| 327 |
+
'transaction_id'=>$transaction_id,
|
| 328 |
+
'action'=>'capture'
|
| 329 |
+
);
|
| 330 |
+
|
| 331 |
+
$fields_string = http_build_query($post_data);
|
| 332 |
+
|
| 333 |
+
curl_setopt ($ch, CURLOPT_POSTFIELDS, $fields_string);
|
| 334 |
+
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
|
| 335 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
| 336 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
| 337 |
+
$result = curl_exec($ch);
|
| 338 |
+
|
| 339 |
+
curl_close($ch);
|
| 340 |
+
|
| 341 |
+
|
| 342 |
+
|
| 343 |
+
$approved = false;
|
| 344 |
+
$output = $this->get_value_from_response($result,'result');
|
| 345 |
+
|
| 346 |
+
|
| 347 |
+
if($output == "success"){
|
| 348 |
+
$approved = true;
|
| 349 |
+
}else{
|
| 350 |
+
$error = $this->get_value_from_response($result,'errors_meaning');
|
| 351 |
+
$approved = false;
|
| 352 |
+
Mage::throwException($error);
|
| 353 |
+
}
|
| 354 |
+
|
| 355 |
+
if($result == null){
|
| 356 |
+
$approved = false;
|
| 357 |
+
}
|
| 358 |
+
}
|
| 359 |
+
if($type == "Sale"){
|
| 360 |
+
|
| 361 |
+
|
| 362 |
+
$ch = curl_init();
|
| 363 |
+
|
| 364 |
+
curl_setopt($ch, CURLOPT_URL,$url);
|
| 365 |
+
|
| 366 |
+
curl_setopt($ch, CURLOPT_POST, true);
|
| 367 |
+
|
| 368 |
+
$post_data = array(
|
| 369 |
+
|
| 370 |
+
'identifier' => $identifier,
|
| 371 |
+
'vericode'=> $vericode,
|
| 372 |
+
'website_unique_id'=>$website_unique_id,
|
| 373 |
+
'item_name'=> $item_name_total,
|
| 374 |
+
'first_name'=> $first_name,
|
| 375 |
+
'last_name'=> $last_name,
|
| 376 |
+
'email'=> $email,
|
| 377 |
+
'phone'=> $bphone,
|
| 378 |
+
'amount'=> $grandTotal1,
|
| 379 |
+
'language'=> 'en',
|
| 380 |
+
'quantity'=> '1',
|
| 381 |
+
'cc_type'=> $cc_type,
|
| 382 |
+
'cc_number'=> $cc_number,
|
| 383 |
+
'cc_expdate'=> $cc_expdate,
|
| 384 |
+
'cc_security_code'=>$cc_security_code,
|
| 385 |
+
'return_url'=>$return_url,
|
| 386 |
+
'address'=>$billing_address,
|
| 387 |
+
'city'=>$billing_city,
|
| 388 |
+
'state_or_province'=>$billing_state_or_province,
|
| 389 |
+
'zip_or_postal_code'=>$billing_zip_or_postal_code,
|
| 390 |
+
'country'=>$billing_country,
|
| 391 |
+
'shipping_address'=>$shipping_address,
|
| 392 |
+
'shipping_city'=>$shipping_city,
|
| 393 |
+
'shipping_state_or_province'=>$shipping_state_or_province,
|
| 394 |
+
'shipping_zip_or_postal_code'=>$shipping_zip_or_postal_code,
|
| 395 |
+
'shipping_country'=>$shipping_country,
|
| 396 |
+
'currency'=>$currency_code,
|
| 397 |
+
'action'=>'payment'
|
| 398 |
+
);
|
| 399 |
+
|
| 400 |
+
$fields_string = http_build_query($post_data);
|
| 401 |
+
|
| 402 |
+
curl_setopt ($ch, CURLOPT_POSTFIELDS, $fields_string);
|
| 403 |
+
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
|
| 404 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
| 405 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
| 406 |
+
$result = curl_exec($ch);
|
| 407 |
+
|
| 408 |
+
curl_close($ch);
|
| 409 |
+
|
| 410 |
+
$approved = false;
|
| 411 |
+
$output = $this->get_value_from_response($result,'result');
|
| 412 |
+
if($output == "success"){
|
| 413 |
+
$approved = true;
|
| 414 |
+
}else{
|
| 415 |
+
$error = $this->get_value_from_response($result,'customer_errors_meaning');
|
| 416 |
+
$approved = false;
|
| 417 |
+
}
|
| 418 |
+
|
| 419 |
+
$transaction_id = $this->get_value_from_response($result,'transaction_id');
|
| 420 |
+
|
| 421 |
+
|
| 422 |
+
if($result == null){
|
| 423 |
+
$approved = false;
|
| 424 |
+
}
|
| 425 |
+
}
|
| 426 |
+
|
| 427 |
+
if($type == "Authorization"){
|
| 428 |
+
|
| 429 |
+
|
| 430 |
+
$ch = curl_init();
|
| 431 |
+
|
| 432 |
+
curl_setopt($ch, CURLOPT_URL,$url);
|
| 433 |
+
|
| 434 |
+
curl_setopt($ch, CURLOPT_POST, true);
|
| 435 |
+
|
| 436 |
+
$post_data = array(
|
| 437 |
+
|
| 438 |
+
'identifier' => $identifier,
|
| 439 |
+
'vericode'=> $vericode,
|
| 440 |
+
'website_unique_id'=>$website_unique_id,
|
| 441 |
+
'item_name'=> $item_name_total,
|
| 442 |
+
'first_name'=> $first_name,
|
| 443 |
+
'last_name'=> $last_name,
|
| 444 |
+
'email'=> $email,
|
| 445 |
+
'phone'=> $bphone,
|
| 446 |
+
'amount'=> $grandTotal1,
|
| 447 |
+
'language'=> 'en',
|
| 448 |
+
'quantity'=> '1',
|
| 449 |
+
'cc_type'=> $cc_type,
|
| 450 |
+
'cc_number'=> $cc_number,
|
| 451 |
+
'cc_expdate'=> $cc_expdate,
|
| 452 |
+
'cc_security_code'=>$cc_security_code,
|
| 453 |
+
'return_url'=>$return_url,
|
| 454 |
+
'address'=>$billing_address,
|
| 455 |
+
'city'=>$billing_city,
|
| 456 |
+
'state_or_province'=>$billing_state_or_province,
|
| 457 |
+
'zip_or_postal_code'=>$billing_zip_or_postal_code,
|
| 458 |
+
'country'=>$billing_country,
|
| 459 |
+
'shipping_address'=>$shipping_address,
|
| 460 |
+
'shipping_city'=>$shipping_city,
|
| 461 |
+
'shipping_state_or_province'=>$shipping_state_or_province,
|
| 462 |
+
'shipping_zip_or_postal_code'=>$shipping_zip_or_postal_code,
|
| 463 |
+
'shipping_country'=>$shipping_country,
|
| 464 |
+
'currency'=>$currency_code,
|
| 465 |
+
'action'=>'authorized payment'
|
| 466 |
+
);
|
| 467 |
+
|
| 468 |
+
$fields_string = http_build_query($post_data);
|
| 469 |
+
|
| 470 |
+
curl_setopt ($ch, CURLOPT_POSTFIELDS, $fields_string);
|
| 471 |
+
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
|
| 472 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
| 473 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
| 474 |
+
$result = curl_exec($ch);
|
| 475 |
+
|
| 476 |
+
curl_close($ch);
|
| 477 |
+
// Mage::throwException($result);
|
| 478 |
+
|
| 479 |
+
$approved = false;
|
| 480 |
+
$output = $this->get_value_from_response($result,'result');
|
| 481 |
+
if($output == "success"){
|
| 482 |
+
$approved = true;
|
| 483 |
+
}else{
|
| 484 |
+
$error = $this->get_value_from_response($result,'customer_errors_meaning');
|
| 485 |
+
$approved = false;
|
| 486 |
+
}
|
| 487 |
+
|
| 488 |
+
$transaction_id = $this->get_value_from_response($result,'transaction_id');
|
| 489 |
+
|
| 490 |
+
if($result == null){
|
| 491 |
+
$approved = false;
|
| 492 |
+
}
|
| 493 |
+
|
| 494 |
+
|
| 495 |
+
}
|
| 496 |
+
|
| 497 |
+
|
| 498 |
+
if ($approved == true) {
|
| 499 |
+
return array( 'status' => 1, 'transaction_id' => $transaction_id, 'fraud' => 0 );
|
| 500 |
+
} else {
|
| 501 |
+
return array( 'status' => 0, 'error' => $error, 'transaction_id' => $transaction_id, 'fraud' => 0 );
|
| 502 |
+
}
|
| 503 |
+
} else {
|
| 504 |
+
$error = Mage::helper('pay')->__('Invalid amount for authorization.');
|
| 505 |
+
return array( 'status' => 0, 'transaction_id' => $transaction_id, 'fraud' => 0 );
|
| 506 |
+
}
|
| 507 |
+
}
|
| 508 |
+
|
| 509 |
+
private function callDecline(varien_Object $payment, $type=""){
|
| 510 |
+
|
| 511 |
+
$identifier = trim(Mage::getStoreConfig('payment/pay/identifier'));
|
| 512 |
+
$vericode = trim(Mage::getStoreConfig('payment/pay/vericode'));
|
| 513 |
+
$website_unique_id = trim(Mage::getStoreConfig('payment/pay/website_unique_id'));
|
| 514 |
+
$url = trim(Mage::getStoreConfig('payment/pay/integration_url'));
|
| 515 |
+
|
| 516 |
+
|
| 517 |
+
|
| 518 |
+
$transaction_id = $payment->getParentTransactionId();
|
| 519 |
+
if($transaction_id==null){
|
| 520 |
+
Mage::throwException(Mage::helper('payment')->__('null value in transaction id'));
|
| 521 |
+
|
| 522 |
+
}
|
| 523 |
+
|
| 524 |
+
|
| 525 |
+
$comments = "Transaction was declined by admin";
|
| 526 |
+
$ch = curl_init();
|
| 527 |
+
|
| 528 |
+
curl_setopt($ch, CURLOPT_URL,$url);
|
| 529 |
+
|
| 530 |
+
curl_setopt($ch, CURLOPT_POST, true);
|
| 531 |
+
|
| 532 |
+
$post_data = 'identifier='.$identifier.'&vericode='.$vericode.'&comments='.$comments.'&transaction_id='.$transaction_id.'&action=decline authorized payment';
|
| 533 |
+
curl_setopt ($ch, CURLOPT_POSTFIELDS, $post_data);
|
| 534 |
+
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
|
| 535 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
| 536 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
| 537 |
+
$result = curl_exec($ch);
|
| 538 |
+
|
| 539 |
+
curl_close($ch);
|
| 540 |
+
$res = explode('" ',$result);
|
| 541 |
+
$output = $this->get_value_from_response($result,'result');
|
| 542 |
+
if($output == "success"){
|
| 543 |
+
$approved = true;
|
| 544 |
+
}else{
|
| 545 |
+
$error = $this->get_value_from_response($result,'errors_meaning');
|
| 546 |
+
$approved = false;
|
| 547 |
+
Mage::throwException($error);
|
| 548 |
+
}
|
| 549 |
+
|
| 550 |
+
$transaction_id = $this->get_value_from_response($result,'transaction_id');
|
| 551 |
+
|
| 552 |
+
if($result == null){
|
| 553 |
+
$approved = false;
|
| 554 |
+
}
|
| 555 |
+
if($approved==false){
|
| 556 |
+
Mage::throwException(Mage::helper('payment')->__('Problem encountered in Declining.'));
|
| 557 |
+
}
|
| 558 |
+
if ($approved == true) {
|
| 559 |
+
return array( 'status' => 1, 'transaction_id' => $transaction_id, 'error_message' => $result, 'fraud' => 0 );
|
| 560 |
+
} else {
|
| 561 |
+
return array( 'status' => 0, 'error' => $error, 'transaction_id' => $transaction_id, 'fraud' => 0 );
|
| 562 |
+
}
|
| 563 |
+
}
|
| 564 |
+
|
| 565 |
+
private function get_value_from_response($l_str, $l_key) {
|
| 566 |
+
if(strpos($l_str, $l_key."=\"")) {
|
| 567 |
+
$l_substr = substr($l_str, strpos($l_str, $l_key."=\"") + strlen($l_key) + 2);
|
| 568 |
+
return substr($l_substr, 0, strpos($l_substr, "\""));
|
| 569 |
+
}
|
| 570 |
+
else return FALSE;
|
| 571 |
+
}
|
| 572 |
+
}
|
| 573 |
+
?>
|
app/code/community/DebitwayCC/Creditcard/Model/Source/Action.php
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class DebitwayCC_Creditcard_Model_Source_Action
|
| 3 |
+
{
|
| 4 |
+
public function toOptionArray()
|
| 5 |
+
{
|
| 6 |
+
return array(
|
| 7 |
+
array(
|
| 8 |
+
'value' => Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE,
|
| 9 |
+
'label' => Mage::helper('core')->__('Authorize & Capture')
|
| 10 |
+
),
|
| 11 |
+
array(
|
| 12 |
+
'value' => Mage_Payment_Model_Method_Abstract::ACTION_ORDER,
|
| 13 |
+
'label' => Mage::helper('core')->__('Order')
|
| 14 |
+
),
|
| 15 |
+
array(
|
| 16 |
+
'value' => Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE,
|
| 17 |
+
'label' => Mage::helper('core')->__('Authorize')
|
| 18 |
+
),
|
| 19 |
+
|
| 20 |
+
);
|
| 21 |
+
}
|
| 22 |
+
}
|
app/code/community/DebitwayCC/Creditcard/controllers/IndexController.php
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class DebitwayCC_Creditcard_IndexController extends Mage_Core_Controller_Front_Action
|
| 3 |
+
{
|
| 4 |
+
public function indexAction()
|
| 5 |
+
{
|
| 6 |
+
$this->loadLayout();
|
| 7 |
+
$this->renderLayout();
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
public function successAction()
|
| 11 |
+
{
|
| 12 |
+
$request = $_REQUEST;
|
| 13 |
+
Mage::log($request, null, 'lps.log');
|
| 14 |
+
$orderIncrementId = $request['Merchant_ref_number'];
|
| 15 |
+
Mage::log($orderIncrementId);
|
| 16 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
|
| 17 |
+
Mage::log($order->getId());
|
| 18 |
+
Mage::log($order->getId(), null, 'lps.log');
|
| 19 |
+
try{
|
| 20 |
+
if($request['Status_'] == 05){
|
| 21 |
+
$comment = $order->sendNewOrderEmail()->addStatusHistoryComment('Bank Status : Declined By Bank')
|
| 22 |
+
->setIsCustomerNotified(false)
|
| 23 |
+
->save();
|
| 24 |
+
$this->_forward('error');
|
| 25 |
+
}
|
| 26 |
+
elseif($request['Status_'] == 90){
|
| 27 |
+
$comment = $order->sendNewOrderEmail()->addStatusHistoryComment('Bank Status : Comm. Failed')
|
| 28 |
+
->setIsCustomerNotified(false)
|
| 29 |
+
->save();
|
| 30 |
+
$this->_forward('error');
|
| 31 |
+
}elseif($request['Status_'] == 00){
|
| 32 |
+
$comment = $order->sendNewOrderEmail()->addStatusHistoryComment('Bank Status : ----')
|
| 33 |
+
->setIsCustomerNotified(false)
|
| 34 |
+
->save();
|
| 35 |
+
$payment = $order->getPayment();
|
| 36 |
+
$grandTotal = $order->getBaseGrandTotal();
|
| 37 |
+
if(isset($request['Transactionid'])){
|
| 38 |
+
$tid = $request['Transactionid'];
|
| 39 |
+
}
|
| 40 |
+
else {
|
| 41 |
+
$tid = -1 ;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
$payment->setTransactionId($tid)
|
| 45 |
+
->setPreparedMessage("Payment Sucessful Result:")
|
| 46 |
+
->setIsTransactionClosed(0)
|
| 47 |
+
->registerAuthorizationNotification($grandTotal);
|
| 48 |
+
$order->save();
|
| 49 |
+
|
| 50 |
+
try {
|
| 51 |
+
if(!$order->canInvoice())
|
| 52 |
+
{
|
| 53 |
+
Mage::throwException(Mage::helper('core')->__('Cannot create an invoice.'));
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
$invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
|
| 57 |
+
|
| 58 |
+
if (!$invoice->getTotalQty()) {
|
| 59 |
+
Mage::throwException(Mage::helper('core')->__('Cannot create an invoice without products.'));
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
|
| 63 |
+
|
| 64 |
+
$invoice->register();
|
| 65 |
+
$transactionSave = Mage::getModel('core/resource_transaction')
|
| 66 |
+
->addObject($invoice)
|
| 67 |
+
->addObject($invoice->getOrder());
|
| 68 |
+
|
| 69 |
+
$transactionSave->save();
|
| 70 |
+
$message = Mage::helper('pay')->__('Notified customer about invoice #%s.', $invoice->getIncrementId());
|
| 71 |
+
$comment = $order->sendNewOrderEmail()->addStatusHistoryComment($message)
|
| 72 |
+
->setIsCustomerNotified(true)
|
| 73 |
+
->save();
|
| 74 |
+
}
|
| 75 |
+
catch (Mage_Core_Exception $e) {
|
| 76 |
+
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
$url = Mage::getUrl('checkout/onepage/success', array('_secure'=>true));
|
| 80 |
+
Mage::register('redirect_url',$url);
|
| 81 |
+
$this->_redirectUrl($url);
|
| 82 |
+
}
|
| 83 |
+
}
|
| 84 |
+
catch(Exception $e)
|
| 85 |
+
{
|
| 86 |
+
Mage::logException($e);
|
| 87 |
+
}
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
protected function _getCheckout()
|
| 91 |
+
{
|
| 92 |
+
return Mage::getSingleton('checkout/session');
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
public function errorAction()
|
| 96 |
+
{
|
| 97 |
+
$request = $_REQUEST;
|
| 98 |
+
Mage::log($request, null, 'lps.log');
|
| 99 |
+
$gotoSection = false;
|
| 100 |
+
$session = $this->_getCheckout();
|
| 101 |
+
if ($session->getLastRealOrderId()) {
|
| 102 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($session->getLastRealOrderId());
|
| 103 |
+
if ($order->getId()) {
|
| 104 |
+
//Cancel order
|
| 105 |
+
if ($order->getState() != Mage_Sales_Model_Order::STATE_CANCELED) {
|
| 106 |
+
$order->registerCancellation($errorMsg)->save();
|
| 107 |
+
}
|
| 108 |
+
$quote = Mage::getModel('sales/quote')
|
| 109 |
+
->load($order->getQuoteId());
|
| 110 |
+
//Return quote
|
| 111 |
+
if ($quote->getId()) {
|
| 112 |
+
$quote->setIsActive(1)
|
| 113 |
+
->setReservedOrderId(NULL)
|
| 114 |
+
->save();
|
| 115 |
+
$session->replaceQuote($quote);
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
//Unset data
|
| 119 |
+
$session->unsLastRealOrderId();
|
| 120 |
+
//Redirect to payment step
|
| 121 |
+
$gotoSection = 'payment';
|
| 122 |
+
$url = Mage::getUrl('checkout/onepage/index', array('_secure'=>true));
|
| 123 |
+
Mage::register('redirect_url',$url);
|
| 124 |
+
$this->_redirectUrl($url);
|
| 125 |
+
}
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
return $gotoSection;
|
| 129 |
+
}
|
| 130 |
+
}
|
app/code/community/DebitwayCC/Creditcard/etc/config.xml
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<DebitwayCC_Creditcard>
|
| 5 |
+
<version>0.1.0</version>
|
| 6 |
+
</DebitwayCC_Creditcard>
|
| 7 |
+
</modules>
|
| 8 |
+
<frontend>
|
| 9 |
+
<routers>
|
| 10 |
+
<pay>
|
| 11 |
+
<use>standard</use>
|
| 12 |
+
<args>
|
| 13 |
+
<module>Debitway_Creditcard</module>
|
| 14 |
+
<frontName>pay</frontName>
|
| 15 |
+
</args>
|
| 16 |
+
</pay>
|
| 17 |
+
</routers>
|
| 18 |
+
<layout>
|
| 19 |
+
<updates>
|
| 20 |
+
<pay>
|
| 21 |
+
<file>pay.xml</file>
|
| 22 |
+
</pay>
|
| 23 |
+
</updates>
|
| 24 |
+
</layout>
|
| 25 |
+
</frontend>
|
| 26 |
+
<global>
|
| 27 |
+
<fieldsets>
|
| 28 |
+
<sales_convert_quote_payment>
|
| 29 |
+
<check_no>
|
| 30 |
+
<to_order_payment>*</to_order_payment>
|
| 31 |
+
</check_no>
|
| 32 |
+
<check_date>
|
| 33 |
+
<to_order_payment>*</to_order_payment>
|
| 34 |
+
</check_date>
|
| 35 |
+
</sales_convert_quote_payment>
|
| 36 |
+
</fieldsets>
|
| 37 |
+
<models>
|
| 38 |
+
<pay>
|
| 39 |
+
<class>DebitwayCC_Creditcard_Model</class>
|
| 40 |
+
<resourceModel>pay_mysql4</resourceModel>
|
| 41 |
+
</pay>
|
| 42 |
+
<pay_mysql4>
|
| 43 |
+
<class>DebitwayCC_Creditcard_Model_Mysql4</class>
|
| 44 |
+
<entities>
|
| 45 |
+
<pay>
|
| 46 |
+
<table>pay</table>
|
| 47 |
+
</pay>
|
| 48 |
+
</entities>
|
| 49 |
+
</pay_mysql4>
|
| 50 |
+
</models>
|
| 51 |
+
<resources>
|
| 52 |
+
<pay_setup>
|
| 53 |
+
<setup>
|
| 54 |
+
<module>DebitwayCC_Creditcard</module>
|
| 55 |
+
</setup>
|
| 56 |
+
<connection>
|
| 57 |
+
<use>core_setup</use>
|
| 58 |
+
</connection>
|
| 59 |
+
</pay_setup>
|
| 60 |
+
<pay_write>
|
| 61 |
+
<connection>
|
| 62 |
+
<use>core_write</use>
|
| 63 |
+
</connection>
|
| 64 |
+
</pay_write>
|
| 65 |
+
<pay_read>
|
| 66 |
+
<connection>
|
| 67 |
+
<use>core_read</use>
|
| 68 |
+
</connection>
|
| 69 |
+
</pay_read>
|
| 70 |
+
</resources>
|
| 71 |
+
<blocks>
|
| 72 |
+
<pay>
|
| 73 |
+
<class>DebitwayCC_Creditcard_Block</class>
|
| 74 |
+
</pay>
|
| 75 |
+
</blocks>
|
| 76 |
+
<helpers>
|
| 77 |
+
<pay>
|
| 78 |
+
<class>DebitwayCC_Creditcard_Helper</class>
|
| 79 |
+
</pay>
|
| 80 |
+
</helpers>
|
| 81 |
+
</global>
|
| 82 |
+
<default>
|
| 83 |
+
<payment>
|
| 84 |
+
<pay>
|
| 85 |
+
<active>1</active>
|
| 86 |
+
<model>pay/pay</model>
|
| 87 |
+
<order_status>processing</order_status>
|
| 88 |
+
<title>Debitway Creditcard Method</title>
|
| 89 |
+
<message>Please enter your credit card information</message>
|
| 90 |
+
</pay>
|
| 91 |
+
</payment>
|
| 92 |
+
</default>
|
| 93 |
+
</config>
|
app/code/community/DebitwayCC/Creditcard/etc/system.xml
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
<config>
|
| 3 |
+
<sections>
|
| 4 |
+
<payment>
|
| 5 |
+
<groups>
|
| 6 |
+
<pay translate="label" module="pay">
|
| 7 |
+
<label>Debitway - Credit Card</label>
|
| 8 |
+
<sort_order>0</sort_order>
|
| 9 |
+
<show_in_default>1</show_in_default>
|
| 10 |
+
<show_in_website>1</show_in_website>
|
| 11 |
+
<show_in_store>1</show_in_store>
|
| 12 |
+
<fields>
|
| 13 |
+
<active translate="label">
|
| 14 |
+
<label>Enabled</label>
|
| 15 |
+
<frontend_type>select</frontend_type>
|
| 16 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 17 |
+
<sort_order>1</sort_order>
|
| 18 |
+
<show_in_default>1</show_in_default>
|
| 19 |
+
<show_in_website>1</show_in_website>
|
| 20 |
+
<show_in_store>0</show_in_store>
|
| 21 |
+
</active>
|
| 22 |
+
|
| 23 |
+
<cctypes translate="label">
|
| 24 |
+
<label>Credit Card Types</label>
|
| 25 |
+
<frontend_type>multiselect</frontend_type>
|
| 26 |
+
<source_model>adminhtml/system_config_source_payment_cctype</source_model>
|
| 27 |
+
<sort_order>4</sort_order>
|
| 28 |
+
<show_in_default>1</show_in_default>
|
| 29 |
+
<show_in_website>1</show_in_website>
|
| 30 |
+
<show_in_store>0</show_in_store>
|
| 31 |
+
<can_be_empty>1</can_be_empty>
|
| 32 |
+
</cctypes>
|
| 33 |
+
<useccv translate="label">
|
| 34 |
+
<label>Request Card Security Code</label>
|
| 35 |
+
<frontend_type>select</frontend_type>
|
| 36 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 37 |
+
<sort_order>5</sort_order>
|
| 38 |
+
<show_in_default>1</show_in_default>
|
| 39 |
+
<show_in_website>1</show_in_website>
|
| 40 |
+
<show_in_store>0</show_in_store>
|
| 41 |
+
</useccv>
|
| 42 |
+
<payment_action translate="label">
|
| 43 |
+
<label>Payment Action</label>
|
| 44 |
+
<frontend_type>select</frontend_type>
|
| 45 |
+
<source_model>paygate/authorizenet_source_paymentAction</source_model>
|
| 46 |
+
<sort_order>15</sort_order>
|
| 47 |
+
<show_in_default>1</show_in_default>
|
| 48 |
+
<show_in_website>1</show_in_website>
|
| 49 |
+
</payment_action>
|
| 50 |
+
<order_status translate="label">
|
| 51 |
+
<label>New order status</label>
|
| 52 |
+
<frontend_type>select</frontend_type>
|
| 53 |
+
<source_model>adminhtml/system_config_source_order_status_processing</source_model>
|
| 54 |
+
<sort_order>2</sort_order>
|
| 55 |
+
<show_in_default>1</show_in_default>
|
| 56 |
+
<show_in_website>1</show_in_website>
|
| 57 |
+
<show_in_store>0</show_in_store>
|
| 58 |
+
</order_status>
|
| 59 |
+
<title translate="label">
|
| 60 |
+
<label>Title</label>
|
| 61 |
+
<frontend_type>text</frontend_type>
|
| 62 |
+
<comment>It is recommended to set the value to "DebitWay - Credit Card" per store views.</comment>
|
| 63 |
+
<sort_order>3</sort_order>
|
| 64 |
+
<show_in_default>1</show_in_default>
|
| 65 |
+
<show_in_website>1</show_in_website>
|
| 66 |
+
<show_in_store>1</show_in_store>
|
| 67 |
+
</title>
|
| 68 |
+
|
| 69 |
+
<vericode>
|
| 70 |
+
<label>Vericode</label>
|
| 71 |
+
<frontend_type>text</frontend_type>
|
| 72 |
+
<sort_order>130</sort_order>
|
| 73 |
+
<show_in_default>1</show_in_default>
|
| 74 |
+
<show_in_website>1</show_in_website>
|
| 75 |
+
<show_in_store>0</show_in_store>
|
| 76 |
+
</vericode>
|
| 77 |
+
<identifier>
|
| 78 |
+
<label>Identifier</label>
|
| 79 |
+
<frontend_type>text</frontend_type>
|
| 80 |
+
<sort_order>131</sort_order>
|
| 81 |
+
<show_in_default>1</show_in_default>
|
| 82 |
+
<show_in_website>1</show_in_website>
|
| 83 |
+
<show_in_store>0</show_in_store>
|
| 84 |
+
</identifier>
|
| 85 |
+
<website_unique_id>
|
| 86 |
+
<label>Website Unique Id</label>
|
| 87 |
+
<frontend_type>text</frontend_type>
|
| 88 |
+
<sort_order>132</sort_order>
|
| 89 |
+
<show_in_default>1</show_in_default>
|
| 90 |
+
<show_in_website>1</show_in_website>
|
| 91 |
+
<show_in_store>0</show_in_store>
|
| 92 |
+
</website_unique_id>
|
| 93 |
+
<integration_url>
|
| 94 |
+
<label>Integration Url</label>
|
| 95 |
+
<frontend_type>text</frontend_type>
|
| 96 |
+
<sort_order>133</sort_order>
|
| 97 |
+
<show_in_default>1</show_in_default>
|
| 98 |
+
<show_in_website>1</show_in_website>
|
| 99 |
+
<show_in_store>0</show_in_store>
|
| 100 |
+
</integration_url>
|
| 101 |
+
<api_username translate="label">
|
| 102 |
+
<label>API Username</label>
|
| 103 |
+
<frontend_type>text</frontend_type>
|
| 104 |
+
<sort_order>555</sort_order>
|
| 105 |
+
<show_in_default>0</show_in_default>
|
| 106 |
+
<show_in_website>1</show_in_website>
|
| 107 |
+
<show_in_store>0</show_in_store>
|
| 108 |
+
</api_username>
|
| 109 |
+
<api_password translate="label">
|
| 110 |
+
<label>API Password</label>
|
| 111 |
+
<frontend_type>text</frontend_type>
|
| 112 |
+
<sort_order>555</sort_order>
|
| 113 |
+
<show_in_default>0</show_in_default>
|
| 114 |
+
<show_in_website>0</show_in_website>
|
| 115 |
+
<show_in_store>0</show_in_store>
|
| 116 |
+
</api_password>
|
| 117 |
+
<message translate="label">
|
| 118 |
+
<label>Displayed Message</label>
|
| 119 |
+
<frontend_type>textarea</frontend_type>
|
| 120 |
+
<sort_order>4</sort_order>
|
| 121 |
+
<show_in_default>0</show_in_default>
|
| 122 |
+
<show_in_website>1</show_in_website>
|
| 123 |
+
<show_in_store>0</show_in_store>
|
| 124 |
+
</message>
|
| 125 |
+
<gateway_url translate="label">
|
| 126 |
+
<label>Gateway URL</label>
|
| 127 |
+
<frontend_type>text</frontend_type>
|
| 128 |
+
<sort_order>500</sort_order>
|
| 129 |
+
<show_in_default>0</show_in_default>
|
| 130 |
+
<show_in_website>1</show_in_website>
|
| 131 |
+
<show_in_store>0</show_in_store>
|
| 132 |
+
</gateway_url>
|
| 133 |
+
|
| 134 |
+
</fields>
|
| 135 |
+
</pay>
|
| 136 |
+
</groups>
|
| 137 |
+
</payment>
|
| 138 |
+
</sections>
|
| 139 |
+
</config>
|
app/etc/modules/DebitwayCC_Creditcard.xml
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<DebitwayCC_Creditcard>
|
| 5 |
+
<active>true</active>
|
| 6 |
+
<codePool>community</codePool>
|
| 7 |
+
</DebitwayCC_Creditcard>
|
| 8 |
+
</modules>
|
| 9 |
+
</config>
|
package.xml
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<package>
|
| 3 |
+
<name>DebitwayCC_Creditcard</name>
|
| 4 |
+
<version>2.0.0</version>
|
| 5 |
+
<stability>stable</stability>
|
| 6 |
+
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License</license>
|
| 7 |
+
<channel>community</channel>
|
| 8 |
+
<extends/>
|
| 9 |
+
<summary>This plugin is used to support Debitway Credit card integration.</summary>
|
| 10 |
+
<description>This plug in incorporates the DebitWay Credit Card Payment Processing.
|
| 11 |
+

|
| 12 |
+
The information is collected by the user and details are send to Debitway. Based on the response from Debitway, the transaction is either saved or not saved. 
|
| 13 |
+
</description>
|
| 14 |
+
<notes>The Base currency of the magento should be same as the Currency with which merchant account is processing in Debitway</notes>
|
| 15 |
+
<authors><author><name>ramya</name><user>tech4</user><email>tech@debitway.ca</email></author></authors>
|
| 16 |
+
<date>2015-03-25</date>
|
| 17 |
+
<time>19:52:56</time>
|
| 18 |
+
<contents><target name="magecommunity"><dir name="DebitwayCC"><dir name="Creditcard"><dir name="Block"><dir name="Form"><file name="Pay.php" hash="d4f3ef8fab1defffee9fb2f5e925ad77"/></dir><dir name="Info"><file name="Pay.php" hash="38f5fd149883267bee345d98abedfb98"/></dir></dir><dir name="Helper"><file name="Data.php" hash="fa1e42e8278b9a11dd4c3c86cbc62c2f"/></dir><dir name="Model"><file name="Pay.php" hash="dfce333207f24f27390b0a078c30beeb"/><dir name="Source"><file name="Action.php" hash="bf50491a440da1fb423f250c11e446ea"/></dir></dir><dir name="controllers"><file name="IndexController.php" hash="9a9b8a5bfbd60699499f73a1497c33f0"/></dir><dir name="etc"><file name="config.xml" hash="dfb34b49370888933ab399ec3d54a532"/><file name="system.xml" hash="56360152b744d2d72d5609f9af154a42"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="DebitwayCC_Creditcard.xml" hash="81024901b4eda192c2adff48ea676740"/></dir></target></contents>
|
| 19 |
+
<compatible/>
|
| 20 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.6.0.0</min><max>1.7</max></package><extension><name>gd</name><min>2.0.28</min><max>3.0</max></extension></required></dependencies>
|
| 21 |
+
</package>
|
