Skip to content

Commit

Permalink
[Beanstream gateway] Adding recurring payment
Browse files Browse the repository at this point in the history
  • Loading branch information
kamotos authored and tuxcanfly committed Dec 2, 2013
1 parent 58c9b91 commit f19c5d1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ Thanks go out to all the contributors listed in alphabetical order:
* Tom Aratyn <[email protected]>
* Venkata Ramana <[email protected]>
* Jordi Llonch <https://github.com/llonchj>
* Zahim Anass <https://github.com/kamotos>
26 changes: 21 additions & 5 deletions billing/gateways/beanstream_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class BeanstreamGateway(Gateway):
("approvedPage", False), # URL (encoded). Unlimited a/n characters. Beanstream provides default approved or declined transaction pages. For a seamless transaction flow, design unique pages and specify the approved transaction redirection URL here.
("declinedPage", False), # URL (encoded). Unlimited a/n characters. Specify the URL for your custom declined transaction notification page here.

("trnCardOwner", True), #* Max 64 a/n characters This field must contain the full name of the card holder exactly as it appears on their credit card.
("trnCardOwner", True), #* Max 64 a/n characters This field must contain the full name of the card holder exactly as it appears on their credit card.
("trnCardNumber", True), # Max 20 digits Capture the customer's credit card number.
("trnExpMonth", True), # 2 digits (January = 01) The card expiry month with January as 01 and December as 12.
("trnExpYear", True), # 2 digits (2011=11) Card expiry years must be entered as a number less than 50. In combination, trnExpYear and trnExpMonth must reflect a date in the future.
Expand Down Expand Up @@ -145,8 +145,8 @@ def purchase(self, money, credit_card, options=None):

def authorize(self, money, credit_card, options=None):
"""Authorization for a future capture transaction"""
# TODO: Need to add check for trnAmount
# For Beanstream Canada and TD Visa & MasterCard merchant accounts this value may be $0 or $1 or more.
# TODO: Need to add check for trnAmount
# For Beanstream Canada and TD Visa & MasterCard merchant accounts this value may be $0 or $1 or more.
# For all other scenarios, this value must be $0.50 or greater.
options = options or {}
order_number = options.get("order_number") if options else None
Expand Down Expand Up @@ -239,7 +239,23 @@ def credit(self, money, identification, options=None):

def recurring(self, money, creditcard, options=None):
"""Setup a recurring transaction"""
raise NotImplementedError
card = self.convert_cc(creditcard)
frequency_period = options['frequency_period']
frequency_increment = options['frequency_increment']
billing_address = options.get('billing_address', None) # must be a beanstream.billing.Address instance

txn = self.beangw.create_recurring_billing_account(
money, card, frequency_period, frequency_increment, billing_address)
resp = self._parse_resp(txn.commit())
if resp["status"] == "SUCCESS":
transaction_was_successful.send(sender=self,
type="recurring",
response=resp["response"])
else:
transaction_was_unsuccessful.send(sender=self,
type="recurring",
response=resp["response"])
return resp

def store(self, credit_card, options=None):
"""Store the credit card and user profile information
Expand All @@ -253,7 +269,7 @@ def store(self, credit_card, options=None):
status = "FAILURE"
response = None
if resp.approved() or resp.resp["responseCode"] == ["17"]:
status = "SUCCESS"
status = "SUCCESS"
else:
response = resp

Expand Down

0 comments on commit f19c5d1

Please sign in to comment.