Beispiel #1
0
def show_checkout(transaction_id):

    # find_transaction uses Braintree gateway to get specific transaction data
    transaction = find_transaction(transaction_id)
    result = {}
    if transaction.status in TRANSACTION_SUCCESS_STATUSES:
        result = {
            'header':
            'Sweet Success!',
            'icon':
            'success',
            'message':
            'Your test transaction has been successfully processed. See the Braintree API response and try again.'
        }
    else:
        result = {
            'header':
            'Transaction Failed',
            'icon':
            'fail',
            'message':
            'Your test transaction has a status of ' + transaction.status +
            '. See the Braintree API response and try again.'
        }
    return render_template('checkouts/show.html',
                           transaction=transaction,
                           result=result)
Beispiel #2
0
def show_refund(transaction_id):
    transaction = find_transaction(transaction_id)
    result = {}
    if transaction.status in TRANSACTION_REFUND_STATUSES:
        result = {
            'header':
            'Successful Refund!',
            'icon':
            'refunding',
            'message':
            'Your test transaction has been successfully refunded. See the Braintree API response and try again.'
        }
    else:
        result = {
            'header':
            'Transaction Failed',
            'icon':
            'fail',
            'message':
            'Your test transaction has a status of ' + transaction.status +
            '. See the Braintree API response and try again.'
        }

    return render_template('checkouts/reshow.html',
                           transaction=transaction,
                           result=result)
Beispiel #3
0
def give_refund(transaction_id):
    transaction = find_transaction(transaction_id)
    result = refund(transaction, "10.00")
    if result.is_success:
        return redirect(url_for('show_refund'), transaction_id=transaction_id)
    else:
        for x in result.errors.deep_errors:
            flash('Error: %s: %s' % (x.code, x.message))
        return redirect(url_for('new_checkout'))
    # transaction = find_transaction(transaction_id)
    # result1 = {}
    # if transaction.status in TRANSACTION_REFUND_STATUSES:
    #     result1 = {
    #         'header': 'Sweet Success!',
    #         'icon': 'success',
    #         'message': 'Your test transaction has been successfully processed and click the button below if you would like to refund.'
    #     }
    # else:
    #     result1 = {
    #         'header': 'No Refund, sorry!',
    #         'icon': 'norefund',
    #         'message': 'Your test transaction has a status of ' + transaction.status + '. See the Braintree API response and try again.'
    #     }

    return render_template('refund/reshow.html',
                           transaction=transaction,
                           result=result1)
Beispiel #4
0
def create_checkout():
    nonce = request.json.get('payment_method_nonce')
    amount = request.json.get('amount')
    result = transact({
        'amount': amount,
        'payment_method_nonce': nonce,
        'options': {
            "submit_for_settlement": True
        }
    })
    # amount = int(request.form.get('amount'))
    # current_id= current_user.id
    # current_email = str(current_user.email)

    if result.is_success or result.transaction:
        # print(result.transaction.id[0])
        transaction = find_transaction(result.transaction.id)
        transac = {}
        transac['id'] = transaction.id
        transac['type'] = transaction.type
        transac['amount'] = str(transaction.amount)
        transac['status'] = transaction.status
        result = {}
        if transaction.status in TRANSACTION_SUCCESS_STATUSES:
            result = {
                'header':
                'Sweet Success!',
                'icon':
                'success',
                'message':
                'Your test transaction has been successfully processed. See the Braintree API response and try again.'
            }
        else:
            result = {
                'header':
                'Transaction Failed',
                'icon':
                'fail',
                'message':
                'Your test transaction has a status of ' + transaction.status +
                '. See the Braintree API response and try again.'
            }

        return jsonify(message=result, transac=transac)
    else:

        # for x in result.errors.deep_errors: flash('Error: %s: %s' % (x.code, x.message))
        # errormessage={}
        # errormessage['errormessage'] = result.errors.deep_errors
        return jsonify(error="error")
Beispiel #5
0
def show_checkout(transaction_id):
    global parsedItems
    transaction = find_transaction(transaction_id)
    result = {}
    if transaction.status in TRANSACTION_SUCCESS_STATUSES:
        result = {
            'header': 'Sweet Success!',
            'icon': 'success',
            'message': 'Your test transaction has been successfully processed. See the Braintree API response and try again.'
        }
        #make a new transaction table entry, {"transaction_id" : value, "jsonItems" : value}
    else:
        result = {
            'header': 'Transaction Failed',
            'icon': 'fail',
            'message': 'Your test transaction has a status of ' + transaction.status + '. See the Braintree API response and try again.'
        }
    return render_template('checkouts/show.html', transaction=transaction, result=result, parsedItems=parsedItems)
Beispiel #6
0
def show_checkout(transaction_id):
    transaction = find_transaction(transaction_id)
    result = {}
    if transaction.status in TRANSACTION_SUCCESS_STATUSES:
        result = {
            'header': 'Success!',
            'icon': 'success',
            'message': 'Your transaction has been successfully processed.'
        }
    else:
        result = {
            'header':
            'Transaction Failed',
            'icon':
            'fail',
            'message':
            'Your test transaction has a status of ' + transaction.status + '.'
        }

    return render_template('checkouts/show.html',
                           transaction=transaction,
                           result=result)