Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Official PayPal IPN Support Thread


Mark Evans

Recommended Posts

Well, would you believe it. ..... AYPAL. It turned out she had not checked the merchant option in her paypal account so paypal was doing al the shipping for her

We've all been there - including clients trying to use PayPal without a business account. I sometimes feel quite silly asking questions like "do you have a PayPal account?" but often it turns out it's the most basic thing that went wrong. Anyway, glad it's working! Terra

My code for combining PayPal IPN with ** QTPro 4.25 ** osC Affiliate ** CCGV(trad)

and how to solve the invoice already paid error

General info: Allow customer to delete order comment ** FTP Programs & Text Editors ** Amending order email **

Link to comment
Share on other sites

We have added IPN to our store recently, and our paypal orders appear to be doubling up. Not sure if this is with all our PayPal orders or just some of them.

 

One pair of the order is stuck in "Preparing [PayPal IPN]" with no order status comments, and the 2nd is in

"Recent" with a comment of "PayPal IPN Verified [Completed (Unverified; $x.xx)]". The issue was brought to our attention when customers started pointing out they had 2 orders in their order history for their one order.

 

We also recently added Fast Easy Checkout, but haven't noticed this doubling with orders via other payment methods.

 

Any advice on what to check or how to fix it?

Link to comment
Share on other sites

We have added IPN to our store recently, and our paypal orders appear to be doubling up. Not sure if this is with all our PayPal orders or just some of them.

 

One pair of the order is stuck in "Preparing [PayPal IPN]" with no order status comments, and the 2nd is in

"Recent" with a comment of "PayPal IPN Verified [Completed (Unverified; $x.xx)]". The issue was brought to our attention when customers started pointing out they had 2 orders in their order history for their one order.

 

We also recently added Fast Easy Checkout, but haven't noticed this doubling with orders via other payment methods.

 

Any advice on what to check or how to fix it?

 

Looked into it further, it only happens to one of the orders in the last week, we were looking at something the wrong way.

Link to comment
Share on other sites

check data base and note down the time when the orders were added.

if the difference is less then few seconds then your code might be inserting it twice.

 

 

Satish

Looked into it further, it only happens to one of the orders in the last week, we were looking at something the wrong way.

Ask/Skype for Free osCommerce value addon/SEO suggestion tips for your site.

 

Check My About US For who am I and what My company does.

Link to comment
Share on other sites

There is setting in paypal to over ride shipping and use its shipping calculations.

You need to check the paypal account profile setting and on shipping issues.

 

 

Satish Mantri

 

 

Well, would you believe it.

 

I worked on trying to figure my problem for over a day and could not find any way to fix it so felt it had to be something in osc thats the cause.

 

Installed oscmax, moved the db file over (compare etc) and within an hour I had the client an new site using oscmax, but there was that problem al ver again.

 

PAYPAL. It turned out she had not checked the merchant option in her paypal account so paypal was doing al the shipping for her

Ask/Skype for Free osCommerce value addon/SEO suggestion tips for your site.

 

Check My About US For who am I and what My company does.

Link to comment
Share on other sites

I'm in some serious need of help and want to verify this is in fact the solution. I have a few questions here. First a little background. I operate two websites. Site 1: runs the normal/plain ole paypal cart. Site 2: runs OSC with PayPal as the payment method.

 

Today on my OSC site I had a customer make a repeat purchase. I received the paypal payment but in the admin the order was not written to the database. I wound up having to call to find out what they ordered. Now after reading about this contribution it appears she did not click return to merchant and that caused it not to write the order to the database. Please can someone tell me if this is what happened?

 

If so, this contrib appears to be the solution.

 

Now I have another issue. On the regular PayPal cart site will this module effect anything with it. Right now the shipping and tax tables are shared between the two sites. I think I've figured out with this contrib I can get away from that but the PayPal cart site still has to use it. My main question is will this effect anything on the PayPal cart site. Site 1: has to stay exactly as it is.

 

Why keep the PayPal cart going you ask? My current customers hated OSC and I almost went under so I had to go back. So now I have 2 sites. I would love to have the shipping and tax and everything totally independant of each other.

 

Will this contribution do what I need? Plus actually pass the orders to me so I don't have to call the customer to get it?

 

I will clarify anything if I"ve confused anybody, I just need help! arggh!

 

Thanks!

 

Shell

Link to comment
Share on other sites

Shellgc,

I'm no expert here but regarding your customer not coming back to the merchant:

You are right about this contribution. However, you will need to manage orders with a status = Preparing [PayPal IPN]. Whenever the customer changes their mind and doesn't pay, then you will have to manually delete the order. Make sure you allow enough time before you delete it. Some recommend waiting up to 48 hours.

 

Regarding your shipping and taxes question, I have no idea.

 

I am interested as to why your customers hated osCommerce?

 

Cheers,

Nap

Link to comment
Share on other sites

Shellgc,

I'm no expert here but regarding your customer not coming back to the merchant:

You are right about this contribution. However, you will need to manage orders with a status = Preparing [PayPal IPN]. Whenever the customer changes their mind and doesn't pay, then you will have to manually delete the order. Make sure you allow enough time before you delete it. Some recommend waiting up to 48 hours.

 

Regarding your shipping and taxes question, I have no idea.

 

I am interested as to why your customers hated osCommerce?

 

Cheers,

Nap

 

I just downloaded the module and my answer about not returning to merchant was in the first paragraph. Sorry about that.

 

My customers hated it because my original site is super easy to use, basically 1 page to checkout. No signing up etc. The OSC looks totally different and works totally different 7-8 pages to checkout (I've got it down to 2-3 now). I'm not exactly sure why but I wish they'd move over to OSC, much easier for me!! The whole point of the new site was to do bulk discounts automatically so they don't have to call for one.

 

I guess people fear change. Ha ha It's really no trouble to run both, I just need to get the shipping seperated. I know there's an option to override shipping in PayPal but I don't want to goof it up for site 1. This gets complicated huh?

 

Thanks for your response. I will dive into the documentation to make sure I know what I'm doing. I don't know what this is yet Preparing [PayPal IPN].

 

Thanks!

 

Shell

Link to comment
Share on other sites

I tried searching the thread but couldn't find the answer. Everything is working fine actually, my question is about the methodology of the module. Why is _cart set to not work with EWP? If it a size/POST limit or something? I like the functionality of EWP, just for knowing that my POST data WILL NOT be manipulated at all, but would prefer the customer to be able to see the contents of their cart on paypal also.. I've already converted the code to do _cart over EWP, but just wondering if anyone else has tried this and experienced problems with it. It seems to be working, but horror stories are welcome also.

 

Did you ever get a reply on this? Or run into any problems?

 

I noticed this too. I also tweaked the IF to permit this

 

261c261,264

< if ( (MODULE_PAYMENT_PAYPAL_IPN_TRANSACTION_TYPE == 'Per Item') && (MODULE_PAYMENT_PAYPAL_IPN_EWP_STATUS == 'False') ) {

---

> if ( (MODULE_PAYMENT_PAYPAL_IPN_TRANSACTION_TYPE == 'Per Item')

> # yes you can encrypt carts - ANY

> #&& (MODULE_PAYMENT_PAYPAL_IPN_EWP_STATUS == 'False')

> ) {

 

No problems so far for me.

 

Alastair

Link to comment
Share on other sites

Hi guys,

 

I'm totally stumped. The PayPal IPN module is NOT showing up in my payment modules!

 

Yes, I did read the ReadMe for this contrib. The very first installation step says:

 

"Copy the files in the directory structure set in the contribution download file to your osCommerce installation directory. Note: Be sure to also copy the new "ext" directory to the catalog root directory."

 

I did that. I uploaded the "ext" directory and all its contents to my /catalog directory.

 

I uploaded the other files in their corresponding directories to the /includes directory in the /catalog directory.

 

I made sure the all files are CHMOD'd to 777.

 

Step two of the installation instructions proceeds right to installing the module in the Administration panel in the payment modules.

 

But is there something else in between steps 1 and 2 that I should be doing?

 

In another thread around here I read that there's some kind of editing of the php files that needs to be done, but I can't find anything referencing that in the installation directions.

 

Ideas???

 

Thank you,

Morcar

Link to comment
Share on other sites

Hi guys,

 

I'm totally stumped. The PayPal IPN module is NOT showing up in my payment modules!

 

Yes, I did read the ReadMe for this contrib. The very first installation step says:

 

"Copy the files in the directory structure set in the contribution download file to your osCommerce installation directory. Note: Be sure to also copy the new "ext" directory to the catalog root directory."

 

I did that. I uploaded the "ext" directory and all its contents to my /catalog directory.

 

I uploaded the other files in their corresponding directories to the /includes directory in the /catalog directory.

You may have missed something or put it in the wrong place. When you go into the administration panel, the code that creates the list of modules will enumerate every php file that is in /catalog/includes/modules/payment, then load the information required to display the names.

 

In particular, note that, like many osC files, there are two (or more) files with the same name in different directories. This contribution has two files named paypal_ipn.php. The first, in /catalog/includes/modules/payment/, is the module itself. The second, in /catalog/includes/languages/english/modules/payment/, contains the English language strings for the module. Make certain that the correct file is in each directory.

 

Note also that if you installed osC in your server's public root directory that "/catalog/" may not be top of your installation tree. If this is the case, find the includes directory on your server and install everything from this contribution below it, except the /ext/ directory, which is installed at the root level, the directory in which index.php resides.

 

I made sure the all files are CHMOD'd to 777.

CHMOD 644 ought to be sufficient (owner RW, group RO. world RO).

 

Step two of the installation instructions proceeds right to installing the module in the Administration panel in the payment modules.

 

But is there something else in between steps 1 and 2 that I should be doing?

 

In another thread around here I read that there's some kind of editing of the php files that needs to be done, but I can't find anything referencing that in the installation directions.

To make this module work correctly with certain other contributions, you must do some editing. This is discussed in the instructions under the headings "Known Issues" and "Integrating with other Contributions". You should not need to do any of that to make the module show up in the administration panel.

 

--Glen

Link to comment
Share on other sites

You may have missed something or put it in the wrong place.

--Glen

 

Hi Glen, and thanks for a very informative reply.

 

You were right, I did miss something - but it wasn't what either one of us thought. :blush:

 

I used to have two other instances of osCommerce installed on my website, for initial testing. Recently I uninstalled one and installed the new one I'm trying to make live. Well I forgot to uninstall the very first one!!!

 

And of course I was still able to log in to the Admin interface! Just now I noted the URL where I was logging in, and I was like, "Hey, that's my OLD store!" No wonder the PayPal IPN module wasn't showing up!

 

So when I logged into the Admin interface for the current store, there's the PayPal IPN waiting to be installed.

 

I'm going to have to be really careful about that in the future.

 

Thanks again - oh, and be assured you'll see me around here plenty more! B) :thumbsup:

Morcar

Edited by morcar
Link to comment
Share on other sites

hi

 

i'm getting the following warning when trying to Enable Encrypted Web Payments.

 

Warning: fread(): Length parameter must be greater than 0. in /home/sitename/public_html/allo/includes/modules/payment/paypal_ipn.php on line 407

 

(line 406 with 1.3 and line 407 with 1.2)

 

i've read through all the forum and only found a couple people with the same problem. i've tried doing what they have done but no luck.

 

(all this is in test mode)

 

any help would be appreciated.

Link to comment
Share on other sites

hi

 

i'm getting the following warning when trying to Enable Encrypted Web Payments.

 

Warning: fread(): Length parameter must be greater than 0. in /home/sitename/public_html/allo/includes/modules/payment/paypal_ipn.php on line 407

 

(line 406 with 1.3 and line 407 with 1.2)

 

i've read through all the forum and only found a couple people with the same problem. i've tried doing what they have done but no luck.

 

(all this is in test mode)

 

any help would be appreciated.

 

The code block where this error is occurring is used when (a) you have enabled encrypted website payment support and (B) your PHP installation doesn't have OpenSSL support compiled in, so signing and encryption must be done externally through the smime program.

 

What the error is telling you is that the encrypted text has a length of zero, or that the file doesn't exist.

 

Off the top of my head, I can think of several reasons that this might occur.

 

1. Permissions problem on the working directory. Check that the working directory that you entered in the module settings exists, and that PHP can get to it.

 

2. smime not installed on your server, or you don't have permission to use it. Check with your server admin.

 

3. bad or non-existent keys. Make sure that you have generated public and private keys, and that they exist in the location you specified in the module settings.

 

Please let us know what you find.

 

--Glen

Link to comment
Share on other sites

The code block where this error is occurring is used when (a) you have enabled encrypted website payment support and (B) your PHP installation doesn't have OpenSSL support compiled in, so signing and encryption must be done externally through the smime program.

 

What the error is telling you is that the encrypted text has a length of zero, or that the file doesn't exist.

 

Off the top of my head, I can think of several reasons that this might occur.

 

1. Permissions problem on the working directory. Check that the working directory that you entered in the module settings exists, and that PHP can get to it.

 

2. smime not installed on your server, or you don't have permission to use it. Check with your server admin.

 

3. bad or non-existent keys. Make sure that you have generated public and private keys, and that they exist in the location you specified in the module settings.

 

Please let us know what you find.

 

--Glen

 

hi,

 

1. i think the working directory is fine and permissios are set properly.

 

2. what is "smime"? the sll keys i made was from cpanel admin i get access to. There was a option which said ssl manger so i used that.

 

3. i think the keys are fine and are getting pointed to correctly.

 

i dont know if my host uses openssl.

 

if i get in touch with my host what should i be asking them? (i use myqth.co.uk)

 

 

Sally.

Link to comment
Share on other sites

RE: Download products and Paypal IPN:

 

I have installed the latest IPN contribution osCommerce PayPal IPN Module v1.3 For 2.2MS2 and a new install of 2.2MS2 together with the download module. I can make payments through paypal and come back and get my downloads, no problem.

 

However, here IS the problem. If I backpeddle in Paypal and do not make the payment but go back to the store and click Order History. the recent order shows with "Preparing [PayPal IPN]" If I view that order detail, all the download links for the products I chose are active and I can download the products without paying for them. :(

 

Any ideas? Is it just me or is it a bug?

 

Thanks

Link to comment
Share on other sites

RE: Download products and Paypal IPN:

 

I have installed the latest IPN contribution osCommerce PayPal IPN Module v1.3 For 2.2MS2 and a new install of 2.2MS2 together with the download module. I can make payments through paypal and come back and get my downloads, no problem.

 

However, here IS the problem. If I backpeddle in Paypal and do not make the payment but go back to the store and click Order History. the recent order shows with "Preparing [PayPal IPN]" If I view that order detail, all the download links for the products I chose are active and I can download the products without paying for them. :(

 

Any ideas? Is it just me or is it a bug?

 

Thanks

 

if you follow this http://www.oscommerce.com/forums/index.php?showtopic=177853 you should get it working fine with no hitch, i had the same problem but following that sorted it out.

 

i'm just stuck with the encryted payment bit. if anyone got any ideas please help.

Link to comment
Share on other sites

The only problem left with the Download Controller is that the download counter is decreased regardless of whether the download was successful or not.

 

Here is an example of what I mean:

With the counter set to 1 (meaning the customer can only download once).

Press the download link. You should get the window asking you to save the file.

Press Cancel instead of Ok.

There goes your one download (even though you didn't download the file).

Go back to the download link (refresh the page) and you will see that it's not available.

 

This problem can also result from a number of other situations that might happen at the customer's end; power outage, ISP service failure, cancel halfway through the download.

Increasing the allowed download counter is not the answer (since that is an open loop approach).

 

I've been trying to figure out a way to overcome this but haven't had any luck yet. (I'm fairly new to PHP coding, but I have tried using readfile and echo fread($fp,4096) with ignore_user_abort(true), connection_aborted() == true, and connection_status != 0.)

 

Great contribution, but needs this issue fixed to make it work as the creator intended.

 

Cheers,

Nap

Link to comment
Share on other sites

hi,

 

1. i think the working directory is fine and permissios are set properly.

 

2. what is "smime"? the sll keys i made was from cpanel admin i get access to. There was a option which said ssl manger so i used that.

smime is a Unix program for encrypting and decrypting Secure MIME (S/MIME) messages. It is quite possible that it is not available on your server. Without either OpenSSL support in PHP or access to the smime program, you will be unable to use the Encrypted Website Payments feature.

3. i think the keys are fine and are getting pointed to correctly.

 

i dont know if my host uses openssl.

You can verify it by going to Admin->Tools->Server Info. There is a block labeled "openssl". Yours is probably disabled. You can ask your host to reinstall PHP with openSSL support enabled.

Link to comment
Share on other sites

Hello all,

 

I've installed the

Variable Product Commission http://www.oscommerce.com/community/contri...ducts+Commision

 

It allows you to group your products and use different %s form affiliates....

It works fine with all the other payment modules but for some reason with Paypal IPN it comes up with the following...

 

Fatal error: Call to a member function on a non-object in D:\Apache2\webroot\oscommerce\catalog\includes\affiliate_checkout_process.php on line 34

 

on the checkout_confirmation.php page...i'm stumped!

and have no idea what to do, i've looking everywhere on the internet for what it might mean but still don't know how to fix this.

 

affiliate_checkout_process.php on line 34

// LE commision script on - BR

$affiliate_payment = tep_round(($cart->le_commission()), 2);

// LE commision script off - BR

 

I'm desperate to find out(it's driving me nuts!)...please help

 

This is the paypal_ipn.php

<?php

/*

$Id: paypal_ipn.php,v 1.1.2.11 2004/12/05 19:14:35 hpdl Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2004 osCommerce

 

Released under the GNU General Public License

*/

 

class paypal_ipn {

var $code, $title, $description, $enabled, $identifier;

 

// class constructor

function paypal_ipn() {

global $order;

 

$this->code = 'paypal_ipn';

$this->title = MODULE_PAYMENT_PAYPAL_IPN_TEXT_TITLE;

$this->description = MODULE_PAYMENT_PAYPAL_IPN_TEXT_DESCRIPTION;

$this->sort_order = MODULE_PAYMENT_PAYPAL_IPN_SORT_ORDER;

$this->enabled = ((MODULE_PAYMENT_PAYPAL_IPN_STATUS == 'True') ? true : false);

$this->identifier = 'osCommerce PayPal IPN v1.0';

 

if ((int)MODULE_PAYMENT_PAYPAL_IPN_PREPARE_ORDER_STATUS_ID > 0) {

$this->order_status = MODULE_PAYMENT_PAYPAL_IPN_PREPARE_ORDER_STATUS_ID;

}

 

if (is_object($order)) $this->update_status();

 

if (MODULE_PAYMENT_PAYPAL_IPN_GATEWAY_SERVER == 'Live') {

$this->form_action_url = 'https://www.paypal.com/cgi-bin/webscr';

} else {

$this->form_action_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';

}

}

 

//get paypal images

function get_paypal_image() {

$paypal_image .= tep_image(DIR_WS_ICONS . 'paypal.gif', $value);

return $paypal_image;

}

 

 

// class methods

function update_status() {

global $order;

 

if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_PAYPAL_IPN_ZONE > 0) ) {

$check_flag = false;

$check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_PAYPAL_IPN_ZONE . "' and zone_country_id = '" . $order->billing['country']['id'] . "' order by zone_id");

while ($check = tep_db_fetch_array($check_query)) {

if ($check['zone_id'] < 1) {

$check_flag = true;

break;

} elseif ($check['zone_id'] == $order->billing['zone_id']) {

$check_flag = true;

break;

}

}

 

if ($check_flag == false) {

$this->enabled = false;

}

}

}

 

function javascript_validation() {

return false;

}

 

function selection() {

return array('id' => $this->code,

'module' => $this->title . ' ' . $this->get_paypal_image());

 

}

 

function pre_confirmation_check() {

return false;

}

 

function confirmation() {

global $cartID, $cart_PayPal_IPN_ID, $customer_id, $languages_id, $order, $order_total_modules;

global $affiliate_ref, $affiliate_clientdate, $affiliate_clientbrowser, $affiliate_clientip, $affiliate_clickthroughs_id, $HTTP_SESSION_VARS;

 

 

if (tep_session_is_registered('cartID')) {

$insert_order = false;

 

if (tep_session_is_registered('cart_PayPal_IPN_ID')) {

$order_id = substr($cart_PayPal_IPN_ID, strpos($cart_PayPal_IPN_ID, '-')+1);

 

$curr_check = tep_db_query("select currency from " . TABLE_ORDERS . " where orders_id = '" . (int)$order_id . "'");

$curr = tep_db_fetch_array($curr_check);

 

if ( ($curr['currency'] != $order->info['currency']) || ($cartID != substr($cart_PayPal_IPN_ID, 0, strlen($cartID))) ) {

$check_query = tep_db_query('select orders_id from ' . TABLE_ORDERS_STATUS_HISTORY . ' where orders_id = "' . (int)$order_id . '" limit 1');

 

if (tep_db_num_rows($check_query) < 1) {

tep_db_query('delete from ' . TABLE_ORDERS . ' where orders_id = "' . (int)$order_id . '"');

tep_db_query('delete from ' . TABLE_ORDERS_TOTAL . ' where orders_id = "' . (int)$order_id . '"');

tep_db_query('delete from ' . TABLE_ORDERS_STATUS_HISTORY . ' where orders_id = "' . (int)$order_id . '"');

tep_db_query('delete from ' . TABLE_ORDERS_PRODUCTS . ' where orders_id = "' . (int)$order_id . '"');

tep_db_query('delete from ' . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . ' where orders_id = "' . (int)$order_id . '"');

tep_db_query('delete from ' . TABLE_ORDERS_PRODUCTS_DOWNLOAD . ' where orders_id = "' . (int)$order_id . '"');

}

 

$insert_order = true;

}

} else {

$insert_order = true;

}

 

if ($insert_order == true) {

$order_totals = array();

if (is_array($order_total_modules->modules)) {

reset($order_total_modules->modules);

while (list(, $value) = each($order_total_modules->modules)) {

$class = substr($value, 0, strrpos($value, '.'));

if ($GLOBALS[$class]->enabled) {

for ($i=0, $n=sizeof($GLOBALS[$class]->output); $i<$n; $i++) {

if (tep_not_null($GLOBALS[$class]->output[$i]['title']) && tep_not_null($GLOBALS[$class]->output[$i]['text'])) {

$order_totals[] = array('code' => $GLOBALS[$class]->code,

'title' => $GLOBALS[$class]->output[$i]['title'],

'text' => $GLOBALS[$class]->output[$i]['text'],

'value' => $GLOBALS[$class]->output[$i]['value'],

'sort_order' => $GLOBALS[$class]->sort_order);

}

}

}

}

}

 

$sql_data_array = array('customers_id' => $customer_id,

'customers_name' => $order->customer['firstname'] . ' ' . $order->customer['lastname'],

'customers_company' => $order->customer['company'],

'customers_street_address' => $order->customer['street_address'],

'customers_suburb' => $order->customer['suburb'],

'customers_city' => $order->customer['city'],

'customers_postcode' => $order->customer['postcode'],

'customers_state' => $order->customer['state'],

'customers_country' => $order->customer['country']['title'],

'customers_telephone' => $order->customer['telephone'],

'customers_email_address' => $order->customer['email_address'],

'customers_address_format_id' => $order->customer['format_id'],

'delivery_name' => $order->delivery['firstname'] . ' ' . $order->delivery['lastname'],

'delivery_company' => $order->delivery['company'],

'delivery_street_address' => $order->delivery['street_address'],

'delivery_suburb' => $order->delivery['suburb'],

'delivery_city' => $order->delivery['city'],

'delivery_postcode' => $order->delivery['postcode'],

'delivery_state' => $order->delivery['state'],

'delivery_country' => $order->delivery['country']['title'],

'delivery_address_format_id' => $order->delivery['format_id'],

'billing_name' => $order->billing['firstname'] . ' ' . $order->billing['lastname'],

'billing_company' => $order->billing['company'],

'billing_street_address' => $order->billing['street_address'],

'billing_suburb' => $order->billing['suburb'],

'billing_city' => $order->billing['city'],

'billing_postcode' => $order->billing['postcode'],

'billing_state' => $order->billing['state'],

'billing_country' => $order->billing['country']['title'],

'billing_address_format_id' => $order->billing['format_id'],

'payment_method' => $order->info['payment_method'],

'cc_type' => $order->info['cc_type'],

'cc_owner' => $order->info['cc_owner'],

'cc_number' => $order->info['cc_number'],

'cc_expires' => $order->info['cc_expires'],

'date_purchased' => 'now()',

'orders_status' => $order->info['order_status'],

'currency' => $order->info['currency'],

'currency_value' => $order->info['currency_value']);

 

tep_db_perform(TABLE_ORDERS, $sql_data_array);

 

$insert_id = tep_db_insert_id();

 

for ($i=0, $n=sizeof($order_totals); $i<$n; $i++) {

$sql_data_array = array('orders_id' => $insert_id,

'title' => $order_totals[$i]['title'],

'text' => $order_totals[$i]['text'],

'value' => $order_totals[$i]['value'],

'class' => $order_totals[$i]['code'],

'sort_order' => $order_totals[$i]['sort_order']);

 

tep_db_perform(TABLE_ORDERS_TOTAL, $sql_data_array);

}

 

for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {

$sql_data_array = array('orders_id' => $insert_id,

'products_id' => tep_get_prid($order->products[$i]['id']),

'products_model' => $order->products[$i]['model'],

'products_name' => $order->products[$i]['name'],

'products_price' => $order->products[$i]['price'],

'final_price' => $order->products[$i]['final_price'],

'products_tax' => $order->products[$i]['tax'],

'products_quantity' => $order->products[$i]['qty']);

 

tep_db_perform(TABLE_ORDERS_PRODUCTS, $sql_data_array);

 

$order_products_id = tep_db_insert_id();

 

$attributes_exist = '0';

if (isset($order->products[$i]['attributes'])) {

$attributes_exist = '1';

for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) {

if (DOWNLOAD_ENABLED == 'true') {

$attributes_query = "select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix, pad.products_attributes_maxdays, pad.products_attributes_maxcount , pad.products_attributes_filename

from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa

left join " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad

on pa.products_attributes_id=pad.products_attributes_id

where pa.products_id = '" . $order->products[$i]['id'] . "'

and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "'

and pa.options_id = popt.products_options_id

and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "'

and pa.options_values_id = poval.products_options_values_id

and popt.language_id = '" . $languages_id . "'

and poval.language_id = '" . $languages_id . "'";

$attributes = tep_db_query($attributes_query);

} else {

$attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . $order->products[$i]['id'] . "' and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" . $languages_id . "' and poval.language_id = '" . $languages_id . "'");

}

$attributes_values = tep_db_fetch_array($attributes);

 

$sql_data_array = array('orders_id' => $insert_id,

'orders_products_id' => $order_products_id,

'products_options' => $attributes_values['products_options_name'],

'products_options_values' => $attributes_values['products_options_values_name'],

'options_values_price' => $attributes_values['options_values_price'],

'price_prefix' => $attributes_values['price_prefix']);

 

tep_db_perform(TABLE_ORDERS_PRODUCTS_ATTRIBUTES, $sql_data_array);

 

if ((DOWNLOAD_ENABLED == 'true') && isset($attributes_values['products_attributes_filename']) && tep_not_null($attributes_values['products_attributes_filename'])) {

$sql_data_array = array('orders_id' => $insert_id,

'orders_products_id' => $order_products_id,

'orders_products_filename' => $attributes_values['products_attributes_filename'],

'download_maxdays' => $attributes_values['products_attributes_maxdays'],

'download_count' => $attributes_values['products_attributes_maxcount']);

 

tep_db_perform(TABLE_ORDERS_PRODUCTS_DOWNLOAD, $sql_data_array);

}

}

}

}

 

tep_session_register('cart_PayPal_IPN_ID');

$cart_PayPal_IPN_ID = $cartID . '-' . $insert_id;

}

}

 

// Include OSC-AFFILIATE

require(DIR_WS_INCLUDES . 'affiliate_checkout_process.php');

 

return false;

}

 

 

function process_button() {

global $customer_id, $order, $languages_id, $currencies, $currency, $cart_PayPal_IPN_ID, $shipping;

 

if (MODULE_PAYMENT_PAYPAL_IPN_CURRENCY == 'Selected Currency') {

$my_currency = $currency;

} else {

$my_currency = substr(MODULE_PAYMENT_PAYPAL_IPN_CURRENCY, 5);

}

if (!in_array($my_currency, array('CAD', 'EUR', 'GBP', 'JPY', 'USD'))) {

$my_currency = 'USD';

}

 

$parameters = array();

 

if ( (MODULE_PAYMENT_PAYPAL_IPN_TRANSACTION_TYPE == 'Per Item') && (MODULE_PAYMENT_PAYPAL_IPN_EWP_STATUS == 'False') ) {

$parameters['cmd'] = '_cart';

$parameters['upload'] = '1';

 

for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {

$item = $i+1;

 

$tax_value = ($order->products[$i]['tax'] / 100) * $order->products[$i]['final_price'];

 

$parameters['item_name_' . $item] = $order->products[$i]['name'];

$parameters['amount_' . $item] = number_format($order->products[$i]['final_price'] * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));

$parameters['tax_' . $item] = number_format($tax_value * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));

$parameters['quantity_' . $item] = $order->products[$i]['qty'];

 

if ($i == 0) {

if (DISPLAY_PRICE_WITH_TAX == 'true') {

$shipping_cost = $order->info['shipping_cost'];

} else {

$module = substr($shipping['id'], 0, strpos($shipping['id'], '_'));

$shipping_tax = tep_get_tax_rate($GLOBALS[$module]->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);

$shipping_cost = $order->info['shipping_cost'] + tep_calculate_tax($order->info['shipping_cost'], $shipping_tax);

}

 

$parameters['shipping_' . $item] = number_format($shipping_cost * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));

}

 

if (isset($order->products[$i]['attributes'])) {

for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) {

if (DOWNLOAD_ENABLED == 'true') {

$attributes_query = "select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix, pad.products_attributes_maxdays, pad.products_attributes_maxcount , pad.products_attributes_filename

from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa

left join " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad

on pa.products_attributes_id=pad.products_attributes_id

where pa.products_id = '" . $order->products[$i]['id'] . "'

and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "'

and pa.options_id = popt.products_options_id

and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "'

and pa.options_values_id = poval.products_options_values_id

and popt.language_id = '" . $languages_id . "'

and poval.language_id = '" . $languages_id . "'";

$attributes = tep_db_query($attributes_query);

} else {

$attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . $order->products[$i]['id'] . "' and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" . $languages_id . "' and poval.language_id = '" . $languages_id . "'");

}

$attributes_values = tep_db_fetch_array($attributes);

 

// Unfortunately PayPal only accepts two attributes per product, so the

// third attribute onwards will not be shown at PayPal

$parameters['on' . $j . '_' . $item] = $attributes_values['products_options_name'];

$parameters['os' . $j . '_' . $item] = $attributes_values['products_options_values_name'];

}

}

}

 

$parameters['num_cart_items'] = $item;

} else {

$parameters['cmd'] = '_xclick';

$parameters['item_name'] = STORE_NAME;

$parameters['shipping'] = number_format($order->info['shipping_cost'] * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));

$parameters['tax'] = number_format($order->info['tax'] * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));

}

 

$parameters['business'] = MODULE_PAYMENT_PAYPAL_IPN_ID;

$parameters['amount'] = number_format(($order->info['total'] - $order->info['shipping_cost'] - $order->info['tax']) * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));

$parameters['currency_code'] = $my_currency;

$parameters['invoice'] = substr($cart_PayPal_IPN_ID, strpos($cart_PayPal_IPN_ID, '-')+1);

$parameters['custom'] = $customer_id;

$parameters['no_shipping'] = '1';

$parameters['no_note'] = '1';

$parameters['notify_url'] = tep_href_link('ext/modules/payment/paypal_ipn/ipn.php', '', 'SSL', false, false);

$parameters['return'] = tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL');

$parameters['cancel_return'] = tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL');

$parameters['bn'] = $this->identifier;

 

if (tep_not_null(MODULE_PAYMENT_PAYPAL_IPN_PAGE_STYLE)) {

$parameters['page_style'] = MODULE_PAYMENT_PAYPAL_IPN_PAGE_STYLE;

}

 

if (MODULE_PAYMENT_PAYPAL_IPN_EWP_STATUS == 'True') {

$parameters['cert_id'] = MODULE_PAYMENT_PAYPAL_IPN_EWP_CERT_ID;

 

$random_string = rand(100000, 999999) . '-' . $customer_id . '-';

 

$data = '';

while (list($key, $value) = each($parameters)) {

$data .= $key . '=' . $value . "\n";

}

 

$fp = fopen(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'data.txt', 'w');

fwrite($fp, $data);

fclose($fp);

 

unset($data);

 

if (function_exists('openssl_pkcs7_sign') && function_exists('openssl_pkcs7_encrypt')) {

openssl_pkcs7_sign(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'data.txt', MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'signed.txt', file_get_contents(MODULE_PAYMENT_PAYPAL_IPN_EWP_PUBLIC_KEY), file_get_contents(MODULE_PAYMENT_PAYPAL_IPN_EWP_PRIVATE_KEY), array('From' => MODULE_PAYMENT_PAYPAL_IPN_ID), PKCS7_BINARY);

 

unlink(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'data.txt');

 

// remove headers from the signature

$signed = file_get_contents(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'signed.txt');

$signed = explode("\n\n", $signed);

$signed = base64_decode($signed[1]);

 

$fp = fopen(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'signed.txt', 'w');

fwrite($fp, $signed);

fclose($fp);

 

unset($signed);

 

openssl_pkcs7_encrypt(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'signed.txt', MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'encrypted.txt', file_get_contents(MODULE_PAYMENT_PAYPAL_IPN_EWP_PAYPAL_KEY), array('From' => MODULE_PAYMENT_PAYPAL_IPN_ID), PKCS7_BINARY);

 

unlink(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'signed.txt');

 

// remove headers from the encrypted result

$data = file_get_contents(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'encrypted.txt');

$data = explode("\n\n", $data);

$data = '-----BEGIN PKCS7-----' . "\n" . $data[1] . "\n" . '-----END PKCS7-----';

 

unlink(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'encrypted.txt');

} else {

exec(MODULE_PAYMENT_PAYPAL_IPN_EWP_OPENSSL . ' smime -sign -in ' . MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'data.txt -signer ' . MODULE_PAYMENT_PAYPAL_IPN_EWP_PUBLIC_KEY . ' -inkey ' . MODULE_PAYMENT_PAYPAL_IPN_EWP_PRIVATE_KEY . ' -outform der -nodetach -binary > ' . MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'signed.txt');

unlink(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'data.txt');

 

exec(MODULE_PAYMENT_PAYPAL_IPN_EWP_OPENSSL . ' smime -encrypt -des3 -binary -outform pem ' . MODULE_PAYMENT_PAYPAL_IPN_EWP_PAYPAL_KEY . ' < ' . MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'signed.txt > ' . MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'encrypted.txt');

unlink(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'signed.txt');

 

$fh = fopen(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'encrypted.txt', 'rb');

$data = fread($fh, filesize(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'encrypted.txt'));

fclose($fh);

 

unlink(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'encrypted.txt');

}

 

$process_button_string = tep_draw_hidden_field('cmd', '_s-xclick') .

tep_draw_hidden_field('encrypted', $data);

 

unset($data);

} else {

while (list($key, $value) = each($parameters)) {

echo tep_draw_hidden_field($key, $value);

}

}

 

