When you need to place a test order, it’s as easy as turning on Test Payments! But, what if your site is live? You can’t turn on Test Payments if you have customers on your site! Getting out a real credit card is a pain, here’s a way to enable quick test orders that only admins can see!
Step One – Tag Yourself
You’ll need a way to differentiate admins from regular customers. Use a customer tag! For the purposes of this tutorial, we’ll call it ‘test account’ (case-sensitive!). Go and tag your own customer account with that tag.
Step Two – Create a Payment Script
Install Script Editor and open it up. Create a script, select the Payment Gateways tab, and select Blank template. Name it something descriptive like “Test Gateway for Developers” and insert the following code:
if !Input.cart.customer || !Input.cart.customer.tags.include?("test account")
Input.payment_gateways.delete_if do |payment_gateway|
payment_gateway.name == "Test"
Output.payment_gateways = Input.payment_gateways
This will delete the payment gateway named “Test” (once it exists) for any user that does _not_ have the customer tag ‘test account’. Publish this code and leave the tab open so you can test the script in a couple minutes.
Step Three – Create a Payment Method
Head to Settings > Payments > Manual Payments > Create Custom Payment Method, and create a new method named “Test”. This method behaves like a COD or bank deposit. In other words, it does nothing and requires invoicing the customer. Save the payment method.
Step Four – Test It!
After completing that last step, your payment method is now live! Make sure your customers can’t see it!
Go back to the script editor and click Run Script. The Output section should not contain your test method!
Add your tagged customer to the cart in the Input tab. Try running the script again. The Output should contain your test method!
Step Five – Celebrate!
If your tests aren’t looking right, go deactivate your new payment method and review the steps again. Chances are there’s an error in the casing of your tag or payment method; the code is case sensitive!
However, if your tests were successful, you’re all done! You now have a hidden payment method and don’t have to use a live credit card to make test orders!