Laravel Package that interacts with Bancard API vPOS 2.0

Overview

Laravel Bancard

Installation

Install via composer

composer require deviam/laravel-bancard

Publish config and migrations

php artisan vendor:publish --provider="Deviam\Bancard\BancardServiceProvider"

This is the contents of the file which will be published at config/bancard.php:

return [

    /*
    |--------------------------------------------------------------------------
    | Bancard Keys
    |--------------------------------------------------------------------------
    |
    | The Bancard public key and private key give you access to Bancard's
    | API.
    |
    */
    'public' => env('BANCARD_PUBLIC_KEY', ''),

    'private' => env('BANCARD_PRIVATE_KEY', ''),

    /*
    |--------------------------------------------------------------------------
    | Bancard Environment
    |--------------------------------------------------------------------------
    |
    | This value determines if your application is using the 
    | staging environment from Bancard's API.
    |
    */
    'staging' => (bool) env('BANCARD_STAGING', true),

    /*
    |--------------------------------------------------------------------------
    | Bancard URL
    |--------------------------------------------------------------------------
    */

    // The return URL for the Single Buy Operation
    'single_buy_return_url' => env('BANCARD_SINGLE_BUY_RETURN_URL', ''), 
    
    // The cancel URL for the Single Buy Operation
    'single_buy_cancel_url' => env('BANCARD_SINGLE_BUY_CANCEL_URL', ''), 
    
    // The return URL for the New Card Operation
    'new_card_return_url' => env('BANCARD_NEW_CARD_RETURN_URL', ''), 
];

Run migrations

php artisan migrate

Usage

The methods listed below return an instance of the class Illuminate\Http\Client\Response.

According to Laravel Documentation these are some of the methods you can use to inspect the response.

// Get the body of the response.
$response->body() : string;

// Get the JSON decoded body of the response as an array or scalar value.
$response->json() : array|mixed;

// Determine if the status code is >= 200 and < 300...
$response->successful();

// Determine if the status code is >= 400...
$response->failed();

Single Buy

Start the payment process.

use Deviam\Bancard\Bancard;

$response = Bancard::singleBuy('Ejemplo de pago', 10330.00);
if ($response->failed()) {
	// Do something here.
}
$data = $response->json();
$processId = $data['process_id'];
$scriptUrl = Bancard::scriptUrl();

return view('your_view_here', compact('processId', 'scriptUrl'));

Through the singleBuy method an eloquent model called SingleBuy is created. You can retrieve the record using the process_id value.

use Deviam\Bancard\Models\SingleBuy;

$order = SingleBuy::where('process_id', '')->first();

Cards New

Start the registration process of a card.

use Deviam\Bancard\Bancard;

$response = Bancard::newCard(966389, '09********', '[email protected]');
if ($response->failed()) {
	// Do something here.
}
$data = $response->json();
$processId = $data['process_id'];
$scriptUrl = Bancard::scriptUrl();

return view('your_view_here', compact('processId', 'scriptUrl'));

Through the newCard method an eloquent model called Card is created. You can retrieve all the cards from an user with the user_id value;

use Deviam\Bancard\Models\Card;

$cards = Card::where('user_id', '')->get();

Users Cards

Operation that allow you to list the cards registered from an user.

use Deviam\Bancard\Bancard;

$response = Bancard::listCards(966389);
if ($response->failed()) {
	// Do something here.
}
$data = $response->json();
$cards = $data['cards'];

Delete

Operation that allow you to delete a registered card.

use Deviam\Bancard\Bancard;

$response = Bancard::deleteCard(966389, 'c8996fb92427ae41e4649b934ca495991b7852b855');
if ($response->failed()) {
	// Do something here.
}
$data = $response->json();
$status = $data['status'];

Charge

Operation that allow you to make a payment with a token.

use Deviam\Bancard\Bancard;

$response = Bancard::tokenCharge('Ejemplo de pago', 10330.00, 'c8996fb92427ae41e4649b934ca495991b7852b855');
if ($response->failed()) {
	// Do something here.
}
$data = $response->json();
$confirmation = $data['confirmation'];

Through the tokenCharge method two eloquent models are created. These models are SingleBuy and Confirmation. You can retrieve each record with the shop_process_id value that comes in the response.

use Deviam\Bancard\Models\{SingleBuy, Confirmation};

$order = SingleBuy::where('shop_process_id', '')->first();
$confirmation = Confirmation::where('shop_process_id', '')->first();

Single Buy Rollback

Operation that allow you to cancel the payment.

use Deviam\Bancard\Bancard;

$response = Bancard::rollback('12313');
if ($response->failed()) {
	// Do something here.
}
$data = $response->json();
$status = $data['status'];

Through the rollback method an eloquent model called Rollback is created. You can retrieve the record using the shop_process_id value.

use Deviam\Bancard\Models\Rollback;

$record = Rollback::where('shop_process_id', '')->first();

Single Buy Get Confirmation

Operation that allow you to know if a payment was confirmed or not.

use Deviam\Bancard\Bancard;

$response = Bancard::confirmation('12313');
if ($response->failed()) {
	// Do something here.
}
$data = $response->json();
$confirmation = $data['confirmation'];

Through the confirmation method an eloquent model called Confirmation is created. You can retrieve the record using the shop_process_id value.

use Deviam\Bancard\Models\Confirmation;

$record = Confirmation::where('shop_process_id', '')->first();

Credits

License

The MIT License (MIT). Please see License File for more information.

You might also like...
A simple API documentation package for Laravel using OpenAPI and Stoplight Elements

Laravel Stoplight Elements Easily publish your API documentation using your OpenAPI document in your Laravel Application. Installation You can install

A simple package allowing for consistent API responses throughout your Laravel application
A simple package allowing for consistent API responses throughout your Laravel application

Laravel API Response Helpers A simple package allowing for consistent API responses throughout your Laravel application. Requirements PHP ^7.4 | ^8.0

Package to easily test crudable controllers for Laravel based API

Laravel Crudable Test This package is very usefull to easily test crudable controllers. Installation You can install package via composer. Add reposit

A Laravel package to simplify using DPO Payment API in your application.

DPO (Direct Pay Online) Laravel Package The best DPO Laravel package, simple Ever This is the package that will help you add DPO Payment API to your L

A laravel package to access data from the Strava API.

Laravel Strava Package A laravel package to access data from the Strava API. Compatible with Laravel 5.0 and above. Table of Contents Strava Access Cr

The fastest way to make a powerful JSON:API compatible Rest API with Laravel.
The fastest way to make a powerful JSON:API compatible Rest API with Laravel.

The first fully customizable Laravel JSON:API builder. "CRUD" and protect your resources with 0 (zero) extra line of code. Installation You can instal

GeoLocation-Package - This package helps you to know the current language of the user, the country from which he is browsing, the currency of his country, and also whether he is using it vpn
GeoLocation-Package - This package helps you to know the current language of the user, the country from which he is browsing, the currency of his country, and also whether he is using it vpn

GeoLocation in PHP (API) 😍 😍 😍 This package helps you to know a lot of information about the current user by his ip address 😍 😍 😍 This package h

A lightweight package for handling API error responses.

Laravel API Errors This package provides an easy way to manage and handle error response for JSON API's. Installation You can install the package via

An easy way to get vendor and package data from Packagist via API calls
An easy way to get vendor and package data from Packagist via API calls

Laravel Packagist Laravel Packagist (LaravelPackagist) is a package for Laravel 5 to interact with the packagist api quickly and easily. Table of cont

Comments
Owner
Miguel Chávez
La idea es colaborar.
Miguel Chávez
Laravel Package for TMDB ( The Movie Database ) API. Provides easy access to the wtfzdotnet/php-tmdb-api library.

Laravel Package for TMDB API Wrapper A Laravel package that provides easy access to the php-tmdb/api TMDB (The Movie Database) API wrapper. This packa

PHP - The Movie Database 151 Nov 1, 2022
Jetstrap is a lightweight laravel 8 package that focuses on the VIEW side of Jetstream / Breeze package installed in your Laravel application

A Laravel 8 package to easily switch TailwindCSS resources generated by Laravel Jetstream and Breeze to Bootstrap 4.

null 686 Dec 28, 2022
A Laravel chat package. You can use this package to create a chat/messaging Laravel application.

Chat Create a Chat application for your multiple Models Table of Contents Click to expand Introduction Installation Usage Adding the ability to partic

Tinashe Musonza 931 Dec 24, 2022
Laravel Responder - a package for building API responses, integrating Fractal into Laravel and Lumen

A Laravel Fractal package for building API responses, giving you the power of Fractal with Laravel's elegancy.

Alexander Tømmerås 776 Dec 25, 2022
A Laravel Wrapper for the CoinDCX API. Now easily connect and consume the CoinDCX Public API in your Laravel apps without any hassle.

This package provides a Laravel Wrapper for the CoinDCX API and allows you to easily communicate with it. Important Note This package is in early deve

Moinuddin S. Khaja 2 Feb 16, 2022
This package provides extended support for our spatie/enum package in Laravel.

Laravel support for spatie/enum This package provides extended support for our spatie/enum package in Laravel. Installation You can install the packag

Spatie 264 Dec 23, 2022
Testbench Component is the de-facto package that has been designed to help you write tests for your Laravel package

Laravel Testing Helper for Packages Development Testbench Component is the de-facto package that has been designed to help you write tests for your La

Orchestra Platform 1.9k Dec 29, 2022
🥳🔐 This package is a Laravel package that checks if an email address is a spammer

This package is a Laravel package that checks if an email address is a spammer. It verifies your signups and form submissions to confirm that they are legitimate.

Endurance, the Martian 15 Dec 19, 2022
Laravel package to use the notion API

Package to work with Notion API from Laravel This package helps you to use the notion API from Laravel. Installation You can install the package via c

64 Robots 11 Jun 6, 2021
Laravel wrapper package for the Aimon.it API

Laravel Aimon Package A laravel wrapper package for the Aimon.it API. For more information see Aimon Requirements Laravel 6 or later Installation Inst

Ruslan 3 Aug 7, 2022