【发布时间】:2014-12-11 03:16:25
【问题描述】:
我使用 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();
}
}
?>
【问题讨论】:
-
你能发布一些你的代码吗?
-
当然,我刚刚添加了charge.php
-
假设您现在可以通过电子邮件进行搜索,但 Stripe 仍然愚蠢地允许多个客户使用同一电子邮件,因此我们需要处理结果中的重复项:stackoverflow.com/a/40482496/470749
标签: php stripe-payments