📄 stormpay.php
字号:
<?
include "../ipn.class.php";
include "inc/sp.inc.php";
include "../../includes/inc.php";
/**
* iniate the class
*/
$checker = new SP_Validater($db);
$ipn = new ipn_class('SP');
$ipn->MD5AccountPassword=$checker->MD5AccountPassword;
$ipn->IPNVars='transaction_id|transaction_date|amount';
$ipn->TestMode=$checker->TestMode;
$ipn->EmailTo=$user->setting[adminemail];
$ipn->BindDB(&$db);
$Var=$ipn->RecieveData();
$result=$ipn->CheckDataIntegrity();
header("HTTP/1.1 202 Accepted");
/**
* Begin to check...
*/
if($result==false) $ipn->SetError('Hack attempted!');
$checker->LoadServer($ipn);
if($ipn->PayeeAccount!=($checker->GetPayeeAcount()))
{
$ipn->SetError('Error PayeeAccount!'.$ipn->PayeeAccount.':'.$checker->GetPayeeAcount());
}
if($ipn->Amount!=$checker->GetAmount()&&$ipn->PaymentType=='instant')
{
$ipn->SetError('Error Amount!'.$ipn->Amount.':'.$checker->GetAmount());
}
if($ipn->PaymentType=='subscriptions')
{
if($ipn->TrialAmount!=$checker->GetTrialAmount())
{
$ipn->SetError('Error TrialAmount!'.$ipn->TrialAmount.':'.$checker->GetTrialAmount());
}
if($ipn->TrialPeriod!=$checker->GetTrialPeriod())
{
$ipn->SetError('Error TrialPeriod!'.$ipn->TrialPeriod.':'.$checker->GetTrialPeriod());
}
if($ipn->SubsAmount!=$checker->GetSubsAmount())
{
$ipn->SetError('Error SubsAmount!'.$ipn->SubsAmount.':'.$checker->GetSubsAmount());
}
if($ipn->SubsPeriod!=$checker->GetSubsPeriod())
{
$ipn->SetError('Error SubsPeriod!'.$ipn->SubsPeriod.':'.$checker->GetSubsPeriod());
}
}
/**
* check the TXNID is unique
*/
$TXNID=$ipn->GetTXNID();
if(!$ipn->IsUniqueTXNID())
{
$ipn->SetError('Repeat Transaction ID:'.$TXNID);
$ipn->EmailErrors();
die;//stop to process
}
$ipn->EmailErrors();
if($ipn->Errors) exit;
/**
* record into database!
*/
$ipn->RecordIPN();
$STATUS=$ipn->GetVar('status');
//============================
// Switch by transaction type
//============================
switch ($STATUS) {
//------------------------------------------------------
// Get the product info - either single-product or cart
//------------------------------------------------------
case 'TEST':
//if this is live mode,jump the SUCCESS process!
if($checker->TestMode==0) break;
case 'SUCCESS':
$item_info = array();
if($ipn->GetVar('distinct_item_count') <= 0) {
$checker->ProcessPayment($ipn);
}
//----------------------------------------------------------------------------------------------------
// Cart contents is a set of "item_info1" .. to "item_infoN" variables where N = $distinct_item_count
//----------------------------------------------------------------------------------------------------
else {
for($i=1; $i <= $distinct_item_count; $i++){
$item_info=explode('|', $ipn->GetVar("item_info$i"));
$GLOBALS['product_name']=$item_info[0];
$GLOBALS['quantity']=$item_info[1];
$checker->ProcessCart($ipn);
}
}
break;
//--------------------------------------------------------------------------------
// If there was a chargeback on a previous transacion where you received money...
//--------------------------------------------------------------------------------------------------------
// The transaction was a REFUND, TEST or ERROR. Log details in sales table, but don't send a confirmation
//--------------------------------------------------------------------------------------------------------
case 'CHARGEBACK':
case 'REFUND':
case 'ERROR':
$checker->ProcessOthers($ipn);
break;
//---------------------
// Subscription Cancel
//---------------------
case 'CANCEL':
// Log the cancel details in 'sales' so they're visible
$checker->ProcessCancelPayment($ipn);
break;
} // End switch
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -