Jump to content


Photo

IPN Subscriptions


  • This topic is locked This topic is locked
5 replies to this topic

#1 joel@perpetualmedia.com

joel@perpetualmedia.com

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 06 May 2003 - 08:55 AM

I've not yet seen a working cold fusion example script that processes both the initial subscription and handles cancellations, end of subscriptions, or any associated functionality. The example on easycfm.com only appears to handle new subscriptions but none of the other processes necessary. The few links on this forum are mostly dead links or irrelevant. I'm also quite confused by the statements in this forum that suggest that payment_status is not sent for subscriptions when all of the examples I've seen are using it... Please help if you can..

#2 MAGSGQ

MAGSGQ

    Member

  • Members
  • PipPip
  • 13 posts

Posted 07 May 2003 - 09:12 AM

I'm searching for the same thing. The 'test' code I found on here returns no errors; I can output my vars and data just fine; but for some reason I can't write to the dbase.

I offer just one year subsriptions renewable after 365 days, but at this point I'm about to give up.

I just need some more insight, after I run the TEST how to determine if it was a successful test.

If I see or hear anything different I'll post here for you.

I suck at CFusion!

#3 joel@perpetualmedia.com

joel@perpetualmedia.com

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 09 May 2003 - 09:04 AM

I developed this and have tested it to handle cancelations, but it hasn't worked to date, maybe one of the wonderful PayPal Patrons can steer me where I've gone wrong. Here we go

<code>
<!-- read post from PayPal system and add 'cmd' -->
<CFSET str="cmd=_notify-validate">

<cfoutput>
<CFLOOP INDEX="TheField" list="#Form.FieldNames#">
<CFSET str = str & "#LCase(TheField)#=#URLEncodedFormat(Evaluate(TheField))#">
</CFLOOP>
</cfoutput>

<CFIF IsDefined("FORM.payment_date")>
<CFSET str = str & "&payment_date=#URLEncodedFormat(Form.payment_date)#">
</CFIF>

<CFIF IsDefined("FORM.subscr_date")>
<CFSET str = str & "&subscr_date=#URLEncodedFormat(Form.subscr_date)#">
</CFIF>
<cfoutput>
#str#
#form.txn_type#
</cfoutput>
<!-- post back to PayPal system to validate -->
<CFHTTP URL="https://www.paypal.com/cgi-bin/webscr?#str#" METHOD="GET" RESOLVEURL="false">
</CFHTTP>

<!-- check notification validation -->
<CFIF #CFHTTP.FileContent# is "VERIFIED">
<!-- check that receiver_email is your email address -->
<cfif #FORM.RECEIVER_EMAIL# eq "joel@perpetualmedia.com">
<!--- Query My Database for txn_id and account information --->
<cfquery name="pclient_client_id" datasource="#session.dsn#" username="#session.du#" password="#session.dp#">
select *
from pclient
where client_id = #form.custom#
</cfquery>

<!--- Process different types of payment --->
<cfswitch expression="#form.txn_type#">
Test
<cfcase value="subscr_signup">
<!-- process sign-up -->
<cfquery name="update_pclient" datasource="#session.dsn#" username="#session.du#" password="#session.dp#">
update pclient
set account_status = 1, trial = 0
where client_id = #form.custom#
</cfquery>
<!--- Continue with My registration process --->
<cfoutput>

<cflocation url="#session.url#/index.cfm?attributes.fuseaction=sign_up4&client_id=#form.custom#">
</cfoutput>
</cfcase>
<cfcase value="subscr_payment">
<!-- process payment -->
<cfquery name="update_pclient" datasource="#session.dsn#" username="#session.du#" password="#session.dp#">
update pclient
set account_status = 1
where client_id = #form.custom#
</cfquery>
<!--- Mail customer thanking them for their payment --->
<cfinclude template="../act/act_payment_confirmation.cfm">
</cfcase>
<cfcase value="subscr_cancel">
<!-- process cancellation -->
<cfquery name="update_pclient" datasource="#session.dsn#" username="#session.du#" password="#session.dp#">
update pclient
set account_status = 0, trial = 0
where client_id = #form.custom#
</cfquery>
<!--- Mail customer alerting them to the cancellation --->
<cfinclude template="../act/act_cancellation.cfm">
</cfcase>
<cfcase value="subscr_eot">
<!-- process end of term -->
<cfquery name="update_pclient" datasource="#session.dsn#" username="#session.du#" password="#session.dp#">
update pclient
set account_status = 0, trial = 0
where client_id = #form.custom#
</cfquery>
<!--- Mail customer alerting them to the cancellation --->
<cfinclude template="../act/act_cancellation.cfm">
</cfcase>
</cfswitch>
</cfif>
<CFELSEIF #CFHTTP.FileContent# is "INVALID">
<!-- log for investigation -->
Screwed up
<CFELSE>
Screwed UP
<!-- error -->
</CFIF>
</code>

