How to add plain PHP library into Laravel?
<p>I am using 2checkout API to integrate payments in my application. I am following their <a href="https://www.2checkout.com/documentation/payment-api/tutorial" rel="nofollow">API Tutorial</a>. I made slight modifications to their approach. Below is the unmodified front-end code by tutorial.</p>

<pre><code>&lt;form id="myCCForm" action="payment.php" method="post"&gt;
&lt;input id="token" name="token" type="hidden" value=""&gt;
&lt;div&gt;
    &lt;label&gt;
        &lt;span&gt;Card Number&lt;/span&gt;
    &lt;/label&gt;
    &lt;input id="ccNo" type="text" size="20" value="" autocomplete="off" required /&gt;
&lt;/div&gt;
&lt;div&gt;
    &lt;label&gt;
        &lt;span&gt;Expiration Date (MM/YYYY)&lt;/span&gt;
    &lt;/label&gt;
    &lt;input type="text" size="2" id="expMonth" required /&gt;
    &lt;span&gt; / &lt;/span&gt;
    &lt;input type="text" size="2" id="expYear" required /&gt;
&lt;/div&gt;
&lt;div&gt;
    &lt;label&gt;
        &lt;span&gt;CVC&lt;/span&gt;
    &lt;/label&gt;
    &lt;input id="cvv" size="4" type="text" value="" autocomplete="off" required /&gt;
&lt;/div&gt;
&lt;input type="submit" value="Submit Payment"&gt;
</code></pre>

<p></p>

<p>I changed  the line <code>&lt;form id="myCCForm" action="payment.php" method="post"&gt;</code>to <code>&lt;form id="myCCForm" action="{{route('postPayment)}}" method="post"&gt;</code> and also added CSRF token field in the above form.</p>

<p>This thing is working fine. </p>

<p>The 2nd Part is server side script that I want to handle in Laravel application. In tutorial this is written in payment.php. The script is working fine in payment.php but I am trying to write it in controller as follows:</p>

<pre><code>&lt;?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\TwoCheckout;



class PaymentsController extends Controller
{

    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $twoCheckOut = TwoCheckout::find(1);
        return view('payment')-&gt;with('twoCheckOut',$twoCheckOut);
    }

    public function process()
    {
       require_once("2checkout-php/lib/Twocheckout.php");

        Twocheckout::privateKey('6CC34113-3588-4B09-8ECB-958C0B3299F3');
        Twocheckout::sellerId('901303383');
        Twocheckout::sandbox(true);


        try {
            $charge = Twocheckout_Charge::auth(array(
                "sellerId" =&gt; "901303383",
                "merchantOrderId" =&gt; "123",
                "token" =&gt; 'Y2U2OTdlZjMtOGQzMi00MDdkLWJjNGQtMGJhN2IyOTdlN2Ni',
                "currency" =&gt; 'USD',
                "total" =&gt; '10.00',
                "billingAddr" =&gt; array(
                    "name" =&gt; 'Testing Tester',
                    "addrLine1" =&gt; '123 Test St',
                    "city" =&gt; 'Columbus',
                    "state" =&gt; 'OH',
                    "zipCode" =&gt; '43123',
                    "country" =&gt; 'USA',
                    "email" =&gt; 'testingtester@2co.com',
                    "phoneNumber" =&gt; '555-555-5555'
                ),
                "shippingAddr" =&gt; array(
                    "name" =&gt; 'Testing Tester',
                    "addrLine1" =&gt; '123 Test St',
                    "city" =&gt; 'Columbus',
                    "state" =&gt; 'OH',
                    "zipCode" =&gt; '43123',
                    "country" =&gt; 'USA',
                    "email" =&gt; 'testingtester@2co.com',
                    "phoneNumber" =&gt; '555-555-5555'
                )
            ), 'array');
            if ($charge['response']['responseCode'] == 'APPROVED') {
                echo "Thanks for your Order!";
            }
        } catch (Twocheckout_Error $e) {
            $e-&gt;getMessage();
        }
    }


}
</code></pre>

<p>The problem is occurring in following lines.</p>

<pre><code>require_once("2checkout-php/lib/Twocheckout.php");

            Twocheckout::privateKey('6CC34113-3588-4B09-8ECB-958C0B3299F3');
            Twocheckout::sellerId('901303383');
            Twocheckout::sandbox(true);
</code></pre>

<p><strong>ERROR</strong></p>

<blockquote>
  <p>BadMethodCallException in Builder.php line 2099:
  Call to undefined method Illuminate\Database\Query\Builder::privateKey()</p>
</blockquote>

<p>What am I doing wrong here?</p>