return $process_button_string;

}

 

function before_process() {

global $customer_id, $order, $sendto, $billto, $payment, $currencies, $cart, $cart_PayPal_IPN_ID;

global $$payment;

 

include(DIR_WS_CLASSES . 'order_total.php');

$order_total_modules = new order_total;

 

$order_totals = $order_total_modules->process();

 

$order_id = substr($cart_PayPal_IPN_ID, strpos($cart_PayPal_IPN_ID, '-')+1);

 

$sql_data_array = array('orders_id' => $order_id,

'orders_status_id' => $order->info['order_status'],

'date_added' => 'now()',

'customer_notified' => (SEND_EMAILS == 'true') ? '1' : '0',

'comments' => $order->info['comments']);

 

tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);

 

// initialized for the email confirmation

$products_ordered = '';

$subtotal = 0;

$total_tax = 0;

 

for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {

// Stock Update - Joao Correia

if (STOCK_LIMITED == 'true') {

if (DOWNLOAD_ENABLED == 'true') {

$stock_query_raw = "SELECT products_quantity, pad.products_attributes_filename

FROM " . TABLE_PRODUCTS . " p

LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES . " pa

ON p.products_id=pa.products_id

LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad

ON pa.products_attributes_id=pad.products_attributes_id

WHERE p.products_id = '" . tep_get_prid($order->products[$i]['id']) . "'";

// Will work with only one option for downloadable products

// otherwise, we have to build the query dynamically with a loop

$products_attributes = $order->products[$i]['attributes'];

if (is_array($products_attributes)) {

$stock_query_raw .= " AND pa.options_id = '" . $products_attributes[0]['option_id'] . "' AND pa.options_values_id = '" . $products_attributes[0]['value_id'] . "'";

}

$stock_query = tep_db_query($stock_query_raw);

} else {

$stock_query = tep_db_query("select products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");

}

if (tep_db_num_rows($stock_query) > 0) {

$stock_values = tep_db_fetch_array($stock_query);

// do not decrement quantities if products_attributes_filename exists

if ((DOWNLOAD_ENABLED != 'true') || (!$stock_values['products_attributes_filename'])) {

$stock_left = $stock_values['products_quantity'] - $order->products[$i]['qty'];

} else {

$stock_left = $stock_values['products_quantity'];

}

tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity = '" . $stock_left . "' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");

if ( ($stock_left < 1) && (STOCK_ALLOW_CHECKOUT == 'false') ) {

tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '0' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");

}

}

}

 

// Update products_ordered (for bestsellers list)

tep_db_query("update " . TABLE_PRODUCTS . " set products_ordered = products_ordered + " . sprintf('%d', $order->products[$i]['qty']) . " where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");

 

//------insert customer choosen option to order--------

$attributes_exist = '0';

$products_ordered_attributes = '';

if (isset($order->products[$i]['attributes'])) {

$attributes_exist = '1';

for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) {

if (DOWNLOAD_ENABLED == 'true') {

$attributes_query = "select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix, pad.products_attributes_maxdays, pad.products_attributes_maxcount , pad.products_attributes_filename

from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa

left join " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad

on pa.products_attributes_id=pad.products_attributes_id

where pa.products_id = '" . $order->products[$i]['id'] . "'

and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "'

and pa.options_id = popt.products_options_id

and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "'

and pa.options_values_id = poval.products_options_values_id

and popt.language_id = '" . $languages_id . "'

and poval.language_id = '" . $languages_id . "'";

$attributes = tep_db_query($attributes_query);

} else {

$attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . $order->products[$i]['id'] . "' and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" . $languages_id . "' and poval.language_id = '" . $languages_id . "'");

}

$attributes_values = tep_db_fetch_array($attributes);

 

$products_ordered_attributes .= "\n\t" . $attributes_values['products_options_name'] . ' ' . $attributes_values['products_options_values_name'];

}

}

