Clicky

How would I use Magento functions to invoice an order programatically vs. having to go into the BO to do it?

asked 11/09/2011 12:37

EddieShipman's gravatar image

EddieShipman ♦♦


11 Answers:
Do you mean that you want to use a Bridge to link magento to your CRM software?(http://www.ebridgeconnections.com/webstore/varien-magento-ecommerce.html)
link

answered

miked2004's gravatar image

miked2004

Nope, we want to be able to call a script from our Accounting system with an order number and the script would create the invoice and mark it as paid.
The bridge is a good idea but we don't use any Magento related info with the exception of order numbers.

We have an ExpressionEngine CMS and are using ONLY the Magento cart. Our accounting system is an in-house built Oracle system.

We offer courses, online and classroom.  Each 'event" is synched with our Oracle backend into the ExpressionEngine tables as well as Magento.
We also sell publications, which are also stored in Magento.

When a user adds a course to their cart, we use an in-memory "voucher" because we also allow them to register other people for the course. We are beginning to offer eBooks and need to be able to invoice so we can enable the download link. Since we also offer Pay By Check, we want the accounting dept to be able to trigger the creation of the Magento Invoice when the check clears.
link

answered 2011-11-09 at 08:43:29

EddieShipman's gravatar image

EddieShipman

Ah.. Well you can create a script to do this and place it in magento's webroot or you can create a custom module that will provide a url to send this data to(that is the easy part).

Then you will need to process the order. Here is a link that describes the general idea. You may need to adapt the code to work for you.
http://inchoo.net/ecommerce/magento/how-to-create-magento-invoice-from-order/
link

answered 2011-11-09 at 09:21:58

miked2004's gravatar image

miked2004

That should work. However, what is CAPTURE_ONLINE?
link

answered 2011-11-09 at 10:07:47

EddieShipman's gravatar image

EddieShipman

Oh, a new direction has arisen...

We intend to do it like this, instead of the way outlined above:
1. Customer gets sent regular confirmation email, order is still marked as Pending.
2. Customer clicks on the link.
3. Script that checks to see if link is enabled actually sends the order_id to a webservice that responds 'YES' or 'NO' based on completion of the Oracle accounting system invoice.
4. If 'YES' then product is allowed to be downloaded.
5. If 'NO', then customer is redirected to a page saying their payment hasn't cleared, with message based on payment type.
  If check hasn't cleared, it will say that, it CC then give reason why it wasn't accepted, perhaps AV check or something like
  that because we don't do AV checks within Magento.

Now, what script checks to see if the invoice is enabled for download?
link

answered 2011-11-09 at 10:33:43

EddieShipman's gravatar image

EddieShipman

You will need to check for each download link, there is not a setting for the entire order/invoice.

Each downloadable link gets recorded into two tables.

1. downloadable_link_purchased: This mainly allows you to relate the order_id to a downloads purchased. You need the purchased_id from this table to look up the actual links bought, which are stored on the next table.

2. downloadable_link_purchased_item: This is where each link's data is stored. There is a field for "Status", which will be "pending", "available", "expired", or "pending_payment". You should only allow downloading if it is set to available.


You can look at the __construct function in the following block to get an idea of how Magento gathers valid downloads per customer(you will need to tweak to work via order_id).
/app/code/core/Mage/Downloadable/block/customer/product/list.php
link

answered 2011-11-09 at 10:50:44

miked2004's gravatar image

miked2004

Where is the code where when you click on this link:
http://www.mystore.com/downloadable/download/link/id/MC40NTQ0MTkwMCAxMzIwODU3OTU5ODMwMDY0NjU2OA,,/

it would redirect to the actual download link and begin downloading if the item was enabled?

I don't quite understand why I would have to manipulate the DB. I want to be able to circumvent the checking for that status.
link

answered 2011-11-09 at 11:07:24

EddieShipman's gravatar image

EddieShipman

Oh, I think I found it...
/app/code/core/Mage/Downloadable/Helper/Download.php
link

answered 2011-11-09 at 12:19:43

EddieShipman's gravatar image

EddieShipman

Also the _processDownload() function in
app/code/core/Mage/Downloadable/controllers/DownloadController.php
link

answered 2011-11-09 at 12:25:29

EddieShipman's gravatar image

EddieShipman

Yipee!!! I figured it out.

in the linkAction() function there is a try..catch where _processDownload() is called. Looks like I'll still have to have the "Order Item Status to Enable Downloads" set to Pending and then catch it before it calls _processDownload().

I'm going to have it redirect to a page telling them that their payment hasn't cleared otherwise it will go ahead and download the product. Just tested it and it works.
link

answered 2011-11-09 at 12:27:58

EddieShipman's gravatar image

EddieShipman

Thanks, Mike, you are tons more help than those crappy Magento Forums. I've gotten better responses here from you than from anyone on their own forums.

Keep up the good work, I'll keep feeding you the points!!!
link

answered 2011-11-09 at 12:54:19

EddieShipman's gravatar image

EddieShipman

Your answer
[hide preview]

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Tags:

Asked: 11/09/2011 12:37

Seen: 678 times

Last updated: 11/09/2011 05:03