Skip to content

Commit

Permalink
new function added
Browse files Browse the repository at this point in the history
  • Loading branch information
chrislim2888 committed Jan 5, 2016
1 parent 193e90a commit 0473ffe
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Revision History for FraudLabs Pro
1.0.1 2016-1-5
Support new params and orderFeedback function
Support composer install

1.00 2014-2-12
First Release
61 changes: 61 additions & 0 deletions FraudLabsPro.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ public function fraudCheck($returnAs = 'string'){
$params .= '&format=json';
}

if (!is_null($this->flpRequest->firstName)){
$params .= '&first_name=' . rawurlencode($this->flpRequest->firstName);
}

if (!is_null($this->flpRequest->lastName)){
$params .= '&bill_city=' . rawurlencode($this->flpRequest->lastName);
}


if (!is_null($this->flpRequest->billingCity)){
$params .= '&bill_city=' . rawurlencode($this->flpRequest->billingCity);
}
Expand Down Expand Up @@ -127,6 +136,7 @@ public function fraudCheck($returnAs = 'string'){

//Prepare the email adomain and hash for checking
$params .= '&email_domain=' . rawurlencode(substr($this->flpRequest->emailAddress, strpos($this->flpRequest->emailAddress, '@')+1));
$params .= '&email=' . rawurlencode($this->flpRequest->emailAddress);
$params .= '&email_hash=' . rawurlencode($this->doHash($this->flpRequest->emailAddress));
}

Expand Down Expand Up @@ -192,6 +202,10 @@ public function fraudCheck($returnAs = 'string'){
if (!is_null($this->flpRequest->sessionId)){
$params .= '&session_id=' . rawurlencode($this->flpRequest->sessionId);
}

if (!is_null($this->flpRequest->flpChecksum)){
$params .= '&flp_checksum=' . rawurlencode($this->flpRequest->flpChecksum);
}

//Perform fraud check (3 tries on fails)
$retry = 0;
Expand Down Expand Up @@ -222,7 +236,47 @@ public function fraudCheck($returnAs = 'string'){
return $result;
}
}

///////////////////////////////////////
// Purpose: feedback the order status
// Input:
// transactionID - transaction ID
// action - APPROVE, REJECT
// returnAs: json - return json result
// xml - return xml result
//
// Output:
// Depend on the returnAs param
///////////////////////////////////////
public function feedbackOrder($transactionID, $action, $returnAs = 'json'){
// Perform validation (where applicable) and construct the REST queries
$params = 'key=' . $this->apiKey;
$params .= '&id=' . rawurlencode($transactionID);

if (in_array($action, array('APPROVE', 'REJECT'))){
$params .= '&action=' . $action;
}
else
return NULL;

if (in_array($returnAs, array('json', 'xml'))){
$params .= '&format=' . $returnAs;
}
else
return NULL;

//Perform fraud check (3 tries on fails)
$retry = 0;
while($retry++ < 3){
$result = $this->http('https://api.fraudlabspro.com/v1/order/feedback?' . $params);
if($result) break;
sleep(2);
}

//Return value to caller
return $result;
}

// List of ISO-3166 country codes for validation before sent
private function isCountryCode($cc){
if(!$cc) return false;
Expand Down Expand Up @@ -297,6 +351,10 @@ class Flp_Request{
public $department = NULL;
public $paymentMode = NULL;
public $sessionId = NULL;
public $lastName = NULL;
public $firstName = NULL;
public $flpChecksum = NULL;


//Reset the variables
public function reset(){
Expand Down Expand Up @@ -326,6 +384,9 @@ public function reset(){
$this->department = NULL;
$this->paymentMode = NULL;
$this->sessionId = NULL;
$this->lastName = NULL;
$this->firstName = NULL;
$this->flpChecksum = NULL;
}
}

Expand Down
18 changes: 18 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "chrislim2888/fraudlabspro",
"description": "Fraud Prevention API to screen order transaction for online fraud. It helps to minimize fraud losses.",
"keywords": ["fraudlabs", "fraudlabspro", "fraud", "fraud detection", "fraud prevention"],
"homepage": "http://www.fraudlabspro.com",
"type": "library",
"license": "LGPLv3",
"autoload": {
"classmap": ["FraudLabsPro.class.php"]
},
"authors": [
{
"name": "FraudLabs Pro",
"email": "support@fraudlabspro.com",
"homepage": "http://www.fraudlabspro.com"
}
]
}

0 comments on commit 0473ffe

Please sign in to comment.