Cant find how to implement django-paypal correctlySaving form data rewrites the same rowHow to find if directory exists in PythonFor statement in Django templates doesn't work'NoneType' object is not subscriptable in using django smart selectsHow to expose some specific fields of model_b based on a field of model_a?How to set dynamic initial values to django modelform fielddjango how to hide specific form filed and loop data inputDjango-Paypal: How to create a unique django-paypal form for each object in a store model, and then display the Buy Now buttons with template tags?How to check if Django Signal works?How can I insert foreign key values into forms?
Running a linear programming model to maximize binned predictions
Why are so many countries still in the Commonwealth?
Why are angular mometum and angular velocity not necessarily parallel, but linear momentum and linear velocity are always parallel?
Are glider winch launches rarer in the USA than in the rest of the world? Why?
Who has jurisdiction for a crime committed in an embassy?
Inadvertently nuked my disk permission structure - why?
Invert Some Switches on a Switchboard
Should I describe a character deeply before killing it?
Please help, I’m a problem player
Why did NASA use Imperial units?
What is the meaning of "a thinly disguised price"?
Can GPL and BSD licensed applications be used for government work?
What do I do when a student working in my lab "ghosts" me?
Historicity doubted by Romans
The seven story archetypes. Are they truly all of them?
What is a reasonable time for modern human society to adapt to dungeons?
Book with a female main character living in a convent who has to fight gods
What are the exact meanings of roll, pitch and yaw?
High income, sudden windfall
Where to place an artificial gland in the human body?
Why did computer video outputs go from digital to analog, then back to digital?
Spoken encryption
Other than a swing wing, what types of variable geometry have flown?
Why keep the bed heated after initial layer(s) with PLA (or PETG)?
Cant find how to implement django-paypal correctly
Saving form data rewrites the same rowHow to find if directory exists in PythonFor statement in Django templates doesn't work'NoneType' object is not subscriptable in using django smart selectsHow to expose some specific fields of model_b based on a field of model_a?How to set dynamic initial values to django modelform fielddjango how to hide specific form filed and loop data inputDjango-Paypal: How to create a unique django-paypal form for each object in a store model, and then display the Buy Now buttons with template tags?How to check if Django Signal works?How can I insert foreign key values into forms?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I know how the django paypal system is supposed to work. I try to follow the instructions here: https://django-paypal.readthedocs.io/en/stable/standard/ipn.html
My problem is that i dont understand most of it. This is what i have:
views.py
from django.core.urlresolvers import reverse
from django.shortcuts import render
from paypal.standard.forms import PayPalPaymentsForm
from .models import Subs
from .forms import SubForm
from django.shortcuts import redirect
from forum.views import home
from django.urls import reverse
def BuyShit(request):
user = request.user
if request.method == "POST":
formbuy = SubForm(request.POST)
if formbuy.is_valid() and 'buy' in request.POST:
sub = formbuy.save(commit=False)
sub.owner = user
sub.save()
order_created.delay(sub.id)
request.session['order_id'] = sub.id
return redirect(home)
forms.py
from django import forms
from .models import Subs
class SubForm(forms.ModelForm):
class Meta:
model = Subs
fields = ('item','price')
models.py
from django.db import models
from forum.models import Post
from django.contrib.auth.models import User
# Create your models here.
class Subs(models.Model):
item = models.Charfield(max_length=55, verbose_name='item')
price = models.Charfield(max_length=55, verbose_name='item')
owner = models.Charfield(User, max_length=55, verbose_name='item')
I have also added the appropriate settings and url for paypal:
url(r'^paypal/', include('paypal.standard.ipn.urls')),
On the link to the django-paypal, they have this in views.py:
from django.core.urlresolvers import reverse
from django.shortcuts import render
from paypal.standard.forms import PayPalPaymentsForm
def view_that_asks_for_money(request):
# What you want the button to do.
paypal_dict =
"business": "receiver_email@example.com",
"amount": "10000000.00",
"item_name": "name of the item",
"invoice": "unique-invoice-id",
"notify_url": request.build_absolute_uri(reverse('paypal-ipn')),
"return": request.build_absolute_uri(reverse('your-return-view')),
"cancel_return": request.build_absolute_uri(reverse('your-cancel-view')),
"custom": "premium_plan", # Custom command to correlate to some function later (optional)
# Create the instance.
form = PayPalPaymentsForm(initial=paypal_dict)
context = "form": form
return render(request, "payment.html", context)
Which part of it do i use? where do i add how much it costs or the title?
Then there have a hooks.py thing that i really dont understand how that works:
from paypal.standard.models import ST_PP_COMPLETED
from paypal.standard.ipn.signals import valid_ipn_received
def show_me_the_money(sender, **kwargs):
ipn_obj = sender
if ipn_obj.payment_status == ST_PP_COMPLETED:
# WARNING !
# Check that the receiver email is the same we previously
# set on the `business` field. (The user could tamper with
# that fields on the payment form before it goes to PayPal)
if ipn_obj.receiver_email != "receiver_email@example.com":
# Not a valid payment
return
# ALSO: for the same reason, you need to check the amount
# received, `custom` etc. are all what you expect or what
# is allowed.
# Undertake some action depending upon `ipn_obj`.
if ipn_obj.custom == "premium_plan":
price = ...
else:
price = ...
if ipn_obj.mc_gross == price and ipn_obj.mc_currency == 'USD':
...
else:
#...
valid_ipn_received.connect(show_me_the_money)
All the components seem disconected. I am familiar with django but this seems completely different.
I am completely lost. And the tutorials online are terrible. Please help!!! I just need to add a button to buy a single product and on success trigger a function to modify the appropriate model. Sounds simple..... Thanks for any help!!!!!
python django django-forms paypal-ipn django-paypal
add a comment |
I know how the django paypal system is supposed to work. I try to follow the instructions here: https://django-paypal.readthedocs.io/en/stable/standard/ipn.html
My problem is that i dont understand most of it. This is what i have:
views.py
from django.core.urlresolvers import reverse
from django.shortcuts import render
from paypal.standard.forms import PayPalPaymentsForm
from .models import Subs
from .forms import SubForm
from django.shortcuts import redirect
from forum.views import home
from django.urls import reverse
def BuyShit(request):
user = request.user
if request.method == "POST":
formbuy = SubForm(request.POST)
if formbuy.is_valid() and 'buy' in request.POST:
sub = formbuy.save(commit=False)
sub.owner = user
sub.save()
order_created.delay(sub.id)
request.session['order_id'] = sub.id
return redirect(home)
forms.py
from django import forms
from .models import Subs
class SubForm(forms.ModelForm):
class Meta:
model = Subs
fields = ('item','price')
models.py
from django.db import models
from forum.models import Post
from django.contrib.auth.models import User
# Create your models here.
class Subs(models.Model):
item = models.Charfield(max_length=55, verbose_name='item')
price = models.Charfield(max_length=55, verbose_name='item')
owner = models.Charfield(User, max_length=55, verbose_name='item')
I have also added the appropriate settings and url for paypal:
url(r'^paypal/', include('paypal.standard.ipn.urls')),
On the link to the django-paypal, they have this in views.py:
from django.core.urlresolvers import reverse
from django.shortcuts import render
from paypal.standard.forms import PayPalPaymentsForm
def view_that_asks_for_money(request):
# What you want the button to do.
paypal_dict =
"business": "receiver_email@example.com",
"amount": "10000000.00",
"item_name": "name of the item",
"invoice": "unique-invoice-id",
"notify_url": request.build_absolute_uri(reverse('paypal-ipn')),
"return": request.build_absolute_uri(reverse('your-return-view')),
"cancel_return": request.build_absolute_uri(reverse('your-cancel-view')),
"custom": "premium_plan", # Custom command to correlate to some function later (optional)
# Create the instance.
form = PayPalPaymentsForm(initial=paypal_dict)
context = "form": form
return render(request, "payment.html", context)
Which part of it do i use? where do i add how much it costs or the title?
Then there have a hooks.py thing that i really dont understand how that works:
from paypal.standard.models import ST_PP_COMPLETED
from paypal.standard.ipn.signals import valid_ipn_received
def show_me_the_money(sender, **kwargs):
ipn_obj = sender
if ipn_obj.payment_status == ST_PP_COMPLETED:
# WARNING !
# Check that the receiver email is the same we previously
# set on the `business` field. (The user could tamper with
# that fields on the payment form before it goes to PayPal)
if ipn_obj.receiver_email != "receiver_email@example.com":
# Not a valid payment
return
# ALSO: for the same reason, you need to check the amount
# received, `custom` etc. are all what you expect or what
# is allowed.
# Undertake some action depending upon `ipn_obj`.
if ipn_obj.custom == "premium_plan":
price = ...
else:
price = ...
if ipn_obj.mc_gross == price and ipn_obj.mc_currency == 'USD':
...
else:
#...
valid_ipn_received.connect(show_me_the_money)
All the components seem disconected. I am familiar with django but this seems completely different.
I am completely lost. And the tutorials online are terrible. Please help!!! I just need to add a button to buy a single product and on success trigger a function to modify the appropriate model. Sounds simple..... Thanks for any help!!!!!
python django django-forms paypal-ipn django-paypal
add a comment |
I know how the django paypal system is supposed to work. I try to follow the instructions here: https://django-paypal.readthedocs.io/en/stable/standard/ipn.html
My problem is that i dont understand most of it. This is what i have:
views.py
from django.core.urlresolvers import reverse
from django.shortcuts import render
from paypal.standard.forms import PayPalPaymentsForm
from .models import Subs
from .forms import SubForm
from django.shortcuts import redirect
from forum.views import home
from django.urls import reverse
def BuyShit(request):
user = request.user
if request.method == "POST":
formbuy = SubForm(request.POST)
if formbuy.is_valid() and 'buy' in request.POST:
sub = formbuy.save(commit=False)
sub.owner = user
sub.save()
order_created.delay(sub.id)
request.session['order_id'] = sub.id
return redirect(home)
forms.py
from django import forms
from .models import Subs
class SubForm(forms.ModelForm):
class Meta:
model = Subs
fields = ('item','price')
models.py
from django.db import models
from forum.models import Post
from django.contrib.auth.models import User
# Create your models here.
class Subs(models.Model):
item = models.Charfield(max_length=55, verbose_name='item')
price = models.Charfield(max_length=55, verbose_name='item')
owner = models.Charfield(User, max_length=55, verbose_name='item')
I have also added the appropriate settings and url for paypal:
url(r'^paypal/', include('paypal.standard.ipn.urls')),
On the link to the django-paypal, they have this in views.py:
from django.core.urlresolvers import reverse
from django.shortcuts import render
from paypal.standard.forms import PayPalPaymentsForm
def view_that_asks_for_money(request):
# What you want the button to do.
paypal_dict =
"business": "receiver_email@example.com",
"amount": "10000000.00",
"item_name": "name of the item",
"invoice": "unique-invoice-id",
"notify_url": request.build_absolute_uri(reverse('paypal-ipn')),
"return": request.build_absolute_uri(reverse('your-return-view')),
"cancel_return": request.build_absolute_uri(reverse('your-cancel-view')),
"custom": "premium_plan", # Custom command to correlate to some function later (optional)
# Create the instance.
form = PayPalPaymentsForm(initial=paypal_dict)
context = "form": form
return render(request, "payment.html", context)
Which part of it do i use? where do i add how much it costs or the title?
Then there have a hooks.py thing that i really dont understand how that works:
from paypal.standard.models import ST_PP_COMPLETED
from paypal.standard.ipn.signals import valid_ipn_received
def show_me_the_money(sender, **kwargs):
ipn_obj = sender
if ipn_obj.payment_status == ST_PP_COMPLETED:
# WARNING !
# Check that the receiver email is the same we previously
# set on the `business` field. (The user could tamper with
# that fields on the payment form before it goes to PayPal)
if ipn_obj.receiver_email != "receiver_email@example.com":
# Not a valid payment
return
# ALSO: for the same reason, you need to check the amount
# received, `custom` etc. are all what you expect or what
# is allowed.
# Undertake some action depending upon `ipn_obj`.
if ipn_obj.custom == "premium_plan":
price = ...
else:
price = ...
if ipn_obj.mc_gross == price and ipn_obj.mc_currency == 'USD':
...
else:
#...
valid_ipn_received.connect(show_me_the_money)
All the components seem disconected. I am familiar with django but this seems completely different.
I am completely lost. And the tutorials online are terrible. Please help!!! I just need to add a button to buy a single product and on success trigger a function to modify the appropriate model. Sounds simple..... Thanks for any help!!!!!
python django django-forms paypal-ipn django-paypal
I know how the django paypal system is supposed to work. I try to follow the instructions here: https://django-paypal.readthedocs.io/en/stable/standard/ipn.html
My problem is that i dont understand most of it. This is what i have:
views.py
from django.core.urlresolvers import reverse
from django.shortcuts import render
from paypal.standard.forms import PayPalPaymentsForm
from .models import Subs
from .forms import SubForm
from django.shortcuts import redirect
from forum.views import home
from django.urls import reverse
def BuyShit(request):
user = request.user
if request.method == "POST":
formbuy = SubForm(request.POST)
if formbuy.is_valid() and 'buy' in request.POST:
sub = formbuy.save(commit=False)
sub.owner = user
sub.save()
order_created.delay(sub.id)
request.session['order_id'] = sub.id
return redirect(home)
forms.py
from django import forms
from .models import Subs
class SubForm(forms.ModelForm):
class Meta:
model = Subs
fields = ('item','price')
models.py
from django.db import models
from forum.models import Post
from django.contrib.auth.models import User
# Create your models here.
class Subs(models.Model):
item = models.Charfield(max_length=55, verbose_name='item')
price = models.Charfield(max_length=55, verbose_name='item')
owner = models.Charfield(User, max_length=55, verbose_name='item')
I have also added the appropriate settings and url for paypal:
url(r'^paypal/', include('paypal.standard.ipn.urls')),
On the link to the django-paypal, they have this in views.py:
from django.core.urlresolvers import reverse
from django.shortcuts import render
from paypal.standard.forms import PayPalPaymentsForm
def view_that_asks_for_money(request):
# What you want the button to do.
paypal_dict =
"business": "receiver_email@example.com",
"amount": "10000000.00",
"item_name": "name of the item",
"invoice": "unique-invoice-id",
"notify_url": request.build_absolute_uri(reverse('paypal-ipn')),
"return": request.build_absolute_uri(reverse('your-return-view')),
"cancel_return": request.build_absolute_uri(reverse('your-cancel-view')),
"custom": "premium_plan", # Custom command to correlate to some function later (optional)
# Create the instance.
form = PayPalPaymentsForm(initial=paypal_dict)
context = "form": form
return render(request, "payment.html", context)
Which part of it do i use? where do i add how much it costs or the title?
Then there have a hooks.py thing that i really dont understand how that works:
from paypal.standard.models import ST_PP_COMPLETED
from paypal.standard.ipn.signals import valid_ipn_received
def show_me_the_money(sender, **kwargs):
ipn_obj = sender
if ipn_obj.payment_status == ST_PP_COMPLETED:
# WARNING !
# Check that the receiver email is the same we previously
# set on the `business` field. (The user could tamper with
# that fields on the payment form before it goes to PayPal)
if ipn_obj.receiver_email != "receiver_email@example.com":
# Not a valid payment
return
# ALSO: for the same reason, you need to check the amount
# received, `custom` etc. are all what you expect or what
# is allowed.
# Undertake some action depending upon `ipn_obj`.
if ipn_obj.custom == "premium_plan":
price = ...
else:
price = ...
if ipn_obj.mc_gross == price and ipn_obj.mc_currency == 'USD':
...
else:
#...
valid_ipn_received.connect(show_me_the_money)
All the components seem disconected. I am familiar with django but this seems completely different.
I am completely lost. And the tutorials online are terrible. Please help!!! I just need to add a button to buy a single product and on success trigger a function to modify the appropriate model. Sounds simple..... Thanks for any help!!!!!
python django django-forms paypal-ipn django-paypal
python django django-forms paypal-ipn django-paypal
edited Mar 26 at 16:10
Mike Kioul MikeKioulepoglou
asked Mar 26 at 15:21
Mike Kioul MikeKioulepoglouMike Kioul MikeKioulepoglou
106 bronze badges
106 bronze badges
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55360701%2fcant-find-how-to-implement-django-paypal-correctly%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55360701%2fcant-find-how-to-implement-django-paypal-correctly%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown