Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

small update to use of sandbox #8

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions paypal/pro/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
from paypal.pro.models import PayPalNVP, L
from paypal.pro.exceptions import PayPalFailure

TEST = settings.PAYPAL_TEST
USER = settings.PAYPAL_WPP_USER
TEST = getattr(settings, "PAYPAL_TEST", settings.DEBUG)
USER = settings.PAYPAL_WPP_USER
PASSWORD = settings.PAYPAL_WPP_PASSWORD
SIGNATURE = settings.PAYPAL_WPP_SIGNATURE
VERSION = 54.0
Expand Down
4 changes: 2 additions & 2 deletions paypal/standard/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

class PayPalSettingsError(Exception):
"""Raised when settings be bad."""


TEST = getattr(settings, "PAYPAL_TEST", True)

TEST = getattr(settings, "PAYPAL_TEST", settings.DEBUG)


RECEIVER_EMAIL = settings.PAYPAL_RECEIVER_EMAIL
Expand Down
17 changes: 7 additions & 10 deletions paypal/standard/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from django.utils.safestring import mark_safe
from paypal.standard.conf import *
from paypal.standard.widgets import ValueHiddenInput, ReservedValueHiddenInput
from paypal.standard.conf import (POSTBACK_ENDPOINT, SANDBOX_POSTBACK_ENDPOINT,
RECEIVER_EMAIL)
from paypal.standard.conf import (POSTBACK_ENDPOINT, SANDBOX_POSTBACK_ENDPOINT,
RECEIVER_EMAIL, TEST)


# 20:18:05 Jan 30, 2009 PST - PST timezone support is not included out of the box.
Expand Down Expand Up @@ -100,17 +100,14 @@ def __init__(self, button_type="buy", *args, **kwargs):
self.button_type = button_type

def render(self):
if TEST:
postback_endpoint = SANDBOX_POSTBACK_ENDPOINT
else:
postback_endpoint = POSTBACK_ENDPOINT
return mark_safe(u"""<form action="%s" method="post">
%s
<input type="image" src="%s" border="0" name="submit" alt="Buy it Now" />
</form>""" % (POSTBACK_ENDPOINT, self.as_p(), self.get_image()))


def sandbox(self):
return mark_safe(u"""<form action="%s" method="post">
%s
<input type="image" src="%s" border="0" name="submit" alt="Buy it Now" />
</form>""" % (SANDBOX_POSTBACK_ENDPOINT, self.as_p(), self.get_image()))
</form>""" % (postback_endpoint, self.as_p(), self.get_image()))

def get_image(self):
return {
Expand Down
2 changes: 1 addition & 1 deletion paypal/standard/ipn/templates/ipn/paypal.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<body>


{{ form.sandbox }}
{{ form.render }}


</body>
Expand Down
4 changes: 2 additions & 2 deletions paypal/standard/pdt/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from django.http import QueryDict
from django.utils.http import urlencode
from paypal.standard.models import PayPalStandardBase
from paypal.standard.conf import POSTBACK_ENDPOINT, SANDBOX_POSTBACK_ENDPOINT
from paypal.standard.conf import POSTBACK_ENDPOINT, SANDBOX_POSTBACK_ENDPOINT, TEST
from paypal.standard.pdt.signals import pdt_successful, pdt_failed

# ### Todo: Move this logic to conf.py:
Expand Down Expand Up @@ -48,7 +48,7 @@ def _postback(self):

def get_endpoint(self):
"""Use the sandbox when in DEBUG mode as we don't have a test_ipn variable in pdt."""
if getattr(settings, 'PAYPAL_DEBUG', settings.DEBUG):
if TEST:
return SANDBOX_POSTBACK_ENDPOINT
else:
return POSTBACK_ENDPOINT
Expand Down