2013-06-18 3 views
0

내가 사용하는 장고 - 페이팔 사용자가 지불을 할 때 내가 Truefinished 필드를 변경하려면 어떻게 https://github.com/johnboxall/django-paypal사용자가 결제 할 때 완료 필드를 True로 변경하려면 어떻게해야합니까?

def view_that_asks_for_money(request): 
    my_order = Order.objects.get(id=1) 

    # What you want the button to do. 
    paypal_dict = { 
     "business": "[email protected]", 
     "amount": my_order.total_price, 
     "item_name": my_order.name, 
     "invoice": "unique-invoice-id", 
     "notify_url": "http://www.example.com/your-ipn-location/", 
     "return_url": "http://www.example.com/your-return-location/", 
     "cancel_return": "http://www.example.com/your-cancel-location/", 

    } 

    # Create the instance. 
    form = PayPalPaymentsForm(initial=paypal_dict) 
    context = {"form": form} 
    return render_to_response("payment.html", context) 

노력하고있어?

class Order(models.Model): 
    ... 
    finished = models.BooleanField(default=False) 
    ... 

답변

2

ipn 신호 payment_was_successful을 청취해야합니다. 받은 경우 주문 상태를 변경 :

from django.dispatch import receiver 
from paypal.standard.ipn.signals import payment_was_successful 

@receiver(payment_was_successful) 
def complete_order(sender, **kwargs): 
    """ 
    Receiver function for successful payment. 
    Calls when PayPal returns success. 
    """ 
    ipn_obj = sender 
    # do your work here