{"id":3503,"date":"2021-03-10T16:31:39","date_gmt":"2021-03-10T16:31:39","guid":{"rendered":"https:\/\/documents.openpay.mx\/?p=3503"},"modified":"2022-02-18T16:29:49","modified_gmt":"2022-02-18T16:29:49","slug":"fraud-tool","status":"publish","type":"post","link":"https:\/\/documents-mx-dev.opdevhm.com\/en\/docs\/fraud-tool.html","title":{"rendered":"Anti-Fraud"},"content":{"rendered":"
What is the anti fraud tool?<\/strong><\/p> It is the tool that Openpay provides for the prevention of fraud in card charges and it\u2019s provided to all businesses registered on Openpay through the implementation of the openpay-data.js library with no extra charges.<\/p> How it works?<\/strong><\/p> Once the openpay-data.js library or the android \/ iOS library is implemented on your website, each card transaction will be run some rules to determine if the transaction is fraudulent or legitimate. The entire process is performed within milliseconds, making it almost invisible to your customers.<\/p> The advanced set of rules that filters the transactions verify several factors including the credit \/ debit number, card address, email and device information used on the transaction.<\/p> How do I start using it?<\/strong><\/p> If the transactions are made from a web page, the anti-fraud tool must be implemented using a JavaScript library. If the transactions are from a mobile device you can use our SDKs to implement it.<\/p> What does the API responds when a transaction is marked as fraudulent?<\/strong><\/p> In this case the API will respond an error object with the following data:<\/p> Response:<\/strong><\/p> See the error page for more information on the format of the error object.<\/em><\/span><\/p> What can I do if I want that a transaction marked as fraudulent to be approved?<\/strong><\/p> There\u2019s no other choice but to tell the client to retry the payment with another card.<\/p> 1.- Load and setup<\/strong><\/p> The library is loaded and the value for device_session_id is initialized with the following code:<\/p> Note:<\/strong><\/span> openpay-data.js depends on the openpay.js library. Watch to run the setSandboxMode() method from the openpay.js library first and the method setup after.<\/em><\/span><\/p> Parameter Parameter Another way to handle the 2.- Server side handling<\/strong><\/p> Every time someone comes to your page or website, the data will be collected directly from the device accessing it and the Once the data has been received by your server, send the \u00a0<\/p> To see a complete example on how to make a charge, please check the Charges Tutorial.<\/p>{<\/span>\n \"category\"<\/span>:<\/span> \"gateway\"<\/span>,<\/span>\n \"description\"<\/span>:<\/span> \"The card was declined by fraud system\"<\/span>,<\/span>\n \"http_code\"<\/span>:<\/span> 402<\/span>,<\/span>\n \"error_code\"<\/span>:<\/span> 3005<\/span>,<\/span>\n \"request_id\"<\/span>:<\/span> \"4fc452d8-5ddc-4464-ae70-e03569622850\"<\/span>\n}<\/span><\/code><\/pre><\/figure>
Javascript implementation.<\/h2>
<<\/span>script <\/span>type<\/span>=<\/span>'text\/javascript'<\/span> src<\/span>=<\/span>\"https:\/\/js.openpay.mx\/openpay-data.v1.min.js\"<\/span>><\/<\/span><\/span>script<\/span>><\/span>\n<<\/span>script <\/span>type<\/span>=<\/span>\"text\/javascript\"<\/span>><\/span>\n var<\/span> deviceSessionId<\/span> =<\/span> OpenPay<\/span>.<\/span>deviceData<\/span>.<\/span>setup<\/span>(<\/span>\"formId\"<\/span>,<\/span> \"deviceIdHiddenFieldName\"<\/span>);<\/span>\n<\/<\/span><\/span>script<\/span>><\/span><\/code><\/pre><\/figure>
formId<\/span><\/code><\/span>, must store the form id which contains charge information to send. Say to he library this form contains the hidden field with the
device_session_id<\/span><\/code>.<\/p>
deviceIdHiddenFieldName<\/span><\/code><\/span>, needs the hidden field name than will store
device_session_id<\/span><\/code><\/span>. This field is important if you will need to recover the fiel value then send it with submit action.<\/p>
device_session_id<\/span><\/code> value is to store it in a variable and then attach it to an ajax request. This is a manual process:<\/p>
<<\/span>script <\/span>type<\/span>=<\/span>'text\/javascript'<\/span> src<\/span>=<\/span>\"https:\/\/js.openpay.mx\/openpay-data.v1.min.js\"<\/span>><\/<\/span><\/span>script<\/span>><\/span>\n<<\/span>script <\/span>type<\/span>=<\/span>\"text\/javascript\"<\/span>><\/span>\n var<\/span> deviceSessionId<\/span> =<\/span> OpenPay<\/span>.<\/span>deviceData<\/span>.<\/span>setup<\/span>();<\/span>\n<\/<\/span><\/span>script<\/span>><\/span><\/code><\/pre><\/figure>
device_session_id<\/span><\/code>will be generated. Once your customer makes the charge to the card, be sure of sending the
device_session_id<\/span><\/code>.<\/p>
device_session_id<\/span><\/code> to the openpay servers as part of the request, see example below:<\/p>
'method'<\/span> =><\/span> 'card'<\/span>,\n<\/span> 'source_id'<\/span> =><\/span> $POST<\/em><\/span>[<\/span>\"source_id\"<\/span>],\n<\/span> 'amount'<\/span> =><\/span> (<\/span>float<\/span>)<\/span>$<\/span><\/em>POST[<\/span>\"amount\"<\/span>],\n<\/span> 'description'<\/span> =><\/span> $POST<\/em><\/span>[<\/span>\"description\"<\/span>],\n<\/span> 'order_id'<\/span> =><\/span> 'ORDEN-00071'<\/span>,\n<\/span> 'device_session_id'<\/span> =><\/span> $<\/span><\/em>POST[<\/span>\"deviceIdHiddenFieldName\"<\/span>]\n<\/span> );<\/span><\/code><\/pre>
$charge<\/span><\/span> =<\/span> $openpay<\/span>-><\/span>charges<\/span>-><\/span>create<\/span>(<\/span>$chargeData<\/span>);<\/span>\n?><\/span><\/code><\/code><\/pre><\/figure>
Android Implementation<\/h2>