Post by CVFRacing » Sun Feb 14, 2010 12:20 pm

For some reason, my open cart site isn't passing the shipping address and other details on to paypal. I get payments just fine, but not the address. Makes it a pain to ship using paypal. Any ideas? I searched the forum and didn't find a solution. Using 1.3.4

Newbie

Posts

Joined
Fri Jun 26, 2009 4:11 am

Post by Miguelito » Mon Feb 15, 2010 5:03 pm

Post your paypal controller php script (from dir /catalog/controller/payment/)and template script (from dir /catalog/view/theme/default/template/payment).

The Finnish OpenCart Forum
"Real programmers don't document. If it was hard to write, it should be hard to understand."


Active Member

Posts

Joined
Sun Jan 10, 2010 10:11 pm

Post by CVFRacing » Tue Feb 16, 2010 5:40 am

PHP Script

<?php
class ControllerPaymentPPPro extends Controller {
protected function index() {
$this->language->load('payment/pp_pro');

$this->data['text_credit_card'] = $this->language->get('text_credit_card');
$this->data['text_start_date'] = $this->language->get('text_start_date');
$this->data['text_issue'] = $this->language->get('text_issue');
$this->data['text_wait'] = $this->language->get('text_wait');

$this->data['entry_cc_owner'] = $this->language->get('entry_cc_owner');
$this->data['entry_cc_type'] = $this->language->get('entry_cc_type');
$this->data['entry_cc_number'] = $this->language->get('entry_cc_number');
$this->data['entry_cc_start_date'] = $this->language->get('entry_cc_start_date');
$this->data['entry_cc_expire_date'] = $this->language->get('entry_cc_expire_date');
$this->data['entry_cc_cvv2'] = $this->language->get('entry_cc_cvv2');
$this->data['entry_cc_issue'] = $this->language->get('entry_cc_issue');

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

$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' => 'Discover Card',
'value' => 'DISCOVER'
);

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

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

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

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

for ($i = 1; $i <= 12; $i++) {
$this->data['months'][] = array(
'text' => strftime('%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'] + 11; $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 ($this->request->get['route'] != 'checkout/guest/confirm') {
$this->data['back'] = $this->url->https('checkout/payment');
} else {
$this->data['back'] = $this->url->https('checkout/guest');
}

$this->id = 'payment';

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_test')) {
$api_endpoint = 'https://api-3t.paypal.com/nvp';
} else {
$api_endpoint = 'https://api-3t.sandbox.paypal.com/nvp';
}

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']);

$payment_data = array(
'METHOD' => 'DoDirectPayment',
'VERSION' => '51.0',
'USER' => html_entity_decode($this->config->get('pp_pro_username'), ENT_QUOTES, 'UTF-8'),
'PWD' => html_entity_decode($this->config->get('pp_pro_password'), ENT_QUOTES, 'UTF-8'),
'SIGNATURE' => html_entity_decode($this->config->get('pp_pro_signature'), ENT_QUOTES, 'UTF-8'),
'CUSTREF' => $order_info['order_id'],
'PAYMENTACTION' => $payment_type,
'AMT' => $this->currency->format($order_info['total'], $order_info['currency'], 1.00000, FALSE),
'CREDITCARDTYPE' => $this->request->post['cc_type'],
'ACCT' => str_replace(' ', '', $this->request->post['cc_number']),
'CARDSTART' => $this->request->post['cc_start_date_month'] . $this->request->post['cc_start_date_year'],
'EXPDATE' => $this->request->post['cc_expire_date_month'] . $this->request->post['cc_expire_date_year'],
'CVV2' => $this->request->post['cc_cvv2'],
'CARDISSUE' => $this->request->post['cc_issue'],
'FIRSTNAME' => $order_info['payment_firstname'],
'LASTNAME' => $order_info['payment_lastname'],
'EMAIL' => $order_info['email'],
'PHONENUM' => $order_info['telephone'],
'IPADDRESS' => $this->request->server['REMOTE_ADDR'],
'STREET' => $order_info['payment_address_1'],
'CITY' => $order_info['payment_city'],
'STATE' => ($order_info['payment_iso_code_2'] != 'US') ? $order_info['payment_zone'] : $order_info['payment_zone_code'],
'ZIP' => $order_info['payment_postcode'],
'COUNTRYCODE' => $order_info['payment_iso_code_2'],
'CURRENCYCODE' => $order_info['currency']
);

$curl = curl_init($api_endpoint);

curl_setopt($curl, CURLOPT_PORT, 443);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FORBID_REUSE, 1);
curl_setopt($curl, CURLOPT_FRESH_CONNECT, 1);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($payment_data));

$response = curl_exec($curl);

curl_close($curl);

if (!$response) {
exit('DoDirectPayment failed: ' . curl_error($curl) . '(' . curl_errno($curl) . ')');
}

$response_data = array();

parse_str($response, $response_data);

$json = array();

