嗨,我正在向客户添加用法,但出现以下错误:
{
"error": {
"code": "parameter_unknown",
"doc_url": "https://stripe.com/docs/error-codes/parameter-unknown",
"message": "Received unknown parameter: {\"quantity\":1,\"timestamp\":1624294464}",
"param": "{\"quantity\":1,\"timestamp\":1624294464}",
"type": "invalid_request_error"
}
}
这很奇怪,因为quantity&×tamp是请求中的必需参数。
这是我现在拥有的代码。
注意:我正在使用 laravel,但我不想使用 php 库。
$url = 'https://api.stripe.com/v1/subscription_items/'.$subscriptionItemObj->stripe_id.'/usage_records';
$fields = ["quantity"=>1, "timestamp" => $dt->getTimestamp()];
$fieldsEncoded = json_encode($fields);
$headers = [ 'Authorization: Bearer '.env('STRIPE_SECRET') ];
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fieldsEncoded);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$output = curl_exec($ch);
curl_close($ch);
你知道为什么会发生这种情况吗?
