Forum

Thread tagged as: Problem, Shop

Perch Shop Misnumbered Invoices

I've set up Perch shop and it's working well. I posted a couple of questions, but the following seems like a bit of a bug/issue.

We've now had four orders through. The final order is labelled as "Invoice 4" in Perch, but the corresponding PayPal email says it is "Invoice 8", which makes it hard to marry up the two. The order has ID=8 in the database (order IDs 4-7 are just "Created" orders, but never completed, so when order ID 8 completes it's labelled Invoice 4, but Invoice 8 in PayPal).

It would be better if the Invoice Numbers agreed in both places. (Ideally the PayPal order would show all the items as well as the Invoice number)

Is the problem with the Orders in the database which don't have an Invoice number? Or with the numbering?

Here's my diagnostics...

Perch: 3.1.2, PHP: 7.1.5, MySQL: mysqlnd 5.0.12-dev - 20150407 - $Id: b396954eeb2d1d9ed7902b8bae237b287f21ad9e $, with PDO
Server OS: Linux, cgi-fcgi
Installed apps: content (3.1.2), assets (3.1.2), categories (3.1.2), perch_blog (5.6.1), perch_events (1.9.5), perch_forms (1.12), perch_shop_orders (1.2.6), perch_shop_products (1.2.6), perch_shop (1.2.6), perch_members (1.6.4)
App runtimes: <?php $apps_list = [ 'categories', 'perch_blog', 'perch_forms', 'perch_members', 'perch_shop', 'perch_events', ];
PERCH_LOGINPATH: /perch
PERCH_PATH: /var/sites/s/SITE.COM/public_html/perch
PERCH_CORE: /var/sites/s/SITE.COM/public_html/perch/core
PERCH_RESFILEPATH: /var/sites/s/SITE.COM/public_html/perch/resources
Image manipulation: GD
PHP limits: Max upload 100M, Max POST 100M, Memory: 128M, Total max file upload: 100M
F1: 3b606135b33e6a102526838f4152a807
Resource folder writeable: Yes
DOCUMENT_ROOT: /var/sites/w/SITE.COM/public_html
HTTP_HOST: www.satelliteworship.com
REQUEST_URI: /perch/core/settings/diagnostics/
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
Paul Bell

Paul Bell 0 points

  • 2 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

It sounds like one template is using the order ID and the other the order number. Could just be a template tweak. It should be the order number.

Maybe... it's the PayPal email that is wrong though... if I look in the Perch Shop admin, it shows up as Invoice 4 (I can only see it's ID=8 by hovering over it and inspecting the link). I'm using the default templates for all the emails, and I'm not aware of a way of templating the PayPal email (which also shows up if you log in to PayPal to view the transactions).

Drew - is there somewhere I should look to see if this can be resolved? Which template? Thanks.

I've just had a dig into this... it seems as though this is going to be tricky to resolve.

The PayPal payment gateway sends over the order ID from the database to Perch. Only after the payment is processed and completed is the Invoice ID assigned, so it's never going to show be possible to show the Invoice ID correctly on the PayPal email, and once the order ID and Invoice ID get out of sync (say someone clicks off to PayPal and doesn't complete their payment), they're going to disagree on every invoice, which is confusing for the client and customer.

Is there another suggestion of something I could try? Or perhaps just not include the Invoice ID at PayPal?

Hussein Al Hammad

Hussein Al Hammad 105 points
Registered Developer

Hello Paul,

once the order ID and Invoice ID get out of sync (say someone clicks off to PayPal and doesn't complete their payment)

Technically an order is different from an invoice, so each has their own ID, no?

When someone attempts to checkout, Perch creates a new order. If they don't go through with the payment, there's no invoice and so Perch Shop cannot assign an invoice ID to this order. Analytically, wouldn't this be useful to know if a customer abandoned the payment process halfway through? I don't think Shop lists those at the moment though.

So I don't think trying the have the order ID and the invoice ID to be the same makes sense.

they're going to disagree on every invoice, which is confusing for the client and customer.

I would add both the order ID and the invoice ID to the email you send from Perch.

Thanks for this - good suggestion to add the order ID as well as the invoice ID to the Perch email. That does make some sense. I can see the technical reason why the order ID and Invoice Number shouldn't agree, it was just that it wasn't immediately obvious to me, much less so the client, that these should be different. The client has no reason to worry about the difference...

I could just use the order ID throughout, but then there would be gaps in the numbering, which again is confusing to the client. What I'd like to be able to do is to hide the Order ID from the client entirely and just use the Invoice ID, but that doesn't work due to it being exposed in the PayPal email. (I've already explained why I can see it's difficult to use the Invoice ID in the PayPal email since it's not assigned until the payment successfully completes). I guess I just have to let the client live with it, but it is slightly less than ideal.

Drew McLellan

Drew McLellan 2638 points
Perch Support

We can't send the invoice ID to PayPal, as the invoice ID is only created when the payment has been made. I don't believe we can control what PayPal puts in their emails either. The invoice IDs should be sequential, as that's what the client will need to use for their accounting.