Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
codeinthehole committed Oct 3, 2012
2 parents 28ec02e + ea1af28 commit 09b8af4
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 12 deletions.
4 changes: 4 additions & 0 deletions README.rst
Expand Up @@ -36,6 +36,10 @@ The package is released under the new BSD license.
Changelog
---------

0.2.5
~~~~~
* Fix silly bug with reference transactions

0.2.4
~~~~~
* Fix bug with installing templates
Expand Down
2 changes: 1 addition & 1 deletion paypal/__init__.py
@@ -1 +1 @@
VERSION = '0.2.4'
VERSION = '0.2.5'
8 changes: 4 additions & 4 deletions paypal/payflow/facade.py
Expand Up @@ -131,15 +131,15 @@ def referenced_sale(order_number, pnref, amt):
payment details.
2. It allows an initial authorisation to be settled in multiple parts. The
first settle should use delayed_capture but any subsequent ones should use this method.
first settle should use delayed_capture but any subsequent ones should
use this method.
:order_number: Order number.
:pnref: PNREF of a previous transaction to use.
:amt: The amount to settle for.
"""
txn = gateway.reference_transaction(order_number,
pnref,
amt)
txn = gateway.reference_transaction(
order_number, pnref, amt)
if not txn.is_approved:
raise exceptions.UnableToTakePayment(txn.respmsg)
return txn
Expand Down
9 changes: 6 additions & 3 deletions paypal/payflow/gateway.py
Expand Up @@ -89,7 +89,8 @@ def reference_transaction(order_number, pnref, amt):
"""
params = {
'COMMENT1': order_number,
# Use SALE as we are effectively authorisating and settling a new transaction
# Use SALE as we are effectively authorising and settling a new
# transaction
'TRXTYPE': codes.SALE,
'ORIGID': pnref,
'AMT': amt,
Expand Down Expand Up @@ -136,7 +137,7 @@ def _transaction(extra_params):
# Validate constraints on parameters
constraints = {
codes.AUTHORIZATION: ('ACCT', 'AMT', 'EXPDATE'),
codes.SALE: ('ACCT', 'AMT', 'EXPDATE'),
codes.SALE: ('AMT',),
codes.DELAYED_CAPTURE: ('ORIGID',),
codes.CREDIT: ('ORIGID',),
codes.VOID: ('ORIGID',),
Expand Down Expand Up @@ -170,7 +171,8 @@ def _transaction(extra_params):
# Ensure that any amounts have a currency and are formatted correctly
if 'AMT' in params:
if 'CURRENCY' not in params:
params['CURRENCY'] = getattr(settings, 'PAYPAL_PAYFLOW_CURRENCY', 'USD')
params['CURRENCY'] = getattr(settings,
'PAYPAL_PAYFLOW_CURRENCY', 'USD')
params['AMT'] = "%.2f" % params['AMT']

if getattr(settings, 'PAYPAL_PAYFLOW_PRODUCTION_MODE', False):
Expand All @@ -183,6 +185,7 @@ def _transaction(extra_params):
pairs = gateway.post(url, params)

# Beware - this log information will contain the Payflow credentials
# only use it in development, not production.
logger.debug("Raw request: %s", pairs['_raw_request'])
logger.debug("Raw response: %s", pairs['_raw_response'])

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Expand Up @@ -5,3 +5,4 @@ django-nose==1.0
nose==1.1.2
django-extensions==0.8
django-debug-toolbar==0.9.4
pinocchio==0.3.1
9 changes: 5 additions & 4 deletions runtests.py
Expand Up @@ -64,15 +64,15 @@
),
DEBUG=False,
SOUTH_TESTS_MIGRATE=False,
HAYSTACK_CONNECTIONS = {
HAYSTACK_CONNECTIONS={
'default': {
'ENGINE': 'haystack.backends.simple_backend.SimpleEngine',
},
},
TEMPLATE_DIRS = (OSCAR_MAIN_TEMPLATE_DIR,),
TEMPLATE_DIRS=(OSCAR_MAIN_TEMPLATE_DIR,),
SITE_ID=1,
ROOT_URLCONF='tests.urls',
NOSE_ARGS=['-s'],
NOSE_ARGS=['-s', '--with-spec'],
**extra_settings
)

Expand All @@ -88,7 +88,7 @@ def run_tests(*test_args):
test_args = ['tests']

# Run tests
test_runner = NoseTestSuiteRunner(verbosity=2)
test_runner = NoseTestSuiteRunner(verbosity=1)

c = coverage(source=['paypal'], omit=['*migrations*', '*tests*'])
c.start()
Expand All @@ -100,6 +100,7 @@ def run_tests(*test_args):
print "Generating HTML coverage report"
c.html_report()


def generate_migration():
from south.management.commands.schemamigration import Command
com = Command()
Expand Down
16 changes: 16 additions & 0 deletions tests/unit/payflow/gateway_tests.py
Expand Up @@ -65,3 +65,19 @@ def test_error_handled_gracefully(self):
cvv='123',
expiry_date='0113',
amt=D('10.8000'))


class TestReferenceTransaction(TestCase):

def test_for_smoke(self):
with mock.patch('paypal.gateway.post') as mock_post:
mock_post.return_value = {
'RESULT': '1',
'RESPMSG': '',
'_raw_request': '',
'_raw_response': '',
'_response_time': 1000
}
gateway.reference_transaction(order_number='12345',
pnref='111222',
amt=D('12.23'))

0 comments on commit 09b8af4

Please sign in to comment.