Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/283.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何同时创建客户和收费订阅?_Php_Stripe Payments_Checkout_Stripe.js - Fatal编程技术网

Php 如何同时创建客户和收费订阅?

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

我正在使用stripe,以前所有订阅都正常工作。 就在最近,我尝试将相同的代码移动到不同的条带帐户,并且在尝试向订阅收费时收到错误

<?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.