-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from amora2972/laravel-pos-refactoring
comply laravel-pos to the new interface of mews/pos
- Loading branch information
Showing
5 changed files
with
245 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
|
||
|
||
namespace Mews\LaravelPos\Factory; | ||
|
||
|
||
use Mews\Pos\Entity\Account\EstPosAccount; | ||
use Mews\Pos\Entity\Account\GarantiPosAccount; | ||
use Mews\Pos\Entity\Account\PayForAccount; | ||
use Mews\Pos\Entity\Account\PosNetAccount; | ||
use Mews\Pos\Entity\Account\VakifBankAccount; | ||
use Mews\Pos\Exceptions\BankNotFoundException; | ||
|
||
class AccountFactory | ||
{ | ||
const ACCOUNTS = [ | ||
'akbank' => EstPosAccount::class, | ||
'ziraat' => EstPosAccount::class, | ||
'isbank' => EstPosAccount::class, | ||
'finansbank' => EstPosAccount::class, | ||
'halkbank' => EstPosAccount::class, | ||
'teb' => EstPosAccount::class, | ||
'yapikredi' => PosNetAccount::class, | ||
'garanti' => GarantiPosAccount::class, | ||
'qnbfinansbank-payfor' => PayForAccount::class, | ||
'vakifbank' => VakifBankAccount::class, | ||
]; | ||
|
||
public static function create(array $account) | ||
{ | ||
$class = self::ACCOUNTS[$account['bank']] ?? null; | ||
|
||
if (! $class) { | ||
throw new BankNotFoundException(); | ||
} | ||
|
||
$params = [ | ||
$account['bank'], | ||
$account['model'], | ||
$account['client_id'], | ||
]; | ||
|
||
if ($account['bank'] != 'vakifbank') { | ||
$params[] = $account['username']; | ||
} | ||
|
||
$params[] = $account['password']; | ||
|
||
if ($account['bank'] != 'vakifbank') { | ||
$params[] = $account['lang'] ?? 'tr'; | ||
} | ||
|
||
switch ($account['bank']) { | ||
case "garanti": | ||
$params[] = $account['terminal_id']; | ||
$params[] = $account['store_key'] ?? null; | ||
$params[] = $account['refund_username'] ?? null; | ||
$params[] = $account['refund_password'] ?? null; | ||
break; | ||
case "yapikredi": | ||
$params[] = $account['terminal_id']; | ||
$params[] = $account['pos_net_id']; | ||
$params[] = $account['store_key']; | ||
break; | ||
case "vakifbank": | ||
$params[] = $account['terminal_id']; | ||
$params[] = $account['merchant_type'] ?? 0; | ||
$params[] = $account['sub_merchant_id'] ?? null; | ||
} | ||
|
||
if ($account['bank'] != 'vakifbank') { | ||
$params[] = $account['store_key'] ?? null; | ||
} | ||
|
||
return new $class(...$params); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
|
||
namespace Mews\LaravelPos\Factory; | ||
|
||
|
||
use Mews\Pos\Entity\Card\CreditCardEstPos; | ||
use Mews\Pos\Entity\Card\CreditCardGarantiPos; | ||
use Mews\Pos\Entity\Card\CreditCardPayFor; | ||
use Mews\Pos\Entity\Card\CreditCardPosNet; | ||
use Mews\Pos\Entity\Card\CreditCardVakifBank; | ||
use Mews\Pos\Exceptions\BankNotFoundException; | ||
|
||
class CardFactory | ||
{ | ||
const CARDS = [ | ||
'akbank' => CreditCardEstPos::class, | ||
'ziraat' => CreditCardEstPos::class, | ||
'isbank' => CreditCardEstPos::class, | ||
'finansbank' => CreditCardEstPos::class, | ||
'halkbank' => CreditCardEstPos::class, | ||
'teb' => CreditCardEstPos::class, | ||
'yapikredi' => CreditCardPosNet::class, | ||
'garanti' => CreditCardGarantiPos::class, | ||
'qnbfinansbank-payfor' => CreditCardPayFor::class, | ||
'vakifbank' => CreditCardVakifBank::class, | ||
]; | ||
|
||
public static function create(array $card) | ||
{ | ||
$class = self::CARDS[$card['bank']]; | ||
|
||
if (! $class) { | ||
throw new BankNotFoundException(); | ||
} | ||
|
||
$number = $card['number']; | ||
$expireMonth = $card['month']; | ||
$expireYear = $card['year']; | ||
$cvv = $card['cvv']; | ||
$cardHolderName = $card['name'] ?? null; | ||
$cardType = $card['type'] ?? null; | ||
|
||
return new $class($number, $expireYear, $expireMonth, $cvv, $cardHolderName, $cardType); | ||
} | ||
} |
Oops, something went wrong.