PHP code example of yadahan / laravel-cardcom

1. Go to this page and download the library: Download yadahan/laravel-cardcom library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

yadahan / laravel-cardcom example snippets


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

    Yadahan\Cardcom\CardcomServiceProvider::class,
],

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

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

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

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

// The first ( (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);

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

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

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

Cardcom::card('4580000000000000', '01', '2020')->charge(10, 'ILS')
    ->invoice([
        'customer_name'    => 'Test Test',
        'send_email'       => 'true',
        'invoice_language' => 'he',
        'email'            => '[email protected]',
        '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',
    ]);

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');