我使用的是标准的django paypal模块: https://github.com/spookylukey/django-paypal
我试图实现的是一个人可以添加资金到他们的帐户在我的网站上,而不要求他们有一个贝宝帐户档案(解释如下)。目前我的系统是
def paypal_payment_successful(sender, **kwargs):
#Called when the payment is sucessful
ipn_obj = sender
if ipn_obj.payment_status == "Completed":
try:
user_profile = models.UserProfile.objects.get(paypal_account=sender.payer_email)
user_profile.account_balance += float(ipn_obj.mc_gross)
user_profile.save()
except models.UserProfile.DoesNotExist:
pass # TODO email admin
paypal_signals.payment_was_successful.connect(paypal_payment_successful)
@csrf_exempt
def account_paypal_return(request):
if request.REQUEST.get('payment_status') == 'Completed':
messages.add_message(request, messages.INFO,
message=_('The amount of %(amount)s was successfully deposited to your account.') % {
'amount': utils.format_currency(float(request.REQUEST['mc_gross']))})
notifications.notify_paypal_payment(request.user, int(float(request.REQUEST['mc_gross'])))
return HttpResponseRedirect('/account/')
如果你看一下paypal_payment_successful函数,你可以看到目前我通过ipn提供的paypal帐户和用户配置文件中的paypal帐户获取关联的用户。有没有其他方法可以让我知道如何更新用户的帐户配置文件,而不要求他们在其配置文件中保存一个。在
如果我能以某种方式结合贝宝支付成功和帐户贝宝返回(这是从贝宝网站返回调用)我可以使用请求.user.id确定用户。在
明白了。在页面的查看功能中,您可以添加我修改了paypal字典的资金
我把成功的函数调用改为
^{pr2}$相关问题 更多 >
编程相关推荐