Skip to content

Instantly share code, notes, and snippets.

@w3guy
Forked from craigchristenson/gist:2869509
Created December 30, 2015 08:06
Show Gist options
  • Save w3guy/d717de3b12487a2c8399 to your computer and use it in GitHub Desktop.
Save w3guy/d717de3b12487a2c8399 to your computer and use it in GitHub Desktop.
Example PHP script to check fraud status on a sale.
<?php
if ($_POST['message_type'] == 'FRAUD_STATUS_CHANGED') {
$insMessage = array();
foreach ($_POST as $k => $v) {
$insMessage[$k] = $v;
}
$hashSecretWord = "tango"; # Input your secret word
$hashSid = 1303908; #Input your seller ID (2Checkout account number)
$hashOrder = $insMessage['sale_id'];
$hashInvoice = $insMessage['invoice_id'];
$StringToHash = strtoupper(md5($hashOrder . $hashSid . $hashInvoice . $hashSecretWord));
if ($StringToHash != $insMessage['md5_hash']) {
die('Hash Incorrect');
}
switch ($insMessage['fraud_status']) {
case 'pass':
# Do something when sale passes fraud review.
break;
case 'fail':
# Do something when sale fails fraud review.
break;
case 'wait':
# Do something when sale requires additional fraud review.
break;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment