Skip to content

Commit 4ee345e

Browse files
committed
Fixed Code
Fixed Code
1 parent 009b17a commit 4ee345e

File tree

1 file changed

+32
-28
lines changed

1 file changed

+32
-28
lines changed

src/Veritrans.php

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ public function getStatus($id)
5858
*/
5959
public function vtWebCharge($payload)
6060
{
61-
$result = \Codenom\Midtrans\Parse\JSONParse::decodeToObject(
62-
\Codenom\Midtrans\Constant::CURL_TYPE_POST,
63-
$this->veritrans->getBaseUrl() . '/charge',
64-
$this->config->serverKey,
65-
$payload
66-
);
67-
68-
return $result->redirect_url;
61+
return \Codenom\Midtrans\Parse\JSONParse::decodeToObject(
62+
APIMidtrans::call(
63+
\Codenom\Midtrans\Constant::CURL_TYPE_POST,
64+
$this->veritrans->getBaseUrl() . '/charge',
65+
$this->config->serverKey,
66+
$payload
67+
)
68+
)->redirect_url;
6969
}
7070

7171
/**
@@ -80,10 +80,12 @@ public function vtWebCharge($payload)
8080
public function vtWebDirectCharge($payload)
8181
{
8282
return \Codenom\Midtrans\Parse\JSONParse::decodeToObject(
83-
\Codenom\Midtrans\Constant::CURL_TYPE_POST,
84-
$this->veritrans->getBaseUrl() . '/charge',
85-
$this->config->serverKey,
86-
$payload
83+
APIMidtrans::call(
84+
\Codenom\Midtrans\Constant::CURL_TYPE_POST,
85+
$this->veritrans->getBaseUrl() . '/charge',
86+
$this->config->serverKey,
87+
$payload
88+
)
8789
);
8890
}
8991

@@ -94,17 +96,17 @@ public function vtWebDirectCharge($payload)
9496
*
9597
* @var Type CURL POST = \Codenom\Midtrans\Constant::CURL_TYPE_POST
9698
* @param string $id Order ID or transaction ID
97-
* @return string
99+
* @return Object
98100
*/
99101
public function approve($id)
100102
{
101-
$result = \Codenom\Midtrans\Parse\JSONParse::decodeToObject(
102-
\Codenom\Midtrans\Constant::CURL_TYPE_POST,
103-
$this->veritrans->getBaseUrl() . '/' . $id . '/approve',
104-
$this->config->serverKey
103+
return \Codenom\Midtrans\Parse\JSONParse::decodeToObject(
104+
APIMidtrans::call(
105+
\Codenom\Midtrans\Constant::CURL_TYPE_POST,
106+
$this->veritrans->getBaseUrl() . '/' . $id . '/approve',
107+
$this->config->serverKey
108+
)
105109
);
106-
107-
return $result->status_code;
108110
}
109111

110112
/**
@@ -118,13 +120,13 @@ public function approve($id)
118120
*/
119121
public function cancel($id)
120122
{
121-
$result = \Codenom\Midtrans\Parse\JSONParse::decodeToObject(
122-
\Codenom\Midtrans\Constant::CURL_TYPE_POST,
123-
$this->veritrans->getBaseUrl() . '/' . $id . '/cancel',
124-
$this->config->serverKey
123+
return \Codenom\Midtrans\Parse\JSONParse::decodeToObject(
124+
APIMidtrans::call(
125+
\Codenom\Midtrans\Constant::CURL_TYPE_POST,
126+
$this->veritrans->getBaseUrl() . '/' . $id . '/cancel',
127+
$this->config->serverKey
128+
)
125129
);
126-
127-
return $result->status_code;
128130
}
129131

130132
/**
@@ -139,9 +141,11 @@ public function cancel($id)
139141
public function expire($id)
140142
{
141143
return \Codenom\Midtrans\Parse\JSONParse::decodeToObject(
142-
\Codenom\Midtrans\Constant::CURL_TYPE_POST,
143-
$this->veritrans->getBaseUrl() . '/' . $id . '/expire',
144-
$this->config->serverKey
144+
APIMidtrans::call(
145+
\Codenom\Midtrans\Constant::CURL_TYPE_POST,
146+
$this->veritrans->getBaseUrl() . '/' . $id . '/expire',
147+
$this->config->serverKey
148+
)
145149
);
146150
}
147151
}

0 commit comments

Comments
 (0)