我想通过API向某人发送付款。基本上,我想输入此人的PayPal电子邮件地址和金额并发送。没有批准或任何东西。这是我到目前为止所创建的付款:
headers = {
"X-PAYPAL-SECURITY-USERID": PAYPAL_USERNAME,
"X-PAYPAL-SECURITY-PASSWORD": PAYPAL_PASSWORD,
"X-PAYPAL-SECURITY-SIGNATURE": PAYPAL_SIGNATURE,
"X-PAYPAL-APPLICATION-ID": PAYPAL_APP_ID,
"X-PAYPAL-SERVICE-VERSION": PAYPAL_SERVICE_VERSION,
"X-PAYPAL-REQUEST-DATA-FORMAT": "NV",
"X-PAYPAL-RESPONSE-DATA-FORMAT": "JSON",
}
params = OrderedDict()
params['requestEnvelope.errorLanguage'] = 'en_US'
params['actionType'] = 'PAY'
params['currencyCode'] = 'USD'
params['cancelUrl'] = 'https://example.com/'
params['returnUrl'] = 'https://example.com/'
params['receiverList.receiver.email'] = 'david@example.com'
params['receiverList.receiver.amount'] = '1.00'
res = requests.post(
"https://svcs{}.paypal.com/AdaptivePayments/Pay/".format("" if settings.STAGE == "production" else ".sandbox"),
headers=headers, data=params
)
这会成功创建付款对象:
>>> data
{u'responseEnvelope': {u'ack': u'Success', u'timestamp': u'2014-11-19T23:52:50.500-08:00', u'build': u'13414382', u'correlationId': u'5fe166107b9e3'},
u'paymentExecStatus': u'CREATED', u'payKey': u'AP-76K6303883448644B'}
我将如何批准'没有登录或任何东西的付款,这可能吗?我尝试了以下操作,但提出错误,付款必须由发件人授权。
params = OrderedDict()
params['requestEnvelope.errorLanguage'] = 'en_US'
params['payKey'] = 'AP-76K6303883448644B'
res = requests.post(
"https://svcs{}.paypal.com/AdaptivePayments/ExecutePayment/".format("" if settings.STAGE == "production" else ".sandbox"),
headers=headers, data=params )
data = res.json()
我有payKey
后我可以批准/发送付款而无需转到网址并手动批准吗?
答案 0 :(得分:0)
如果您在此处指定senderEmail
,则会立即发起('隐式')付款:
params['senderEmail'] = 'sender@example.com'
以下是有关详细信息的文档:https://developer.paypal.com/docs/classic/api/adaptive-payments/Pay_API_Operation/