leonardcodep/mercadopago-sdk-php
最新稳定版本:2.4.8
Composer 安装命令:
composer require leonardcodep/mercadopago-sdk-php
包简介
Cliente Mercado de Pago API para PHP
README 文档
README
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.
-
Download Composer if not already installed
-
On your project directory run on the command line
composer require leonardcodep/mercadopago-sdk-php -
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:
- Payments APIs: Spanish / Portuguese
- Mercado Pago checkout: Spanish / Portuguese
- Web Tokenize checkout: Spanish / Portuguese
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.44k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-01-14