leonardcodep/mercadopago-sdk-php 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

leonardcodep/mercadopago-sdk-php

最新稳定版本:2.4.8

Composer 安装命令:

composer require leonardcodep/mercadopago-sdk-php

包简介

Cliente Mercado de Pago API para PHP

README 文档

README

Latest Stable Version Total Downloads License

This library provides developers with a simple set of bindings to help you integrate Mercado Pago API to a website and start receiving payments.

💡 Requirements

PHP 7.1, 8.0 y 8.1 or higher

💻 Installation

First time using Mercado Pago? Create your Mercado Pago account, if you don’t have one already.

  1. Download Composer if not already installed

  2. On your project directory run on the command line composer require leonardcodep/mercadopago-sdk-php

  3. Copy the access_token in the credentials section of the page and replace YOUR_ACCESS_TOKEN with it.

That's it! Mercado Pago SDK has been successfully installed.

🌟 Getting Started

Simple usage looks like:

  <?php
    require_once 'vendor/autoload.php'; // You have to require the library from your Composer vendor folder

    use MercadoPago\SDK;
    use MercadoPago\Entity\Shared\Payment;
    use MercadoPago\Entity\Shared\Payer;
    try {
        SDK::setAccessToken("YOUR_ACCESS_TOKEN"); // Either Production or SandBox AccessToken
        $payment = new Payment();
        $payment->transaction_amount = 259;
        $payment->token = $request->token;
        $payment->description = "Compra de productos";
        $payment->installments = (int) $request->installments;
        $payment->payment_method_id = $request->payment_method_id;
        $payment->issuer_id = (int) $request->issuer_id;

        $payer = new Payer();
        $payerForm = $request->payer;
        $payer->email = $payerForm['email'];
        $payer->identification = array(
            "type" => $payerForm['identification']['type'],
            "number" => $payerForm['identification']['number']
        );
        $payment->payer = $payer;
        $payment->save();

        if($payment->id === null) {
            $error_message = 'Unknown error cause';
            if(isset($payment->error)) {
                $error_message = $payment->error->message;
            }
            throw new Exception($error_message);
        }

        $response = array(
            "request" => $request,
            "payment_id" => $payment->id,
            "status" => $payment->status,
            "status_detail" => $payment->status_detail,
        );
    } catch (Exception $e) {
        throw new Exception(trim(trim($e->getMessage()), '"'));
    }
  ?>

📚 Documentation

Visit our Dev Site for further information regarding:

Check our official code reference to explore all available functionalities.

❤️ Support

If you require technical support, please contact our support team at developers.mercadopago.com

统计信息

  • 总下载量: 2.59k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-01-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固