正如标题所示,我无法使用Stripe将我的客户ID保存在我的数据库中。我正在创建一个注册表单,因此当用户注册该网站时,他们将拥有一个Stripe客户ID,以便将来付款。但是,当用户注册时,除客户ID外,所有数据都将保存到数据库中。
// Create a Customer
$customer = \Stripe\Customer::create(array(
"source" => $token,
"description" => "Example customer")
);
echo "customer ID is ".$customer->id;
$newCustomer = $customer->id;
// Charge the Customer instead of the card
\Stripe\Charge::create(array(
"amount" => 250, // amount in cents, again
"currency" => "gbp",
"customer" => $customer->id)
);
}
?>
<div class="container">
<div class="login">
<form action="register.php" method="POST">
<div class="col-md-6 login-do">
<div>
<select name="title" type="text" class="dropdown-select">
<option value="">Title</option>
<option value="Mr">Mr</option>
<option value="Miss">Miss</option>
<option value="Mrs">Mrs</option>
<option value="Ms">Ms</option>
</select>
</div>
<div class="login-mail">
<input name="first_name" type="text" placeholder="First Name" required="" oninvalid="this.setCustomValidity('Please Enter your first name')"/>
<i class="glyphicon glyphicon-user"></i>
</div>
<div class="login-mail">
<input name="last_name" type="text" placeholder="Last Name" required="" oninvalid="this.setCustomValidity('Please Enter your last name')" />
</div>
<div class="login-mail">
<input name="email" type="text" placeholder="E-Mail" />
<i class="glyphicon glyphicon-envelope"></i>
</div>
<div class="login-mail">
<input name="pass" type="text" type="password" placeholder="Password" />
<i class="glyphicon glyphicon-lock"></i>
</div>
<div class="login-mail">
<input name="retyped_password" type="text" type="password" placeholder="Retype Password" />
</div>
<a class="news-letter " href="#">
<label class="checkbox1"><input type="checkbox" name="checkbox" ><i> </i>Forget Password</label>
</a>
<label class="hvr-skew-backward">
<input type="submit" name="submit" value="Submit">
</label>
</div>
<div class="col-md-6 login-right">
<a href="login.html" class="hvr-skew-backward">Login</a>
</div>
<div class="clearfix"> </div>
</form>
</div>
</div>
<?php
if( isset($_POST['submit']) ){
$title = $_POST['title'];
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email = $_POST['email'];
$password = $_POST['pass'];
$retyped_password = $_POST['retyped_password'];
$newCustomer = $_POST['newCus'];
答案 0 :(得分:0)
您希望身份证来自哪里?您正在创建客户,但不在代码顶部包含其ID。它不应该包含在那里吗?
$customer = \Stripe\Customer::create(array(
"source" => $token,
"description" => "Example customer",
"id" => "123")
);
答案 1 :(得分:0)
逻辑应该是这样的(只是伪代码):
\Stripe\Customer::create()