1

有料通話の方法について2つの異なるバージョンを見てきましたが、どちらのバージョンも機能しないため、何が間違っているのか知りたいと思いました。

@result = HTTParty.post('https://svcs.sandbox.paypal.com/AdaptivePayments/Pay',
  :body =>
    {:actionType => "PAY",
     :currencyCode => "USD",
     :receiverList => {
       :receiver => [
         {:amount => "1.00",
          :email => "rec1_1312486368_biz@gmail.com"}]
     },
     :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"
     }
 )

@result = HTTParty.post('https://svcs.sandbox.paypal.com/AdaptivePayments/Pay',
  :body => {
    :actionType => "PAY",
    :currencyCode => "USD",
    "receiverList.receiver(0).email".to_sym => "rec1_1312486368_biz@gmail.com",
    "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"
   }
)
4

2 に答える 2

3

このgem、http://rubygems.org/gems/active_paypal_adaptive_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_urlと値はcancel_url、自分のWebサイトの相対URLである必要があります。

よろしく!

于 2013-01-22T10:32:43.760 に答える
3

PayPalには公式のRubySDK(paypal-sdk-adaptivepayments)があります

http://paypal-sdk-samples.herokuapp.com/adaptive_payments/payで入手可能なサンプル

于 2013-01-24T04:49:32.363 に答える