2

收到 Paypal 的通知后,我无法生成 PDF 文件(使用 PRAWN)。我的代码中是否缺少某些内容?这是我的代码:

订购型号:

def paypal_encryption() 
  values = {
    :cert_id => "YR5RRR2MUKRA2",
    :cmd => '_xclick',
    :upload => 1,
    :return => success_payments_url, ,
    :cancel_return => profile_url,
    :business => "seller_1306231025_biz@spt.com",
    :item_name => "FMN Book",
    :amount => self.price,
    :quantity => self.quantity,
    :rm => 2, 
    :cbt => "Return to Forgetmenotbook",
    :currency_code => self.currency,  
    :notify_url => "http://home.spt.com/payments/pdfbook_for_print",

} 

控制器代码:

def pdfbook_for_print   

  respond_to do |format|
    format.pdf {} 
  end
end

还有对虾文件:pdfbook_for_print.pdf.prawn

require "open-uri"
require "rubygems"
require "sanitize"

Prawn::Document.generate("#{Rails.root.to_s}/public/print-pdf-print.pdf", :page_size    
=>  [590,590], :left_margin => 50,:right_margin => 50, :page_layout => :portrait,    
:skip_page_creation => true, :skip_encoding => true) do |pdf|
  pdf.start_new_page 
  pdf.fill_color "981a00"
  pdf.move_down(50)  
  pdf.text "Testing pdf for printing", :size => 13

end 

我怀疑notify_url中应该有类似:format => pdf参数的东西,不确定。任何帮助都感激不尽。

4

1 回答 1

0

最后,我确实解决了这个问题,但不确定它是否正确,但它工作得很好。我所做的是 - 创建了一个新操作,只是为了接收来自 Paypal 的通知,然后重定向到实际生成 PDF 文件的操作pdfbook_for_print 。

def notification_from_paypal 
 redirect_to :action => 'pdfbook_for_printing', :format => 'pdf'
end 

def pdfbook_for_print   
  respond_to do |format|
    format.pdf {} 
  end
end
于 2011-07-26T10:31:27.513 回答