Jump to content

Alertpay IPN Help


austin752

Recommended Posts

I have been trying for days to get my alertpay ipn to update my database. I thought I had it but obviously I don't. Please help.

 

here is the last bit of code I put together.

 

$rs[4] is my merchant email address

$rs[23] is my alertpay security code

 


include "config.php";

$sql=mysql_query("Select * from adminsettings");
$result = mysql_query($sql);
$rs =  mysql_fetch_array($result);

//The value is the Security Code generated from the IPN section of your AlertPay account. Please change it to yours.
define("IPN_SECURITY_CODE", "". $rs[23]."");
define("MY_MERCHANT_EMAIL", "". $rs[4] ."");

//Setting information about the transaction from the IPN post variables
$ap_SecurityCode = $_POST['ap_securitycode'];
$ap_CustFirstName =$_POST['ap_custfirstname'];
$ap_CustLastName = $_POST['ap_custlastname'];
$ap_CustAddress = $_POST['ap_custaddress'];
$ap_CustCity = $_POST['ap_custcity'];
$ap_CustCountry = $_POST['ap_custcountry'];
$ap_CustState = $_POST['ap_custstate'];
$ap_CustZip = $_POST['ap_custzip'];
$ap_CustEmailAddress = $_POST['ap_custemailaddress'];
$ap_PurchaseType = $_POST['ap_purchasetype'];
$ap_Merchant = $_POST['ap_merchant'];
$ap_ItemName = $_POST['ap_itemname'];
$ap_Description = $_POST['ap_description'];
$ap_Quantity = $_POST['ap_quantity'];
$ap_Amount = $_POST['ap_amount'];
$ap_AdditionalCharges=$_POST['ap_additionalcharges'];
$ap_ShippingCharges=$_POST['ap_shippingcharges'];
$ap_TaxAmount=$_POST['ap_taxamount'];
$ap_DiscountAmount=$_POST['ap_discountamount'];
$ap_TotalAmount = $_POST['ap_totalamount'];
$ap_Currency = $_POST['ap_currency'];
$ap_ReferenceNumber = $_POST['ap_referencenumber'];
$ap_Status = $_POST['ap_status'];
$ap_ItemCode = $_POST['ap_itemcode'];
$ap_Test = $_POST['ap_test'];
$ap_SubscriptionReferenceNumber = $_POST['ap_subscriptionreferencenumber'];
$ap_TimeUnit = $_POST['ap_timeunit'];
$ap_PeriodLength=$_POST['ap_periodlength'];
$ap_PeriodCount=$_POST['ap_periodcount'];
$ap_NextRunDate=$_POST['ap_nextrundate'];
$ap_TrialTimeUnit=$_POST['ap_trialtimeunit'];
$ap_TrialPeriodLength=$_POST['ap_trialperiodlength'];
$ap_TrialAmount=$_POST['ap_trialamount'];
$ap_Apc_1 = $_POST['apc_1'];
$ap_Apc_2 = $_POST['apc_2'];
$ap_Apc_3 = $_POST['apc_3'];
$ap_Apc_4 = $_POST['apc_4'];
$ap_Apc_5 = $_POST['apc_5'];
$ap_Apc_6 = $_POST['apc_6'];
$transactionDate = date('d-m-Y H:i:s');

if ($receivedMerchantEmailAddress != $rs[4]) {
	// The data was not meant for the business profile under this email address.
	// Take appropriate action.
	error_log('wrong merchant email address', 0);
}
else {	
	// Check if the security code matches
	if ($mySecurityCode != $rs[23]) {
		// The data is NOT sent by AlertPay.
		// Take appropriate action.
		error_log('wrong security code', 0);
	}
	else {
		// Check if it is an initial payment for a subscription
		if ($purchaseType == "subscription" && $transactionStatus == "Success") {

			//no trial period

		}
		elseif ($purchaseType == "subscription" && $transactionStatus == "Subscription-Payment-Success" && $subscriptionPaymentNumber > 1) {

			mysql_query("INSERT INTO `payment_history`(`member_id`, `account`, `firstname`, `lastname`, `address`, `city`, `state`, `zip`, `country`, `amount`, `paid`, `transaction_number`, `date`) VALUES ($ap_Apc_1, $ap_CustEmailAddress, $ap_CustFirstName, $ap_CustLastName, $ap_CustAddress, $ap_CustCity, $ap_CustState,  $ap_CustZip, $ap_CustCountry, $ap_Amount, 1, $ap_ReferenceNumber, $transactionDate)");	
		}
		else {
			switch ($transactionStatus){
				case "Subscription-Expired":
					// Take appropriate when the subscription has reached its terms.
					break;
				case "Subscription-Payment-Failed":
					// Take appropriate actions when a payment attempt has failed.
					break;
				case "Subscription-Payment-Rescheduled":
					// Take appropriate actions when a payment is rescheduled.
					break;
				case "Subscription-Canceled":
					// Take appropriate actions regarding a cancellation.
					break;
				default:
					// Take a default action in the case that none of the above were handled.
					break;
			}			
		}
	}
}

 

I attached the full file if you want to look at that

18331_.php

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.