Help for integrating the Laravel package
Forum rules: Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
#3813 by mvnaz
09 Jan 2017, 18:26
Hello every body. Thank you all for help! It is me again. I continue develop my shop on laravel aimeos. And now I have two problems. I read documentation https://aimeos.org/docs/User_Manual/Adm ... ist#Manual and looked forum. But I did not found full information.

My questions:

1. I need add custom payment method for bank in my country, I need use API of this bank also. And I need to delete unneccessary payment methods for me. How I can do it ?

2. Also I need to add my custom shipping methods which exists in my country. Also I need to delete unnecessary shipping methods for me.

I use php 7, aimeos-laravel last version and windows 7 os.

I hope for you help. Best regards.
#3819 by mvnaz
10 Jan 2017, 18:54
Hello, excuse me please. It is my first skill with MVC frameworks and laravel/aimeos. Some is difficult for me now. In this link https://aimeos.org/docs/Developers/Libr ... y_provider says about delivery provider implement and basic skeleton for this. But it is not says where I have insert this code ? I have insert this code into existing file or create new file ? I see that for all codes which are in the link, it is absent discription where this code must be inserted. May be it is not problem for experienced developers, but it is hard for me.

So may be already exist simple example how to implement new payment and delivery method. It would be nice if someone can help me a little bit, that I could start. I would not ask a lot of questions and then acted independently. I also think that this information will help many other people who have the same problem. Thank you very much for your help!
#3820 by aimeos
11 Jan 2017, 10:52
Here you can find existing implementations:
- https://github.com/aimeos/aimeos-core/tree/master/lib/mshoplib/src/MShop/Service/Provider/Delivery
- https://github.com/aimeos/aimeos-core/tree/master/lib/mshoplib/src/MShop/Service/Provider/Payment

The preferred way to create new payment integrations is to install the ai-payments extension and write an Omnipay driver: http://omnipay.thephpleague.com/
#3822 by mvnaz
11 Jan 2017, 15:05
In expert admin panel I added new service. Type =payment, code=cod, provider=cod, label=mytext,position=0.
In aimeos-core/lib/mshoplib/src/MShop/Service/Provider/Payment/ I created file cod.php
The content of this file is:

<?php

namespace \Aimeos\MShop\Service\Provider\Payment;

class cod
extends \Aimeos\MShop\Service\Provider\Payment\Base
implements \Aimeos\MShop\Service\Provider\Payment\Iface
{
/**
* Tries to get an authorization or captures the money immediately for the given
* order if capturing isn't supported or not configured by the shop owner.
*
* @param \Aimeos\MShop\Order\Item\Iface $order Order invoice object
* @param array $params Request parameter if available
* @return \Aimeos\MShop\Common\Item\Helper\Form\Standard Form object with URL, action
* and parameters to redirect to (e.g. to an external server of the payment
* provider or to a local success page)
*/
public function process( \Aimeos\MShop\Order\Item\Iface $order, array $params = array() )
{
// perform your actions
return parent::process( $order, $params );
}
}


But I see error:

TokenMismatchException in D:\OpenServer\domains\shop\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\VerifyCsrfToken.php line 68:

in VerifyCsrfToken.php line 68
at VerifyCsrfToken->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 64
at StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
at Pipeline->then(object(Closure)) in Router.php line 655
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 629
at Router->dispatchToRoute(object(Request)) in Router.php line 607
at Router->dispatch(object(Request)) in Kernel.php line 268
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 46
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
at Pipeline->then(object(Closure)) in Kernel.php line 150
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 117
at Kernel->handle(object(Request)) in index.php line 53

And it is another error:

FatalThrowableError in cod.php line 3:
Undefined constant 'Aimeos\MShop\Service\Provider\Payment'

in cod.php line 3
at include() in ClassLoader.php line 440
at Composer\Autoload\includeFile('D:\OpenServer\domains\shop\vendor\composer/../aimeos/aimeos-core/lib/mshoplib/src/MShop\Service\Provider\Payment\cod.php') in ClassLoader.php line 322
at ClassLoader->loadClass('Aimeos\MShop\Service\Provider\Payment\cod')
at spl_autoload_call('Aimeos\MShop\Service\Provider\Payment\cod')
at class_exists('\Aimeos\MShop\Service\Provider\Payment\cod') in Standard.php line 658
at Standard->getProvider(object(Standard))
at call_user_func_array(array(object(Standard), 'getProvider'), array(object(Standard))) in Base.php line 51
at Base->__call('getProvider', array(object(Standard))) in Standard.php line 63
at Standard->getServices('payment', object(Standard)) in Standard.php line 349
at Standard->setViewParams(object(Standard), array(), null) in Standard.php line 85
at Standard->getBody('', array(), null) in Standard.php line 148
at Standard->getBody() in Page.php line 93
at Page->getSections('checkout-index') in CheckoutController.php line 44
at CheckoutController->indexAction()
at call_user_func_array(array(object(CheckoutController), 'indexAction'), array()) in Controller.php line 55
at Controller->callAction('indexAction', array()) in ControllerDispatcher.php line 44
at ControllerDispatcher->dispatch(object(Route), object(CheckoutController), 'indexAction') in Route.php line 189
at Route->runController() in Route.php line 144
at Route->run(object(Request)) in Router.php line 653
at Router->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in SubstituteBindings.php line 41
at SubstituteBindings->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in VerifyCsrfToken.php line 65
at VerifyCsrfToken->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 64
at StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
at Pipeline->then(object(Closure)) in Router.php line 655
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 629
at Router->dispatchToRoute(object(Request)) in Router.php line 607
at Router->dispatch(object(Request)) in Kernel.php line 268
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 46
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
at Pipeline->then(object(Closure)) in Kernel.php line 150
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 117
at Kernel->handle(object(Request)) in index.php line 53