#4 Chadd

Chadd

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 16 May 2003 - 01:38 PM

I have tried everything in these friggen forums and nothing works. why doesnt paypal have an exact script (IPN.CFM) file and all the users need to do is add in their info. man paypal would be cool if they offered a little more help to the businesses.


Can anyone please let me copy their IPN script for subscription that actually works. Please help nothing is working. i get eliteweaver to show that i am posting incorrect script but that is it.

this link doesnt work http://jshop.homeip...._paypal_ipn.cfm

here is a copy of my code

<!--- http://www.tbforeclo...eckout/IPN2.cfm --->
<!-- read post from PayPal system and add 'cmd' -->

<CFSET str="cmd=_notify-validate">
<CFLOOP INDEX="TheField" list="#Form.FieldNames#">
<CFSET str = str & "#LCase(TheField)#=#URLEncodedFormat(Evaluate(TheField))#">
</CFLOOP>
<CFIF IsDefined("FORM.payment_date")>
<CFSET str = str & "&payment_date=#URLEncodedFormat(Form.payment_date)#">
</CFIF>
<CFIF IsDefined("FORM.subscr_date")>
<CFSET str = str & "&subscr_date=#URLEncodedFormat(Form.subscr_date)#">
</CFIF>



<!-- post back to PayPal system to validate -->
<CFHTTP URL="http://www.paypal.com/cgi-bin/webscr?#str#" METHOD="GET" RESOLVEURL="false">

</CFHTTP>
<!-- check notification validation -->


<!--- Log the received form posting to file --->
<cfset Ret = chr(13) & chr(10)>
<cfset strMsg = "">
<CFLOOP INDEX="TheField" list="#Form.FieldNames#">
<CFSET strMsg = strMsg & "#LCase(TheField)#=#Evaluate(TheField)#" & Ret>
</CFLOOP>
<!--- Write the incoming IPN to a file log request --->
<CFSET thisPath= ExpandPath("*.*")>
<CFSET thisDirectory= GetDirectoryFromPath(thisPath)>
<cfset strStamp = DatePart("yyyy", Now()) & "_" & DatePart("m", Now()) & "_" & DatePart("d", Now()) & DatePart("m", Now()) & DatePart("s", Now())>
<cfset strFileName = "IN_IPN_#strStamp#.txt">
<cfset strfilePath = "#GetDirectoryFromPath(thisPath)#posts\#strFileName#">
<CFFILE ACTION="Write"
FILE=#strfilePath#
OUTPUT=#strMsg#
ADDNEWLINE="No">

<!-- check notification validation -->
<!--- <CFIF #CFHTTP.FileContent# is "VERIFIED"> --->
<!-- check that payment_status=Completed -->
<!-- check that txn_id has not been previously processed -->
<cfquery name="Check" datasource="foreclosure" password="jamesbond" username="foreclosure">
Select txn_ID from
dbo.Users
Where txn_ID = '#Form.txn_ID#'
</cfquery>
<cfset strError = "">
<cfif Not Check.RecordCount is 0>

<cfset strError = " Transaction has been previously processed. ">
</cfif>
<!-- check that receiver_email is your email address -->

<cfif not CompareNoCase(trim(Form.receiver_email), "robertd@rdempster.com")>

<cfset strError = strError & " Receiver email is not correct. ">
</cfif>
<cfif CompareNoCase(trim(CFHTTP.FileContent), "INVALID")>

<cfset strError = strError & " Payment posting was invalid. ">
</cfif>
<cfif strError is "">
<cfset Product_ID = ReplaceNoCase(Form.item_number, "-Listing", "")>

