【发布时间】:2016-03-17 22:02:22
【问题描述】:
我正在使用 Stripe 作为我设计的网站的支付网关。我已经能够创建客户并向客户收费,但是我还想将客户 ID 存储在我的数据库中。如何检索客户 ID?这是我的代码 sn-p:
....
// Create a Customer
$customer = \Stripe\Customer::create(array(
'email' => $email,
'card' => $token,
//'address_line1' = $addr1 . " ". $addr2 . " ". $city . " " . " " .$country ,
//'address_zip' = $postcode,
'description' =>'Partnership' . " " . $fname . " " . $lname
));
// Charge the Customer instead of the card
$charge = \Stripe\Charge::create(array(
'customer' => $customer->id,
'amount' => $amount,
'currency' => 'gbp',
"metadata" => array("order_id" => "6735")
));
//retrieve customer id
$customerId = \Stripe\Charge::retrieve($charge['customer']);
这是我收到的错误消息:
Notice: Undefined variable: charge
Fatal error: Uncaught exception 'Stripe\Error\InvalidRequest' with message 'Could not determine which URL to request: Stripe\Charge instance has invalid ID: ' in ....
1. enter code here
【问题讨论】:
-
你是怎么解决这个问题的?我需要一点帮助
标签: stripe-payments