gpt4 book ai didi

javascript - Stripe : no such token

转载 作者:行者123 更新时间:2023-11-28 05:11:16 24 4
gpt4 key购买 nike

我在尝试使用 Stripe 集成进行支付时不断收到此错误:

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"

config/initializers/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]

Controller /api_controller.rb:

require 'stripe'

charge = Stripe::Charge.create( # -> Line of the error
:amount => price,
:currency => "gbp",
:source => token,
:description => ""
)

在前端,我使用 Angular 和模块 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;
});

}
};

我检查过,所有 key 都正确并且与我正在使用的帐户匹配...在测试模式下一切正常...我缺少什么?

最佳答案

我的错, key 是正确的,但我没有更新缩小的 js 文件!

关于javascript - Stripe : no such token,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41364068/

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