Page 1 of 1

[SOLVED] Need help with Payment Module

Posted: Mon Apr 16, 2012 11:57 pm
by mandamexico
I created a payment module and users have contacted me about the confirm button in the checkout process does not respond or work. The payment extension is all done and everything works EXCEPT the last button for checkout. The extension is in the free contributions section of the forum here: http://forum.opencart.com/viewtopic.php?f=119&t=56934

I have the payment module installed on my site here: http://www.mandamexico.com

I believe the problem is with the file in the controller folder because the button does not work and the callback function might not be correct. When clicking the button it should redirect you to paypals secure site at "https://payflowlink.paypal.com" but clicking confirm does nothing.

Here is my code:

catalog/controller/payment/

Code: Select all

<?php
class ControllerPaymentPayflowlink extends Controller {
	protected function index() {

	/////////////
	// This section updated to allow for CSC entry

		$this->data['button_confirm'] = $this->language->get('button_confirm');

	$this->language->load('payment/payflowlink');
		$this->data['action'] = 'https://payflowlink.paypal.com';
		$this->data['MERCHANT'] = $this->config->get('payflowlink_merchant');
		$this->data['PARTNER'] = $this->config->get('payflowlink_partner');
		$this->data['CSC'] = $this->config->get('payflowlink_CSC');
		$this->data['TYPE'] = 'S';

		
		$order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']);
		$this->data['order_id'] = $order_info['order_id'];
		$this->data['amount'] = $order_info['total'];
		$this->data['name'] = $order_info['payment_firstname'] . ' ' . $order_info['payment_lastname'];
		if (!$order_info['payment_address_2']) {
			$this->data['address'] = $order_info['payment_address_1'];
		} else {
			$this->data['address'] = $order_info['payment_address_1'] . ', ' . $order_info['payment_address_2'];
		}
		$this->data['city']= $order_info['payment_city'];
		$this->data['zip'] = $order_info['payment_postcode'];
		$this->data['state'] = $order_info['payment_zone'];
		$this->data['telephone'] = $order_info['telephone'];
		$this->data['country'] = $order_info['payment_country'];
		$this->data['orderid'] = $this->config->get('config_store') . ' - #' . $order_info['order_id'];
		$this->data['email'] = $order_info['email'];
		$this->data['description'] = "Order ID: ".$order_info['order_id'];
		
    	$this->data['text_credit_card'] = $this->language->get('text_credit_card');
		$this->data['entry_CSC_number'] = $this->language->get('entry_CSC_number');
		$this->data['entry_credit_card_type'] = $this->language->get('entry_credit_card_type');
		$this->data['entry_credit_card_number'] = $this->language->get('entry_credit_card_number');
		$this->data['entry_expire_date'] = $this->language->get('entry_expire_date');
		
		$this->data['cards'] = array();

		$this->data['cards'][] = array(
			'text'  => 'Visa', 
			'value' => 'VISA'
		);

		$this->data['cards'][] = array(
			'text'  => 'MasterCard', 
			'value' => 'MASTERCARD'
		);

		
		$this->data['cards'][] = array(
			'text'  => 'American Express', 
			'value' => 'AMEX'
		);

		$this->data['cards'][] = array(
			'text'  => 'Discover', 
			'value' => 'DISCOVER'
		);
	
		$this->data['months'] = array();
		
		for ($i = 1; $i <= 12; $i++) {
			$this->data['months'][] = array(
				'text'  => strftime(''.$i.'. %B', mktime(0, 0, 0, $i, 1, 2000)), 
				'value' => sprintf('%02d', $i)
			);
		}
		
		$today = getdate();
		
		$this->data['year_valid'] = array();
		
		for ($i = $today['year'] - 10; $i < $today['year'] + 1; $i++) {	
			$this->data['year_valid'][] = array(
				'text'  => strftime('%Y', mktime(0, 0, 0, 1, 1, $i)), 
				'value' => strftime('%Y', mktime(0, 0, 0, 1, 1, $i))
			);
		}

		$this->data['year_expire'] = array();

		for ($i = $today['year']; $i < $today['year'] + 10; $i++) {
			$this->data['year_expire'][] = array(
				'text'  => strftime('%Y', mktime(0, 0, 0, 1, 1, $i)),
				'value' => strftime('%Y', mktime(0, 0, 0, 1, 1, $i)) 
			);
		}
		
		if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/payflowlink.tpl')) {
		$this->template = $this->config->get('config_template') . '/template/payment/payflowlink.tpl';
			} else {
				$this->template = 'default/template/payment/payflowlink.tpl';
			}
		
