Php 错误:不能多次使用条带标记
我正在尝试使用StripeAPI制定每月订阅计划,但我收到一条错误消息,上面说 不能多次使用条带标记 当我试图删除Php 错误:不能多次使用条带标记,php,stripe-payments,Php,Stripe Payments,我正在尝试使用StripeAPI制定每月订阅计划,但我收到一条错误消息,上面说 不能多次使用条带标记 当我试图删除'source'=>$token时,出现以下错误: 客户必须具有活动的付款来源 这是我的密码: require_once('stripe/config.php'); $token = $_POST['stripeToken']; $email = $_POST['stripeEmail']; $customer = \Stripe\Customer::create([ 'em
'source'=>$token
时,出现以下错误:
客户必须具有活动的付款来源
这是我的密码:
require_once('stripe/config.php');
$token = $_POST['stripeToken'];
$email = $_POST['stripeEmail'];
$customer = \Stripe\Customer::create([
'email' => $email,
'source' => $token,
]);
\Stripe\Stripe::setApiKey("sk_test_xxxxxxxxxxxxxxxxxxxxxxxxx");
$product = \Stripe\Product::create([
'name' => 'Abonnement Simple',
'type' => 'service',
]);
$subscription = \Stripe\Subscription::create(array(
"customer" => $customer->id,
"plan" => "simpleNoEngagement"
));
仅在创建新客户时才需要令牌。创建客户后,您无需再次发送令牌。在这种情况下,您需要获取customerId。您已经在某个地方设置了API密钥,您已经创建了customer,这意味着条带已经初始化,否则无法创建customer。令牌只能在条带中使用一次。如果您想重用它,您必须将令牌保存到Customer中,就像您使用令牌创建Customer时所做的那样。之后,您可以对客户进行简单的收费或创建订阅,默认情况下将使用保存的卡。这里我认为问题在于你的订阅创建签名,你应该遵循这个API文档。您需要将计划放入项目数组中。