我需要我的客户添加他们的信用卡信息,但我不想立即收取费用。有什么办法,我可以在使用Stripes checkout
解决方案时添加他们的详细信息,以便稍后再存储他们的卡片令牌吗?
我在后端使用Laravel Cashier。
答案 0 :(得分:0)
但是使用Stripe,您可以创建客户并在以后通过信息向他们收费。
\Stripe\Stripe::setApiKey("sk_test_BQokikJOvBiI2HlWgH4olfQ2");
// Create a Customer:
$customer = \Stripe\Customer::create([
'source' => 'tok_mastercard',
'email' => 'paying.user@example.com',
]);
// Charge the Customer instead of the card:
$charge = \Stripe\Charge::create([
'amount' => 1000,
'currency' => 'usd',
'customer' => $customer->id,
]);
// YOUR CODE: Save the customer ID and other info in a database for later.
// When it's time to charge the customer again, retrieve the customer ID.
$charge = \Stripe\Charge::create([
'amount' => 1500, // $15.00 this time
'currency' => 'usd',
'customer' => $customer_id, // Previously stored, then retrieved
]);
希望这有帮助。
答案 1 :(得分:0)
// Set Stripe API key
\Stripe\Stripe::setApiKey("sk_test_HGJJKJLJLKHKJHGJHGKH");
// Retrieve Customer
$customer = \Stripe\Customer::retrieve("cus_KJHKJHJKJKHKJHKJ");
// Create new card
$data = [
"type" => "card",
"card" => [
"exp_month" => "01",
"exp_year" => "20",
"number" => "4242424242424242",
"cvc" => "123",
],
];
$card = \Stripe\Source::create($data);
// Assign the created card to the customer
$customer->sources->create(["source" => $card['id']]);