2014-04-15 2 views
0

나는 편지에 implementation guide 다음에도 불구하고 다음과 같은 오류로 실행 계속 :왜 PayPal :: SDK :: Core :: Exceptions :: MethodNotAllowed가 표시됩니까?

PayPal::SDK::Core::Exceptions::MethodNotAllowed in SiteController#execute_payment 
Failed. Response code = 405. Response message = Method Not Allowed. 

이것은 잘못된 라인 :

@payment.execute(:payer_id => params[:PayerID]) 

내가 잘못 뭐하는 거지? (여기 내 컨트롤러의) :

class SiteController < ApplicationController 
    def index 
    end 

    def create_payment 
     payment = PayPal::SDK::REST::Payment.new({ 
      :intent => "sale", 
      :payer => { 
       :payment_method => "paypal" }, 
       :redirect_urls => { 
       :return_url => execute_payment_url, 
       :cancel_url => "https://devtools-paypal.com/guide/pay_paypal/ruby?cancel=true" }, 
       :transactions => [ { 
        :amount => { 
        :total => "12", 
        :currency => "USD" }, 
        :description => "creating a payment" } ] }) 

     payment.transactions[0].item_list.items[0] = { 
       quantity: 1, 
       name: 'Poop', 
       price: 12, 
       currency: 'USD' 
      } 

     if payment.create 
      session[:payment_id] = payment.id 
      redirect_to payment.links[1].href 
     end 
    end 

    def execute_payment 
     @payment = PayPal::SDK::REST::Payment.new({ 
      :payment_id => session[:payment_id]}) 
     @payment.execute(:payer_id => params[:PayerID]) 
    end 

end 

답변

0

대신 당신이 변경 .. 찾을 사용해야 새로운 지불 만들기 :

@payment = PayPal::SDK::REST::Payment.new({ 
     :payment_id => session[:payment_id]}) 

이 내 사본에이 문제를 해결

@payment = PayPal::SDK::REST::Payment.find(session[:payment_id]) 

로를 당신의 코드.