Well... I wasn't using a paypal test business account... changed that and it worked. O well
-- See here for the full answer to question
On Tuesday, March 21, 2017 at 2:59:29 PM UTC-6, Michael Goytia wrote:
On Tuesday, March 21, 2017 at 2:59:29 PM UTC-6, Michael Goytia wrote:
Hello All,
I have a similar issue to the post "Updating Django database when using django-paypal"What we are trying to do(I don't know this other person but I assume we stand together on this topic) is to understand how to deduce a path to receiving a paypal IPN signal in which we then can update the django database.I have implemented the django-paypal API by following the directions hereOverall what I do is I create a view in my views.py as followsdef payment_page(request):"""This fucntion returns payment page for the form"""if not request.session.get('form-submitted' , False):return HttpResponseRedirect(reverse('grap_main:error_page' ))else:amount = set_payment()paypal_dict = {"amount": str(amount),"item_name": "2017 USGF Championships","cancel_return": "https://15b6b6cb.ngrok.io/RegistrationForm ",}form = PayPalPaymentsForm(initial=paypal_dict )context = confirm_information()context["amount"] = amountcontext["form"] = formrequest.session['form-submitted' ] = Falsevalid_ipn_received.connect(show_me_the_money )return render(request, "grap_main/payment.html", context)Where my then I have payment.html which then create the paypal button simply by using the line as advised in the documentation{{ form.render }}Now I can receive a POST to the paypal url that I specified in the documentation however I don't know where I should put my signal function that will grab the IPNs once someone has completed a purchase.def show_me_the_money(sender, **kwargs):"""signal function"""
ipn_obj = senderif ipn_obj.payment_status == ST_PP_COMPLETED:print 'working'else:print "not working"Right now I am calling this function in the view payment_page() however I know this is before the POST to the paypal and is not correctI don't understand where I should call the show_me_the_money() function. I am used to creating a views in which is called from the html script as shown belowdef register(request):"""aquire information from new entry"""if request.method != 'POST':form = RegisterForm()else:if 'refill' in request.POST:form = RegisterForm()else:form = RegisterForm(data=request.POST) if form.is_valid():form.save()request.session['form-submitted' ] = Truereturn HttpResponseRedirect(reverse('grap_main:payment_page' ))<form action="{% url 'grap_main:register' %}" method='post' class="form">{% csrf_token %}{% bootstrap_form form %}<br>{% buttons %}<center><button name='submit' class="btn btn-primary">Submit</button></center>{% endbuttons %}</form>I believe I need to call the function after a person has completed a purchase however I don't know how to target that time window in my code. I want to make sure I handle a case in which the user once there are done paying don't always return to the merchant site.Any help on this subject would not only benefit me but also the earlier poster. I hope to make a tutorial when I figure this out to help others that might get stuck as well.Please note that I have also use ngrok to make sure my project is accessible to the paypal IPN service. I am using two urls.py files as well, i which the main one looks as sourlpatterns = [url(r'^paypal/', include('paypal.standard.ipn.urls' )),url(r'^admin/', admin.site.urls),url(r'', include('grap_main.urls', namespace='grap_main')),
]
where the 'grap_main.urls' are all the specific views for my site, ex.url(r'^$', views.index, name='index'),urlpatterns = [url(r'^Confirm', views.confirm, name='confirm'),url(r'^Events', views.events, name='events'),
.........]Thanks.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1b600f65-2b8c-435f-92f9-27e4e8eeaa35%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment