Skip to content

Instantly share code, notes, and snippets.

@craigchristenson
Created June 4, 2012 16:51
Show Gist options
  • Save craigchristenson/2869509 to your computer and use it in GitHub Desktop.
Save craigchristenson/2869509 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