E-Junkie Forum http://www.e-junkie.com/bb/ E-Junkie Forum RSS en-us Copyright 2013, 19.5 Degrees. All rights reserved. webmaster@e-junkie.com webmaster@e-junkie.com Thu, 21 Jun 2012 22:51:17 GMT Wed, 22 May 2013 04:06:46 GMT 681 E-JUNKIE 5 E-Junkie Forum http://www.e-junkie.com/bb/ http://www.e-junkie.com/ej/logo.gif 290 104 Post #11 http://www.e-junkie.com/bb/topic/2597/pg/0#post21189 http://www.e-junkie.com/bb/topic/2597/pg/0#post21189 Thu, 21 Jun 2012 22:51:17 GMT
First, I've created a DB table called 'purchases' with the following vars:
first_name
last_name
payer_email
payment_date
custom
invoice
item_name
item_number

Why? Because these are the only items I want to know about a purchase. Feel free to add your own.

Now for the PHP code.

<?php
//since all this happens invisibly between servers, we can't see errors, so email myself all the bugs that happen
function emailOnFail($var)
{
mail ("YOUR_EMAIL_ADDRESS_HERE","post from e-junkie", print_r($_POST) . $var);
}

//First, check if the server that triggered this page to load is sending the right handshake
if ($_POST['handshake']!==md5("YOUR_EJUNKIE_EMAIL_HERE".md5("YOUR_EJUNKIE_PASSWORD_HERE")))
{
//The server is not legit, so exit to prevent this fraud from happening.
die();
}

//Connect to the MySQL database
mysql_connect("DB_HOST_HERE", "DB_USER_HERE", "DB_PASSWORD_HERE") or die(emailOnFail("MYSQL ERROR! ".mysql_error()));
mysql_select_db("DB_NAME_HERE") or die(emailOnFail("DB-SELECT ERROR! ".mysql_error()));

//Multiple items could have been purchased so go through the list to see how many items have been purchased; I'm capping it at 1000
$i = 1000;
$count = 1;
while ($i>$count)
{
if($_POST['item_number'.$count])
{

//We need to know the following variables (left: e-junkie var, right: database var):
/*
first_name = first_name
last_name = last_name
payer_email = payer_email
payment_date = payment_date
custom = YouTubeChannel
invoice = invoice
item_name = item_name
item_number = item_number
*/

//set the vars to a database array (left: db var, right: e-junkie var)
//WARNING: You should probably check if these post-vars actually exist!
$db['first_name'] = $_POST['first_name'];
$db['last_name'] = $_POST['last_name'];
$db['payer_email'] = $_POST['payer_email'];
$db['payment_date'] = $_POST['payment_date'];
$db['YouTubeChannel'] = $_POST['custom'];
$db['invoice'] = $_POST['invoice'];
$db['item_name'] = $_POST['item_name'.$count.''];
$db['item_number'] = $_POST['item_number'.$count.''];

//extract the database array into a query
$string = "INSERT INTO purchases (first_name, last_name, payer_email, payment_date, YouTubeChannel, invoice, item_name, item_number)
VALUES('".$db['first_name']."',
'".$db['last_name']."',
'".$db['payer_email']."',
'".$db['payment_date']."',
'".$db['YouTubeChannel']."',
'".$db['invoice']."',
'".$db['item_name']."',
'".$db['item_number']."'
)";

//fire it into the db or die with an email notification
mysql_query($string) or die(emailOnFail("DB-INSERT ERROR! ".mysql_error()));

}
else
{
//there are no items left in the cart, so kill this script. All done!
$finalcount = $count;
$count = 1001;
break;
die();
}
//There are more items left in the script so go back and do some more!
$count++;
}
?>]]>
E-junkie Discussions; TheNiceGuy
Post #10 http://www.e-junkie.com/bb/topic/2597/pg/0#post21189 http://www.e-junkie.com/bb/topic/2597/pg/0#post21189 Thu, 14 Aug 2008 16:46:32 GMT
<cfparam name="payer_email" default="john@doe.com">
<cfparam name="txn_id" default="999999">
<cfparam name="first_name" default="firstname">
<cfparam name="last_name" default="lastname">
<cfparam name="mc_gross" default="0.00">
<cfparam name="address_city" default="novalue">
<cfparam name="address_state" default="novalue">
<cfparam name="address_zip" default="novalue">
<cfparam name="key" default="novalue">
<cfparam name="item_name1" default="novalue">
<cfparam name="item_number1" default="novalue">
<cfparam name="quantity1" default="novalue">
<cfparam name="mc_gross_1" default="mc_gross_1">

Based on our own configuration, we only really sell one product

<cfparam name="item_name2" default="novalue">
<cfparam name="item_number2" default="novalue">
<cfparam name="quantity2" default="novalue">
<cfparam name="mc_gross_2" default="mc_gross_2">

The parameters some in via a form

<cfset email='#Form.payer_email#'>
<cfset txn_id='#Form.txn_id#'>
<cfset first='#Form.first_name#'>
<cfset last='#Form.last_name#'>
<cfset mc_gross='#Form.mc_gross#'>
<cfset address_city='#Form.address_city#'>
<cfset address_state='#Form.address_state#'>
<cfset address_zip='#Form.address_zip#'>
<cfset key='#key#'>

<cfset item_name1='#Form.item_name1#'>
<cfset item_number1='#Form.item_number1#'>
<cfset quantity1='#Form.quantity1#'>
<cfset mc_gross_1='#Form.mc_gross_1#'>

