Passed
Push — master ( 56e3ba...d2a4fa )
by İbrahim
03:24
created

CancelRequestBuilder   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
dl 0
loc 28
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A build() 0 21 1
1
<?php
2
namespace Paranoia\Builder\Posnet;
3
4
use Paranoia\Common\Serializer\Serializer;
5
use Paranoia\Request\Request;
6
7
class CancelRequestBuilder extends BaseRequestBuilder
8
{
9
    const TRANSACTION_TYPE = 'reverse';
10
    const ENVELOPE_NAME    = 'posnetRequest';
11
12
    const TEMPORARY_DEFAULT_TRANSACTION_TYPE ='sale'; //TODO: To be removed.
13
14
    public function build(Request $request)
15
    {
16
        //TODO: Normally, the bank can cancel any type of request
17
        // but we are going to be assumed we can just do 'cancel'
18
        // sale transactions for the first phase.
19
20
        $data = array_merge(
21
            $this->buildBaseRequest($request),
22
            [
23
                self::TRANSACTION_TYPE => [
24
                    'transaction' => self::TEMPORARY_DEFAULT_TRANSACTION_TYPE,
25
                    'hostLogKey' => $request->getTransactionId(),
26
                    //authCode just needed when VFT transaction performed
27
                    // For the other transaction types we can keep it as '000000'
28
                    'authCode' => '000000'
29
                ]
30
            ]
31
        );
32
33
        $serializer = new Serializer(Serializer::XML);
34
        return $serializer->serialize($data, ['root_name' => self::ENVELOPE_NAME]);
35
    }
36
}
37