Closed cspreston closed 8 years ago
I've never got it, so not able to fix it, Could you investigate it further and fix,
BTW why not use 1.0?
Facing the same issue. Laravel 5.1
From composer.json
"payum/payum-laravel-package": "^1.0",
"payum/payum": "^1.0"
My PaymentController:
namespace App\Http\Controllers;
use Payum\LaravelPackage\Controller\PayumController;
class PaymentController extends PayumController {
public function payum()
{
$storage = $this->getPayum()->getStorage('Payum\Core\Model\Payment');
dd($this->getPayum());
$details = $storage->create();
$details['PAYMENTREQUEST_0_CURRENCYCODE'] = 'EUR';
$details['PAYMENTREQUEST_0_AMT'] = 1.23;
$storage->update($details);
$captureToken = $this->getPayum()->getTokenFactory()->createCaptureToken('paypal_ec', $details, 'payment_done');
return \Redirect::to($captureToken->getTargetUrl());
}
}
Hm, I am not sure but I suspect you haven't registered the payum service? Could you confirm you did it?
Btw, Do you use laravel 5?
Yes, you're right, it was the reason. In Get it started there is no info about registering service. So I registered Payum\LaravelPackage\PayumServiceProvider and now getting "Token storage must be configured" error. And yes, I use 5.1 Laravel
Indeed the doc miss this part, gonna fix it. To solve token storage must be configure you have to add a token storage to the payum builder, most like you want to choose eloquent storage.
<?php
// bootstrap/start.php
use Payum\LaravelPackage\Storage\EloquentStorage;
use Payum\LaravelPackage\Model\Token;
App::resolving('payum.builder', function(\Payum\Core\PayumBuilder $payumBuilder) {
$payumBuilder
->setTokenStorage(new EloquentStorage(Token::class))
;
});
ok, but bootstrap/start.php is for Laravel 4. Where to put this config in L5.1?
Put in any other place which is similar to start.php and where you can do similar things. I am not laravel developer. I dont know
This what you have to do to fix the reflection bug: https://github.com/makasim/PayumLaravelBundleSandbox/blob/payum-examples2/app/config/app.php#L124
The doc is updated: https://github.com/Payum/PayumLaravelPackage/blob/master/docs/get-it-started.md
Have succeeded with package setup. Here what you need to do if you use L5.1
Piece of code that resolves PayumBuilder should go from bootstrap/start.php to some ServiceProvider, for example PayumServiceProvider:
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Payum\LaravelPackage\Storage\EloquentStorage;
use Payum\LaravelPackage\Model\Token;
//use Payum\LaravelPackage\Model\Payment;
use \App\Payment;
class PayumServiceProvider extends ServiceProvider {
public function register()
{
\App::resolving('payum.builder', function(\Payum\Core\PayumBuilder $payumBuilder) {
$payumBuilder
->setTokenStorage(new EloquentStorage(Token::class))
->addStorage(Payment::class, new EloquentStorage(Payment::class))
->addGateway('paypal_ec', [
'factory' => 'paypal_express_checkout',
'username' => config('payum.username'),
'password' => config('payum.password'),
'signature' => config('payum.signature'),
'sandbox' => config('payum.sandbox')
])
;
});
}
}
Here you can use Payment model from the package and API call should be successfull but it will give an error if using Payment done controller code from example: https://github.com/Payum/PayumLaravelPackage/blob/master/docs/payment_done_controller.md. Because it doesn't implement Iterator interface and iterator_to_array will crash. So we need to extend base model, implement IteratorAggregate and add method from the Interface:
namespace App;
use Illuminate\Database\Eloquent\Model;
use IteratorAggregate;
use ArrayIterator;
class Payment extends \Payum\LaravelPackage\Model\Payment implements IteratorAggregate
{
public function getIterator()
{
return new ArrayIterator($this->getDetails());
}
}
Good luck!
@ribagek Thank you for sharing. I'll adjust the docs with what you write here, do you want to do it maybe?
Though I am not sure about the second part. The done action is the action where you put your own logic, iterator_to_array is used just to show you that you have access to all payment details. Feel free to remove it completely and put there whatever you need. Do not implement IteratorAggregate interface until you need it in your business logic
totaly agree about 2nd. Thanks, I will add this to docs
using "payum/paypal-express-checkout-nvp":"0.15.*" laravel version 5.1
got this error.
ReflectionException in Container.php line 737: Class payum does not exist