我在 Django 中使用贝宝。这就是场景。用户已登录,他还没有为服务付费。付款后,我必须将他的用户资料更新为“已付款 = True”。然后他将可以访问整个站点。
我正在努力理解这必须如何与贝宝集成。我使付款成功。但是,当贝宝向用户收费时,我的服务器如何知道它将是哪个用户呢?
我认为必须有一个字段供我发送到贝宝,例如用户 ID,然后贝宝在付款时必须将其发送给我,这样我才能看到它是哪个用户?
你如何用贝宝实现这个?
创建按钮
paypal_dict = {
"cmd": "_xclick-subscriptions",
"business": settings.PAYPAL_RECEIVER_EMAIL,
"a3": "5.00", # monthly price
"p3": 1, # duration of each unit (depends on unit)
"t3": "M", # duration unit ("M for Month")
"src": "1", # make payments recur
"sra": "1", # reattempt payment on payment error
"no_note": "1", # remove extra notes (optional)
"item_name": "Test monthly subscription",
"notify_url": "http://localhost:8000/payment/",
"return_url": "http://localhost:8000/",
"cancel_return": "http://localhost:8000/",
"custom":request.user.get_profile().pk
}
# Create the instance.
ppform = PayPalPaymentsForm(initial=paypal_dict, button_type="subscribe")