Jump to content
Harald Ponce de Leon

PayPal App for osCommerce Online Merchant

Recommended Posts

4 hours ago, azpro said:

Actually I think an ordernumber should be created on chekcout_payment.php and order should be stored in DB immediately at checkout_process.php

Why?  You don't process the payment until after checkout_confirmation.  I.e. you wouldn't send the order number to the payment processor until after checkout_confirmation.  The checkout payment page doesn't need an order number, as it only collects data from the customer, not the payment processor. 


Always back up before making changes.

Share this post


Link to post
Share on other sites
10 minutes ago, ecartz said:

You don't process the payment until after checkout_confirmation.

Offcourse - that's why

10 minutes ago, ecartz said:

order should be stored in DB immediately at checkout_process.php 

 

10 minutes ago, ecartz said:

you wouldn't send the order number to the payment processor

We do - And I can tell you it has saved us a significant number of phonecalls - AND clicking between Payment provider back to Checkout. It seems people are confused if on the payment-page of for example a bank there is no direct referall to the order (in this case the order number). In fact - if I do online purchases myself I am reluctant if it only gives a general desciption like "Purchase online at ZZZZ-shop" at Payment Porcessor / bank.

 

Edited by azpro

Share this post


Link to post
Share on other sites

@azpro

44 minutes ago, ecartz said:

you wouldn't send the order number to the payment processor until after checkout_confirmation

He's agreeing (mostly), just not with the reason for creating the order on checkout_payment.

Actually in the current system the order gets created when checkout_payment is confirmed, at the top of checkout_confirmation, and if you go back to checkout_payment the order gets deleted again. Which is where this whole discussion started...


For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce (Phoenix).

here: on the official osc download page

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites

@BrockleyJohn  Thanks! I was kind of jumping in without reading all posts ... My bad 😉

But I didn't mean / say to create the whole ORDER but only the Order Number (order_id) on checkout_payment. 

Share this post


Link to post
Share on other sites

Ok - but that sounds unnecessarily complicated - and btw checkout_process is too late as previously discussed.


For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce (Phoenix).

here: on the official osc download page

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites

