\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
]);
希望这可以帮助 .
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']]);
2 回答
与Laravel收银员相比,真的很难做到这一点 . 你必须稍微调整一下..
但是使用Stripe,您可以创建客户并在以后通过信息向他们收费 .
希望这可以帮助 .