diff options
Diffstat (limited to 'postgresqleu/paypal/util.py')
-rw-r--r-- | postgresqleu/paypal/util.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/postgresqleu/paypal/util.py b/postgresqleu/paypal/util.py index d9c2e4c3..03934a14 100644 --- a/postgresqleu/paypal/util.py +++ b/postgresqleu/paypal/util.py @@ -49,3 +49,20 @@ class PaypalAPI(object): return self._api_call('GetTransactionDetails', { 'TRANSACTIONID': transactionid, }) + + + def refund_transaction(self, paypaltransid, amount, isfull, refundnote): + r = self._api_call('RefundTransaction', { + 'TRANSACTIONID': paypaltransid, + 'REFUNDTYPE': isfull and 'Full' or 'Partial', + 'AMT': '{0:.2f}'.format(amount), + 'CURRENCYCODE': settings.CURRENCY_ISO, + 'NOTE': refundnote, + }) + + # We ignore the status here as we will parse it from the + # actual statement later. + if r['ACK'][0] == 'Success': + return r['REFUNDTRANSACTIONID'][0] + + raise Exception(r) |