我尝试在交易后从PayPal接收ipn信号,但由于某些原因我无法得到它。这是我的表格(我使用简单的表单html发送到paypal):
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" id="checkout_form_id">
<input type="hidden" name="business" value="mygmail@gmail.com" id="id_business"/>
<input type="hidden" name="amount" value="" id="id_amount"/>
<input type="hidden" name="item_name" value="Payment for victorywow.com" id="id_item_name"/>
<input type="hidden" name="notify_url" value="{{ paypal_url }}/paypal/" id="id_notify_url"/>
<input type="hidden" name="cancel_return" value={{ paypal_url }}?cancel_return= id="id_cancel_return"/>
<input id="id_return_url" name="return" type="hidden" value="{{ paypal_url }}?success_return="/>
<input type="hidden" name="invoice" value="" id="id_invoice"/>
<input type="hidden" name="cmd" value="_xclick" id="id_cmd"/>
<input type="hidden" name="charset" value="utf-8" id="id_charset"/>
<input type="hidden" name="currency_code" value="USD" id="id_currency_code"/>
<input type="hidden" name="no_shipping" value="1" id="id_no_shipping" />
<input type="button" class="form_button pay_pal_but" value="PAY NOW">
</form>
某些变量invoice_id
,amount
等我按js
添加。
&#39; paypal_url&#39;我在views.py
中创建:request.build_absolute_uri(reverse('index'))
(index
是这样的网址'^$'
)
urls.py
:
url(r'^paypal/', include('paypal.standard.ipn.urls'))
signals.py
:
from paypal.standard.models import ST_PP_COMPLETED
from paypal.standard.ipn.signals import valid_ipn_received
from .models import Order
def ipn_geter(sender, **kwargs):
print(1000 * '*')
ipn_obj = sender
print(ipn_obj.receiver_email)
order = Order.objects.get(id=28)
order.email = ipn_obj.receiver_email
order.save()
if ipn_obj.payment_status == ST_PP_COMPLETED:
pass
valid_ipn_received.connect(ipn_geter)
但成功后,paypal事务ipn_geter
无法执行。我该怎么做才能解决它。为什么我没有得到ipn信号?
编辑:
我读到我无法向localhost
网址发送ipn信号,因此我使用ngrox对其进行了更改以进行测试。运行ngrox后,我发送ipn信号,结束获取paypal
url的200状态代码,但数据没有改变,在控制台中我看不到*
,所以函数没有执行。我怎么解决这个问题?