Php 如何同时创建客户和收费订阅?
我正在使用stripe,以前所有订阅都正常工作。 就在最近,我尝试将相同的代码移动到不同的条带帐户,并且在尝试向订阅收费时收到错误Php 如何同时创建客户和收费订阅?,php,stripe-payments,checkout,stripe.js,Php,Stripe Payments,Checkout,Stripe.js,我正在使用stripe,以前所有订阅都正常工作。 就在最近,我尝试将相同的代码移动到不同的条带帐户,并且在尝试向订阅收费时收到错误 <?php require_once('../stripe-php-master/init.php'); // (switch to the live key later) \Stripe\Stripe::setApiKey("sk_test_hlQNSE1fy1cGmsqDSbR9LfDF"); try { $customer = \Stri
<?php
require_once('../stripe-php-master/init.php');
// (switch to the live key later)
\Stripe\Stripe::setApiKey("sk_test_hlQNSE1fy1cGmsqDSbR9LfDF");
try
{
$customer = \Stripe\Customer::create(array(
'email' => $_POST['stripeEmail'],
'source' => $_POST['stripeToken'],
'plan' => 'basic_annually'
));
header('Location: ../../subscription-success.html');
exit;
}
catch(Exception $e)
{
header('Location:oops.html');
error_log("unable to sign up customer:" . $_POST['stripeEmail'].
", error:" . $e->getMessage());
}
您必须更改机密和测试api密钥您必须更改机密和测试api密钥同时具有和属性
id
是计划的唯一标识符,name
是计划的显示名称
或时,参数的值必须设置为有效的计划ID,而不是计划名称
在您的情况下,错误消息明确告诉您,有一个计划的名称为“basic\u monthly”
,但该计划的id是504102373103330
,因此,您需要在plan
参数中传递该值,以创建对该计划的订阅。同时具有和属性id
是计划的唯一标识符,name
是计划的显示名称
或时,参数的值必须设置为有效的计划ID,而不是计划名称
在您的情况下,错误消息明确告诉您,有一个计划的名称为“basic\u monthly”
,但该计划的id是504102373103330
,这就是您需要在plan
参数中传递的值,以创建对该计划的订阅。正如您所说,您正在尝试对不同的条带帐户使用相同的代码。该条带帐户是否具有定义了ID
basic\u的计划?如果ID
为504102373103330
则为是,您需要在计划中传递该计划,正如您所说的,您正在尝试为不同的条带帐户使用相同的代码。该条带帐户是否具有定义了ID
basic\u的计划?如果ID
为504102373103330
则为是,您需要在计划中传递该计划
unable to sign up customer: 'test@example.com', error:No such plan: basic_monthly; one exists with a name of basic_monthly, but its ID is 504102373103330.