简体   繁体   中英

Fatal error: Cannot use object of type Stripe\Customer as array

When I am creating stripe customer it is giving me the error that i mentioned.

Fatal error: Cannot use object of type Stripe\\Customer as array

include("vendor/autoload.php");

use Stripe\Stripe;
use Stripe\Customer;

Stripe::setApiKey("sk_test_Gq0THSZXNnpOqFRpN4uSwV7Y");


if(isset($_POST['stripeToken'])) {
Stripe::setApiKey("sk_test_anjsdanjnasdjnjads");
$sEmail=$_POST['stripeEmail'];
$sToken=$_POST['stripeToken'];
    $customer = Customer::create(array(
        "email" => $sEmail,
        "source" => $sToken,
    ));

I was using the latest version of Stripe API which as it turns out to be unstable. Downgraded to version 4.2 and it worked !

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM