简体   繁体   中英

What's the JSON for PayPal Adaptive Payments Chained Payment

I've successfully implemented creating simple payments in Rails using the paypal-sdk-adaptivepayments gem. The JSON is as follows from the documentation:

  {
    :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"
  }

I need, however, to set up a similar JSON string but with multiple receivers (one primary) for a chained payment. The PayPal docs show how to do this, but it's not in JSON which is what I need for the SDK:

&actionType=PAY
&cancelUrl=http:\\example.com\cancel.htm
&currencyCode=USD
&receiverList.receiver(0).amount=9.00
&receiverList.receiver(0).email=andrea@example.com
&receiverList.receiver(1).amount=5.00
&receiverList.receiver(1).email=linda@example.com
&requestEnvelope.errorLanguage=en_US
&returnUrl=http:\\example.com\return.htm

Anybody know how to set this up? It's not immediately obvious

I found out the format, and it's not intuitive. The basic structure can be seen here where they show it this way:

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,
}

Here's roughly what I used in my application:

  {
    :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 => 'receiver2@email.com',
        :primary => 'false' }
        ]
      },
    :returnUrl => "http://localhost:3000/samples/adaptive_payments/pay"
  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM