credit card edit

This commit is contained in:
unknown 2017-01-03 09:33:25 -04:00
parent ad581bbf40
commit 86777a4699
7 changed files with 432 additions and 36 deletions

View file

@ -28,6 +28,7 @@ $( document ).ready(function() {
var hasCreditcard = window.hasCreditcard; var hasCreditcard = window.hasCreditcard;
hasCreditcard= true;
console.log("has creditcard"); console.log("has creditcard");
console.log("has creditcard"); console.log("has creditcard");
console.log("has creditcard"); console.log("has creditcard");
@ -40,9 +41,11 @@ $( document ).ready(function() {
e.preventDefault(); e.preventDefault();
if (hasCreditcard) { if (hasCreditcard) {
$('#billing-form').submit(); $('#billing-form').submit();
console.log("has creditcard2");
} }
else  { else  {
$('#payment-form').submit(); $('#payment-form').submit();
console.log("has creditcard3");
} }

View file

@ -70,7 +70,7 @@
<br> <br>
</form> </form>
</div> </div>
{% if credit_card_data.last4 and credit_card_data.cc_brand %} {% if credit_card_data.last4 %}
<form role="form" id="billing-form" method="post" action="{% url 'digitalglarus:booking_payment' %}" novalidate> <form role="form" id="billing-form" method="post" action="{% url 'digitalglarus:booking_payment' %}" novalidate>
<h2 class="billing-head">Credit Card<a class="btn btn-primary btn-grey btn-edit" href="{% url 'digitalglarus:TermsAndConditions' %}">Edit</a></h2> <h2 class="billing-head">Credit Card<a class="btn btn-primary btn-grey btn-edit" href="{% url 'digitalglarus:TermsAndConditions' %}">Edit</a></h2>
<h2 class="membership-lead">Last 4: *****{{credit_card_data.last4}}</h2> <h2 class="membership-lead">Last 4: *****{{credit_card_data.last4}}</h2>
@ -78,6 +78,7 @@
<input type="hidden" name="credit_card_needed" value="false"/> <input type="hidden" name="credit_card_needed" value="false"/>
</form> </form>
{% else %} {% else %}
<h2 class="billing-head">Credit Card (Last used)</h2> <h2 class="billing-head">Credit Card (Last used)</h2>
<div class="signup-form form-group row"> <div class="signup-form form-group row">
<form role="form" id="payment-form" novalidate> <form role="form" id="payment-form" novalidate>

View file

@ -0,0 +1,301 @@
{% extends "new_base_glarus.html" %}
{% load staticfiles bootstrap3 i18n %}
{% block content %}
<style type="text/css">
.nopadding {
padding: 0 !important;
margin: 0 !important;
}
.form-control#id_country{
-webkit-appearance: none;
-moz-appearance: none;
background-position: right 50%;
background-repeat: no-repeat;
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAMCAYAAABSgIzaAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNSBNYWNpbnRvc2giIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6NDZFNDEwNjlGNzFEMTFFMkJEQ0VDRTM1N0RCMzMyMkIiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6NDZFNDEwNkFGNzFEMTFFMkJEQ0VDRTM1N0RCMzMyMkIiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDo0NkU0MTA2N0Y3MUQxMUUyQkRDRUNFMzU3REIzMzIyQiIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDo0NkU0MTA2OEY3MUQxMUUyQkRDRUNFMzU3REIzMzIyQiIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PuGsgwQAAAA5SURBVHjaYvz//z8DOYCJgUxAf42MQIzTk0D/M+KzkRGPoQSdykiKJrBGpOhgJFYTWNEIiEeAAAMAzNENEOH+do8AAAAASUVORK5CYII=);
padding: .5em;
padding-right: 1.5em
}
.order-bottom-text a{
margin-left: 0px;
}
</style>
<section id="price">
<div class="signup-container">
<div class="col-xs-12 col-sm-6 col-lg-8 text-center wow fadeInDown">
<div class="payment-box">
<h2 class="section-heading payment-head">Booking</h2>
<!-- <h2 class="membership-amount">35CHF</h2> -->
<hr class="greyline-long">
<h2 class="membership-lead">
Your Digital Glarus Membership enables
you to use our coworking space and it includes
2 working days for the month you signed up.
The membership fee is a monthly subscription.
Additional day costs
15CHF per day. More than 17 days a month it
will charge only 290CHF/month.
</h2>
{% if is_free %}
<h2 class="billing-head">Billing Adress</h2>
<div class="signup-form form-group row">
<form role="form" id="billing-form" method="post" action="{% url 'digitalglarus:booking_payment' %}" novalidate>
{% for field in form %}
{% csrf_token %}
{% bootstrap_field field show_label=False type='fields'%}
{% endfor %}
{% bootstrap_form_errors form type='non_fields'%}
<br>
</form>
</div>
<hr class="greyline-long">
<br/>
<h2 class="billing-head">Your booking is FREE of charge! You can change or cancel the booking freely 7 days before the booking date.</h2>
<br/><br/>
{% else %}
<h2 class="billing-head">Billing Adress</h2>
<div class="signup-form form-group row">
<form role="form" id="billing-form" method="post" action="{% url 'digitalglarus:booking_payment' %}" novalidate>
{% for field in form %}
{% csrf_token %}
{% bootstrap_field field show_label=False type='fields'%}
{% endfor %}
{% bootstrap_form_errors form type='non_fields'%}
<br>
</form>
<div class="col-xs-4 col-md-6 pull-right">
<div class="form-group">
<label for="cvCode">CV CODE</label>
<input type="password" class="form-control" name="cvCode" placeholder="CV" required data-stripe="cvc" />
</div>
</div>
</div>
<div class="col-xs-4 col-md-6 pull-right">
<div class="form-group">
<label for="cvCode">CV CODE</label>
<input type="password" class="form-control" name="cvCode" placeholder="CV" required data-stripe="cvc" />
</div>
</div>
<div class="col-xs-4 col-md-6 pull-right">
<div class="form-group">
<label for="cvCode">CV CODE</label>
<input type="password" class="form-control" name="cvCode" placeholder="CV" required data-stripe="cvc" />
</div>
</div>
{% if last4 %}
<form role="form" id="billing-form" method="post" action="{% url 'digitalglarus:booking_payment' %}" novalidate>
<h2 class="billing-head">Credit Card<a class="btn btn-primary btn-grey btn-edit" href="{% url 'digitalglarus:TermsAndConditions' %}">Edit</a></h2>
<h2 class="membership-lead">Last 4: *****{{last4}}</h2>
<h2 class="membership-lead">Type: {{credit_card_data.cc_brand}}</h2>
<input type="hidden" name="credit_card_needed" value="false"/>
</form>
{% else %}
<h2 class="billing-head">Credit Card (Last used)</h2>
<div class="signup-form form-group row">
<form role="form" id="payment-form" novalidate>
<div class="row">
<div class="col-xs-12 col-md-12">
<div class="form-group">
<input type="text" class="form-control" name="cardName" placeholder="Name on card" required autofocus data-stripe="name" />
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-md-12">
<div class="form-group">
<input type="text" class="form-control" name="cardNumber" placeholder="Valid Card Number" required data-stripe="number" />
</div>
</div>
</div>
<div class="row">
<div class="col-xs-6 col-md-6 nopadding">
<label for="expMonth">EXPIRATION DATE</label><br/>
<div class="col-xs-6 col-lg-6 col-md-6">
<div class="form-group">
<input type="text" class="form-control" name="expMonth" placeholder="MM" required data-stripe="exp_month" />
</div>
</div>
<div class="col-xs-6 col-lg-6 col-md-6 pl-ziro">
<div class="form-group">
<input type="text" class="form-control" name="expYear" placeholder="YY" required data-stripe="exp_year" />
</div>
</div>
</div>
<div class="col-xs-4 col-md-6 pull-right">
<div class="form-group">
<label for="cvCode">CV CODE</label>
<input type="password" class="form-control" name="cvCode" placeholder="CV" required data-stripe="cvc" />
</div>
</div>
</div>
<div class="row" style="display:none;">
<div class="col-xs-12">
<p class="payment-errors"></p>
</div>
</div>
{% if paymentError %}
<div class="row">
<div class="col-xs-12">
<p>
{% bootstrap_alert paymentError alert_type='danger' %}
</p>
</div>
</div>
{% endif %}
</form>
<br>
</div>
{% endif %}
{% endif %}
</div>
</div>
<div class="col-xs-12 col-sm-4 col-lg-4 wow fadeInDown">
<div class="order-summary">
<div class="header text-center">
<h2 class="order-name">Booking Summary</h2>
</div>
<div class="order-box">
<h3 class="col-xs-6 order-item">Dates {{start_date}} - {{end_date}}</h3>
<p class="order-bottom-text">
<a href="{{request.META.HTTP_REFERER}}">Change dates</a>
</p>
<hr class="greyline">
<h2 class="col-xs-6 payment-total">Total days: {{booking_days}} </h2>
<h2 class="order-sum">{{original_price|floatformat}}CHF</h2>
<br/>
{% if free_days %}
<h2 class="col-xs-6 payment-total">Free days: {{free_days}}</h2>
<h2 class="order-sum"><span class="text-danger">-{{total_discount|floatformat}}CHF</span></h2>
{% endif %}
<hr class="greyline">
<h2 class="col-xs-6 payment-total">Total</h2>
<h2 class="order-result">{{final_price|floatformat}}CHF</h2>
<div class="text-center">
<label class="custom-control custom-checkbox">
<br/>
<input type="checkbox" class="custom-control-input agree-terms">
<span class="custom-control-indicator"></span>
<span class="custom-control-description">I accept the Digital Glarus <a data-toggle="modal" data-target="#cancel-subscription-modal" target="_blank">Terms and Conditions</a>, <a href=#>Community Guidelines</a> and <a href=#>Privacy Policy</a></span>
</label>
<div class="button-box">
<div class="row">
<div class="col-xs-12">
<button id="payment_button" class="btn btn-primary btn-md btn-blck submit-payment" type="submit">Book</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<section id="contact">
<div class="fill">
<div class="row" class="wow fadeInDown">
<div class="col-lg-12 text-center wow fadeInDown">
<div class="col-md-4 map-title">
Digital Glarus<br>
<span class="map-caption">In der Au 7 Schwanden 8762 Switzerland
<br>info@digitalglarus.ch
<br>
(044) 534-66-22
<p>&nbsp;</p>
</span>
</div>
<p>&nbsp;</p>
</div>
</div>
</div>
</section>
<div class="modal fade bs-example-modal-sm" id="cancel-subscription-modal" tabindex="-1" role="dialog" aria-hidden ="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body">
<section id="price2">
<div class="container">
<!--<div class="row col-md-2 text-center wow fadeInDown"></div> -->
<div class="row col-xs-12 col-sm-7 col-lg-6 text-center wow fadeInDown">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<div class="price-box">
<span class="glyphicon glyphicon-flag"></span>
<h2 class="section-heading">General Terms & Conditions of Digital Glarus Membership</h2>
<h2 class="price">Valid from 31 October 2016, v1.0 dated 31 October 2016</h2>
<hr class="primary">
<div class="price-exp-box">
<p class="text-left">
<p class="term-head">1. Membership</p>
1.1. The membership fee is 35CHF per month and charged on the 1st day of each month after your first month of subscription. <br>
1.2. Each additional day costs 15CHF for members.<br>
<br>
<p class="term-head">2. Coworking days</p>
2.1. Coworking days are counted as 1 calendar day. <br>
2.2. Free coworking days are included in the membership. <br>
2.3. Unused working days are not refunded and can not be compensated for. <br><br>
<p class="term-head">3. Possible reduction</p>
3.1. Your first month's membership fee is calculated according to the date of your subscription. <br>
3.2. The days already passed in the first month are discounted from the first month's membership fee.<br>
3.3. A member booking more than 19 days for coworking gets a reduction in total cost and will only pay maximum 290CHF per month. The reduction will be applied automatically on Digital Glarus website.<br><br>
<p class="term-head">4. Member's right to cancellation </p>
4.1. The member may cancel or change the booking of working day at any time prior to 7 days before the working day with no extra cost. <br>
4.2. Bookings cancelled less than 7 days before the working date will not be refunded.<br><br>
<p class="term-head">5. Digital Glarus' right to cancel a membership </p>
5.1. Digital Glarus may cancel a membership contract without notice at any time, stating the reasons for the cancellation.<br>
5.2. Members disrupting the environment of coworking may be rejected to join the membership.<br><br>
<p class="term-head">6. Digital Glarus' right to cancel a membership </p>
6.1. Digital Glarus may cancel a membership contract without notice at any time, stating the reasons for the cancellation.<br>
6.2. Digital Glarus may reject a member who disrupts the environment of coworking space from joining the membership.<br>
6.3. Digital Glarus may terminate the membership of a member who disrupts the environment of coworking space. <br>
6.4. Digital Glarus may expell a member who disrupts the environment of coworking space from the coworking space, stating the reasons for the expulsion.
<br><br>
</p>
<div class="text-center">
<a href="mailto:info@ungleich.ch" class="btn btn-primary btn-blue">Still have a question?</a>
</div>
<div class="row col-md-2 text-center wow fadeInDown">
</div>
</div>
</div>
</div>
<div class="row col-md-3 text-center wow fadeInDown"></div>
</div>
</section>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!-- stripe key data -->
{% if stripe_key %}
<script type="text/javascript">
(function () {window.stripeKey = "{{stripe_key}}";})();
</script>
{%endif%}
{% if credit_card_data.last4 and credit_card_data.cc_brand %}
<script type="text/javascript">
(function () {window.hasCreditcard = true;})();
</script>
{%endif%}
{% endblock %}

View file

@ -120,7 +120,8 @@
<div class="row"> <div class="row">
<div class="col-xs-12 col-md-12"> <div class="col-xs-12 col-md-12">
<div class="form-group"> <div class="form-group">
<input type="text" class="form-control" name="cardName" placeholder="Name on card" required autofocus data-stripe="name" />
<input type="text" class="form-control" name="cardName" placeholder="Name on card" required autofocus data-stripe="name" />
</div> </div>
</div> </div>
</div> </div>

View file

@ -37,7 +37,7 @@
<h2 class="membership-lead"> <h2 class="membership-lead">
</h2> </h2>
{% if is_free %} <!-- {% if is_free %}
<h2 class="billing-head">Billing Adress</h2> <h2 class="billing-head">Billing Adress</h2>
<div class="signup-form form-group row"> <div class="signup-form form-group row">
<form role="form" id="billing-form" method="post" action="{% url 'digitalglarus:booking_payment' %}" novalidate> <form role="form" id="billing-form" method="post" action="{% url 'digitalglarus:booking_payment' %}" novalidate>
@ -55,19 +55,12 @@
<h2 class="billing-head">Your booking is FREE of charge! You can change or cancel the booking freely 7 days before the booking date.</h2> <h2 class="billing-head">Your booking is FREE of charge! You can change or cancel the booking freely 7 days before the booking date.</h2>
<br/><br/> <br/><br/>
{% else %} {% else %}
-->
<br> <br>
<h2 class="billing-head">Credit Card Information</h2> <h2 class="billing-head">Credit Card Information</h2>
{% if credit_card_data %}
<form role="form" id="billing-form" method="post" action="{% url 'digitalglarus:booking_payment' %}" novalidate>
<h2 class="membership-lead">Last 4: *****{{last4}}</h2>
<h2 class="membership-lead">Type: {{cc_brand}}</h2>
<input type="hidden" name="credit_card_needed" value="false"/>
</form>
{% else %}
<form role="form" id="billing-form" method="post" action="{% url 'digitalglarus:booking_payment' %}" novalidate> <form role="form" id="billing-form" method="post" action="{% url 'digitalglarus:booking_payment' %}" novalidate>
{% csrf_token %} {% csrf_token %}
<h2 class="membership-lead">Last 4: *****{{last4}}</h2> <h2 class="membership-lead">Last 4: *****{{last4}}</h2>
@ -81,7 +74,9 @@
<form role="form" id="payment-form" novalidate> <!-- <form role="form" id="payment-form" novalidate> -->
<form role="form" id="payment-form2" method="post" action="{% url 'digitalglarus:booking_payment_view' %}" novalidate>
{% csrf_token %} {% csrf_token %}
<div class="row"> <div class="row">
<div class="col-xs-12 col-md-12"> <div class="col-xs-12 col-md-12">
@ -151,8 +146,8 @@
</form> </form>
<br> <br>
</div> </div>
{% endif %}
{% endif %} <!-- {% endif %} -->
</div> </div>
</div> </div>

View file

@ -7,12 +7,13 @@ from .views import ContactView, IndexView, AboutView, HistoryView, LoginView, Si
MembershipPricingView, BookingSelectDatesView, BookingPaymentView, OrdersBookingDetailView,\ MembershipPricingView, BookingSelectDatesView, BookingPaymentView, OrdersBookingDetailView,\
BookingOrdersListView, MembershipOrdersListView, OrdersMembershipDetailView, \ BookingOrdersListView, MembershipOrdersListView, OrdersMembershipDetailView, \
MembershipDeactivateView, MembershipDeactivateSuccessView, UserBillingAddressView, \ MembershipDeactivateView, MembershipDeactivateSuccessView, UserBillingAddressView, \
MembershipReactivateView,TermsAndConditions,ValidateUser,SupportusView,Probar,TermsAndConditions2,TermsAndConditions3 MembershipReactivateView,TermsAndConditions,ValidateUser,SupportusView,Probar,TermsAndConditions2,TermsAndConditions3,BookingPaymentView2
# from membership.views import LoginRegistrationView # from membership.views import LoginRegistrationView
urlpatterns = [ urlpatterns = [
url(_(r'booking/payment/view/?$'), BookingPaymentView2, name='booking_payment_view'),
url(_(r'probar3/?$'),TermsAndConditions3, name='probar3'), url(_(r'probar3/?$'),TermsAndConditions3, name='probar3'),
url(_(r'probar2/?$'),TermsAndConditions2.as_view(), name='credit_card_edit'), url(_(r'probar2/?$'),TermsAndConditions2.as_view(), name='credit_card_edit'),
url(_(r'probar/?$'), Probar, name='probar'), url(_(r'probar/?$'), Probar, name='probar'),

View file

@ -21,18 +21,15 @@ from .models import Supporter
from .mixins import ChangeMembershipStatusMixin from .mixins import ChangeMembershipStatusMixin
from utils.forms import ContactUsForm from utils.forms import ContactUsForm
from utils.mailer import BaseEmail from utils.mailer import BaseEmail
from django.views.generic.edit import FormView from django.views.generic.edit import FormView
from membership.calendar.calendar import BookCalendar from membership.calendar.calendar import BookCalendar
from membership.models import Calendar as CalendarModel, StripeCustomer from membership.models import Calendar as CalendarModel, StripeCustomer
from utils.views import LoginViewMixin, SignupViewMixin, \ from utils.views import LoginViewMixin, SignupViewMixin, \
PasswordResetViewMixin, PasswordResetConfirmViewMixin PasswordResetViewMixin, PasswordResetConfirmViewMixin
from utils.forms import PasswordResetRequestForm, UserBillingAddressForm from utils.forms import PasswordResetRequestForm, UserBillingAddressForm
from utils.stripe_utils import StripeUtils from utils.stripe_utils import StripeUtils
from utils.models import UserBillingAddress from utils.models import UserBillingAddress
import stripe
from .forms import LoginForm, SignupForm, MembershipBillingForm, BookingDateForm,\ from .forms import LoginForm, SignupForm, MembershipBillingForm, BookingDateForm,\
BookingBillingForm, CancelBookingForm BookingBillingForm, CancelBookingForm
@ -42,13 +39,37 @@ from .models import MembershipType, Membership, MembershipOrder, Booking, Bookin
from .mixins import MembershipRequiredMixin, IsNotMemberMixin from .mixins import MembershipRequiredMixin, IsNotMemberMixin
''' def BookingPaymentView2(request):
class Probar(TemplateView): #print (request.user)
template_name='digitalglarus/new_credit_card.html' resp = dict()
model = Membership cus = StripeCustomer.get_or_create(email=request.user.email)
success_url = reverse_lazy('digitalglarus:probar') s= str(cus)
''' s= s.split(" ")
resp['object']='card'
resp['exp_month']=request.POST['expMonth']
resp['exp_year']=request.POST['expYear']
resp['number']=request.POST['cardNumber']
resp['cvc']=request.POST['cvCode']
resp['name']=request.POST['cardName']
customer = stripe.Customer.retrieve(s[0])
customer.sources.create(source=resp)
t=stripe.Customer.retrieve(s[0]).sources.all(object="card")
tt=t['data']
x= resp['number']
cc= dict()
for i in tt:
#print (i.id)
#print (i.last4)
#print (x[-4:])
if i.last4 == x[-4:]:
cc['last4']= i.last4
cc['cc_brand']= i.brand
customer.default_source= i.id
customer.save()
current_billing_address = request.user.billing_addresses.first()
#return HttpResponse(json.dumps(resp), content_type ='application/json')
#return render_to_response('digitalglarus/booking_payment.html',{'last4':cc['last4'],'stripe_key': settings.STRIPE_API_PUBLIC_KEY,'street_address': current_billing_address.street_address,'city': current_billing_address.city, 'postal_code': current_billing_address.postal_code,'country': current_billing_address.country,},context_instance= RequestContext(request))
return HttpResponseRedirect('/digitalglarus/booking/payment/')
def Probar(TemplateView): def Probar(TemplateView):
print ("hello") print ("hello")
@ -85,11 +106,55 @@ class ValidateView(SignupViewMixin):
@csrf_exempt @csrf_exempt
def TermsAndConditions(request): def TermsAndConditions(request):
#template_name ="digitalglarus/new_credit_card.html" cus = StripeCustomer.get_or_create(email=request.user.email)
print (request.user) s= str(cus)
#u+Contacto.objects.filter(asesor = U.objects.get(email=request.session['user'])) s= s.split(" ")
#t=stripe.Customer.retrieve(s[0]).sources.all(object="card")
#tt=t['data']
#print (tt)
#for i in tt:
# print (i.id)
# print (i.last4)
# print ("aja estoy aqui",i.id)
# customer = stripe.Customer.retrieve(s[0])
# customer.sources.retrieve(i.id).delete()
# crear tarjeta de credito
customer = stripe.Customer.retrieve(s[0])
#print ("voy por aqui")
custom_card= customer.default_source
t=stripe.Customer.retrieve(s[0]).sources.all(object="card")
tt=t['data']
#print (tt)
cc = dict()
for i in tt:
#print (i.id)
#print (i.last4)
if i.id== custom_card:
#print ("ESTA ES LA TARJETA ACTUAL")
cc['last4']= i.last4
cc['cc_brand'] = i.brand
#customer.sources.create(source=resp)
#t=stripe.Customer.retrieve(s[0]).sources.all(object="card")
#tt=t['data']
#x= resp['number']
#for i in tt:
# print (i.id)
# print (i.last4)
# print (x[-4:])
# if i.last4 == x[-4:]:
# print ("ESTOY AQUI")
# customer.default_source= i.id
#customer.save()
m=MembershipOrder.objects.filter(customer__user=request.user) m=MembershipOrder.objects.filter(customer__user=request.user)
customer = StripeCustomer.get_or_create(email=request.user.email) customer = StripeCustomer.get_or_create(email=request.user.email)
last_booking_order = BookingOrder.objects.filter(customer__user=request.user).last() last_booking_order = BookingOrder.objects.filter(customer__user=request.user).last()
last_membership_order = MembershipOrder.objects.filter(customer__user=request.user).last() last_membership_order = MembershipOrder.objects.filter(customer__user=request.user).last()
credit_card_data = last_booking_order.get_booking_cc_data() if last_booking_order \ credit_card_data = last_booking_order.get_booking_cc_data() if last_booking_order \
@ -97,9 +162,13 @@ def TermsAndConditions(request):
else last_membership_order.get_membership_order_cc_data() else last_membership_order.get_membership_order_cc_data()
current_billing_address = request.user.billing_addresses.first() current_billing_address = request.user.billing_addresses.first()
return render_to_response('digitalglarus/new_credit_card.html',{'last4':credit_card_data['last4'],'brand_type':credit_card_data['cc_brand'],'stripe_key': settings.STRIPE_API_PUBLIC_KEY,'street_address': current_billing_address.street_address,'city': current_billing_address.city, 'postal_code': current_billing_address.postal_code,'country': current_billing_address.country,},context_instance= RequestContext(request))
#return render_to_response('digitalglarus/new_credit_card.html',{'last4':credit_card_data['last4'],'brand_type':credit_card_data['cc_brand'],'stripe_key': settings.STRIPE_API_PUBLIC_KEY,'street_address': current_billing_address.street_address,'city': current_billing_address.city, 'postal_code': current_billing_address.postal_code,'country': current_billing_address.country,},context_instance= RequestContext(request))
return render_to_response('digitalglarus/new_credit_card.html',{'last4':cc['last4'],'brand_type':cc['cc_brand'],'stripe_key': settings.STRIPE_API_PUBLIC_KEY,'street_address': current_billing_address.street_address,'city': current_billing_address.city, 'postal_code': current_billing_address.postal_code,'country': current_billing_address.country,},context_instance= RequestContext(request))
#return render_to_response('digitalglarus/new_credit_card.html',{'last4':'probando','brand_type':'probando','stripe_key': settings.STRIPE_API_PUBLIC_KEY,'street_address': current_billing_address.street_address,'city': current_billing_address.city, 'postal_code': current_billing_address.postal_code,'country': current_billing_address.country,},context_instance= RequestContext(request))
''' '''
def get_success_url(self): def g
et_success_url(self):
# redirect to membership orders list if user has at least one. # redirect to membership orders list if user has at least one.
print (self.request.user) print (self.request.user)
print ("JNSKDJNASJDNKSJANDKJNSAKJDNKJND") print ("JNSKDJNASJDNKSJANDKJNSAKJDNKJND")
@ -256,9 +325,34 @@ class BookingPaymentView(LoginRequiredMixin, MembershipRequiredMixin, FormView):
user = self.request.user user = self.request.user
last_booking_order = BookingOrder.objects.filter(customer__user=user).last() last_booking_order = BookingOrder.objects.filter(customer__user=user).last()
last_membership_order = MembershipOrder.objects.filter(customer__user=user).last() last_membership_order = MembershipOrder.objects.filter(customer__user=user).last()
credit_card_data = last_booking_order.get_booking_cc_data() if last_booking_order \
and last_booking_order.get_booking_cc_data() \ #credit_card_data = last_booking_order.get_booking_cc_data() if last_booking_order \
else last_membership_order.get_membership_order_cc_data() # and last_booking_order.get_booking_cc_data() \
# else last_membership_order.get_membership_order_cc_data()
#print ("LA TARJETA NATACHA QUE QUEREMOS VER SI FUNCIONA ES ESTA",credit_card_data)
#credit_card_data =
#### ESTOY POR AQUI CAMBIANDO ESTO UN POCO PARA VER SI FUNCIONA
##########################################################################################
cus = StripeCustomer.get_or_create(email=user )
s= str(cus)
s= s.split(" ")
customer = stripe.Customer.retrieve(s[0])
#print ("voy por aqui")
custom_card= customer.default_source
t=stripe.Customer.retrieve(s[0]).sources.all(object="card")
tt=t['data']
cc = dict()
for i in tt:
#print (i.id)
#print (i.last4)
if i.id== custom_card:
credit_card_data= i
#print ("ESTA ES LA TARJETA ACTUAL")
cc['last4']= i.last4
cc['cc_brand'] = i.brand
##########################################################################
booking_data.update({ booking_data.update({
'credit_card_data': credit_card_data if credit_card_data else None, 'credit_card_data': credit_card_data if credit_card_data else None,