/** * verify if a transaction is fraudulent * @return boolean */ public function is_fraud() { //only production and api set if ($this->loaded() and core::config('payment.fraudlabspro') != '') { //get the country $country_code = i18n::ip_country_code(); // Include FraudLabs Pro library require Kohana::find_file('vendor/', 'FraudLabsPro.class'); $fraud = new FraudLabsPro(core::config('payment.fraudlabspro')); try { // Check this transaction for possible fraud. FraudLabs Pro support comprehensive validation check, // and for this example, we only perform the IP address, BIN and billing country validation. // For complete validation, please check our developer page at http://www.fraudlabspro.com/developer $fraud_result = $fraud->check(array('ipAddress' => Request::$client_ip, 'billingCountry' => $country_code, 'quantity' => 1, 'amount' => $this->amount, 'currency' => $this->currency, 'emailAddress' => $this->user->email, 'paymentMode' => 'others', 'sessionId' => session_id())); $fraud_result_status = $fraud_result->fraudlabspro_status; } catch (Exception $e) { $fraud_result_status = 'DECLINED'; } // This transaction is legitimate, let's submit to Stripe if ($fraud_result_status == 'APPROVE') { return FALSE; } else { Kohana::$log->add(Log::ERROR, 'Fraud detected id_order:' . $this->id_order); return TRUE; } } //by default we say is not fraud return FALSE; }
<?php /******************************* * Example to do a fraud check for a credit card sales order * *******************************/ require 'FraudLabsPro.class.php'; /////////////////////////////// // Create FraudLabs Pro object // Note: You need to enter the API key during the instantiation // If you do not have the api key, register it free at http://www.fraudlabspro.com $flp = new FraudLabsPro('<API_KEY>'); ///////////////////////////////////////////////// // Enter sales order information for fraud check // For example: // Ship item to US, bill to MY, pay with credit card // Amount: $123.00 for 1 item $flp->flpRequest->billingCity = 'Bayan Lepas'; $flp->flpRequest->billingZIPCode = '11950'; $flp->flpRequest->billingState = 'Bayan Lepas'; $flp->flpRequest->billingCountry = 'MY'; $flp->flpRequest->shippingAddress = '12, street address'; $flp->flpRequest->shippingCity = 'NY'; $flp->flpRequest->shippingZIPCode = '00001'; $flp->flpRequest->shippingState = 'NY'; $flp->flpRequest->shippingCountry = 'US'; $flp->flpRequest->emailAddress = '*****@*****.**'; $flp->flpRequest->creditCardNumber = '1111111111111111'; $flp->flpRequest->bankName = 'BANKNAME'; $flp->flpRequest->orderId = 'order123'; $flp->flpRequest->amount = 123.0;