Hey Guys,
I'm working on a open cart store.
I am trying to create either coupons or vouchers. In 1.5 with the paypal standard module with the token enabled and everything.
Whenever we get to the paypal payment screen, the total is the originial price- not the new total with the price - coupon/voucher.
I read on here that people were having issues with the coupons, i am too- but I am also having issues with the voucher.
Is there a way to make the voucher module work?
Appreicate your time,
thanks
I'm working on a open cart store.
I am trying to create either coupons or vouchers. In 1.5 with the paypal standard module with the token enabled and everything.
Whenever we get to the paypal payment screen, the total is the originial price- not the new total with the price - coupon/voucher.
I read on here that people were having issues with the coupons, i am too- but I am also having issues with the voucher.
Is there a way to make the voucher module work?
Appreicate your time,
thanks
Backup your catalog/controller/payment/pp_standard.php file first
Then replace using this:
Then replace using this:
Code: Select all
<?php
class ControllerPaymentPPStandard extends Controller {
protected function index() {
$this->language->load('payment/pp_standard');
$this->data['text_testmode'] = $this->language->get('text_testmode');
$this->data['button_confirm'] = $this->language->get('button_confirm');
$this->data['testmode'] = $this->config->get('pp_standard_test');
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']);
if ($order_info) {
$currencies = array(
'AUD',
'CAD',
'EUR',
'GBP',
'JPY',
'USD',
'NZD',
'CHF',
'HKD',
'SGD',
'SEK',
'DKK',
'PLN',
'NOK',
'HUF',
'CZK',
'ILS',
'MXN',
'MYR',
'BRL',
'PHP',
'TWD',
'THB',
'TRY'
);
if (in_array($order_info['currency_code'], $currencies)) {
$currency = $order_info['currency_code'];
} else {
$currency = 'USD';
}
$this->data['business'] = $this->config->get('pp_standard_email');
$this->data['item_name'] = html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8');
$this->data['products'] = array();
foreach ($this->cart->getProducts() as $product) {
$option_data = array();
foreach ($product['option'] as $option) {
$option_data[] = array(
'name' => $option['name'],
'value' => $option['option_value']
);
}
$this->data['products'][] = array(
'name' => $product['name'],
'model' => $product['model'],
'price' => $this->currency->format($product['price'], $currency, false, false),
'quantity' => $product['quantity'],
'option' => $option_data,
'weight' => $product['weight']
);
}
$this->data['discount_amount_cart'] = 0;
$total = $this->currency->format($order_info['total'] - $this->cart->getSubTotal(), $currency, false, false);
if ($total > 0) {
$this->data['products'][] = array(
'name' => $this->language->get('text_total'),
'model' => '',
'price' => $total,
'quantity' => 1,
'option' => array(),
'weight' => 0
);
} else {
$this->data['discount_amount_cart'] -= $this->currency->format($total, $currency, FALSE, FALSE);
}
$this->data['currency_code'] = $currency;
$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');
$this->data['country'] = $order_info['payment_iso_code_2'];
$this->data['notify_url'] = $this->url->link('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->session->data['language'];
$this->data['return'] = $this->url->link('checkout/success');
$this->data['notify_url'] = $this->url->link('payment/pp_standard/callback');
$this->data['cancel_return'] = $this->url->link('checkout/checkout', '', 'SSL');
if (!$this->config->get('pp_standard_transaction')) {
$this->data['paymentaction'] = 'authorization';
} else {
$this->data['paymentaction'] = 'sale';
}
$this->load->library('encryption');
$encryption = new Encryption($this->config->get('config_encryption'));
$this->data['custom'] = $encryption->encrypt($this->session->data['order_id']);
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/pp_standard.tpl')) {
$this->template = $this->config->get('config_template') . '/template/payment/pp_standard.tpl';
} else {
$this->template = 'default/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(html_entity_decode($value, ENT_QUOTES, 'UTF-8'));
}
if (!$this->config->get('pp_standard_test')) {
$curl = curl_init('https://www.paypal.com/cgi-bin/webscr');
} else {
$curl = curl_init('https://www.sandbox.paypal.com/cgi-bin/webscr');
}
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $request);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($curl);
if (!$response) {
$this->log->write('PP_STANDARD :: CURL failed ' . curl_error($curl) . '(' . curl_errno($curl) . ')');
}
if ($this->config->get('pp_standard_debug')) {
$this->log->write('PP_STANDARD :: IPN REQUEST: ' . $request);
$this->log->write('PP_STANDARD :: IPN RESPONSE: ' . $response);
}
if ((strcmp($response, 'VERIFIED') == 0 || strcmp($response, 'UNVERIFIED') == 0) && isset($this->request->post['payment_status'])) {
$order_status_id = $this->config->get('config_order_status_id');
switch($this->request->post['payment_status']) {
case 'Canceled_Reversal':
$order_status_id = $this->config->get('pp_standard_canceled_reversal_status_id');
break;
case 'Completed':
if ((float)$this->request->post['mc_gross'] == $this->currency->format($order_info['total'], $order_info['currency_code'], $order_info['currency_value'], false)) {
$order_status_id = $this->config->get('pp_standard_completed_status_id');
}
break;
case 'Denied':
$order_status_id = $this->config->get('pp_standard_denied_status_id');
break;
case 'Expired':
$order_status_id = $this->config->get('pp_standard_expired_status_id');
break;
case 'Failed':
$order_status_id = $this->config->get('pp_standard_failed_status_id');
break;
case 'Pending':
$order_status_id = $this->config->get('pp_standard_pending_status_id');
break;
case 'Processed':
$order_status_id = $this->config->get('pp_standard_processed_status_id');
break;
case 'Refunded':
$order_status_id = $this->config->get('pp_standard_refunded_status_id');
break;
case 'Reversed':
$order_status_id = $this->config->get('pp_standard_reversed_status_id');
break;
case 'Voided':
$order_status_id = $this->config->get('pp_standard_voided_status_id');
break;
}
if (!$order_info['order_status_id']) {
$this->model_checkout_order->confirm($order_id, $order_status_id);
} else {
$this->model_checkout_order->update($order_id, $order_status_id);
}
} else {
$this->model_checkout_order->confirm($order_id, $this->config->get('config_order_status_id'));
}
curl_close($curl);
}
}
}
?>
There must be something else going wrong with your Opencart server. I am using the same pp_standard.php file as uksitebuilder , and it works fine with the coupons.
Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig
OK so you changed the pp_standard file. Reinstalled the module. Type your paypal email, token, put the setting to sale. And click save? And it all works?JNeuhoff wrote:There must be something else going wrong with your Opencart server. I am using the same pp_standard.php file as uksitebuilder , and it works fine with the coupons.
do you have these lines in catalog/view/theme/default/template/payment/pp_standard.tpl
around line: 23
around line: 23
Code: Select all
<?php if ($discount_amount_cart) { ?>
<input type="hidden" name="discount_amount_cart" value="<?php echo $discount_amount_cart; ?>" />
<?php } ?>
No I don't have anything like that. This is what I have..uksitebuilder wrote:do you have these lines in catalog/view/theme/default/template/payment/pp_standard.tpl
around line: 23
Code: Select all
<?php if ($discount_amount_cart) { ?> <input type="hidden" name="discount_amount_cart" value="<?php echo $discount_amount_cart; ?>" /> <?php } ?>
<?php if ($testmode) { ?>
<div class="warning"><?php echo $text_testmode; ?></div>
<?php } ?>
<form action="<?php echo $action; ?>" method="post" id="payment">
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="upload" value="1" />
<input type="hidden" name="business" value="<?php echo $business; ?>" />
<?php $i = 1; ?>
<?php foreach ($products as $product) { ?>
<input type="hidden" name="item_name_<?php echo $i; ?>" value="<?php echo $product['name']; ?>" />
<input type="hidden" name="item_number_<?php echo $i; ?>" value="<?php echo $product['model']; ?>" />
<input type="hidden" name="amount_<?php echo $i; ?>" value="<?php echo $product['price']; ?>" />
<input type="hidden" name="quantity_<?php echo $i; ?>" value="<?php echo $product['quantity']; ?>" />
<input type="hidden" name="weight_<?php echo $i; ?>" value="<?php echo $product['weight']; ?>" />
<?php $j = 0; ?>
<?php foreach ($product['option'] as $option) { ?>
<input type="hidden" name="on<?php echo $j; ?>_<?php echo $i; ?>" value="<?php echo $option['name']; ?>" />
<input type="hidden" name="os<?php echo $j; ?>_<?php echo $i; ?>" value="<?php echo $option['value']; ?>" />
<?php $j++; ?>
<?php } ?>
<?php $i++; ?>
<?php } ?>
<input type="hidden" name="currency_code" value="<?php echo $currency_code; ?>" />
<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="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="rm" value="2" />
<input type="hidden" name="no_note" value="1" />
<input type="hidden" name="charset" value="utf-8" />
<input type="hidden" name="return" value="<?php echo $return; ?>" />
<input type="hidden" name="notify_url" value="<?php echo $notify_url; ?>" />
<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">
<div class="right"><a id="button-confirm" class="button" onclick="$('#payment').submit();"><span><?php echo $button_confirm; ?></span></a></div>
</div>
Hi
I´m having the same problem with opencart 1.5.0
When i apply the coupon i got and error in paypal "Importe de artículo con un formato incorrecto."
I hope you could help solve that problem
Thank you very much
Regards
I´m having the same problem with opencart 1.5.0
When i apply the coupon i got and error in paypal "Importe de artículo con un formato incorrecto."
I hope you could help solve that problem
Thank you very much
Regards
version 1.5.1.1
theme is basically an altered default theme that was for version 1.5.1
www.Sixus1.com/store
I had to use the fix in this post (I was using a theme that obviously wasn't up to date) to get my coupons to apply. I did have one problem left in regards to this....
My order went through fine and the downloads were available in the account BUT the order was still in the cart. Does anyone know where and what I need to change ?
Thank you for your time,
Rebekah
theme is basically an altered default theme that was for version 1.5.1
www.Sixus1.com/store
I had to use the fix in this post (I was using a theme that obviously wasn't up to date) to get my coupons to apply. I did have one problem left in regards to this....
My order went through fine and the downloads were available in the account BUT the order was still in the cart. Does anyone know where and what I need to change ?
Thank you for your time,
Rebekah
uksitebuilder wrote:do you have these lines in catalog/view/theme/default/template/payment/pp_standard.tpl
around line: 23
Code: Select all
<?php if ($discount_amount_cart) { ?> <input type="hidden" name="discount_amount_cart" value="<?php echo $discount_amount_cart; ?>" /> <?php } ?>
Brilliant! Thankyou for your time.
I am having the same problem as originally indicated my the OP for this thread. (voucher is applying correctly, but when customer gets to paypal, the total in paypal doesn't include the discount/voucher amount.)
I'm using OpenCart 1.5.1.3.
Edited to add: I have implemented all the fixes listed here and am still getting the same result.
any help is greatly appreciated.
Thanks in advance,
Katey
I'm using OpenCart 1.5.1.3.
Edited to add: I have implemented all the fixes listed here and am still getting the same result.
any help is greatly appreciated.
Thanks in advance,
Katey
There also seem to be a problem with the redeem as also encountered for the coupon redeem.
In your catalog/model/checkout/voucher.php file,
find:
replace with:
In your catalog/model/checkout/voucher.php file,
find:
Code: Select all
public function redeem($voucher_id, $order_id, $amount) {
$this->db->query("INSERT INTO `" . DB_PREFIX . "voucher_history` SET voucher_id = '" . (int)$voucher_id . "', order_id = '" . (int)$order_id . "', amount = '" . (float)$amount . "', date_added = NOW()");
}
Code: Select all
$sql = "INSERT INTO " . DB_PREFIX . "voucher_history
(voucher_id, order_id, amount, date_added)
VALUES(" . (int)$voucher_id . ", " . (int)$order_id . ", " . (float)$amount . ", NOW())
";
$this->db->query($sql);
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Real BRILLIANT. You left out the state information just as in the ORIGINAL, which causes the credit card form not to be populated. SLOW DOWN and do RESEARCH before you post code.uksitebuilder wrote:Backup your catalog/controller/payment/pp_standard.php file first
Then replace using this:
Code: Select all
<?php class ControllerPaymentPPStandard extends Controller { protected function index() { $this->language->load('payment/pp_standard'); $this->data['text_testmode'] = $this->language->get('text_testmode'); $this->data['button_confirm'] = $this->language->get('button_confirm'); $this->data['testmode'] = $this->config->get('pp_standard_test'); 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']); if ($order_info) { $currencies = array( 'AUD', 'CAD', 'EUR', 'GBP', 'JPY', 'USD', 'NZD', 'CHF', 'HKD', 'SGD', 'SEK', 'DKK', 'PLN', 'NOK', 'HUF', 'CZK', 'ILS', 'MXN', 'MYR', 'BRL', 'PHP', 'TWD', 'THB', 'TRY' ); if (in_array($order_info['currency_code'], $currencies)) { $currency = $order_info['currency_code']; } else { $currency = 'USD'; } $this->data['business'] = $this->config->get('pp_standard_email'); $this->data['item_name'] = html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'); $this->data['products'] = array(); foreach ($this->cart->getProducts() as $product) { $option_data = array(); foreach ($product['option'] as $option) { $option_data[] = array( 'name' => $option['name'], 'value' => $option['option_value'] ); } $this->data['products'][] = array( 'name' => $product['name'], 'model' => $product['model'], 'price' => $this->currency->format($product['price'], $currency, false, false), 'quantity' => $product['quantity'], 'option' => $option_data, 'weight' => $product['weight'] ); } $this->data['discount_amount_cart'] = 0; $total = $this->currency->format($order_info['total'] - $this->cart->getSubTotal(), $currency, false, false); if ($total > 0) { $this->data['products'][] = array( 'name' => $this->language->get('text_total'), 'model' => '', 'price' => $total, 'quantity' => 1, 'option' => array(), 'weight' => 0 ); } else { $this->data['discount_amount_cart'] -= $this->currency->format($total, $currency, FALSE, FALSE); } $this->data['currency_code'] = $currency; $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'); $this->data['country'] = $order_info['payment_iso_code_2']; $this->data['notify_url'] = $this->url->link('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->session->data['language']; $this->data['return'] = $this->url->link('checkout/success'); $this->data['notify_url'] = $this->url->link('payment/pp_standard/callback'); $this->data['cancel_return'] = $this->url->link('checkout/checkout', '', 'SSL'); if (!$this->config->get('pp_standard_transaction')) { $this->data['paymentaction'] = 'authorization'; } else { $this->data['paymentaction'] = 'sale'; } $this->load->library('encryption'); $encryption = new Encryption($this->config->get('config_encryption')); $this->data['custom'] = $encryption->encrypt($this->session->data['order_id']); if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/pp_standard.tpl')) { $this->template = $this->config->get('config_template') . '/template/payment/pp_standard.tpl'; } else { $this->template = 'default/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(html_entity_decode($value, ENT_QUOTES, 'UTF-8')); } if (!$this->config->get('pp_standard_test')) { $curl = curl_init('https://www.paypal.com/cgi-bin/webscr'); } else { $curl = curl_init('https://www.sandbox.paypal.com/cgi-bin/webscr'); } curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, $request); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_TIMEOUT, 30); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); $response = curl_exec($curl); if (!$response) { $this->log->write('PP_STANDARD :: CURL failed ' . curl_error($curl) . '(' . curl_errno($curl) . ')'); } if ($this->config->get('pp_standard_debug')) { $this->log->write('PP_STANDARD :: IPN REQUEST: ' . $request); $this->log->write('PP_STANDARD :: IPN RESPONSE: ' . $response); } if ((strcmp($response, 'VERIFIED') == 0 || strcmp($response, 'UNVERIFIED') == 0) && isset($this->request->post['payment_status'])) { $order_status_id = $this->config->get('config_order_status_id'); switch($this->request->post['payment_status']) { case 'Canceled_Reversal': $order_status_id = $this->config->get('pp_standard_canceled_reversal_status_id'); break; case 'Completed': if ((float)$this->request->post['mc_gross'] == $this->currency->format($order_info['total'], $order_info['currency_code'], $order_info['currency_value'], false)) { $order_status_id = $this->config->get('pp_standard_completed_status_id'); } break; case 'Denied': $order_status_id = $this->config->get('pp_standard_denied_status_id'); break; case 'Expired': $order_status_id = $this->config->get('pp_standard_expired_status_id'); break; case 'Failed': $order_status_id = $this->config->get('pp_standard_failed_status_id'); break; case 'Pending': $order_status_id = $this->config->get('pp_standard_pending_status_id'); break; case 'Processed': $order_status_id = $this->config->get('pp_standard_processed_status_id'); break; case 'Refunded': $order_status_id = $this->config->get('pp_standard_refunded_status_id'); break; case 'Reversed': $order_status_id = $this->config->get('pp_standard_reversed_status_id'); break; case 'Voided': $order_status_id = $this->config->get('pp_standard_voided_status_id'); break; } if (!$order_info['order_status_id']) { $this->model_checkout_order->confirm($order_id, $order_status_id); } else { $this->model_checkout_order->update($order_id, $order_status_id); } } else { $this->model_checkout_order->confirm($order_id, $this->config->get('config_order_status_id')); } curl_close($curl); } } } ?>
Assuming your code is good, it should be as follows:
Code: Select all
<?php
class ControllerPaymentPPStandard extends Controller {
protected function index() {
$this->language->load('payment/pp_standard');
$this->data['text_testmode'] = $this->language->get('text_testmode');
$this->data['button_confirm'] = $this->language->get('button_confirm');
$this->data['testmode'] = $this->config->get('pp_standard_test');
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']);
if ($order_info) {
$currencies = array(
'AUD',
'CAD',
'EUR',
'GBP',
'JPY',
'USD',
'NZD',
'CHF',
'HKD',
'SGD',
'SEK',
'DKK',
'PLN',
'NOK',
'HUF',
'CZK',
'ILS',
'MXN',
'MYR',
'BRL',
'PHP',
'TWD',
'THB',
'TRY'
);
if (in_array($order_info['currency_code'], $currencies)) {
$currency = $order_info['currency_code'];
} else {
$currency = 'USD';
}
$this->data['business'] = $this->config->get('pp_standard_email');
$this->data['item_name'] = html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8');
$this->data['products'] = array();
foreach ($this->cart->getProducts() as $product) {
$option_data = array();
foreach ($product['option'] as $option) {
$option_data[] = array(
'name' => $option['name'],
'value' => $option['option_value']
);
}
$this->data['products'][] = array(
'name' => $product['name'],
'model' => $product['model'],
'price' => $this->currency->format($product['price'], $currency, false, false),
'quantity' => $product['quantity'],
'option' => $option_data,
'weight' => $product['weight']
);
}
$this->data['discount_amount_cart'] = 0;
$total = $this->currency->format($order_info['total'] - $this->cart->getSubTotal(), $currency, false, false);
if ($total > 0) {
$this->data['products'][] = array(
'name' => $this->language->get('text_total'),
'model' => '',
'price' => $total,
'quantity' => 1,
'option' => array(),
'weight' => 0
);
} else {
$this->data['discount_amount_cart'] -= $this->currency->format($total, $currency, FALSE, FALSE);
}
$this->data['currency_code'] = $currency;
$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['state'] = html_entity_decode($order_info['payment_zone_code'], ENT_QUOTES, 'UTF-8');
$this->data['zip'] = html_entity_decode($order_info['payment_postcode'], ENT_QUOTES, 'UTF-8');
$this->data['country'] = $order_info['payment_iso_code_2'];
$this->data['notify_url'] = $this->url->link('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->session->data['language'];
$this->data['return'] = $this->url->link('checkout/success');
$this->data['notify_url'] = $this->url->link('payment/pp_standard/callback');
$this->data['cancel_return'] = $this->url->link('checkout/checkout', '', 'SSL');
if (!$this->config->get('pp_standard_transaction')) {
$this->data['paymentaction'] = 'authorization';
} else {
$this->data['paymentaction'] = 'sale';
}
$this->load->library('encryption');
$encryption = new Encryption($this->config->get('config_encryption'));
$this->data['custom'] = $encryption->encrypt($this->session->data['order_id']);
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/pp_standard.tpl')) {
$this->template = $this->config->get('config_template') . '/template/payment/pp_standard.tpl';
} else {
$this->template = 'default/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(html_entity_decode($value, ENT_QUOTES, 'UTF-8'));
}
if (!$this->config->get('pp_standard_test')) {
$curl = curl_init('https://www.paypal.com/cgi-bin/webscr');
} else {
$curl = curl_init('https://www.sandbox.paypal.com/cgi-bin/webscr');
}
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $request);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($curl);
if (!$response) {
$this->log->write('PP_STANDARD :: CURL failed ' . curl_error($curl) . '(' . curl_errno($curl) . ')');
}
if ($this->config->get('pp_standard_debug')) {
$this->log->write('PP_STANDARD :: IPN REQUEST: ' . $request);
$this->log->write('PP_STANDARD :: IPN RESPONSE: ' . $response);
}
if ((strcmp($response, 'VERIFIED') == 0 || strcmp($response, 'UNVERIFIED') == 0) && isset($this->request->post['payment_status'])) {
$order_status_id = $this->config->get('config_order_status_id');
switch($this->request->post['payment_status']) {
case 'Canceled_Reversal':
$order_status_id = $this->config->get('pp_standard_canceled_reversal_status_id');
break;
case 'Completed':
if ((float)$this->request->post['mc_gross'] == $this->currency->format($order_info['total'], $order_info['currency_code'], $order_info['currency_value'], false)) {
$order_status_id = $this->config->get('pp_standard_completed_status_id');
}
break;
case 'Denied':
$order_status_id = $this->config->get('pp_standard_denied_status_id');
break;
case 'Expired':
$order_status_id = $this->config->get('pp_standard_expired_status_id');
break;
case 'Failed':
$order_status_id = $this->config->get('pp_standard_failed_status_id');
break;
case 'Pending':
$order_status_id = $this->config->get('pp_standard_pending_status_id');
break;
case 'Processed':
$order_status_id = $this->config->get('pp_standard_processed_status_id');
break;
case 'Refunded':
$order_status_id = $this->config->get('pp_standard_refunded_status_id');
break;
case 'Reversed':
$order_status_id = $this->config->get('pp_standard_reversed_status_id');
break;
case 'Voided':
$order_status_id = $this->config->get('pp_standard_voided_status_id');
break;
}
if (!$order_info['order_status_id']) {
$this->model_checkout_order->confirm($order_id, $order_status_id);
} else {
$this->model_checkout_order->update($order_id, $order_status_id);
}
} else {
$this->model_checkout_order->confirm($order_id, $this->config->get('config_order_status_id'));
}
curl_close($curl);
}
}
}
?>
I realize this is an old thread ... but I'm having problems with Paypal and 100% coupons with v. 1.5.1. Is there a way to have the inventory reduced and skip over Paypal completely, going to the 'Order Completed' page that Paypal takes you to when you have successfully paid? Any help would be greatly appreciated ...
Who is online
Users browsing this forum: No registered users and 330 guests