在尝试使用条带集成付款时,我一直收到此错误:
Stripe::InvalidRequestError (No such token: tok_19Vh25DGnBus....):
这是我的Ruby on Rails集成:
config / application.yml(我使用Figaro gem来处理环境变量):
STRIPE_SECRET_KEY :"sk_test_xxxxxxxxxxxxx"
STRIPE_PUB_KEY :"pk_test_xxxxxxxxxxxxx"
配置/初始化/ stripe.rb:
Rails.configuration.stripe = {
:publishable_key => ENV['STRIPE_PUB_KEY'],
:secret_key => ENV['STRIPE_SECRET_KEY']
}
Stripe.api_key = Rails.configuration.stripe[:secret_key]
controllers / api_controller.rb:
require 'stripe'
charge = Stripe::Charge.create( # -> Line of the error
:amount => price,
:currency => "gbp",
:source => token,
:description => ""
)
在前端,我使用角度和模块angularPayments:
$window.Stripe.setPublishableKey("pk_live_xxxxxxxxxxx");
$scope.handleStripe = function(status, response){
$rootScope.loader = true;
var email = $scope.email;
$scope.email = "";
$scope.number = '';
$scope.expiry = null;
$scope.cvc = '';
if(response.error) {
$scope.paid= false;
$scope.message = "The card you have inserted is not valid.";
$rootScope.loader = false;
} else {
var data = {
'invoice_url' : $stateParams.invoiceUrl,
'token' : response.id,
'price': $scope.invoice.price,
'email': email
};
$http.post(URL.url + 'send_payment', data).then(function(res){
if(res.data.error){
$scope.paid= false;
$scope.message = res.data.message;
$rootScope.loader = false;
}else{
$scope.paid= true;
$rootScope.temp_modal = true;
$scope.message = res.data.message;
}
$rootScope.loader = false;
});
}
};
我检查了所有密钥是否正确并且与我正在使用的帐户相匹配...在测试模式下,一切正常...我错过了什么?
答案 0 :(得分:0)
我的不好,关键是正确但我没有更新缩小的js文件!