Hi me again:
The problem with Paypal standard persists (OC 1.3.2), I tried to test mode and also in normal mode.
Then show the contents of files associated with paypal standard.
catalog/controller/payment/pp_standrad.php
Code: Select all
<?php
class ControllerPaymentPPStandard extends Controller {
protected function index() {
$this->data['button_confirm'] = $this->language->get('button_confirm');
$this->data['button_back'] = $this->language->get('button_back');
if (!$this->config->get('pp_standard_test')) {
$this->data['action'] = 'https://www.paypal.com/cgi-bin/webscr';
} else {
$this->data['action'] = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
}
$this->load->model('checkout/order');
$order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']);
$this->data['business'] = $this->config->get('pp_standard_email');
$this->data['item_name'] = html_entity_decode($this->config->get('config_store'), ENT_QUOTES, 'UTF-8');
$this->data['currency_code'] = $order_info['currency'];
$this->data['amount'] = $this->currency->format($order_info['total'], $order_info['currency'], $order_info['value'], FALSE);
$this->data['first_name'] = html_entity_decode($order_info['payment_firstname'], ENT_QUOTES, 'UTF-8');
$this->data['last_name'] = html_entity_decode($order_info['payment_lastname'], ENT_QUOTES, 'UTF-8');
$this->data['address1'] = html_entity_decode($order_info['payment_address_1'], ENT_QUOTES, 'UTF-8');
$this->data['address2'] = html_entity_decode($order_info['payment_address_2'], ENT_QUOTES, 'UTF-8');
$this->data['city'] = html_entity_decode($order_info['payment_city'], ENT_QUOTES, 'UTF-8');
$this->data['zip'] = html_entity_decode($order_info['payment_postcode'], ENT_QUOTES, 'UTF-8');
$payment_address = $this->customer->getAddress($this->session->data['payment_address_id']);
$this->data['country'] = $payment_address['iso_code_2'];
$this->data['notify_url'] = $this->url->http('payment/pp_standard/callback');
$this->data['email'] = $order_info['email'];
$this->data['invoice'] = $this->session->data['order_id'] . ' - ' . html_entity_decode($order_info['payment_firstname'], ENT_QUOTES, 'UTF-8') . ' ' . html_entity_decode($order_info['payment_lastname'], ENT_QUOTES, 'UTF-8');
$this->data['lc'] = $this->language->getCode();
if (!$this->config->get('pp_standard_transaction')) {
$this->data['paymentaction'] = 'authorization';
} else {
$this->data['paymentaction'] = 'sale';
}
$this->data['return'] = $this->url->https('checkout/success');
$this->data['cancel_return'] = $this->url->https('checkout/payment');
$this->load->library('encryption');
$encryption = new Encryption($this->config->get('config_encryption'));
$this->data['custom'] = $encryption->encrypt($this->session->data['order_id']);
$this->data['back'] = $this->url->https('checkout/payment');
$this->id = 'payment';
$this->template = $this->config->get('config_template') . 'payment/pp_standard.tpl';
$this->render();
}
public function callback() {
$this->load->library('encryption');
$encryption = new Encryption($this->config->get('config_encryption'));
if (isset($this->request->post['custom'])) {
$order_id = $encryption->decrypt($this->request->post['custom']);
} else {
$order_id = 0;
}
$this->load->model('checkout/order');
$order_info = $this->model_checkout_order->getOrder($order_id);
if ($order_info) {
$request = 'cmd=_notify-validate';
foreach ($this->request->post as $key => $value) {
$request .= '&' . $key . '=' . urlencode(stripslashes($value));
}
if (extension_loaded('curl')) {
if (!$this->config->get('pp_standard_test')) {
$ch = curl_init('https://www.paypal.com/cgi-bin/webscr');
} else {
$ch = curl_init('https://www.sandbox.paypal.com/cgi-bin/webscr');
}
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
if (strcmp($response, 'VERIFIED') == 0) {
$this->model_checkout_order->confirm($order_id, $this->config->get('pp_standard_order_status_id'));
}
curl_close($ch);
} else {
$header = 'POST /cgi-bin/webscr HTTP/1.0' . "\r\n";
$header .= 'Content-Type: application/x-www-form-urlencoded' . "\r\n";
$header .= 'Content-Length: ' . strlen(utf8_decode($request)) . "\r\n\r\n";
$header .= 'Connection: close' ."\r\n\r\n";
if (!$this->config->get('pp_standard_test')) {
$fp = fsockopen('www.paypal.com', 80, $errno, $errstr, 30);
} else {
$fp = fsockopen('www.sandbox.paypal.com', 80, $errno, $errstr, 30);
}
if ($fp) {
fputs($fp, $header . $request);
while (!feof($fp)) {
$response = fgets($fp, 1024);
if (strcmp($response, 'VERIFIED') == 0) {
$this->model_checkout_order->confirm($order_id, $this->config->get('pp_standard_order_status_id'));
}
}
fclose($fp);
}
}
}
}
}
?>
catalog/view/theme/default/template/payment/pp_standard.tpl
Code: Select all
<form action="<?php echo $action; ?>" method="post" id="checkout">
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="business" value="<?php echo $business; ?>" />
<input type="hidden" name="item_name" value="<?php echo $item_name; ?>" />
<input type="hidden" name="currency_code" value="<?php echo $currency_code; ?>" />
<input type="hidden" name="amount" value="<?php echo $amount; ?>" />
<input type="hidden" name="first_name" value="<?php echo $first_name; ?>" />
<input type="hidden" name="last_name" value="<?php echo $last_name; ?>" />
<input type="hidden" name="address1" value="<?php echo $address1; ?>" />
<input type="hidden" name="address2" value="<?php echo $address2; ?>" />
<input type="hidden" name="city" value="<?php echo $city; ?>" />
<input type="hidden" name="zip" value="<?php echo $zip; ?>" />
<input type="hidden" name="country" value="<?php echo $country; ?>" />
<input type="hidden" name="address_override" value="0" />
<input type="hidden" name="notify_url" value="<?php echo $notify_url; ?>" />
<input type="hidden" name="email" value="<?php echo $email; ?>" />
<input type="hidden" name="invoice" value="<?php echo $invoice; ?>" />
<input type="hidden" name="lc" value="<?php echo $lc; ?>" />
<input type="hidden" name="return" value="<?php echo $return; ?>" />
<input type="hidden" name="rm" value="2" />
<input type="hidden" name="no_note" value="1" />
<input type="hidden" name="cancel_return" value="<?php echo $cancel_return; ?>" />
<input type="hidden" name="paymentaction" value="<?php echo $paymentaction; ?>" />
<input type="hidden" name="custom" value="<?php echo $custom; ?>" />
</form>
<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="$('#checkout').submit();" class="button"><span><?php echo $button_confirm; ?></span></a></td>
</tr>
</table>
</div>
And they also attached a screenshot of the behavior of Firebug at the right time to finish the payment with paypal standard mode normal.
Thanks in advance for your help.