Added a paypal unsubscribe button. Also added a paypal banner image.
This commit is contained in:
parent
d0362a3ad1
commit
7d2e2e4de2
|
@ -55,5 +55,8 @@ settings = {
|
||||||
# "fee": 19,
|
# "fee": 19,
|
||||||
# },
|
# },
|
||||||
],
|
],
|
||||||
|
"luminotes.unsubscribe_button":
|
||||||
|
"""
|
||||||
|
""",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -267,6 +267,7 @@ class Root( object ):
|
||||||
object_id = u"upgrade",
|
object_id = u"upgrade",
|
||||||
contents = unicode( Upgrade_note(
|
contents = unicode( Upgrade_note(
|
||||||
self.__settings[ u"global" ].get( u"luminotes.rate_plans", [] ),
|
self.__settings[ u"global" ].get( u"luminotes.rate_plans", [] ),
|
||||||
|
self.__settings[ u"global" ].get( u"luminotes.unsubscribe_button" ),
|
||||||
https_url,
|
https_url,
|
||||||
user,
|
user,
|
||||||
) ),
|
) ),
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
import re
|
import re
|
||||||
|
import urllib
|
||||||
|
import urllib2
|
||||||
import cherrypy
|
import cherrypy
|
||||||
from pytz import utc
|
from pytz import utc
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
@ -97,6 +99,17 @@ class Access_error( Exception ):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class Payment_error( Exception ):
|
||||||
|
def __init__( self, message ):
|
||||||
|
Exception.__init__( self, message )
|
||||||
|
self.__message = message
|
||||||
|
|
||||||
|
def to_dict( self ):
|
||||||
|
return dict(
|
||||||
|
error = self.__message
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def grab_user_id( function ):
|
def grab_user_id( function ):
|
||||||
"""
|
"""
|
||||||
A decorator to grab the current logged in user id from the cherrypy session and pass it as a
|
A decorator to grab the current logged in user id from the cherrypy session and pass it as a
|
||||||
|
@ -955,4 +968,29 @@ class Users( object ):
|
||||||
|
|
||||||
self.__database.commit()
|
self.__database.commit()
|
||||||
|
|
||||||
# def paypal_notify( self, **data ):
|
@expose()
|
||||||
|
def paypal_notify( self, **params ):
|
||||||
|
PAYPAL_URL = u"https://www.sandbox.paypal.com/cgi-bin/webscr"
|
||||||
|
#PAYPAL_URL = u"https://www.paypal.com/cgi-bin/webscr"
|
||||||
|
|
||||||
|
print params
|
||||||
|
params[ u"cmd" ] = u"_notify-validate"
|
||||||
|
params = urllib.urlencode( params )
|
||||||
|
|
||||||
|
response = urllib2.Request( PAYPAL_URL )
|
||||||
|
response.add_header( u"Content-type", u"application/x-www-form-urlencoded" )
|
||||||
|
response_file = urllib2.urlopen( PAYPAL_URL, params )
|
||||||
|
result = response_file.read()
|
||||||
|
|
||||||
|
if result != u"VERIFIED":
|
||||||
|
raise Payment_error( result )
|
||||||
|
|
||||||
|
print "VERIFIED"
|
||||||
|
|
||||||
|
# TODO: update the database
|
||||||
|
|
||||||
|
return dict()
|
||||||
|
|
||||||
|
@expose()
|
||||||
|
def thanks( self ):
|
||||||
|
pass # TODO
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 8.6 KiB |
|
@ -2,7 +2,7 @@ from Tags import Div, Span, H3, P, A, Table, Tr, Th, Td, Br, Img
|
||||||
|
|
||||||
|
|
||||||
class Upgrade_note( Span ):
|
class Upgrade_note( Span ):
|
||||||
def __init__( self, rate_plans, https_url, user ):
|
def __init__( self, rate_plans, unsubscribe_button, https_url, user ):
|
||||||
MEGABYTE = 1024 * 1024
|
MEGABYTE = 1024 * 1024
|
||||||
|
|
||||||
Span.__init__(
|
Span.__init__(
|
||||||
|
@ -65,6 +65,7 @@ class Upgrade_note( Span ):
|
||||||
user and user.rate_plan > 0 and P(
|
user and user.rate_plan > 0 and P(
|
||||||
u"You're currently subscribed to Luminotes %s." %
|
u"You're currently subscribed to Luminotes %s." %
|
||||||
rate_plans[ user.rate_plan ][ u"name" ].capitalize(),
|
rate_plans[ user.rate_plan ][ u"name" ].capitalize(),
|
||||||
|
unsubscribe_button,
|
||||||
) or None,
|
) or None,
|
||||||
|
|
||||||
H3( u"share your notebook" ),
|
H3( u"share your notebook" ),
|
||||||
|
|
Reference in New Issue