我有条纹检查与PHP.它创造了客户并为他们收费.我想创建一个捐赠表单,如果同一个客户回来并给出相同的电子邮件地址,Stripe不会创建另一个客户,但会向现有客户收取额外付款.这可能吗?或者结账总是创建具有新客户ID的新客户?
这是我的charge.php
<?php
require_once('config.php');
$token = $_POST['stripeToken'];
if($_POST) {
$error = NULL;
try{
if(!isset($_POST['stripeToken']))
throw new Exception("The Stripe Token was not generated correctly");
$customer = Stripe_Customer::create(array(
'card' => $token,
'email' => $_POST['stripeEmail'],
'description' => 'Thrive General Donor'
));
$charge = Stripe_Charge::create(array(
'customer' => $customer->id,
'amount' => $_POST['donationAmount'] * 100,
'currency' => 'usd'
));
}
catch(Exception $e) {
$eror = $e->getMessage();
}
}
?>
Run Code Online (Sandbox Code Playgroud)