src
5 years ago
tests
5 years ago
LICENSE
5 years ago
README.md
5 years ago
composer.json
5 years ago
example.php
5 years ago
phpunit.xml
5 years ago
README.md
257 lines
| 1 | FraudLabs Pro PHP SDK |
| 2 | ======================== |
| 3 | This PHP module enables user to easily implement fraud detection feature into their solution using the API from https://www.fraudlabspro.com. |
| 4 | |
| 5 | Below are the features of this PHP module: |
| 6 | - Fraud analysis and scoring |
| 7 | - IP address geolocation & proxy validation |
| 8 | - Email address validation |
| 9 | - Credit card issuing bank validation |
| 10 | - Transaction velocity validation |
| 11 | - Device transaction validation |
| 12 | - Blacklist validation |
| 13 | - Custom rules trigger |
| 14 | - Email notification of fraud orders |
| 15 | - Mobile app notification of fraud orders |
| 16 | |
| 17 | This module requires API key to function. You may subscribe a free API key at https://www.fraudlabspro.com |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | Usage Example |
| 23 | ============ |
| 24 | ### Validate Order |
| 25 | |
| 26 | #### Object Properties |
| 27 | |
| 28 | | Property Name | Property Type | Description | |
| 29 | | --------------------------------- | ------------- | ------------------------------------------------------------ | |
| 30 | | ip | string | IP address of online transaction. It supports both IPv4 and IPv6 address format. | |
| 31 | | billing->firstName | string | User's first name. | |
| 32 | | billing->lastName | string | User's last name. | |
| 33 | | billing->username | string | User's username. | |
| 34 | | billing->password | string | User's password. | |
| 35 | | billing->email | string | User's email address. | |
| 36 | | billing->phone | string | User's phone number. | |
| 37 | | billing->address | string | Street address of billing address. | |
| 38 | | billing->city | string | City of billing address. | |
| 39 | | billing->state | string | State of billing address. It supports state codes, e.g. NY (New York), for state or province of United States or Canada. Please refer to [](https://www.fraudlabspro.com/developer/reference/state-and-province-codesState & Province Codes](https://www.fraudlabspro.com/developer/reference/state-and-province-codes](https://www.fraudlabspro.com/developer/reference/state-and-province-codes) for complete list. | |
| 40 | | billing->postcode | string | Postal or ZIP code of billing address. | |
| 41 | | billing->country | string | Country of billing address. It requires the input of ISO-3166 alpha-2 country code, e.g. US for United States. Please refer to [](https://www.fraudlabspro.com/developer/reference/country-codesCountry Codes](https://www.fraudlabspro.com/developer/reference/country-codes](https://www.fraudlabspro.com/developer/reference/country-codes) for complete list. | |
| 42 | | order->orderId | string | Merchant identifier to uniquely identify a transaction. It supports maximum of 15 characters user order id input. | |
| 43 | | order->note | string | Merchant description of an order transaction. It supports maximum of 200 characters. | |
| 44 | | order->amount | float | Amount of the transaction. | |
| 45 | | order->quantity | integer | Total quantity of the transaction. | |
| 46 | | order->currency | string | Currency code used in the transaction. It requires the input of ISO-4217 (3 characters) currency code, e.g. USD for US Dollar. Please refer to [](https://www.fraudlabspro.com/developer/reference/currency-codesCurrency Codes](https://www.fraudlabspro.com/developer/reference/currency-codes](https://www.fraudlabspro.com/developer/reference/currency-codes) for complete list. | |
| 47 | | order->department | string | Merchant identifier to uniquely identify a product or service department. | |
| 48 | | order->paymentMethod | string | Payment mode of transaction. Please see references section. | |
| 49 | | card->number | string | Billing credit card number or BIN number. | |
| 50 | | card->avs | string | The single character AVS result returned by the credit card processor. Please refer to [](https://www.fraudlabspro.com/developer/reference/avs-and-cvv2-response-codesAVS & CVV2 Response Codes](https://www.fraudlabspro.com/developer/reference/avs-and-cvv2-response-codes](https://www.fraudlabspro.com/developer/reference/avs-and-cvv2-response-codes) for details. | |
| 51 | | card->cvv | string | The single character CVV2 result returned by the credit card processor. Please refer to [](https://www.fraudlabspro.com/developer/reference/avs-and-cvv2-response-codesAVS & CVV2 Response Codes](https://www.fraudlabspro.com/developer/reference/avs-and-cvv2-response-codes](https://www.fraudlabspro.com/developer/reference/avs-and-cvv2-response-codes) for details. | |
| 52 | | shipping->address | string | Street address of shipping address. | |
| 53 | | shipping->city | string | City of shipping address. | |
| 54 | | shipping->state | string | State of shipping address. It supports state codes, e.g. NY - New York, for state or province of United States or Canada. Please refer to [](https://www.fraudlabspro.com/developer/reference/state-and-province-codesState & Province Codes](https://www.fraudlabspro.com/developer/reference/state-and-province-codes](https://www.fraudlabspro.com/developer/reference/state-and-province-codes) for complete list. | |
| 55 | | shipping->postcode | string | Postal or ZIP code of shipping address. | |
| 56 | | shipping->country | string | Country of shipping address. It requires the input of ISO-3166 alpha-2 country code, e.g. US for United States. Please refer to [](https://www.fraudlabspro.com/developer/reference/country-codesCountry Codes](https://www.fraudlabspro.com/developer/reference/country-codes](https://www.fraudlabspro.com/developer/reference/country-codes) for complete list. | |
| 57 | |
| 58 | |
| 59 | ``` |
| 60 | <?php |
| 61 | require_once __DIR__.'/vendor/autoload.php'; |
| 62 | |
| 63 | // Configures FraudLabs Pro API key |
| 64 | $config = new FraudLabsPro\Configuration('YOUR_API_KEY'); |
| 65 | $fraudlabspro = new FraudLabsPro\FraudValidation($config); |
| 66 | |
| 67 | // Order details |
| 68 | $orderDetails = [ |
| 69 | // IP parameter is optional, this library can detects IP address automatically |
| 70 | 'ip' => '146.112.62.105', |
| 71 | |
| 72 | 'order' => [ |
| 73 | 'orderId' => '67398', |
| 74 | 'note' => 'Online shop', |
| 75 | 'currency' => 'USD', |
| 76 | 'amount' => '79.89', |
| 77 | 'quantity' => 1, |
| 78 | |
| 79 | // Please refer reference section for full list of payment methods |
| 80 | 'paymentMethod' => FraudLabsPro\FraudValidation::CREDIT_CARD, |
| 81 | ], |
| 82 | |
| 83 | 'card' => [ |
| 84 | 'number' => '4556553172971283', |
| 85 | ], |
| 86 | |
| 87 | 'billing' => [ |
| 88 | 'firstName' => 'Hector', |
| 89 | 'lastName' => 'Henderson', |
| 90 | 'email' => 'hh5566@gmail.com', |
| 91 | 'phone' => '561-628-8674', |
| 92 | |
| 93 | 'address' => '1766 Powder House Road', |
| 94 | 'city' => 'West Palm Beach', |
| 95 | 'state' => 'FL', |
| 96 | 'postcode' => '33401', |
| 97 | 'country' => 'US', |
| 98 | ], |
| 99 | |
| 100 | 'shipping' => [ |
| 101 | 'address' => '4469 Chestnut Street', |
| 102 | 'city' => 'Tampa', |
| 103 | 'state' => 'FL', |
| 104 | 'postcode' => '33602', |
| 105 | 'country' => 'US', |
| 106 | ], |
| 107 | ]; |
| 108 | |
| 109 | // Sends the order details to FraudLabs Pro |
| 110 | $result = $fraudlabspro->validate($orderDetails); |
| 111 | ``` |
| 112 | |
| 113 | |
| 114 | |
| 115 | ### Get Transaction |
| 116 | |
| 117 | #### Parameter Properties |
| 118 | |
| 119 | | Parameter Name | Parameter Type | Description | |
| 120 | | -------------- | -------------- | ------------------------------------------------------------ | |
| 121 | | $id | string | FraudLabs Pro transaction ID or Order ID. | |
| 122 | | $type | string | ID type. Either: **FraudLabsPro\FraudValidation::FLP_ID** or **FraudLabsPro\FraudValidation::ORDER_ID** | |
| 123 | |
| 124 | ``` |
| 125 | <?php |
| 126 | require_once __DIR__.'/vendor/autoload.php'; |
| 127 | |
| 128 | // Configures FraudLabs Pro API key |
| 129 | $config = new FraudLabsPro\Configuration('YOUR_API_KEY'); |
| 130 | $fraudlabspro = new FraudLabsPro\FraudValidation($config); |
| 131 | |
| 132 | $result = $fraudlabspro->getTransaction('20170906MXFHSTRF', FraudLabsPro\FraudValidation::FLP_ID); |
| 133 | ``` |
| 134 | |
| 135 | |
| 136 | |
| 137 | ### Feedback |
| 138 | |
| 139 | #### Object Properties |
| 140 | |
| 141 | | Property Name | Property Type | Description | |
| 142 | | ------------- | ------------- | ------------------------------------------------------------ | |
| 143 | | id | string | Unique transaction ID generated from **Validate** function. | |
| 144 | | status | string | Perform APPROVE, REJECT, or REJECT_BLACKLIST action to transaction. Refer to [](#feedback-statusreference section](#feedback-status](#feedback-status) for status code. | |
| 145 | | note | string | Notes for the feedback request. | |
| 146 | |
| 147 | ``` |
| 148 | <?php |
| 149 | require_once __DIR__.'/vendor/autoload.php'; |
| 150 | |
| 151 | // Configures FraudLabs Pro API key |
| 152 | $config = new FraudLabsPro\Configuration('YOUR_API_KEY'); |
| 153 | $fraudlabspro = new FraudLabsPro\FraudValidation($config); |
| 154 | |
| 155 | $fraudlabspro->feedback([ |
| 156 | 'id' => '20170906MXFHSTRF', |
| 157 | // Please refer to reference section for full list of feedback statuses |
| 158 | 'status' => FraudLabsPro\FraudValidation::APPROVE, |
| 159 | 'note' => 'This customer made a valid purchase before.', |
| 160 | ]); |
| 161 | |
| 162 | ``` |
| 163 | |
| 164 | |
| 165 | |
| 166 | |
| 167 | ## SMS Verification |
| 168 | |
| 169 | ### Send SMS Verification |
| 170 | |
| 171 | #### Object Properties |
| 172 | |
| 173 | | Property Name | Property Type | Description | |
| 174 | | ------------- | :-----------: | ------------------------------------------------------------ | |
| 175 | | tel | string | The recipient mobile phone number in E164 format which is a plus followed by just numbers with no spaces or parentheses. | |
| 176 | | mesg | string | The message template for the SMS. Add <otp> as placeholder for the actual OTP to be generated. Max length is 140 characters. | |
| 177 | | otp_timeout | integer | Timeout feature for OTP value in seconds. Default is 3600 seconds(1 hour). Max timeout is 86400 seconds(24 hours). | |
| 178 | | country_code | string | ISO 3166 country code for the recipient mobile phone number. If parameter is supplied, then some basic telephone number validation is done. | |
| 179 | |
| 180 | ``` |
| 181 | <?php |
| 182 | require_once __DIR__.'/vendor/autoload.php'; |
| 183 | |
| 184 | // Configures FraudLabs Pro API key |
| 185 | $config = new FraudLabsPro\Configuration('YOUR_API_KEY'); |
| 186 | $fraudlabsproSms = new \FraudLabsPro\SmsVerification($config); |
| 187 | |
| 188 | // Send SMS Verification |
| 189 | $fraudlabsproSms->sendSms([ |
| 190 | 'tel' => '+123456789', |
| 191 | 'mesg' => 'Hi, your OTP is <otp>.', |
| 192 | 'otp_timeout' => 3600, |
| 193 | 'country_code' => 'US', |
| 194 | ]); |
| 195 | ``` |
| 196 | |
| 197 | |
| 198 | |
| 199 | ### Get SMS Verification Result |
| 200 | |
| 201 | #### Object Properties |
| 202 | |
| 203 | | Property Name | Property Type | Description | |
| 204 | | ------------- | :-----------: | ------------------------------------------------------------ | |
| 205 | | tran_id | string | The unique ID that was returned by the Send SMS Verification that triggered the OTP sms. | |
| 206 | | otp | string | The OTP that was sent to the recipient’s phone. | |
| 207 | |
| 208 | ``` |
| 209 | <?php |
| 210 | require_once __DIR__.'/vendor/autoload.php'; |
| 211 | |
| 212 | // Configures FraudLabs Pro API key |
| 213 | $config = new FraudLabsPro\Configuration('YOUR_API_KEY'); |
| 214 | $fraudlabsproSms = new \FraudLabsPro\SmsVerification($config); |
| 215 | |
| 216 | // Get SMS Verification result |
| 217 | $fraudlabsproSms->verifyOtp([ |
| 218 | 'tran_id' => 'UNIQUE_TRANS_ID', |
| 219 | 'otp' => 'OTP_RECEIVED', |
| 220 | ]); |
| 221 | ``` |
| 222 | |
| 223 | |
| 224 | |
| 225 | # Reference |
| 226 | |
| 227 | #### Payment Method |
| 228 | |
| 229 | | Payment Method | |
| 230 | | ------------------------------------ | |
| 231 | | FraudLabsPro\FraudValidation::CREDIT_CARD | |
| 232 | | FraudLabsPro\FraudValidation::PAYPAL | |
| 233 | | FraudLabsPro\FraudValidation::GOOGLE_CHECKOUT | |
| 234 | | FraudLabsPro\FraudValidation::CASH_ON_DELIVERY | |
| 235 | | FraudLabsPro\FraudValidation::MONEY_ORDER | |
| 236 | | FraudLabsPro\FraudValidation::WIRE_TRANSFER | |
| 237 | | FraudLabsPro\FraudValidation::BANK_DEPOSIT | |
| 238 | | FraudLabsPro\FraudValidation::BITCOIN | |
| 239 | | FraudLabsPro\FraudValidation::OTHERS | |
| 240 | |
| 241 | |
| 242 | |
| 243 | #### Feedback Status |
| 244 | |
| 245 | | Feedback Status | Description | |
| 246 | | ------------------------------------ | ------------------------------------------- | |
| 247 | | FraudLabsPro\FraudValidation::APPROVE | Approves an order that under review status. | |
| 248 | | FraudLabsPro\FraudValidation::REJECT | Rejects an order than under review status. | |
| 249 | | FraudLabsPro\FraudValidation::REJECT_BLACKLIST | Rejects and blacklists an order. | |
| 250 | |
| 251 | |
| 252 | |
| 253 | |
| 254 | LICENCE |
| 255 | ===================== |
| 256 | See the LICENSE file. |
| 257 |