Conditions | 2 |
Paths | 2 |
Total Lines | 27 |
Code Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Tests | 18 |
CRAP Score | 2 |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
9 | 9 | public function getData() |
|
10 | { |
||
11 | 9 | $this->validate('transactionReference'); |
|
12 | |||
13 | try { |
||
14 | 9 | $transactionReference = simplexml_load_string($this->getTransactionReference()); |
|
15 | 3 | } catch (\Exception $e) { |
|
16 | 3 | throw new InvalidRequestException('Invalid transaction reference'); |
|
17 | } |
||
18 | |||
19 | 6 | $transactionReceipt = $transactionReference->receipt; |
|
20 | |||
21 | 6 | $request = new \SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><request></request>'); |
|
22 | 6 | $request->addChild('store_id', $this->getMerchantId()); |
|
23 | 6 | $request->addChild('api_token', $this->getMerchantKey()); |
|
24 | |||
25 | 6 | $refund = $request->addChild('completion'); |
|
26 | 6 | $refund->addChild('order_id', $transactionReceipt->ReceiptId); |
|
27 | 6 | $refund->addChild('comp_amount', '0.00'); |
|
28 | 6 | $refund->addChild('txn_number', $transactionReceipt->TransID); |
|
29 | 6 | $refund->addChild('crypt_type', $this->getCryptType()); |
|
30 | 6 | $refund->addChild('cust_id', $transactionReceipt->ReferenceNum); |
|
31 | 6 | $refund->addChild('dynamic_descriptor', 'void'); |
|
32 | |||
33 | 6 | $data = $request->asXML(); |
|
34 | |||
35 | 6 | return preg_replace('/\n/', ' ', $data); |
|
36 | } |
||
38 |