我的 Stripe 工作得很好。客户捐款后,会创建一个新订阅,并且效果很好 - 除非 Stripe 识别出电子邮件并说“输入验证码”。
如果客户这样做,出于某种原因,不会创建新订阅并且不会向客户收费。
这是我的charge-monthly.php
<?php
require_once('init.php');
// Set your secret key: remember to change this to your live secret key in production
// See your keys here https://dashboard.stripe.com/account/apikeys
\Stripe\Stripe::setApiKey("sk_test_**************");
// Get the credit card details submitted by the form
$token = $_POST['stripeToken'];
$email = $_POST['stripeEmail'];
$amount = $_POST['amount'];
$finalamount = $amount * 100;
$dollars = ".00";
$plan = "/month";
$dash = " - ";
$monthlyplan = $amount .$dollars .$plan .$dash .$email;
//Create monthly plan
$plan = \Stripe\Plan::create(array(
"name" => $monthlyplan,
"id" => $monthlyplan,
"interval" => "month",
"currency" => "usd",
"amount" => $finalamount,
));
// Create a Customer
$customer = \Stripe\Customer::create(array(
"source" => $token,
"description" => "MONTHLY DONATION",
"plan" => $monthlyplan,
"email" => $email, )
);
?>
任何想法为什么当 Stripe 识别出用户并且他“登录”时它不允许我创建订阅?
在 Stripe 日志中,我收到了 400 错误:
{
"error": {
"type": "invalid_request_error",
"message": "Plan already exists."
}
}
但是绝对没有制定计划……啊!