My comments aren't regarding policy...but rather what I see in the code.  Now, I may be a little fuzzy, but I do know that special accommodations with regard to the timing of order creation during the checkout process are altogether different for PayPal.  There are vast sections of code that are duplicated and run 'a step sooner' just for PayPal.  I've not experienced much in the way of payment modules, but that much I know for certain.  I've installed (and used) authorize.net, PayPal, and the 'wire transfer' module.  Wire transfer creates the order at completion, and the order is posted as "awaiting payment" in the admin list.  Authorize.net does NOT create an order number.  In their interface...there is only an amount...no correlating order.  However, when you return to the store, you'll find an order number.  When I dug deeper to see why, it was revealed just how simple the module is (there was no order number being sent because it didn't exist yet), and by comparison, just how complex the PayPal module is.  But again...don't take my word for gospel here.  @Harald Ponce de Leon is the guy that can answer these questions without conjecture.

My main point is to address the stated concerns about why order numbers were changing - and it's because the customer is altering their cart AFTER having chosen PayPal as the payment method.  Also...there will be a number of customers that don't ever actually place the order...and when they do that, that order number will be 'occupied' indefinitely...the site will skip over it and continue on generating new order numbers from there.  The solve for me was simple: create an order status just for these "temporary" orders, and have your orders.php query exclude that status from displaying normally.  You can always specify from the drop-down if you need to view them.

There are other issues that you may find more problematic with the PayPal app...like inventory counts being off, for example, because there are 2 opportunities for the site/code to 'complete' the order - one when the customer returns to the site from PayPal, and again when the IPN lands on the site.  I find that both MUST be used, because sometimes a customer will click 'pay' at paypal, but will close the browser before they ever return to the site.  Can't really rely only on the IPN either, because there are times - fairly often - when the IPN is delayed.  On occasion, it's been hours late showing up.  And of course in this case, the customer returns to find an 'unpaid' order.  Well, when both are used, it just so happens that they CAN land close enough to each other that BOTH try to complete the order (stock decrement, etc.).  This happens pretty often.  And the only tell-tale sign that you have, is that the site will have sent 2 order confirmation emails, which you can see in the status updates for the order in your store ("customer emailed - green checkmark").  This is a long thread, but go through and read up on it.  I've posted numerous times in numerous threads about this...provided images of the backend, database content screenshots.

And here's another kind of major issue with PayPal.  OSC isn't set up to distinguish between payment statuses as returned by PayPal.  Just because a customer completes the payment, doesn't mean that PayPal has approved the payment.  I've seen it return 'Pending' payments...not pending order status....pending PAYMENT status.  The site can't tell the difference.  It processes the order just like PayPal approved the transaction.  I've posted numerous details about this too.  You can potentially ship what you think is a paid order, only to find out days later that the payment actually was never approved...good luck getting your product back.

And now that they are no longer refunding fees ...you as the business owner will get stuck with paying fees based on what the original transaction amount was...not the total after you issue a partial refund.  Maybe not a big deal if your average sale is $100, but wait till you have to refund $1500 of a $2000 sale...that'll get your attention.  We're moving away from PayPal as fast as my fingers can type.

In other news...the Square module seems to be working very nicely...

Share this post


Link to post
Share on other sites

@Supertex   I wanted to stay further silent in this thread but I believe you are right .. It seems like a differnece between coding and real-life running a shop. All the examples you give we had to "code" around ...

- Stock-deduction : we do extra checks 

- Customers clicking back and forth betwen payment-processing and checkout: we check order_id and status so there is not a new order number

- Payment statusses for non confirmed Payment / and or abandoned payment: we do extra checks

So - improvements can surely can be made!

Share this post


Link to post
Share on other sites

Do you still get double-processing with the app? I've not seen it in my clients but lots with the previous modules, so I believe it's better now at least if not eliminated.

Yes, a different status for paypal cheques would be a good thing. My stock interfaces have to interrogate the order history to find out whether the payment has cleared or not.

I don't get the obsession with consecutive order ids (which you can never achieve totally anyway). If you want to track sales consecutively, why not allocate a consecutive sale/purchase/invoice number when an order is paid? Much simpler and the way that many other systems work. This is an issue right across osc and not confined to the paypal module.


For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce (Phoenix).

here: on the official osc download page

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites
On 11/18/2019 at 1:26 PM, azpro said:

😂

I have to agree with @BrockleyJohn  .. Actually I think an ordernumber should be created on chekcout_payment.php and order should be stored in DB immediately at checkout_process.php .. The need for it would probably depend on different Payment Service Providers / Gateways but in my experience the ones I have seen could be handled better with an existing/created ordernumber.

Actually this was one of the first changes we did some 15 years ago when we started to use oSC.

 

I have done the same thing on my 2.2 site, and now need to rewrite phoenix to do the same
yes I occasionally have to go into the database to delete declined orders but but I have to pass an order # to my payment processor.
to me it makes sense to assign the order number the moment checkout_process.php is loaded


Jim Bullen - President

The Cigar Hut Group of Companies

 

 

Installed add-ons: (that now need to be upgraded to OSC CE Phoenix)

PWA, MVS, Easy Populate, Dynamic Sitemap, Featured Products, MVS Order Editor, MVS Shipping Estimator, Google XML Sitemap, About Us, Ad Tracker, Address Enhancer, Also Purchased, Backorders, Category Descriptions, Dynamic Meta Tags, Contact Us Email Subjects, Country state Selector, Extra Address Line, Order Number in Email Subject, OSC Affiliate, Product Extra Fields, Review Approval System, Reviews in Product Display, Sold Out, Sold Out (but Displayed), Ultimate SEO URL's, Updated Spiders, Welcome Email Password, Pending Order Email, Who's Online Enhancement, CCGV, Easy Discounts, Customer Comments, Request a Review, Sales Report, plus many many more!

Share this post


Link to post
Share on other sites
4 hours ago, cigarsforless said:

to assign the order number the moment checkout_process.php is loaded

This is the latest time that an order can be created and is typically after the payment has been taken. I do recall working with a payment module that doesn't go off-site for the payment until the before_process in checkout_process and executes its after_process on a callback. This does allow you to postpone allocating an order id until the order is confirmed.

However, modules that offer an express checkout - paypal expresss and amazon pay for example - must allocate the reference number at the beginning of checkout.


For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce (Phoenix).

here: on the official osc download page

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites

Things that I see with paypal:

1. Customer arrives on paypal and then does not pay - order is created but no paypal info, still shows as pending! This I can cope with as I can see that there are no paypal entries.

2. Customer pays and then does something ???? resulting in a payment but no order, sometimes when checking baskets the stuff is in the basket. This I cannot cope with I get emails!!!

3. Duplicate order nos at paypal. Paypal checks the order no and there better not be a duplicate or it wont process properly at paypal. I learned this the hard way after my first upgrade. Now if Iupgrade the database I always increment the base order no by 100000.

4. And a little bit off piste BUT: its nice to have a permanent basket but I have hundreds in the database. We could actually do with something to clean them up after a specified time. e.g. not updated for 3 months

 

Share this post


Link to post
Share on other sites

@astecme are you using the app? Sounds like your paypal isn't configured properly: order should be created in preparing status not pending and that IPN isn't working and quite possibly the return url is not working properly either!

None of that is behaviour you need to live with.

Incidentally, what has upgrading the database to do with order numbers?

 


For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce (Phoenix).

here: on the official osc download page

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites

Yes and yes it is working and configured correctly. What I mentioned were exceptions not the rule. Apart from the order no check.

Share this post


Link to post
Share on other sites
1 hour ago, astecme said:

We could actually do with something to clean them up after a specified time

We have a mod from @burt - "Recover Carts" - that does this as well as alternatively emailing customers about their basket contents - it's been of great use in our shops.

Share this post


Link to post
Share on other sites
44 minutes ago, Heatherbell said:

We have a mod from @burt - "Recover Carts" - that does this as well as alternatively emailing customers about their basket contents - it's been of great use in our shops.

highly recommended


For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce (Phoenix).

here: on the official osc download page

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites
2 hours ago, astecme said:

We could actually do with something to clean them up after a specified time. e.g. not updated for 3 months

https://apps.oscommerce.com/HUONy&unsold-carts-report-2-0

Lets you run a report for a selected number of days to show all unsold carts. You can then deleat if required.

image.thumb.png.eefda6661e1225bbde59deb5d3773d20.png


 

Share this post


Link to post
Share on other sites

Hello.

I need a little help fixing some code that saves some customized text attributes in each product in the order, if inserted... It works for all orders and payments except PayPal Standard orders..

It saves the attributes at checkout_process.php, but seems that PayPal deletes the order created and generates a new this way: 

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

I need to save order_id and also orders_products_id. The current code I got in checkout_process.php (also at paypal_standard.php) is this:

tep_db_query("insert into orders_text_attributes (`orders_id`, `products_id`, `products_text_attributes_id`, `products_text_attributes_text`, `orders_products_id`) values ('" . $insert_id . "', '" . $order->products[$i]['id'] . "', " . $attr['products_text_attributes_id'] . ", '" .  $attr['products_text_attributes_text'] . "', '" . $order_products_id . "')");

The variables $insert_id and $order_products_id gets -1 from what is correct and final order id.

I've added at the paypal_standard.php but it seems that it does the same as checkout_process.php but I've saw at the logs, that after the payment paypal page redirects to checkout_process.php and then receive a POST in standard_ipn.php from PayPal and then checkout_sucess.php. Can this be caused because of the code at paypal_standard.php? Should it be only at checkout_process.php or should I user variable $order_id instead $insert_id?

By the way if someone could explain how the paypal standard works, for example what files does what and what are they segment.. So I could understand and least where to fix this. Because I've already saw this at logs:

1º checkout_process.php?amt=...&cc=...&cm=...&st=...&tx=...

2º checkout_sucess.php

3º standard_ipn.php (sometimes is checkout_sucess.php the last - maybe some delay?)

Best regards

Edited by sinopia
edit

Share this post


Link to post
Share on other sites

I've commented the code from paypal_standard.php and leave the code at checkout_process.php. 

From the logs the PayPal orders goes through checkout_process so probably there should be the correct order id variable.. I'll test to see if it works.

Share this post


Link to post
Share on other sites

Paypal creates orders before checkout_process - the order is created before passing the customer to paypal. That order is then updated and emails sent by the processing in checkout_process or by the ipn.

The processing that creates the order (confirmation method) is run on the checkout_confirmation page - creating an order in the preparing status. If the customer subsequently cancels out of paypal, they land back at the checkout_payment page and the preparing order gets deleted. If they choose paypal again, a new order will be created when they get to confirmation again.

The customer does not always come back to your site after paying. You can't rely on changes to checkout_process always being performed.


For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce (Phoenix).

here: on the official osc download page

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites

Hi @BrockleyJohn

Thank you for your explanation. 

I've only the code at checkout_process.php now. As it was running the code at paypal_standard it was recording as the old order id as the payment was not confirmed yet.

I've Auto Return enabled for checkout_process.php so after confirming the payment it returns to my website after finishing the payment, at least what I see in the logs:

XXX.XX.XXX.XXX - - [06/Feb/2020:22:26:33 +0000] "GET /checkout_process.php?amt=XX.XX&cc=EUR&cm=XXXXX&st=Completed&tx=XXXXXXXXXXX HTTP/2.0" 302 20 "https://www.paypal.com/webapps/hermes?token=XXXXXXXXXX&useraction=commit&rm=X&mfid=XXXXXXXXXXXXXXX" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36"

The referer comes directly from paypal so it should work. I'll see in the next order if this is working as it should.

Thank you very much. Best regards.

Share this post


Link to post
Share on other sites

In the ordinary run of things, the delivered paypal standard module doesn't change the order number. That only happens if the customer goes to paypal, cancels back to the checkout, then confirms again. Of course, if you've changed it then it might be doing something different!


For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce (Phoenix).

here: on the official osc download page

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites

Some store owners are experiencing a problem where PayPal is not sending the orders back to the store.  The IPN is failing.  As a troubleshooting step, get the latest version of the ext/modules/payment/paypal/paypal.com.crt file and replace the version on your store with it.  See if things work after doing that. 

The easiest way to get that file is to download the current version of Phoenix, either from the Products page or https://github.com/gburton/CE-Phoenix/archive/master.zip and extract the file from it. 

I believe that file has been required for PayPal.  So your store should have it.  If for some reason you are trying to install PayPal on an older store, consider getting the PayPal App from the Marketplace:  https://apps.oscommerce.com/fZMiN&paypal-app

The most recent version is older than the introduction of the file to Phoenix, so you may have to update the version of the file that comes with that.  But the PayPal App version of the payment module does use that file. 

Note that PayPal with IPN uses multiple files.  There will always be one in includes/modules/payment plus it has files in includes/apps and ext/modules/payment/paypal .  If you don't have all those files, then you may need to install the PayPal App to get them. 


Always back up before making changes.

Share this post


Link to post
Share on other sites

For others using PayPal express, is it default behaviour that only the sub-total gets passed through to the PayPal page,  not e.g. shipping?

On the paypal page, my customers see the sub-total, which does not include shipping. On return to the checkout confirmation page they see everything else (shipping, discounts etc.). The subsequent paypal payment record only shows the total form the checkout confirmation page as the sub-total, and excludes shipping.

My recollection of the not too distant past is that the shipping information would pass through. Certainly it would appear on the paypal records as an individual amount.

Peter

 

 


PROUDLY PASSIONATE PHOENIX SUPPORTER

Full-time I am a C-suite executive of a large retail company in Australia. In my spare time, I enjoying learning about web-design.

Download the latest version of CE Phoenix from gitHub here

Join the Phoenix Club. Become a Phoenix Supporter.  Gain access to special codes and modules and help the project thrive. Read here

 

Share this post


Link to post
Share on other sites
2 hours ago, peterpil19 said:

For others using PayPal express, is it default behaviour that only the sub-total gets passed through to the PayPal page,  not e.g. shipping?

On the paypal page, my customers see the sub-total, which does not include shipping. On return to the checkout confirmation page they see everything else (shipping, discounts etc.). The subsequent paypal payment record only shows the total form the checkout confirmation page as the sub-total, and excludes shipping.

My recollection of the not too distant past is that the shipping information would pass through. Certainly it would appear on the paypal records as an individual amount.

Peter

 

 

You can't get shipping quotes until you provide an address, which in this case comes from paypal. So the sequence is: flow to paypal with basket, choose shipping address in paypal, paypal makes a call to the store to get the shipping quotes, choose the shipping method and payment method on the total including shipping, back to checkout confirmation

Sounds like there could be a problem with the callback for shipping quotes on your checkout


For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce (Phoenix).

here: on the official osc download page

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×