<cfset strIntoDates = ",ListingStartDate, ListingEndDate">
<!--- Add 60 days to the start date --->
<cfset strValueDates = ",#CreateODBCDateTime(now())#, #CreateODBCDateTime(DateAdd("d", "60", Now()))#">
<cfelse>
<cfset strIntoDates = "">
<cfset strValueDates = "">
</cfif>
<!--cfset CurrentPage=GetFileFromPath(GetTemplatePath())-->
<!--cfif IsDefined("FORM.MM_InsertRecord") AND FORM.MM_InsertRecord EQ "TestForm"-->

<cfquery datasource="foreclosure" password="jamesbond" username="foreclosure">
INSERT INTO dbo.Users (receiver_email, business, item_name, item_number,
invoice, custom, option_name1, option_selection1, option_name2, option_selection2,
payment_status, pending_reason, payment_date, settle_amount, settle_currency,
exchange_rate, payment_gross, payment_fee, mc_gross, mc_fee, mc_currency, tax,
txn_id, txn_type, memo, first_name, last_name, address_street, address_city,
address_state, address_zip, address_country, address_status, payer_email, payer_id,
payer_status, payment_type, subscr_date, subscr_effective, period1, period2,
period3, amount1, amount2, amount3, mc_amount1, mc_amount2, mc_amount3, recurring,
reattempt, retry_at, recur_times, username, password, subscr_id, notify_version,
verify_sign, status) VALUES (

<cfif IsDefined("FORM.receiver_email") AND #FORM.receiver_email# NEQ "">
'#FORM.receiver_email#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.business") AND #FORM.business# NEQ "">
'#FORM.business#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.item_name") AND #FORM.item_name# NEQ "">
'#FORM.item_name#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.item_number") AND #FORM.item_number# NEQ "">
'#FORM.item_number#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.invoice") AND #FORM.invoice# NEQ "">
'#FORM.invoice#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.custom") AND #FORM.custom# NEQ "">
'#FORM.custom#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.option_name1") AND #FORM.option_name1# NEQ "">
'#FORM.option_name1#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.option_selection1") AND #FORM.option_selection1# NEQ "">
'#FORM.option_selection1#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.option_name2") AND #FORM.option_name2# NEQ "">
'#FORM.option_name2#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.option_selection2") AND #FORM.option_selection2# NEQ "">
'#FORM.option_selection2#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.payment_status") AND #FORM.payment_status# NEQ "">
'#FORM.payment_status#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.pending_reason") AND #FORM.pending_reason# NEQ "">
'#FORM.pending_reason#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.payment_date") AND #FORM.payment_date# NEQ "">
'#FORM.payment_date#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.settle_amount") AND #FORM.settle_amount# NEQ "">
#FORM.settle_amount#
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.settle_currency") AND #FORM.settle_currency# NEQ "">
'#FORM.settle_currency#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.exchange_rate") AND #FORM.exchange_rate# NEQ "">
'#FORM.exchange_rate#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.payment_gross") AND #FORM.payment_gross# NEQ "">
#FORM.payment_gross#
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.payment_fee") AND #FORM.payment_fee# NEQ "">
#FORM.payment_fee#
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.mc_gross") AND #FORM.mc_gross# NEQ "">
#FORM.mc_gross#
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.mc_fee") AND #FORM.mc_fee# NEQ "">
#FORM.mc_fee#
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.mc_currency") AND #FORM.mc_currency# NEQ "">
'#FORM.mc_currency#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.tax") AND #FORM.tax# NEQ "">
#FORM.tax#
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.txn_id") AND #FORM.txn_id# NEQ "">
'#FORM.txn_id#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.txn_type") AND #FORM.txn_type# NEQ "">
'#FORM.txn_type#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.memo") AND #FORM.memo# NEQ "">
'#FORM.memo#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.first_name") AND #FORM.first_name# NEQ "">
'#FORM.first_name#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.last_name") AND #FORM.last_name# NEQ "">
'#FORM.last_name#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.address_street") AND #FORM.address_street# NEQ "">
'#FORM.address_street#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.address_city") AND #FORM.address_city# NEQ "">
'#FORM.address_city#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.address_state") AND #FORM.address_state# NEQ "">
'#FORM.address_state#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.address_zip") AND #FORM.address_zip# NEQ "">
'#FORM.address_zip#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.address_country") AND #FORM.address_country# NEQ "">
'#FORM.address_country#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.address_status") AND #FORM.address_status# NEQ "">
'#FORM.address_status#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.payer_email") AND #FORM.payer_email# NEQ "">
'#FORM.payer_email#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.payer_id") AND #FORM.payer_id# NEQ "">
'#FORM.payer_id#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.payer_status") AND #FORM.payer_status# NEQ "">
'#FORM.payer_status#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.payment_type") AND #FORM.payment_type# NEQ "">
'#FORM.payment_type#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.subscr_date") AND #FORM.subscr_date# NEQ "">
'#FORM.subscr_date#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.subscr_effective") AND #FORM.subscr_effective# NEQ "">
'#FORM.subscr_effective#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.period1") AND #FORM.period1# NEQ "">
'#FORM.period1#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.period2") AND #FORM.period2# NEQ "">
'#FORM.period2#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.period3") AND #FORM.period3# NEQ "">
'#FORM.period3#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.amount1") AND #FORM.amount1# NEQ "">
#FORM.amount1#
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.amount2") AND #FORM.amount2# NEQ "">
#FORM.amount2#
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.amount3") AND #FORM.amount3# NEQ "">
#FORM.amount3#
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.mc_amount1") AND #FORM.mc_amount1# NEQ "">
#FORM.mc_amount1#
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.mc_amount2") AND #FORM.mc_amount2# NEQ "">
#FORM.mc_amount2#
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.mc_amount3") AND #FORM.mc_amount3# NEQ "">
#FORM.mc_amount3#
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.recurring") AND #FORM.recurring# NEQ "">
#FORM.recurring#
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.reattempt") AND #FORM.reattempt# NEQ "">
#FORM.reattempt#
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.retry_at") AND #FORM.retry_at# NEQ "">
'#FORM.retry_at#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.recur_times") AND #FORM.recur_times# NEQ "">
#FORM.recur_times#
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.username") AND #FORM.username# NEQ "">
'#FORM.username#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.password") AND #FORM.password# NEQ "">
'#FORM.password#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.subscr_id") AND #FORM.subscr_id# NEQ "">
'#FORM.subscr_id#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.notify_version") AND #FORM.notify_version# NEQ "">
'#FORM.notify_version#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.verify_sign") AND #FORM.verify_sign# NEQ "">
'#FORM.verify_sign#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.status") AND #FORM.status# NEQ "1">
'#FORM.status#'
<cfelse>
0
</cfif>
)
</cfquery>