//------insert customer choosen option eof ----

$total_weight += ($order->products[$i]['qty'] * $order->products[$i]['weight']);

$total_tax += tep_calculate_tax($total_products_price, $products_tax) * $order->products[$i]['qty'];

$total_cost += $total_products_price;

 

$products_ordered .= $order->products[$i]['qty'] . ' x ' . $order->products[$i]['name'] . ' (' . $order->products[$i]['model'] . ') = ' . $currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']) . $products_ordered_attributes . "\n";

}

 

// lets start with the email confirmation

$email_order = STORE_NAME . "\n" .

EMAIL_SEPARATOR . "\n" .

EMAIL_TEXT_ORDER_NUMBER . ' ' . $order_id . "\n" .

EMAIL_TEXT_INVOICE_URL . ' ' . tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $order_id, 'SSL', false) . "\n" .

EMAIL_TEXT_DATE_ORDERED . ' ' . strftime(DATE_FORMAT_LONG) . "\n\n";

if ($order->info['comments']) {

$email_order .= tep_db_output($order->info['comments']) . "\n\n";

}

$email_order .= EMAIL_TEXT_PRODUCTS . "\n" .

EMAIL_SEPARATOR . "\n" .

$products_ordered .

EMAIL_SEPARATOR . "\n";

 

