Giter VIP home page Giter VIP logo

Comments (12)

makasim avatar makasim commented on May 26, 2024

I've never got it, so not able to fix it, Could you investigate it further and fix,

BTW why not use 1.0?

from payumlaravelpackage.

ribagek avatar ribagek commented on May 26, 2024

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());
}
}

from payumlaravelpackage.

makasim avatar makasim commented on May 26, 2024

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?

from payumlaravelpackage.

ribagek avatar ribagek commented on May 26, 2024

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

from payumlaravelpackage.

makasim avatar makasim commented on May 26, 2024

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))
    ;
});

from payumlaravelpackage.

ribagek avatar ribagek commented on May 26, 2024

ok, but bootstrap/start.php is for Laravel 4. Where to put this config in L5.1?

from payumlaravelpackage.

makasim avatar makasim commented on May 26, 2024

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

from payumlaravelpackage.

makasim avatar makasim commented on May 26, 2024

This what you have to do to fix the reflection bug: https://github.com/makasim/PayumLaravelBundleSandbox/blob/payum-examples2/app/config/app.php#L124

from payumlaravelpackage.

makasim avatar makasim commented on May 26, 2024

The doc is updated: https://github.com/Payum/PayumLaravelPackage/blob/master/docs/get-it-started.md

from payumlaravelpackage.

ribagek avatar ribagek commented on May 26, 2024

Have succeeded with package setup. Here what you need to do if you use L5.1

  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')
                ])
            ;
        });
    }
    
    }
    
  2. 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!

from payumlaravelpackage.

makasim avatar makasim commented on May 26, 2024

@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

from payumlaravelpackage.

ribagek avatar ribagek commented on May 26, 2024

totaly agree about 2nd. Thanks, I will add this to docs

from payumlaravelpackage.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.