Skip to content

Commit

Permalink
param integration initial
Browse files Browse the repository at this point in the history
  • Loading branch information
mustapayev committed Jan 12, 2025
1 parent 0bdaefa commit 988d466
Show file tree
Hide file tree
Showing 16 changed files with 651 additions and 1,300 deletions.
7 changes: 2 additions & 5 deletions config/pos_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@
'name' => 'TURK Elektronik Para A.Ş',
'class' => Mews\Pos\Gateways\ParamPos::class,
'gateway_endpoints' => [
//'payment_api' => 'https://testposws.param.com.tr/turkpos.ws/service_turkpos_prod.asmx',
//'payment_api' => 'https://test-dmz.param.com.tr/turkpos.ws/service_turkpos_test.asmx?wsdl',
'payment_api' => 'https://test-dmz.param.com.tr/turkpos.ws/service_turkpos_test.asmx', //xml
'payment_api' => 'https://test-dmz.param.com.tr/turkpos.ws/service_turkpos_test.asmx',
'payment_api_2' => 'https://test-pos.param.com.tr/to.ws/Service_Odeme.asmx',
'gateway_3d_host' => 'https://test-pos.param.com.tr/default.aspx',
//'payment_api' => 'https://test-dmz.param.com.tr:4443/turkpos.ws/service_turkpos_test.asmx?WSDL',
//prod: 'payment_api' => 'https://posws.param.com.tr/turkpos.ws/service_turkpos_prod.asmx?wsdl',
],
],
'payten_v3_hash' => [
Expand Down
14 changes: 6 additions & 8 deletions examples/_common-codes/regular/history.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,15 @@ function createHistoryOrder(string $gatewayClass, array $extraData, string $ip):
// ];
} elseif (\Mews\Pos\Gateways\ParamPos::class === $gatewayClass) {
$order = [
// Gün aralığı 1 günden fazla girilemez
// Gün aralığı 7 günden fazla girilemez
'start_date' => $txTime->modify('-23 hour'),
'end_date' => $txTime,
'end_date' => $txTime->modify('+2 days'),

// optional:
'transaction_type' => \Mews\Pos\PosInterface::TX_TYPE_PAY_AUTH, // TX_TYPE_CANCEL, TX_TYPE_REFUND
'order_status' => 'Başarılı', // Başarılı, Başarısız
// Bu değerler gönderilince API nedense hata veriyor.
// 'transaction_type' => \Mews\Pos\PosInterface::TX_TYPE_PAY_AUTH, // TX_TYPE_CANCEL, TX_TYPE_REFUND
// 'order_status' => 'Başarılı', // Başarılı, Başarısız
];
// ya da batch number ile (batch number odeme isleminden alinan response'da bulunur):
// $order = [
// 'batch_num' => 24,
// ];
}

return $order;
Expand Down
77 changes: 0 additions & 77 deletions examples/_common-codes/regular/order_history.php

This file was deleted.

5 changes: 5 additions & 0 deletions examples/_common-codes/regular/status.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ function createStatusOrder(string $gatewayClass, array $lastResponse, string $ip
}

$order = createStatusOrder(get_class($pos), $session->get('last_response'), $ip);
//$statusOrder = [
// 'id' => 'c4dd4571-c475-4779-b559-79cc54fe8f49', // MerchantOrderId
// // 'currency' => $lastResponse['currency'],
// 'ip' => filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) ? $ip : '127.0.0.1',
//];
dump($order);

