Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RequestStringBuilder modified & add paymentId to Reporting Request #144

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/Iyzipay/Request/ReportingPaymentDetailRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
class ReportingPaymentDetailRequest extends Request
{
private $paymentConversationId;
private $paymentId;

public function getPaymentConversationId()
{
Expand All @@ -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();
}
}
56 changes: 28 additions & 28 deletions src/Iyzipay/RequestStringBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
7 changes: 4 additions & 3 deletions tests/Iyzipay/Tests/RequestStringBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand Down