Skip to content

Commit d84dc16

Browse files
committed
[Payzen] Made some api methods public for debugging.
1 parent e2cf9eb commit d84dc16

File tree

5 files changed

+49
-53
lines changed

5 files changed

+49
-53
lines changed

Action/CaptureAction.php

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ class CaptureAction implements ActionInterface, GatewayAwareInterface, GenericTo
2525

2626
/**
2727
* {@inheritdoc}
28+
*
29+
* @param Capture $request
2830
*/
2931
public function execute($request)
3032
{

Action/RefundAction.php

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ class RefundAction implements ActionInterface, GatewayAwareInterface
2121

2222
/**
2323
* {@inheritdoc}
24+
*
25+
* @param Refund $request
2426
*/
2527
public function execute($request)
2628
{

Action/StatusAction.php

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ class StatusAction implements ActionInterface
1616
{
1717
/**
1818
* {@inheritdoc}
19+
*
20+
* @param GetStatusInterface $request
1921
*/
2022
public function execute($request)
2123
{

Action/SyncAction.php

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ class SyncAction implements ActionInterface, GatewayAwareInterface
2121

2222
/**
2323
* {@inheritdoc}
24+
*
25+
* @param Sync $request
2426
*/
2527
public function execute($request)
2628
{

Api/Api.php

+41-53
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,30 @@ public function createRequestUrl(array $data)
115115
}
116116

117117
/**
118-
* Parse the response data.
118+
* Creates the request data.
119119
*
120120
* @param array $data
121121
*
122122
* @return array
123123
*/
124-
public function parseResponseData(array $data)
124+
public function createRequestData(array $data)
125125
{
126+
$data = $this
127+
->getRequestOptionsResolver()
128+
->resolve(array_replace($data, [
129+
'vads_page_action' => 'PAYMENT',
130+
'vads_version' => 'V2',
131+
]));
132+
133+
$data = array_filter($data, function ($value) {
134+
return null !== $value;
135+
});
136+
137+
$data['vads_site_id'] = $this->config['site_id'];
138+
$data['vads_ctx_mode'] = $this->config['ctx_mode'];
139+
140+
$data['signature'] = $this->generateSignature($data);
141+
126142
return $data;
127143
}
128144

@@ -144,6 +160,29 @@ public function checkResponseIntegrity(array $data)
144160
&& $data['signature'] === $this->generateSignature($data);
145161
}
146162

163+
/**
164+
* Generates the signature.
165+
*
166+
* @param array $data
167+
* @param bool $hashed
168+
*
169+
* @return string
170+
*/
171+
public function generateSignature(array $data, $hashed = true)
172+
{
173+
ksort($data);
174+
175+
$content = "";
176+
foreach ($data as $key => $value) {
177+
if (substr($key, 0, 5) == 'vads_') {
178+
$content .= $value . '+';
179+
}
180+
}
181+
$content .= $this->config['certificate'];
182+
183+
return $hashed ? sha1($content) : $content;
184+
}
185+
147186
/**
148187
* Returns the directory path and creates it if not exists.
149188
*
@@ -173,57 +212,6 @@ private function getEndpoint()
173212
return 'https://paiement.systempay.fr/vads-payment/';
174213
}
175214

176-
/**
177-
* Creates the request data.
178-
*
179-
* @param array $data
180-
*
181-
* @return array
182-
*/
183-
private function createRequestData(array $data)
184-
{
185-
$data = $this
186-
->getRequestOptionsResolver()
187-
->resolve(array_replace($data, [
188-
'vads_page_action' => 'PAYMENT',
189-
'vads_version' => 'V2',
190-
]));
191-
192-
$data = array_filter($data, function ($value) {
193-
return null !== $value;
194-
});
195-
196-
$data['vads_site_id'] = $this->config['site_id'];
197-
$data['vads_ctx_mode'] = $this->config['ctx_mode'];
198-
199-
$data['signature'] = $this->generateSignature($data);
200-
201-
return $data;
202-
}
203-
204-
/**
205-
* Generates the signature.
206-
*
207-
* @param array $data
208-
* @param bool $hashed
209-
*
210-
* @return string
211-
*/
212-
private function generateSignature(array $data, $hashed = true)
213-
{
214-
ksort($data);
215-
216-
$content = "";
217-
foreach ($data as $key => $value) {
218-
if (substr($key, 0, 5) == 'vads_') {
219-
$content .= $value . '+';
220-
}
221-
}
222-
$content .= $this->config['certificate'];
223-
224-
return $hashed ? sha1($content) : $content;
225-
}
226-
227215
/**
228216
* Check that the API has been configured.
229217
*

0 commit comments

Comments
 (0)