本文介绍了Paypal Ruby自适应付款的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到了两种有关如何进行付费电话的版本,并且我想知道自己在做错什么,因为这两种版本都不起作用.

I've seen two different versions on how the pay call should be made and I wanted to know what I am doing wrong because both versions do not work.

@result = HTTParty.post('https://svcs.sandbox.paypal.com/AdaptivePayments/Pay',
  :body =>
    {:actionType => "PAY",
     :currencyCode => "USD",
     :receiverList => {
       :receiver => [
         {:amount => "1.00",
          :email => "[email protected]"}]
     },
     :returnUrl => "www.yahoo.com",
     :cancelUrl => "google.com",
     :requestEnvelope => {
       :errorLanguage => "en_US",
       :detailLevel => "ReturnAll"}
     },
     :headers => {
       "X-PAYPAL-SECURITY-USERID" => "caller_13124862354_api1.gmail.com",
       "X-PAYPAL-SECURITY-PASSWORD" => "1234567890",
       "X-PAYPAL-SECURITY-SIGNATURE" => "AbtI7HV1xB428VygBUcIhARzxch4AL78.T19CTeylixNNxDZUu0iO87e",
       "X-PAYPAL-APPLICATION-ID" => "APP-81W284485P518643T",
       "X-PAYPAL-REQUEST-DATA-FORMAT" => "JSON",
       "X-PAYPAL-RESPONSE-DATA-FORMAT" => "JSON"
     }
 )

AND

@result = HTTParty.post('https://svcs.sandbox.paypal.com/AdaptivePayments/Pay',
  :body => {
    :actionType => "PAY",
    :currencyCode => "USD",
    "receiverList.receiver(0).email".to_sym => "[email protected]",
    "receiverList.receiver(0).amount".to_sym => "1.00",
    :returnUrl => "www.yahoo.com",
    :cancelUrl => "gizmodo.com",
    :requestEnvelope => {
      :errorLanguage => "en_US",
      :detailLevel => "ReturnAll"}
  },
  :headers => {
    "X-PAYPAL-SECURITY-USERID" => "caller_13124862354_api1.gmail.com",
    "X-PAYPAL-SECURITY-PASSWORD" => "1234567890",
    "X-PAYPAL-SECURITY-SIGNATURE" => "AbtI7HV1xB428VygBUcIhARzxch5AL65.T18CTeylixNNxDZUu0iO87e",
    "X-PAYPAL-APPLICATION-ID" => "APP-81W284485P518643T",
    "X-PAYPAL-REQUEST-DATA-FORMAT" => "JSON",
    "X-PAYPAL-RESPONSE-DATA-FORMAT" => "JSON"
   }
)

推荐答案

我建议使用此gem, http://rubygems.org/gems/active_paypal_adaptive_payment ,您可以进行付款,预批准的付款,取消付款 ...等.

I recommend use this gem, http://rubygems.org/gems/active_paypal_adaptive_payment, you can make payments, Pre-approved payment, cancel payments...etc.

您需要使用下面的代码进行付款.

You need use the next code to make a payment.

def checkout #this method is for checking, you must add this code to your method on your controller
  recipients = [{:email => 'email1',
                 :amount => some_amount,
                 :primary => true},
                {:email => 'email2',
                 :amount => recipient_amount,
                 :primary => false}
                 ]
  response = gateway.setup_purchase(
    :return_url => url_for(:action => 'action', :only_path => false),
    :cancel_url => url_for(:action => 'action', :only_path => false),
    :ipn_notification_url => url_for(:action => 'notify_action', :only_path => false),
    :receiver_list => recipients
  )

  # For redirecting the customer to the actual paypal site to finish the payment.
  redirect_to (gateway.redirect_url_for(response["payKey"]))
end

return_urlcancel_url值必须是您自己网站上的相对URL!

The return_url and cancel_url values, must be relative urls on your own website!

致谢!

这篇关于Paypal Ruby自适应付款的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 03:15