jeudi 23 juin 2016

Conekta integration breaking with Session Middleware in Laravel 5.1

I am trying to integrate the Conekta API (conekta.io) in my Laravel 5.1 project. The integration and the instances go quite good, but somehow, when posting the form, I receive an error saying:

Argument 1 passed to Illuminate\Session\Middleware\StartSession::addCookieToResponse() must be an instance of Symfony\Component\HttpFoundation\Response, instance of Illuminate\View\View given, called in /Library/WebServer/Documents/mi-plan/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php on line 72 and defined

Somehow, the StartSession middleware is getting a view instead of the actual response of the petition.

Here is the code that receives the request

public function processPayment()
    {

        //dd($request);
        Conekta::setApiKey("key_wbtMPeCmTpPRchKtTGM3Yg");
        try {
            $charge = Conekta_Charge::create(array(
                'description'=> 'Stogies',
                'reference_id'=> '9839-wolf_pack',
                'amount'=> 20000,
                'currency'=>'MXN',
                'card'=> 'tok_test_visa_4242',
                'details'=> array(
                    'name'=> 'Arnulfo Quimare',
                    'phone'=> '403-342-0642',
                    'email'=> 'logan@x-men.org',
                    'customer'=> array(
                        'corporation_name'=> 'Conekta Inc.',
                        'logged_in'=> true,
                        'successful_purchases'=> 14,
                        'created_at'=> 1379784950,
                        'updated_at'=> 1379784950,
                        'offline_payments'=> 4,
                        'score'=> 9
                    ),
                    'line_items'=> array(
                        array(
                            'name'=> 'Box of Cohiba S1s',
                            'description'=> 'Imported From Mex.',
                            'unit_price'=> 20000,
                            'quantity'=> 1,
                            'sku'=> 'cohb_s1',
                            'type'=> 'food'
                        )
                    ),
                    'billing_address'=> array(
                        'street1'=>'77 Mystery Lane',
                        'street2'=> 'Suite 124',
                        'street3'=> null,
                        'city'=> 'Darlington',
                        'state'=>'NJ',
                        'zip'=> '10192',
                        'country'=> 'Mexico',
                        'phone'=> '77-777-7777',
                        'email'=> 'purshasing@x-men.org'
                    )
                )
            ));

        } catch (\Conekta_Error $e)
        {
            echo $e->getMessage(); die();
        }

        //echo $charge->status;
    }

Here are my routes:

Route::resource("/buy/subscription/",'SubscriptionController@buySubscription');
        Route::post("/buy/subscription/payment/",'SubscriptionController@processPayment');

Hopefully somebody knows whats going on and can help.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/28TD9V2
via IFTTT

Aucun commentaire:

Enregistrer un commentaire