Skip to content

Commit

Permalink
Merge branch 'master' into 254-kuveytpos-vakifkatilim-undefined-index
Browse files Browse the repository at this point in the history
  • Loading branch information
mustapayev committed Dec 24, 2024
2 parents 1270f47 + a885e33 commit ec3b87c
Show file tree
Hide file tree
Showing 45 changed files with 305 additions and 191 deletions.
12 changes: 9 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
"escapestudios/symfony2-coding-standard": "^3.11",
"monolog/monolog": "^2.8",
"php-http/curl-client": "^2.2",
"phpstan/phpstan": "^1.11",
"phpstan/phpstan-strict-rules": "^1.4",
"phpstan/phpstan": "^2.0",
"phpstan/phpstan-strict-rules": "^2.0",
"phpunit/phpunit": "^9",
"rector/rector": "^1.1",
"rector/rector": "^2.0",
"slim/psr7": "^1.4",
"squizlabs/php_codesniffer": "^3.5",
"symfony/event-dispatcher": "^5.4",
Expand All @@ -57,5 +57,11 @@
"allow-plugins": {
"php-http/discovery": true
}
},
"scripts": {
"test": "./vendor/bin/phpunit --testsuite=unit",
"phpstan": "./vendor/bin/phpstan",
"baseline": "./vendor/bin/phpstan --generate-baseline",
"rector": "./vendor/bin/rector"
}
}
3 changes: 2 additions & 1 deletion docs/PRE-AUTH-POST-EXAMPLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ try {
$order,
$paymentModel,
$transactionType,
$card
$card,
false
);
} catch (\Exception|\Error $e) {
var_dump($e);
Expand Down
3 changes: 2 additions & 1 deletion docs/THREED-PAYMENT-EXAMPLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@ try {
$order,
$paymentModel,
$transactionType,
$card
$card,
false
);
} catch (\InvalidArgumentException $e) {
// örneğin kart bilgisi sağlanmadığında bu exception'i alırsınız.
Expand Down
3 changes: 2 additions & 1 deletion docs/THREED-SECURE-AND-PAY-PAYMENT-IN-MODALBOX-EXAMPLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ try {
$order,
$paymentModel,
$transactionType,
$card
$card,
false
);
} catch (\InvalidArgumentException $e) {
// örneğin kart bilgisi sağlanmadığında bu exception'i alırsınız.
Expand Down
2 changes: 1 addition & 1 deletion examples/_common-codes/3d/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ function (RequestDataPreparedEvent $requestDataPreparedEvent): void {
// ============================================================================================

try {
$formData = $pos->get3DFormData($order, $paymentModel, $transaction, $card);
$formData = $pos->get3DFormData($order, $paymentModel, $transaction, $card, false);
//dd($formData);
} catch (\InvalidArgumentException $e) {
// örneğin kart bilgisi sağlanmadığında bu exception'i alırsınız.
Expand Down
128 changes: 86 additions & 42 deletions phpstan-baseline.neon

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/Crypt/EstV3PosCrypt.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function create3DHash(AbstractPosAccount $posAccount, array $formInputs):
}
}

$formInputs[] = $posAccount->getStoreKey();
$formInputs[] = $posAccount->getStoreKey() ?? '';
// escape | and \ characters
$data = \str_replace("\\", "\\\\", \array_values($formInputs));
$data = \str_replace(self::HASH_SEPARATOR, "\\".self::HASH_SEPARATOR, $data);
Expand Down
2 changes: 1 addition & 1 deletion src/Crypt/PosNetV1PosCrypt.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function createHash(AbstractPosAccount $posAccount, array $requestData):
$threeDSecureData['CavvData'],
$threeDSecureData['Eci'],
$threeDSecureData['MdStatus'],
$posAccount->getStoreKey(),
$posAccount->getStoreKey() ?? '',
];

