|
| 1 | +# Quickstart |
| 2 | + |
| 3 | +## Dependencies |
| 4 | + |
| 5 | +This module requires API key to function. You may subscribe a free API key at [https://www.fraudlabspro.com](https://www.fraudlabspro.com) |
| 6 | + |
| 7 | +## Installation |
| 8 | + |
| 9 | +To use this module in your Java project, please visit [https://central.sonatype.com/artifact/com.fraudlabspro/fraudlabspro-java](https://central.sonatype.com/artifact/com.fraudlabspro/fraudlabspro-java) to copy the corrensponding code to your building tool. |
| 10 | + |
| 11 | +## Sample Codes |
| 12 | + |
| 13 | +### Validate Order |
| 14 | + |
| 15 | +You can validate your order as below: |
| 16 | + |
| 17 | +```java |
| 18 | +import com.fraudlabspro.*; |
| 19 | +import java.util.Hashtable; |
| 20 | + |
| 21 | +public class Main { |
| 22 | + |
| 23 | + public static void main(String[] args) { |
| 24 | + // Configures FraudLabs Pro API key |
| 25 | + FraudLabsPro.APIKEY = "YOUR_API_KEY"; |
| 26 | + |
| 27 | + // Screen Order API |
| 28 | + Order order = new Order(); |
| 29 | + |
| 30 | + // Sets order details |
| 31 | + Hashtable<String, String> data = new Hashtable<>(); |
| 32 | + |
| 33 | + data.put("ip", "146.112.62.105"); // IP parameter is mandatory |
| 34 | + data.put("first_name", "Hector"); |
| 35 | + data.put("last_name", "Henderson"); |
| 36 | + data.put("email", "hh5566@gmail.com"); |
| 37 | + data.put("user_phone", "561-628-8674"); |
| 38 | + |
| 39 | + // Billing information |
| 40 | + data.put("bill_addr", "1766 PowderHouse Road"); |
| 41 | + data.put("bill_city", "West Palm Beach"); |
| 42 | + data.put("bill_state", "FL"); |
| 43 | + data.put("bill_country", "US"); |
| 44 | + data.put("bill_zip_code", "33401"); |
| 45 | + data.put("number", "4556553172971283"); |
| 46 | + |
| 47 | + // Order information |
| 48 | + data.put("user_order_id", "67398"); |
| 49 | + data.put("user_order_memo", "Online shop"); |
| 50 | + data.put("amount", "79.89"); |
| 51 | + data.put("quantity", "1"); |
| 52 | + data.put("currency", "USD"); |
| 53 | + data.put("payment_mode", order.CREDIT_CARD); // Please refer reference section for full list of payment methods |
| 54 | + |
| 55 | + // Shipping information |
| 56 | + data.put("ship_addr", "4469 Chestnut Street"); |
| 57 | + data.put("ship_city", "Tampa"); |
| 58 | + data.put("ship_state", "FL"); |
| 59 | + data.put("ship_zip_code", "33602"); |
| 60 | + data.put("ship_country", "US"); |
| 61 | + |
| 62 | + String result = order.validate(data); // Sends order details to FraudLabs Pro |
| 63 | + } |
| 64 | +} |
| 65 | +``` |
| 66 | + |
| 67 | +### Get Transaction |
| 68 | + |
| 69 | +You can get the details of a transaction as below: |
| 70 | + |
| 71 | +```java |
| 72 | +import com.fraudlabspro.*; |
| 73 | +import java.util.Hashtable; |
| 74 | + |
| 75 | +public class Main { |
| 76 | + |
| 77 | + public static void main(String[] args) { |
| 78 | + // Configures FraudLabs Pro API key |
| 79 | + FraudLabsPro.APIKEY = "YOUR_API_KEY"; |
| 80 | + |
| 81 | + // Get Order Result API |
| 82 | + Order orderResults = new Order(); |
| 83 | + |
| 84 | + // Sets order ID to return all available information regarding the order |
| 85 | + Hashtable<String, String> data = new Hashtable<>(); |
| 86 | + data.put("id", "20180709-NHAEUK"); |
| 87 | + data.put("id_type", orderResults.FLP_ID); |
| 88 | + |
| 89 | + String result = orderResults.getTransaction(data); // Obtains order results from FraudLabs Pro |
| 90 | + } |
| 91 | +} |
| 92 | +``` |
| 93 | + |
| 94 | +### Feedback |
| 95 | + |
| 96 | +You can approve, reject or ignore a transaction as below: |
| 97 | + |
| 98 | +```java |
| 99 | +import com.fraudlabspro.*; |
| 100 | +import java.util.Hashtable; |
| 101 | + |
| 102 | +public class Main { |
| 103 | + |
| 104 | + public static void main(String[] args) { |
| 105 | + // Configures FraudLabs Pro API key |
| 106 | + FraudLabsPro.APIKEY = "YOUR_API_KEY"; |
| 107 | + |
| 108 | + // Feedback Order API |
| 109 | + Order fb = new Order(); |
| 110 | + |
| 111 | + // Sets feedback details |
| 112 | + Hashtable<String, String> data = new Hashtable<>(); |
| 113 | + data.put("id", "20180709-NHAEUK"); |
| 114 | + data.put("action", fb.APPROVE); // Please refer to reference section for full list of feedback statuses |
| 115 | + data.put("note", "This customer made a valid purchase before."); |
| 116 | + |
| 117 | + String result = fb.feedback(data); // Sends feedback details to FraudLabs Pro |
| 118 | + } |
| 119 | +} |
| 120 | +``` |
| 121 | + |
| 122 | +### Send SMS Verification |
| 123 | + |
| 124 | +You can send SMS verification for authentication purpose as below: |
| 125 | + |
| 126 | +```java |
| 127 | +import com.fraudlabspro.*; |
| 128 | +import java.util.Hashtable; |
| 129 | + |
| 130 | +public class Main { |
| 131 | + |
| 132 | + public static void main(String[] args) { |
| 133 | + // Configures FraudLabs Pro API key |
| 134 | + FraudLabsPro.APIKEY = "YOUR_API_KEY"; |
| 135 | + |
| 136 | + // Send SMS Verification API |
| 137 | + SMSVerification sms = new SMSVerification(); |
| 138 | + |
| 139 | + // Sets SMS details for authentication purpose |
| 140 | + Hashtable<String, String> data = new Hashtable<>(); |
| 141 | + data.put("tel", "+123456789"); |
| 142 | + data.put("country_code", "US"); |
| 143 | + data.put("mesg", "Hi, your OTP is <otp>."); |
| 144 | + data.put("otp_timeout", 3600); |
| 145 | + |
| 146 | + String result = sms.sendSMS(data); |
| 147 | + } |
| 148 | +} |
| 149 | +``` |
| 150 | + |
| 151 | +### Get SMS Verification Result |
| 152 | + |
| 153 | +You can verify the OTP sent by Fraudlabs Pro SMS verification API as below: |
| 154 | + |
| 155 | +```java |
| 156 | +import com.fraudlabspro.*; |
| 157 | +import java.util.Hashtable; |
| 158 | + |
| 159 | +public class Main { |
| 160 | + |
| 161 | + public static void main(String[] args) { |
| 162 | + // Configures FraudLabs Pro API key |
| 163 | + FraudLabsPro.APIKEY = "YOUR_API_KEY"; |
| 164 | + |
| 165 | + // Get Verification Result API |
| 166 | + SMSVerification verification = new SMSVerification(); |
| 167 | + |
| 168 | + // Sets transaction ID and otp details for verification purpose |
| 169 | + Hashtable<String, String> data = new Hashtable<>(); |
| 170 | + data.put("tran_id", "UNIQUE_TRANS_ID"); |
| 171 | + data.put("otp", "OTP_RECEIVED"); |
| 172 | + |
| 173 | + String result = verification.verifySMS(data); |
| 174 | + } |
| 175 | +} |
| 176 | +``` |
0 commit comments