Skip to content

marcoss2009/dx-php

 
 

Repository files navigation

Mercado Pago SDK for PHP

Build Status

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

PHP Versions Supported:

The SDK supports PHP 5.6, 7.1 or major

Installation

Using Composer

  1. Download Composer if not already installed

  2. Go to your project directory and run on the command line composer require "mercadopago/dx-php:2.0.0" for PHP7 or composer require "mercadopago/dx-php:1.8.1" for PHP5.6. See the latest version (here)[https://github.com/mercadopago/dx-php/releases].

  3. This how your directory structure would look like.

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

installation-demo

Quick Start

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

    MercadoPago\SDK::setAccessToken("YOUR_ACCESS_TOKEN");      // On Production
    MercadoPago\SDK::setAccessToken("YOUR_TEST_ACCESS_TOKEN"); // On Sandbox
  2. 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 __DIR__  . '/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"
    );
 
    echo $payment->status;
    
  ?>

Support

Write us at developers.mercadopago.com

About

Mercado Pago's Official PHP SDK

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Languages

  • PHP 100.0%