2017-05-06 127 views
0

我試圖讓laravel 5.4上的paymentwall工作,但我無法設置它。與Laravel 5.4一起使用非laravel和composer包

我已將它直接添加到根文件夾folder structure感覺有文檔說它需要添加到我正在構建的應用程序中。我也曾嘗試設置我的根composer.json這樣的:

"autoload": { 
    "classmap": [ 
     "database" 
    ], 
    "psr-4": { 
     "App\\": "app/", 
     "Paymentwall\\": "paymentwall-php-master/paymentwall-php-master/lib" 
    } 
}, 

後dumpauto我叫itlike牛逼

namespace App\Http\Controllers; 

使用Paymentwall;

使用Illuminate \ Http \ Request; 類CheckoutController擴展控制器 {

public static function checkout(){ 
    return view('rent.checkout.checkout'); 
} 

public function paymentDrive(request $request){ 


    Paymentwall_Config::getInstance()->set(array(
     'private_key' => 'xxxxxxxx' 
    )); 

    echo print_r($_POST, true); 

    $cardInfo = array(
     'email' =>'[email protected]', 
     'amount' => 10, 
     'currency' => 'USD', 
     'token' => $_POST['brick_token'], 
     'fingerprint' => $_POST['brick_fingerprint'], 
     'description' => 'Order #123' 
    ); 

    $charge = new Paymentwall_Charge(); 
    $charge->create($cardInfo); 
    $response = $charge->getPublicData(); 
    if ($charge->isSuccessful()) { 
     if ($charge->isCaptured()) { 
      // deliver s product 
     } elseif ($charge->isUnderReview()) { 
      // decide on risk charge 
     } 
    } else { 
     $errors = json_decode($response, true); 
    } 
    echo $response; 
} 

}

但我仍然得到這個錯誤Class 'App\Http\Controllers\Paymentwall_Config' not found

我真的想了解如何做到這一點。 BTW這個API包使用不同的文件夾結構,這讓我感到困惑。

回答

0

您應該運行:

composer require paymentwall/paymentwall-php 
在控制檯

這應該是一切(您不必手動複製包文件)。

您不應該爲此手動更新您的composer.json。這個庫可在packagist這裏找到:https://packagist.org/packages/paymentwall/paymentwall-php

+0

這確實解決了付款問題,謝謝。但是我仍然對如何實現一個沒有composer的軟件包感到困惑。 –