Skip to content
This repository has been archived by the owner on May 10, 2019. It is now read-only.

Commit

Permalink
Merge pull request #1 from fmr/master
Browse files Browse the repository at this point in the history
bankcard date format, etc.
  • Loading branch information
Jonathan Moss committed Aug 9, 2012
2 parents 47cdd3c + 8a40adc commit 03d3c7c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
6 changes: 1 addition & 5 deletions paymentexpress/__init__.py
@@ -1,5 +1 @@
'''
Created on May 11, 2012
@author: reyesf
'''
PAYMENTEXPRESS = 'PaymentExpress'
25 changes: 19 additions & 6 deletions paymentexpress/facade.py
Expand Up @@ -69,17 +69,25 @@ def _handle_response(self, txn_type, order_number, amount, response):
else:
raise InvalidGatewayRequestError(response.get_message())

def _format_card_date(self, str_date):
# Dirty hack so that Oscar's BankcardForm doesn't need to be overridden
return str_date.replace('/', '')

def authorise(self, order_number, amount, bankcard):
"""
Authorizes a transaction.
Must be completed within 7 days using the "Complete" TxnType
"""
self._check_amount(amount)

card_issue_date = self._format_card_date(bankcard.start_date)
card_expiry_date = self._format_card_date(bankcard.expiry_date)

merchant_ref = self._get_merchant_reference(order_number, AUTH)
res = self.gateway.authorise(card_holder=bankcard.card_holder_name,
card_number=bankcard.card_number,
card_expiry=bankcard.expiry_date,
card_issue_date=bankcard.start_date,
card_issue_date=card_issue_date,
card_expiry=card_expiry_date,
cvc2=bankcard.cvv,
amount=amount,
merchant_ref=merchant_ref)
Expand Down Expand Up @@ -112,11 +120,13 @@ def purchase(self, order_number, amount, billing_id=None, bankcard=None):
billing_id=billing_id,
merchant_ref=merchant_ref)
elif bankcard:
card_issue_date = self._format_card_date(bankcard.start_date)
card_expiry_date = self._format_card_date(bankcard.expiry_date)
res = self.gateway.purchase(amount=amount,
card_holder=bankcard.card_holder_name,
card_number=bankcard.card_number,
card_expiry=bankcard.expiry_date,
card_issue_date=bankcard.start_date,
card_issue_date=card_issue_date,
card_expiry=card_expiry_date,
cvc2=bankcard.cvv,
merchant_ref=merchant_ref,
enable_add_bill_card=1)
Expand Down Expand Up @@ -146,11 +156,14 @@ def validate(self, bankcard):
automatically add to Billing Database if the transaction is approved.
"""
amount = 1.00
card_issue_date = self._format_card_date(bankcard.start_date)
card_expiry_date = self._format_card_date(bankcard.expiry_date)

res = self.gateway.validate(amount=amount,
card_holder=bankcard.card_holder_name,
card_number=bankcard.card_number,
card_expiry=bankcard.expiry_date,
card_issue_date=bankcard.start_date,
card_issue_date=card_issue_date,
card_expiry=card_expiry_date,
cvc2=bankcard.cvv,
enable_add_bill_card=1)
return self._handle_response(VALIDATE, None, amount, res)

0 comments on commit 03d3c7c

Please sign in to comment.