条带 - 使用表单中的电子邮件检索客户ID

时间:2014-06-15 17:00:30

标签: php stripe-payments

有没有办法从他们通过API在付款方式中输入的电子邮件中检索客户ID?

对于我的应用程序,客户将持续多次支付,但为了简单起见,没有登录,他们只需输入他们的付款信息和发票号码。作为一种最佳做法,我希望将所有费用保存在Stripe中,原因显而易见,但这似乎不太可能吗?

2 个答案:

答案 0 :(得分:6)

我做了这个API请求。条带docs中没有此API请求。我根据我的要求在仪表板上定制了搜索请求。

url :https://api.stripe.com/v1/search?query="+email+"&prefix=false",
method: GET
headers: {
  "authorization": "Bearer Your_seceret Key",
  "content-type": "application/x-www-form-urlencoded",
}

答案 1 :(得分:3)

这取决于您是否已经遵循其他最佳做法。 ;)

使用Stripe,与大多数付款解决方案一样,您打算保留您将重复使用的资源的ID。如果你这样做,那么你的用户数据库应该包含每个用户的Stripe客户ID,你可以:

听起来你还在开发中,在这种情况下,你可以轻松添加任何缺失的部分并继续运输。

例如,如果你正在使用Laravel,你可能会这样做:

// When creating a customer
$customer = new Customer;
$customer->name = 'John Smith';
$customer->email = 'jsmith@example.com';

$stripe_customer = Stripe_Customer::create(array(
  "description" => $customer->name,
  "email" => $customer->email
));

$customer->stripe_id = $stripe_customer->id;  // Keep this! We'll use it again!
$customer->save();


// When creating a charge
Stripe_Charge::create(array(
  "amount" => 2999,
  "currency" => "usd",
  "customer" => Auth::user()->stripe_id,      // Assign it to the customer
  "description" => "Payment for Invoice 4321"
));

但我已经推出了!

如果您已经推出并拥有实时发票,那么您将过去的费用与客户相关联的能力将随着您已经传递到Stripe的数据而变化。

如果没有更多详细信息,则无法提供任何具体指导,但the list of all charges可能是一个很好的起点。

相关问题