[WebDNA] PayPal IPN harvester

This WebDNA talk-list message is from

2013


It keeps the original formatting.
numero = 110341
interpreted = N
texte = Here is working code for wrangling the PayPal IPN response: paypal.db: --------------------- timestamptxn_idIPN_responsepayment_typepayment_datepayment_statusaddress_statuspayer_statusfirst_namelast_namepayer_emailpayer_idaddress_nameaddress_countryaddress_country_codeaddress_zipaddress_stateaddress_cityaddress_streetreceiver_emailreceiver_idresidence_countryitem_nameitem_name1item_numberitem_number1quantityquantity1taxmc_currencymc_feemc_grossmc_gross1mc_handlingmc_handling1mc_shippingmc_shipping1txn_typenotify_versioncustominvoicecharsetverify_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]timestamp=[timestamp][/append] [!]-- Echo back to paypal & get response --[/!] [text]content=[!] [/!][formvariables][name]=[url][value][/url]&[/formvariables]cmd=_notify-validate[!] [/!][/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_currency¬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¬Found=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=Thank 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 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)
Here is working code for wrangling the Paypal IPN response: paypal.db: --------------------- timestamptxn_idIPN_responsepayment_typepayment_datepayment_statusaddress_statuspayer_statusfirst_namelast_namepayer_emailpayer_idaddress_nameaddress_countryaddress_country_codeaddress_zipaddress_stateaddress_cityaddress_streetreceiver_emailreceiver_idresidence_countryitem_nameitem_name1item_numberitem_number1quantityquantity1taxmc_currencymc_feemc_grossmc_gross1mc_handlingmc_handling1mc_shippingmc_shipping1txn_typenotify_versioncustominvoicecharsetverify_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]timestamp=[timestamp][/append] [!]-- Echo back to paypal & get response --[/!] [text]content=[!] [/!][formvariables][name]=[url][value][/url]&[/formvariables]cmd=_notify-validate[!] [/!][/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_currency¬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¬Found=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=Thank 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 Dan Strong

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:

[Repost] Triggers, again (2000) Zip Code Search (2000) search form problem.. (1997) [include ...] behavior (1997) Dealer locator (1998) FW: weird problem (2004) Multiple prices (1997) [ConvertChars] problem (1997) Limiting [FoundItems] (2000) OH MY GOD! (1998) really wierd browser truncating (1997) spaces in [texta] (1998) Special characters in field names (1998) PCS Frames (1997) using showpage and showcart commands (1996) Ensuring data gets passed to shopping cart (2000) WebCat2 beta 11 - new prefs ... (1997) unique ID (1997) [WebDNA] after latest OSX upgrade, WebDNA not running? (2011) test (2006)