Exemplo n.º 1
0
def credit(order_number, pnref=None, amt=None):
    """
    Return funds that have been previously settled.

    :order_number: Order number
    :pnref: The PNREF of the authorization transaction to use.  If not
            specified, the order number is used to retrieve the appropriate transaction.
    :amt: A custom amount to capture.  If not specified, the entire transaction
          is refuneded.
    """
    if pnref is None:
        # No PNREF specified, look-up the auth/sale transaction for this order number
        # to get the PNREF from there.
        try:
            auth_txn = models.PayflowTransaction.objects.get(
                comment1=order_number,
                trxtype__in=(codes.AUTHORIZATION, codes.SALE))
        except models.PayflowTransaction.DoesNotExist:
            raise exceptions.UnableToTakePayment(
                "No authorization transaction found with PNREF=%s" % pnref)
        pnref = auth_txn

    txn = gateway.credit(order_number, pnref, amt)
    if not txn.is_approved:
        raise exceptions.PaymentError(txn.respmsg)
    return txn
Exemplo n.º 2
0
def credit(order_number, pnref=None, amt=None):
    """
    Return funds that have been previously settled.

    :order_number: Order number
    :pnref: The PNREF of the authorization transaction to use.  If not
            specified, the order number is used to retrieve the appropriate transaction.
    :amt: A custom amount to capture.  If not specified, the entire transaction
          is refuneded.
    """
    if pnref is None:
        # No PNREF specified, look-up the auth/sale transaction for this order number
        # to get the PNREF from there.
        try:
            auth_txn = models.PayflowTransaction.objects.get(
                comment1=order_number, trxtype__in=(codes.AUTHORIZATION,
                                                    codes.SALE))
        except models.PayflowTransaction.DoesNotExist:
            raise exceptions.UnableToTakePayment(
                "No authorization transaction found with PNREF=%s" % pnref)
        pnref = auth_txn

    txn = gateway.credit(order_number, pnref, amt)
    if not txn.is_approved:
        raise exceptions.PaymentError(txn.respmsg)
    return txn
Exemplo n.º 3
0
    def test_credit_after_sale(self):
        sale_txn = gateway.sale('1234', '4111111111111111', '123', '1213',
                                D('12.99'))
        credit_txn = gateway.credit('1234', sale_txn.pnref)

        # Normally this fails as the auth_txn is not approved
        self.assertFalse(credit_txn.is_approved)
 def test_credit_after_sale(self):
     sale_txn = gateway.sale(
         '1234', '4111111111111111', '123', '1219', D('12.99'))
     credit_txn = gateway.credit('1234', sale_txn.pnref)
     self.assertTrue(credit_txn.is_approved)
    def test_credit_after_sale(self):
        sale_txn = gateway.sale('1234', '4111111111111111', '123', '1213', D('12.99'))
        credit_txn = gateway.credit('1234', sale_txn.pnref)

        # Normally this fails as the auth_txn is not approved
        self.assertFalse(credit_txn.is_approved)
Exemplo n.º 6
0
 def test_credit_after_sale(self):
     sale_txn = gateway.sale('1234', '4111111111111111', '123', '1219',
                             D('12.99'))
     credit_txn = gateway.credit('1234', sale_txn.pnref)
     self.assertTrue(credit_txn.is_approved)