From 10a14d26a5386aaa3abb3bd2e1278d79bb4ff315 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C4=B1dd=C4=B1k=20Ak=C3=A7ay?= Date: Mon, 3 Jun 2024 23:10:37 +0300 Subject: [PATCH 1/5] =?UTF-8?q?Yorum=20sat=C4=B1rlar=C4=B1=20kald=C4=B1r?= =?UTF-8?q?=C4=B1ld=C4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Payment/Payment.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Payment/Payment.php b/src/Payment/Payment.php index 0050de3..75574d1 100644 --- a/src/Payment/Payment.php +++ b/src/Payment/Payment.php @@ -362,8 +362,7 @@ public function create() { $requestBody = $this->getBody(); $response = $this->callApi('POST', 'odeme/api/get-token', $requestBody); -// return $response->getBody(); -// return json_decode((string) $response->getBody()); + return new PaytrResponse(json_decode((string)$response->getBody(), true)); } } \ No newline at end of file From 177d5cace684b75602b12448d03aacf7138760b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C4=B1dd=C4=B1k=20Ak=C3=A7ay?= Date: Mon, 3 Jun 2024 23:19:17 +0300 Subject: [PATCH 2/5] =?UTF-8?q?Body=20parametreleri=20d=C3=B6k=C3=BCmandak?= =?UTF-8?q?i=20s=C4=B1raya=20getirildi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Payment/Payment.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Payment/Payment.php b/src/Payment/Payment.php index 75574d1..2443f06 100644 --- a/src/Payment/Payment.php +++ b/src/Payment/Payment.php @@ -337,24 +337,25 @@ private function formattedPaymentAmount() private function getBody() { $paymentToken = $this->createPaymentToken(); + return [ 'merchant_id' => $this->credentials['merchant_id'], 'user_ip' => $this->getUserIp(), 'merchant_oid' => $this->getMerchantOid(), 'email' => $this->getEmail(), 'payment_amount' => $this->formattedPaymentAmount(), - 'paytr_token' => $paymentToken, + 'currency' => $this->getCurrency(), 'user_basket' => $this->basket->formatted(), - 'debug_on' => $this->isDebugOn(), 'no_installment' => $this->getNoInstallment(), 'max_installment' => $this->getMaxInstallment(), + 'paytr_token' => $paymentToken, 'user_name' => $this->getUserName(), 'user_address' => $this->getUserAddress(), 'user_phone' => $this->getUserPhone(), 'merchant_ok_url' => $this->options['success_url'], 'merchant_fail_url' => $this->options['fail_url'], - 'currency' => $this->getCurrency(), 'test_mode' => $this->options['test_mode'], + 'debug_on' => $this->isDebugOn(), ]; } From 3f4fd58d84fee8ca41543deb603c686e06344acf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C4=B1dd=C4=B1k=20Ak=C3=A7ay?= Date: Mon, 3 Jun 2024 23:28:08 +0300 Subject: [PATCH 3/5] =?UTF-8?q?d=C3=B6k=C3=BCmanda=20bulunan=20timeout=5Fl?= =?UTF-8?q?imit=20ve=20lang=20parametreleri=20eklendi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Payment/Payment.php | 50 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/Payment/Payment.php b/src/Payment/Payment.php index 2443f06..6a3fc40 100644 --- a/src/Payment/Payment.php +++ b/src/Payment/Payment.php @@ -69,6 +69,16 @@ class Payment extends PaytrClient */ private $currency = Currency::TRY; + /** + * @var int + */ + private $timeoutLimit = 0; + + /** + * @var string + */ + private $lang = 'tr'; + /** * @return string */ @@ -308,6 +318,44 @@ public function setBasket(Basket $basket) return $this; } + /** + * @return int + */ + public function getTimeoutLimit(): int + { + return $this->timeoutLimit; + } + + /** + * @param int $timeoutLimit + * @return self + */ + public function setTimeoutLimit(int $timeoutLimit): self + { + $this->timeoutLimit = $timeoutLimit; + + return $this; + } + + /** + * @return string + */ + public function getLang(): string + { + return $this->lang; + } + + /** + * @param string $lang + * @return self + */ + public function setLang(string $lang): self + { + $this->lang = $lang; + + return $this; + } + private function getHash() { return '' . @@ -356,6 +404,8 @@ private function getBody() 'merchant_fail_url' => $this->options['fail_url'], 'test_mode' => $this->options['test_mode'], 'debug_on' => $this->isDebugOn(), + 'timeout_limit' => $this->getTimeoutLimit(), + 'lang' => $this->getLang(), ]; } From 2f1531277bb38fb1233c06abd3e3dfff9846d6f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C4=B1dd=C4=B1k=20Ak=C3=A7ay?= Date: Mon, 3 Jun 2024 23:34:40 +0300 Subject: [PATCH 4/5] Apply styles --- src/Payment/Payment.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/Payment/Payment.php b/src/Payment/Payment.php index 6a3fc40..8b85544 100644 --- a/src/Payment/Payment.php +++ b/src/Payment/Payment.php @@ -14,46 +14,57 @@ class Payment extends PaytrClient * @var string */ private $userIp; + /** * @var string */ private $merchantOid; + /** * @var string */ private $email; + /** * @var float */ private $paymentAmount; + /** * @var int */ private $noInstallment; + /** * @var int */ private $maxInstallment; + /** * @var string */ private $userName; + /** * @var string */ private $userAddress; + /** * @var string */ private $userPhone; + /** * @var string */ private $successUrl; + /** * @var string */ private $failUrl; + /** * @var bool */ @@ -93,6 +104,7 @@ public function getCurrency(): string public function setCurrency(string $currency) { $this->currency = $currency; + return $this; } @@ -110,6 +122,7 @@ public function getUserIp(): string public function setUserIp(string $userIp) { $this->userIp = $userIp; + return $this; } @@ -127,6 +140,7 @@ public function getMerchantOid(): string public function setMerchantOid(string $merchantOid) { $this->merchantOid = $merchantOid; + return $this; } @@ -144,6 +158,7 @@ public function getEmail(): string public function setEmail(string $email) { $this->email = $email; + return $this; } @@ -161,6 +176,7 @@ public function getPaymentAmount(): float public function setPaymentAmount(float $paymentAmount) { $this->paymentAmount = $paymentAmount; + return $this; } @@ -178,6 +194,7 @@ public function getNoInstallment(): int public function setNoInstallment(int $noInstallment) { $this->noInstallment = $noInstallment; + return $this; } @@ -195,6 +212,7 @@ public function getMaxInstallment(): int public function setMaxInstallment(int $maxInstallment) { $this->maxInstallment = $maxInstallment; + return $this; } @@ -212,6 +230,7 @@ public function getUserName(): string public function setUserName(string $userName) { $this->userName = $userName; + return $this; } @@ -229,6 +248,7 @@ public function getUserAddress(): string public function setUserAddress(string $userAddress) { $this->userAddress = $userAddress; + return $this; } @@ -246,6 +266,7 @@ public function getUserPhone(): string public function setUserPhone(string $userPhone) { $this->userPhone = $userPhone; + return $this; } @@ -263,6 +284,7 @@ public function getSuccessUrl(): string public function setSuccessUrl(string $successUrl) { $this->successUrl = $successUrl; + return $this; } @@ -280,6 +302,7 @@ public function getFailUrl(): string public function setFailUrl(string $failUrl) { $this->failUrl = $failUrl; + return $this; } @@ -297,6 +320,7 @@ public function isDebugOn(): bool public function setDebugOn(bool $debugOn) { $this->debugOn = $debugOn; + return $this; } @@ -315,6 +339,7 @@ public function getBasket(): Basket public function setBasket(Basket $basket) { $this->basket = $basket; + return $this; } @@ -374,6 +399,7 @@ private function getHash() private function createPaymentToken() { $hash = $this->getHash(); + return base64_encode(hash_hmac('sha256', $hash . $this->credentials['merchant_salt'], $this->credentials['merchant_key'], true)); } From 061bf4e78e740723dea85334ef5b3f7f9c04448a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C4=B1dd=C4=B1k=20Ak=C3=A7ay?= Date: Mon, 3 Jun 2024 23:45:15 +0300 Subject: [PATCH 5/5] eof --- src/Payment/Payment.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Payment/Payment.php b/src/Payment/Payment.php index 8b85544..e8c908e 100644 --- a/src/Payment/Payment.php +++ b/src/Payment/Payment.php @@ -442,4 +442,4 @@ public function create() return new PaytrResponse(json_decode((string)$response->getBody(), true)); } -} \ No newline at end of file +}