$pos->status($order);
Expand Down
14 changes: 14 additions & 0 deletions examples/parampos/_payment_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@
'name' => 'John Doe',
],
// 'visa1' => [
// 'number' => '5421190122090656',
// 'year' => '28',
// 'month' => '04',
// 'cvv' => '916',
// 'name' => 'John Doe',
// ],
// 'visa1' => [
// 'number' => '5406675406675403',
// 'year' => '26',
// 'month' => '12',
// 'cvv' => '000',
// 'name' => 'John Doe',
// ],
// 'visa1' => [
// 'number' => '4508034508034509',
// 'year' => '26',
// 'month' => '12',
Expand Down
17 changes: 1 addition & 16 deletions src/Crypt/ParamPosCrypt.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,11 @@
class ParamPosCrypt extends AbstractCrypt
{
/**
* todo remove?
* {@inheritDoc}
*/
public function create3DHash(AbstractPosAccount $posAccount, array $formInputs): string
{
$hashData = [
$formInputs['clientid'],
$formInputs['oid'],
$formInputs['amount'],
$formInputs['okUrl'],
$formInputs['failUrl'],
$formInputs['islemtipi'],
$formInputs['taksit'],
$formInputs['rnd'],
$posAccount->getStoreKey(),
];

$hashStr = \implode(static::HASH_SEPARATOR, $hashData);

return $this->hashString($hashStr);
throw new NotImplementedException();
}

/**
Expand Down
72 changes: 55 additions & 17 deletions src/DataMapper/RequestDataMapper/ParamPosRequestDataMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function create3DPaymentRequestData(AbstractPosAccount $posAccount, array
'Siparis_ID' => (string) $responseData['orderId'],

Check failure on line 96 in src/DataMapper/RequestDataMapper/ParamPosRequestDataMapper.php

View workflow job for this annotation

GitHub Actions / test (7.4, prefer-stable)

Offset 'orderId' does not exist on array{TP_WMD_Pay: array<string, mixed>}.

Check failure on line 96 in src/DataMapper/RequestDataMapper/ParamPosRequestDataMapper.php

View workflow job for this annotation

GitHub Actions / test (8.0, prefer-stable)

Offset 'orderId' does not exist on array{TP_WMD_Pay: array<string, mixed>}.
];

return ['TP_WMD_Pay' => $requestData];
return $this->wrapSoapEnvelope(['TP_WMD_Pay' => $requestData], $posAccount);
}

/**
Expand All @@ -111,6 +111,9 @@ public function create3DEnrollmentCheckRequestData(AbstractPosAccount $posAccoun
if (PosInterface::MODEL_3D_HOST === $paymentModel) {
return $this->create3DHostEnrollmentCheckRequestData($posAccount, $order);
}
if (null === $creditCard) {
throw new \InvalidArgumentException('Bu işlem için kredi kartı bilgileri gereklidir.');
}
$order = $this->preparePaymentOrder($order);

$requestData = $this->getRequestAccountData($posAccount) + [
Expand Down Expand Up @@ -147,16 +150,16 @@ public function create3DEnrollmentCheckRequestData(AbstractPosAccount $posAccoun

$requestData[$soapAction]['Islem_Hash'] = $this->crypt->createHash($posAccount, $requestData);

return $requestData;
return $this->wrapSoapEnvelope($requestData, $posAccount);
}

public function create3DHostEnrollmentCheckRequestData(AbstractPosAccount $posAccount, array $order): array

Check failure on line 156 in src/DataMapper/RequestDataMapper/ParamPosRequestDataMapper.php

View workflow job for this annotation

GitHub Actions / test (7.4, prefer-stable)

Method Mews\Pos\DataMapper\RequestDataMapper\ParamPosRequestDataMapper::create3DHostEnrollmentCheckRequestData() has parameter $order with no value type specified in iterable type array.

Check failure on line 156 in src/DataMapper/RequestDataMapper/ParamPosRequestDataMapper.php

View workflow job for this annotation

GitHub Actions / test (8.0, prefer-stable)

Method Mews\Pos\DataMapper\RequestDataMapper\ParamPosRequestDataMapper::create3DHostEnrollmentCheckRequestData() has parameter $order with no value type specified in iterable type array.
{
$order = $this->preparePaymentOrder($order);

$requestData = $this->getRequestAccountData($posAccount, PosInterface::MODEL_3D_HOST) + [
// '@xmlns' => 'https://turkodeme.com.tr/',
'@xmlns' => 'https://turkpos.com.tr/',
$requestData = [
'@xmlns' => 'https://turkodeme.com.tr/',
//'@xmlns' => 'https://turkpos.com.tr/',
'Borclu_Tutar' => 'r|'.$this->formatAmount($order['amount']),
// Bu alan editable olsun istiyorsanız başına “e|”, readonly olsun istiyorsanız başına “r|” eklemelisiniz.
'Borclu_Odeme_Tip' => 'r|Diğer',
Expand All @@ -165,6 +168,7 @@ public function create3DHostEnrollmentCheckRequestData(AbstractPosAccount $posAc
'Return_URL' => 'r|'.$order['success_url'],
'Islem_ID' => $this->crypt->generateRandomString(),
'Borclu_Kisi_TC' => '',
'Terminal_ID' => $posAccount->getClientId(),
'Borclu_GSM' => 'r|5555555555',
// = 0 ise tüm taksitler listelenir. > 0 ise sadece o taksit seçeneği listelenir.
//'Taksit' => $this->mapInstallment((int) $order['installment']),
Expand Down Expand Up @@ -192,7 +196,7 @@ public function create3DHostEnrollmentCheckRequestData(AbstractPosAccount $posAc
//$soapAction = PosInterface::CURRENCY_TRY === $order['currency'] ? 'TP_WMD_UCD' : 'TP_Islem_Odeme_WD';
$soapAction = 'TO_Pre_Encrypting_OOS';

return [$soapAction => $requestData];
return $this->wrapSoapEnvelope([$soapAction => $requestData], $posAccount);
}


Expand All @@ -206,6 +210,9 @@ public function create3DHostEnrollmentCheckRequestData(AbstractPosAccount $posAc
public function createNonSecurePaymentRequestData(AbstractPosAccount $posAccount, array $order, string $txType, CreditCardInterface $creditCard): array
{
$order = $this->preparePaymentOrder($order);
if (PosInterface::CURRENCY_TRY !== $order['currency']) {
throw new \LogicException('MODEL_NON_SECURE odeme döviz ödemeleri desteklememektedir.');
}

$requestData = $this->getRequestAccountData($posAccount) + [
'@xmlns' => 'https://turkpos.com.tr/',
Expand Down Expand Up @@ -241,7 +248,7 @@ public function createNonSecurePaymentRequestData(AbstractPosAccount $posAccount

$requestData[$soapAction]['Islem_Hash'] = $this->crypt->createHash($posAccount, $requestData);

return $requestData;
return $this->wrapSoapEnvelope($requestData, $posAccount);
}

//todo
Expand All @@ -262,7 +269,7 @@ public function createNonSecurePostAuthPaymentRequestData(AbstractPosAccount $po
'Siparis_ID' => (string) $order['id'],
];

return ['TP_Islem_Odeme_OnProv_Kapa' => $requestData];
return $this->wrapSoapEnvelope(['TP_Islem_Odeme_OnProv_Kapa' => $requestData], $posAccount);
}

/**
Expand All @@ -277,7 +284,7 @@ public function createStatusRequestData(AbstractPosAccount $posAccount, array $o
'Siparis_ID' => $order['id'],
];

return ['TP_Islem_Sorgulama4' => $requestData];
return $this->wrapSoapEnvelope(['TP_Islem_Sorgulama4' => $requestData], $posAccount);
}

/**
Expand All @@ -294,7 +301,7 @@ public function createCancelRequestData(AbstractPosAccount $posAccount, array $o
'Siparis_ID' => $order['id'],
];

return ['TP_Islem_Iptal_OnProv' => $requestData];
return $this->wrapSoapEnvelope(['TP_Islem_Iptal_OnProv' => $requestData], $posAccount);
}
$requestData = $this->getRequestAccountData($posAccount) + [
'@xmlns' => 'https://turkpos.com.tr/',
Expand All @@ -303,7 +310,7 @@ public function createCancelRequestData(AbstractPosAccount $posAccount, array $o
'Tutar' => $order['amount'],
];

return ['TP_Islem_Iptal_Iade_Kismi2' => $requestData];
return $this->wrapSoapEnvelope(['TP_Islem_Iptal_Iade_Kismi2' => $requestData], $posAccount);
}


Expand All @@ -321,7 +328,7 @@ public function createRefundRequestData(AbstractPosAccount $posAccount, array $o
'Tutar' => $order['amount'],
];

return ['TP_Islem_Iptal_Iade_Kismi2' => $requestData];
return $this->wrapSoapEnvelope(['TP_Islem_Iptal_Iade_Kismi2' => $requestData], $posAccount);
}

/**
Expand Down Expand Up @@ -352,15 +359,15 @@ public function createHistoryRequestData(AbstractPosAccount $posAccount, array $
}
if (isset($data['transaction_type'])) {
if (PosInterface::TX_TYPE_PAY_AUTH === $data['transaction_type']) {
$requestData['Islem_Tipi'] = 'Satış';
$requestData['Islem_Tip'] = 'Satış';
} elseif (PosInterface::TX_TYPE_CANCEL === $data['transaction_type']) {
$requestData['Islem_Tipi'] = 'İptal';
$requestData['Islem_Tip'] = 'İptal';
} elseif (PosInterface::TX_TYPE_REFUND === $data['transaction_type']) {
$requestData['Islem_Tipi'] = 'İade';
$requestData['Islem_Tip'] = 'İade';
}
}

return ['TP_Islem_Izleme' => $requestData];
return $this->wrapSoapEnvelope(['TP_Islem_Izleme' => $requestData], $posAccount);
}

/**
Expand Down Expand Up @@ -388,6 +395,10 @@ public function create3DFormData(?AbstractPosAccount $posAccount, ?array $order,
];
}

if ('' === $extraData['UCD_HTML']) {
throw new \RuntimeException('3D form verisi oluşturulamadı! UCD_HTML değeri boş.');
}

return $extraData['UCD_HTML'];
}

Expand All @@ -399,7 +410,7 @@ public function createCustomQueryRequestData(AbstractPosAccount $posAccount, arr
$soapAction = \array_key_first($requestData);
$requestData[$soapAction] = $requestData[$soapAction] + $this->getRequestAccountData($posAccount);

return $requestData;
return $this->wrapSoapEnvelope($requestData, $posAccount);
}

/**
Expand Down Expand Up @@ -519,4 +530,31 @@ private function formatRequestDateTime(\DateTimeInterface $dateTime): string
{
return $dateTime->format('d.m.Y H:i:s');
}

private function wrapSoapEnvelope(array $data, AbstractPosAccount $posAccount): array
{
if (isset($data['TO_Pre_Encrypting_OOS'])) {
return [
'@xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
'@xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema',
'@xmlns:soap' => 'http://schemas.xmlsoap.org/soap/envelope/',
'soap:Header' => [ // for soap:Header calls header must be before soap:Body
'ServiceSecuritySoapHeader' => [
'@xmlns' => 'https://turkodeme.com.tr/',
'CLIENT_CODE' => $posAccount->getClientId(),
'CLIENT_USERNAME' => $posAccount->getUsername(),
'CLIENT_PASSWORD' => $posAccount->getPassword(),
],
],
'soap:Body' => $data,
];
}

return [
'@xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
'@xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema',
'@xmlns:soap' => 'http://schemas.xmlsoap.org/soap/envelope/',
'soap:Body' => $data,
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ public function mapOrderHistoryResponse(array $rawResponseData): array
}

if (!$isRecurringOrder) {
\usort($transactions, static function (array $tx1, array $tx2): int {
\usort($transactions, static function (array $tx1, array $tx2): int {
if (null !== $tx1['transaction_time'] && null === $tx2['transaction_time']) {
return 1;
}
Expand Down
Loading

0 comments on commit 988d466

Please sign in to comment.