PaymentController.php
<?php
namespace App\Http\Controllers;
use Paypalpayment;
class paymentController extends Controller
{
private $_apiContext;
function __construct()
{
$this->_apiContext = Paypalpayment::apiContext(config('paypal_payment.Account.ClientId'
), config('paypal_payment.Account.ClientSecret'));
}
public function store()
{
$addr= Paypalpayment::address();
$addr->setLine1("3909 Witmer Road");
$addr->setLine2("Niagara Falls");
$addr->setCity("Niagara Falls");
$addr->setState("NY");
$addr->setPostalCode("14305");
$addr->setCountryCode("US");
$addr->setPhone("716-298-1822");
$card = Paypalpayment::creditCard();
$card->setType("visa")
->setNumber("4758411877817150")
->setExpireMonth("05")
->setExpireYear("2019")
->setCvv2("456")
->setFirstName("Joe")
->setLastName("Shopper");
$fi = Paypalpayment::fundingInstrument();
$fi->setCreditCard($card);
$payer = Paypalpayment::payer();
$payer->setPaymentMethod("credit_card")
->setFundingInstruments(array($fi));
$item1 = Paypalpayment::item();
$item1->setName('Ground Coffee 40 oz')
->setDescription('Ground Coffee 40 oz')
->setCurrency('USD')
->setQuantity(1)
->setTax(0.3)
->setPrice(7.50);
$item2 = Paypalpayment::item();
$item2->setName('Granola bars')
->setDescription('Granola Bars with Peanuts')
->setCurrency('USD')
->setQuantity(5)
->setTax(0.2)
->setPrice(2);
$itemList = Paypalpayment::itemList();
$itemList->setItems(array($item1,$item2));
$details = Paypalpayment::details();
$details->setShipping("1.2")
->setTax("1.3")
//total of items prices
->setSubtotal("17.5");
//Payment Amount
$amount = Paypalpayment::amount();
$amount->setCurrency("USD")
// the total is $17.8 = (16 + 0.6) * 1 ( of quantity) + 1.2 ( of Shipping).
->setTotal("20")
->setDetails($details);
$transaction = Paypalpayment::transaction();
$transaction->setAmount($amount)
->setItemList($itemList)
->setDescription("Payment description")
->setInvoiceNumber(uniqid());
$payment = Paypalpayment::payment();
$payment->setIntent("sale")
->setPayer($payer)
->setTransactions(array($transaction));
try
{
$payment->create($this->_apiContext);
}
catch (\PPConnectionException $ex)
{
return "Exception: " . $ex->getMessage() . PHP_EOL;
exit(1);
}
dd($payment);
}
}
?>
Composer.json
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.1.*"
"laravelcollective/html": "5.1.*"
"anouar/paypalpayment" : "~1.0"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1"
},
FatalErrorException: Class 'anouar\Paypalpayment\PaypalpaymentServiceProvider' not found
i m getting this error FatalErrorException: Class 'anouar\Paypalpayment\PaypalpaymentServiceProvider' not found
FatalErrorException: Class 'anouar\Paypalpayment\PaypalpaymentServiceProvider' not found
i m getting this error FatalErrorException: Class 'anouar\Paypalpayment\PaypalpaymentServiceProvider' not found
FatalErrorException: Class 'anouar\Paypalpayment\PaypalpaymentServiceProvider' not found
i m getting this error FatalErrorException: Class 'anouar\Paypalpayment\PaypalpaymentServiceProvider' not found
FatalErrorException: Class 'anouar\Paypalpayment\PaypalpaymentServiceProvider' not found
i m getting this error FatalErrorException: Class 'anouar\Paypalpayment\PaypalpaymentServiceProvider' not found
FatalErrorException: Class 'anouar\Paypalpayment\PaypalpaymentServiceProvider' not found
i m getting this error FatalErrorException: Class 'anouar\Paypalpayment\PaypalpaymentServiceProvider' not found
FatalErrorException:未找到类'anouar \ Paypalpayment \ PaypalpaymentServiceProvider' 我收到此错误FatalErrorException:未找到类'anouar \ Paypalpayment \ PaypalpaymentServiceProvider' FatalErrorException:找不到类'anouar \ Paypalpayment \ PaypalpaymentServiceProvider' 我收到此错误FatalErrorException:未找到类'anouar \ Paypalpayment \ PaypalpaymentServiceProvider' 我收到此错误FatalErrorException:未找到类'anouar \ Paypalpayment \ PaypalpaymentServiceProvider'
答案 0 :(得分:0)
PHP命名空间区分大小写。在为Paypalpayment软件包定义服务提供程序时,您似乎在config/app.php
文件中犯了错误。
应该是:
Anouar\Paypalpayment\PaypalpaymentServiceProvider::class
而不是:
anouar\Paypalpayment\PaypalpaymentServiceProvider::class