yadahan / laravel-cardcom
Laravel Cardcom 提供了一种表达性和流畅的接口,用于 Cardcom 的账单服务。
v0.4.2
2020-11-23 13:35 UTC
Requires
- php: >=7.0
- guzzlehttp/guzzle: ~7.0
Requires (Dev)
- phpunit/phpunit: ~9.0
README
安装
注意: Laravel Cardcom 目前处于测试版。
Laravel Cardcom 需要 Laravel 5.4 或更高版本,以及 PHP 7.0+。您可以使用 Composer 将 Laravel Cardcom 安装到您的 Laravel 项目中
composer require yadahan/laravel-cardcom
配置
Laravel 5.5 及更高版本中,服务提供者和外观将自动注册。
在 Laravel 5.4 中,安装 Laravel Cardcom 后,请在您的 config/app.php
配置文件中注册 Yadahan\Cardcom\CardcomServiceProvider
'providers' => [ // Other service providers... Yadahan\Cardcom\CardcomServiceProvider::class, ],
此外,将 Cardcom
外观添加到您的 app
配置文件中的 aliases
数组中
'Cardcom' => Yadahan\Cardcom\Facades\Cardcom::class,
接下来,使用 vendor:publish
Artisan 命令发布其配置
php artisan vendor:publish --tag="cardcom-config"
您还需要为终端添加凭证。这些凭证应放在您的 config/cardcom.php
配置文件中,例如
'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 (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);
创建信用卡令牌
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' => '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', ]);
当然,您可以配置您想要的终端
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');
贡献
感谢您考虑为 Laravel Cardcom 贡献。
许可证
Laravel Cardcom 是开源软件,根据 MIT 许可证 许可。