コード例 #1
0
def delayed_capture(order_number, pnref=None, amt=None):
    """
    Capture funds that have been previously authorized.

    Notes:

    * It's possible to capture a lower amount than the original auth
      transaction - however...
    * ...only one delayed capture is allowed for a given PNREF...
    * ...If multiple captures are required, a 'reference transaction' needs to be
      used.
    * It's safe to retry captures if the first one fails or errors

    :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 pnref is None:
        # No PNREF specified, look-up the auth transaction for this order number
        # to get the PNREF from there.
        try:
            auth_txn = models.PayflowTransaction.objects.get(
                comment1=order_number, trxtype=codes.AUTHORIZATION)
        except models.PayflowTransaction.DoesNotExist:
            raise exceptions.UnableToTakePayment(
                "No authorization transaction found with PNREF=%s" % pnref)
        pnref = auth_txn

    txn = gateway.delayed_capture(order_number, pnref, amt)
    if not txn.is_approved:
        raise exceptions.UnableToTakePayment(txn.respmsg)
    return txn
コード例 #2
0
ファイル: facade.py プロジェクト: kchudy/django-oscar-paypal
def delayed_capture(order_number, pnref=None, amt=None):
    """
    Capture funds that have been previously authorized.

    Notes:

    * It's possible to capture a lower amount than the original auth
      transaction - however...
    * ...only one delayed capture is allowed for a given PNREF...
    * ...If multiple captures are required, a 'reference transaction' needs to be
      used.
    * It's safe to retry captures if the first one fails or errors

    :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 pnref is None:
        # No PNREF specified, look-up the auth transaction for this order number
        # to get the PNREF from there.
        try:
            auth_txn = models.PayflowTransaction.objects.get(
                comment1=order_number, trxtype=codes.AUTHORIZATION)
        except models.PayflowTransaction.DoesNotExist:
            raise exceptions.UnableToTakePayment(
                "No authorization transaction found with PNREF=%s" % pnref)
        pnref = auth_txn

    txn = gateway.delayed_capture(order_number, pnref, amt)
    if not txn.is_approved:
        raise exceptions.UnableToTakePayment(txn.respmsg)
    return txn
コード例 #3
0
    def test_auth_then_delayed_capture(self):
        params = {
            'first_name': 'Barry',
            'last_name': 'Chuckle',
            'street': '1 Road',
            'city': 'Liverpool',
            'zip': 'L1 9ET',
        }
        auth_txn = gateway.authorize('1234', '4111111111111111', '123', '1219',
                                     D('12.99'), **params)
        capture_txn = gateway.delayed_capture('1234', auth_txn.pnref)

        self.assertTrue(capture_txn.is_approved)
コード例 #4
0
    def test_auth_then_delayed_capture(self):
        params = {
            'first_name': 'Barry',
            'last_name': 'Chuckle',
            'street': '1 Road',
            'city': 'Liverpool',
            'zip': 'L1 9ET',
        }
        auth_txn = gateway.authorize(
            '1234', '4111111111111111', '123', '1219', D('12.99'),
            **params)
        capture_txn = gateway.delayed_capture('1234', auth_txn.pnref)

        self.assertTrue(capture_txn.is_approved)