Source

satchmo / satchmo / apps / payment / templates / shop / checkout / paypal / confirm.html

Full commit
{% extends "shop/checkout/base_confirm.html" %}
{% load i18n %}
{% load satchmo_util %}
{% load smart_if %}
{# this is the Paypal confirm template #}

{% block payment_step %}<a href="{% url PAYPAL_satchmo_checkout-step2 %}">{% trans "Payment" %}</a>{% endblock %}

{% block payment_display %}
<h4>{% trans "Payment" %}</h4>
{% if not PAYMENT_LIVE %}<b>PAYMENT TEST MODE</b><br/>{% endif %}
{% trans "Your payment will be processed through PayPal." %}
{% endblock %}

{% block payment_form %}
{% if order.paid_in_full %}
<form action="{% url PAYPAL_satchmo_checkout_free-confirm %}">
    <input type="submit" value="{% trans "Purchase Items" %}" />
</form>
{% else %}
<form action="{{ post_url }}" method="post">{% csrf_token %}
<input type="hidden" name="business" value="{{ business }}" />
<input type="hidden" name="currency_code" value="{{ currency_code }}" />
<input type="hidden" name="return" value="{{ return_address }}" />
{% if subscription %}
<input type="hidden" name="cmd" value="_xclick-subscriptions">
<input type="hidden" name="item_name" value="{{ subscription.product.name }}">
<input type="hidden" name="item_number" value="{{ invoice }}">
<input type="hidden" name="invoice" value="{{ invoice }}" />
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="bn" value="PP-SubscriptionsBF">
{% if subscription.trial1 %}
<input type="hidden" name="a1" value="{{ subscription.trial1.price }}">
<input type="hidden" name="p1" value="{{ subscription.trial1.expire_length }}">
<input type="hidden" name="t1" value="{{ subscription.trial1.expire_unit }}">
{% endif %}
{% if subscription.product.trial2_price %}
<input type="hidden" name="a2" value="{{ subscription.product.trial2.price }}">
<input type="hidden" name="p2" value="{{ subscription.product.trial2.expire_length }}">
<input type="hidden" name="t2" value="{{ subscription.product.trial2.expire_unit}}">
{% endif %}
<input type="hidden" name="a3" value="{{ subscription.price }}">
<input type="hidden" name="p3" value="{{ subscription.product.subscriptionproduct.expire_length }}">
<input type="hidden" name="t3" value="{{ subscription.product.subscriptionproduct.expire_unit }}">
{% if subscription.product.recurring %}
<input type="hidden" name="src" value="1">
{% endif %}
<input type="hidden" name="sra" value="1">
<input type="hidden" name="srt" value="{{ recuring.recurring_times }}">
{% else %}
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="upload" value="1" />
<input type="hidden" name="no_shipping" value="1" />
<input type="hidden" name="invoice" value="{{ invoice }}" />
{% if order.partially_paid %}
<input type="hidden" name="item_name_1" value="Remaining Balance for order {{ order.id }}" />
<input type="hidden" name="amount_1" value="{{order.balance|truncate_decimal:2}}" />
<input type="hidden" name="quantity_1" value="1" />
{% else %}
{% for item in order.orderitem_set.all %}{% spaceless %}
{% if item.discount %}
  {% if item.line_total > item.discount %}
    <input type="hidden" name="item_name_{{forloop.counter}}" value="{{item}}" />
    <input type="hidden" name="amount_{{forloop.counter}}" value="{{item.unit_price|truncate_decimal:2}}" />
    <input type="hidden" name="discount_amount_{{forloop.counter}}" value="{{item.discount|truncate_decimal:2}}" />
  {% else %}
    {# paypal doesn't like 100% discounts, so skip this item if it has zero cost. #}
    {# BUT, if this is the only thing in the cart, then we still need to put *something* #}
    {# in the cart, so lets do handling as a line item #}
    {% if order.discounted_sub_total <= 0 %}
      <input type="hidden" name="item_name_{{forloop.counter}}" value="Shipping for free items" />
      <input type="hidden" name="amount_{{forloop.counter}}" value="{{order.shipping_with_tax|truncate_decimal:2}}" />
    {% endif %}
  {% endif %}
{% else %}
  {# no discount %}
  <input type="hidden" name="item_name_{{forloop.counter}}" value="{{item}}" />
  <input type="hidden" name="amount_{{forloop.counter}}" value="{{item.unit_price|truncate_decimal:2}}" />
{% endif %}
{% endspaceless %}
<input type="hidden" name="quantity_{{forloop.counter}}" value="{{item.quantity|truncate_decimal:0}}" />
{% endfor %}
{# LEAVE THE HANDLING CHARGE ALONE!  PAYPAL SHIPPING WILL INEVITABLY BE MESSED UP IF YOU USE THEIR SHIPPING METHODS #}
{# To work around their bizarre system, we are telling Paypal "no shipping" and adding all shipping charges as handling #}
{% spaceless %}{% if order.discounted_sub_total > 0 %}
  {# don't add handling if we already used it above - see the 100% discount section above #}
  <input type="hidden" name="handling_cart" value="{{order.shipping_with_tax|truncate_decimal:2}}" />
{% endif %}{% endspaceless %}
<input type="hidden" name="tax_cart" value="{{order.tax|truncate_decimal:2}}" />
{% endif %}
{% endif %}
{% if order.contact.billing_address %}{% with order.contact.billing_address as address %}
<input type="hidden" name="first_name" value="{{order.contact.first_name}}" />
<input type="hidden" name="last_name" value="{{order.contact.last_name}}" />
<input type="hidden" name="address1" value="{{address.street1}}" />
<input type="hidden" name="address2" value="{{address.street2}}" />
<input type="hidden" name="city" value="{{address.city}}" />
{# only U.S. abbreviations may be used here #}{% ifequal address.country.iso2_code|lower 'us' %}{% ifequal address.state|length 2 %}<input type="hidden" name="state" value="{{address.state}}" />{% endifequal %}{% endifequal %}
<input type="hidden" name="country" value="{{address.country.iso2_code}}" />
<input type="hidden" name="zip" value="{{address.postal_code}}" />
<input type="hidden" name="email" value="{{order.contact.email}}" />
<input type="hidden" name="address_override" value="0" />
{% endwith %}{% endif %}
<input type="hidden" name="notify_url" value="{{shop.base_url}}{% url PAYPAL_satchmo_checkout-ipn %}" />
<input type="submit" value="{% trans "Purchase Items" %}" />
</form>
{% endif %}
{% endblock %}