[Checkins] SVN: zc.authorizedotnet/trunk/src/zc/authorizedotnet/
Added credit (refund) support. Unfortunately it's impossible
to test it
Albertas Agejevas
alga at pov.lt
Tue Jan 2 13:00:29 EST 2007
Log message for revision 71687:
Added credit (refund) support. Unfortunately it's impossible to test it
with a live server, as this requires a transaction to be settled.
I did make sure crediting works in principle, by finding a settled test
transaction and refunding it.
Changed:
U zc.authorizedotnet/trunk/src/zc/authorizedotnet/README.txt
U zc.authorizedotnet/trunk/src/zc/authorizedotnet/processing.py
U zc.authorizedotnet/trunk/src/zc/authorizedotnet/tests.py
-=-
Modified: zc.authorizedotnet/trunk/src/zc/authorizedotnet/README.txt
===================================================================
--- zc.authorizedotnet/trunk/src/zc/authorizedotnet/README.txt 2007-01-02 14:51:01 UTC (rev 71686)
+++ zc.authorizedotnet/trunk/src/zc/authorizedotnet/README.txt 2007-01-02 18:00:28 UTC (rev 71687)
@@ -50,7 +50,7 @@
To authorize a charge use the ``authorize`` method. It returns a
``Transaction`` object.
- >>> result = cc.authorize(amount='1.00', card_num='4007000000027',
+ >>> result = cc.authorize(amount='2.00', card_num='4007000000027',
... exp_date='0530')
The result object contains details about the transaction.
@@ -61,6 +61,7 @@
'This transaction has been approved.'
>>> result.approval_code
'123456'
+ >>> auth_trans_id = result.trans_id
>>> result.trans_id
'123456789'
@@ -82,28 +83,50 @@
'approved'
The server shows that the transaction has been captured and is awaiting
-setttlement:
+settlement:
>>> transactions = server.getTransactions()
>>> transactions[result.trans_id]
'Captured/Pending Settlement'
+Credit (refund) transactions
+----------------------------
+
+A previosly credited transaction can be refunded. The amount of the
+refund cannot exceed the amount captured. At least the last four
+digits of the credit card number must be provided, along with the
+transaction id.
+
+Credit will only work when the transaction has been settled by the
+banks, that is if we try refunding immediately, it will fail:
+
+ >>> result = cc.credit(trans_id=auth_trans_id,
+ ... card_num='4007000000027',
+ ... exp_date='0530',
+ ... amount='1.00',
+ ... )
+ >>> result.response_reason
+ 'The referenced transaction does not meet the criteria for issuing a credit.'
+ >>> result.response
+ 'error'
+
+
Voiding Transactions
--------------------
If we need to stop a transaction that has not yet been completed (like the
-capturing of the authorized transaction above) we can do so with the ``void``
+crediting of the captured transaction above) we can do so with the ``void``
method.
- >>> result = cc.void(trans_id=result.trans_id)
+ >>> result = cc.void(trans_id=auth_trans_id)
>>> result.response
'approved'
The server shows that the transaction was voided:
>>> transactions = server.getTransactions()
- >>> transactions[result.trans_id]
+ >>> transactions[auth_trans_id]
'Voided'
@@ -113,7 +136,7 @@
If something about the transaction is erroneous, the transaction results
indicate so.
- >>> result = cc.authorize(amount='2.00', card_num='4007000000027',
+ >>> result = cc.authorize(amount='2.50', card_num='4007000000027',
... exp_date='0599')
The result object reflecs the error.
Modified: zc.authorizedotnet/trunk/src/zc/authorizedotnet/processing.py
===================================================================
--- zc.authorizedotnet/trunk/src/zc/authorizedotnet/processing.py 2007-01-02 14:51:01 UTC (rev 71686)
+++ zc.authorizedotnet/trunk/src/zc/authorizedotnet/processing.py 2007-01-02 18:00:28 UTC (rev 71687)
@@ -186,6 +186,10 @@
type = 'PRIOR_AUTH_CAPTURE'
return self.connection.sendTransaction(type=type, **kws)
+ def credit(self, **kws):
+ type = 'CREDIT'
+ return self.connection.sendTransaction(type=type, **kws)
+
def void(self, **kws):
type = 'VOID'
return self.connection.sendTransaction(type=type, **kws)
Modified: zc.authorizedotnet/trunk/src/zc/authorizedotnet/tests.py
===================================================================
--- zc.authorizedotnet/trunk/src/zc/authorizedotnet/tests.py 2007-01-02 14:51:01 UTC (rev 71686)
+++ zc.authorizedotnet/trunk/src/zc/authorizedotnet/tests.py 2007-01-02 18:00:28 UTC (rev 71687)
@@ -176,6 +176,17 @@
return out
+ def CREDIT(self, fields):
+ trans_id = fields.getvalue('x_trans_id')
+
+ response_code = '3'
+ reason_text = 'The referenced transaction does not meet the criteria for issuing a credit.'
+ approval_code = '123456'
+ out = self.makeOut(response_code, reason_text, approval_code,
+ trans_id, amount='')
+ in_process_server.info[trans_id] = 'XXX'
+ return out
+
def VOID(self, fields):
trans_id = fields.getvalue('x_trans_id')
@@ -245,6 +256,7 @@
conn.getresponse()
http_server.thread.join()
+
def remoteSetUp(test):
login = os.environ.get('AUTHORIZE_DOT_NET_LOGIN')
password = os.environ.get('AUTHORIZE_DOT_NET_PASSWORD')
@@ -262,6 +274,8 @@
test.globs['LOGIN'] = login
test.globs['KEY'] = key
+
+
def remoteTearDown(test):
test.globs['server'].close()
@@ -295,7 +309,7 @@
)
unit = doctest.DocTestSuite('zc.authorizedotnet.processing',
optionflags=doctest.ELLIPSIS)
- return unittest.TestSuite((remote, local, unit))
+ return unittest.TestSuite((local, remote, unit))
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
More information about the Checkins
mailing list