		$this->render();		
	}

	
	public function confirm() {
	//this needs to first check to make sure response code was 0 = purchase successful//
		$verification = $_REQUEST['RESULT'];
		if($verification=='0'){
		$this->load->model('checkout/order');
		$id = $_REQUEST['USER1'];
		$this->model_checkout_order->confirm($id, $this->config->get('config_order_status_id'));
		}
	}
	

}
?>
catalog/view/theme/default/template/payment/

Code: Select all

<form action="<?php echo $action; ?>" method="post" id="checkout">
<b style="margin-bottom: 3px; display: block;"><?php echo $text_credit_card; ?></b>
<div id="payflowlink" style="background: #F7F7F7; border: 1px solid #DDDDDD; padding: 10px; margin-bottom: 10px;">

<!--Added for informational purposes -- Delete to next comment to remove-->
<!--<table width="100%">
	<tr>
	  <td style="text-align:center">Please Note : No information pertaing to your credit card is stored in our system <br />
	  Please read our <a href="#" target=”_blank”>Privacy Policy</a> for more details.</td>
    </tr>
</table>-->
<!--Delete to here to remove above information-->

<table width="100%">
    <tr>
      <td><?php echo $entry_credit_card_type; ?></td>
      <td><select name="credit_card_type">
          <?php foreach ($cards as $card) { ?>
          <option value="<?php echo $card['value']; ?>"><?php echo $card['text']; ?></option>
          <?php } ?>
        </select></td>
    </tr>
    <tr>
      <td><?php echo $entry_credit_card_number; ?></td>
      <td><input type="text" name="CARDNUM" value="" /> <!--&nbsp;&nbsp;&nbsp;*Card number only, no spaces or hyphens--></td>
    </tr>
   
    <tr>
      <td><?php echo $entry_expire_date; ?></td>
      <td><select name="expire_date_month" id="cardExMonth">
          <?php foreach ($months as $month) { ?>
          <option value="<?php echo $month['value']; ?>"><?php echo $month['text']; ?></option>
          <?php } ?>
        </select>
        
        <select name="expire_date_year" id="cardExYear">
          <?php foreach ($year_expire as $year) { ?>
          <option value="<?php echo $year['value']; ?>"><?php echo $year['text']; ?></option>
          <?php } ?>
        </select></td>
    </tr>
<!--Updated to allow optional CSC collection-->
<!--Second update to create popups for help with CSC-->
    <?php if ($CSC == 1) { ?>	
    <tr>
      <td><?php echo $entry_CSC_number; ?></td>
      <td><input type="text" size="4" name="CSC" value="" maxlength="4" />&nbsp;&nbsp;&nbsp; <a href=javascript:{}; onclick="javascript:{window.open('./system/csc.html','test','height=550,width=800,top=100,left=100');false}"> Help me locate my CSC</a></td>
      <td  valign="left"><a href=javascript:{}; onclick="javascript:{window.open('./system/csc.html','test','height=550,width=800,top=100,left=100');false}"><img src="image/csc.gif" title="csc explained" alt="csc explained" /></a></td>
	  </tr>
	<?php } ?>	
  </table>
