Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| v:2.0:fighting-fraud [2017/07/20 12:09] – [Pre-Checkout Hooks] adam | v:2.0:fighting-fraud [2021/06/09 08:47] (current) – [Extra Setup if you're using a Custom Subdomain] adam | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Fraud Prevention in FoxyCart ====== | ====== Fraud Prevention in FoxyCart ====== | ||
| + | |||
| + | ===== Foxy's Internal Abuse Prevention ===== | ||
| + | |||
| + | In addition to the options below, we have some systems in place to block more " | ||
| ===== minFraud in Foxy ===== | ===== minFraud in Foxy ===== | ||
| Line 5: | Line 9: | ||
| ==== What to do with it? ==== | ==== What to do with it? ==== | ||
| - | You can enable minFraud in the " | + | You can enable minFraud in the " |
| Though every store and customer base will have different riskScore averages, MaxMind' | Though every store and customer base will have different riskScore averages, MaxMind' | ||
| Line 37: | Line 41: | ||
| Foxy's [[https:// | Foxy's [[https:// | ||
| - | Foxy defaults to reCAPTCHA being off, but has 2 different options: | + | The setting is shown within the “Anti-Fraud Integrations” section, displayed within the “Let customers pay with a Credit or Debit Card” payment option when enabled. |
| - | - **Enabled, Always.** As it sounds, this will include | + | <WRAP center round info 95%> |
| - | - **Enabled, Automatically as Needed.** This will require reCAPTCHA for checkouts loaded by IP addresses that have triggered multiple errors in a preceding window of time. We attempt to set this so it would //very// rarely be shown to a legitimate customer, but would effectively make bot-based bulk fraud impossible. We don' | + | If you're using a payment option which is configured outside of the "Let customers pay with a Credit or Debit Card" option, to enable Google reCAPTCHA you'll need to currently enable the "Let customers pay with a Credit or Debit Card" option, set your reCAPTCHA |
| + | </ | ||
| - | Note that reCAPTCHA | + | Foxy defaults to reCAPTCHA |
| - | ===== Pre-Checkout Hooks ===== | + | |
| + | - **Enabled, Always**: As it sounds, this will include reCAPTCHA on every checkout. | ||
| + | - **Enabled, Automatically as Needed**: This will require reCAPTCHA only in specific situations when our systems have cause to believe your store needs extra protection. We do not reveal specific behavior here, but broadly: If we detect behavior that makes us think a bot (or botnet) is pushing transactions through without a real human behind it, we will enable reCAPTCHA either for specific IPs or for //all checkout attempts//. We attempt to set this so it would //very// rarely be shown to a legitimate customer, but would effectively make bot-based bulk fraud impossible. | ||
| - | The Pre-Checkout Hook functionality allows for stores to apply custom validations for transactions prior to the request being set to the chosen payment method. A payload containing information about the current transaction is sent to the endpoint configured for this functionality, | + | Note that reCAPTCHA isn't required for API-based or [[.: |
| - | Common use cases for the pre-checkout hook include: | + | ==== Extra Setup if you're using a Custom Subdomain ==== |
| - | * Final inventory checks for low-stock or one-of-a-kind products | + | If you're using a [[.: |
| - | * Custom validations | + | |
| - | | + | |
| - | ==== Enabling the Pre-Checkout Hook ==== | + | |
| - | + | - Enter a label that' | |
| - | To enable the pre-checkout hook, head to the " | + | - Select |
| - | + | | |
| - | | + | - It should be successful, and take you to a page with your Site Key and Secret Key. |
| - | : The URL for the endpoint script, which needs to be HTTPS, which will receive | + | - Copy those two keys into the "payment" |
| - | | + | - Save the payment settings in the FoxyCart admin. |
| - | : If your endpoint script fails to load or respond correctly, use this setting to set whether | + | - Do some test transactions, if you'd like. (You can set the reCAPTCHA setting |
| - | + | ||
| - | + | ||
| - | ==== Handling the request ==== | + | |
| - | + | ||
| - | When the customer attempts to complete their purchase, after the Google reCAPTCHA is validated (if active), a POST request is sent off to your custom post-checkout hook endpoint with a JSON payload representing the current cart. It follows the same structure as our [[https:// | + | |
| - | + | ||
| - | The following is an example of the JSON payload, showing two products | + | |
| - | + | ||
| - | <code javascript> | + | |
| - | { | + | |
| - | " | + | |
| - | }, | + | |
| - | " | + | |
| - | " | + | |
| - | { | + | |
| - | " | + | |
| - | }, | + | |
| - | " | + | |
| - | " | + | |
| - | { | + | |
| - | " | + | |
| - | }, | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | }, | + | |
| - | { | + | |
| - | " | + | |
| - | }, | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | } | + | |
| - | ], | + | |
| - | " | + | |
| - | " | + | |
| - | }, | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | } | + | |
| - | }, | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | }, | + | |
| - | { | + | |
| - | | + | |
| - | }, | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | }, | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | } | + | |
| - | }, | + | |
| - | " | + | |
| - | | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | } | + | |
| - | ], | + | |
| - | " | + | |
| - | { | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | } | + | |
| - | ], | + | |
| - | " | + | |
| - | { | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | }], | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | }, | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | { | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | } | + | |
| - | ], | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | } | + | |
| - | } | + | |
| - | } | + | |
| - | }, | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | } | + | |
| - | </ | + | |
| - | + | ||
| - | === Notes === | + | |
| - | + | ||
| - | * The payload includes several _links arrays. These contain helpful URI's that could be used through the Hypermedia API if you're also making use of that. If not, these can be safely ignored. | + | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | ==== Sending a response ==== | + | |
| - | + | ||
| - | In response, FoxyCart expects a JSON payload | + | |
| - | + | ||
| - | === Approve === | + | |
| - | + | ||
| - | <code javascript> | + | |
| - | { | + | |
| - | | + | |
| - | | + | |
| - | } | + | |
| - | </ | + | |
| - | + | ||
| - | === Reject === | + | |
| - | + | ||
| - | <code javascript> | + | |
| - | { | + | |
| - | " | + | |
| - | " | + | |
| - | } | + | |
| - | </ | + | |
| - | + | ||
| - | {{ : | + | |
| - | + | ||
| - | <WRAP center round important 90%> | + | |
| - | Only a valid JSON object | + | |
| - | </ | + | |
| - | ==== Example Endpoint | + | ===== FraudLabs Pro ===== |
| - | The following is an example PHP endpoint that could be used to handle the pre-checkout hook: | + | [[https:// |
| + | * [[https:// | ||
| - | <code php> | + | ===== Pre-Payment Webhook ===== |
| - | <?php | + | |
| - | $rawPost | + | |
| - | $cart_details | + | |
| - | $response = array( | + | The [[pre_payment_webhook|pre-payment web hook]] can be used for custom anti-fraud integrations. |
| - | ' | + | |
| - | ' | + | |
| - | ); | + | |
| - | foreach($cart_details[' | + | * [[https:// |
| - | | + | |
| - | $response[' | + | |
| - | $response[' | + | |
| - | } | + | |
| - | } | + | |
| - | header(' | ||
| - | print json_encode($response); | ||
| - | </ | ||