for ($i=0, $n=sizeof($order_totals); $i<$n; $i++) {

$email_order .= strip_tags($order_totals[$i]['title']) . ' ' . strip_tags($order_totals[$i]['text']) . "\n";

}

 

if ($order->content_type != 'virtual') {

$email_order .= "\n" . EMAIL_TEXT_DELIVERY_ADDRESS . "\n" .

EMAIL_SEPARATOR . "\n" .

tep_address_label($customer_id, $sendto, 0, '', "\n") . "\n";

}

 

$email_order .= "\n" . EMAIL_TEXT_BILLING_ADDRESS . "\n" .

EMAIL_SEPARATOR . "\n" .

tep_address_label($customer_id, $billto, 0, '', "\n") . "\n\n";

 

if (is_object($$payment)) {

$email_order .= EMAIL_TEXT_PAYMENT_METHOD . "\n" .

EMAIL_SEPARATOR . "\n";

$payment_class = $$payment;

$email_order .= $payment_class->title . "\n\n";

if ($payment_class->email_footer) {

$email_order .= $payment_class->email_footer . "\n\n";

}

}

 

tep_mail($order->customer['firstname'] . ' ' . $order->customer['lastname'], $order->customer['email_address'], EMAIL_TEXT_SUBJECT, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);

 

// send emails to other people

if (SEND_EXTRA_ORDER_EMAILS_TO != '') {

tep_mail('', SEND_EXTRA_ORDER_EMAILS_TO, EMAIL_TEXT_SUBJECT, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);

}

 

// load the after_process function from the payment modules

$this->after_process();

 

$cart->reset(true);

 

// unregister session variables used during checkout

tep_session_unregister('sendto');

tep_session_unregister('billto');

tep_session_unregister('shipping');

tep_session_unregister('payment');

tep_session_unregister('comments');

 

tep_session_unregister('cart_PayPal_IPN_ID');

 

tep_redirect(tep_href_link(FILENAME_CHECKOUT_SUCCESS, '', 'SSL'));

}

 

function after_process() {

return false;

}

 

function output_error() {

return false;

}

 

function check() {

if (!isset($this->_check)) {

$check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_PAYPAL_IPN_STATUS'");

$this->_check = tep_db_num_rows($check_query);

}

return $this->_check;

}

 

