Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.6 kB
1
Indexable
Never
        /*elseif($data['payment_method'] == 'mercadopago')
        {
            $preference = new Preference();

            $item = new Item();
            $item->id = Auth::user()->id;
            $item->title =  'Acceso a charlas SEODAY 2023: '. $this->code;
            $item->description = 'Acceso a las charlas del SEODAY 2023.';
            $item->quantity = 1;

            //$item->currency_id = 'USD';
            //$item->unit_price = $price;

            $item->currency_id = 'ARS';
            $item->unit_price = 5;

            $payer = new Payer();
            $payer->email = Auth::user()->email;

            $preference->items = [$item]; 
            $preference->payer = $payer;

            $preference->external_reference = $this->code;

            $preference->back_urls = [
                "success" => url('/seoday?payment=success'),
                "pending" => url('/seoday?payment=pending'),
                "failure" => url('/seoday?payment=failure'),
            ];

            $preference->auto_return = "all";
            $preference->notification_url = url('/ipn');

            $preference->save();

            $user_payment          = new UserPayment;
            $user_payment->user_id = Auth::user()->id;
            $user_payment->code    = $this->code;
            $user_payment->paid    = $price;
            $user_payment->method  = $data['payment_method'];
            $user_payment->save();

            if (config('mercadopago.sandbox')) {
                return redirect($preference->sandbox_init_point);
            }

            return redirect($preference->init_point);
        }*/