簡體   English   中英

PHP - 條帶客戶端/客戶創建不起作用

[英]PHP - Stripe Client/Customer Creation not working

我正在嘗試創建一個新的 Stripe 客戶端,然后將其用於創建一個新客戶。 但是當我嘗試創建客戶端時出現錯誤(但沒有錯誤消息)

$email = "test@gmail.com"; // Only for testing: is drawn from my database above

// STRIPE STUFF //
require_once('./vendor/autoload.php');

echo "OK";

// Set your secret key. Remember to switch to your live secret key in production.
// See your keys here: https://dashboard.stripe.com/account/apikeys
$stripe = new \Stripe\StripeClient('sk_test_***');

echo "OK";

// Create the Customer
$customer = $stripe->customers->create([
    'email' => $email
]);
$customerResponse = json_decode($response->withJson(['customer' => $customer]), TRUE);

$stripeCustomerId = $customerResponse["id"];

第一個“OK”是 output,但第二個不是,之后不再執行任何代碼。 所以這一定是因為我如何創建 Stripe 客戶端,但不幸的是,我在 Stack Overflow 或 Stripe 文檔中找不到任何對我有幫助的東西。

StripeClient class 僅在幾個月前由 Stripe 添加。 它在 stripe-php 的 7.33.0 版本中提供,如此所述。 這意味着如果您使用的是舊版本的庫,則 class 將不存在。

根據您共享的代碼以及它在第一次回顯后如何崩潰,這可能是問題所在。 您的庫版本不夠最新,並且您的代碼無法安全地處理錯誤並崩潰。 如果您查看系統上的 PHP 錯誤日志,很可能會顯示一條錯誤消息,指出StripeClient class 不存在。

您必須至少升級到 7.33.0 版本,但最好升級到最新版本。 如果您使用的是 7.x 之前的版本,請確保查看 7.x 版本中的重大更改: https://github.com/stripe/stripe-php/wiki/Migration-guide-for-v7

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM