基本上,我只是想通过价格扩展产品调用,因此我不必为检索到的每个产品创建另一个 API。
Product.list(ProductListParams.builder()
.setActive(true)
.addExpand("data.prices")
.build());
Run Code Online (Sandbox Code Playgroud)
我已经尝试过 data.prices 和 data.price 但 Product Collection 响应 -> defaultPrice 仍然只是返回带有 null 可扩展对象的价格 id。
我也尝试过 data.defaultPrice,但在这种情况下调用完全失败。
谢谢大家。
我正在尝试从付款意图(其中网站中的用户按下付款来支付商品)和付款链接(他收到一个链接,然后他可以通过该链接付款)读取 webhook 响应试图找出如何区分它们,但我找不到区别。是否有标志或其他东西可以区分哪一个已付款
在 Stripe 客户门户设置中,我设置了“允许客户应用促销代码”,但是当我打开客户门户时,我找不到可以添加促销代码的任何地方。我可以取消订阅、更新付款方式或在设置中配置的客户数据,但不能取消促销代码。有什么特别的事情需要做吗?在生产中,我们通过特殊的 BillingPortalSession(stripe api)打开它,但我也检查了 stripe 自身生成的链接。
计费门户配置功能如下所示:
"features": {
"customer_update": {
"allowed_updates": [
"email",
"address",
"phone"
],
"enabled": true
},
"invoice_history": {
"enabled": true
},
"payment_method_update": {
"enabled": true
},
"subscription_cancel": {
"cancellation_reason": {
"enabled": true,
"options": [
"too_expensive",
"missing_features",
"switched_service",
"unused",
"other",
"customer_service",
"too_complex"
]
},
"enabled": true,
"mode": "at_period_end",
"proration_behavior": "none"
},
"subscription_pause": {
"enabled": false
},
"subscription_update": {
"default_allowed_updates": [
"price",
"promotion_code"
],
"enabled": true,
"proration_behavior": "create_prorations"
}
Run Code Online (Sandbox Code Playgroud) 为客户创建超过3 个订阅后,我收到以下错误:客户 cus_ ** 已拥有最多 3 个当前订阅和计划订阅。*
我正在关注 stripe 官方文档来集成订阅模块。但我在编写相同的代码时遇到错误:
未定义付款意图:TypeScript
错误:类型“string | ”上不存在属性“ payment_intent” 发票'。类型“string”上不存在属性“ payment_intent”。ts(2339)
exports.doSubscribe = functions.https.onRequest(async (data, res) => {
try {
///Create Customer
const customer = await stripe.customers.create({
description: 'My First Test Customer (created for API docs at https://www.stripe.com/docs/api)',
});
///Create Payment Method
const paymentMethod = await stripe.paymentMethods.create({
type: 'card',
card: {
number: '4242424242424242',
exp_month: 10,
exp_year: 2023,
cvc: '314',
},
});
///Attach Payment Method with Customer
await stripe.paymentMethods.attach(
paymentMethod.id,
{customer:customer.id}
);
///Crate Product
const product = await stripe.products.create({
name: 'Gold Special', …Run Code Online (Sandbox Code Playgroud) 我目前正在尝试在结帐会话完成后通过 Webhook 测试从 Stripe 接收 client_reference_id 。
目前,我正在通过 Stripe CLI 使用以下命令运行测试触发器:
条带触发器 checkout.session.completed
这成功调用了我后端的端点,并记录了事件。
但是,在通过 CLI 进行的这些触发器调用中,client_reference_id 为空。我想用我网站的用户 ID 填充此内容,这样我就可以更新我的数据库以将用户标记为高级帐户。
为此,我尝试这样做:
条带触发器 checkout.session.completed --add customer:client_reference_id=1234
希望它将 id 设置为 1234。但是,它保持为 null。
有谁知道通过 Stripe CLI 设置 client_reference_id 的命令是什么?
在我的 Rails 7 应用程序中,我正在使用订阅模型,因此通过 Stripe API 实现订阅。
请参阅下面的付款方式 (subscriptions_controller.rb),当用户单击“选择计划”按钮时会触发该付款方式。重定向有效,然后无效,然后再次有效;我没有改变订阅的创建方式以及检索 URL 的方式。
def payment
@subscription = current_user.subscription
if @subscription
plan_id = params[:plan_id]
@subscription.update(id: @subscription.id, plan_id:, user_id: current_user.id, active: true)
else
subscription_id = SecureRandom.uuid
plan_id = params[:plan_id]
@subscription = Subscription.new(id: subscription_id, plan_id:, user_id: current_user.id)
end
@checkout_session = create_checkout_session(@subscription)
@subscription.checkout_session_id = @checkout_session.id
@subscription.save!
redirect_to @checkout_session.url, allow_other_host: true
end
private
def create_checkout_session(subscription)
Stripe::Checkout::Session.create({
customer: current_user.stripe_id,
payment_method_types: ['card'],
line_items: [{
price: subscription.plan.stripe_price_id,
quantity: 1
}],
mode: 'subscription',
success_url: subscription_url(subscription),
cancel_url: new_subscription_url
})
end
Run Code Online (Sandbox Code Playgroud)
错误信息
我正在尝试用条纹创建电荷.尝试创建订单对象时出现以下错误,但我设置了attr_accessor:stripe_card_token.有谁知道我做错了什么?
ActiveModel::MassAssignmentSecurity::Error in OrdersController#create
Can't mass-assign protected attributes: stripe_card_token
Run Code Online (Sandbox Code Playgroud)
OrdersController - 创建动作
def create
@order = current_cart.build_order(params[:order])
@order.ip_address = request.remote_ip
@order.user_id = current_user.id
respond_to do |format|
if @order.save_with_payment
@order.add_line_items_from_cart(current_cart)
Cart.destroy(session[:cart_id])
session[:cart_id] = nil
format.html { render :action => "success", :notice => 'Thank you for your order.' }
format.xml { render :xml => @order, :status => :created, :location => @order }
else
format.html { render :action => "new" }
format.xml { render :xml => @order.errors,
:status => :unprocessable_entity }
end
end …Run Code Online (Sandbox Code Playgroud) shopping-cart ruby-on-rails mass-assignment attr-accessor stripe-payments
这是我第一次与Stripe交互并尝试将其绑定到CodeIgniter.目前,当您在我的应用程序上创建帐户时,它会将您添加到正确的条带计划中,并增加在该帐户上开帐单的总金额.
我在尝试使用此订阅计划时遇到问题#.我在他们的文档中发现,这涉及订阅计划数量.
我需要做的是当你停用一个用户时,它需要将数量更新为1.我无法弄清楚这一点.
使用他们的API,我可以通过以下方式完全删除订阅的客户:
$this->load->library( 'stripe' );
$this->stripe->customer_delete('cus_1WS0pth6srNf7H');
Run Code Online (Sandbox Code Playgroud)
现在我正在与:
$this->load->library( 'stripe' );
$customer_id = $company->stripe_id;
$this->stripe->customer_update($customer_id, **WHAT GOES HERE?**);
Run Code Online (Sandbox Code Playgroud)
任何帮助将不胜感激.总结一下,我需要在停用用户时将我的计划数量更新为-1.用户在我的应用程序中被停用正常,但现在我需要向Stripe发送请求以将我的计划更新为少1个用户.
也许这个customer_update功能不适合用于此?Stripe.php文件中有很多内容.
一旦我解决了这个问题,我就可以将其应用于重新激活用户.
stripe-payments ×10
angular ×1
codeigniter ×1
java ×1
laravel-5 ×1
node.js ×1
php ×1
ruby ×1
typescript ×1
webhooks ×1