什么是PayPal自适应付款JSON连锁支付
问题描述:
我已经成功实现了在使用paypal-sdk-adaptivepayments
宝石的Rails中创建简单付款。的JSON是从文档如下:什么是PayPal自适应付款JSON连锁支付
{
:actionType => "PAY",
:cancelUrl => "http://localhost:3000/samples/adaptive_payments/pay",
:currencyCode => "USD",
:feesPayer => "EACHRECEIVER",
:ipnNotificationUrl => "http://localhost:3000/samples/adaptive_payments/ipn_notify",
:receiverList => {
:receiver => [{
:amount => self.amount,
:email => self.help_request.creator.master_profile.paypal_email }] },
:returnUrl => "http://localhost:3000/samples/adaptive_payments/pay"
}
我需要的,但是,设置一个类似JSON字符串,但使用多个接收器(一个主)为链式支付。贝宝文档展示了如何做到这一点,但它不是在JSON这正是我需要的SDK:
&actionType=PAY
&cancelUrl=http:\\example.com\cancel.htm
¤cyCode=USD
&receiverList.receiver(0).amount=9.00
&receiverList.receiver(0)[email protected]
&receiverList.receiver(1).amount=5.00
&receiverList.receiver(1)[email protected]
&requestEnvelope.errorLanguage=en_US
&returnUrl=http:\\example.com\return.htm
有人知道如何设置呢?这不是很明显
答
我发现了格式,它并不直观。基本结构可以看出here,他们表现出来是这样的:
params = {
'requestEnvelope' : {'errorLanguage' : 'en_US', 'detailLevel' : 'ReturnAll'},
'actionType' : 'PAY',
'receiverList' : {
'receiver' : [
{'email' : receiver1, 'amount' : amount1, 'primary' : True },
{'email' : receiver2, 'amount' : amount2, 'primary' : False},
{'email' : receiver3, 'amount' : amount2, 'primary' : False}
],
},
'currencyCode' : 'USD',
'memo' : 'Chained payment example.',
'cancelUrl' : cancel_url,
'returnUrl' : return_url,
}
这里大概是我在我的应用程序中使用:
{
:actionType => "PAY",
:cancelUrl => "http://localhost:3000/samples/adaptive_payments/pay",
:currencyCode => "USD",
:feesPayer => "PRIMARYRECEIVER",
:ipnNotificationUrl => "http://localhost:3000/samples/adaptive_payments/ipn_notify",
:receiverList => {
:receiver => [{
:amount => self.amount,
:email => self.help_request.creator.master_profile.paypal_email,
:primary => 'true' },
{
:amount => self.fee_amount,
:email => '[email protected]',
:primary => 'false' }
]
},
:returnUrl => "http://localhost:3000/samples/adaptive_payments/pay"
}