gpt4 book ai didi

ruby-on-rails - 收到来自 Paypal 的通知后生成 PDF 文件

转载 作者:太空宇宙 更新时间:2023-11-03 15:51:43 31 4
gpt4 key购买 nike

收到来自 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",

}

Controller 代码:

def pdfbook_for_print   

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

还有 Prawn 文件: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 的参数,不确定。任何帮助将不胜感激。

最佳答案

最后,我确实解决了问题,但不确定方法是否正确,但效果非常好。我所做的是 - 创建了一个新操作来接收来自 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

关于ruby-on-rails - 收到来自 Paypal 的通知后生成 PDF 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6407018/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com