PHPackages                             pw/laramidtrans - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. pw/laramidtrans

ActivePackage[Payment Processing](/categories/payments)

pw/laramidtrans
===============

A Midtrans Payment Wrapper for Laravel

011PHP

Since Dec 27Pushed 7y ago1 watchersCompare

[ Source](https://github.com/PurwadiPw/laramidtrans)[ Packagist](https://packagist.org/packages/pw/laramidtrans)[ RSS](/packages/pw-laramidtrans/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Midtrans/Veritrans Library
==================================

[](#laravel-midtransveritrans-library)

Installation
------------

[](#installation)

First, require the package in composer.json by

```
composer require pw/laramidtrans

```

After require the package, open `config/app.php` to add the ServiceProvider and Facade by following below:

```
Pw\Midtrans\MidtransServiceProvider::class,

```

For the convenience when using the package, you can optionally add the Facade too by

```
'Midtrans' => Pw\Midtrans\Facades\Midtrans::class,
'Veritrans' => Pw\Midtrans\Facades\Veritrans::class,

```

There are two facades because the endpoint of the services from Midtrans is different (Veritrans is the old one) and they already change their names to Midtrans. So, choose your partnership with Midtrans to choose the right Facade for you.

Configuration
-------------

[](#configuration)

Before using the package, it's better to publish the config file first to make you can set the `environment`, `server_key` and `client_key`

```
php artisan vendor:publish --provider="Pw\Midtrans\MidtransServiceProvider"

```

Running command above will copy a config file to your project directory `config/midtrans.php` and you can set the variable. To set the variables, it's better to put in the .env file rather than change it directly on the config file, so in your .env file put

```
`MIDTRANS_IS_PRODUCTION`, `MIDTRANS_CLIENT_KEY` and `MIDTRANS_SERVER_KEY`

```

based on your key that's on your midtrans dashboard.

Using
-----

[](#using)

You can create package instance easily by

```
App::make('Midtrans');

```

This depends on what type of payment you will use for your payment method.

If you want to use the easiest way by using the facade but make sure to use the facade on top of your file.

### Sample for Midtrans Facade

[](#sample-for-midtrans-facade)

```
