Created
March 28, 2011 19:16
-
-
Save mkelley33/891073 to your computer and use it in GitHub Desktop.
An almost working view for django-braintree
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Note: this is just for testing, and doesn't do stuff like set the amount or redirect if successful. | |
# | |
# This tidbit was created primarily to troubleshoot why I couldn't submit a form with validation errors | |
# twice without being redirected to https://sandbox.braintreegateway.com/login | |
# | |
# Tested using Python 2.6.6, django 1.2.5, django-braintree 1.5, and braintree 1.8 | |
def make_payment(request): | |
result = TransactionForm.get_result(request) | |
form = TransactionForm(result, redirect_url='http://127.0.0.1:8000/make_payment/') | |
form.generate_tr_data() | |
# When I'm redirected back to make_payment with validation errors, | |
# inspection of form.fields['tr_data'].initial reveals the expected data. | |
# | |
# However, if you fire up Chrome, CMD-alt-i, and examine the source, | |
# you'll see the hidden input has been rendered, but without any data. | |
# | |
# What gives? | |
return direct_to_template(request, 'make_payment.html', { 'form': form }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment