如何使用Stripe Checkout记录免信用卡的100%折扣交易?
解决方法
方法1:调整0金额/微金额+固定抵扣优惠券的配置
你之前尝试的100%折扣被禁止,大概率是因为使用了percent_off=100的规则,换用固定金额抵扣的优惠券即可绕过限制:
- 先创建一个金额为1分的商品价格(
amount=1,币种匹配你的业务) - 创建对应币种的优惠券,设置
amount_off=1(与商品金额完全抵消) - 在PHP的Checkout会话中同时传入商品和优惠券参数,最终订单金额为0,Stripe会正常记录交易:
// 创建优惠券(仅需执行一次) $coupon = \Stripe\Coupon::create([ 'amount_off' => 1, 'currency' => 'usd', 'name' => '员工免费购买抵扣券', ]); // 创建Checkout会话 $session = \Stripe\Checkout\Session::create([ 'payment_method_types' => ['link'], 'line_items' => [[ 'price' => 'price_minimal', // 提前创建的1分金额Price ID 'quantity' => 1, ]], 'discounts' => [[ 'coupon' => $coupon->id, ]], 'mode' => 'payment', 'success_url' => 'https://yourdomain.com/success', 'cancel_url' => 'https://yourdomain.com/cancel', ]);
方法2:使用Stripe发票系统创建免费账单并标记已支付
通过发票流程可以生成完整的交易记录,且无需信用卡验证:
- 为员工创建对应的Customer对象(若不存在)
- 创建关联商品的发票,应用全额抵扣的优惠券,然后手动标记为已支付:
// 创建发票 $invoice = \Stripe\Invoice::create([ 'customer' => 'cus_employee', // 员工的Customer ID 'collection_method' => 'send_invoice', 'days_until_due' => 0, 'line_items' => [[ 'price' => 'price_your_product', // 正常商品价格 'quantity' => 1, ]], ]); // 应用全额抵扣优惠券 $invoice->update([ 'discount' => ['coupon' => 'coupon_full_off'], // 提前创建的固定金额抵扣优惠券 ]); // 确认发票并标记已支付 $invoice->finalizeInvoice(); $invoice->markAsPaid();
此操作会在Stripe的发票记录、交易日志中留下完整轨迹,完全符合需求。
方法3:利用客户余额实现免费支付
给员工的客户账户添加等额信用额度,支付时自动用余额抵消订单金额:
- 为员工创建Customer对象
- 给客户账户添加信用额度:
\Stripe\CustomerBalanceTransaction::create([ 'customer' => 'cus_employee', 'amount' => -1000, // 负数值代表信用,单位为分,此处为10美元 'currency' => 'usd', 'description' => '员工福利信用额度', ]);
- 创建Checkout会话时,将
payment_method_types包含customer_balance,支付流程会自动用余额完成抵扣,无需信用卡。
内容的提问来源于stack exchange,提问作者hdwebpros
相关产品推荐
相关产品推荐

