forked from mewebstudio/pos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kuveyt pos integration - initial commit
- Loading branch information
Showing
17 changed files
with
1,651 additions
and
23 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
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,20 @@ | ||
<?php | ||
|
||
require '../_payment_config.php'; | ||
|
||
$baseUrl = $bankTestsUrl.'/3d/'; | ||
|
||
$account = \Mews\Pos\Factory\AccountFactory::createKuveytPosAccount( | ||
'kuveytpos', | ||
'496', | ||
'apiuser1', | ||
'400235', | ||
'Api1232', | ||
\Mews\Pos\Gateways\AbstractGateway::MODEL_3D_SECURE | ||
); | ||
|
||
$pos = getGateway($account); | ||
|
||
$transaction = \Mews\Pos\Gateways\AbstractGateway::TX_PAY; | ||
|
||
$templateTitle = '3D Model Payment'; |
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,36 @@ | ||
<?php | ||
|
||
use Symfony\Component\HttpFoundation\RedirectResponse; | ||
|
||
require '_config.php'; | ||
|
||
require '../../template/_header.php'; | ||
|
||
if ($request->getMethod() !== 'POST') { | ||
echo new RedirectResponse($baseUrl); | ||
exit(); | ||
} | ||
|
||
$order = getNewOrder($baseUrl, $ip, $request->get('installment')); | ||
|
||
$session->set('order', $order); | ||
|
||
$card = new \Mews\Pos\Entity\Card\CreditCardKuveytPos( | ||
$request->get('number'), | ||
$request->get('year'), | ||
$request->get('month'), | ||
$request->get('cvv'), | ||
$request->get('name'), | ||
$request->get('type') | ||
); | ||
|
||
$pos->prepare($order, $transaction, $card); | ||
|
||
try { | ||
$formData = $pos->get3DFormData(); | ||
} catch (\Exception $e) { | ||
dd($e); | ||
} | ||
|
||
require '../../template/_redirect_form.php'; | ||
require '../../template/_footer.php'; |
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,10 @@ | ||
<?php | ||
|
||
require '_config.php'; | ||
require '../../template/_header.php'; | ||
|
||
$url = $baseUrl.'form.php'; | ||
$card = $testCards['visa1']; | ||
|
||
require '../../template/_credit_card_form.php'; | ||
require '../../template/_footer.php'; |
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,4 @@ | ||
<?php | ||
|
||
$card = null; | ||
require '../../template/_payment_response.php'; |
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,71 @@ | ||
<?php | ||
|
||
use Mews\Pos\Entity\Card\AbstractCreditCard; | ||
use Mews\Pos\Gateways\AbstractGateway; | ||
|
||
require __DIR__.'/../_main_config.php'; | ||
|
||
$bankTestsUrl = $hostUrl.'/kuveytpos'; | ||
|
||
$subMenu = [ | ||
AbstractGateway::MODEL_3D_SECURE => [ | ||
'path' => '/3d/index.php', | ||
'label' => '3D Ödeme', | ||
], | ||
]; | ||
|
||
$installments = [ | ||
0 => 'Peşin', | ||
2 => '2 Taksit', | ||
6 => '6 Taksit', | ||
12 => '12 Taksit', | ||
]; | ||
|
||
function getNewOrder( | ||
string $baseUrl, | ||
string $ip, | ||
?int $installment = 0 | ||
): array { | ||
$successUrl = $baseUrl.'response.php'; | ||
$failUrl = $baseUrl.'response.php'; | ||
|
||
$orderId = date('Ymd').strtoupper(substr(uniqid(sha1(time())), 0, 4)); | ||
|
||
$amount = 10.01; | ||
|
||
$order = [ | ||
'id' => $orderId, | ||
'amount' => $amount, | ||
'installment' => $installment, | ||
'currency' => 'TRY', | ||
'success_url' => $successUrl, | ||
'fail_url' => $failUrl, | ||
'ip' => $ip, | ||
]; | ||
|
||
return $order; | ||
} | ||
|
||
|
||
function doPayment(\Mews\Pos\PosInterface $pos, string $transaction, ?\Mews\Pos\Entity\Card\AbstractCreditCard $card) | ||
{ | ||
if ($pos->getAccount()->getModel() === \Mews\Pos\Gateways\AbstractGateway::MODEL_NON_SECURE | ||
&& \Mews\Pos\Gateways\AbstractGateway::TX_POST_PAY !== $transaction | ||
) { | ||
//bu asamada $card regular/non secure odemede lazim. | ||
$pos->payment($card); | ||
} else { | ||
$pos->payment(); | ||
} | ||
} | ||
|
||
$testCards = [ | ||
'visa1' => new \Mews\Pos\Entity\Card\CreditCardKuveytPos( | ||
'4155650100416111', | ||
25, | ||
1, | ||
'123', | ||
'John Doe', | ||
AbstractCreditCard::CARD_TYPE_VISA | ||
), | ||
]; |
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,6 @@ | ||
<?php | ||
|
||
$templateTitle = 'Kuveyt POS'; | ||
require './_payment_config.php'; | ||
require '../template/_header.php'; | ||
require '../template/_footer.php'; |
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,56 @@ | ||
<?php | ||
|
||
namespace Mews\Pos\Entity\Account; | ||
|
||
/** | ||
* KuveytPosAccount | ||
*/ | ||
class KuveytPosAccount extends AbstractPosAccount | ||
{ | ||
/** | ||
* POS dokumanda response'da SubMerchantId yer aliyor | ||
* ancak kullanimi hakkinda hic bir bilgi yok. | ||
* @var string|null | ||
*/ | ||
protected $subMerchantId; | ||
|
||
/** | ||
* @param string $bank | ||
* @param string $merchantId Mağaza Numarası | ||
* @param string $username POS panelinizden kullanıcı işlemleri sayfasında APİ rolünde kullanıcı oluşturulmalıdır | ||
* @param string $customerId CustomerNumber, Müşteri No | ||
* @param string $storeKey Oluşturulan APİ kullanıcısının şifre bilgisidir. | ||
* @param string $model | ||
* @param string $lang | ||
* @param string|null $subMerchantId | ||
*/ | ||
public function __construct( | ||
string $bank, | ||
string $merchantId, | ||
string $username, | ||
string $customerId, | ||
string $storeKey, | ||
string $model, | ||
string $lang, | ||
?string $subMerchantId = null | ||
) { | ||
parent::__construct($bank, $model, $merchantId, $username, $customerId, $lang, $storeKey); | ||
$this->subMerchantId = $subMerchantId; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function customerId(): string | ||
{ | ||
return $this->password; | ||
} | ||
|
||
/** | ||
* @return string|null | ||
*/ | ||
public function getSubMerchantId(): ?string | ||
{ | ||
return $this->subMerchantId; | ||
} | ||
} |
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,42 @@ | ||
<?php | ||
|
||
namespace Mews\Pos\Entity\Card; | ||
|
||
/** | ||
* Class CreditCardEstPos | ||
*/ | ||
class CreditCardKuveytPos extends AbstractCreditCard | ||
{ | ||
private $cardTypeToCodeMapping = [ | ||
self::CARD_TYPE_VISA => 'Visa', | ||
self::CARD_TYPE_MASTERCARD => 'MasterCard', | ||
]; | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getExpirationDate(): string | ||
{ | ||
return $this->getExpireMonth().$this->getExpireYear(); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getCardCode(): string | ||
{ | ||
if (!isset($this->cardTypeToCodeMapping[$this->type])) { | ||
return $this->type; | ||
} | ||
|
||
return $this->cardTypeToCodeMapping[$this->type]; | ||
} | ||
|
||
/** | ||
* @return string[] | ||
*/ | ||
public function getCardTypeToCodeMapping(): array | ||
{ | ||
return $this->cardTypeToCodeMapping; | ||
} | ||
} |
Oops, something went wrong.