我想使用Paypal SDK与Python Flask一起使用Paypal方法实现付款(paypal到paypal,没有Visa卡或其他东西)。我试图了解事情是如何运作的,而且我遇到了一些问题。
1)首先,配置SDK。完成并理解
2)然后,创建付款URL并将用户重定向到该URL。 Done and understood
3)最后,检查用户是否汇款。 Undone and not understood
payment = paypalrestsdk.Payment.find("PAY-57363176S1057143SKE2HO3A")
什么是PAY-57363176S1057143SKE2HO3A?这是在第5行,第51行中看到的payment.id吗?如果是,那么,{"payer_id": "DUFRQ8GWYMJXC"}
是什么?此代码中包含2个ID,create_with_paypal.py
文件中对ID的唯一引用是单payment.id
。
答案 0 :(得分:0)
是的,有单独的付款标识符和为该付款提供资金的一方(个人或公司)。因此,如果foo@bar.com发送henry13@somesite.com 10美元,那么两个付款人之间的资金流动就会有一个付款ID,您可以使用该ID来检索有关付款的信息。交易信息将包括当事人在付款中发送和接收的款项,而发件人(付款人)的帐户ID就是所谓的付款人ID。
答案 1 :(得分:0)
from paypalrestsdk import CreditCard
from paypalrestsdk import Payment
def card_payemnt(request):
paypalrestsdk.configure({
"mode": "sandbox", # sandbox or live
'client_id' :"",
'client_secret':"",
})
credit_card = CreditCard({
"type": "visa",
"number": "4024007185826731",
"expire_month": "12",
"expire_year": "2022",
"cvv2": "874",
"first_name": "Joe",
"last_name": "Shopper",
})
if credit_card.create():
print("CreditCard[%s] created successfully" % (credit_card.id ))
return HttpResponse('good')
else:
print("Error while creating CreditCard:")
print(credit_card.error)
def credit_card_payment(request):
paypalrestsdk.configure({
"mode": "sandbox", # sandbox or live
'client_id': "",
'client_secret': "",
})
payment = paypalrestsdk.Payment(
{
"intent": "sale",
"payer": {
"payment_method": "credit_card",
"funding_instruments": [
{
"credit_card_token": {
"credit_card_id": "CARD-7MH68586JW7132142LXWASJI",
}
}]
},
"transactions": [
{
"amount": {
"total": "6.70",
"currency": "USD"
},
"description": "Payment by vaulted credit card."
}]
}
)
if payment.create():
print(payment.id)
print("Payment created successfully")
else:
print(payment.error)