我正在使用stripe.js切换条带检出.当我输入卡片时,一切都有效,除非它从未通过.每当我点击提交时,我收到的错误是:
Cannot charge a customer that has no active card
Run Code Online (Sandbox Code Playgroud)
我已经尝试过使用测试卡和真实的信用卡号码,他们两个都给了我同样的错误.这是我的stripe.rb:
class ChargesController < ApplicationController
before_action :authenticate_user!
def new
end
def create
# Amount in cents
@amount = 500
customer = Stripe::Customer.create(
:email => params[:stripeEmail],
:source => params[:stripeToken]
)
Stripe.api_key = 'sk_test_string'
charge = Stripe::Charge.create(
:amount => 1000,
:customer => customer.id,
:currency => "usd",
:card => params[:stripeToken] # replace full card details with the string token from our params
)
rescue Stripe::CardError => e
flash[:error] = e.message
redirect_to new_charge_path
end …Run Code Online (Sandbox Code Playgroud) 我运行db:create时收到此错误:
FATAL: Peer authentication failed for user "wandrr"
/home/jack/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/postgresql_adapter.rb:1208:in `initialize'
/home/jack/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/postgresql_adapter.rb:1208:in `new'
/home/jack/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/postgresql_adapter.rb:1208:in `connect'
/home/jack/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/postgresql_adapter.rb:326:in `initialize'
/home/jack/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `new'
/home/jack/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `postgresql_connection'
/home/jack/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in `new_connection'
/home/jack/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:325:in `checkout_new_connection'
/home/jack/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:247:in `block (2 levels) in checkout'
/home/jack/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `loop'
/home/jack/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `block in checkout'
/home/jack/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/jack/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:239:in `checkout'
/home/jack/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:102:in `block in connection'
/home/jack/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/jack/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:101:in `connection'
/home/jack/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:410:in `retrieve_connection'
....Edit out 40 more of these warnings...
/home/jack/.rvm/gems/ruby-1.9.3-p327/bin/ruby_noexec_wrapper:14:in `eval'
/home/jack/.rvm/gems/ruby-1.9.3-p327/bin/ruby_noexec_wrapper:14:in `<main>'
Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "database"=>"wandrr_test", "pool"=>5, "username"=>"wandrr", "password"=>nil}
Run Code Online (Sandbox Code Playgroud)
所以我发现我必须编辑pg_hba.conf问题是......它无法打开.它一直告诉我,我没有权限使用此文件.那么我如何获得许可?我正在运行ubuntu 12.10和rails 1.9.3以及postgres 9.1
嘿,我是rails(以及linux)的新手,我一直收到这个错误:
Installing json (1.7.5) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from extconf.rb:1:in `<main>'
Gem files will remain installed in /home/jack/.bundler/tmp/10426/gems/json-1.7.5 for inspection.
Results logged to /home/jack/.bundler/tmp/10426/gems/json-1.7.5/ext/json/ext/generator/gem_make.out
An error occurred while installing json (1.7.5), and Bundler cannot continue.
Make sure that `gem install json -v '1.7.5'` succeeds before bundling.
jack@jack-ThinkCentre:~/rails_projects/sample_app$
Run Code Online (Sandbox Code Playgroud)
我无法单独安装gem或使用bundle install.我使用rvm来安装rails.提前致谢.
我需要为 Ubuntu 找到 Elasticsearch 错误日志的默认位置。当我启动该服务时,它表示可以,但是当我要求该服务时,出现了:
Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled; vendo
Active: inactive (dead) since Thu 2017-11-23 05:49:46 CST; 3min ago
Docs: http://www.elastic.co
Main PID: 81608 (code=exited, status=0/SUCCESS)
Run Code Online (Sandbox Code Playgroud)
我需要弄清楚为什么会发生这种情况,但我不知道错误日志的位置。我已经有几年没有使用过这台计算机了,我也没有从默认位置更改它。
.xlsx我正在尝试在 WPF .NET Core 3.1 应用程序中打开 Excel 文件 ( )。使用 Winforms,我能够做到
process.start("Resources/test.xlsx")
Run Code Online (Sandbox Code Playgroud)
文件将会打开。
在 WPF 应用程序中执行相同的操作会导致错误
指定的可执行文件不是该操作系统平台的有效应用程序
我使用相同的代码并使用两个应用程序打开相同的文件。只有 Winforms 应用程序可以工作,WPF 会抛出该错误。
.Net 3 中是否有一种新的打开文件方式System.Diagnostics.Process.Start?
即使我的函数无效,我也收到此错误?我认为错误只发生在非void函数中.提前致谢.
void scramble(void)
{
char newgrid[DIMENSION][DIMENSION];
for(int i=0; i<DIMENSION; i++){
for(int j=0; j<DIMENSION; j++){
newgrid[i][j] = grid[i][j];
}
}
for(int i = DIMENSION-1; i>=0; i--){
for(int j = 0; j<DIMENSION; i++){
printf("%c", newgrid[i][j]);
}
}
}
Run Code Online (Sandbox Code Playgroud) 您好,我在使环境变量正常工作时遇到问题。我将它们导出到服务器上,执行以下操作:
Export username=name password=password
Run Code Online (Sandbox Code Playgroud)
当我执行 Irb 并输入变量时,我得到它:
2.2.1 :001 > ENV["password"]
=> "password"
Run Code Online (Sandbox Code Playgroud)
但是我在 postgresql 中收到此错误:
PG::ConnectionBad: FATAL: password authentication failed for user "ENV["username"]"
Run Code Online (Sandbox Code Playgroud)
我的环境变量似乎没有加载到系统中。这是我的database.yml 文件:
production:
<<: *default
database: postgresql
username: ENV["username"]
password: ENV["password"]
Run Code Online (Sandbox Code Playgroud)
当我放入原始字符串时,它工作得很好。任何帮助都是极好的。