ServerCompletePurchaseRequest::runTransaction()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 11
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 16
rs 9.9
1
<?php
2
3
namespace ByTIC\Omnipay\PlatiOnline\Message;
4
5
use ByTIC\Omnipay\PlatiOnline\Utils\Urls;
6
7
/**
8
 * Class ServerCompletePurchaseRequest
9
 * @package ByTIC\Omnipay\PlatiOnline\Message
10
 *
11
 * @method ServerCompletePurchaseResponse send()
12
 */
13
class ServerCompletePurchaseRequest extends AbstractRequest
14
{
15
    protected $relayMessageKey = 'f_itsn_message';
16
    protected $cryptMessageKey = 'f_crypt_message';
17
18
    use Traits\RelayRequestTrait;
0 ignored issues
show
introduced by
The trait ByTIC\Omnipay\PlatiOnlin...raits\RelayRequestTrait requires some properties which are not provided by ByTIC\Omnipay\PlatiOnlin...CompletePurchaseRequest: $request, $query
Loading history...
19
    use Traits\HasSoapRequestTrait;
0 ignored issues
show
Bug introduced by
The trait ByTIC\Omnipay\PlatiOnlin...its\HasSoapRequestTrait requires the property $faultcode which is not provided by ByTIC\Omnipay\PlatiOnlin...CompletePurchaseRequest.
Loading history...
20
21
    /**
22
     * @return string
23
     */
24
    protected function getSoapAction(): string
25
    {
26
        return 'query';
27
    }
28
29
    /**
30
     * @param \SoapClient $soapClient
31
     * @param array $data
32
     */
33
    protected function runTransaction($soapClient, $data)
34
    {
35
        /** @var \SimpleXMLElement $notification */
36
        $notification = $data['notification'];
37
        $request['f_website'] = (string)$notification->f_login;
0 ignored issues
show
Comprehensibility Best Practice introduced by
$request was never initialized. Although not strictly required by PHP, it is generally a good practice to add $request = array(); before regardless.
Loading history...
38
        $request['f_order_number'] = (string)$notification->f_order_number;
39
        $request['x_trans_id'] = (string)$notification->x_trans_id;
40
        $request['f_action'] = 0;
41
42
        $response = $this->runSoapRequest($soapClient, $request, 'po_query');
43
        $data['notification'] = [
44
            'order' => $response->order,
45
            'transaction' => $response->order->tranzaction,
46
            'payment_token' => $response->po_payment_token
47
        ];
48
        return $data;
49
    }
50
51
    protected function getValidationMessageUrl()
52
    {
53
        return Urls::$itsnXml;
54
    }
55
56
    protected function getSoapRequestValidationUrl(): string
57
    {
58
        return Urls::$queryXml;
59
    }
60
61
    protected function getSoapResponseValidationUrl()
62
    {
63
        return Urls::$queryResponseXml;
64
    }
65
}
66