diego-mascarenhas/laravel-mercadopago-sdk
Composer 安装命令:
composer require diego-mascarenhas/laravel-mercadopago-sdk
包简介
Mercado Pago SDK v0.6.3 for Laravel
README 文档
README
Installation
composer require diego-mascarenhas/laravel-mercadopago-sdk
Within config/app.php, add the following Provider and Alias
Provider
'providers' => [ // Others Providers... DiegoMascarenhas\LaravelMercadoPago\Providers\MercadoPagoServiceProvider::class, /* * Application Service Providers... */ ],
Alias
'aliases' => [ // Others Aliases 'MP' => DiegoMascarenhas\LaravelMercadoPago\Facades\MP::class, ],
Configuration
Before configuring the APP ID and APP SECRET, run the following command:
php artisan vendor:publish
After executing the command, go to the .env file and add the MP_APP_ID and MP_APP_SECRET fields with the corresponding values of the CLIENT_ID and CLIENT_SECRET from your MercadoPago application.
To find out your CLIENT_ID and CLIENT_SECRET information, you can go here:
If you do not want to use the .env file, go to config/mercadopago.php and add your corresponding application details.
return [ 'app_id' => env('MP_APP_ID', 'YOUR CLIENT ID'), 'app_secret' => env('MP_APP_SECRET', 'YOUR CLIENT SECRET'), 'app_ssl' => env('MP_APP_SSL', true), 'app_sandbox' => env('MP_APP_DEBUG', false) ];
Usage
In this example, we will create a payment preference using the MP Facade.
<?php 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' => 101, 'category_id' => 'electronics', 'title' => 'iPhone 14 Pro Max', 'description' => 'iPhone 14 Pro Max 128GB - Black', 'picture_url' => 'https://example.com/images/products/iphone-14-pro-max-black.png', 'quantity' => 1, 'currency_id' => 'ARS', 'unit_price' => 150000 ] ], 'payer' => [ 'email' => 'customer@example.com' ], 'payment_methods' => [ 'excluded_payment_types' => [ ['id' => 'atm'] ], 'installments' => 12 ], 'back_urls' => [ 'success' => 'https://yourdomain.com/success', 'failure' => 'https://yourdomain.com/failure', 'pending' => 'https://yourdomain.com/pending' ], 'auto_return' => 'approved', 'notification_url' => 'https://yourdomain.com/notifications' ]; $preference = MP::create_preference($preferenceData); return dd($preference); }
In this example, we will create a subscription (automatic debit) using the MP Facade.
<?php 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' => 'customer@example.com', 'back_url' => 'https://example.com/preapproval', 'reason' => 'Premium Suscription', '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); }
In the example, the use of the Carbon library can be seen to specify the start and end dates of the subscription, with a monthly frequency.
To the current date, an hour is added via Carbon, as otherwise MercadoPago might consider the date as past.
Troubleshooting
SSL Certificate Problem: Unable to Get Local Issuer Certificate
If you encounter an error stating SSL certificate problem: unable to get local issuer certificate, this typically occurs when the root certificates on your system are out of date or missing.
To resolve this issue, download the Latest CA Certificates Bundle from CA Extract.
diego-mascarenhas/laravel-mercadopago-sdk 适用场景与选型建议
diego-mascarenhas/laravel-mercadopago-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 12 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 03 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「ecommerce」 「sdk」 「laravel」 「mercadopago」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 diego-mascarenhas/laravel-mercadopago-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 diego-mascarenhas/laravel-mercadopago-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 diego-mascarenhas/laravel-mercadopago-sdk 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Nevogate Payment Gateway SDK
Dealing with payments through the Egyptian payment gateway PayMob
A PHP (and Laravel) package to interface with the Snipcart api.
Alfabank REST API integration
Customer notes for Contao Isotope eCommerce checkout.
Zero-dependency raw PHP DNS resolver, domain-ownership verification, and intoDNS/MxToolbox-style diagnostics. Queries authoritative nameservers directly over sockets — never trusts the recursive cache for ownership checks.
统计信息
- 总下载量: 12
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 13
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-03-18