我在使用 Stripe Connect 处理付款时遇到了一些麻烦。出于某种原因,我在提交表单后立即收到此错误:
发生网络错误,您未被收取费用。请重试
他们设置我的系统的方式是用户可以使用 Stripe 登录,这会从 Stripe 发回以下详细信息,我将这些详细信息连同用户 ID 一起保存到数据库中。
在我的支付页面上,我有这个脚本:
Stripe.setPublishableKey('<?= $publishable_key; ?>');
var stripeResponseHandler = function(status, response) {
var $form = $('#payment-form');
$form.find('.form-error').text("")
$form.find('.error').removeClass("error")
validate = validateFields();
if (response.error) {
error = 0;
// Show the errors on the form
if (response.error.message == "This card number looks invalid"){
error = error + 1;
$form.find('.card_num').text(response.error.message);
$('#dcard_num').addClass("error");
}
if (response.error.message == "Your card number is incorrect."){
error = error + 1;
$form.find('.card_num').text(response.error.message);
$('#dcard_num').addClass("error");
}
if (response.error.message == "Your card's expiration year is invalid."){
error = error + 1;
$form.find('.exp').text(response.error.message);
$('#dexp').addClass("error");
}
if (response.error.message == "Your card's expiration month is invalid."){
error = error + 1;
$form.find('.exp').text(response.error.message);
$('#dexp').addClass("error");
}
if (response.error.message == "Your card's security code is invalid."){
error = error + 1;
$form.find('.cvc').text(response.error.message);
$('#dcvc').addClass("error");
}
if (error == 0){
$form.find('.payment-errors').text(response.error.message);
}
$form.find('button').prop('disabled', false);
} else {
if (validate == 1){
// token contains id, last4, and card type
var token = response.id;
// Insert the token into the form so it gets submitted to the server
$form.append($('<input type="hidden" name="stripeToken" />').val(token));
// and re-submit
$form.get(0).submit();
}
}
};
出于某种原因,验证从未发生,而且我没有获得卡详细信息的 token 。结果,我的代码的下一部分,即我实际向用户收费的部分没有运行:
global $wpdb;
$author_id = get_the_author_meta('id');
$stripe_connect_account = $wpdb->get_row("SELECT * FROM wp_stripe_connect WHERE wp_user_id = $author_id", ARRAY_A);
if($stripe_connect_account != null){
$publishable_key = $stripe_connect_account['stripe_publishable_key'];
$secret_key = $stripe_connect_account['stripe_access_token'];
}
$charging = chargeWithCustomer($secret_key, $amountToDonate, $currency_stripe, $stripe_usr_id);
这是 chargeWithCustomer 函数:
function chargeWithCustomer($secret_key, $amountToDonate, $currency, $customer) {
require_once('plugin/Stripe.php');
Stripe::setApiKey($secret_key);
$charging = Stripe_Charge::create(array("amount" => $amountToDonate,
"currency" => $currency,
"customer" => $customer,
"description" => ""));
return $charging;
}
如果有人可以帮助我解决这个问题,我将不胜感激。我对我哪里出错了感到困惑,我无法在 Stripes 文档中找到答案。
最佳答案
如果您没有阅读整个系列,或者不知道秘诀,Stripe.js 会将支付信息直接发送到 Stripe 并获得关联的唯一 token 作为返回。然后该 token 会被提交到您的服务器并用于实际向客户收费。
如果您想知道充电尝试为何仍然会失败,那么说实话,您应该知道 Stripe.js 进程实际上只做了两件事:
1) 以安全的方式获取 Stripe 的付款信息(限制您的责任) 2)验证支付信息是否可用
**处理被拒绝的卡有点复杂,因为您需要找出卡被拒绝的原因并将该信息提供给客户,以便他或她可以纠正问题。目的是从异常中得到下降的具体原因。这是一个多步骤过程:
1)从异常中获取JSON格式的总响应
2)从响应中获取错误正文
3)从错误正文中获取具体信息**
require_once('path/to/lib/Stripe.php');
try {
Stripe::setApiKey(STRIPE_PRIVATE_KEY);
$charge = Stripe_Charge::create(array(
'amount' => $amount, // Amount in cents!
'currency' => 'usd',
'card' => $token,
'description' => $email
));
} catch (Stripe_CardError $e) {
}
Knowing what kinds of exceptions might occur, you can expand this to watch for the various types, from the most common (Stripe_CardError) to a catch-all (Stripe_Error):
require_once('path/to/lib/Stripe.php');
try {
Stripe::setApiKey(STRIPE_PRIVATE_KEY);
$charge = Stripe_Charge::create(array(
'amount' => $amount, // Amount in cents!
'currency' => 'usd',
'card' => $token,
'description' => $email
));
} catch (Stripe_ApiConnectionError $e) {
// Network problem, perhaps try again.
} catch (Stripe_InvalidRequestError $e) {
// You screwed up in your programming. Shouldn't happen!
} catch (Stripe_ApiError $e) {
// Stripe's servers are down!
} catch (Stripe_CardError $e) {
// Card was declined.
}
希望这有助于...!
关于javascript - Stripe 付款问题 - 网络错误,您尚未被收取费用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27058997/
我想为Heroku构建一个Rails3应用程序。他们使用Postgres作为他们的数据库,所以我通过MacPorts安装了postgres9.0。现在我需要一个postgresgem并且共识是出于性能原因你想要pggem。但是我对我得到的错误感到非常困惑当我尝试在rvm下通过geminstall安装pg时。我已经非常明确地指定了所有postgres目录的位置可以找到但仍然无法完成安装:$envARCHFLAGS='-archx86_64'geminstallpg--\--with-pg-config=/opt/local/var/db/postgresql90/defaultdb/po
尝试通过RVM将RubyGems升级到版本1.8.10并出现此错误:$rvmrubygemslatestRemovingoldRubygemsfiles...Installingrubygems-1.8.10forruby-1.9.2-p180...ERROR:Errorrunning'GEM_PATH="/Users/foo/.rvm/gems/ruby-1.9.2-p180:/Users/foo/.rvm/gems/ruby-1.9.2-p180@global:/Users/foo/.rvm/gems/ruby-1.9.2-p180:/Users/foo/.rvm/gems/rub
我的最终目标是安装当前版本的RubyonRails。我在OSXMountainLion上运行。到目前为止,这是我的过程:已安装的RVM$\curl-Lhttps://get.rvm.io|bash-sstable检查已知(我假设已批准)安装$rvmlistknown我看到当前的稳定版本可用[ruby-]2.0.0[-p247]输入命令安装$rvminstall2.0.0-p247注意:我也试过这些安装命令$rvminstallruby-2.0.0-p247$rvminstallruby=2.0.0-p247我很快就无处可去了。结果:$rvminstall2.0.0-p247Search
由于fast-stemmer的问题,我很难安装我想要的任何rubygem。我把我得到的错误放在下面。Buildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingfast-stemmer:ERROR:Failedtobuildgemnativeextension./System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/rubyextconf.rbcreatingMakefilemake"DESTDIR="cleanmake"DESTDIR=
当我尝试安装Ruby时遇到此错误。我试过查看this和this但无济于事➜~brewinstallrubyWarning:YouareusingOSX10.12.Wedonotprovidesupportforthispre-releaseversion.Youmayencounterbuildfailuresorotherbreakages.Pleasecreatepull-requestsinsteadoffilingissues.==>Installingdependenciesforruby:readline,libyaml,makedepend==>Installingrub
我想在Ruby中创建一个用于开发目的的极其简单的Web服务器(不,不想使用现成的解决方案)。代码如下:#!/usr/bin/rubyrequire'socket'server=TCPServer.new('127.0.0.1',8080)whileconnection=server.acceptheaders=[]length=0whileline=connection.getsheaders想法是从命令行运行这个脚本,提供另一个脚本,它将在其标准输入上获取请求,并在其标准输出上返回完整的响应。到目前为止一切顺利,但事实证明这真的很脆弱,因为它在第二个请求上中断并出现错误:/usr/b
我正在尝试使用boilerpipe来自JRuby。我看过guide从JRuby调用Java,并成功地将它与另一个Java包一起使用,但无法弄清楚为什么同样的东西不能用于boilerpipe。我正在尝试基本上从JRuby中执行与此Java等效的操作:URLurl=newURL("http://www.example.com/some-location/index.html");Stringtext=ArticleExtractor.INSTANCE.getText(url);在JRuby中试过这个:require'java'url=java.net.URL.new("http://www
我意识到这可能是一个非常基本的问题,但我现在已经花了几天时间回过头来解决这个问题,但出于某种原因,Google就是没有帮助我。(我认为部分问题在于我是一个初学者,我不知道该问什么......)我也看过O'Reilly的RubyCookbook和RailsAPI,但我仍然停留在这个问题上.我找到了一些关于多态关系的信息,但它似乎不是我需要的(尽管如果我错了请告诉我)。我正在尝试调整MichaelHartl'stutorial创建一个包含用户、文章和评论的博客应用程序(不使用脚手架)。我希望评论既属于用户又属于文章。我的主要问题是:我不知道如何将当前文章的ID放入评论Controller。
首先回顾一下拉格朗日定理的内容:函数f(x)是在闭区间[a,b]上连续、开区间(a,b)上可导的函数,那么至少存在一个,使得:通过这个表达式我们可以知道,f(x)是函数的主体,a和b可以看作是主体函数f(x)中所取的两个值。那么可以有, 也就意味着我们可以用来替换 这种替换可以用在求某些多项式差的极限中。方法: 外层函数f(x)是一致的,并且h(x)和g(x)是等价无穷小。此时,利用拉格朗日定理,将原式替换为 ,再进行求解,往往会省去复合函数求极限的很多麻烦。使用要注意:1.要先找到主体函数f(x),即外层函数必须相同。2.f(x)找到后,复合部分是等价无穷小。3.要满足作差的形式。如果是加
网络编程套接字网络编程基础知识理解源`IP`地址和目的`IP`地址理解源MAC地址和目的MAC地址认识端口号理解端口号和进程ID理解源端口号和目的端口号认识`TCP`协议认识`UDP`协议网络字节序socket编程接口`sockaddr``UDP`网络程序服务器端代码逻辑:需要用到的接口服务器端代码`udp`客户端代码逻辑`udp`客户端代码`TCP`网络程序服务器代码逻辑多个版本服务器单进程版本多进程版本多线程版本线程池版本服务器端代码客户端代码逻辑客户端代码TCP协议通讯流程TCP协议的客户端/服务器程序流程三次握手(建立连接)数据传输四次挥手(断开连接)TCP和UDP对比网络编程基础知识