예제 #1
0
    def refund_transaction(self, transactionid=None, payerid=None, **kwargs):
        """Shortcut for RefundTransaction method.
           Note new API supports passing a PayerID instead of a transaction id, exactly one must be provided.
           Optional:
               INVOICEID
               REFUNDTYPE
               AMT
               CURRENCYCODE
               NOTE
               RETRYUNTIL
               REFUNDSOURCE
               MERCHANTSTOREDETAILS
               REFUNDADVICE
               REFUNDITEMDETAILS
               MSGSUBID

           MERCHANSTOREDETAILS has two fields:
               STOREID
               TERMINALID
           """
        #this line seems like a complete waste of time... kwargs should not be populated
        if (transactionid is None) and (payerid is None):
            raise PayPalError('RefundTransaction requires either a transactionid or a payerid')
        if (transactionid is not None) and (payerid is not None):
            raise PayPalError('RefundTransaction requires only one of transactionid %s and payerid %s' % (transactionid, payerid))
        if transactionid is not None:
            kwargs['TRANSACTIONID'] = transactionid
        else:
            kwargs['PAYERID'] = payerid

        return self._call('RefundTransaction', **kwargs)
예제 #2
0
 def _check_required(self, requires, **kwargs):
     """
     Checks kwargs for the values specified in 'requires', which is a tuple
     of strings. These strings are the NVP names of the required values.
     """
     for req in requires:
         # PayPal api is never mixed-case.
         if req.lower() not in kwargs and req.upper() not in kwargs:
             raise PayPalError('missing required : %s' % req)