Post by Vectra » Thu Feb 28, 2013 9:58 am

v1.5.2.1 I need the OpenCart order number to show up at PayPalPro. I will guess that the catalog/controller/payment/pp_pro.php file needs to be updated? Here is the middle section of it:

Code: Select all

		if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/pp_pro.tpl')) {
			$this->template = $this->config->get('config_template') . '/template/payment/pp_pro.tpl';
		} else {
			$this->template = 'default/template/payment/pp_pro.tpl';
		}	
		
		$this->render();		
	}

	public function send() {
		if (!$this->config->get('pp_pro_transaction')) {
			$payment_type = 'Authorization';	
		} else {
			$payment_type = 'Sale';
		}
		
		$this->load->model('checkout/order');
		
		$order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']);
		
		$request  = 'METHOD=DoDirectPayment';
		$request .= '&VERSION=51.0';
		$request .= '&USER=' . urlencode($this->config->get('pp_pro_username'));
		$request .= '&PWD=' . urlencode($this->config->get('pp_pro_password'));
		$request .= '&SIGNATURE=' . urlencode($this->config->get('pp_pro_signature'));
		$request .= '&CUSTREF=' . (int)$order_info['order_id'];
		$request .= '&PAYMENTACTION=' . $payment_type;
		$request .= '&AMT=' . $this->currency->format($order_info['total'], $order_info['currency_code'], false, false);
		$request .= '&CREDITCARDTYPE=' . $this->request->post['cc_type'];
		$request .= '&ACCT=' . urlencode(str_replace(' ', '', $this->request->post['cc_number']));
		$request .= '&CARDSTART=' . urlencode($this->request->post['cc_start_date_month'] . $this->request->post['cc_start_date_year']);
		$request .= '&EXPDATE=' . urlencode($this->request->post['cc_expire_date_month'] . $this->request->post['cc_expire_date_year']);
		$request .= '&CVV2=' . urlencode($this->request->post['cc_cvv2']);
		
		if ($this->request->post['cc_type'] == 'SWITCH' || $this->request->post['cc_type'] == 'SOLO') { 
			$request .= '&CARDISSUE=' . urlencode($this->request->post['cc_issue']);
		}
		
		$request .= '&FIRSTNAME=' . urlencode($order_info['payment_firstname']);
		$request .= '&LASTNAME=' . urlencode($order_info['payment_lastname']);
		$request .= '&EMAIL=' . urlencode($order_info['email']);
		$request .= '&PHONENUM=' . urlencode($order_info['telephone']);
		$request .= '&IPADDRESS=' . urlencode($this->request->server['REMOTE_ADDR']);
		$request .= '&STREET=' . urlencode($order_info['payment_address_1']);
		$request .= '&CITY=' . urlencode($order_info['payment_city']);
		$request .= '&STATE=' . urlencode(($order_info['payment_iso_code_2'] != 'US') ? $order_info['payment_zone'] : $order_info['payment_zone_code']);
		$request .= '&ZIP=' . urlencode($order_info['payment_postcode']);
		$request .= '&COUNTRYCODE=' . urlencode($order_info['payment_iso_code_2']);
		$request .= '&CURRENCYCODE=' . urlencode($order_info['currency_code']);
		
        if ($this->cart->hasShipping()) {
			$request .= '&SHIPTONAME=' . urlencode($order_info['shipping_firstname'] . ' ' . $order_info['shipping_lastname']);
			$request .= '&SHIPTOSTREET=' . urlencode($order_info['shipping_address_1']);
			$request .= '&SHIPTOCITY=' . urlencode($order_info['shipping_city']);
			$request .= '&SHIPTOSTATE=' . urlencode(($order_info['shipping_iso_code_2'] != 'US') ? $order_info['shipping_zone'] : $order_info['shipping_zone_code']);
			$request .= '&SHIPTOCOUNTRYCODE=' . urlencode($order_info['shipping_iso_code_2']);
			$request .= '&SHIPTOZIP=' . urlencode($order_info['shipping_postcode']);
        } else {
			$request .= '&SHIPTONAME=' . urlencode($order_info['payment_firstname'] . ' ' . $order_info['payment_lastname']);
			$request .= '&SHIPTOSTREET=' . urlencode($order_info['payment_address_1']);
			$request .= '&SHIPTOCITY=' . urlencode($order_info['payment_city']);
			$request .= '&SHIPTOSTATE=' . urlencode(($order_info['payment_iso_code_2'] != 'US') ? $order_info['payment_zone'] : $order_info['payment_zone_code']);
			$request .= '&SHIPTOCOUNTRYCODE=' . urlencode($order_info['payment_iso_code_2']);
			$request .= '&SHIPTOZIP=' . urlencode($order_info['payment_postcode']);			
		}		
How do I get the order number to show up at PayPalPro?
I thank you.

New member

Posts

Joined
Sat May 12, 2012 3:32 am

Post by Vectra » Fri Mar 01, 2013 2:53 am

I am wondering how others reconcile/balance their payments when PayPalPro does not have a reference number (either the order number or invoice number). The dollar amount is not always the same due to a discount or other change. Some times the name even changes (credit card name is different than person/company you are shipping to).
We download all history from PayPalPro into an Excel file for reconciling in accounting. The job is quick with an order reference number. The hunting required without an order reference number is too much.
Is it possible for PayPalPro to have some kind of order reference number to help balance our books?
Thank you.

New member

Posts

Joined
Sat May 12, 2012 3:32 am

Post by labeshops » Fri Mar 01, 2013 2:59 am

I search by the transaction number that opencart posts in your order history. Takes 2 seconds.

Running Opencart v3.0.3.9 with multi-stores and the default template from https://www.labeshops.com which has links to all my stores.


User avatar
Expert Member

Posts

Joined
Thu Aug 04, 2011 4:41 am
Location - Florida, USA

Post by Vectra » Fri Mar 01, 2013 6:57 am

Thank you for the reply. Our accountant doesn't go into OpenCart. He balances the PayPal export with our internal order system called Syspro (that we use for manufacturing, purchasing, and put our sales orders into).
He came up with this solution though: The PayPal export has its transaction ID, and OpenCart shows this same transaction ID at OCadmin/Sales/Orders/view/order history.
order history.png

order history.png (30 KiB) Viewed 2342 times

We just need this transaction ID printed on the OpenCart invoice, (probably by "Order ID:" at the top right).
Here is this section of the invoice code (admin/view/template/sale/order_invoice.tpl):

Code: Select all

          <?php if ($order['invoice_no']) { ?>
          <tr>
            <td><b><?php echo $text_invoice_no; ?></b></td>
            <td><?php echo $order['invoice_no']; ?></td>
          </tr>
          <?php } ?>
          <tr>
            <td><b><?php echo $text_order_id; ?></b></td>
            <td><?php echo $order['order_id']; ?></td>
          </tr>
          <tr>
            <td><b><?php echo $text_payment_method; ?></b></td>
            <td><?php echo $order['payment_method']; ?></td>
          </tr>
What td code do I need to insert above to show the TRANSACTIONID: on the printed OpenCart invoice?
Thank you.

New member

Posts

Joined
Sat May 12, 2012 3:32 am

Post by labeshops » Fri Mar 01, 2013 7:56 am

The problem is the transaction ID is not stored as a separate field in the database - it only ports to the order history section. Not even sure if it's possible to pull it into the array in the controller file.

Running Opencart v3.0.3.9 with multi-stores and the default template from https://www.labeshops.com which has links to all my stores.


User avatar
Expert Member

Posts

Joined
Thu Aug 04, 2011 4:41 am
Location - Florida, USA

Post by Vectra » Sat Mar 02, 2013 1:57 am

Thank you for the reply. I trust your statement, but I decided to try something even though I don't know the code or its interactions. I pulled this code line from order_history.tpl:

Code: Select all

<td><?php echo $history['comment']; ?></td>
and put it into order_invoice.tpl. Then I clicked the "print invoice" button in admin. The print had a "Notice: undefined variable: history in....".
I don't understand how I can view an old or new order in Admin and click the "Order History" tab, and always see the PayPal transactionid right there on the screen, and not be able to put this same comment into the invoice print. But, like I said, I don't know the interactions or the code. Here is the full order_history.tpl file:

Code: Select all

<?php if ($error_warning) { ?>
<div class="warning"><?php echo $error_warning; ?></div>
<?php } ?>
<?php if ($success) { ?>
<div class="success"><?php echo $success; ?></div>
<?php } ?>
<table class="list">
  <thead>
    <tr>
      <td class="left"><b><?php echo $column_date_added; ?></b></td>
      <td class="left"><b><?php echo $column_comment; ?></b></td>
      <td class="left"><b><?php echo $column_status; ?></b></td>
      <td class="left"><b><?php echo $column_notify; ?></b></td>
    </tr>
  </thead>
  <tbody>
    <?php if ($histories) { ?>
    <?php foreach ($histories as $history) { ?>
    <tr>
      <td class="left"><?php echo $history['date_added']; ?></td>
      <td class="left"><?php echo $history['comment']; ?></td>
      <td class="left"><?php echo $history['status']; ?></td>
      <td class="left"><?php echo $history['notify']; ?></td>
    </tr>
    <?php } ?>
    <?php } else { ?>
    <tr>
      <td class="center" colspan="4"><?php echo $text_no_results; ?></td>
    </tr>
    <?php } ?>
  </tbody>
</table>
<div class="pagination"><?php echo $pagination; ?></div>
It won't help to bring more of this file over to the order_invoice.tpl file like?:

Code: Select all

    <?php if ($histories) { ?>
    <?php foreach ($histories as $history) { ?>
Thank you.

New member

Posts

Joined
Sat May 12, 2012 3:32 am

Post by labeshops » Sat Mar 02, 2013 3:44 am

That's because of the way MCV works. Each template in opencart utilizes a Model and Controller file. To simplify it, the model file pulls fields out of the database, the controller defines the variables, and the template organizes that data to View it.

You would need to make sure the order model file is pulling the history comment and define it in the sale controller file so that it can be pulled in the invoice.tpl.

Running Opencart v3.0.3.9 with multi-stores and the default template from https://www.labeshops.com which has links to all my stores.


User avatar
Expert Member

Posts

Joined
Thu Aug 04, 2011 4:41 am
Location - Florida, USA

Post by Vectra » Sat Mar 02, 2013 5:37 am

I thank you again.
I see that the catalog/model/account/order.php file has this instance of "comment" in the main return array:

Code: Select all

				'payment_iso_code_3'      => $payment_iso_code_3,
				'payment_address_format'  => $order_query->row['payment_address_format'],
				'payment_method'          => $order_query->row['payment_method'],
				'comment'                 => $order_query->row['comment'],
				'total'                   => $order_query->row['total'],
				'order_status_id'         => $order_query->row['order_status_id'],
and farther down this "comment":

Code: Select all

		$query = $this->db->query("SELECT date_added, os.name AS status, oh.comment, oh.notify FROM " . DB_PREFIX . "order_history oh LEFT JOIN " . DB_PREFIX . "order_status os ON oh.order_status_id = os.order_status_id WHERE oh.order_id = '" . (int)$order_id . "' AND oh.notify = '1' AND os.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY oh.date_added");
The catalog/controller/account/order.php file has these instances of "comment":

Code: Select all

      		$this->data['text_payment_address'] = $this->language->get('text_payment_address');
      		$this->data['text_history'] = $this->language->get('text_history');
			$this->data['text_comment'] = $this->language->get('text_comment');

      		$this->data['column_name'] = $this->language->get('column_name');
      		$this->data['column_model'] = $this->language->get('column_model');
      		$this->data['column_quantity'] = $this->language->get('column_quantity');
      		$this->data['column_price'] = $this->language->get('column_price');
      		$this->data['column_total'] = $this->language->get('column_total');
			$this->data['column_action'] = $this->language->get('column_action');
			$this->data['column_date_added'] = $this->language->get('column_date_added');
      		$this->data['column_status'] = $this->language->get('column_status');
      		$this->data['column_comment'] = $this->language->get('column_comment');
and farther down also:

Code: Select all

      		$this->data['totals'] = $this->model_account_order->getOrderTotals($this->request->get['order_id']);
			
			$this->data['comment'] = nl2br($order_info['comment']);
			
			$this->data['histories'] = array();

			$results = $this->model_account_order->getOrderHistories($this->request->get['order_id']);

      		foreach ($results as $result) {
        		$this->data['histories'][] = array(
          			'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])),
          			'status'     => $result['status'],
          			'comment'    => nl2br($result['comment'])
        		);
      		}
Is this the correct "comment" that I need?
Thank you.

New member

Posts

Joined
Sat May 12, 2012 3:32 am

Post by labeshops » Sat Mar 02, 2013 10:56 pm

I believe that is the comment a customer leaves when they place the order, not the order history paypal pro posts into.

Running Opencart v3.0.3.9 with multi-stores and the default template from https://www.labeshops.com which has links to all my stores.


User avatar
Expert Member

Posts

Joined
Thu Aug 04, 2011 4:41 am
Location - Florida, USA
Who is online

Users browsing this forum: No registered users and 1 guest