Skip to content

Instantly share code, notes, and snippets.

@mkelley33
Created March 23, 2011 16:08
Show Gist options
  • Save mkelley33/883356 to your computer and use it in GitHub Desktop.
Save mkelley33/883356 to your computer and use it in GitHub Desktop.
A partial implementation of transparent redirect for braintree payments
def register_new_account(request):
result = TransactionForm.get_result(request)
if result:
if result.is_success:
result = braintree.TransparentRedirect.confirm(request.META["QUERY_STRING"])
# TODO: store customer info in vault
# TODO: create a subscription
return redirect('cream_thank_you')
elif result.errors:
pass
# TODO: re-populate form
# TODO: allow for re-submission
# from IPython.Shell import IPShellEmbed
# ipshell = IPShellEmbed()
# ipshell()
form = TransactionForm(result, redirect_url="%s%s" % (settings.SITE_URL, reverse('cream_register_new_account')))
form.tr_protected['transaction']['options']['submit_for_settlement'] = u'true'
form.remove_section('transaction[shipping_address]')
form.remove_section('transaction[amount]')
form.tr_fields['transaction']['amount'] = '60'
form.generate_tr_data()
return direct_to_template(request, 'cream/register.html', { 'form': form, })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment