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:
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:
oops private message leaked into talk list (1997)
searchable list archive (1997)
Mac 2.1b2 speed (1997)
TRAINING videos - Prove IT. (1998)
Showif, Hideif reverse logic ? (1997)
Interactive Online Docs Was: [OT] Mozilla | Was: R.I.P. (2003)
Fileinfo... (2000)
unique ascending numbers (2003)
Validating A Date (2004)
DB permission issues (2004)
Re:2nd WebCatalog2 Feature Request (1996)
Gil's in the lead (1999)
Frames and WebCat (1997)
Database cloning- will the real -oRiGiNaL- please stand up (2003)
Summarising on two fields (1998)
Bug or syntax error on my part? (1997)
[shownext] not displaying anything but first indices found (2000)
Unique SKU Numbers (2000)
Error Lob.db records error message not name (1997)
bypassing typo's (1998)