From 10380153485ea4d28dc2cbdd3cb0020a4338cdba Mon Sep 17 00:00:00 2001 From: Kadri Demir Date: Thu, 28 Jan 2021 12:47:48 +0300 Subject: [PATCH 1/2] RequestStringBuilder modified & add paymentId to Reporting Request --- .../Request/ReportingPaymentDetailRequest.php | 12 ++++ src/Iyzipay/RequestStringBuilder.php | 56 +++++++++---------- .../ReportingPaymentDetailRequestTest.php | 2 + .../Tests/RequestStringBuilderTest.php | 7 ++- 4 files changed, 46 insertions(+), 31 deletions(-) diff --git a/src/Iyzipay/Request/ReportingPaymentDetailRequest.php b/src/Iyzipay/Request/ReportingPaymentDetailRequest.php index 2c238d02..c4e8c99d 100644 --- a/src/Iyzipay/Request/ReportingPaymentDetailRequest.php +++ b/src/Iyzipay/Request/ReportingPaymentDetailRequest.php @@ -8,6 +8,7 @@ class ReportingPaymentDetailRequest extends Request { private $paymentConversationId; + private $paymentId; public function getPaymentConversationId() { @@ -19,10 +20,21 @@ public function setPaymentConversationId($paymentConversationId) $this->paymentConversationId = $paymentConversationId; } + public function getPaymentId() + { + return $this->paymentId; + } + + public function setPaymentId($paymentId) + { + $this->paymentId = $paymentId; + } + public function getJsonObject() { return JsonBuilder::fromJsonObject(parent::getJsonObject()) ->add("paymentConversationId", $this->getPaymentConversationId()) + ->add("paymentId", $this->getPaymentId()) ->getObject(); } } \ No newline at end of file diff --git a/src/Iyzipay/RequestStringBuilder.php b/src/Iyzipay/RequestStringBuilder.php index 13682a77..87da6280 100644 --- a/src/Iyzipay/RequestStringBuilder.php +++ b/src/Iyzipay/RequestStringBuilder.php @@ -140,101 +140,101 @@ public function getRequestString() public static function requestToStringQuery(Request $request, $type = null) { - $stringQuery = false; + $params = array(); if($request->getConversationId()) { - $stringQuery = "?conversationId=" . $request->getConversationId(); + $params["conversationId"] = $request->getConversationId(); } if($request->getLocale()) { - $stringQuery .= "&locale=" . $request->getLocale(); + $params["locale"] = $request->getLocale(); } if($type == 'defaultParams' ) { if($request->getConversationId()) { - $stringQuery = "?conversationId=" . $request->getConversationId(); - $stringQuery .= ($request->getLocale()) ? ("&locale=" . $request->getLocale()) : ''; - }else{ - $stringQuery = ($request->getLocale()) ? ("?locale=" . $request->getLocale()) : ''; + $params["conversationId"] = $request->getConversationId(); } } if($type == 'reporting') { if($request->getPaymentConversationId()) { - $stringQuery .= "?paymentConversationId=" . $request->getPaymentConversationId(); + $params["paymentConversationId"] = $request->getPaymentConversationId(); + } + if($request->getPaymentId()) { + $params["paymentId"] = $request->getPaymentId(); } } if($type == 'reportingTransaction') { if($request->getTransactionDate()) { - $stringQuery .= "&transactionDate=" . $request->getTransactionDate(); + $params["transactionDate"] = $request->getTransactionDate(); } if ($request->getPage()) { - $stringQuery .= "&page=" . $request->getPage(); + $params["page"] = $request->getPage(); } } if($type == 'subscriptionItems' ) { if ($request->getPage()) { - $stringQuery = "?page=" . $request->getPage(); + $params["page"] = $request->getPage(); } if ($request->getCount()) { - $stringQuery .= "&count=" . $request->getCount(); + $params["count"] = $request->getCount(); } if($request->getConversationId()) { - $stringQuery .= "&conversationId=" . $request->getConversationId(); + $params["conversationId"] = $request->getConversationId(); } if($request->getLocale()) { - $stringQuery .= "&locale=" . $request->getLocale(); + $params["locale"] = $request->getLocale(); } } if($type == 'searchSubscription') { if($request->getPage()){ - $stringQuery = "?page=".$request->getPage(); + $params["page"] =$request->getPage(); } if($request->getCount()){ - $stringQuery .= "&count=".$request->getCount(); + $params["count"] =$request->getCount(); } if($request->getSubscriptionReferenceCode()){ - $stringQuery .= "&subscriptionReferenceCode=".$request->getSubscriptionReferenceCode(); + $params["subscriptionReferenceCode"] =$request->getSubscriptionReferenceCode(); } if($request->getParentReferenceCode()){ - $stringQuery .= "&parentReferenceCode=".$request->getParentReferenceCode(); + $params["parentReferenceCode"] =$request->getParentReferenceCode(); } if($request->getCustomerReferenceCode()){ - $stringQuery .= "&customerReferenceCode=".$request->getCustomerReferenceCode(); + $params["customerReferenceCode"] =$request->getCustomerReferenceCode(); } if($request->getPricingPlanReferenceCode()){ - $stringQuery .= "&pricingPlanReferenceCode=".$request->getPricingPlanReferenceCode(); + $params["pricingPlanReferenceCode"] =$request->getPricingPlanReferenceCode(); } if($request->getSubscriptionStatus()){ - $stringQuery .= "&subscriptionStatus=".$request->getSubscriptionStatus(); + $params["subscriptionStatus"] =$request->getSubscriptionStatus(); } if($request->getStartDate()){ - $stringQuery .= "&startDate=".$request->getStartDate(); + $params["startDate"] =$request->getStartDate(); } if($request->getEndDate()){ - $stringQuery .= "&endDate=".$request->getEndDate(); + $params["endDate"] =$request->getEndDate(); } if($request->getConversationId()) { - $stringQuery .= "&conversationId=" . $request->getConversationId(); + $params["conversationId"] = $request->getConversationId(); } if($request->getLocale()) { - $stringQuery .= "&locale=" . $request->getLocale(); + $params["locale"] = $request->getLocale(); } } if($type == 'pages') { if ($request->getPage()) { - $stringQuery .= "&page=" . $request->getPage(); + $params["page"] = $request->getPage(); } if ($request->getCount()) { - $stringQuery .= "&count=" . $request->getCount(); + $params["count"] = $request->getCount(); } } - + $stringQuery = (!empty($params)?"?":"").http_build_query($params); return $stringQuery; } } \ No newline at end of file diff --git a/tests/Iyzipay/Tests/Request/ReportingPaymentDetailRequestTest.php b/tests/Iyzipay/Tests/Request/ReportingPaymentDetailRequestTest.php index 0e699b6d..4a32fa6c 100644 --- a/tests/Iyzipay/Tests/Request/ReportingPaymentDetailRequestTest.php +++ b/tests/Iyzipay/Tests/Request/ReportingPaymentDetailRequestTest.php @@ -16,12 +16,14 @@ public function test_should_report_payment_detail_request_object() $this->assertEquals(Locale::TR, $jsonObject["locale"]); $this->assertEquals("123456789", $jsonObject["conversationId"]); $this->assertEquals("123456789", $jsonObject["paymentConversationId"]); + $this->assertEquals("1234", $jsonObject["paymentId"]); } private function prepareRequest() { $request = new ReportingPaymentDetailRequest(); $request->setLocale(\Iyzipay\Model\Locale::TR); + $request->setPaymentId("1234"); $request->setConversationId("123456789"); $request->setPaymentConversationId("123456789"); diff --git a/tests/Iyzipay/Tests/RequestStringBuilderTest.php b/tests/Iyzipay/Tests/RequestStringBuilderTest.php index e5c2d66e..6eaec82b 100644 --- a/tests/Iyzipay/Tests/RequestStringBuilderTest.php +++ b/tests/Iyzipay/Tests/RequestStringBuilderTest.php @@ -36,9 +36,10 @@ public function test_should_request_string_query_reporting() $request->setLocale(Locale::TR); $request->setConversationId("123456789"); $request->setPaymentConversationId('123456789'); + $request->setPaymentId('1234'); $result = RequestStringBuilder::requestToStringQuery($request, 'reporting'); - $this->assertEquals("?conversationId=123456789&locale=tr?paymentConversationId=123456789", $result); + $this->assertEquals("?conversationId=123456789&locale=tr&paymentConversationId=123456789&paymentId=1234", $result); } public function test_should_request_string_query_reporting_transaction() @@ -69,7 +70,7 @@ public function test_should_request_string_query_subscription_search() $request->setConversationId("123456789"); $result = RequestStringBuilder::requestToStringQuery($request, 'searchSubscription'); - $this->assertEquals("?page=1&count=10&subscriptionReferenceCode=3579&parentReferenceCode=9876&customerReferenceCode=1234&pricingPlanReferenceCode=c1d489b6&subscriptionStatus=ACTIVE&startDate=2018-10-05&endDate=2019-10-05&conversationId=123456789&locale=tr", $result); + $this->assertEquals("?conversationId=123456789&locale=tr&page=1&count=10&subscriptionReferenceCode=3579&parentReferenceCode=9876&customerReferenceCode=1234&pricingPlanReferenceCode=c1d489b6&subscriptionStatus=ACTIVE&startDate=2018-10-05&endDate=2019-10-05", $result); } public function test_should_request_string_query_subscription_item() @@ -81,7 +82,7 @@ public function test_should_request_string_query_subscription_item() $request->setConversationId("123456789"); $result = RequestStringBuilder::requestToStringQuery($request, 'subscriptionItems'); - $this->assertEquals("?page=1&count=10&conversationId=123456789&locale=tr", $result); + $this->assertEquals("?conversationId=123456789&locale=tr&page=1&count=10", $result); } public function test_should_request_string_query_subscription_default_params() From fbb251b631b208f26c38a016a6bd8c3c6d3f7f3d Mon Sep 17 00:00:00 2001 From: Kadri Demir Date: Fri, 5 Feb 2021 11:06:07 +0300 Subject: [PATCH 2/2] commit for rebuild travis