An Easy Way to Validate Billing and Shipping Information PHP Script

An Easy Way to Validate Billing and Shipping Information PHP Script

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.

I have included the FraudLabs Pro class in the zip. However, you may check the latest FraudLabs Pro library at http://fraudlabspro.codeplex.com
Sign up for a free API key, if you do not have one, at http://www.fraudlabspro.com/sign-up
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.
Input the billing and shipping information.

 
 

$flp->flpRequest->billingCity = "New York";
$flp->flpRequest->billingZIPCode = "00001";
$flp->flpRequest->billingState = "New York";
$flp->flpRequest->billingCountry = "US";
$flp->flpRequest->shippingAddress = "1-2-3 Street A";
$flp->flpRequest->shippingCity = "New York";
$flp->flpRequest->shippingZIPCode = "30002";
$flp->flpRequest->shippingState = "NY";
$flp->flpRequest->shippingCountry = "US";
$flp->flpRequest->amount = 123.00;
$flp->flpRequest->quantity = 2;
$flp->flpRequest->currency = 'USD';
$flp->flpRequest->paymentMode = 'creditcard';

 

Perform the fraud check.

 
 

$result = $flp->fraudCheck();

 

Get the result:

Check if billing country match the shipping country

 
 

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

 

Check if billing state match the shipping state

 
 

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

 

Check if billing city match the shipping city

 
 

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

 

Check if the billing postal code match the shipping postal code

 
 

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

 

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

 
 

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

 

Check if the billing country is flagged as high risk country

 
 

if ($flp->flpResponse->isHighRiskCountry == "Y")
echo "Is the billing country is a high risk country: Yes<br/>";
else if ($flp->flpResponse->isHighRiskCountry == "N")
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.

 

 

 

Comments

Popular posts from this blog

Motos Android Mame Game Download

Storytlr Micro Blog PHP Script Free Download

Tiki Wiki CMS Groupware Portal PHP Script Free Download