</div>
  <input type="hidden" name="LOGIN" value="<?php echo $MERCHANT; ?>" />
  <input type="hidden" name="PARTNER" value="<?php echo $PARTNER; ?>" />
  <input type="hidden" name="TYPE" value="<?php echo $TYPE; ?>" />
  <input type="hidden" name="AMOUNT" value="<?php echo $amount; ?>" />
  <input type="hidden" id="cardEXP" name="EXPDATE" value="b" />
  <input type="hidden" name="ORDERFORM" value="False">
  <input type="hidden" name="SHOWCONFIRM" value="False">
  <input type="hidden" name="USER1" value="<?php echo $order_id; ?>" />
  <input type="hidden" name="DESCRIPTION" value="<?php echo $description; ?>" /> 
  <!--because we're not using the form, have to pass the following values-->
  <input type="hidden" name="NAME" value="<?php echo $name; ?>" />
  <input type="hidden" name="ADDRESS" value="<?php echo $address; ?>" />
  <input type="hidden" name="CITY" value="<?php echo $city; ?>" />
  <input type="hidden" name="ZIP" value="<?php echo $zip; ?>" />
  <input type="hidden" name="PHONE" value="<?php echo $telephone; ?>" />
  <input type="hidden" name="STATE" value="<?php echo $state; ?>" />
  <input type="hidden" name="country" value="<?php echo $country; ?>" />
  <input type="hidden" name="email" value="<?php echo $email; ?>" />  
</form>
<div class="buttons">
  <table>
    <tr>
      <td align="left"></td>
      <td align="right"><a onclick="confirmSubmit();" href="<?php echo $button_confirm; ?>" class="button"><span><?php echo $button_confirm; ?></span></a></td>
    </tr>
  </table>
</div>
<script type="text/javascript"><!--
function confirmSubmit() {
	var cardExMonth = $('#cardExMonth').attr("value");
	var cardExYear = $('#cardExYear').attr("value");
	cardExConcat = cardExMonth  +  cardExYear;
	$('#cardEXP').val(cardExConcat);
	$('#checkout').submit();
}
//--></script>
catalog/model/payment/

Code: Select all

<?php 
class ModelPaymentPayflowlink extends Model {
  	public function getMethod($address, $total) {
		$this->load->language('payment/payflowlink');
		
		if ($this->config->get('payflowlink_status')) {
//			$address = $this->customer->getAddress($this->session->data['payment_address_id']);
			
      		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$this->config->get('payflowlink_geo_zone_id') . "' AND country_id = '" . (int)$address['country_id'] . "' AND (zone_id = '" . (int)$address['zone_id'] . "' OR zone_id = '0')");
			
			if (!$this->config->get('payflowlink_geo_zone_id')) {
        		$status = TRUE;
      		} elseif ($query->num_rows) {
      		  	$status = TRUE;
      		} else {
     	  		$status = FALSE;
			}	
      	} else {
			$status = FALSE;
		}
		
		$method_data = array();
	
		if ($status) {  
      		$method_data = array( 
        		'code'         => 'payflowlink',
        		'title'      => $this->language->get('text_title'),
				'sort_order' => $this->config->get('payflowlink_sort_order')
      		);
    	}
   
    	return $method_data;
  	}
}
?>
Running OpenCart 1.5.2.1
Does anyone have experience with this? Thanks in advance!

Re: Need help with Payment Module

Posted: Thu Apr 19, 2012 11:31 am
by mandamexico
Done. Thank you Straightlight 8)

Re: [SOLVED] Need help with Payment Module

Posted: Fri Jul 20, 2012 6:54 am
by parvathy
Hi

Could you please help me to integrate the credit card details in to my website.I am wondering where to put this codes.Instead of pp_standard.php(paypal) in all the three module I have changed with your code but It seems not showing the radio button credit or debit in the payment section.Can you tell me what exactly I need to do to fix this problem.Any help would greatly appreciated.

Thanks

Re: [SOLVED] Need help with Payment Module

Posted: Sat Sep 15, 2012 5:54 am
by mandamexico
I have this extension for purchase already. Search for Payflow Link in the Extensions section of the site.