I'm using the SDK provided online to connect the payment API, and I'm sure the SDK can work successfully. However, as I followed the steps setting up my code, I got an error. I think it might because of the different Laravel version I used.
I want to use the class "Newebpay" in my PurchasesController.php, but I got the error message: Class 'Newebpay' not found.
Here is my PurchasesController.php code:
<?php
namespace App\Http\Controllers;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
use Newebpay;
class PurchasesController extends Controller
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
public function index()
{
return view('purchases.index');
}
public function purchase()
{
$newebpay = new NewebPay();
return $newebpay->payment(
'549881412984', // 訂單編號
123, // 交易金額
'test', // 交易描述
'kk@gmail.com' // 付款人信箱
)->submit();
}
}
I've followed the instruction in the SDK, adding 'NewebPay' => Treerful\NewebPay\NewebPay::class,in the \config\app.php 'aliases' part as the code below.
'aliases' => [
'App' => Illuminate\Support\Facades\App::class,
...
'NewebPay' => Treerful\NewebPay\NewebPay::class,
],
For more details, here is my git repository of this project. https://github.com/shigenogoro/testing_laravel
Aucun commentaire:
Enregistrer un commentaire