["Security error", "Sec-6ren">
gpt4 book ai didi

ruby-on-rails - Paypal 错误 10002 :Security error Security header is not valid

转载 作者:太空宇宙 更新时间:2023-11-03 16:32:04 25 4
gpt4 key购买 nike

我正在关注 RailsCast #289,在完成教程后我收到了一个 RuntimeError:

[{:code=>"10002", :messages=>["Security error", "Security header is not valid"]}]

单击订阅页面上的“使用 PayPal 结帐”按钮时出错。

错误是指向行上的paypal_payment.rb

raise response.errors.inspect if response.errors.present?

Paypal_Payment.rb:

  def initialize(subscription)
@subscription = subscription
end

def checkout_details
process :checkout_details
end

def checkout_url(options)
process(:checkout, options).checkout_url
end

def make_recurring
process :request_payment
process :create_recurring_profile, period: :monthly, frequency: 1, start_at: Time.zone.now
end

private

def process(action, options = {})
options = options.reverse_merge(
token: @subscription.paypal_payment_token,
payer_id: @subscription.paypal_customer_token,
description: @subscription.plan.name,
amount: @subscription.plan.price,
currency: "USD"
)
response = PayPal::Recurring.new(options).send(action)
raise response.errors.inspect if response.errors.present?
response
end
end

订阅 Controller :

  def new
plan = Plan.find(params[:plan_id])
@subscription = plan.subscriptions.build
if params[:PayerID]
@subscription.paypal_customer_token = params[:PayerID]
@subscription.paypal_payment_token = params[:token]
@subscription.email = @subscription.paypal.checkout_details.email
end
end

def create
@subscription = Subscription.new(params[:subscription])
if @subscription.save_with_payment
redirect_to @subscription, :notice => "Thank you for subscribing!"
else
render :new
end
end

def show
@subscription = Subscription.find(params[:id])
end

def paypal_checkout
plan = Plan.find(params[:plan_id])
subscription = plan.subscriptions.build
redirect_to subscription.paypal.checkout_url(
return_url: new_subscription_url(:plan_id => plan.id),
cancel_url: root_url
)
end
end

我在初始化程序中输入了正确的用户、密码和签名。难道是我在本地主机上?

最佳答案

如果您处于测试模式,您需要修改初始化程序并将 config.sandbox=true 更改为 false。 Railscast 设置为实时模式。

关于ruby-on-rails - Paypal 错误 10002 :Security error Security header is not valid,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22158318/

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