Re: [WebDNA] PayPal IPN harvester

This WebDNA talk-list message is from

2013


It keeps the original formatting.
numero = 110343
interpreted = N
texte = Perfect, thank you for sharing. On 4/12/13 2:14 PM, "Dan Strong" wrote: >Here is working code for wrangling the PayPal IPN response: > >paypal.db: >--------------------- >timestamptxn_idIPN_responsepayment_typepayment_dateb>payment_statusaddress_statuspayer_statusfirst_namela >st_namepayer_emailpayer_idaddress_nameaddress_country< >tab>address_country_codeaddress_zipaddress_stateaddress_cit >yaddress_streetreceiver_emailreceiver_idresidence_coun >tryitem_nameitem_name1item_numberitem_number1quan >tityquantity1taxmc_currencymc_feemc_grossmc_ >gross1mc_handlingmc_handling1mc_shippingmc_shipping1ab>txn_typenotify_versioncustominvoicecharsetveri >fy_signpending_reasonflagged > >IPN.html >-------------------- >[!]-- Set timestamp & write IPN data to paypal.db --[/!] >[text]timestamp=[math]{[date]}[/math].[math]{[time]}[/math][/text] > [append >db=^paypal.db][formvariables][name]=[url][value][/url]&[/formvariables]tim >estamp=[timestamp][/append] > >[!]-- Echo back to paypal & get response --[/!] > [text]content=[!] >[/!][formvariables][name]=[url][value][/url]&[/formvariables]cmd=_notify-v >alidate[!] > [/!][/text] > > [text]response=[!] > [/!][TCPconnect host=www.paypal.com&port=443&ssl=T][!] > [/!][TCPsend skipheader=T]POST /cgi-bin/webscr >HTTP/1.0[unURL]%0D%0A[/unURL][!] > [/!]USER-AGENT: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT >5.0)[unURL]%0D%0A[/unURL][!] > [/!]Content-Type: >application/x-www-form-urlencoded[unURL]%0D%0A[/unURL][!] > [/!]Content-Length: >[countChars][content][/countChars][unURL]%0D%0A[/unURL][!] > [/!][unURL]%0D%0A[/unURL][!] > [/!][content][unURL]%0D%0A[/unURL][!] > [/!][/TCPSend][!] > [/!][/TCPconnect][/text] > > [replace db=^paypal.db&eqTIMESTAMPdata=[timestamp]][!] > [/!]IPN_response=[response][!] > [/!][/replace] > >[!]-- Response is INVALID --[/!] > [showif [url][response][/url]=INVALID] > [sendmail >TO=you@youremail.com&from=you@youremail.com&SUBJECT=PAYPAL IPN - >INVALID: [txn_id]] > [/sendmail] > [/showif] > >[!]-- Response is VERIFIED --[/!] > [showif [url][response][/url]=VERIFIED] > [!]-- Check that "txn_id" has not been previously processed >--[/!] > [search db=^paypal.db&eqTXN_IDdata=[txn_id]] > [showif [numfound]>1] > [replace >db=^paypal.db&eqTIMESTAMPdata=[timestamp]]flagged=x[/replace] > > [sendmail >TO=you@youremail.com&from=you@youremail.com&SUBJECT=PAYPAL IPN - flagged >(Dup. Id): [timestamp]] > Duplicate txn_id: [txn_id] > [/sendmail] > [/showif] > [/search] > > [!]-- Check that "receiver_email" is your Primary PayPal email >--[/!] > [text]recvEmail=[lookup >db=^paypal.db&lookinfield=timestamp&value=[TIMESTAMP]&returnfield=receiver >_email¬Found=NOT-FOUND][/text] > [hideif [url][recvEmail][/url]=[url]you@youremail.com[/url]] > [replace >db=^paypal.db&eqTIMESTAMPdata=[timestamp]]flagged=x[/replace] > > [sendmail >TO=you@youremail.com&from=you@youremail.com&SUBJECT=PAYPAL IPN - flagged >(Wrong Receiver Email): [timestamp]] > [recvEmail] > [/sendmail] > [/hideif] > > [!]-- Check that "payment_status" is "Completed" --[/!] > [text]payStatus=[lookup >db=^paypal.db&lookinfield=timestamp&value=[TIMESTAMP]&returnfield=payment_ >status¬Found=NOT-FOUND][/text] > [hideif [url][payStatus][/url]=[url]Completed[/url]] > [replace >db=^paypal.db&eqTIMESTAMPdata=[timestamp]]flagged=x[/replace] > > [sendmail >TO=you@youremail.com&from=you@youremail.com&SUBJECT=PAYPAL IPN - flagged >(Pay Status): [timestamp]] > [payStatus] > [/sendmail] > [/hideif] > > [!]-- Check that "mc_currency" is correct --[/!] > [text]currency=[lookup >db=^paypal.db&lookinfield=timestamp&value=[TIMESTAMP]&returnfield=mc_curre >ncy¬Found=NOT-FOUND][/text] > [hideif [url][currency][/url]=[url]USD[/url]] > [replace >db=^paypal.db&eqTIMESTAMPdata=[timestamp]]flagged=x[/replace] > > [sendmail >TO=you@youremail.com&from=you@youremail.com&SUBJECT=PAYPAL IPN - flagged >(Currency): [timestamp]] > [currency] > [/sendmail] > [/hideif] > > [!]-- Check that "payment_amount" is correct --[/!] > [text]paidAmount=[lookup >db=^paypal.db&lookinfield=timestamp&value=[TIMESTAMP]&returnfield=mc_gross >¬Found=NOT-FOUND][/text] > [text]itemAmount=[!]--lookup item amount here, or hard code >if you are only selling one item --[/!][/text] > > [hideif [url][paidAmount][/url]=[url][itemAmount][/url]] > [replace >db=^paypal.db&eqTIMESTAMPdata=[timestamp]]flagged=x[/replace] > > [sendmail >TO=you@youremail.com&from=you@youremail.com&SUBJECT=PAYPAL IPN - flagged >(Incorrect Payment Amount): [timestamp]] > Paid: $[paidAmount] - Item (should be): $[itemAmount] > [/sendmail] > [/hideif] > >[!]-- If all is good, send email to buyer --[/!] >[text]isFlagged=[lookup >db=^paypal.db&lookinfield=timestamp&value=[TIMESTAMP]&returnfield=flagged& >notFound=x][/text] > >[hideif [isFlagged]=x] >[search db=^paypal.db&eqTIMESTAMPdata=[TIMESTAMP]&max=1] >[founditems] >[sendmail >TO=[payer_email]&BCC=you@youremail.com&FROM=you@youremail.com&SUBJECT=Than >k >you for your order #[item_number]][!] >[/!]Thank you for your order: ([item_name] - $[mc_gross]). > >Words words words go here to thank the buyer. > >[/sendmail] >[/founditems] >[/search] >[/hideif] >[/showif] > >-- >-Dan Strong >New World Creative LLC >http://www.NewWorldCreative.com > >--------------------------------------------------------- >This message is sent to you because you are subscribed to >the mailing list . >To unsubscribe, E-mail to: >archives: http://mail.webdna.us/list/talk@webdna.us >Bug Reporting: support@webdna.us Associated Messages, from the most recent to the oldest:

    
  1. Re: [WebDNA] PayPal IPN harvester (Eddie Z 2013)
  2. [WebDNA] PayPal IPN harvester (Dan Strong 2013)
Perfect, thank you for sharing. On 4/12/13 2:14 PM, "Dan Strong" wrote: >Here is working code for wrangling the Paypal IPN response: > >paypal.db: >--------------------- >timestamptxn_idIPN_responsepayment_typepayment_dateb>payment_statusaddress_statuspayer_statusfirst_namela >st_namepayer_emailpayer_idaddress_nameaddress_country< >tab>address_country_codeaddress_zipaddress_stateaddress_cit >yaddress_streetreceiver_emailreceiver_idresidence_coun >tryitem_nameitem_name1item_numberitem_number1quan >tityquantity1taxmc_currencymc_feemc_grossmc_ >gross1mc_handlingmc_handling1mc_shippingmc_shipping1ab>txn_typenotify_versioncustominvoicecharsetveri >fy_signpending_reasonflagged > >IPN.html >-------------------- >[!]-- Set timestamp & write IPN data to paypal.db --[/!] >[text]timestamp=[math]{[date]}[/math].[math]{[time]}[/math][/text] > [append >db=^paypal.db][formvariables][name]=[url][value][/url]&[/formvariables]tim >estamp=[timestamp][/append] > >[!]-- Echo back to paypal & get response --[/!] > [text]content=[!] >[/!][formvariables][name]=[url][value][/url]&[/formvariables]cmd=_notify-v >alidate[!] > [/!][/text] > > [text]response=[!] > [/!][TCPconnect host=www.paypal.com&port=443&ssl=T][!] > [/!][TCPsend skipheader=T]POST /cgi-bin/webscr >HTTP/1.0[unurl]%0D%0A[/unURL][!] > [/!]USER-AGENT: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT >5.0)[unurl]%0D%0A[/unURL][!] > [/!]Content-Type: >application/x-www-form-urlencoded[unurl]%0D%0A[/unURL][!] > [/!]Content-Length: >[countchars][content][/countChars][unurl]%0D%0A[/unURL][!] > [/!][unurl]%0D%0A[/unURL][!] > [/!][content][unurl]%0D%0A[/unURL][!] > [/!][/TCPSend][!] > [/!][/TCPconnect][/text] > > [replace db=^paypal.db&eqTIMESTAMPdata=[timestamp]][!] > [/!]IPN_response=[response][!] > [/!][/replace] > >[!]-- Response is INVALID --[/!] > [showif [url][response][/url]=INVALID] > [sendmail >TO=you@youremail.com&from=you@youremail.com&SUBJECT=Paypal IPN - >INVALID: [txn_id]] > [/sendmail] > [/showif] > >[!]-- Response is VERIFIED --[/!] > [showif [url][response][/url]=VERIFIED] > [!]-- Check that "txn_id" has not been previously processed >--[/!] > [search db=^paypal.db&eqTXN_IDdata=[txn_id]] > [showif [numfound]>1] > [replace >db=^paypal.db&eqTIMESTAMPdata=[timestamp]]flagged=x[/replace] > > [sendmail >TO=you@youremail.com&from=you@youremail.com&SUBJECT=Paypal IPN - flagged >(Dup. Id): [timestamp]] > Duplicate txn_id: [txn_id] > [/sendmail] > [/showif] > [/search] > > [!]-- Check that "receiver_email" is your Primary PayPal email >--[/!] > [text]recvEmail=[lookup >db=^paypal.db&lookinfield=timestamp&value=[TIMESTAMP]&returnfield=receiver >_email¬Found=NOT-FOUND][/text] > [hideif [url][recvEmail][/url]=[url]you@youremail.com[/url]] > [replace >db=^paypal.db&eqTIMESTAMPdata=[timestamp]]flagged=x[/replace] > > [sendmail >TO=you@youremail.com&from=you@youremail.com&SUBJECT=Paypal IPN - flagged >(Wrong Receiver Email): [timestamp]] > [recvEmail] > [/sendmail] > [/hideif] > > [!]-- Check that "payment_status" is "Completed" --[/!] > [text]payStatus=[lookup >db=^paypal.db&lookinfield=timestamp&value=[TIMESTAMP]&returnfield=payment_ >status¬Found=NOT-FOUND][/text] > [hideif [url][payStatus][/url]=[url]Completed[/url]] > [replace >db=^paypal.db&eqTIMESTAMPdata=[timestamp]]flagged=x[/replace] > > [sendmail >TO=you@youremail.com&from=you@youremail.com&SUBJECT=Paypal IPN - flagged >(Pay Status): [timestamp]] > [payStatus] > [/sendmail] > [/hideif] > > [!]-- Check that "mc_currency" is correct --[/!] > [text]currency=[lookup >db=^paypal.db&lookinfield=timestamp&value=[TIMESTAMP]&returnfield=mc_curre >ncy¬Found=NOT-FOUND][/text] > [hideif [url][currency][/url]=[url]USD[/url]] > [replace >db=^paypal.db&eqTIMESTAMPdata=[timestamp]]flagged=x[/replace] > > [sendmail >TO=you@youremail.com&from=you@youremail.com&SUBJECT=Paypal IPN - flagged >(Currency): [timestamp]] > [currency] > [/sendmail] > [/hideif] > > [!]-- Check that "payment_amount" is correct --[/!] > [text]paidAmount=[lookup >db=^paypal.db&lookinfield=timestamp&value=[TIMESTAMP]&returnfield=mc_gross >¬Found=NOT-FOUND][/text] > [text]itemAmount=[!]--lookup item amount here, or hard code >if you are only selling one item --[/!][/text] > > [hideif [url][paidAmount][/url]=[url][itemAmount][/url]] > [replace >db=^paypal.db&eqTIMESTAMPdata=[timestamp]]flagged=x[/replace] > > [sendmail >TO=you@youremail.com&from=you@youremail.com&SUBJECT=Paypal IPN - flagged >(Incorrect Payment Amount): [timestamp]] > Paid: $[paidAmount] - Item (should be): $[itemAmount] > [/sendmail] > [/hideif] > >[!]-- If all is good, send email to buyer --[/!] >[text]isFlagged=[lookup >db=^paypal.db&lookinfield=timestamp&value=[TIMESTAMP]&returnfield=flagged& >notFound=x][/text] > >[hideif [isFlagged]=x] >[search db=^paypal.db&eqTIMESTAMPdata=[TIMESTAMP]&max=1] >[founditems] >[sendmail >TO=[payer_email]&BCC=you@youremail.com&FROM=you@youremail.com&SUBJECT=Than >k >you for your order #[item_number]][!] >[/!]Thank you for your order: ([item_name] - $[mc_gross]). > >Words words words go here to thank the buyer. > >[/sendmail] >[/founditems] >[/search] >[/hideif] >[/showif] > >-- >-Dan Strong >New World Creative LLC >http://www.NewWorldCreative.com > >--------------------------------------------------------- >This message is sent to you because you are subscribed to >the mailing list . >To unsubscribe, E-mail to: >archives: http://mail.webdna.us/list/talk@webdna.us >Bug Reporting: support@webdna.us Eddie Z

DOWNLOAD WEBDNA NOW!

Top Articles:

Talk List

The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...

Related Readings:

The beginning (1997) can WC render sites out? (1997) Virtual Postcards (1998) Questions! (2000) MySQL 4.1 (2004) Problem (1997) Stupid question (2003) Shopping cart now good (fixed it) (1997) Separate SSL Server (1997) problems with 2 tags (1997) Strange search... (2001) server side includes & webcatalog (2000) Multiple serial numbers (1997) HELP WITH DATES (1997) WebCatalog Hosting (1996) WebCatalog can't find database (1997) Major problem (1999) Upgrading to 10.1.5 (2002) 6.0 /Panther install issues (2004) Fun with Dates - finally resolved but.... (1997)