function install() {

$check_query = tep_db_query("select orders_status_id from " . TABLE_ORDERS_STATUS . " where orders_status_name = 'Preparing [PayPal IPN]' limit 1");

 

if (tep_db_num_rows($check_query) < 1) {

$status_query = tep_db_query("select max(orders_status_id) as status_id from " . TABLE_ORDERS_STATUS);

$status = tep_db_fetch_array($status_query);

 

$status_id = $status['status_id']+1;

 

$languages = tep_get_languages();

 

foreach ($languages as $lang) {

tep_db_query("insert into " . TABLE_ORDERS_STATUS . " (orders_status_id, language_id, orders_status_name) values ('" . $status_id . "', '" . $lang['id'] . "', 'Preparing [PayPal IPN]')");

}

} else {

$check = tep_db_fetch_array($check_query);

 

$status_id = $check['orders_status_id'];

}

 

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable PayPal IPN Module', 'MODULE_PAYMENT_PAYPAL_IPN_STATUS', 'False', 'Do you want to accept PayPal IPN payments?', '6', '3', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('E-Mail Address', 'MODULE_PAYMENT_PAYPAL_IPN_ID', '', 'The e-mail address to use for the PayPal IPN service', '6', '4', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Transaction Currency', 'MODULE_PAYMENT_PAYPAL_IPN_CURRENCY', 'Selected Currency', 'The currency to use for transactions', '6', '6', 'tep_cfg_select_option(array(\'Selected Currency\',\'Only USD\',\'Only CAD\',\'Only EUR\',\'Only GBP\',\'Only JPY\'), ', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort order of display.', 'MODULE_PAYMENT_PAYPAL_IPN_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Payment Zone', 'MODULE_PAYMENT_PAYPAL_IPN_ZONE', '0', 'If a zone is selected, only enable this payment method for that zone.', '6', '2', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, use_function, date_added) values ('Set Preparing Order Status', 'MODULE_PAYMENT_PAYPAL_IPN_PREPARE_ORDER_STATUS_ID', '" . $status_id . "', 'Set the status of prepared orders made with this payment module to this value', '6', '0', 'tep_cfg_pull_down_order_statuses(', 'tep_get_order_status_name', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, use_function, date_added) values ('Set PayPal Acknowledged Order Status', 'MODULE_PAYMENT_PAYPAL_IPN_ORDER_STATUS_ID', '0', 'Set the status of orders made with this payment module to this value', '6', '0', 'tep_cfg_pull_down_order_statuses(', 'tep_get_order_status_name', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Transaction Type', 'MODULE_PAYMENT_PAYPAL_IPN_TRANSACTION_TYPE', 'Per Item', 'Send individual items to PayPal or aggregate all as one total item?', '6', '6', 'tep_cfg_select_option(array(\'Per Item\',\'Aggregate\'), ', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Gateway Server', 'MODULE_PAYMENT_PAYPAL_IPN_GATEWAY_SERVER', 'Testing', 'Use the testing (sandbox) or live gateway server for transactions?', '6', '6', 'tep_cfg_select_option(array(\'Testing\',\'Live\'), ', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Page Style', 'MODULE_PAYMENT_PAYPAL_IPN_PAGE_STYLE', '', 'The page style to use for the transaction procedure (defined at your PayPal Profile page)', '6', '4', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Debug E-Mail Address', 'MODULE_PAYMENT_PAYPAL_IPN_DEBUG_EMAIL', '', 'All parameters of an Invalid IPN notification will be sent to this email address if one is entered.', '6', '4', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Encrypted Web Payments', 'MODULE_PAYMENT_PAYPAL_IPN_EWP_STATUS', 'False', 'Do you want to enable Encrypted Web Payments?', '6', '3', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Your Private Key', 'MODULE_PAYMENT_PAYPAL_IPN_EWP_PRIVATE_KEY', '', 'The location of your Private Key to use for signing the data. (*.pem)', '6', '4', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Your Public Certificate', 'MODULE_PAYMENT_PAYPAL_IPN_EWP_PUBLIC_KEY', '', 'The location of your Public Certificate to use for signing the data. (*.pem)', '6', '4', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('PayPals Public Certificate', 'MODULE_PAYMENT_PAYPAL_IPN_EWP_PAYPAL_KEY', '', 'The location of the PayPal Public Certificate for encrypting the data.', '6', '4', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Your PayPal Public Certificate ID', 'MODULE_PAYMENT_PAYPAL_IPN_EWP_CERT_ID', '', 'The Certificate ID to use from your PayPal Encrypted Payment Settings Profile.', '6', '4', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Working Directory', 'MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY', '', 'The working directory to use for temporary files. (trailing slash needed)', '6', '4', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('OpenSSL Location', 'MODULE_PAYMENT_PAYPAL_IPN_EWP_OPENSSL', '/usr/bin/openssl', 'The location of the openssl binary file.', '6', '4', now())");

 

}

 

function remove() {

tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");

}

 

function keys() {

return array('MODULE_PAYMENT_PAYPAL_IPN_STATUS', 'MODULE_PAYMENT_PAYPAL_IPN_ID', 'MODULE_PAYMENT_PAYPAL_IPN_CURRENCY', 'MODULE_PAYMENT_PAYPAL_IPN_ZONE', 'MODULE_PAYMENT_PAYPAL_IPN_PREPARE_ORDER_STATUS_ID', 'MODULE_PAYMENT_PAYPAL_IPN_ORDER_STATUS_ID', 'MODULE_PAYMENT_PAYPAL_IPN_GATEWAY_SERVER', 'MODULE_PAYMENT_PAYPAL_IPN_TRANSACTION_TYPE', 'MODULE_PAYMENT_PAYPAL_IPN_PAGE_STYLE', 'MODULE_PAYMENT_PAYPAL_IPN_DEBUG_EMAIL', 'MODULE_PAYMENT_PAYPAL_IPN_SORT_ORDER', 'MODULE_PAYMENT_PAYPAL_IPN_EWP_STATUS', 'MODULE_PAYMENT_PAYPAL_IPN_EWP_PRIVATE_KEY', 'MODULE_PAYMENT_PAYPAL_IPN_EWP_PUBLIC_KEY', 'MODULE_PAYMENT_PAYPAL_IPN_EWP_PAYPAL_KEY', 'MODULE_PAYMENT_PAYPAL_IPN_EWP_CERT_ID', 'MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY', 'MODULE_PAYMENT_PAYPAL_IPN_EWP_OPENSSL');

}

}

?>

 

 

 

This is the Shopping cart

 

<?php

/*

$Id: shopping_cart.php,v 1.35 2003/06/25 21:14:33 hpdl Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2003 osCommerce

 

Released under the GNU General Public License

*/

 

class shoppingCart {

var $contents, $total, $weight, $cartID, $content_type;

 

function shoppingCart() {

$this->reset();

}

 

function restore_contents() {

global $customer_id;

 

if (!tep_session_is_registered('customer_id')) return false;

 

// insert current cart contents in database

if (is_array($this->contents)) {

reset($this->contents);

while (list($products_id, ) = each($this->contents)) {

$qty = $this->contents[$products_id]['qty'];

$product_query = tep_db_query("select products_id from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");

if (!tep_db_num_rows($product_query)) {

tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . $qty . "', '" . date('Ymd') . "')");

if (isset($this->contents[$products_id]['attributes'])) {

reset($this->contents[$products_id]['attributes']);

while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {

tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "')");

}

}

} else {

tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . $qty . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");

}

}

}

 

// reset per-session cart contents, but not the database contents

$this->reset(false);

 

$products_query = tep_db_query("select products_id, customers_basket_quantity from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "'");

while ($products = tep_db_fetch_array($products_query)) {

$this->contents[$products['products_id']] = array('qty' => $products['customers_basket_quantity']);

// attributes

$attributes_query = tep_db_query("select products_options_id, products_options_value_id from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products['products_id']) . "'");

while ($attributes = tep_db_fetch_array($attributes_query)) {

$this->contents[$products['products_id']]['attributes'][$attributes['products_options_id']] = $attributes['products_options_value_id'];

}

}

 

$this->cleanup();

}

 

function reset($reset_database = false) {

global $customer_id;

 

$this->contents = array();

$this->total = 0;

$this->weight = 0;

$this->content_type = false;

 

if (tep_session_is_registered('customer_id') && ($reset_database == true)) {

tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "'");

tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '

Link to comment
Share on other sites

smime is a Unix program for encrypting and decrypting Secure MIME (S/MIME) messages. It is quite possible that it is not available on your server. Without either OpenSSL support in PHP or access to the smime program, you will be unable to use the Encrypted Website Payments feature.

 

You can verify it by going to Admin->Tools->Server Info. There is a block labeled "openssl". Yours is probably disabled. You can ask your host to reinstall PHP with openSSL support enabled.

 

Hi,

 

thanks for all your help, openssl was disabled. i emailed my host and they enabled it. everything is working perfectly now.

 

thank you.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...