2

我有一個紅寶石軌應用程序;我希望有一個用戶能夠支付另一個用戶,少於10%的佣金給應用程序;我的客戶希望從應用程序保留的10%中獲得費用,原因有兩個:1)不是鎳/消費者的客戶2)在一定交易量(每月)後,顯然百分比變低Rails貝寶連鎖支付費用

因此例如,如果用戶1支付用戶2 $ 100,我希望它顯示爲:

用戶1嚮應用程序發送100美元 - >應用程序收到97.09美元($ 100減少費用) - > 應用程序發送90.00(90% )到用戶2 - >用戶2收到全部$ 90(在他那邊不收費)

但是,儘管將應用設置爲主要接收方,它將這些費用公佈在輔助接收方上,使得用戶2支付了費用。我也嘗試將用戶2設置爲主要用戶,之後只嚮應用發送10%轉發,但後來將費用轉移到主接收方。我在代碼中修改的唯一內容是收取的百分比,以及主要/次要電子郵件。我的代碼如下所示:

<!-- app/lib/pay_pal_api.rb --> 
require "pp-adaptive" 

class PayPalAPI 

def self.payment_url(submission) 
    amount = submission.amount_in_cents.to_f/100.0 
    recipient_cut = amount * 0.9 
    recipient_email = submission.submitter.paypal_email 

    client.execute(:Pay, 
    :action_type  => "PAY", 
    :currency_code => "USD", 
    :cancel_url  => "http://localhost:3000/my-studio", 
    :return_url  => "http://localhost:3000/submissions/#{submission.id}", 
    :receivers  => [ 
     { :email => recipient_email, :amount => recipient_cut, :primary => false }, 
     { :email => "[email protected]", :amount => amount, :primary => true } 
    ] 
) do |response| 

    if response.success? 
     puts "Pay key: #{response.pay_key}" 

     # send the user to PayPal to make the payment 
     # e.g. https://www.sandbox.paypal.com/webscr?cmd=_ap-payment&paykey=abc 
     return client.payment_url(response) 
    else 
     puts "#{response.ack_code}: #{response.error_message}" 
    end 

    end 
    return nil 
end 

回答

1

使用feesPayer字段並將其設置爲PRIMARYRECEIVERSECONDARYONLY取決於誰是第一個收到付款。這樣做的紅寶石SDK版本是fees_payer - 從API Reference

feesPayer xs:string (Optional) The payer of PayPal fees. Allowable values are: 
     SENDER – Sender pays all fees (for personal, implicit simple/parallel payments; do not use for chained or unilateral payments) 
     PRIMARYRECEIVER – Primary receiver pays all fees (chained payments only) 
     EACHRECEIVER – Each receiver pays their own fee (default, personal and unilateral payments) 
     SECONDARYONLY – Secondary receivers pay all fees (use only for chained payments with one secondary receiver) 

EG:

client.execute(:Pay, 
    :action_type  => "PAY", 
    :currency_code => "USD", 
    :cancel_url  => "http://localhost:3000/my-studio", 
    :return_url  => "http://localhost:3000/submissions/#{submission.id}", 
    :fees_payer  => "SECONDARYONLY", 
    :receivers  => [ 
     { :email => recipient_email, :amount => recipient_cut, :primary => false }, 
     { :email => "[email protected]", :amount => amount, :primary => true } 
    ] 
) 
+0

我很感謝您的迴應;但我錯了,它仍然向中學而不是小學收費。我添加了::feesPayer =>「PRIMARYRECEIVER」,如下:return_url,它仍然不起作用。 *嘆* – Azketta

+0

你們有什麼想法如何推遲鏈接付款? – codigomonstruo

2

我想通了,在PP-自適應的寶石,它需要這樣的語法:

:fees_payer  => "PRIMARYRECEIVER", 

現在它工作完美。

+0

謝謝,我已經相應地更新了我的答案。這在我能找到的任何SDK文檔中都不清楚。 – Aaron