[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:

searching multiple databases in single search (1997) Group search doesn't work. (1997) [WebDNA] v7 help (2012) Re2: frames & carts (1997) Bannerad Demo (1998) pc (1997) emailer (1997) textA (1998) Sku numbers (1997) formvariable funkyness (2000) BannerAds demo (1998) Re:Emailer and encryption (1997) Help Encrypt/Decrypt eMail (2003) Cart -> Date and Time (2004) Menu Syntax on Edit/Add templates (1998) Expiration of Carts (1997) [WebDNA] WebDNA crash and now emailer not working (2009) Strange conversions (2001) WebCat2b13MacPlugIn - [showif][search][/showif] (1997) Webcatalog 4.02b5 Mac OS X headers (2000)