1
我是一位Ruby用戶,他試圖製作一個Ruby應用程序,允許我付錢給我的朋友。我的朋友單獨擁有Paypal帳戶(即[email protected])。我有一筆錢,我必須支付給我的朋友。 我有一個商業帳戶。 ([email protected])。 但我無法找到我可以付錢給我的朋友。如何讓Ruby應用程序向特定用戶匯款?
我必須將我的信用卡信息或只是我的電子郵件地址和金額?另外我應該在哪裏放置我的朋友的電子郵件地址?
我真的很想知道如何有效地。我期待得到一個反饋!
最佳
require 'paypal-sdk-rest'
PayPal::SDK::Core::Config.load('config/paypal.yml', ENV['RACK_ENV'] || 'development')
PayPal::SDK.logger = Logger.new(STDERR)
PayPal::SDK.logger.level = Logger::INFO
PayPal::SDK.configure({
:mode => "sandbox",
:client_id => "xxx-xx",
:client_secret => "xx-xx"
})
@payment = PayPal::SDK::REST::Payment.new({
:intent => "sale",
:payer => {
:payment_method => "credit_card",
:funding_instruments => [{
:credit_card => {
:type => "visa",
:number => "4567516310777851",
:expire_month => "11",
:expire_year => "2018",
:cvv2 => "874",
:first_name => "Joe",
:last_name => "Shopper",
:billing_address => {
:line1 => "52 N Main ST",
:city => "Johnstown",
:state => "OH",
:postal_code => "",
:country_code => "US" }}}]},
:transactions => [{
:item_list => {
:items => [{
:name => "item",
:sku => "item",
:price => "1",
:currency => "USD",
:quantity => 1 }]},
:amount => {
:total => "1.00",
:currency => "USD" },
:description => "This is the payment transaction description." }]})
# Create Payment and return the status(true or false)
if @payment.create
@payment.id # Payment Id
else
@payment.error # Error Hash
end
如果您在測試過程中需要幫助,我很樂意提供幫助。我的電子郵件地址在我的檔案中。 –