<!-- only if it exists? -->
<CFIF IsDefined("FORM.quantity2")>
<cfset item_name2='#Form.item_name2#'>
<cfset item_number2='#Form.item_number2#'>
<cfset quantity2='#Form.quantity2#'>
<cfset mc_gross_2='#Form.mc_gross_2#'>
</CFIF>

<!-- Serial Numbers (Product Keys) are published with a Carraige Return/Line Feed, for simplicity I replace that with a "+" sign so I can stick them into one database field -->
<cfset key = Replace(key, Chr(13), "+", "ALL")>
<cfset key = Replace(key, Chr(10), "+", "ALL")>

Here is the real code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>eJunkie Processing</title>
</head>
<body>

<!-- Here I'm creating an email as a backup mechanism -->
<CFMAIL TO="me@mydomain.com"
SERVER="mail.mydomain.com"
FROM="ejunkie@mydomain.com"
SUBJECT="eJunkie Purchase from #email#">
User Information
email: #payer_email#
txn_id: #txn_id#
First: #first#
Last: #last#
Payment: #mc_gross#
address_city=#address_city#
address_state=#address_state#
address_zip=#address_zip#

Serial Number
serialnumber=#key#

Item 1
item_name1=#item_name1#
item_number1=#item_number1#
quantity1=#quantity1#
mc_gross_1=#mc_gross_2#

Item 2
item_name2=#item_name2#
item_number2=#item_number2#
quantity2=#quantity2#
mc_gross_2=#mc_gross_2#

</CFMAIL>
<!-- now do the SQL Insert Statement -->
<cfquery name="qeJunkieInsert" datasource="mydatabase">
Insert into eJunkie (transactdate, txn_id, email, firstname, lastname, grossamount, city, state, zip, serialnumber)
values
(#CreateODBCDate(now())#, '#txn_id#', '#payer_email#', '#first#', '#last#', #mc_gross#, '#address_city#', '#address_state#', '#address_zip#', '#key#')
</cfquery>
Thanks
</body>
</html>

And that's it. Works for me, pretty simple.]]>
E-junkie Discussions; dhacker
Post #9 http://www.e-junkie.com/bb/topic/2597/pg/0#post21189 http://www.e-junkie.com/bb/topic/2597/pg/0#post21189 Fri, 8 Aug 2008 03:25:42 GMT E-junkie Discussions; dhacker Post #8 http://www.e-junkie.com/bb/topic/2597/pg/0#post21189 http://www.e-junkie.com/bb/topic/2597/pg/0#post21189 Thu, 7 Aug 2008 16:44:36 GMT E-junkie Discussions; matthew239 Post #7 http://www.e-junkie.com/bb/topic/2597/pg/0#post21189 http://www.e-junkie.com/bb/topic/2597/pg/0#post21189 Mon, 21 Jul 2008 20:19:12 GMT E-junkie Discussions; matthew239 Post #6 http://www.e-junkie.com/bb/topic/2597/pg/0#post21189 http://www.e-junkie.com/bb/topic/2597/pg/0#post21189 Mon, 19 May 2008 23:24:53 GMT E-junkie Discussions; dhacker Post #5 http://www.e-junkie.com/bb/topic/2597/pg/0#post21189 http://www.e-junkie.com/bb/topic/2597/pg/0#post21189 Mon, 19 May 2008 21:51:51 GMT
Funny how people that pay me to improve their business listen but when its free advice it is disgarded. I have always laughed at that. I tell people all the time that they really do need to pay me to help them or it won't work lol.]]>
E-junkie Discussions; lemonbar
Post #4 http://www.e-junkie.com/bb/topic/2597/pg/0#post21189 http://www.e-junkie.com/bb/topic/2597/pg/0#post21189 Mon, 19 May 2008 21:44:50 GMT
However, I still think you guys would want to put a 'complete' php script there or a link to some robust examples (even better) or ones the manipulate the datebase.

It just makes it easier for more people to use your service.

Having a section on your site where code example are placed would be a cool thing as well.]]>
E-junkie Discussions; lemonbar
Post #3 http://www.e-junkie.com/bb/topic/2597/pg/0#post21189 http://www.e-junkie.com/bb/topic/2597/pg/0#post21189 Mon, 19 May 2008 21:25:50 GMT http://www.e-junkie.com/ej/help.integration.php
(BTW, the street address variable would indeed be "address_street" -- looks like we missed that one in the documentation :^).

Notice at the very end of that page our "Passthru" instructions, which would just dump all the data we collect for each transaction to your URL, so you could capture that and sift thru everything to see what's useful or just grab what you need and ignore the rest.

Getting your own custom scripts to work is of course entirely up to you and your personal expertise with PHP or Perl or whatever you're scripting in; we cannot help develop or troubleshoot or bugfix your own scripting.]]>
E-junkie Discussions; E-junkieGuru
Post #2 http://www.e-junkie.com/bb/topic/2597/pg/0#post21189 http://www.e-junkie.com/bb/topic/2597/pg/0#post21189 Sun, 18 May 2008 04:22:32 GMT
does the notification list we get not always display all values? maybe due to being null?

what is the address field name? i only see city, state, zip listed on the site. is it 'address_street' ?]]>
E-junkie Discussions; lemonbar
Post #1 http://www.e-junkie.com/bb/topic/2597/pg/0#post21189 http://www.e-junkie.com/bb/topic/2597/pg/0#post21189 Sat, 17 May 2008 21:00:45 GMT
maybe it is already on the site somehwere and if no tthen maybe e-junkie can add it for reference.

how do most handle errors. do they have an email sent to site admin?

do most of you have an email sent on successful ad as well?

thank you]]>
E-junkie Discussions; lemonbar