darkghosthunter/transbanker

This package is abandoned and no longer maintained. No replacement package was suggested.

Transbank API connector for Laravel

v3.1.0 2021-03-19 17:20 UTC

This package is auto-updated.

Last update: 2021-05-05 04:44:16 UTC


README

This package has been deprecated for a new version, which uses a REST and HTTP Client.

Sharon McCutcheon - Unsplash (UL) #-8a5eJ1-mmQ

Latest Stable Version License Build Status Coverage Status Maintainability Test Coverage

Laravel Transbanker

Transbank API connector for Laravel

This package connects the Transbank API package, which allows you to use Transbank payment gateway, to your Laravel Application.

Requirements

  • PHP >= 7.3
  • Laravel 6.x, 7.x or 8.x

Check older releases for older Laravel versions.

Installation

Call composer and require it into your application.

composer require darkghosthunter/transbanker

Configuration

Environment

By default, the package uses integration unless you explicitly set production, which will make all transactions real.

TRANSBANK_ENV=production

Credentials

The integration environment sets testing credentials automatically, so you don't need to set them unless you want to overwrite one of them.

Otherwise, in production environment, you will need to add your Transbank credentials for your services.

For Webpay, these must be located under storage/transbank/webpay as files. You can overload the default webpay.cert that comes with this package with your own.

WEBPAY_COMMERCE_CODE=5000000001
WEBPAY_PRIVATE_KEY=private.key
WEBPAY_PUBLIC_CERT=public.cert
WEBPAY_CERT=webpay.cert

For Onepay, you can use the API key and Secret directly.

ONEPAY_API_KEY=dKVhq1WGt_XapIYirTXNyUKoWTDFfxaEV63-O5jcsdw
ONEPAY_SECRET="?XW#WOLG##FBAGEAYSNQ5APD#JF@$AYZ"

If your secret has # characters, you may want to enclose it using double quotes ".

That is the basic configuration. If you need to fine tune this package, refer to the Advanced section.

Redirection

This package registers the transbank::webpay-redirect for instant redirection to Webpay. When creating a Webpay Plus or Webpay Oneclick transaction, you can redirect the user instantly to the payment gateway inside your controllers:

<?

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use DarkGhostHunter\Transbanker\Facades\Webpay;

class PaymentController extends Controller {
    
    /**
     * Creates a Payment
     * 
     * @param Request $request
     * @return \Illuminate\View\View
     */
    public function pay(Request $request)
    {
        // .. Validate Request, amount, etc..
        
        $response = Webpay::createNormal([
            'sessionId' => $request->session()->getId(),
            'buyOrder'  => 'myOrder#16548',
            'amount'    => 1000,
        ]);
        
        return view('transbanker::webpay-redirect', [
            'response' => $response            
        ]);
    }
    
}

Usage

For usage, check the TransbankApi (Spanish, English by Google Translate).

Advanced

To fine tune Transbanker, just publish the config file:

php artisan vendor:publish --provider="DarkGhostHunter\Transbanker\TransbankerServiceProvider"

This will publish the transbank.php file in the config directory.

Routes

This package with some default routes for your application (as configured inside config/transbank.php):

Service URL Value
Webpay Plus Return URL http://yourappurl.com/webpay/result
Webpay Plus Final URL http://yourappurl.com/webpay/receipt
Webpay Plus Mall Return URL http://yourappurl.com/webpay/mall/result
Webpay Plus Mall Final URL http://yourappurl.com/webpay/mall/receipt
Webpay Oneclick Response URL http://yourappurl.com/webpay/registration
Onepay Callback URL http://yourappurl.com/onepay/result

You're free to change these URLs.

In any case, be sure to add your logic in these routes to receive Transbank http POST Requests, and remove the csrf middleware since Webpay will need to hit these routes so the payment can be processed.

License

This package is open-sourced software licensed under the MIT license.

Redcompra, Webpay, Onepay, Patpass and tbk are trademarks of Transbank S.A.

This package is not developed, approved, supported nor endorsed by Transbank S.A., nor by a natural person or company linked directly or indirectly by Transbank S.A.