<?php
namespace App\Services\Midtrans;

use Midtrans\Snap;

class CreateSnapTokenService extends Midtrans
{
    protected $request;

    public function __construct($request)
    {
        parent::__construct();

        $this->request = $request;
    }

    /*
    public function getSnapToken()
    {
        $params = [
            'transaction_details' => [
                //'order_id' => $this->order->number,
                //'gross_amount' => $this->order->total_price,
                'order_id' => rand(),
                'gross_amount' => 50000,
            ],
            'item_details' => [
                [
                    'id' => 1,
                    'price' => '150000',
                    'quantity' => 1,
                    'name' => 'Flashdisk Toshiba 32GB',
                ],
                [
                    'id' => 2,
                    'price' => '60000',
                    'quantity' => 2,
                    'name' => 'Memory Card VGEN 4GB',
                ],
            ],
            'customer_details' => [
                'first_name' => 'Martin Mulyo Syahidin',
                'email' => 'mulyosyahidin95@gmail.com',
                'phone' => '081234567890',
            ]
        ];

        $snapToken = Snap::getSnapToken($params);

        return $snapToken;
    }*/
    public function getSnapToken()
    {
        $snapToken = Snap::getSnapToken($this->request);
        return $snapToken;

        }    
    }
?>