Clear a few things on the tutorial - signals processing - payment button

78 views
Skip to first unread message

babintel

unread,
Feb 7, 2011, 6:47:04 AM2/7/11
to django-paypal
Hi all,
I am a bit new on django and just would like to make sure my
understanding is good before I go on integrating payments on my app.

1-PAYPAL_DICT
paypal_dict{
"invoice":"unique"
}

I am thinking of modeling it as {{client.pk}}+"-"+
{{client.order.number}}+"-"+{{other_bla_bla"}}
I hope this number comes back to me from paypal by a signal and that I
can parse this numbers and process my order.
Am I right?

I Understand that "notify_url" is the url for signals, and
"return_url" is the url where the client will be
redirected from paypal to my site after paying, correct?

Can I add other keys to this dictionnary
( "my_custom_data_to_recover_later":"this_data")?


2-IPN and SIGNALS PROCESSING
if i get it right, django-paypal handles IPN by itself, all I have to
do is connect the signals to functions and do what I have to do when I
am signaled. Practically :

#models.py
payment_was_successful.connect(process_successfull_payment)
payment_was_flagged.connect(process_flagged_payment)

#views.py
def process_successfull_payment(sender, **kwargs):
blabla

def process_flagged_payment(sender, **kwargs):
blibli

Is that the correct way to handle the signals ?

What will I find in sender anf **kwargs ? the initial dictionary ?
can I even pull anything form **kwargs ?

3-Payment Button
When I opened my Paypal account I was able to configure a custom
button. is there a way I can recover it?
(my site is in French and the paypal button saying "Buy" is not really
convinient)

I know it is a lot of questions but hopefully most of the answers will
be "correct" ;)

Thanks in advance

A.

babintel

unread,
Feb 7, 2011, 4:15:13 PM2/7/11
to django-paypal
Hello !
Replying to myself

it works if the signal lives beneath the functions they trigger in
models.py. But when I run "manage.py test ipn", I don't seem to gain
access to my models :
###models.py

def process_successfull_payment(sender, **kwargs):
ipn_obj = sender
azer=Client.objects.get(pk=int(ipn_obj.invoice[0])) #
int(ipn_obj.invoice[0])=1 in my tests
azer.name="ypiee"
azer.save()

payment_was_successful.connect(process_successfull_payment)
###
does not change the client, more, it gives an error "DoesNotExist:
Client matching query does not exist."

But when i create a test2() function that just does
def test2():
azer=Client.objects.get(pk=1)
azer.name="ypiee"
azer.save()

it works and my data is updated.

I have 2 explanations to this :
1 external data is not accessible nor changeable in tests
2 something else happens that I need to understand ;)

Can someone confirm on this ?

Moreover I cannot manage to get results when connecting and copying
the functions in views.py (which I would like a lot!)

So to resume :
1-paypal_dict => ok figured it by looking at the classes in the paypal
app
2-IPN signals processing => is it testing that prevents me from
touching my data ? how can I put the functions triggered in views
(would seem more homogeneous)
3-question on the custom button remains

Thanks a lot
regards

A.
Reply all
Reply to author
Forward
0 new messages