Changeset - c40b8cc02ddc
[Not reviewed]
0 3 0
Christopher Neugebauer - 7 years ago 2016-09-21 09:40:38
chrisjrn@gmail.com
Templates for stripe.
3 files changed with 10 insertions and 4 deletions:
0 comments (0 inline, 0 general)
pinaxcon/settings.py
Show inline comments
...
 
@@ -209,41 +209,42 @@ FIXTURE_DIRS = [
 
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
 

	
 
ACCOUNT_OPEN_SIGNUP = True
 
ACCOUNT_EMAIL_UNIQUE = True
 
ACCOUNT_EMAIL_CONFIRMATION_REQUIRED = False
 
ACCOUNT_LOGIN_REDIRECT_URL = "home"
 
ACCOUNT_LOGOUT_REDIRECT_URL = "home"
 
ACCOUNT_EMAIL_CONFIRMATION_EXPIRE_DAYS = 2
 
ACCOUNT_USE_AUTH_AUTHENTICATE = True
 

	
 
AUTHENTICATION_BACKENDS = [
 
    "symposion.teams.backends.TeamPermissionsBackend",
 
    "account.auth_backends.UsernameAuthenticationBackend",
 
]
 

	
 
CONFERENCE_ID = 1
 
PROPOSAL_FORMS = {
 
    "talk": "pinaxcon.proposals.forms.TalkProposalForm",
 
}
 
PINAX_PAGES_HOOKSET = "pinaxcon.hooks.PinaxPagesHookSet"
 
PINAX_BOXES_HOOKSET = "pinaxcon.hooks.PinaxBoxesHookSet"
 

	
 
PINAX_STRIPE_PUBLIC_KEY = os.environ.get("STRIPE_PUBLIC_KEY", "your test public key")
 
PINAX_STRIPE_SECRET_KEY = os.environ.get("STRIPE_SECRET_KEY", "your test secret key")
 
PINAX_STRIPE_SEND_EMAIL_RECEIPTS = False
 

	
 
# Registrasion Attendee profile model
 
ATTENDEE_PROFILE_MODEL = "pinaxcon.registrasion.models.AttendeeProfile"
 
# Registrasion attendee profile form -- must act on ATTENDEE_PROFILE_FORM
 
# You only need to provide this if you're customising the form from the default
 
# ATTENDEE_PROFILE_FORM = "pinaxcon.registrasion.forms.ProfileForm"
 

	
 
INVOICE_CURRENCY = "AUD"
 

	
 
# Use nose to run all tests
 
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
 

	
 
# Tell nose to measure coverage on the 'foo' and 'bar' apps
 
NOSE_ARGS = [
 
    '--with-coverage',
 
    '--cover-package=registrasion.controllers,registrasion.models',
 
]
pinaxcon/templates/registrasion/invoice.html
Show inline comments
 
{% extends "site_base.html" %}
 
{% load bootstrap %}
 
{% load registrasion_tags %}
 
{% block body %}
 

	
 

	
 
{% if invoice.is_unpaid %}
 
  <p><strong>NOTICE:</strong> The below invoice is automatically generated, and will be voided
 
    if you amend your registration before payment, or if discounts or products contained in the
 
    invoice become unavailable. The items and discounts are only reserved until
 
    the invoice due time.</p>
 

	
 
  {% url "invoice_access" invoice.user.attendee.access_code as access_url %}
 
  <p>Your most recent unpaid invoice will be available at
 
    <a href="{{ access_url }}">{{ request.scheme }}://{{ request.get_host }}{{ access_url }}</a>
 
    You can give this URL to your accounts department to pay your registration.</p>
 

	
 
  <div>
 
    <a class="btn btn-default" href="{% url "demopay" invoice.id invoice.user.attendee.access_code %}">Pay this invoice</a>
 
    <a class="btn btn-default" href="{% url "demopay" invoice.id invoice.user.attendee.access_code %}">Pay this invoice (dummy)</a>
 
    <a class="btn btn-default" href='{% url "registripe_card" invoice.id %}'>Pay this invoice with Stripe</a>
 
    {% if user.is_staff %}
 
      <a class="btn btn-default" href="{% url "manual_payment" invoice.id %}">Apply manual payment</a>
 
    {% endif %}
 
  </div>
 
{% elif invoice.is_paid %}
 
  {% if user.is_staff %}
 
  <div>
 
    {% if user.is_staff %}
 
    <a class="btn btn-default" href="{% url "manual_payment" invoice.id %}">Apply manual payment/refund</a>
 
    <a class="btn btn-default" href="{% url "refund" invoice.id %}">Refund by issuing credit note</a>
 
    {% endif %}
 
  </div>
 
  {% endif %}
 
{% endif %}
 

	
 
<hr />
 

	
 
{% include "registrasion/_invoice_details.html" %}
 

	
 
{% endblock %}
pinaxcon/templates/registrasion/stripe/credit_card_payment.html
Show inline comments
...
 
@@ -14,68 +14,72 @@
 
      $form.submit(function(event) {
 

	
 
        if ($form.find("input[name='stripe_token']").length) {
 
          // If we've added the stripe token, then we're good to go.
 
          return true;
 
        }
 

	
 
        // Disable the submit button to prevent repeated clicks:
 

	
 
        $form.find('input[type=submit]').prop('disabled', true);
 

	
 
        console.log($form.number);
 

	
 
        // Request a token from Stripe:
 
        Stripe.card.createToken($form, stripeResponseHandler);
 

	
 
        // Prevent the form from being submitted:
 
        return false;
 
      });
 
    });
 

	
 
    function stripeResponseHandler(status, response) {
 
      // Grab the form:
 
      var $form = $('#payment-form');
 
      var $submit = $form.find('input[type=submit]')
 
      if (response.error) { // Problem!
 
        console.log(response.error.message);
 

	
 
        // Show the errors on the form:
 
        $form.find('#payment-errors').text(response.error.message);
 
        $form.find('#payment-errors-outer').show();
 
        $form.find('input[type=submit]').prop('disabled', false); // Re-enable submission
 
        $submit.prop('disabled', false); // Re-enable submission
 

	
 
      } else { // Token was created!
 
        console.log(response);
 

	
 
        // Get the token ID:
 
        var token = response.id;
 

	
 
        // Insert the token ID into the form so it gets submitted to the server:
 
        $form = $form.append($('<input type="hidden" name="stripe_token" />').val(token));
 

	
 
        // Submit the form:
 
        $form.find('input[type=submit]').prop('disabled', false);
 
        $form.find('input[type=submit]').click();
 

	
 
        $submit.prop('disabled', false);
 
        $submit.click();
 
        $submit.prop('disabled', true);
 
        $form.append($('<p>').text("Processing your payment. Please do not refresh."));
 
      }
 
    };
 
  </script>
 

	
 
{% endblock %}
 

	
 
{% block body %}
 

	
 
  <h2>Credit card payment for invoice #{{ invoice.id}}</h2>
 

	
 
  <p>You have ${{ invoice.balance_due }} remaining to pay on this invoice.</p>
 

	
 
  <p>Credit card payments are processed by <a href="https://stripe.com">Stripe</a>.
 
    We do not store any of your credit card data locally, but instead Strip will securely tokenise your card details. To allow this, you must allow JavaScript from <code>js.stripe.com</code>.</p>
 

	
 
  <h3>Card details</h3>
 

	
 
  <form id="payment-form" method="post">
 

	
 
    <div class="alert alert-danger" id="payment-errors-outer" style="display: none;">
 
      <a class="close" data-dismiss="alert">×</a>
 
      <span id="payment-errors"></span>
 
    </div>
 

	
0 comments (0 inline, 0 general)