我尝试替换:
const stripe =const stripe=require("stripe")('sk_test_51KMbN...');
Run Code Online (Sandbox Code Playgroud)
到
const stripe = require("stripe")(functions.config().stripe.secret);
Run Code Online (Sandbox Code Playgroud)
但是当我运行 firebase 模拟器时,我遇到了一个错误:
错误:无法从源加载函数定义:无法从函数源生成清单:TypeError:无法读取未定义的属性(读取“秘密”)
我已经将其设置如下:
firebase functions:config:set stripe.secret=< SECRET KEY>
Run Code Online (Sandbox Code Playgroud)
我可以通过运行看到它:
firebase functions:config:get
Run Code Online (Sandbox Code Playgroud)
我在functions/index.js中的代码是
const functions = require("firebase-functions");
const express=require("express");
const cors=require("cors");
require('dotenv').config({ path: './.env' });
//API
const stripe = require("stripe")(functions.config().stripe.secret);
//App config
const app=express();
var admin = require("firebase-admin");
var serviceAccount = require("./serviceAccountKey.json");
admin.initializeApp({
credential: admin.credential.cert(serviceAccount)
});
//middlewares
app.use(cors({origin: true}));
app.use(express.json());
async function createCheckoutSession(req, res) {
const domainUrl = process.env.WEB_APP_URL;
const { line_items, customer_email } = req.body;
if (!line_items || …Run Code Online (Sandbox Code Playgroud) node.js stripe-payments firebase reactjs google-cloud-functions
我尝试通过 Supabase 的 Edge Functions 连接到 Stripe,但我不断收到此错误:
相对导入路径“http”不以 / 或 ./ 或 ../ 为前缀
我一直在挖掘,它似乎与从 Typescript 到 Javascript 的捆绑有关,但我还没有找到解决方案。
我的代码和官方的一样: https: //github.com/supabase/supabase/blob/master/examples/edge-functions/supabase/functions/stripe-webhooks/index.ts
我注意到,如果删除 Stripe 导入,我可以进行部署,所以我猜它可能是相关的,但我无法理解为什么,因为其他导入(例如 Deno 的 Supabase 导入)可以正常工作。
谢谢!!
import { serve } from 'https://deno.land/std@0.132.0/http/server.ts'
// esm.sh is used to compile stripe-node to be compatible with ES modules.
import Stripe from 'https://esm.sh/stripe@10.13.0?target=deno&deno-std=0.132.0'
const stripe = Stripe(Deno.env.get('STRIPE_API_KEY'), {
// This is needed to use the Fetch API rather than relying on the Node http
// package.
httpClient: Stripe.createFetchHttpClient(),
})
// …Run Code Online (Sandbox Code Playgroud) 错误:
"message": "没有找到与负载的预期签名匹配的签名。您是否正在传递从 Stripe 收到的原始请求正文?https://github.com/stripe/stripe-node#webhook-signing ",
我试过了req.rawBody,但结果相同。我还尝试了堆栈溢出和 github 上可用的所有解决方案。
// use express body parser
app.use(bodyParse.json());
Run Code Online (Sandbox Code Playgroud)
router
.route('/payment/hook')
.post(bodyParser.raw({
type: 'application/json'
}), paymentsController.transactionHook);
Run Code Online (Sandbox Code Playgroud)
transactionHook: async(req, res, next) => {
const sig = req.headers['stripe-signature'];
let event;
try {
event = await stripe.webhooks.constructEvent(req.body, sig, endpointSecret);
} catch (err) {
return res.status(400).json({ message: err.message, detail: err.detail });
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试创建客户时收到以下错误.我试着降级Parse.目前它运行最新的(2.2.8)版本,但我也尝试了1.4.2版本,我仍然收到以下错误.这种"TypeError"的原因是什么?
TypeError: Object [object Object] has no method 'isString'
at request (stripe.js 49:25) at post (stripe.js:117:12) at
Object.module.exports.Customers.create (stripe.js:239:16) at main.js:15:22
Run Code Online (Sandbox Code Playgroud)
Main.js:
//STRIPE
var Stripe = require("stripe")
Stripe.initialize = ("sk_test_XXXXX");
Parse.Cloud.define("saveCustomerId", function(request, response) {
Parse.Cloud.useMasterKey();
Stripe.Customers.create({
card : request.params.token,
email: request.params.email,
description: request.params.description,
}, {
success : function(customer) {
var Usr = request.user;
var newcust = Parse.Object.extend("Customer");
var newUsr = new newcust();
newUsr.set("sCID", customer.id);
newUsr.set("parent", Usr);
var pACL = new Parse.ACL();
pACL.setPublicReadAccess(false);
pACL.setPublicWriteAccess(false);
pACL.setReadAccess(Usr, true);
pACL.setWriteAccess(Usr, true);
newUsr.set("ACL", pACL);
newUsr.save(null, …Run Code Online (Sandbox Code Playgroud) 我正在使用条带检查的自定义代码并尊重所有内容,但我收到此错误:
StripeCheckout.configure: 'data-key' is a required option, but was not found
Run Code Online (Sandbox Code Playgroud)
这不是我第一次使用代码,我之前使用它,一切都很好.
这是完整的代码:
var handler = StripeCheckout.configure({
key: 'pk_test_aaaaaaaaaaaaaaaaaaaa',
image: 'https://stripe.com/img/documentation/checkout/marketplace.png',
locale: 'auto',
token: function(token) {
// You can access the token ID with `token.id`.
// Get the token ID to your server-side code for use.
}
});
document.querySelector('.stripe-button').addEventListener('click', function(e) {
// Open Checkout with further options:
handler.open({
name: 'Title',
description: 'description',
currency: 'eur',
amount: 9700
});
e.preventDefault();
});
// Close Checkout on page navigation:
window.addEventListener('popstate', function() {
handler.close();
}); …Run Code Online (Sandbox Code Playgroud)我正在尝试使用Stripe.js和HTML创建一个接受用户银行帐户详细信息的表单.问题是,每次我尝试提交细节时,无论是否正确,我都会收到错误.输入表格如下.有任何想法吗?
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<!-- The required Stripe lib -->
<script type="text/javascript" src="https://js.stripe.com/v2/"></script>
<!-- jQuery is used only for this example; it isn't required to use Stripe -->
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
// This identifies your website in the createToken call below
//blanking my test key out just for stackoverflow
Stripe.setPublishableKey('pk_test_XXXXXXXXXXXXX');
var stripeResponseHandler = function(status, response) {
var $form = $('#inst-form');
if (response.error)
{
alert("Error");
// Not sure how to get these errors.
$form.find('button').prop('disabled', false);
} …Run Code Online (Sandbox Code Playgroud) 我正在使用条纹付款.我需要一个建议,通过API将卡详细信息发送到服务器然后使用条带进行付款是否安全.或者我应该使用条带集成从移动设备创建令牌,然后将令牌发送到服务器以进行更多处理.