Updating data sent from Paypal

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default Updating data sent from Paypal

    I have a value sent from paypal that I am trying to insert into an existing
    database.

    I am trying to call up the data, from the existing database, by the email
    address that is sent from Paypal, then update the table with a subscr_id.

    Unfortunately, I have been staring at this code for too long. I know it
    probably has a simple solution, I just can't see it at this time. Below is the
    code I am trying to use:

    <cfset
    authToken="token number">
    <cfset txToken = url.tx>
    <cfset query="cmd=_notify-synch&tx=" & txToken &
    "&at=" & authToken>

    <CFHTTP url="https://www.sandbox.paypal.com/cgi-bin/webscr?#query#"
    method="GET"
    resolveurl="false">
    </CFHTTP>

    <cfif left(#cfhttp.FileContent#,7) is "SUCCESS">
    <cfloop list="#cfhttp.FileContent#"
    index="curLine"
    delimiters="#chr(10)#">
    <cfif listGetAt(curLine,1,"=") is "first_name">
    <cfset first_name=listGetAt(curLine,2,"=")>
    </cfif>
    <cfif listGetAt(curLine,1,"=") is "last_name">
    <cfset last_name=listGetAt(curLine,2,"=")>
    </cfif>
    <cfif listGetAt(curLine,1,"=") is "item_name">
    <cfset item_name=listGetAt(curLine,2,"=")>
    </cfif>
    <cfif listGetAt(curLine,1,"=") is "mc_gross">
    <cfset mc_gross=listGetAt(curLine,2,"=")>
    </cfif>
    <cfif listGetAt(curLine,1,"=") is "mc_currency">
    <cfset mcCurrency=listGetAt(curLine,2,"=")>
    </cfif>
    <cfif listGetAt(curLine,1,"=") is "subscr_id">
    <cfset subscr_id=listGetAt(curLine,2,"=")>
    </cfif>
    <cfif listGetAt(curLine,1,"=") is "payer_email">
    <cfset email=listGetAt(curLine,2,"=")>
    </cfif>
    </cfloop>
    <!---The following piece of code is used to replace the URL encoding -
    supposedly the prior code was to decode the string, but is isn't working either
    --->

    <cfset email = #Replace(email, "%40", "@")#>
    <cfset item_name = #Replace(item_name, "+", " ")#>

    <!--- here is the code I am using to call up the student_id --->

    <cfquery name="qdata" datasource="#application.main#">
    select student_id, email, first_name, last_name
    from student
    where email = '#email#'
    </cfquery>

    <!-- this is where I am going wrong --->

    <cfset subscr_id = #subscr_id#>
    <cfupdate datasource="#application.main#" tablename="student"
    formfields="student_id,
    subscr_id"
    >
    <cfoutput query="qdata">
    <p><h3>Your order has been received.</h3></p>
    <b>Details</b><br>
    <ul>
    <li>Name: #first_name# #last_name# #student_id#</li>
    <li>Subscription id: #subscr_id#</li>
    <li>Email: #email#</li>
    <li>Amount: #mc_gross# #mcCurrency#</li>
    <li>Class: #item_name#</li>
    </ul>
    <hr>


    rickaclark54 Guest

  2. Similar Questions and Discussions

    1. Updating components when data changes
      I am having trouble getting a set of components to update when data is modified by another set of components. A...
    2. updating XML data
      I have the following code in place to move a variable from my Flash app to an XML file for storage . . . //replace the GoodVN value in the XML...
    3. Updating the data on a Chart
      Hi, I'm trying to invalidate the data of a Chart by calling invalidateData (which is defined in ChartBase and supposedly inherited in PieChart,...
    4. Updating data in a column using it's own value
      I trying to change all the entries in a column of a table to titlecase. I have a custom tag that does the case change but I can't get it to work in...
    5. Updating Data Using a Subform
      On Tue, 8 Jul 2003 12:27:39 -0700, "Brian" <btvisc@hotmail.com> wrote: Base the Subform on a Query with a criterion of on the date/time...
  3. #2

    Default Re: Updating data sent from Paypal

    <!-- this is where I am going wrong --->
    <cfset subscr_id = #subscr_id#>
    <cfupdate datasource="#application.main#" tablename="student"
    formfields="student_id,
    subscr_id"
    >
    The error arises because you forgot one or both of Coldfusion's requirements
    for cfupdate. First, at least one of the column names must correspond to the
    primary key field of the database. Second, cfupdate applies to variables in the
    form scope. This should solve the problem assuming, for example, that email is
    the DB's primary key :

    <cfparam name="form.subscr_id" default="#subscr_id#">
    <cfparam name="form.student_id" default="#qdata.student_id#">
    <cfparam name="form.email" default="#email#">


    <cfupdate datasource="#application.main#" tablename="student"
    formfields="student_id, subscr_id,email">




    BKBK Guest

  4. #3

    Default Re: Updating data sent from Paypal

    I pulled up the primary key in the first query. So, my problem lied with the <cfparam> tag, once I used this tag everything worked fine.

    Thank you
    Rick
    rickaclark54 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139