recca0120 / laravel-payum

Rich payment solutions for Laravel framework. Paypal, payex, authorize.net, be2bill, omnipay, recurring paymens, instant notifications and many more
MIT License
74 stars 26 forks source link

How to Implement this in laravel 5.2? #1

Closed midascodebreaker closed 8 years ago

midascodebreaker commented 8 years ago

Can you provide a Installation Instruction and How to Use it?

recca0120 commented 8 years ago

it still has some bug... few days later....

recca0120 commented 8 years ago

Hello @midascodebreaker

yout could try....

midascodebreaker commented 8 years ago

Yes I would try to test now... would post some comment later thanks

recca0120 commented 8 years ago

okay

midascodebreaker commented 8 years ago

I tried to

composer require recca0120/laravel-payum payum/offline payum/paypal-express-checkout-nvp

then did publish

php artisan vendor publish

then do migrate.

php artisan migrate

then create controller...

php artisan make:controller PaymentController
namespace App\Http\Controllers;

use Illuminate\Routing\Controller as BaseController;
use Recca0120\LaravelPayum\Http\Controllers\Behavior\DoneBehavior;
use Recca0120\LaravelPayum\Http\Controllers\Behavior\PrepareBehavior;

class PaymentController extends BaseController
{
    use PrepareBehavior,
        DoneBehavior;

    protected $gatewayName = 'offline';

    public function onPrepare($payment, $gatewayName, $storage, $payum)
    {
        $payment->setNumber(uniqid());
        $payment->setCurrencyCode('TWD');
        $payment->setTotalAmount(100);
        $payment->setDescription('A description');
        $payment->setClientId('anId');
        $payment->setClientEmail('foo@example.com');
        $payment->setDetails([]);

        return $payment;
    }

    public function onDone($status, $payment, $gateway, $token)
    {
        return response()->json([
            'status' => $status->getValue(),
            'client' => [
                'id'    => $payment->getClientId(),
                'email' => $payment->getClientEmail(),
            ],
            'number'        => $payment->getNumber(),
            'description'   => $payment->getCurrencyCode(),
            'total_amount'  => $payment->getTotalAmount(),
            'currency_code' => $payment->getCurrencyCode(),
            'details'       => $payment->getDetails(),
        ]);
    }
}

Also add router

Route::get('payment', [
    'as'   => 'payment',
    'uses' => 'PaymentController@prepare',
]);

Route::any('payment/done/{payumToken}', [
    'as'   => 'payment.done',
    'uses' => 'PaymentController@done',
]);

i Hit my site url

domain.app/payment

i got this ERROR

http://domain.app/payment/capture/mmaBUyQTJ2Kc6zrMx89PbG5wQTX3Ylt3Ymo6IClf_gs
InvalidArgumentException in AbstractRegistry.php line 92:
Gateway "offline" does not exist.

Hmm what would i do in my config/payum.php

im confuse what to do...

can you give me sample where i can hook in paypal express pro and offline payment gateway using eloquent?

i wanna save the configuration inside database...

recca0120 commented 8 years ago

offline is a payum package, so you need to install it

composer require payum/offline
recca0120 commented 8 years ago

try it

composer require payum/offline

payum.php

return [
    'router' => [
        'prefix'     => 'payment',
        'as'         => 'payment',
        // don't remove web
        'middleware' => 'web',
    ],

    'storage' => [
        // optioins: database, filesystem
        'token' => 'filesystem',

        // optioins: database, filesystem
        'gatewayConfig' => 'filesystem',
    ],

    // [
    //     'customFactoryName' => \GateFactoryClass::class,
    //     'customFactoryName2' => \GateFactoryClass2::class,
    // ]
    'gatewayFactories' => [
    ],

    // 'customFactoryName' => [
    //     'gatewayName' => 'customGatewayName',
    //     'config'      => [
    //         'sandbox' => false
    //     ],
    // ],
    'gatewayConfigs' => [
    ],
];
recca0120 commented 8 years ago

when it show correct, then you could try store data in eloquent

vendor publish

artisan vender:publish

migrate

artisan migrate
return [
    'router' => [
        'prefix'     => 'payment',
        'as'         => 'payment',
        // don't remove web
        'middleware' => 'web',
    ],

    'storage' => [
        // optioins: database, filesystem
        'token' => 'database',

        // optioins: database, filesystem
        'gatewayConfig' => 'filesystem',
    ],

    // [
    //     'customFactoryName' => \GateFactoryClass::class,
    //     'customFactoryName2' => \GateFactoryClass2::class,
    // ]
    'gatewayFactories' => [
    ],

    // 'customFactoryName' => [
    //     'gatewayName' => 'customGatewayName',
    //     'config'      => [
    //         'sandbox' => false
    //     ],
    // ],
    'gatewayConfigs' => [
    ],
];