8000 GitHub - snowangel3339/Transbank
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

snowangel3339/Transbank

 
 

Repository files navigation

Transbank

Latest Version on Packagist Total Downloads

This is where your description should go. Take a look at contributing.md to see a to do list.

Installation

Via Composer

$ composer require innovaweb/transbank

Usage

private $webpay_plus;

public function __construct()
{
    if (env('APP_ENV') == 'production') {

        $this->webpay_plus = new WebpayPlus(
            env('TBK_CC'),
            env('TBK_API_KEY'),
            WebpayPlus::PRODUCTION
        );

    } else {
        $this->webpay_plus = new WebpayPlus();
    }
}
createTransaction($buy_order, $session_id, $amount, $url_return);
commitTransaction($token_ws);
refundTransaction($token, $amount);
getTransactionStatus($token);

Example

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Innovaweb\Transbank\Helpers\HelperTransbankResponseCode;
use Innovaweb\Transbank\WebpayPlus;

class WebpayPlusController extends Controller
{
    private $webpay_plus;

    public function __construct()
    {
        if (env('APP_ENV') == 'production') {

            $this->webpay_plus = new WebpayPlus(
                env('TBK_CC'),
                env('TBK_API_KEY'),
                WebpayPlus::PRODUCTION
            );

        } else {
            $this->webpay_plus = new WebpayPlus();
        }
    }

    public function create(Request $request)
    {
        $response = $this->webpay_plus->createTransaction(
            $request->buy_order,
            'session' . $request->buy_order,
            $request->amount,
            route('response-wp-plus')
        );
        return $this->webpay_plus->redirectHTML();
    }

    public function response(Request $request)
    {
        if ($request->token_ws) {

            $commit = $this->webpay_plus->commitTransaction($request->token_ws);
            $response = $commit['response'];
            
            return [
                $response,
                'vci' => HelperTransbankResponseCode::VCI($response->vci),
                'responseCode' => HelperTransbankResponseCode::ResponseCode($response->responseCode),
                'paymentTypeCode' => HelperTransbankResponseCode::PaymentTypeCode($response->paymentTypeCode),
                'status' => HelperTransbankResponseCode::Status($response->status),
            ];
        } else {
            //transacción anulada
            return $request->all();
        }
    }
}

Change log

Please see the changelog for more information on what has changed recently.

Contributing

Please see contributing.md for details and a todolist.

Security

If you discover any security related issues, please email aisla@innovaweb.cl instead of using the issue tracker.

Credits

License

MIT. Please see the license file for more information.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%
0