Beispiel #1
0
def create(request):
    client = get_client().Transaction
    form = SaleForm(request.DATA)

    if not form.is_valid():
        raise FormError(form.errors)

    result = client.sale(form.braintree_data)
    if not result.is_success:
        log.warning('Error on one-off sale: {}'.format(form.braintree_data))
        raise BraintreeResultError(result)

    our_transaction = Transaction.objects.create(
        amount=result.transaction.amount,
        buyer=form.buyer,
        currency=result.transaction.currency_iso_code,
        provider=constants.PROVIDER_BRAINTREE,
        seller=form.seller_product.seller,
        seller_product=form.seller_product,
        status=constants.STATUS_CHECKED,
        type=constants.TYPE_PAYMENT,
        uid_support=result.transaction.id
    )
    our_transaction.uuid = our_transaction.create_short_uid()
    our_transaction.save()
    log.info('Transaction created: {}'.format(our_transaction.pk))

    braintree_transaction = BraintreeTransaction.objects.create(
        kind='submit_for_settlement',
        paymethod=form.cleaned_data['paymethod'],
        transaction=our_transaction,

    )
    log.info('BraintreeTransaction created: {}'
             .format(braintree_transaction.pk))

    res = Namespaced(
        braintree={},  # Not sure if there's anything useful to add here.
        mozilla={
            'braintree': LocalTransaction(braintree_transaction),
            'generic': TransactionSerializer(our_transaction)
        }
    )
    return Response(res.data, status=200)
Beispiel #2
0
def create(request):
    client = get_client().Transaction
    form = SaleForm(request.DATA)

    if not form.is_valid():
        raise FormError(form.errors)

    result = client.sale(form.braintree_data)
    if not result.is_success:
        log.warning('Error on one-off sale: {}'.format(form.braintree_data))
        raise BraintreeResultError(result)

    our_transaction = Transaction.objects.create(
        amount=result.transaction.amount,
        buyer=form.buyer,
        currency=result.transaction.currency_iso_code,
        provider=constants.PROVIDER_BRAINTREE,
        seller=form.seller_product.seller,
        seller_product=form.seller_product,
        status=constants.STATUS_CHECKED,
        type=constants.TYPE_PAYMENT,
        uid_support=result.transaction.id)
    our_transaction.uuid = our_transaction.create_short_uid()
    our_transaction.save()
    log.info('Transaction created: {}'.format(our_transaction.pk))

    braintree_transaction = BraintreeTransaction.objects.create(
        kind='submit_for_settlement',
        paymethod=form.cleaned_data['paymethod'],
        transaction=our_transaction,
    )
    log.info('BraintreeTransaction created: {}'.format(
        braintree_transaction.pk))

    res = Namespaced(
        braintree={},  # Not sure if there's anything useful to add here.
        mozilla={
            'braintree': LocalTransaction(braintree_transaction),
            'generic': TransactionSerializer(our_transaction)
        })
    return Response(res.data, status=200)
Beispiel #3
0
 def process(self, data):
     form = SaleForm(data)
     form.is_valid()
     return form, form.errors
Beispiel #4
0
 def process(self, data):
     form = SaleForm(data)
     form.is_valid()
     return form, form.errors