You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Laravel中Stripe支付测试正常,生产环境报“No such token”求助

Troubleshooting Stripe Production Charge Error: "No such token: cus_EuguGZgeDoCxBj"

Hey Wesley, let's break down what's happening here—this is a super common mix-up with Stripe's API parameters, so you're definitely not alone in hitting this!

First, let's zero in on the error message: No such token: cus_EuguGZgeDoCxBj. Notice the cus_ prefix? That's a Stripe Customer ID, not a payment source token (which starts with tok_) or payment method ID (which starts with pm_). Your code is passing this Customer ID to the source parameter, which expects a payment source identifier—not a customer ID. That's why Stripe is throwing the error: it's searching for a token with that cus_ ID, which doesn't exist.

Here's how to fix this, depending on your use case:

1. If you're charging an existing customer (using their saved payment method)

If $getCommission->unique_id is indeed a valid Customer ID (the cus_ value from your error), swap the source parameter for customer when creating the Charge. Stripe will automatically use the customer's default payment method, or you can specify a specific one with the payment_method parameter if needed.

Modified code example:

Stripe::setApiKey('sk_live_yourActualLiveSecretKey'); // Double-check this is your production secret key (sk_live_ prefix)
/* Create charge using an existing customer */
$results = \Stripe\Charge::create([
    "amount" => 10, // Use integer values here—Stripe amounts are in the smallest currency unit (10 = 10 JPY)
    "currency" => "jpy",
    "customer" => $getCommission->unique_id, // Replace "source" with "customer"
    "description" => "test charge"
]);

2. If you meant to charge a one-time payment source (not an existing customer)

If you intended to use a one-time payment token (generated via Stripe.js on your frontend), verify that $getCommission->unique_id is a valid tok_ or pm_ identifier. Double-check your frontend code to ensure it's sending the correct payment source token to your backend, not a Customer ID by mistake.

Quick additional checks to rule out other issues:

  • Confirm your API key: Make sure you're using a production Secret Key (starts with sk_live_), not a Publishable Key (pk_live_). Publishable keys don't have permission to create Charges, though the error message would differ—but it's worth verifying anyway.
  • Stripe account status: Ensure your production Stripe account is fully activated (you've submitted required verification info, bank details, etc.). Inactive accounts can't process live charges.
  • Consider migrating to Payment Intents: While the Charge API still works, Stripe recommends using the Payment Intents API for new integrations—it handles 3D Secure and other regulatory requirements more smoothly, which is critical for production.

内容的提问来源于stack exchange,提问作者Wesley Schravendijk

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.12 05:21:39