<!-- check notification validation -->
<!--CFIF #CFHTTP.FileContent# is "VERIFIED"--->
<!-- check that payment_status=Completed -->
<!-- check that txn_id has not been previously processed -->
<!-- check that receiver_email is your Primary PayPal email -->
<!-- process payment--->
<!---CFELSEIF #CFHTTP.FileContent# is "INVALID">
<!-- log for investigation -->
<CFELSE>
<!-- error -->
</CFIF--->


#5 MAGSGQ

MAGSGQ

    Member

  • Members
  • PipPip
  • 13 posts

Posted 07 June 2003 - 07:07 AM

Chadd, I can tell you this much. Start off slow. I was able to get mine working BUT I started with JUST CHECKING vars that are passed between my site and PayPal.

I suggest doing the same. Make sure you can successfully pass the vars BEFORE you start doing INSERTS/UPDATES/CFMAIL etc.

I was amazed but it did work. I used just ordinary "BUY BUTTON" code for starters. Now I'm working on incorporating SUBSCRIPTION variables. I'm not an expert and I too am struggling. I'll try to offer any help I can but let me tell you this:

NO ONE coughed up their code on this one because there has been so much problems. I paid for some code JUST to give me a start and it has helped.


I suck at CFusion!

#6 jmercmon

jmercmon

    Member

  • Members
  • PipPip
  • 14 posts

Posted 08 June 2003 - 11:27 AM

My code works, it will handle every IPN paypal puts out.

http://jshop.homeip...._paypal_ipn.cfm




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users