$hashStr = \implode(static::HASH_SEPARATOR, $hashData);
Expand Down
12 changes: 6 additions & 6 deletions src/DataMapper/RequestDataMapper/KuveytPosRequestDataMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function create3DPaymentRequestData(AbstractPosAccount $posAccount, array
* @param string $txType
* @param CreditCardInterface|null $creditCard
*
* @return array<string, string>
* @return array<string, array<string, string>|int|string>
*
* @throws UnsupportedTransactionTypeException
*/
Expand All @@ -131,16 +131,16 @@ public function create3DEnrollmentCheckRequestData(KuveytPosAccount $kuveytPosAc
//DisplayAmount: Amount değeri ile aynı olacak şekilde gönderilmelidir.
'DisplayAmount' => $this->formatAmount($order['amount']),
'CurrencyCode' => $this->mapCurrency($order['currency']),
'MerchantOrderId' => $order['id'],
'OkUrl' => $order['success_url'],
'FailUrl' => $order['fail_url'],
'MerchantOrderId' => (string) $order['id'],
'OkUrl' => (string) $order['success_url'],
'FailUrl' => (string) $order['fail_url'],
'DeviceData' => [
'ClientIP' => $order['ip'],
'ClientIP' => (string) $order['ip'],
],
];

if ($creditCard instanceof CreditCardInterface) {
$requestData['CardHolderName'] = $creditCard->getHolderName();
$requestData['CardHolderName'] = (string) $creditCard->getHolderName();
$requestData['CardType'] = $this->cardTypeMapping[$creditCard->getType()];
$requestData['CardNumber'] = $creditCard->getNumber();
$requestData['CardExpireDateYear'] = $creditCard->getExpireYear(self::CREDIT_CARD_EXP_YEAR_FORMAT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function create3DPaymentRequestData(AbstractPosAccount $posAccount, array
* @param string $txType
* @param CreditCardInterface|null $creditCard
*
* @return array<string, string>
* @return array<string, string|int>
*/
public function create3DEnrollmentCheckRequestData(KuveytPosAccount $kuveytPosAccount, array $order, string $paymentModel, string $txType, ?CreditCardInterface $creditCard = null): array
{
Expand All @@ -109,13 +109,13 @@ public function create3DEnrollmentCheckRequestData(KuveytPosAccount $kuveytPosAc
'Amount' => $this->formatAmount($order['amount']),
'DisplayAmount' => $this->formatAmount($order['amount']),
'FECCurrencyCode' => $this->mapCurrency($order['currency']),
'MerchantOrderId' => $order['id'],
'OkUrl' => $order['success_url'],
'FailUrl' => $order['fail_url'],
'MerchantOrderId' => (string) $order['id'],
'OkUrl' => (string) $order['success_url'],
'FailUrl' => (string) $order['fail_url'],
];

if ($creditCard instanceof CreditCardInterface) {
$requestData['CardHolderName'] = $creditCard->getHolderName();
$requestData['CardHolderName'] = (string) $creditCard->getHolderName();
$requestData['CardNumber'] = $creditCard->getNumber();
$requestData['CardExpireDateYear'] = $creditCard->getExpireYear(self::CREDIT_CARD_EXP_YEAR_FORMAT);
$requestData['CardExpireDateMonth'] = $creditCard->getExpireMonth(self::CREDIT_CARD_EXP_MONTH_FORMAT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ protected function mapResponseTransactionSecurity(string $mdStatus): string
*
* @param array<string, string> $raw3DAuthResponseData
*
* @return array<string, string>
* @return array<string, mixed>
*/
protected function map3DCommonResponseData(array $raw3DAuthResponseData): array
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ interface NonPaymentResponseMapperInterface
/**
* @param array<string, string> $rawResponseData
*
* @return array<string, string>
* @return array<string, mixed>
*/
public function mapRefundResponse(array $rawResponseData): array;

/**
* @param array<string, string> $rawResponseData
*
* @return array<string, string>
* @return array<string, mixed>
*/
public function mapCancelResponse(array $rawResponseData): array;

Expand All @@ -31,14 +31,14 @@ public function mapStatusResponse(array $rawResponseData): array;
/**
* @param array<string, array<string, string>|string> $rawResponseData
*
* @return array<string, array<string, string|null>>
* @return array<string, mixed>
*/
public function mapHistoryResponse(array $rawResponseData): array;

/**
* @param array<string, array<string, string>|string> $rawResponseData
*
* @return array<string, array<string, string|null>>
* @return array<string, mixed>
*/
public function mapOrderHistoryResponse(array $rawResponseData): array;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface PaymentResponseMapperInterface
* @param string $txType
* @param array<string, mixed> $order
*
* @return array<string, string|float|null>
* @return array<string, mixed>
*/
public function mapPaymentResponse(array $rawPaymentResponseData, string $txType, array $order): array;

Expand All @@ -39,7 +39,7 @@ public function map3DPaymentData(array $raw3DAuthResponseData, ?array $rawPaymen
* @param string $txType
* @param array<string, mixed> $order
*
* @return array<string, string|float|null>
* @return array<string, mixed>
*/
public function map3DPayResponseData(array $raw3DAuthResponseData, string $txType, array $order): array;

Expand All @@ -50,7 +50,7 @@ public function map3DPayResponseData(array $raw3DAuthResponseData, string $txTyp
* @param string $txType
* @param array<string, mixed> $order
*
* @return array<string, string|float|null>
* @return array<string, mixed>
*/
public function map3DHostResponseData(array $raw3DAuthResponseData, string $txType, array $order): array;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ protected function mapResponseTransactionSecurity(string $mdStatus): string
*
* @param array<string, string> $raw3DAuthResponseData
*
* @return array<string, string>
* @return array<string, mixed>
*/
protected function map3DCommonResponseData(array $raw3DAuthResponseData): array
{
Expand Down Expand Up @@ -527,7 +527,7 @@ private function mapSingleOrderHistoryTransaction(array $rawTx): array
* @param string $txType
* @param array<string, mixed> $order
*
* @return array<string, string|float|null>
* @return array<string, mixed>
*/
private function map3DPaymentPaymentResponse(array $rawPaymentResponseData, string $txType, array $order): array
{
Expand Down
2 changes: 1 addition & 1 deletion src/Factory/SerializerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class SerializerFactory
*/
public static function createGatewaySerializer(string $gatewayClass): SerializerInterface
{
/** @var SerializerInterface[] $serializers */
$serializers = [
AkbankPosSerializer::class,
EstPosSerializer::class,
Expand All @@ -48,6 +47,7 @@ public static function createGatewaySerializer(string $gatewayClass): Serializer
VakifKatilimPosSerializer::class,
];

/** @var class-string<SerializerInterface> $serializer */
foreach ($serializers as $serializer) {
if ($serializer::supports($gatewayClass)) {
return new $serializer();
Expand Down
7 changes: 6 additions & 1 deletion src/Gateways/AbstractGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -655,15 +655,20 @@ protected function is3DAuthSuccess(array $responseData): bool
* @param PosInterface::MODEL_3D_* $paymentModel
* @param PosInterface::TX_TYPE_PAY_AUTH|PosInterface::TX_TYPE_PAY_PRE_AUTH $txType
* @param CreditCardInterface|null $card
* @param bool $createWithoutCard
*
* @throws \InvalidArgumentException when inputs are not valid
*/
protected function check3DFormInputs(string $paymentModel, string $txType, CreditCardInterface $card = null): void
protected function check3DFormInputs(string $paymentModel, string $txType, CreditCardInterface $card = null, bool $createWithoutCard = false): void
{
if (!self::isSupportedTransaction($txType, $paymentModel)) {
throw new \LogicException('Bu banka altyapısı sağlanan ödeme modelini ya da işlem tipini desteklenmiyor.');
}

if ($createWithoutCard) {
return;
}

if ((PosInterface::MODEL_3D_SECURE === $paymentModel || PosInterface::MODEL_3D_PAY === $paymentModel)
&& !$card instanceof \Mews\Pos\Entity\Card\CreditCardInterface) {
throw new \InvalidArgumentException('Bu ödeme modeli için kart bilgileri zorunlu!');
Expand Down
4 changes: 2 additions & 2 deletions src/Gateways/AkbankPos.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ public function make3DHostPayment(Request $request, array $order, string $txType
/**
* @inheritDoc
*/
public function get3DFormData(array $order, string $paymentModel, string $txType, CreditCardInterface $creditCard = null): array
public function get3DFormData(array $order, string $paymentModel, string $txType, CreditCardInterface $creditCard = null, bool $createWithoutCard = true): array
{
$this->check3DFormInputs($paymentModel, $txType, $creditCard);
$this->check3DFormInputs($paymentModel, $txType, $creditCard, $createWithoutCard);

$this->logger->debug('preparing 3D form data');

Expand Down
4 changes: 2 additions & 2 deletions src/Gateways/EstPos.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@ public function make3DHostPayment(Request $request, array $order, string $txType
/**
* @inheritDoc
*/
public function get3DFormData(array $order, string $paymentModel, string $txType, CreditCardInterface $creditCard = null): array
public function get3DFormData(array $order, string $paymentModel, string $txType, CreditCardInterface $creditCard = null, bool $createWithoutCard = true): array
{
$this->check3DFormInputs($paymentModel, $txType, $creditCard);
$this->check3DFormInputs($paymentModel, $txType, $creditCard, $createWithoutCard);

$this->logger->debug('preparing 3D form data');

Expand Down
4 changes: 2 additions & 2 deletions src/Gateways/GarantiPos.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ public function make3DPayPayment(Request $request, array $order, string $txType)
/**
* @inheritDoc
*/
public function get3DFormData(array $order, string $paymentModel, string $txType, CreditCardInterface $creditCard = null): array
public function get3DFormData(array $order, string $paymentModel, string $txType, CreditCardInterface $creditCard = null, bool $createWithoutCard = true): array
{
$this->check3DFormInputs($paymentModel, $txType, $creditCard);
$this->check3DFormInputs($paymentModel, $txType, $creditCard, $createWithoutCard);

$this->logger->debug('preparing 3D form data');

Expand Down
4 changes: 2 additions & 2 deletions src/Gateways/InterPos.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ public function orderHistory(array $order): PosInterface
/**
* @inheritDoc
*/
public function get3DFormData(array $order, string $paymentModel, string $txType, CreditCardInterface $creditCard = null): array
public function get3DFormData(array $order, string $paymentModel, string $txType, CreditCardInterface $creditCard = null, bool $createWithoutCard = true): array
{
$this->check3DFormInputs($paymentModel, $txType, $creditCard);
$this->check3DFormInputs($paymentModel, $txType, $creditCard, $createWithoutCard);

$this->logger->debug('preparing 3D form data');

Expand Down
4 changes: 2 additions & 2 deletions src/Gateways/KuveytPos.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ public function orderHistory(array $order): PosInterface
*
* @throws SoapFault
*/
public function get3DFormData(array $order, string $paymentModel, string $txType, CreditCardInterface $creditCard = null): array
public function get3DFormData(array $order, string $paymentModel, string $txType, CreditCardInterface $creditCard = null, bool $createWithoutCard = true): array
{
$this->check3DFormInputs($paymentModel, $txType, $creditCard);
$this->check3DFormInputs($paymentModel, $txType, $creditCard, $createWithoutCard);

$this->logger->debug('preparing 3D form data');

Expand Down
4 changes: 2 additions & 2 deletions src/Gateways/PayFlexCPV4Pos.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ public function orderHistory(array $order): PosInterface
/**
* {@inheritDoc}
*/
public function get3DFormData(array $order, string $paymentModel, string $txType, CreditCardInterface $creditCard = null): array
public function get3DFormData(array $order, string $paymentModel, string $txType, CreditCardInterface $creditCard = null, bool $createWithoutCard = true): array
{
$this->check3DFormInputs($paymentModel, $txType, $creditCard);
$this->check3DFormInputs($paymentModel, $txType, $creditCard, $createWithoutCard);

/** @var array{CommonPaymentUrl: string|null, PaymentToken: string|null, ErrorCode: string|null, ResponseMessage: string|null} $data */
$data = $this->registerPayment($order, $txType, $paymentModel, $creditCard);
Expand Down
2 changes: 1 addition & 1 deletion src/Gateways/PayFlexV4Pos.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public function orderHistory(array $order): PosInterface
/**
* {@inheritDoc}
*/
public function get3DFormData(array $order, string $paymentModel, string $txType, CreditCardInterface $creditCard = null): array
public function get3DFormData(array $order, string $paymentModel, string $txType, CreditCardInterface $creditCard = null, bool $createWithoutCard = true): array
{
$this->check3DFormInputs($paymentModel, $txType, $creditCard);

Expand Down
4 changes: 2 additions & 2 deletions src/Gateways/PayForPos.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,9 @@ public function orderHistory(array $order): PosInterface
/**
* {@inheritDoc}
*/
public function get3DFormData(array $order, string $paymentModel, string $txType, CreditCardInterface $creditCard = null): array
public function get3DFormData(array $order, string $paymentModel, string $txType, CreditCardInterface $creditCard = null, bool $createWithoutCard = true): array
{
$this->check3DFormInputs($paymentModel, $txType, $creditCard);
$this->check3DFormInputs($paymentModel, $txType, $creditCard, $createWithoutCard);

$this->logger->debug('preparing 3D form data');

Expand Down
7 changes: 5 additions & 2 deletions src/Gateways/PosNet.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public function make3DHostPayment(Request $request, array $order, string $txType
/**
* @inheritDoc
*/
public function get3DFormData(array $order, string $paymentModel, string $txType, CreditCardInterface $creditCard = null): array
public function get3DFormData(array $order, string $paymentModel, string $txType, CreditCardInterface $creditCard = null, bool $createWithoutCard = true): array
{
$this->check3DFormInputs($paymentModel, $txType, $creditCard);

Expand All @@ -177,14 +177,17 @@ public function get3DFormData(array $order, string $paymentModel, string $txType

$this->logger->debug('preparing 3D form data');

/** @var array{data1: string, data2: string, sign: string} $responseData */
$responseData = $data['oosRequestDataResponse'];

return $this->requestDataMapper->create3DFormData(
$this->account,
$order,
$paymentModel,
$txType,
$this->get3DGatewayURL($paymentModel),
null,
$data['oosRequestDataResponse']
$responseData
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Gateways/PosNetV1Pos.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ public function make3DHostPayment(Request $request, array $order, string $txType
/**
* @inheritDoc
*/
public function get3DFormData(array $order, string $paymentModel, string $txType, CreditCardInterface $creditCard = null): array
public function get3DFormData(array $order, string $paymentModel, string $txType, CreditCardInterface $creditCard = null, bool $createWithoutCard = true): array
{
$this->check3DFormInputs($paymentModel, $txType, $creditCard);
$this->check3DFormInputs($paymentModel, $txType, $creditCard, $createWithoutCard);

$this->logger->debug('preparing 3D form data');

Expand Down
Loading

0 comments on commit ec3b87c

Please sign in to comment.