尝试从命名空间加载类“Braintree_MerchantAccount”

时间:2016-11-09 11:47:09

标签: symfony braintree

我正在Symfony2 project尝试实施braintree商家付款。我在下面添加了

"require" : {
    "braintree/braintree_php" : "3.17.0"
}

投射

这是使用文档创建商家的操作:

public function createMerchantAction(Request $request){

    $response = new JsonResponse();

    $merchantAccountParams = [
        'individual' => [
            'firstName' => 'Jane',
            'lastName' => 'Doe',
            'email' => 'jane@14ladders.com',
            'phone' => '5553334444',
            'dateOfBirth' => '1981-11-19',
            'ssn' => '456-45-4567',
            'address' => [
                'streetAddress' => '111 Main St',
                'locality' => 'Chicago',
                'region' => 'IL',
                'postalCode' => '60622'
            ]
        ],
        'business' => [
            'legalName' => 'Jane\'s Ladders',
            'dbaName' => 'Jane\'s Ladders',
            'taxId' => '98-7654321',
            'address' => [
                'streetAddress' => '111 Main St',
                'locality' => 'Chicago',
                'region' => 'IL',
                'postalCode' => '60622'
            ]
        ],
        'funding' => [
            'descriptor' => 'Blue Ladders',
            'destination' => 'bank',
            'email' => 'funding@blueladders.com',
            'mobilePhone' => '5555555555',
            'accountNumber' => '1123581321',
            'routingNumber' => '071101307'
        ],
        'tosAccepted' => true,
        'masterMerchantAccountId' => 'asdasd'
    ];

    $result = Braintree_MerchantAccount::create($merchantAccountParams);

    $response->setData([
        "success" => $result->success
    ]);

    return $response;
  }

为什么我一直收到以下错误?

  

'尝试从命名空间“AppBundle \ Controller”加载类“Braintree_MerchantAccount”。您是否忘记了另一个命名空间的“use”语句? (500内部服务器错误)'

1 个答案:

答案 0 :(得分:1)

我认为您尚未为Braintree_MerchantAccount声明名称空间。

请更换 $result = Braintree_MerchantAccount::create($merchantAccountParams);

$result = \Braintree_MerchantAccount::create($merchantAccountParams);