我在哪里可以获得执行付款payer_id(PayPal)?



使用PayPal Python REST SDK。创建付款后,我们需要执行此付款。https://github.com/paypal/PayPal-Python-SDK/blob/master/samples/payment/execute.py 是代码示例。但是在执行付款时

if payment.execute({"payer_id": "DUFRQ8GWYMJXC"}):  # return True or False
print("Payment[%s] execute successfully" % (payment.id))
else:
print(payment.error)

我们需要写payer_id。但是我怎么能接受呢?有什么想法或代码示例吗?

payerid 在回调的主机标头中返回 - 或者,您可以执行以下操作。

在创建销售的过程中,请...

saleinfo_ = {"intent":"sale",
"redirect_urls":{
"return_url":("myurlonsuccess"),
"cancel_url":("myurlonfail")
},
"payer":{"payment_method":"paypal"},
"transactions":[
{"amount":{"total":out_totaltopay_, "details":{"tax":out_taxes_, "subtotal":out_subtotal_}, "currency":symbol_}, "description":description_}
payment_ = Payment(saleinfo_)
if (payment_.create()):
token_ = payment_.id

然后,当返回回调到达时,使用...

payment_ = Payment.find(token_)
if (payment_ != None):
payerid_ = payment_.payer.payer_info.payer_id
if (payment_.execute({"payer_id":payerid_})):
....

查找过程中收到的 json 数据类似于以下内容

{'payment_method': 'paypal', 'status': 'VERIFIED', 'payer_info': {'shipping_address': {'line1': '1 Main St', 'recipient_name': 'Test Buyer', 'country_code': 'US', 'state': 'CA', 'postal_code': '95131', 'city': 'San Jose'}, 'first_name': 'Test', 'payer_id': '<<SOMEID>>', 'country_code': 'US', 'email': 'testbuyer@mydomain.com', 'last_name': 'Buyer'}}

希望有帮助

最新更新