if (($response_data['ACK'] == 'Success') || ($response_data['ACK'] == 'SuccessWithWarning')) {
$this->model_checkout_order->confirm($this->session->data['order_id'], $this->config->get('config_order_status_id'));

$message = '';

if (isset($response_data['AVSCODE'])) {
$message .= 'AVSCODE: ' . $response_data['AVSCODE'] . "\n";
}

if (isset($response_data['CVV2MATCH'])) {
$message .= 'CVV2MATCH: ' . $response_data['CVV2MATCH'] . "\n";
}

if (isset($response_data['TRANSACTIONID'])) {
$message .= 'TRANSACTIONID: ' . $response_data['TRANSACTIONID'] . "\n";
}

$this->model_checkout_order->update($this->session->data['order_id'], $this->config->get('pp_pro_order_status_id'), $message, FALSE);

$json['success'] = $this->url->https('checkout/success');
} else {
$json['error'] = $response_data['L_LONGMESSAGE0'];
}

$this->load->library('json');

$this->response->setOutput(Json::encode($json));
}
}
?>

Template

<b style="margin-bottom: 3px; display: block;"><?php echo $text_credit_card; ?></b>
<div id="paypal" style="background: #F7F7F7; border: 1px solid #DDDDDD; padding: 10px; margin-bottom: 10px;">
<table width="100%">
<tr>
<td><?php echo $entry_cc_type; ?></td>
<td><select name="cc_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_cc_number; ?></td>
<td><input type="text" name="cc_number" value="" /></td>
</tr>
<tr>
<td><?php echo $entry_cc_start_date; ?></td>
<td><select name="cc_start_date_month">
<?php foreach ($months as $month) { ?>
<option value="<?php echo $month['value']; ?>"><?php echo $month['text']; ?></option>
<?php } ?>
</select>
/
<select name="cc_start_date_year">
<?php foreach ($year_valid as $year) { ?>
<option value="<?php echo $year['value']; ?>"><?php echo $year['text']; ?></option>
<?php } ?>
</select>
<?php echo $text_start_date; ?></td>
</tr>
<tr>
<td><?php echo $entry_cc_expire_date; ?></td>
<td><select name="cc_expire_date_month">
<?php foreach ($months as $month) { ?>
<option value="<?php echo $month['value']; ?>"><?php echo $month['text']; ?></option>
<?php } ?>
</select>
/
<select name="cc_expire_date_year">
<?php foreach ($year_expire as $year) { ?>
<option value="<?php echo $year['value']; ?>"><?php echo $year['text']; ?></option>
<?php } ?>
</select></td>
</tr>
<tr>
<td><?php echo $entry_cc_cvv2; ?></td>
<td><input type="text" name="cc_cvv2" value="" size="3" /></td>
</tr>
<tr>
<td><?php echo $entry_cc_issue; ?></td>
<td><input type="text" name="cc_issue" value="" size="1" />
<?php echo $text_issue; ?></td>
</tr>
</table>
</div>
<div class="buttons">
<table>
<tr>
<td align="left"><a onclick="location='<?php echo $back; ?>'" class="button"><span><?php echo $button_back; ?></span></a></td>
<td align="right"><a onclick="confirmSubmit();" id="paypal_button" class="button"><span><?php echo $button_confirm; ?></span></a></td>
</tr>
</table>
</div>
<script type="text/javascript"><!--
function confirmSubmit() {
$.ajax({
type: 'POST',
url: 'index.php?route=payment/pp_pro/send',
data: $('#paypal :input'),
dataType: 'json',
beforeSend: function() {
$('#paypal_button').attr('disabled', 'disabled');

$('#paypal').before('<div class="wait"><img src="catalog/view/theme/default/image/loading_1.gif" alt="" /> <?php echo $text_wait; ?></div>');
},
success: function(data) {
if (data.error) {
alert(data.error);

$('#paypal_button').attr('disabled', '');
}

$('.wait').remove();

if (data.success) {
location = data.success;
}
}
});
}
//--></script>

Newbie

Posts

Joined
Fri Jun 26, 2009 4:11 am

Post by matthew@wormsetc.com » Tue Mar 09, 2010 12:59 pm

Bump

I am having the same problem.

thanks


Posts

Joined
Sun Jan 24, 2010 1:21 am

Post by cerami2 » Sat Jul 23, 2011 1:02 am

im having the same problem deos anyone have a fix

Newbie

Posts

Joined
Thu Jun 16, 2011 12:48 am

Post by IAA » Tue Sep 06, 2011 11:51 pm

Any remedy to this?

IAA
Newbie

Posts

Joined
Thu Jun 02, 2011 11:09 pm

Post by cerami2 » Tue Jan 10, 2012 2:48 am

its almost a year and still no help :'( :'(

Newbie

Posts

Joined
Thu Jun 16, 2011 12:48 am

Post by salahuddin » Fri Jan 13, 2012 2:46 am

Hi guys,

I am facing problem with paypal standard. When in purchage our credit card through pay on my opencart. then show a msg not verify your credit card information. this msg showing on paypal.
paypal standard with opemcart Version 1.4.9.1 transaction problem.

Please help me anybody. my skype ID salahuddin7864

Newbie

Posts

Joined
Fri Jan 13, 2012 2:34 am
Who is online

Users browsing this forum: No registered users and 111 guests