我想知道是否存在某种“约定”或其他将 Stripe 支付数据存储在数据库中的最佳实践。网上确实缺乏信息,因为我是自己做的,所以我想从其他人那里得到一些反馈。
我的网站的基本设置是有一个商店有多种产品。还有一个订阅选项,每月接收这些产品。
所以我设置了两条邮路。一种用于购买产品,一种用于订阅。这些使用 Stripe API。对于订单,我使用stripe.charge,而对于订阅,我从一个客户创建一个客户stripe.customer并让他们订阅一个计划。
对于stripe.charges,我将返回的对象保存到数据库中。这包含所有收费数据。有一个 webhook 作为 发送charge.succeeded,如果charge succeeded. 我不存储这些数据。也许我应该在这里存储费用 id,而不是整个费用对象。我将其存储如下:
订购路线
module.exports = async (req, res) => {
try {
const charge = await stripe.charges.create({
amount: req.session.cart.totalPrice,
currency: 'usd',
source: req.body.id
});
const order = await new Order({
user: req.user,
cart: req.session.cart,
stripeCharge: charge
}).save();
req.session.cart = new Cart({});
res.sendStatus(200);
} catch (e) {
console.log(e);
}
};
Run Code Online (Sandbox Code Playgroud)
对于订阅,它有点复杂,因为创建的客户对象不包含任何费用 ID。所以我将客户 ID 保存到该用户模型中。如果订阅处理正常,Stripe 会触发 6 个 webhook。我存储customer.subscription.created …
我在 Woocommerce 结帐页面中有两个不同的支付网关(条纹和银行转账)。但默认情况下,“银行转账”(bacs)始终是自动选择的。
这是我结帐页面上支付网关的屏幕截图:
我想改变它并自动选择条带支付网关。
我该怎么做?。任何帮助表示赞赏。
我已经集成了 Stripe checkout(最新版本)并且需要发送额外的数据,以便我可以协调稍后的 webhook。
Stripe 拒绝元数据并出现以下错误
Fatal error: Uncaught exception 'Stripe\Error\InvalidRequest' with message 'Received unknown parameter: metadata'
Run Code Online (Sandbox Code Playgroud)
我部分编辑的代码如下所示
$object = \Stripe\Checkout\Session::create([
'success_url' => 'www/payment_processor.php?action=success',
'cancel_url' => 'www/payment_processor.php?action=cancel',
'payment_method_types' => ['card'],
'customer_email' => $email,
'metadata' => ['user_id' => $user_id],
'line_items' => [[
'amount' => $amount,
'currency' => $currency,
'name' => 'Purchase',
'description' => $description,
'quantity' => 1,
]]
]);
Run Code Online (Sandbox Code Playgroud)
我希望元数据被接受并与 webhook 一起返回,如Stripe 文档中所述。
我正在使用 firebase 函数进行条带支付集成。此特定功能用于使用条带注册客户。
节点版本 10.15.3 ,
npm 版本 6.9.0 ,
"ecmaVersion": 6 in .eslintrc.json
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
const stripe = require('stripe')(functions.config().stripe.testkey)
exports.createStripeCustomer = functions.auth.user()
.onCreate(async (user) => {
const customer = await
stripe.customers.create({email: user.email});
await admin.firestore()
.collection('stripe_customers')
.doc(user.uid)
.set({customer_id: customer.id});
});
Run Code Online (Sandbox Code Playgroud)
代码与 github 示例https://github.com/firebase/functions-samples/blob/master/stripe/functions/index.js上提供的 firebase 平台相同
解析错误:意外的令牌 =>
如果我将 .eslintrc.json 中的 "ecmaVersion": 6 更改为 "ecmaVersion": 8
then error is .onCreate(async (user) => {
^
SyntaxError: Unexpected token (
Run Code Online (Sandbox Code Playgroud)
我想正确部署功能,以便用户可以在 firebase 存储中的条带和日期存储上注册
javascript node.js stripe-payments firebase google-cloud-functions
我的 SvelteKit 应用程序中有一个端点,用于处理来自 Stripe 的 Webhook 请求。每个请求都经过签名,以便可以验证它是否来自 Stripe。
我必须验证该事件是否来自 Stripe 的代码如下所示:
import Stripe from "stripe";
const WEBHOOK_SECRET = process.env["STRIPE_WH_SECRET"];
const stripe = new Stripe(process.env["STRIPE_SECRET"], {
apiVersion: "2020-08-27",
});
export async function post({ headers, body }) {
let event: Stripe.Event;
try {
event = stripe.webhooks.constructEvent(
body,
headers["stripe-signature"],
WEBHOOK_SECRET
);
} catch (err) {
return {
status: 400,
body: err,
};
}
// Do stuff with the event
}
Run Code Online (Sandbox Code Playgroud)
但是当它收到来自 Stripe 的事件时,我收到此错误:
No signatures found matching the expected signature for payload. Are …Run Code Online (Sandbox Code Playgroud) 昨天,我的应用程序从 Google Playstore 中删除,因为它使用的是 Stripe-Android SDK。
\n以下是我的应用程序从 Google Playstore 中删除的原因:
\n\n\n我们\xe2\x80\x99 已确定您的应用正在使用 Stripe SDK 或库,这\n有助于电话号码和\n已安装应用程序信息的传输和收集,而\n不符合重要的\n披露准则。请务必在 Play 开发者控制台的指定字段和 Play 分布式应用本身中\n发布隐私政策。如有必要,您可以咨询您的 SDK\n提供商以获取更多信息。
\n
由于我这边没有收集任何类型的信息,我该如何解决这个问题?
\nandroid google-play stripe-payments google-play-services privacy-policy
我是条纹新手,决定使用stripe.net(https://github.com/jaymedavis/stripe.net).
我想做的是让客户按照每月向他们收费的计划.我还想让他们取消他们对该计划的订阅.这是stripe.net项目显示使用的代码.
StripeConfiguration.SetApiKey("[your api key here]");
var myCustomer = new StripeCustomerCreateOptions();
// set these properties if it makes you happy
myCustomer.Email = "pork@email.com";
myCustomer.Description = "Johnny Tenderloin (pork@email.com)";
// set these properties if using a card
myCustomer.CardNumber = "4242424242424242";
myCustomer.CardExpirationYear = "2012";
myCustomer.CardExpirationMonth = "10";
myCustomer.CardAddressCountry = "US";
myCustomer.PlanId = *planId*;
var customerService = new StripeCustomerService();
StripeCustomer stripeCustomer = customerService.Create(myCustomer);
Run Code Online (Sandbox Code Playgroud)
这是我必须做的就是让客户按照每月收费的计划吗?并取消计划......
var customerService = new StripeCustomerService();
StripeSubscription subscription = customerService.CancelSubscription(*customerId*);
Run Code Online (Sandbox Code Playgroud)
这就是我要做的全部吗?在stripe.net页面上还有一个用于创建费用的部分,我不确定是否必须对此进行任何操作.
我想在允许用户看到视频之前检查用户的订阅,因此我使用PHP与Stripe进行交互以检查用户的订阅,并使用PHP脚本将MP4提供给浏览器
第一次在谷歌浏览器中播放视频时使用它很好(使用HTML5播放器)...但是当我关闭视频并再次播放时,视频不再播放...我也不能重新加载当前页面.就像服务器停止工作一样.
当我检查第一个视频请求(播放的那个)时,在Timing选项卡中我看到:"注意:请求尚未完成!" (截图如下)

当我检查第二个视频请求(没有播放的那个)时,在Headers选项卡中显示"[警告标志]临时标题显示"(截图如下)

一切都在Safari或Firefox中按预期工作
任何人都知道发生了什么事吗?视频再次播放的唯一方法是关闭当前标签,再次进入该网站.重新加载不起作用!
php google-chrome video-streaming http-headers stripe-payments
我正在寻找一种方法来自定义“卡号”“到期日期”和“CCV”字段的布局,当使用条纹元素并card.mount('#card-element');按照本页第一个示例中所述注入这些字段https://stripe.com/文档/条纹-js
它将所有卡片字段放在一行中,我想更改该布局并将它们放在不同的行中。
有任何想法吗?
提前致谢
假设我们已经创建了一种付款方式 - pm_xxx。当我们创建客户时,我们可以通过java代码将此方法作为默认付款方式附加到客户:
CustomerCreateParams.Builder customerCreateParamsBuilder = CustomerCreateParams.builder()
.setEmail(email)
.setPaymentMethod('pm_xxx');
Customer.create(customerCreateParamsBuilder.build());
Run Code Online (Sandbox Code Playgroud)
不幸的是,更新客户的相应 api 不可用。所以问题是在 Stripe 中更新客户默认付款方式的首选方式是什么?
编辑:基于@karllekko 的回答,因为我的用例是定期付款,所以我结合了 2 个操作:将客户附加到付款方式:
paymentMethod.attach(PaymentMethodAttachParams.builder().setCustomer(customer.getId()).build());
Run Code Online (Sandbox Code Playgroud)
并为客户发票设置默认付款方式:
customer.update(CustomerUpdateParams.builder().setInvoiceSettings(CustomerUpdateParams.InvoiceSettings.builder().setDefaultPaymentMethod(token).build()).build());
Run Code Online (Sandbox Code Playgroud) stripe-payments ×10
php ×3
node.js ×2
android ×1
asp.net ×1
c# ×1
firebase ×1
google-play ×1
http-headers ×1
java ×1
javascript ×1
stripe.js ×1
sveltekit ×1
woocommerce ×1
wordpress ×1