Question

I am building an application that will need to create some database records in an external database when an order is purchased/completed.

So when the customer makes the purchase from our One Page Checkout cart page, I am hoping to use an Event Observer on
checkout_type_onepage_save_order_after and then connect to my external database and make an order database entry as well as a separate entry for each order item in my other database.

So my question is, how can I test my observer that should be triggered or caught when the order process is completed without you know, using my own credit card!?

Is there some sort of way to trigger or tesdt my code with PHP in a test file? Or some other way to make a test purchase on the live site?

Was it helpful?

Solution

What you're looking for is to test order placement!

Unit tests

There are a bunch of ways to do this, but what you probably need / want is to create unit tests. The two most prevalent at this time are:

Fortunately for you there's a new site for screencasts that just popped up and it goes through unit testing in general, and specifically for Magento:

http://magecasts.io/

Manual

Now, to answer your question. You shouldn't have to use your real credit card for development/testing if you're using a gateway with a test mode or a sandbox. Make sure your payment gateway provides this - change the API credentials to this sandbox environment and use test credit card data (see: http://www.getcreditcardnumbers.com/). All of the major providers offer this service.

Next - HOW do you test this? The old-fashioned way to do this is just bite the bullet and manually enter the order. (See: https://magento.stackexchange.com/a/836/336) This will allow you to enter the order over and over to test and debug.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top