1.4.1 shop_module WITH PAYPAL...

Post custom hacks and enhancements for phpwcms here only. Maybe some of these things will be included in official release later.
smoke
Posts: 53
Joined: Tue 13. Jan 2004, 13:50
Location: Berlin

Re: 1.4.1 shop_module WITH PAYPAL...

Post by smoke »

thank you for the info.
its a pitty that taxes and shipping are not working.
I didnt know that. damn.

for now I am really tired. thanks for your support!
nameless1
Posts: 880
Joined: Sun 27. Apr 2008, 23:22

Re: 1.4.1 shop_module WITH PAYPAL...

Post by nameless1 »

hello,

her is a [beta-]tutorial for adding paypal to blanco shop systems of all versions.
http://www.phpwcms-howto.de/wiki/doku.p ... hop/paypal

greetz

nml1
User avatar
juergen
Moderator
Posts: 4556
Joined: Mon 10. Jan 2005, 18:10
Location: Weinheim
Contact:

Re: 1.4.1 shop_module WITH PAYPAL...

Post by juergen »

Hmmm,

just looked at this, is this going through paypal API ? And is there any example online ? Would be nice to have !
nebenaube
Posts: 139
Joined: Fri 23. Nov 2007, 20:39
Location: Redlands, CA
Contact:

Re: 1.4.1 shop_module WITH PAYPAL...

Post by nebenaube »

There is currently one example running, but it's further initialization will be dormant until Jan 2012; so it probably wouldn't be of much use to you but here it is http://www.elementalalchemy.com clearly, there is an issue regarding sales tax and shipping that I am not able to take the time to address at the moment. I'm not sure if the code package is even available online at the moment; that is unless someone else is sharing it. When my current project is completed, I will work on updating the code and publishing it. Perhaps Oliver will consider including my changes in his codebase, perhaps not. He may not want to support it since it does not support product property choice such as size and color, etc.
nameless1
Posts: 880
Joined: Sun 27. Apr 2008, 23:22

Re: 1.4.1 shop_module WITH PAYPAL...

Post by nameless1 »

i solved the tax-problem quick and dirty. take a look at number 6 in tutorial.
serens
Posts: 1
Joined: Thu 15. Dec 2011, 16:14

Re: 1.4.1 shop_module WITH PAYPAL...

Post by serens »

Hi everybody,
I installed phpwcms_r426 and I would like to use mode-shop with paypal.

I use this tutorial: http://www.phpwcms-howto.de/wiki/doku.p ... hop/paypal

And everything is fine (some instructions are already done in phpwcms_r426).

My problems are two points in particular:
3.2: frontend.render.php

Is it correct put the new code here?

Code: Select all

} elseif( isset($_POST['shop_order_submit']) && !isset($_SESSION[CART_KEY]['error']['step2']) ) {

		// OK agreed - now send order
		
		if($_tmpl['config']['order_number_style'] == 'RANDOM') {
			$order_num = generic_string(8, 2);
________________________________________________________________________________________
} elseif( isset($_GET['shop_order_process'])  ) {
        //process order via paypal ipn
        include($phpwcms['modules']['shop']['path'].'inc/front.order_process.inc.php');
________________________________________________________________________________________
		} else {
			// count all current orders
			$order_num = _dbCount('SELECT COUNT(*) FROM '.DB_PREPEND.'phpwcms_shop_orders') + 1;
			if(strpos($_tmpl['config']['order_number_style'], '%') !== FALSE) {
				$order_num = sprintf($_tmpl['config']['order_number_style'], $order_num);
			}
		}
		
And then the following point: 5. in front.order_submit.inc.php - but the real file now is: frontend.render.php

I really don't understand where exactly put this code:

Code: Select all

                // success inserting db record of order
                    $_SESSION['shopping_cart']['order_number'] = $order_num;
 
                    switch( $_SESSION['shopping_cart']['payby'] ){
 
                    case 'paypal':
                        headerRedirect(PHPWCMS_URL.$_tmpl['config']['cart_url']."&shop_order_process");
                        break;
 
                    default:
Can you explain me this? Before or after which part of code? I'm confused!

Thank you so much!
nebenaube
Posts: 139
Joined: Fri 23. Nov 2007, 20:39
Location: Redlands, CA
Contact:

Re: 1.4.1 shop_module WITH PAYPAL...

Post by nebenaube »

I don't think the version available here has the changes that were required after it was released. I'm not sure how to help integrate it with the version of phpwcms that you are using (I have not seen the changes made to the new core). This is a bad time for me to continue working on it. I'm sorry, the situation is beyond my control. Circumstances in January 2012 might permit me to update the release and at that time, I will include the core module code files as well as a sql dump so that it will be easier to see where modifications to the core system must occur to use this hack/enhancement/pain (whatever one chooses to identify it by). Again, I apologize for your troubles. There is just nothing I can do for you at this time.
User avatar
marcus@localhorst
Posts: 815
Joined: Fri 28. May 2004, 11:31
Location: localhorst
Contact:

Re: 1.4.1 shop_module WITH PAYPAL...

Post by marcus@localhorst »

Hei,
I checked the paypal integration and stumbled over several things in the original Howto. I made some changes on the german WIKI page ( http://www.phpwcms-howto.de/wiki/doku.p ... hop/paypal )
Basically Point 3.x and 5. had false filenames. it's all in frontend.render.php (at least in the current shop version)
There are two custom config variables as described in 4: Zwischenzusammenfassung (add

Code: Select all

$phpwcms['site_domain'] = 'domain.de'; // ohne www oder subdomain
$phpwcms['machine_alias'] = 'alias'; // www oder subdomain
to config.inc.php )
So, now the sandbox works well.

I am just unsure about the fact, that I don't get any emails over the test process.

I setup a sandbox account (buyer and seller) and handle everything over the paypal sandbox.

the front.order_process.php file switches over several actions.
there is the ipn case which hold the whole identification and validation of the payment process as well as the sending of confirmation emails.
But it seems in sandbox mode it never jumps in this switch case.
The order is successful, but the IPN validation did not happen.

Does anybody have any practical experience with that code?

Thanks
Marcus

Edit: ok, I was too fast.
I still didn't understand the IPN switch!
The Sandbox Paypal Order Mails seem to be ok, the order is written to the backend, but I don't get any mail from the phpwcms system?!
nebenaube
Posts: 139
Joined: Fri 23. Nov 2007, 20:39
Location: Redlands, CA
Contact:

Re: 1.4.1 shop_module WITH PAYPAL...

Post by nebenaube »

In the paypal sandbox, one must configure the sandbox to send the ipn notification. At least that is how I remember it. Please read the Paypal documentation for the sandbox and it's use.
User avatar
marcus@localhorst
Posts: 815
Joined: Fri 28. May 2004, 11:31
Location: localhorst
Contact:

Re: 1.4.1 shop_module WITH PAYPAL...

Post by marcus@localhorst »

I figured it all out and got a working example with the sandbox.
There are some pitfalls to get it working.

1.) it's not or just under some special circumstances possible to test payment - especially InstantPaymentNotification (IPN) on localhost, because Paypal try to access your shopurl with the param "&action=ipn" - so it's better to have an online accessible testinstall. fsockopen may choke on a windows machine / Xampp Install too (hint).
2.) some sql statements were buggy so that transaction validation didn't pass (I updated the WIKI function reinitialize_cart_products etc).

I try to dig deeper into paypal payment api... :)

Thanks for the start!
nebenaube
Posts: 139
Joined: Fri 23. Nov 2007, 20:39
Location: Redlands, CA
Contact:

Re: 1.4.1 shop_module WITH PAYPAL...

Post by nebenaube »

Thanks for the heads up on the sql statement, I will check out what you posted and see if my more current source already has that fixed. I should mention that I built and tested my implementation on a live freeBSD 7.3 box running apache 2.2 and one of the version 5 releases of mysql. That machine is currently packed away in storage and I don't have access to it.
nebenaube
Posts: 139
Joined: Fri 23. Nov 2007, 20:39
Location: Redlands, CA
Contact:

Re: 1.4.1 shop_module WITH PAYPAL...

Post by nebenaube »

believe me, I've made worse errors than line 276 or line 362 in front.shop_functions.inc.php...

but what about line 438? : _dbInsertOrUpdate( DB_PREPEND."phpwcms_shop_transactions", $data, "where `txn_id` = '".$trans['txn_id']."'", '');
nebenaube
Posts: 139
Joined: Fri 23. Nov 2007, 20:39
Location: Redlands, CA
Contact:

Re: 1.4.1 shop_module WITH PAYPAL...

Post by nebenaube »

By the way, I used single case switches in the code so that I can add google checkout later.
User avatar
marcus@localhorst
Posts: 815
Joined: Fri 28. May 2004, 11:31
Location: localhorst
Contact:

Re: 1.4.1 shop_module WITH PAYPAL...

Post by marcus@localhorst »

nebenaube wrote:believe me, I've made worse errors than line 276 or line 362 in front.shop_functions.inc.php...

but what about line 438? : _dbInsertOrUpdate( DB_PREPEND."phpwcms_shop_transactions", $data, "where `txn_id` = '".$trans['txn_id']."'", '');
For the _dbInsertOrUpdate function, it's not necessary or maybe false to write the keyword WHERE in the parameter, because it's rendered in the function. Also, this param is just used for mysql 4 fallback.

I didn't find any other errors, just one thing.
When it comes to include the front.order_process.inc.php (WIKI 3.2) then it's in the if statement which first ask for an empty cart

Code: Select all

if(empty($cart_data)){
 // empty cart
}elseif(isset($_POST['shop_cart_checkout']) || isset($ERROR['inv_address']) || isset($_SESSION[CART_KEY]['error']['step1']) || isset($_POST['shop_edit_address'])) {
// step1 checkout process
} elseif( isset($_GET['shop_order_process'])  ) {
// paypal checkout process
include(front.order_process.inc.php)
} 
when paypal calls the shop to send the IPN notification, it never reach this last branch, because $cart is empty and not reinitialized by your script.
So I just set - quick and dirty - the

Code: Select all

 if( isset($_GET['shop_order_process'])  ) {
// paypal checkout process
include(front.order_process.inc.php)
} 
before the switches (addional)
So far, I will play a bit with the code :)
cheeers
nebenaube
Posts: 139
Joined: Fri 23. Nov 2007, 20:39
Location: Redlands, CA
Contact:

Re: 1.4.1 shop_module WITH PAYPAL...

Post by nebenaube »

Marcus,

That's a good catch. Thank you so much for the code review. This is the kind of collaboration I had hoped for years ago when I started working with phpwcms and joined this forum.

Your 'quick and dirty' solution may indeed be the correct path, I don't know for sure at the moment. I will have more time in the new year to wrap my head around the module code and the proposed changes. I will post my conclusions, see what we agree upon and then update and release the newer module package at that time.

Here is how I handled the empty cart issue in my revised code:

Code: Select all

if(empty($cart_data)  && !isset($_GET['shop_order_process'])) {
If anyone would like to fix/extend or validate the tax and shipping issues please jump in and let's work together as a community.

Special kudos to nameless1 for translating my initial effort.


Happy holidays everyone!
Post Reply