set the expiry date based on the campaign deadline. There is a setting PREAPPROVAL_PERIOD_AFTER_CAMPAIGN for specifying how many days after the campaign deadline should we ask for a preapproval deadline. I've put in 90 days.
parent
47399ab23a
commit
c055767173
|
@ -265,7 +265,9 @@ class PledgeView(FormView):
|
|||
|
||||
return_url = self.request.build_absolute_uri(reverse('work',kwargs={'work_id': str(work_id)}))
|
||||
# the recipients of this authorization is not specified here but rather by the PaymentManager.
|
||||
t, url = p.authorize('USD', TARGET_TYPE_CAMPAIGN, preapproval_amount, campaign=campaign, list=None, user=user,
|
||||
# set the expiry date based on the campaign deadline
|
||||
expiry = campaign.deadline + datetime.timedelta( days=settings.PREAPPROVAL_PERIOD_AFTER_CAMPAIGN )
|
||||
t, url = p.authorize('USD', TARGET_TYPE_CAMPAIGN, preapproval_amount, expiry=expiry, campaign=campaign, list=None, user=user,
|
||||
return_url=return_url, anonymous=anonymous)
|
||||
else: # embedded view -- which we're not actively using right now.
|
||||
# embedded view triggerws instant payment: send to the partnering RH
|
||||
|
@ -606,10 +608,13 @@ class CampaignFormView(FormView):
|
|||
# calculate the work corresponding to the campaign id
|
||||
work_id = campaign.work.id
|
||||
|
||||
# set the expiry date based on the campaign deadline
|
||||
expiry = campaign.deadline + datetime.timedelta( days=settings.PREAPPROVAL_PERIOD_AFTER_CAMPAIGN )
|
||||
|
||||
if not self.embedded:
|
||||
|
||||
return_url = self.request.build_absolute_uri(reverse('work',kwargs={'work_id': str(work_id)}))
|
||||
t, url = p.authorize('USD', TARGET_TYPE_CAMPAIGN, preapproval_amount, campaign=campaign, list=None, user=user,
|
||||
t, url = p.authorize('USD', TARGET_TYPE_CAMPAIGN, preapproval_amount, expiry=expiry, campaign=campaign, list=None, user=user,
|
||||
return_url=return_url, anonymous=anonymous)
|
||||
else:
|
||||
# instant payment: send to the partnering RH
|
||||
|
|
|
@ -475,7 +475,7 @@ class PaymentManager( object ):
|
|||
logger.info("Cancel Transaction " + str(transaction.id) + " Failed with error: " + p.error_string())
|
||||
return False
|
||||
|
||||
def authorize(self, currency, target, amount, campaign=None, list=None, user=None, return_url=None, cancel_url=None, anonymous=False):
|
||||
def authorize(self, currency, target, amount, expiry=None, campaign=None, list=None, user=None, return_url=None, cancel_url=None, anonymous=False):
|
||||
'''
|
||||
authorize
|
||||
|
||||
|
@ -505,7 +505,7 @@ class PaymentManager( object ):
|
|||
anonymous=anonymous
|
||||
)
|
||||
|
||||
p = Preapproval(t, amount, return_url=return_url, cancel_url=cancel_url)
|
||||
p = Preapproval(t, amount, expiry, return_url=return_url, cancel_url=cancel_url)
|
||||
|
||||
# Create a response for this
|
||||
envelope = p.envelope()
|
||||
|
|
|
@ -510,7 +510,7 @@ class CancelPreapproval(PaypalEnvelopeRequest):
|
|||
|
||||
|
||||
class Preapproval( PaypalEnvelopeRequest ):
|
||||
def __init__( self, transaction, amount, return_url=None, cancel_url=None):
|
||||
def __init__( self, transaction, amount, expiry=None, return_url=None, cancel_url=None):
|
||||
|
||||
try:
|
||||
|
||||
|
@ -528,8 +528,9 @@ class Preapproval( PaypalEnvelopeRequest ):
|
|||
if cancel_url is None:
|
||||
cancel_url = settings.BASE_URL + CANCEL_URL
|
||||
|
||||
# set the expiration date for the preapproval
|
||||
# set the expiration date for the preapproval if not passed in
|
||||
now = datetime.datetime.utcnow()
|
||||
if expiry is None:
|
||||
expiry = now + datetime.timedelta( days=settings.PREAPPROVAL_PERIOD )
|
||||
transaction.date_authorized = now
|
||||
transaction.date_expired = expiry
|
||||
|
|
|
@ -76,6 +76,7 @@ PAYPAL_BUYER_PASSWORD = ''
|
|||
# The amount of the transaction that Gluejar takes
|
||||
GLUEJAR_COMMISSION = 0.06
|
||||
PREAPPROVAL_PERIOD = 365 # days to ask for in a preapproval
|
||||
PREAPPROVAL_PERIOD_AFTER_CAMPAIGN = 90 # if we ask for preapproval time after a campaign deadline
|
||||
|
||||
# in live system, replace with the real Gluejar paypal email and that for our non-profit partner
|
||||
PAYPAL_GLUEJAR_EMAIL = "glueja_1317336101_biz@gluejar.com"
|
||||
|
|
|
@ -70,6 +70,7 @@ PAYPAL_BUYER_PASSWORD = ''
|
|||
# The amount of the transaction that Gluejar takes
|
||||
GLUEJAR_COMMISSION = 0.06
|
||||
PREAPPROVAL_PERIOD = 365 # days to ask for in a preapproval
|
||||
PREAPPROVAL_PERIOD_AFTER_CAMPAIGN = 90 # if we ask for preapproval time after a campaign deadline
|
||||
|
||||
# in live system, replace with the real Gluejar paypal email and that for our non-profit partner
|
||||
PAYPAL_GLUEJAR_EMAIL = "glueja_1317336101_biz@gluejar.com"
|
||||
|
|
Loading…
Reference in New Issue