PHP code example of diegonella / laravel-mp-etiquetas

1. Go to this page and download the library: Download diegonella/laravel-mp-etiquetas library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

diegonella / laravel-mp-etiquetas example snippets


'providers' => [
  // Otros Providers...
  SantiGraviano\LaravelMercadoPago\Providers\MercadoPagoServiceProvider::class,
  /*
   * Application Service Providers...
   */
],

'aliases' => [
  // Otros Aliases
  'MP' => SantiGraviano\LaravelMercadoPago\Facades\MP::class,
],

return [
	'app_id'     => env('MP_APP_ID', 'TU CLIENT ID AQUI'),
	'app_secret' => env('MP_APP_SECRET', 'TU CLIENT SECRET AQUI')
];



namespace App\Http\Controllers;

use Illuminate\Http\Request;

use MP;
use App\Http\Requests;
use App\Http\Controllers\Controller;

class MercadoPagoController extends Controller
{
  public function getCreatePreference()
  {
  	$preferenceData = [
  		'items' => [
  			[
  				'id' => 12,
  				'category_id' => 'phones',
  				'title' => 'iPhone 6',
  				'description' => 'iPhone 6 de 64gb nuevo',
  				'picture_url' => 'http://d243u7pon29hni.cloudfront.net/images/products/iphone-6-dorado-128-gb-red-4g-8-mpx-1256254%20(1)_m.png',
  				'quantity' => 1,
  				'currency_id' => 'ARS',
  				'unit_price' => 14999
  			]
  		],
  	];

  	$preference = MP::create_preference($preferenceData);

  	return dd($preference);

  }



namespace App\Http\Controllers;

use Illuminate\Http\Request;

use MP;
use App\Http\Requests;
use App\Http\Controllers\Controller;

class MercadoPagoController extends Controller
{
  public function getCreatePreapproval()
  {
    $preapproval_data = [
      'payer_email' => '[email protected]',
      'back_url' => 'http://labhor.com.ar/laravel/public/preapproval',
      'reason' => 'Subscripción a paquete premium',
      'external_reference' => $subscription->id,
      'auto_recurring' => [
        'frequency' => 1,
        'frequency_type' => 'months',
        'transaction_amount' => 99,
        'currency_id' => 'ARS',
        'start_date' => Carbon::now()->addHour()->format('Y-m-d\TH:i:s.BP'),
        'end_date' => Carbon::now()->addMonth()->format('Y-m-d\TH:i:s.BP'),
      ],
    ];

    MP::create_preapproval_payment($preapproval_data);

    return dd($preapproval);
  }