An Easy Way to Validate Billing and Shipping Information

Submitted by: 
Language: 
Visitors have accessed this post 4435 times.

You have an online business that you make your living with. There is nothing more important to ensure all the orders are from legitimate buyers but not fraudsters. Many approaches or tools you may use to ensure this, and here I’m going to show you how to do this by leveraging a free API from http://www.fraudlabspro.com.

First of all, I assume you have basic technical background and well familiar with PHP code. Billing and shipping information is the first indicator you should check for possible fraud attempts. This is particularly true if your business involves shipment of the physical product to a destination. If this is the case, a “Freight Forwarder or P.O.Box” shall trigger your alarm of high potential fraud. A following up on email or phone confirmation is advisable to make sure the right person making the right purchase.

In addition, there may be cases where the buyer is buying a gift for a friend, family member or beloved one who stay in another corner of the world. However, in most cases, a red flag shall be triggered if the billing and shipping address is too far apart in distance. I’m not saying this happens in all cases, but precautionary steps shall be taken to prevent fraud losses.

Be wary of having online transaction with high risk countries! You are not advisable to blandly accept online transaction of a new customer from these countries without taking extra confirmation steps. But, how you determine which countries are the high risk? There is nothing to be worry of, you just need to leverage the high risk countries list from the API. A list that has been regularly checked and compiled by FraudLabs Pro.

There are more validations you can perform, or perhaps you shall perform, to accurately identify a fraud attempt. However, to simplify the code, I will explain further in a few sample codes and tutorials and we focus on the billing vs shipping in this tutorial.

  1. I have included the FraudLabs Pro class in the zip. However, you may check the latest FraudLabs Pro library at http://fraudlabspro.codeplex.com
  2. Sign up for a free API key, if you do not have one, at http://www.fraudlabspro.com/sign-up
  3. It’s time to create the sample code. Here, I will explain you some sections but not all. You may download the entire code for your own testing later on.
  4. Input the billing and shipping information.
    1. $flp->flpRequest->billingCity = "New York";
    2. $flp->flpRequest->billingZIPCode = "00001";
    3. $flp->flpRequest->billingState = "New York";
    4. $flp->flpRequest->billingCountry = "US";
    5. $flp->flpRequest->shippingAddress = "1-2-3 Street A";
    6. $flp->flpRequest->shippingCity = "New York";
    7. $flp->flpRequest->shippingZIPCode = "30002";
    8. $flp->flpRequest->shippingState = "NY";
    9. $flp->flpRequest->shippingCountry = "US";
    10. $flp->flpRequest->amount = 123.00;
    11. $flp->flpRequest->quantity = 2;
    12. $flp->flpRequest->currency = 'USD';
    13. $flp->flpRequest->paymentMode = 'creditcard';
  5. Perform the fraud check.
    1. $result = $flp->fraudCheck();
  6. Get the result:

    Check if billing country match the shipping country

    1. if ($flp->flpResponse->isBillShipCountryMatch == "Y")
    2. echo "Is Billing Country match the Shipping Country: Yes<br/>";
    3. else if ($flp->flpResponse->isBillShipCountryMatch == "N")
    4. echo "Is Billing Country match the Shipping Country: No<br/>";

    Check if billing state match the shipping state

    1. if ($flp->flpResponse->isBillShipStateMatch == "Y")
    2. echo "Is Billing State match the Shipping State: Yes<br/>";
    3. else if ($flp->flpResponse->isBillShipStateMatch == "N")
    4. echo "Is Billing State match the Shipping State: No<br/>";

    Check if billing city match the shipping city

    1. if ($flp->flpResponse->isBillShipCityMatch == "Y")
    2. echo "Is Billing City match the Shipping City: Yes<br/>";
    3. else if ($flp->flpResponse->isBillShipCityMatch == "N")
    4. echo "Is Billing City match the Shipping City: No<br/>";

    Check if the billing postal code match the shipping postal code

    1. if ($flp->flpResponse->isBillShipPostalMatch == "Y")
    2. echo "Is Billing Postal match the Shipping Postal: Yes<br/>";
    3. else if ($flp->flpResponse->isBillShipPostalMatch == "N")
    4. echo "Is Billing Postal match the Shipping Postal: No<br/>";

    Check if shipping address is a freight forwarder or P.O.Box

    1. if ($flp->flpResponse->isAddressShipForward == "Y")
    2. echo "Is the address a Ship Forward or P.O.Box: Yes<br/>";
    3. else if ($flp->flpResponse->isBillShipPostalMatch == "N")
    4. echo "Is the address a Ship Forward or P.O.Box: No<br/>";

    Check if the billing country is flagged as high risk country

    1. if ($flp->flpResponse->isHighRiskCountry == "Y")
    2. echo "Is the billing country is a high risk country: Yes<br/>";
    3. else if ($flp->flpResponse->isHighRiskCountry == "N")
    4. echo "Is the billing country is a high risk country: No<br/>";

Please take note that you do not necessarily matching all elements in shipping address such as country, region, state, and postcode. Often the match of country is what you can consider to validate.

Happy Coding.


Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.

FOR YOUR OWN SAFETY, PLEASE:

1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.