melhorenvio/mercadopago-dx-php-laravel

This package is abandoned and no longer maintained. No replacement package was suggested.

1.2.6 2019-03-08 17:07 UTC

README

Latest Stable Version Total Downloads License

No more doctrine/common and doctrine/annotations issues when using Laravel Framework.

Why made a fork?

Refer this issues/pull requests:

https://github.com/mercadopago/dx-php/issues/78

https://github.com/mercadopago/dx-php/issues/106

mercadopago#136

Disclaimers

The current release of the application is in active development by the official mainteners (MercadoPago). Expect delayed updates here.

This is not an official MercadoPago package. We only fixed some compatibility issues that the official maintener ignore. This package is not formally supported and the code is available as-is with no guarantees.

Mercado Pago SDK for PHP

This library provides developers with a simple set of bindings to the Mercado Pago API.

PHP Versions Supported:

The SDK supports PHP 5.6 or major

Installation

Using Composer

  1. Download Composer if not already installed
  2. Go to your project directory and run composer require melhorenvio/mercadopago-dx-php-laravel on the command line.
  3. This how your directory structure would look like.

screen shot 2017-12-27 at 7 07 47 pm

  1. Thats all, you have Mercado Pago SDK installed.

Quick Start

  1. You have to require the library from your Composer vendor folder.
require __DIR__  . '/vendor/autoload.php';
  1. Setup your credentials or major 10 ​ 11

You have two types of credentials:

  • For API or custom checkout:
    MercadoPago\SDK::setAccessToken("YOUR_ACCESS_TOKEN");      // On Production
    MercadoPago\SDK::setAccessToken("YOUR_TEST_ACCESS_TOKEN"); // On Sandbox
  • For Web-checkout:
    MercadoPago\SDK::setClientId("YOUR_CLIENT_ID");
    MercadoPago\SDK::setClientSecret("YOUR_CLIENT_SECRET");
  1. Using resource objects.

You can interact with all the resources available in the public API, to this each resource is represented by classes according to the following diagram:

sdk resource structure

Sample

  <?php
  
    require_once 'vendor/autoload.php';

    MercadoPago\SDK::setAccessToken("YOUR_ACCESS_TOKEN");

    $payment = new MercadoPago\Payment();

    $payment->transaction_amount = 141;
    $payment->token = "YOUR_CARD_TOKEN";
    $payment->description = "Ergonomic Silk Shirt";
    $payment->installments = 1;
    $payment->payment_method_id = "visa";
    $payment->payer = array(
      "email" => "larue.nienow@hotmail.com"
    );

    $payment->save();

    echo $payment->status;

  ?>

Support

Write us at developers.mercadopago.com