2016-08-04 96 views
0

我已經成功實現了在使用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 
&currencyCode=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 

有人知道如何設置呢?這不是很明顯

回答

0

我發現了格式,它並不直觀。基本結構可以看出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" 
    } 
相關問題