标签: stripe-payments

条带卡验证在开发与生产中表现不同

我对Stripe有一个奇怪的问题(在Rails上,但Rails部分可能无关紧要).

当我在生产中使用语法上有效但非工作的卡号填写我的注册表单时(例如4242424242424242),当我尝试创建令牌时,我收到此响应:

sjsonp1389885476573({
  "error": {
    "message": "Your card was declined.",
    "type": "card_error",
    "code": "card_declined"
  }
}
, 402)
Run Code Online (Sandbox Code Playgroud)

开发中我使用"始终返回card_declined"卡号(4000000000000002),Stripe将其视为非常好:

sjsonp1389885473743({
  "id": "tok_3JvncLYlEZ5NMF",
  "livemode": false,
  "created": 1389885584,
  "used": false,
  "object": "token",
  "type": "card",
  "card": {
    "id": "card_3Jvnr4MtIxzzd5",
    "object": "card",
    "last4": "0002",
    "type": "Visa",
    "exp_month": 2,
    "exp_year": 2020,
    "fingerprint": "dWQBpXrSXnyqoOxe",
    "customer": null,
    "country": "US",
    "name": null,
    "address_line1": null,
    "address_line2": null,
    "address_city": null,
    "address_state": null,
    "address_zip": null,
    "address_country": null,
    "address_line1_check": null,
    "address_zip_check": null,
    "cvc_check": null
  }
} …
Run Code Online (Sandbox Code Playgroud)

credit-card stripe-payments

10
推荐指数
1
解决办法
2379
查看次数

条纹 - 定期付款中包含的附加发票项目

我在订阅时添加发票项目时遇到问题,目前正在敲打我的头.

我在条纹上创建了一个发票项目,我希望发票项目包含在定期付款中

这是我的代码,它在第一张发票上添加了发票项目,但在下一张发票上没有.

$new_customer = Stripe_Customer::create(array(
    'card' => $card,
    'email' => $email,)
);
Stripe_InvoiceItem::create(array(
    'customer' => $new_customer['id'],
    'amount' => $additiona_charges,
    'currency' => 'gbp',
    'description' => 'Addtional Cities'
));
$new_customer->updateSubscription(array('plan' => $selected_plan, 'prorate' => true));
Run Code Online (Sandbox Code Playgroud)

在我目前的设置.我根据订阅时的客户选择收取额外的自定义费用,这样我需要在定期付款时添加额外费用.

它是这样的

计划

1 Cookie - 99GBP  / Per month
2 Cookies - 199GBP / Per month
3 Cookies - 300GBP / Per month
Run Code Online (Sandbox Code Playgroud)

附加费用 - 发票项目

-With Candle - +20GBP // must be included on recurring payment.
-With Icecream - +26GBP // must be included …
Run Code Online (Sandbox Code Playgroud)

webhooks stripe-payments

10
推荐指数
1
解决办法
5142
查看次数

如何在测试环境中删除Stripe上的日志

我正在使用Stripe从CodeIgniter应用程序对假定的客户执行一些测试事务.出于某种原因,要在线重新创建具有相同旧ID和名称的Stripe> Plan,或者 通过API 将Stripe客户重新输入Stripe> Customers,我必须清除测试数据.当我清除测试数据时,它会清除除日志之外的测试数据.

现在当我重新创建Stripe> Plan时会发生什么,它会自动从日志中获取已删除的客户.由于我可能已更改其凭据,因此我不需要计划中的旧客户.

那么如何在测试环境中删除/清除条带上的日志?

stripe-payments

10
推荐指数
6
解决办法
4362
查看次数

条纹结帐PAY按钮更改文本

如何将条带检出模式框中的文本从PAY更改为其他内容.

我知道我可以在弹出模态的按钮上做自定义文本.

description: 'ADD CARD',
label:'ADD CARD',
Run Code Online (Sandbox Code Playgroud)

但在实际的模态窗口.它仍然只是按下PAY.我想要它说ADD CARD.

javascript stripe-payments

10
推荐指数
2
解决办法
1万
查看次数

条纹:必须提供来源或客户

我正在尝试将Stripe集成到我的购物车项目中.我无法提交结帐表单.我不断收到此错误消息:"必须提供来源或客户." 要么我没有正确设置我的Stripe帐户,要么我在我的javascript中缺少一些参数.我花了好几个小时才解决这个问题,但仍然无法理解.

这是来自Stripe的日志:
Parsed Request POST Body

{
  "amount": "21000",
  "currency": "usd",
  "description": "Test Charge"
}
Run Code Online (Sandbox Code Playgroud)

响应机构

{
  "error": {
    "type": "invalid_request_error",
    "message": "Must provide source or customer."
  }
} 
Run Code Online (Sandbox Code Playgroud)

这是我的app.js.

var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var expressHbs = require('express-handlebars');
var mongoose = require('mongoose');
var session = require('express-session');
var passport = require('passport');
var flash = require('connect-flash');
var validator = require('express-validator');
var …
Run Code Online (Sandbox Code Playgroud)

javascript mongodb node.js stripe-payments

10
推荐指数
2
解决办法
1万
查看次数

在数据库中存储条纹付款的最佳实践?

我想知道是否存在某种“约定”或其他将 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 …

stripe-payments stripe.js

10
推荐指数
1
解决办法
4927
查看次数

更改 Woocommerce 中默认选择的支付网关

我在 Woocommerce 结帐页面中有两个不同的支付网关(条纹和银行转账)。但默认情况下,“银行转账”(bacs)始终是自动选择的。

这是我结帐页面上支付网关的屏幕截图:

在此处输入图片说明

我想改变它并自动选择条带支付网关。

我该怎么做?。任何帮助表示赞赏。

php wordpress payment-gateway stripe-payments woocommerce

10
推荐指数
2
解决办法
2万
查看次数

Stripe checkout 不接受元数据

我已经集成了 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 文档中所述

php stripe-payments

10
推荐指数
5
解决办法
5149
查看次数

如何修复节点中的“解析错误:意外令牌 =>”?

我正在使用 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

10
推荐指数
2
解决办法
7626
查看次数

使用结帐会话设置订阅时如何设置 billing_cycle_anchor?

正如标题所示:使用结账会话设置订阅时,在哪里可以设置 billing_cycle_anchor?使用订阅 API ( https://stripe.com/docs/api/subscriptions/create )设置订阅时,这是如何完成的很清楚 ;但是,我找不到有关如何在结帐会话中设置 billing_cycle_anchor 的任何详细信息(https://stripe.com/docs/api/checkout/sessions/create )。有谁知道我该怎么做(我正在使用node.js)?

node.js stripe-payments

10
推荐指数
1
解决办法
4587
查看次数