~sircmpwn/names.sr.ht

d8e28b097b8652613dbd49fe6d6d5089bece1295 — Drew DeVault 1 year, 10 months ago 3d99b9e
Improve registration page
3 files changed, 26 insertions(+), 8 deletions(-)

M names/blueprints/web.py
M names/opensrs.py
M names/templates/create-domain.html
M names/blueprints/web.py => names/blueprints/web.py +4 -2
@@ 49,10 49,12 @@ def create_domain_GET(domain):

    # TODO: Check if user has payment info on file
    if status == DomainStatus.available:
        price = get_price(domain)
        market_price = get_price(domain)
        # Factor in our Stripe fees, so we don't lose money
        our_price = int(market_price + (market_price * 0.029) + 30)
        return render_template("create-domain.html",
                DomainStatus=DomainStatus, status=status, domain=domain,
                price=price)
                our_price=our_price, market_price=market_price)
    else:
        transferable, transfer_email = check_transfer(domain)
        # Note: this could be merged into lookup_domain and save us an API call

M names/opensrs.py => names/opensrs.py +2 -2
@@ 146,7 146,7 @@ class RegistrationType(enum.Enum):

def get_price(domain, reg_type=RegistrationType.new):
    """
    Returns pricing info for this domain.
    Returns price for this domain in cents.
    """
    # TODO: Should we support the period parameter?
    r = _post("get_price", "domain", attrs={


@@ 154,7 154,7 @@ def get_price(domain, reg_type=RegistrationType.new):
        "reg_type": reg_type.value,
    })
    print(r)
    return PricingInfo(int(float(r["attributes"]["price"]) * 100))
    return int(float(r["attributes"]["price"]) * 100)

def check_transfer(domain):
    """

M names/templates/create-domain.html => names/templates/create-domain.html +20 -4
@@ 2,14 2,29 @@
{% block content %}
<div class="row">
  <form class="col-md-12" method="POST">
    <h3>Register {{domain}}</h3>
    <h3>
      Register {{domain}}
      {% if status == DomainStatus.available %}
      <small class="text-success">{{icon('check')}} available</small>
      {% else %}
      <small class="text-danger">{{icon('times')}} taken</small>
      {% endif %}
    </h3>
    {{csrf_token()}}
    {% if status == DomainStatus.available %}
    <p>
      <strong>{{domain}}</strong> is available. You can register it with us for
      ${{"{:.02f}".format(price.cents / 100.0)}} per year, or use our
      nameservers for free.
      ${{"{:.02f}".format(our_price / 100.0)}} per year. Alternatively, you
      can register with someone else and use our nameservers for free.
    </p>
    <blockquote class="alert alert-warning">
      <strong>Where does this price come from?</strong> We can buy this domain
      at wholesale prices for ${{"{:.02f}".format(market_price / 100.0)}}, then
      we add our payment processing fees to bring our total to
      ${{"{:.02f}".format(our_price / 100.0)}}. If you pay for more than 1
      year, we only charge procesisng fees once. Because you have a paid
      {{cfg("sr.ht", "site-name")}} account, we don't charge a markup.
    </blockquote>
    <button class="btn btn-primary">
      Purchase this domain {{icon("caret-right")}}
    </button>


@@ 26,13 41,14 @@
      <a href="mailto:{{transfer_email}}">{{transfer_email}}</a>.
      {%- else %}.
      {% endif %}
      Alternatively, you can use our nameservers for free.
    </p>

    <button class="btn btn-primary">
      Transfer this domain {{icon("caret-right")}}
    </button>
    <button class="btn btn-default">
      I just want DNS {{icon("caret-right")}}
      Configure nameservers {{icon("caret-right")}}
    </button>
    {% else %} {# if transferable #}
      and cannot be transfered. However, you may use our nameservers if you