Download the PHP package crizprz/laravelmercadopago without Composer
On this page you can find all versions of the php package crizprz/laravelmercadopago. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download crizprz/laravelmercadopago
More information about crizprz/laravelmercadopago
Files in crizprz/laravelmercadopago
Package laravelmercadopago
Short Description This package integrates Mercado Pago's Checkout Pro easily
License MIT
Informations about the package laravelmercadopago
Checkout PRO for Laravel by CRIZPRZ
This package integrates Mercado Pago's Checkout Pro very easily
REQUIREMENTS
Composer v.2 is recommended
guzzlehttp/guzzle
INSTALLATION
Install the package through Composer.
Or add the following to your composer.json
file :
CONFIGURATION
-
Open
config/app.php
and add this line to your Service Providers Array. -
Open
config/app.php
and add this line to your aliases Array. - publish the assets.
HOW TO USE
Create User Test
- To create users we must log in to Mercado Pago developers with a real account
- Go to the top right section, click and select your integrations
- once in your integrations click on test credentials, copy the Access Token and put it in the
.env
file in the variable calledACCESS_TOKEN_MP =
- paste this code somewhere in your code either in a route or a running controller, this code will print two test users, the seller and the buyer
This will return an array with the two types of users, we must save these users very well since the paid market only allows creating 10 test users per account.
Note: Run only once.
example of what the previous code returns
create payment preference with test user
- login with the test user in Mercado Pago developers
- Go to the top right section, click and select your integrations
- create new integration fill in the form and click on create application, click on production keys, copy the Access Token and put it in the
.env
file in the variable calledACCESS_TOKEN_MP =
Create Preference
1.paste the following code somewhere in your project where you want to implement the payment button
- visit the api reference, Create a preference to know what each of the properties of the array means
- change the array values to those of your project
create payment button
-
return the variable to some blade view, this variable has saved all the payment prefence For Example
- in the view render the default button of the package
or create a custom payment button and pass it the init_point, which is stored in the $ preference variable For Example
Test your integration
- read the Test your integration documentation to get the test cards it provides
Payment status responses
payment success
The code that is executed when returning to your website from a successful payment is in the App\Http\Controllers\MercadoPagoController
controller in the success method
the payment returns a get request to your server so we will use the Request $request where all the payment data comes, what we are interested in is the payiment_id
sample answer
We are going to do a get request with guzzle / huzzlehttp to find the payment that was made and thus obtain the details, such as amount, type of currency, buyer data etc ...
In the $ response variable we have all the data of the payment made successfully, with this information we can send emails, push notifications, show session messages in laravel, etc.