yadahan / laravel-cardcom by yadahan

Laravel Cardcom provides an expressive, fluent interface to Cardcom's billing services.
8,061
3
2
Package Data
Maintainer Username: yadahan
Maintainer Contact: yakidehan@gmail.com (Yaakov Dahan)
Package Create Date: 2017-07-26
Package Last Update: 2020-11-23
Language: PHP
License: MIT
Last Refreshed: 2024-11-23 03:06:02
Package Statistics
Total Downloads: 8,061
Monthly Downloads: 46
Daily Downloads: 0
Total Stars: 3
Total Watchers: 2
Total Forks: 5
Total Open Issues: 0

Laravel Cardcom

Build Status StyleCI Total Downloads GitHub license

Installation

Note: Laravel Cardcom is currently in beta.

Laravel Cardcom requires Laravel 5.4 or higher, and PHP 7.0+. You may use Composer to install Laravel Cardcom into your Laravel project:

composer require yadahan/laravel-cardcom

Configuration

Laravel 5.5 and higher the service provider and facade will automatically get registered.

In Laravel 5.4, after installing the Laravel Cardcom, register the Yadahan\Cardcom\CardcomServiceProvider in your config/app.php configuration file:

'providers' => [
    // Other service providers...

    Yadahan\Cardcom\CardcomServiceProvider::class,
],

Also, add the Cardcom facade to the aliases array in your app configuration file:

'Cardcom' => Yadahan\Cardcom\Facades\Cardcom::class,

Next, publish its config using the vendor:publish Artisan command:

php artisan vendor:publish --tag="cardcom-config"

You will also need to add credentials for your terminal. These credentials should be placed in your config/cardcom.php configuration file, For example:

'terminals' => [
    'default' => [
        'terminal' => 'your-terminal',
        'username' => 'your-username',
        'api_name' => 'your-api-name',
        'api_password' => 'your-api-password',
    ]
]

Basic Usage

Charge a credit card:

Cardcom::card('4580000000000000', '01', '2020')->charge(10, 'ILS');
// With optional payments parameter
Cardcom::card('4580000000000000', '01', '2020')->charge(10, 'ILS', 3);

Refund a credit card:

Cardcom::card('4580000000000000', '01', '2020')->refund(10, 'ILS');
// With optional payments parameter
Cardcom::card('4580000000000000', '01', '2020')->refund(10, 'ILS', 3);

Cancel a transaction:

// The first (required) parameter is the transaction number
// The second (optional, default false) parameter, is cancel or refund transaction
Cardcom::cancel('12345678', true);
// With optional pertialy amount parameter (The second parameter must be false)
Cardcom::cancel('12345678', false, 10);

Create a credit card token:

Cardcom::card('4580000000000000', '01', '2020')->createToken();

Create and charge a credit card token:

$response = Cardcom::card('4580000000000000', '01', '2020')->createToken();

Cardcom::token($response['token'], '01', '2020')->charge(10, 'ILS');

Charge and create invoice

Cardcom::card('4580000000000000', '01', '2020')->charge(10, 'ILS')
    ->invoice([
        'customer_name'    => 'Test Test',
        'send_email'       => 'true',
        'invoice_language' => 'he',
        'email'            => 'test@test.com',
        'address_1'        => 'Address line 1',
        'address_2'        => 'Address line 2',
        'city'             => 'Test city',
        'phone'            => '031234567',
        'mobile'           => '0501234567',
        'customer_id'      => '1',
        'comments'         => 'Test comments',
        'currency'         => 'ILS',
        'vat_free'         => 'false',
        'account'          => 'true',
        'key'              => '1',
    ])
    ->invoiceItem([
        'description' => 'Test Product 1',
        'price'       => '10',
        'quantity'    => '1',
        'id'          => '1',
        'vat_free'    => 'false',
    ]);

Of course you can config the terminal you want to use:

Cardcom::setConfig(config('cardcom.terminals.other'))->card('4580000000000000', '01', '2020')->charge(10, 'ILS');
// Or
Cardcom::setConfig(['terminal' => '1000', 'username' => 'barak9611'])->card('4580000000000000', '01', '2020')->charge(10, 'ILS');

Contributing

Thank you for considering contributing to the Laravel Cardcom.

License

Laravel Cardcom is open-sourced software licensed under the MIT license.