Skip to content

Commit 5e0fac2

Browse files
committed
Success/Fail redirect method added
1 parent 8e4c7be commit 5e0fac2

File tree

2 files changed

+70
-2
lines changed

2 files changed

+70
-2
lines changed

src/Message/AbstractRequest.php

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,74 @@ public function setSecretKey($value)
107107
return $this->setParameter('secretKey', $value);
108108
}
109109

110+
/**
111+
* Get the return method.
112+
*
113+
* @return string return method
114+
*/
115+
public function getReturnMethod()
116+
{
117+
return $this->formatMethod($this->getParameter('returnMethod'));
118+
}
119+
120+
/**
121+
* Set the return method.
122+
*
123+
* @param string $value return method
124+
*
125+
* @return self
126+
*/
127+
public function setReturnMethod($value)
128+
{
129+
return $this->setParameter('returnMethod', $value);
130+
}
131+
132+
/**
133+
* Get the cancel method.
134+
*
135+
* @return string cancel method
136+
*/
137+
public function getCancelMethod()
138+
{
139+
return $this->formatMethod($this->getParameter('cancelMethod'));
140+
}
141+
142+
/**
143+
* Set the cancel method.
144+
*
145+
* @param string $value cancel method
146+
*
147+
* @return self
148+
*/
149+
public function setCancelMethod($value)
150+
{
151+
return $this->setParameter('cancelMethod', $value);
152+
}
153+
154+
/**
155+
* Redirect method conversion table.
156+
*/
157+
private static $_methods = [
158+
'1' => '1',
159+
'2' => '2',
160+
'GET' => '0',
161+
'POST' => '1',
162+
'LINK' => '2',
163+
];
164+
165+
/**
166+
* Converts redirect method to WebMoney code: 0, 1 or 2.
167+
*
168+
* @param string $method
169+
*
170+
* @return string
171+
*/
172+
public function formatMethod($method)
173+
{
174+
$method = strtoupper((string)$method);
175+
return isset(self::$_methods[$method]) ? self::$_methods[$method] : '0';
176+
}
177+
110178
/**
111179
* Get the SSL file.
112180
*

src/Message/PurchaseRequest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ public function getData()
3939
'LMI_SIM_MODE' => $this->getTestMode() ? '2' : '0',
4040
'LMI_RESULT_URL' => $this->getNotifyUrl(),
4141
'LMI_SUCCESS_URL' => $this->getReturnUrl(),
42-
'LMI_SUCCESS_METHOD' => '0',
42+
'LMI_SUCCESS_METHOD' => $this->getReturnMethod(),
4343
'LMI_FAIL_URL' => $this->getCancelUrl(),
44-
'LMI_FAIL_METHOD' => '0',
44+
'LMI_FAIL_METHOD' => $this->getCancelMethod(),
4545
);
4646
}
4747

0 commit comments

Comments
 (0)