Preventing Credit Card Fraud Using PHP and MYSQL Database in 2022

Credit card fraud has become widespread on the Internet. According to MasterCard International, there has been a 369% increase in account hijacking fraud since 1995. It has become one of the fastest growing and most difficult frauds to combat. More than $ 700 million in online sales was lost to fraud in 2001, according to GartnerG2, accounting for 1.14 percent of the total annual online sales of $ 61.8 billion. Even though the credit card company has given permission for the card’s expiration date, there are several ways to use fraudulent cards on your site. The card could have been lost or stolen, but the cardholder has not yet reported its loss. Or the number on the card (and not the card itself) could have been removed without the owner’s knowledge. There is also a fraud called theft, where a card is issued under a false pretense using someone else’s identity and data.

As an online merchant, you need a system to authenticate your placed orders to protect your business. While it may take extra time and money to do this, it can save you the cost and stress of fraudulent order chargebacks. You have lost your physical products; you lose the selling price; you are missing out on another business opportunity; and you will be fined an additional chargeback fee of $ 15-50. If you have a high chargeback rate, your card company might even blacklist you and void your merchant account. You will also take the time to search for the order and provide the requested information to your card service company. You can surely do without all of this annoyance.

How To Protect Your Business From Credit Card Fraud? Here are a few steps you can take to ensure that the transaction is being requested by the real cardholder.

Suspicious shipping address.

Orders from Ukraine, Indonesia, Yugoslavia, Lithuania, Egypt, Romania, Bulgaria, Turkey, Russia, and Pakistan have very high fraud rates and often have unverifiable addresses, according to ClearCommerce Corporation, a provider of payment processing and fraud protection software for e-commerce. …

Untracked email address.

In many fraudulent orders, the customer’s email address is often found in one of the free email services such as and, which are relatively untraceable.

Expensive things.

Beware of expensive orders, especially expensive branded items.

Several items.

This can be a bad sign, for example, if someone orders three X-Boxes or three DVD players at once, especially if the merchandise has a high resale value.

Express delivery.

Most fraudulent orders do not hesitate to include overnight or day delivery.

The shipping address is different from the billing address.

Pickup location and billing address are different for fraudulent claims. If you are selling valuables, it may be a good policy to only ship to the cardholder’s billing address.

Suspicious billing address.

The address looks too simple or invalid. If the billing address is 123 Main St, New York, the order is likely a scam. You can use either an online location tool to see if the address can be verified.

Leave at the door or in the mailbox.

If the courier service cannot guarantee delivery of the goods, the risk of fraud is very high.

The development of geo-targeting on the Internet allows us to precisely define the geographic region for the order. The information can be used to reduce fraud by verifying it against a billing and shipping address. This method can identify a scenario where someone from country X has stolen credit card information from country Y. The IP lookup service will show the real country instead of relying on the country filled out on the order form.

IP2Location ™ provides technology to translate an IP address to its country of origin. The lookup table is available in several formats such as database and COM. It is ideal for automating fraud detection using client-side programming languages ​​such as C ++ and Visual Basic; or utility programming languages ​​such as ASP, PHP, JSP, and CFML.

For example, company XYZ received an order for a credit card from the IP address The order details are as follows:

Name: John Ma

Address: 123 Main St

City: New York

Postal Code: 11111

Country: USA

Tel: (503) 111-1111

Credit card number: 1234 5678 9012 3456

Valid: December 2010

The credit card processor will authorize this order if the billing address matches the order details. Unfortunately, the credit card details were stolen earlier by Mr. Alphabet from another country via the Internet. Later, using this information, he made a purchase of digital products from XYZ Company. His order was approved by the seller because all the details matched John’s entry in the bank’s database. IP2Location ™ technology can pre-filter the difference between the country of order and the country of entry to protect your business. You can classify this type of order for manual check before delivery. You will be surprised how much this method will help in identifying fraudulent orders.

In this tutorial, we use the IP-Country IP2Location ™ database to find the country of origin based on the visitor’s IP address. Instead of downloading a complete database with over 50,000 entries, we could simplify this guide by assuming there are only two different IP ranges in the world. The IP addresses – come from the United States. Meanwhile, the IP addresses – come from Japan. Here we create a database “IP2Location” with a table “IPCountry” which consists of two IP address range entries.

Step 1. Create the IP2Location database and connect to it.

mysql> CREATE DATABASE IP2Location

mysql> CONNECT IP2Location

Step 2. Create the IPCountry table

mysql> CREATE TABLE IPCountry

-> (




-> countryLONG VARCHAR (100) NOT NULL,



Step 3. Import the ipcountry.csv database into the IPCountry table.

mysql> INSERT INTO IPCountry VALUES (0, 2130706431, ‘US’, ‘UNITED STATES’);

mysql> INSERT IN VALUES IPCountry (2130706432, 4294967295, ‘JP’, ‘JAPAN’);

The full version of the IP-Country Database is available for subscription for $ 49 / year at If you have a full version of the IP-Country IP2Location (TM) database, the import process will be much easier with the LOAD DATA function available in MYSQL.


We are creating a script to compare the country of the search and the data provided in the order authorization stream. It serves as a filter to reduce fraud. All rejected orders will be manually checked by sellers.


Leave a Comment

Your email address will not be published.